blob: 6d9c75ef4906027739cb77b06ce4d1bd93a03b4c [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 Lamaa8e15a2014-02-11 23:30:06 -080023 * Copyright (c) 2012-2014 Qualcomm Atheros, Inc.
24 * All Rights Reserved.
25 * Qualcomm Atheros Confidential and Proprietary.
Kiet Lam1ed83fc2014-02-19 01:15:45 -080026 *
Gopichand Nakkala92f07d82013-01-08 21:16:34 -080027 */
Kiet Lam1ed83fc2014-02-19 01:15:45 -080028
29
Jeff Johnson295189b2012-06-20 16:38:30 -070030/*===========================================================================
31
32
33 W L A N _ Q C T _ T L . C
34
35 OVERVIEW:
36
37 This software unit holds the implementation of the WLAN Transport Layer.
38
39 The functions externalized by this module are to be called ONLY by other
40 WLAN modules that properly register with the Transport Layer initially.
41
42 DEPENDENCIES:
43
44 Are listed for each API below.
45
46
Kiet Lamaa8e15a2014-02-11 23:30:06 -080047 Copyright (c) 2008 QUALCOMM Incorporated.
48 All Rights Reserved.
49 Qualcomm Confidential and Proprietary
Jeff Johnson295189b2012-06-20 16:38:30 -070050===========================================================================*/
51
52/*===========================================================================
53
54 EDIT HISTORY FOR FILE
55
56
57 This section contains comments describing changes made to the module.
58 Notice that changes are listed in reverse chronological order.
59
60
61 $Header$$DateTime$$Author$
62
63
64 when who what, where, why
65---------- --- --------------------------------------------------------
662010-07-13 c_shinde Fixed an issue where WAPI rekeying was failing because
67 WAI frame sent out during rekeying had the protected bit
68 set to 1.
692010-05-06 rnair Changed name of variable from usLlcType to usEtherType
70 Changed function name from GetLLCType to GetEtherType
71 Fixed 802.3 to 802.11 frame translation issue where two
72 bytes of the LLC header was getting overwritten in the
73 non-Qos path
742010-05-06 rnair RxAuth path fix for modifying the header before ether
75 type is retreived (Detected while testing rekeying
76 in WAPI Volans)
772010-02-19 bad Fixed 802.11 to 802.3 ft issues with WAPI
782010-02-19 rnair WAPI: If frame is a WAI frame in TxConn and TxAuth, TL
79 does frame translation.
802010-02-01 rnair WAPI: Fixed a bug where the value of ucIsWapiSta was not
81 being set in the TL control block in the RegisterSTA func.
822010-01-08 lti Added TL Data Caching
832009-11-04 rnair WAPI: Moving common functionality to a seperate function
84 called WLANTL_GetLLCType
852009-10-15 rnair WAPI: Featurizing WAPI code
862009-10-09 rnair WAPI: Modifications to authenticated state handling of Rx data
872009-10-06 rnair Adding support for WAPI
882009-09-22 lti Add deregistration API for management client
892009-07-16 rnair Temporary fix to let TL fetch packets when multiple
90 peers exist in an IBSS
912009-06-10 lti Fix for checking TID value of meta info on TX - prevent
92 memory overwrite
93 Fix for properly checking the sta id for resuming trigger
94 frame generation
952009-05-14 lti Fix for sending out trigger frames
962009-05-15 lti Addr3 filtering
972009-04-13 lti Assert if packet larger then allowed
98 Drop packet that fails flatten
992009-04-02 lti Performance fixes for TL
1002009-02-19 lti Added fix for LLC management on Rx Connect
1012009-01-16 lti Replaced peek data with extract data for non BD opertions
102 Extracted frame control in Tl and pass to HAL for frame
103 type evaluation
1042009-02-02 sch Add handoff support
1052008-12-09 lti Fixes for AMSS compilation
106 Removed assert on receive when there is no station
1072008-12-02 lti Fix fo trigger frame generation
1082008-10-31 lti Fix fo TL tx suspend
1092008-10-01 lti Merged in fixes from reordering
110 Disabled part of UAPSD functionality in TL
111 (will be re-enabled once UAPSD is tested)
112 Fix for UAPSD multiple enable
1132008-08-10 lti Fixes following UAPSD testing
114 Fixed infinite loop on mask computation when STA no reg
1152008-08-06 lti Fixes after QOS unit testing
1162008-08-06 lti Added QOS support
1172008-07-23 lti Fix for vos packet draining
1182008-07-17 lti Fix for data type value
119 Added frame translation code in TL
120 Avoid returning failure to PE in case previous frame is
121 still pending; fail previous and cache new one for tx
122 Get frames returning boolean true if more frames are pending
1232008-07-03 lti Fixes following pre-integration testing
1242008-06-26 lti Fixes following unit testing
125 Added alloc and free for TL context
126 Using atomic set u8 instead of u32
1272008-05-16 lti Created module
128
129===========================================================================*/
130
131/*----------------------------------------------------------------------------
132 * Include Files
133 * -------------------------------------------------------------------------*/
134#include "wlan_qct_tl.h"
135#include "wlan_qct_wda.h"
136#include "wlan_qct_tli.h"
137#include "wlan_qct_tli_ba.h"
138#include "wlan_qct_tl_hosupport.h"
Katya Nigam42e16e82014-02-04 16:28:55 +0530139#include "vos_types.h"
140#include "vos_trace.h"
141#include "wlan_qct_tl_trace.h"
Jeff Johnson295189b2012-06-20 16:38:30 -0700142#include "tlDebug.h"
143#ifdef FEATURE_WLAN_WAPI
144/*Included to access WDI_RxBdType */
145#include "wlan_qct_wdi_bd.h"
146#endif
147/*Enables debugging behavior in TL*/
148#define TL_DEBUG
Hoonki Lee14621352013-04-16 17:51:19 -0700149/*Enables debugging FC control frame in TL*/
150//#define TL_DEBUG_FC
Jeff Johnson295189b2012-06-20 16:38:30 -0700151//#define WLAN_SOFTAP_FLOWCTRL_EN
Jeff Johnson295189b2012-06-20 16:38:30 -0700152//#define BTAMP_TEST
Hoonki Lee14621352013-04-16 17:51:19 -0700153#ifdef TL_DEBUG_FC
154#include <wlan_qct_pal_status.h>
155#include <wlan_qct_pal_device.h> // wpalReadRegister
156#endif
157
Jeff Johnson295189b2012-06-20 16:38:30 -0700158/*----------------------------------------------------------------------------
159 * Preprocessor Definitions and Constants
160 * -------------------------------------------------------------------------*/
161/*LLC header value*/
162static v_U8_t WLANTL_LLC_HEADER[] = {0xAA, 0xAA, 0x03, 0x00, 0x00, 0x00 };
163
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800164#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -0700165/*Aironet SNAP header value*/
166static v_U8_t WLANTL_AIRONET_SNAP_HEADER[] = {0xAA, 0xAA, 0x03, 0x00, 0x40, 0x96, 0x00, 0x00 };
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800167#endif //FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -0700168
169/*BT-AMP packet LLC OUI value*/
170const v_U8_t WLANTL_BT_AMP_OUI[] = {0x00, 0x19, 0x58 };
171
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530172#define WLANTL_MAX_SNR_DATA_SAMPLES 20
Jeff Johnson295189b2012-06-20 16:38:30 -0700173
174#ifdef VOLANS_PERF
175#define WLANTL_BD_PDU_INTERRUPT_ENABLE_THRESHOLD 120
176#define WLANTL_BD_PDU_INTERRUPT_GET_THRESHOLD 120
177
178/* TL BD/PDU threshold to enable interrupt */
179int bdPduInterruptEnableThreshold = WLANTL_BD_PDU_INTERRUPT_ENABLE_THRESHOLD;
180int bdPduInterruptGetThreshold = WLANTL_BD_PDU_INTERRUPT_GET_THRESHOLD;
181#endif /* VOLANS_PERF */
182
183/*-----------------------------------*
184 | Type(2b) | Sub-type(4b) |
185 *-----------------------------------*/
186#define WLANTL_IS_DATA_FRAME(_type_sub) \
187 ( WLANTL_DATA_FRAME_TYPE == ( (_type_sub) & 0x30 ))
188
189#define WLANTL_IS_QOS_DATA_FRAME(_type_sub) \
190 (( WLANTL_DATA_FRAME_TYPE == ( (_type_sub) & 0x30 )) && \
191 ( WLANTL_80211_DATA_QOS_SUBTYPE == ( (_type_sub) & 0xF )))
192
193#define WLANTL_IS_MGMT_FRAME(_type_sub) \
194 ( WLANTL_MGMT_FRAME_TYPE == ( (_type_sub) & 0x30 ))
195
196#define WLANTL_IS_CTRL_FRAME(_type_sub) \
197 ( WLANTL_CTRL_FRAME_TYPE == ( (_type_sub) & 0x30 ))
198
Mohit Khanna698ba2a2012-12-04 15:08:18 -0800199#ifdef FEATURE_WLAN_TDLS
200#define WLANTL_IS_TDLS_FRAME(_eth_type) \
201 ( WLANTL_LLC_TDLS_TYPE == ( _eth_type))
202#endif
203
Jeff Johnson295189b2012-06-20 16:38:30 -0700204/*MAX Allowed len processed by TL - MAx MTU + 802.3 header + BD+DXE+XTL*/
Madan Mohan Koyyalamudia53c4dc2012-11-13 10:35:42 -0800205#define WLANTL_MAX_ALLOWED_LEN (1514 + 100)
Jeff Johnson295189b2012-06-20 16:38:30 -0700206
207#define WLANTL_MASK_AC 0x03
208
Jeff Johnson295189b2012-06-20 16:38:30 -0700209//some flow_control define
210//LWM mode will be enabled for this station if the egress/ingress falls below this ratio
211#define WLANTL_LWM_EGRESS_INGRESS_THRESHOLD (0.75)
212
213//Get enough sample to do the LWM related calculation
214#define WLANTL_LWM_INGRESS_SAMPLE_THRESHOLD (64)
215
216//Maximal on-fly packet per station in LWM mode
217#define WLANTL_STA_BMU_THRESHOLD_MAX (256)
218
219#define WLANTL_AC_MASK (0x7)
Gopichand Nakkala976e3252013-01-03 15:45:56 -0800220#define WLANTL_STAID_OFFSET (0x6)
Jeff Johnson295189b2012-06-20 16:38:30 -0700221
222/* UINT32 type endian swap */
223#define SWAP_ENDIAN_UINT32(a) ((a) = ((a) >> 0x18 ) |(((a) & 0xFF0000) >> 0x08) | \
224 (((a) & 0xFF00) << 0x08) | (((a) & 0xFF) << 0x18))
225
Madan Mohan Koyyalamudi43acf032013-09-27 04:33:28 +0530226/* Maximum value of SNR that can be calculated by the HW */
227#define WLANTL_MAX_HW_SNR 35
Jeff Johnson295189b2012-06-20 16:38:30 -0700228
Jeff Johnson295189b2012-06-20 16:38:30 -0700229/*----------------------------------------------------------------------------
230 * Type Declarations
231 * -------------------------------------------------------------------------*/
232#define TL_LITTLE_BIT_ENDIAN
233
234typedef struct
235{
236
Jeff Johnson295189b2012-06-20 16:38:30 -0700237
238 v_U8_t protVer :2;
239 v_U8_t type :2;
240 v_U8_t subType :4;
241
242 v_U8_t toDS :1;
243 v_U8_t fromDS :1;
244 v_U8_t moreFrag :1;
245 v_U8_t retry :1;
246 v_U8_t powerMgmt :1;
247 v_U8_t moreData :1;
248 v_U8_t wep :1;
249 v_U8_t order :1;
250
Jeff Johnson295189b2012-06-20 16:38:30 -0700251
252} WLANTL_MACFCType;
253
254/* 802.11 header */
255typedef struct
256{
257 /* Frame control field */
258 WLANTL_MACFCType wFrmCtrl;
259
260 /* Duration ID */
261 v_U16_t usDurationId;
262
263 /* Address 1 field */
264 v_U8_t vA1[VOS_MAC_ADDR_SIZE];
265
266 /* Address 2 field */
267 v_U8_t vA2[VOS_MAC_ADDR_SIZE];
268
269 /* Address 3 field */
270 v_U8_t vA3[VOS_MAC_ADDR_SIZE];
271
272 /* Sequence control field */
273 v_U16_t usSeqCtrl;
274
275 // Find the size of the mandatory header size.
276#define WLAN80211_MANDATORY_HEADER_SIZE \
277 (sizeof(WLANTL_MACFCType) + sizeof(v_U16_t) + \
278 (3 * (sizeof(v_U8_t) * VOS_MAC_ADDR_SIZE)) + \
279 sizeof(v_U16_t))
280
281 /* Optional A4 address */
282 v_U8_t optvA4[VOS_MAC_ADDR_SIZE];
283
284 /* Optional QOS control field */
285 v_U16_t usQosCtrl;
286}WLANTL_80211HeaderType;
287
288/* 802.3 header */
289typedef struct
290{
291 /* Destination address field */
292 v_U8_t vDA[VOS_MAC_ADDR_SIZE];
293
294 /* Source address field */
295 v_U8_t vSA[VOS_MAC_ADDR_SIZE];
296
297 /* Length field */
298 v_U16_t usLenType;
299}WLANTL_8023HeaderType;
300
301/*----------------------------------------------------------------------------
302 * Global Data Definitions
303 * -------------------------------------------------------------------------*/
304#define WLAN_TL_INVALID_U_SIG 255
305#define WLAN_TL_INVALID_B_SIG 255
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +0530306#define ENTER() VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO, "Enter:%s", __func__)
307
Jeff Johnson295189b2012-06-20 16:38:30 -0700308#define WLAN_TL_AC_ARRAY_2_MASK( _pSTA, _ucACMask, i ) \
309 do\
310 {\
311 _ucACMask = 0; \
312 for ( i = 0; i < WLANTL_MAX_AC; i++ ) \
313 { \
314 if ( 0 != (_pSTA)->aucACMask[i] ) \
315 { \
316 _ucACMask |= ( 1 << i ); \
317 } \
318 } \
319 } while (0);
320
321/*----------------------------------------------------------------------------
322 * Static Variable Definitions
323 * -------------------------------------------------------------------------*/
324
325/*----------------------------------------------------------------------------
326 * Static Function Declarations and Definitions
327 * -------------------------------------------------------------------------*/
328
329static VOS_STATUS
330WLANTL_GetEtherType
331(
332 v_U8_t * aucBDHeader,
333 vos_pkt_t * vosDataBuff,
334 v_U8_t ucMPDUHLen,
335 v_U16_t * usEtherType
336);
337
Mohit Khanna698ba2a2012-12-04 15:08:18 -0800338#ifdef FEATURE_WLAN_TDLS_INTERNAL
339/* FIXME_MUST: during TDLS integration to main/latest, WLANTL_GetEtherType() conflicts.
340But there is difference. existing WLANTL_GetEtherType() expects vosDataBuff->offset points to MPDU Header,
341wherease TDLS expect vosDataBuff->offset should still points to RxBd.
342So far, data frmae stripped RxBD and passed to data frame handler.
343(RxBd should not be stripped in case TDLS, because it will be eventually routed to mgmt packet
344handler, where RX BD should be preserved)
345To avoid breaking existing functionality, for now, I temporarily rename to
346WLANTL_GetEtherType_2(). Eventually this function should be removed and merged to WLANTL_GetEtherType()
347*/
348static VOS_STATUS
349WLANTL_GetEtherType_2
350(
351 v_U8_t * aucBDHeader,
352 vos_pkt_t * vosDataBuff,
353 v_U8_t ucMPDUHLen,
354 v_U16_t * usEtherType
355);
356#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700357#ifdef FEATURE_WLAN_WAPI
358/*---------------------------------------------------------------------------
359 * Adding a global variable to be used when doing frame translation in TxAuth
360 * state so as to not set the protected bit to 1 in the case of WAI frames
361 *---------------------------------------------------------------------------*/
Madan Mohan Koyyalamudidfd6aa82012-10-18 20:18:43 -0700362v_U8_t gUcIsWai;
Jeff Johnson295189b2012-06-20 16:38:30 -0700363#endif
364
365/*----------------------------------------------------------------------------
366 * Externalized Function Definitions
367* -------------------------------------------------------------------------*/
368
369/*----------------------------------------------------------------------------
370 * Function Declarations and Documentation
371 * -------------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +0530372/*==========================================================================
373
374 FUNCTION WLANTL_FreeClientMemory
375
376 DESCRIPTION
377 It frees up the memory allocated to all the STA clients in TLCB block
378 Can be called inside Close, Stop or when some FAULT occurs
379
380 DEPENDENCIES
381
382 PARAMETERS
383
384 IN
385 pClientSTA: Pointer to the global client pointer array
386
387 RETURN VALUE
388
389 SIDE EFFECTS
390
391============================================================================*/
392void WLANTL_FreeClientMemory
393(WLANTL_STAClientType* pClientSTA[WLAN_MAX_STA_COUNT])
394{
395 v_U32_t i = 0;
396 for(i =0; i < WLAN_MAX_STA_COUNT; i++)
397 {
398 if( NULL != pClientSTA[i] )
399 {
400 vos_mem_free(pClientSTA[i]);
401 }
402 pClientSTA[i] = NULL;
403 }
404 return;
405}
Jeff Johnson295189b2012-06-20 16:38:30 -0700406
407/*==========================================================================
408
409 FUNCTION WLANTL_Open
410
411 DESCRIPTION
412 Called by HDD at driver initialization. TL will initialize all its
413 internal resources and will wait for the call to start to register
414 with the other modules.
415
416 DEPENDENCIES
417
418 PARAMETERS
419
420 IN
421 pvosGCtx: pointer to the global vos context; a handle to TL's
422 control block can be extracted from its context
423 pTLConfig: TL Configuration
424
425 RETURN VALUE
426 The result code associated with performing the operation
427
428 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a page
429 fault
430 VOS_STATUS_SUCCESS: Everything is good :)
431
432 SIDE EFFECTS
433
434============================================================================*/
435VOS_STATUS
436WLANTL_Open
437(
438 v_PVOID_t pvosGCtx,
439 WLANTL_ConfigInfoType* pTLConfig
440)
441{
442 WLANTL_CbType* pTLCb = NULL;
443 v_U8_t ucIndex;
444 tHalHandle smeContext;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +0530445 v_U32_t i = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700446#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
447 VOS_STATUS status = VOS_STATUS_SUCCESS;
448#endif
449 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
450
451 /*------------------------------------------------------------------------
452 Sanity check
453 Extract TL control block
454 ------------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +0530455 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -0700456 vos_alloc_context( pvosGCtx, VOS_MODULE_ID_TL,
457 (void*)&pTLCb, sizeof(WLANTL_CbType));
458
459 pTLCb = VOS_GET_TL_CB(pvosGCtx);
460 if (( NULL == pTLCb ) || ( NULL == pTLConfig ) )
461 {
Madan Mohan Koyyalamudic0e5bd82012-09-18 17:12:27 -0700462 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_FATAL,
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +0530463 "WLAN TL: Invalid input pointer on WLANTL_Open TL %p Config %p", pTLCb, pTLConfig ));
Jeff Johnson295189b2012-06-20 16:38:30 -0700464 return VOS_STATUS_E_FAULT;
465 }
466
Madan Mohan Koyyalamudic0e5bd82012-09-18 17:12:27 -0700467 /* Set the default log level to VOS_TRACE_LEVEL_ERROR */
468 vos_trace_setLevel(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR);
469
Jeff Johnson295189b2012-06-20 16:38:30 -0700470 smeContext = vos_get_context(VOS_MODULE_ID_SME, pvosGCtx);
471 if ( NULL == smeContext )
472 {
473 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700474 "%s: Invalid smeContext", __func__));
Jeff Johnson295189b2012-06-20 16:38:30 -0700475 return VOS_STATUS_E_FAULT;
476 }
477
478 /* Zero out the memory so we are OK, when CleanCB is called.*/
479 vos_mem_zero((v_VOID_t *)pTLCb, sizeof(WLANTL_CbType));
480
481 /*------------------------------------------------------------------------
482 Clean up TL control block, initialize all values
483 ------------------------------------------------------------------------*/
484 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
485 "WLAN TL:WLANTL_Open"));
486
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +0530487 for ( i =0; i<WLAN_MAX_STA_COUNT; i++ )
Jeff Johnson295189b2012-06-20 16:38:30 -0700488 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +0530489 if ( i < WLAN_NON32_STA_COUNT )
490 {
491 pTLCb->atlSTAClients[i] = vos_mem_malloc(sizeof(WLANTL_STAClientType));
492 /* Allocating memory for LEGACY STA COUNT so as to avoid regression issues. */
493 if ( NULL == pTLCb->atlSTAClients[i] )
494 {
495 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR, "WLAN TL: StaClient allocation failed"));
496 WLANTL_FreeClientMemory(pTLCb->atlSTAClients);
497 vos_free_context(pvosGCtx, VOS_MODULE_ID_TL, pTLCb);
498 return VOS_STATUS_E_FAULT;
499 }
500 vos_mem_zero((v_VOID_t *) pTLCb->atlSTAClients[i], sizeof(WLANTL_STAClientType));
501 }
502 else
503 {
504 pTLCb->atlSTAClients[i] = NULL;
505 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700506 }
507
Jeff Johnson295189b2012-06-20 16:38:30 -0700508 pTLCb->reorderBufferPool = vos_mem_malloc(sizeof(WLANTL_REORDER_BUFFER_T) * WLANTL_MAX_BA_SESSION);
509 if (NULL == pTLCb->reorderBufferPool)
510 {
Arif Hussainf2b00992013-11-17 21:46:15 -0800511 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 +0530512 WLANTL_FreeClientMemory(pTLCb->atlSTAClients);
Jeff Johnson295189b2012-06-20 16:38:30 -0700513 vos_free_context(pvosGCtx, VOS_MODULE_ID_TL, pTLCb);
514 return VOS_STATUS_E_FAULT;
Jeff Johnson295189b2012-06-20 16:38:30 -0700515 }
516
517 vos_mem_zero((v_VOID_t *)pTLCb->reorderBufferPool, sizeof(WLANTL_REORDER_BUFFER_T) * WLANTL_MAX_BA_SESSION);
518
519 WLANTL_CleanCB(pTLCb, 0 /*do not empty*/);
520
521 for ( ucIndex = 0; ucIndex < WLANTL_MAX_AC ; ucIndex++)
522 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +0530523 pTLCb->tlConfigInfo.ucAcWeights[ucIndex] = pTLConfig->ucAcWeights[ucIndex];
Jeff Johnson295189b2012-06-20 16:38:30 -0700524 }
525
Dhanashri Atred8c20a32014-01-03 17:20:55 -0800526 for ( ucIndex = 0; ucIndex < WLANTL_MAX_AC ; ucIndex++)
527 {
528 pTLCb->tlConfigInfo.ucReorderAgingTime[ucIndex] = pTLConfig->ucReorderAgingTime[ucIndex];
529 }
530
Jeff Johnson295189b2012-06-20 16:38:30 -0700531 // scheduling init to be the last one of previous round
532 pTLCb->uCurServedAC = WLANTL_AC_BK;
533 pTLCb->ucCurLeftWeight = 1;
534 pTLCb->ucCurrentSTA = WLAN_MAX_STA_COUNT-1;
535
536#if 0
537 //flow control field init
538 vos_mem_zero(&pTLCb->tlFCInfo, sizeof(tFcTxParams_type));
539 //bit 0: set (Bd/pdu count) bit 1: set (request station PS change notification)
540 pTLCb->tlFCInfo.fcConfig = 0x1;
541#endif
542
543 pTLCb->vosTxFCBuf = NULL;
544 pTLCb->tlConfigInfo.uMinFramesProcThres =
545 pTLConfig->uMinFramesProcThres;
Jeff Johnson295189b2012-06-20 16:38:30 -0700546
Sunil Ravid5406f22013-01-22 00:18:31 -0800547#ifdef FEATURE_WLAN_TDLS
548 pTLCb->ucTdlsPeerCount = 0;
549#endif
550
Jeff Johnson295189b2012-06-20 16:38:30 -0700551 pTLCb->tlConfigInfo.uDelayedTriggerFrmInt =
552 pTLConfig->uDelayedTriggerFrmInt;
553
554 /*------------------------------------------------------------------------
555 Allocate internal resources
556 ------------------------------------------------------------------------*/
557 vos_pkt_get_packet(&pTLCb->vosDummyBuf, VOS_PKT_TYPE_RX_RAW, 1, 1,
558 1/*true*/,NULL, NULL);
559
560 WLANTL_InitBAReorderBuffer(pvosGCtx);
561#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
562 /* Initialize Handoff support modue
563 * RSSI measure and Traffic state monitoring */
564 status = WLANTL_HSInit(pvosGCtx);
565 if(!VOS_IS_STATUS_SUCCESS(status))
566 {
567 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
568 "Handoff support module init fail"));
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +0530569 WLANTL_FreeClientMemory(pTLCb->atlSTAClients);
Jeff Johnson295189b2012-06-20 16:38:30 -0700570 vos_mem_free(pTLCb->reorderBufferPool);
571 vos_free_context(pvosGCtx, VOS_MODULE_ID_TL, pTLCb);
572 return status;
573 }
574#endif
575
576 pTLCb->isBMPS = VOS_FALSE;
577 pmcRegisterDeviceStateUpdateInd( smeContext,
578 WLANTL_PowerStateChangedCB, pvosGCtx );
579
580 return VOS_STATUS_SUCCESS;
581}/* WLANTL_Open */
582
583/*==========================================================================
584
585 FUNCTION WLANTL_Start
586
587 DESCRIPTION
588 Called by HDD as part of the overall start procedure. TL will use this
589 call to register with BAL as a transport layer entity.
590
591 DEPENDENCIES
592
593 PARAMETERS
594
595 IN
596 pvosGCtx: pointer to the global vos context; a handle to TL's
597 control block can be extracted from its context
598
599 RETURN VALUE
600 The result code associated with performing the operation
601
602 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a page
603 fault
604 VOS_STATUS_SUCCESS: Everything is good :)
605
606 Other codes can be returned as a result of a BAL failure; see BAL API
607 for more info
608
609 SIDE EFFECTS
610
611============================================================================*/
612VOS_STATUS
613WLANTL_Start
614(
615 v_PVOID_t pvosGCtx
616)
617{
618 WLANTL_CbType* pTLCb = NULL;
619 v_U32_t uResCount = WDA_TLI_MIN_RES_DATA;
620 VOS_STATUS vosStatus;
621 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
622
623 /*------------------------------------------------------------------------
624 Sanity check
625 Extract TL control block
626 ------------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +0530627 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -0700628 pTLCb = VOS_GET_TL_CB(pvosGCtx);
629 if ( NULL == pTLCb )
630 {
631 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
632 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_Start"));
633 return VOS_STATUS_E_FAULT;
634 }
635
636 /*------------------------------------------------------------------------
637 Register with WDA as transport layer client
638 Request resources for tx from bus
639 ------------------------------------------------------------------------*/
640 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
641 "WLAN TL:WLAN TL:WLANTL_Start"));
642
Katya Nigam42e16e82014-02-04 16:28:55 +0530643 tlTraceInit();
Jeff Johnson295189b2012-06-20 16:38:30 -0700644 vosStatus = WDA_DS_Register( pvosGCtx,
645 WLANTL_TxComp,
646 WLANTL_RxFrames,
647 WLANTL_GetFrames,
648 WLANTL_ResourceCB,
649 WDA_TLI_MIN_RES_DATA,
650 pvosGCtx,
651 &uResCount );
652
653 if ( VOS_STATUS_SUCCESS != vosStatus )
654 {
655 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
656 "WLAN TL:TL failed to register with BAL/WDA, Err: %d",
657 vosStatus));
658 return vosStatus;
659 }
660
661 /* Enable transmission */
662 vos_atomic_set_U8( &pTLCb->ucTxSuspended, 0);
663
664 pTLCb->uResCount = uResCount;
Jeff Johnson295189b2012-06-20 16:38:30 -0700665 return VOS_STATUS_SUCCESS;
666}/* WLANTL_Start */
667
668/*==========================================================================
669
670 FUNCTION WLANTL_Stop
671
672 DESCRIPTION
673 Called by HDD to stop operation in TL, before close. TL will suspend all
674 frame transfer operation and will wait for the close request to clean up
675 its resources.
676
677 DEPENDENCIES
678
679 PARAMETERS
680
681 IN
682 pvosGCtx: pointer to the global vos context; a handle to TL's
683 control block can be extracted from its context
684
685 RETURN VALUE
686 The result code associated with performing the operation
687
688 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a page
689 fault
690 VOS_STATUS_SUCCESS: Everything is good :)
691
692 SIDE EFFECTS
693
694============================================================================*/
695VOS_STATUS
696WLANTL_Stop
697(
698 v_PVOID_t pvosGCtx
699)
700{
701 WLANTL_CbType* pTLCb = NULL;
702 v_U8_t ucIndex;
703 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
704
705 /*------------------------------------------------------------------------
706 Sanity check
707 Extract TL control block
708 ------------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +0530709 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -0700710 pTLCb = VOS_GET_TL_CB(pvosGCtx);
711 if ( NULL == pTLCb )
712 {
713 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
714 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_ChangeSTAState"));
715 return VOS_STATUS_E_FAULT;
716 }
717
718 /*------------------------------------------------------------------------
719 Stop TL and empty Station list
720 ------------------------------------------------------------------------*/
721 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
722 "WLAN TL:WLANTL_Stop"));
723
724 /* Disable transmission */
725 vos_atomic_set_U8( &pTLCb->ucTxSuspended, 1);
726
727 if ( NULL != pTLCb->tlMgmtFrmClient.vosPendingDataBuff )
728 {
729 vos_pkt_return_packet(pTLCb->tlMgmtFrmClient.vosPendingDataBuff);
730 pTLCb->tlMgmtFrmClient.vosPendingDataBuff = NULL;
731 }
732
733 if ( NULL != pTLCb->tlBAPClient.vosPendingDataBuff )
734 {
735 vos_pkt_return_packet(pTLCb->tlBAPClient.vosPendingDataBuff);
736 pTLCb->tlBAPClient.vosPendingDataBuff = NULL;
737 }
738
739#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
740 if(VOS_STATUS_SUCCESS != WLANTL_HSStop(pvosGCtx))
741 {
742 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
743 "Handoff Support module stop fail"));
744 }
745#endif
746
747 /*-------------------------------------------------------------------------
748 Clean client stations
749 -------------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +0530750 for ( ucIndex = 0; ucIndex < WLAN_MAX_STA_COUNT; ucIndex++)
Jeff Johnson295189b2012-06-20 16:38:30 -0700751 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +0530752 if ( NULL != pTLCb->atlSTAClients[ucIndex] )
753 {
754 WLANTL_CleanSTA(pTLCb->atlSTAClients[ucIndex], 1 /*empty all queues*/);
755 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700756 }
757
758
759 return VOS_STATUS_SUCCESS;
760}/* WLANTL_Stop */
761
762/*==========================================================================
763
764 FUNCTION WLANTL_Close
765
766 DESCRIPTION
767 Called by HDD during general driver close procedure. TL will clean up
768 all the internal resources.
769
770 DEPENDENCIES
771
772 PARAMETERS
773
774 IN
775 pvosGCtx: pointer to the global vos context; a handle to TL's
776 control block can be extracted from its context
777
778 RETURN VALUE
779 The result code associated with performing the operation
780
781 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a page
782 fault
783 VOS_STATUS_SUCCESS: Everything is good :)
784
785 SIDE EFFECTS
786
787============================================================================*/
788VOS_STATUS
789WLANTL_Close
790(
791 v_PVOID_t pvosGCtx
792)
793{
794 WLANTL_CbType* pTLCb = NULL;
795 tHalHandle smeContext;
796 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
797
798 /*------------------------------------------------------------------------
799 Sanity check
800 Extract TL control block
801 ------------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +0530802 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -0700803 pTLCb = VOS_GET_TL_CB(pvosGCtx);
804 if ( NULL == pTLCb )
805 {
806 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
807 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_ChangeSTAState"));
808 return VOS_STATUS_E_FAULT;
809 }
810 /*------------------------------------------------------------------------
811 Deregister from PMC
812 ------------------------------------------------------------------------*/
813 smeContext = vos_get_context(VOS_MODULE_ID_SME, pvosGCtx);
814 if ( NULL == smeContext )
815 {
816 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700817 "%s: Invalid smeContext", __func__));
Jeff Johnson295189b2012-06-20 16:38:30 -0700818 // continue so that we can cleanup as much as possible
819 }
820 else
821 {
822 pmcDeregisterDeviceStateUpdateInd( smeContext, WLANTL_PowerStateChangedCB );
823 }
824
825#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
826 if(VOS_STATUS_SUCCESS != WLANTL_HSDeInit(pvosGCtx))
827 {
828 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
829 "Handoff Support module DeInit fail"));
830 }
831#endif
832
833 /*------------------------------------------------------------------------
834 Cleanup TL control block.
835 ------------------------------------------------------------------------*/
836 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
837 "WLAN TL: WLANTL_Close"));
838 WLANTL_CleanCB(pTLCb, 1 /* empty queues/lists/pkts if any*/);
839
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +0530840 WLANTL_FreeClientMemory(pTLCb->atlSTAClients);
841
Jeff Johnson295189b2012-06-20 16:38:30 -0700842 vos_mem_free(pTLCb->reorderBufferPool);
843
844 /*------------------------------------------------------------------------
845 Free TL context from VOSS global
846 ------------------------------------------------------------------------*/
847 vos_free_context(pvosGCtx, VOS_MODULE_ID_TL, pTLCb);
848 return VOS_STATUS_SUCCESS;
849}/* WLANTL_Close */
850
851/*----------------------------------------------------------------------------
852 INTERACTION WITH HDD
853 ---------------------------------------------------------------------------*/
854/*==========================================================================
855
856 FUNCTION WLANTL_ConfigureSwFrameTXXlationForAll
857
858 DESCRIPTION
859 Function to disable/enable frame translation for all association stations.
860
861 DEPENDENCIES
862
863 PARAMETERS
864 IN
865 pvosGCtx: VOS context
866 EnableFrameXlation TRUE means enable SW translation for all stations.
867 .
868
869 RETURN VALUE
870
871 void.
872
873============================================================================*/
874void
875WLANTL_ConfigureSwFrameTXXlationForAll
876(
877 v_PVOID_t pvosGCtx,
878 v_BOOL_t enableFrameXlation
879)
880{
881 v_U8_t ucIndex;
882 /*------------------------------------------------------------------------
883 Extract TL control block
884 ------------------------------------------------------------------------*/
885 WLANTL_CbType* pTLCb = VOS_GET_TL_CB(pvosGCtx);
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +0530886 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -0700887 if ( NULL == pTLCb )
888 {
889 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
890 "WLAN TL:Invalid TL pointer from pvosGCtx on "
891 "WLANTL_ConfigureSwFrameTXXlationForAll"));
892 return;
893 }
894
895 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
896 "WLANTL_ConfigureSwFrameTXXlationForAll: Configure SW frameXlation %d",
897 enableFrameXlation));
898
899 for ( ucIndex = 0; ucIndex < WLAN_MAX_TID; ucIndex++)
900 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +0530901 pClientSTA = pTLCb->atlSTAClients[ucIndex];
902 if ( NULL != pClientSTA && 0 != pClientSTA->ucExists )
Jeff Johnson295189b2012-06-20 16:38:30 -0700903 {
904#ifdef WLAN_SOFTAP_VSTA_FEATURE
905 // if this station was not allocated resources to perform HW-based
906 // TX frame translation then force SW-based TX frame translation
907 // otherwise use the frame translation supplied by the client
908 if (!WDA_IsHwFrameTxTranslationCapable(pvosGCtx, ucIndex))
909 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +0530910 pClientSTA->wSTADesc.ucSwFrameTXXlation = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -0700911 }
912 else
913#endif
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +0530914 pClientSTA->wSTADesc.ucSwFrameTXXlation = enableFrameXlation;
Jeff Johnson295189b2012-06-20 16:38:30 -0700915 }
916 }
917}
918
919/*===========================================================================
920
921 FUNCTION WLANTL_StartForwarding
922
923 DESCRIPTION
924
925 This function is used to ask serialization through TX thread of the
926 cached frame forwarding (if statation has been registered in the mean while)
927 or flushing (if station has not been registered by the time)
928
929 In case of forwarding, upper layer is only required to call WLANTL_RegisterSTAClient()
930 and doesn't need to call this function explicitly. TL will handle this inside
931 WLANTL_RegisterSTAClient().
932
933 In case of flushing, upper layer is required to call this function explicitly
934
935 DEPENDENCIES
936
937 TL must have been initialized before this gets called.
938
939
940 PARAMETERS
941
942 ucSTAId: station id
943
944 RETURN VALUE
945
946 The result code associated with performing the operation
947 Please check return values of vos_tx_mq_serialize.
948
949 SIDE EFFECTS
950 If TL was asked to perform WLANTL_CacheSTAFrame() in WLANTL_RxFrames(),
951 either WLANTL_RegisterSTAClient() or this function must be called
952 within reasonable time. Otherwise, TL will keep cached vos buffer until
953 one of this function is called, and may end up with system buffer exhasution.
954
955 It's an upper layer's responsibility to call this function in case of
956 flushing
957
958============================================================================*/
959
960VOS_STATUS
961WLANTL_StartForwarding
962(
963 v_U8_t ucSTAId,
964 v_U8_t ucUcastSig,
965 v_U8_t ucBcastSig
966)
967{
968 vos_msg_t sMessage;
969 v_U32_t uData;
970 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
971
972 /* Signal the OS to serialize our event */
973 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
974 "Serializing TL Start Forwarding Cached for control STA %d",
975 ucSTAId );
976
977 vos_mem_zero( &sMessage, sizeof(vos_msg_t) );
978
979 uData = ucSTAId | (ucUcastSig << 8 ) | (ucBcastSig << 16);
Jeff Johnsond86c05a2013-11-10 18:50:34 -0800980 sMessage.bodyval = uData;
Jeff Johnson295189b2012-06-20 16:38:30 -0700981 sMessage.type = WLANTL_TX_FWD_CACHED;
982
983 return vos_tx_mq_serialize(VOS_MQ_ID_TL, &sMessage);
984
985} /* WLANTL_StartForwarding() */
986
987/*===========================================================================
988
989 FUNCTION WLANTL_AssocFailed
990
991 DESCRIPTION
992
993 This function is used by PE to notify TL that cache needs to flushed'
994 when association is not successfully completed
995
996 Internally, TL post a message to TX_Thread to serialize the request to
997 keep lock-free mechanism.
998
999
1000 DEPENDENCIES
1001
1002 TL must have been initialized before this gets called.
1003
1004
1005 PARAMETERS
1006
1007 ucSTAId: station id
1008
1009 RETURN VALUE
1010
1011 none
1012
1013 SIDE EFFECTS
1014 There may be race condition that PE call this API and send another association
1015 request immediately with same staId before TX_thread can process the message.
1016
1017 To avoid this, we might need PE to wait for TX_thread process the message,
1018 but this is not currently implemented.
1019
1020============================================================================*/
1021void WLANTL_AssocFailed(v_U8_t staId)
1022{
1023 // flushing frames and forwarding frames uses the same message
1024 // the only difference is what happens when the message is processed
1025 // if the STA exist, the frames will be forwarded
1026 // and if it doesn't exist, the frames will be flushed
1027 // in this case we know it won't exist so the DPU index signature values don't matter
1028 if(!VOS_IS_STATUS_SUCCESS(WLANTL_StartForwarding(staId,0,0)))
1029 {
1030 VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001031 " %s fails to start forwarding", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001032 }
1033}
1034
1035 /*===========================================================================
1036
1037 FUNCTION WLANTL_Finish_ULA
1038
1039 DESCRIPTION
1040 This function is used by HDD to notify TL to finish Upper layer authentication
1041 incase the last EAPOL packet is pending in the TL queue.
1042 To avoid the race condition between sme set key and the last EAPOL packet
1043 the HDD module calls this function just before calling the sme_RoamSetKey.
1044
1045 DEPENDENCIES
1046
1047 TL must have been initialized before this gets called.
1048
1049 PARAMETERS
1050
1051 callbackRoutine: HDD Callback function.
1052 callbackContext : HDD userdata context.
1053
1054 RETURN VALUE
1055
1056 VOS_STATUS_SUCCESS/VOS_STATUS_FAILURE
1057
1058 SIDE EFFECTS
1059
1060============================================================================*/
1061
1062VOS_STATUS WLANTL_Finish_ULA( void (*callbackRoutine) (void *callbackContext),
Tushnim Bhattacharyya39a8f182013-02-20 18:10:30 -08001063 void *callbackContext)
Jeff Johnson295189b2012-06-20 16:38:30 -07001064{
Tushnim Bhattacharyya39a8f182013-02-20 18:10:30 -08001065 return WDA_DS_FinishULA( callbackRoutine, callbackContext);
Jeff Johnson295189b2012-06-20 16:38:30 -07001066}
1067
1068
1069/*===========================================================================
1070
1071 FUNCTION WLANTL_RegisterSTAClient
1072
1073 DESCRIPTION
1074
1075 This function is used by HDD to register as a client for data services
1076 with TL. HDD will call this API for each new station that it adds,
1077 thus having the flexibility of registering different callback for each
1078 STA it services.
1079
1080 DEPENDENCIES
1081
1082 TL must have been initialized before this gets called.
1083
1084 Restriction:
1085 Main thread will have higher priority that Tx and Rx threads thus
1086 guaranteeing that a station will be added before any data can be
1087 received for it. (This enables TL to be lock free)
1088
1089 PARAMETERS
1090
1091 pvosGCtx: pointer to the global vos context; a handle to TL's
1092 control block can be extracted from its context
1093 pfnStARx: function pointer to the receive packet handler from HDD
1094 pfnSTATxComp: function pointer to the transmit complete confirmation
1095 handler from HDD
1096 pfnSTAFetchPkt: function pointer to the packet retrieval routine in HDD
1097 wSTADescType: STA Descriptor, contains information related to the
1098 new added STA
1099
1100 RETURN VALUE
1101
1102 The result code associated with performing the operation
1103
1104 VOS_STATUS_E_INVAL: Input parameters are invalid
1105 VOS_STATUS_E_FAULT: Station ID is outside array boundaries or pointer to
1106 TL cb is NULL ; access would cause a page fault
1107 VOS_STATUS_E_EXISTS: Station was already registered
1108 VOS_STATUS_SUCCESS: Everything is good :)
1109
1110 SIDE EFFECTS
1111
1112============================================================================*/
1113VOS_STATUS
1114WLANTL_RegisterSTAClient
1115(
1116 v_PVOID_t pvosGCtx,
1117 WLANTL_STARxCBType pfnSTARx,
1118 WLANTL_TxCompCBType pfnSTATxComp,
1119 WLANTL_STAFetchPktCBType pfnSTAFetchPkt,
1120 WLAN_STADescType* pwSTADescType,
1121 v_S7_t rssi
1122)
1123{
1124 WLANTL_CbType* pTLCb = NULL;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301125 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07001126 v_U8_t ucTid = 0;/*Local variable to clear previous replay counters of STA on all TIDs*/
Jeff Johnson295189b2012-06-20 16:38:30 -07001127 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
1128
1129 /*------------------------------------------------------------------------
1130 Sanity check
1131 ------------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301132 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -07001133 if (( NULL == pwSTADescType ) || ( NULL == pfnSTARx ) ||
1134 ( NULL == pfnSTAFetchPkt ))
1135 {
1136 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1137 "WLAN TL:Invalid parameter sent on WLANTL_RegisterSTAClient"));
1138 return VOS_STATUS_E_INVAL;
1139 }
1140
1141 if ( WLANTL_STA_ID_INVALID( pwSTADescType->ucSTAId ) )
1142 {
1143 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1144 "WLAN TL:Invalid station id requested on WLANTL_RegisterSTAClient"));
1145 return VOS_STATUS_E_FAULT;
1146 }
1147
1148 /*------------------------------------------------------------------------
1149 Extract TL control block
1150 ------------------------------------------------------------------------*/
1151 pTLCb = VOS_GET_TL_CB(pvosGCtx);
1152 if ( NULL == pTLCb )
1153 {
1154 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1155 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_RegisterSTAClient"));
1156 return VOS_STATUS_E_FAULT;
1157 }
1158
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301159 //Code for checking and allocating memory for new STA
1160 if ( NULL == pTLCb->atlSTAClients[pwSTADescType->ucSTAId] ){
1161 pTLCb->atlSTAClients[pwSTADescType->ucSTAId] = vos_mem_malloc(sizeof(WLANTL_STAClientType));
1162 if ( NULL == pTLCb->atlSTAClients[pwSTADescType->ucSTAId] ){
1163 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1164 "WLAN TL: STA Client memory allocation failed in WLANTL_RegisterSTAClient"));
1165 return VOS_STATUS_E_FAILURE;
1166 }
1167 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
1168 "WLAN TL: STA Client memory allocation in WLANTL_RegisterSTAClient"));
1169 vos_mem_zero((v_VOID_t *) pTLCb->atlSTAClients[pwSTADescType->ucSTAId],sizeof(WLANTL_STAClientType));
1170 }
1171
1172 //Assigning the pointer to local variable for easy access in future
1173 pClientSTA = pTLCb->atlSTAClients[pwSTADescType->ucSTAId];
1174 if ( 0 != pClientSTA->ucExists )
Jeff Johnson295189b2012-06-20 16:38:30 -07001175 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301176 pClientSTA->ucExists++;
Jeff Johnson295189b2012-06-20 16:38:30 -07001177 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1178 "WLAN TL:Station was already registered on WLANTL_RegisterSTAClient"));
1179 return VOS_STATUS_E_EXISTS;
1180 }
1181
1182 /*------------------------------------------------------------------------
1183 Register station with TL
1184 ------------------------------------------------------------------------*/
Katya Nigam42e16e82014-02-04 16:28:55 +05301185 MTRACE(vos_trace(VOS_MODULE_ID_TL, TRACE_CODE_TL_REGISTER_STA_CLIENT,
1186 pwSTADescType->ucSTAId, (unsigned )
1187 (*(pwSTADescType->vSTAMACAddress.bytes+2)<<24 |
1188 *(pwSTADescType->vSTAMACAddress.bytes+3)<<16 |
1189 *(pwSTADescType->vSTAMACAddress.bytes+4)<<8 |
1190 *(pwSTADescType->vSTAMACAddress.bytes+5))));
1191
Jeff Johnson295189b2012-06-20 16:38:30 -07001192 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
1193 "WLAN TL:Registering STA Client ID: %d", pwSTADescType->ucSTAId ));
1194
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301195 pClientSTA->pfnSTARx = pfnSTARx;
1196 pClientSTA->pfnSTAFetchPkt = pfnSTAFetchPkt;
Jeff Johnson295189b2012-06-20 16:38:30 -07001197
1198 /* Only register if different from NULL - TL default Tx Comp Cb will
1199 release the vos packet */
1200 if ( NULL != pfnSTATxComp )
1201 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301202 pClientSTA->pfnSTATxComp = pfnSTATxComp;
Jeff Johnson295189b2012-06-20 16:38:30 -07001203 }
1204
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301205 pClientSTA->tlState = WLANTL_STA_INIT;
1206 pClientSTA->tlPri = WLANTL_STA_PRI_NORMAL;
1207 pClientSTA->wSTADesc.ucSTAId = pwSTADescType->ucSTAId;
Gopichand Nakkala8b54e912013-03-11 10:44:21 +05301208 pClientSTA->ptkInstalled = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001209
1210 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
1211 "WLAN TL:Registering STA Client ID: %d with UC %d and BC %d",
1212 pwSTADescType->ucSTAId,
1213 pwSTADescType->ucUcastSig, pwSTADescType->ucBcastSig));
1214
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301215 pClientSTA->wSTADesc.wSTAType = pwSTADescType->wSTAType;
Jeff Johnson295189b2012-06-20 16:38:30 -07001216
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301217 pClientSTA->wSTADesc.ucQosEnabled = pwSTADescType->ucQosEnabled;
Jeff Johnson295189b2012-06-20 16:38:30 -07001218
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301219 pClientSTA->wSTADesc.ucAddRmvLLC = pwSTADescType->ucAddRmvLLC;
Jeff Johnson295189b2012-06-20 16:38:30 -07001220
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301221 pClientSTA->wSTADesc.ucProtectedFrame = pwSTADescType->ucProtectedFrame;
Jeff Johnson295189b2012-06-20 16:38:30 -07001222
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001223#ifdef FEATURE_WLAN_ESE
1224 pClientSTA->wSTADesc.ucIsEseSta = pwSTADescType->ucIsEseSta;
Jeff Johnson295189b2012-06-20 16:38:30 -07001225
1226 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001227 "WLAN TL:Registering STA Client ID: %d QoS %d Add LLC %d ProtFrame %d EseSta %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07001228 pwSTADescType->ucSTAId,
1229 pwSTADescType->ucQosEnabled,
1230 pwSTADescType->ucAddRmvLLC,
1231 pwSTADescType->ucProtectedFrame,
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001232 pwSTADescType->ucIsEseSta));
Jeff Johnson295189b2012-06-20 16:38:30 -07001233#else
1234
1235 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
1236 "WLAN TL:Registering STA Client ID: %d QoS %d Add LLC %d ProtFrame %d",
1237 pwSTADescType->ucSTAId,
1238 pwSTADescType->ucQosEnabled,
1239 pwSTADescType->ucAddRmvLLC,
1240 pwSTADescType->ucProtectedFrame));
1241
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001242#endif //FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07001243#ifdef WLAN_SOFTAP_VSTA_FEATURE
1244 // if this station was not allocated resources to perform HW-based
1245 // TX frame translation then force SW-based TX frame translation
1246 // otherwise use the frame translation supplied by the client
1247
1248 if (!WDA_IsHwFrameTxTranslationCapable(pvosGCtx, pwSTADescType->ucSTAId)
1249 || ( WLAN_STA_BT_AMP == pwSTADescType->wSTAType))
1250 {
1251 pwSTADescType->ucSwFrameTXXlation = 1;
1252 }
1253#endif
1254
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301255 pClientSTA->wSTADesc.ucSwFrameTXXlation = pwSTADescType->ucSwFrameTXXlation;
1256 pClientSTA->wSTADesc.ucSwFrameRXXlation = pwSTADescType->ucSwFrameRXXlation;
Jeff Johnson295189b2012-06-20 16:38:30 -07001257
1258#ifdef FEATURE_WLAN_WAPI
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301259 pClientSTA->wSTADesc.ucIsWapiSta = pwSTADescType->ucIsWapiSta;
Jeff Johnson295189b2012-06-20 16:38:30 -07001260#endif /* FEATURE_WLAN_WAPI */
1261
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301262 vos_copy_macaddr( &pClientSTA->wSTADesc.vSTAMACAddress, &pwSTADescType->vSTAMACAddress);
Jeff Johnson295189b2012-06-20 16:38:30 -07001263
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301264 vos_copy_macaddr( &pClientSTA->wSTADesc.vBSSIDforIBSS, &pwSTADescType->vBSSIDforIBSS);
Jeff Johnson295189b2012-06-20 16:38:30 -07001265
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301266 vos_copy_macaddr( &pClientSTA->wSTADesc.vSelfMACAddress, &pwSTADescType->vSelfMACAddress);
Jeff Johnson295189b2012-06-20 16:38:30 -07001267
Jeff Johnson295189b2012-06-20 16:38:30 -07001268 /* In volans release L replay check is done at TL */
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301269 pClientSTA->ucIsReplayCheckValid = pwSTADescType->ucIsReplayCheckValid;
1270 pClientSTA->ulTotalReplayPacketsDetected = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001271/*Clear replay counters of the STA on all TIDs*/
1272 for(ucTid = 0; ucTid < WLANTL_MAX_TID ; ucTid++)
1273 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301274 pClientSTA->ullReplayCounter[ucTid] = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001275 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001276
1277 /*--------------------------------------------------------------------
1278 Set the AC for the registered station to the highest priority AC
1279 Even if this AC is not supported by the station, correction will be
1280 made in the main TL loop after the supported mask is properly
1281 updated in the pending packets call
1282 --------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301283 pClientSTA->ucCurrentAC = WLANTL_AC_VO;
1284 pClientSTA->ucCurrentWeight = 0;
1285 pClientSTA->ucServicedAC = WLANTL_AC_BK;
1286 pClientSTA->ucEapolPktPending = 0;
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -07001287
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301288 vos_mem_zero( pClientSTA->aucACMask, sizeof(pClientSTA->aucACMask));
Jeff Johnson295189b2012-06-20 16:38:30 -07001289
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301290 vos_mem_zero( &pClientSTA->wUAPSDInfo, sizeof(pClientSTA->wUAPSDInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -07001291
1292 /*--------------------------------------------------------------------
1293 Reordering info and AMSDU de-aggregation
1294 --------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301295 vos_mem_zero( pClientSTA->atlBAReorderInfo,
1296 sizeof(pClientSTA->atlBAReorderInfo[0])*
Jeff Johnson295189b2012-06-20 16:38:30 -07001297 WLAN_MAX_TID);
1298
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301299 vos_mem_zero( pClientSTA->aucMPDUHeader,
Jeff Johnson295189b2012-06-20 16:38:30 -07001300 WLANTL_MPDU_HEADER_LEN);
1301
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301302 pClientSTA->ucMPDUHeaderLen = 0;
1303 pClientSTA->vosAMSDUChain = NULL;
1304 pClientSTA->vosAMSDUChainRoot = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07001305
1306
Leo Chang6b6faaf2014-01-24 21:21:26 -08001307 /* Reorder LOCK
1308 * During handle normal RX frame within RX thread,
1309 * if MC thread try to preempt, ADDBA, DELBA, TIMER
1310 * Context should be protected from race */
1311 for (ucTid = 0; ucTid < WLAN_MAX_TID ; ucTid++)
1312 {
1313 if (!VOS_IS_STATUS_SUCCESS(
1314 vos_lock_init(&pClientSTA->atlBAReorderInfo[ucTid].reorderLock)))
1315 {
1316 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1317 "Lock Init Fail"));
1318 return VOS_STATUS_E_FAILURE;
1319 }
1320 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001321 /*--------------------------------------------------------------------
1322 Stats info
1323 --------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301324 vos_mem_zero( pClientSTA->auRxCount,
1325 sizeof(pClientSTA->auRxCount[0])*
Jeff Johnson295189b2012-06-20 16:38:30 -07001326 WLAN_MAX_TID);
1327
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301328 vos_mem_zero( pClientSTA->auTxCount,
1329 sizeof(pClientSTA->auRxCount[0])*
Jeff Johnson295189b2012-06-20 16:38:30 -07001330 WLAN_MAX_TID);
1331 /* Initial RSSI is always reported as zero because TL doesnt have enough
1332 data to calculate RSSI. So to avoid reporting zero, we are initializing
1333 RSSI with RSSI saved in BssDescription during scanning. */
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301334 pClientSTA->rssiAvg = rssi;
Shailender Karmuchi13c0d082013-03-26 14:41:39 -07001335#ifdef FEATURE_WLAN_TDLS
1336 if(WLAN_STA_TDLS == pClientSTA->wSTADesc.wSTAType)
1337 {
1338 /* If client is TDLS, use TDLS specific alpha */
1339 pClientSTA->rssiAlpha = WLANTL_HO_TDLS_ALPHA;
1340 }
1341 else
1342 {
1343 pClientSTA->rssiAlpha = WLANTL_HO_DEFAULT_ALPHA;
1344 }
1345#else
1346 pClientSTA->rssiAlpha = WLANTL_HO_DEFAULT_ALPHA;
1347#endif /* FEATURE_WLAN_TDLS */
Jeff Johnson295189b2012-06-20 16:38:30 -07001348
1349 /*Tx not suspended and station fully registered*/
1350 vos_atomic_set_U8(
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301351 &pClientSTA->ucTxSuspended, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07001352
1353 /* Used until multiple station support will be added*/
1354 pTLCb->ucRegisteredStaId = pwSTADescType->ucSTAId;
1355
1356 /* Save the BAP station ID for future usage */
1357 if ( WLAN_STA_BT_AMP == pwSTADescType->wSTAType )
1358 {
1359 pTLCb->tlBAPClient.ucBAPSTAId = pwSTADescType->ucSTAId;
1360 }
1361
1362 /*------------------------------------------------------------------------
1363 Statistics info
1364 -----------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301365 memset(&pClientSTA->trafficStatistics,
Jeff Johnson295189b2012-06-20 16:38:30 -07001366 0, sizeof(WLANTL_TRANSFER_STA_TYPE));
1367
1368
1369 /*------------------------------------------------------------------------
1370 Start with the state suggested by client caller
1371 -----------------------------------------------------------------------*/
Madan Mohan Koyylamudi64258222013-01-30 14:35:10 +05301372 pClientSTA->tlState = pwSTADescType->ucInitState;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301373 pClientSTA->ucRxBlocked = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07001374 /*-----------------------------------------------------------------------
1375 After all the init is complete we can mark the existance flag
1376 ----------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301377 pClientSTA->ucExists++;
Jeff Johnson295189b2012-06-20 16:38:30 -07001378
Jeff Johnson295189b2012-06-20 16:38:30 -07001379 //flow control fields init
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301380 pClientSTA->ucLwmModeEnabled = FALSE;
1381 pClientSTA->ucLwmEventReported = FALSE;
1382 pClientSTA->bmuMemConsumed = 0;
1383 pClientSTA->uIngress_length = 0;
1384 pClientSTA->uBuffThresholdMax = WLANTL_STA_BMU_THRESHOLD_MAX;
Jeff Johnson295189b2012-06-20 16:38:30 -07001385
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301386 pClientSTA->uLwmThreshold = WLANTL_STA_BMU_THRESHOLD_MAX / 3;
Jeff Johnson295189b2012-06-20 16:38:30 -07001387
1388 //@@@ HDDSOFTAP does not queue unregistered packet for now
1389 if ( WLAN_STA_SOFTAP != pwSTADescType->wSTAType )
1390 {
Jeff Johnson295189b2012-06-20 16:38:30 -07001391 /*------------------------------------------------------------------------
1392 Forward received frames while STA was not yet registered
1393 - ----------------------------------------------------------------------*/
1394 if(!VOS_IS_STATUS_SUCCESS(WLANTL_StartForwarding( pwSTADescType->ucSTAId,
1395 pwSTADescType->ucUcastSig,
1396 pwSTADescType->ucBcastSig)))
1397 {
1398 VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001399 " %s fails to start forwarding", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001400 }
Sunil Ravid5406f22013-01-22 00:18:31 -08001401#ifdef FEATURE_WLAN_TDLS
1402 if( WLAN_STA_TDLS == pwSTADescType->wSTAType )
1403 pTLCb->ucTdlsPeerCount++;
1404#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001405 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001406 return VOS_STATUS_SUCCESS;
1407}/* WLANTL_RegisterSTAClient */
1408
1409/*===========================================================================
1410
1411 FUNCTION WLANTL_ClearSTAClient
1412
1413 DESCRIPTION
1414
1415 HDD will call this API when it no longer needs data services for the
1416 particular station.
1417
1418 DEPENDENCIES
1419
1420 A station must have been registered before the clear registration is
1421 called.
1422
1423 PARAMETERS
1424
1425 pvosGCtx: pointer to the global vos context; a handle to TL's
1426 control block can be extracted from its context
1427 ucSTAId: identifier for the STA to be cleared
1428
1429 RETURN VALUE
1430
1431 The result code associated with performing the operation
1432
1433 VOS_STATUS_E_FAULT: Station ID is outside array boundaries or pointer to
1434 TL cb is NULL ; access would cause a page fault
1435 VOS_STATUS_E_EXISTS: Station was not registered
1436 VOS_STATUS_SUCCESS: Everything is good :)
1437
1438 SIDE EFFECTS
1439
1440============================================================================*/
1441VOS_STATUS
1442WLANTL_ClearSTAClient
1443(
1444 v_PVOID_t pvosGCtx,
1445 v_U8_t ucSTAId
1446)
1447{
1448 WLANTL_CbType* pTLCb = NULL;
1449 v_U8_t ucIndex;
1450 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
1451
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301452 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -07001453 /*------------------------------------------------------------------------
1454 Sanity check
1455 ------------------------------------------------------------------------*/
1456 if ( WLANTL_STA_ID_INVALID( ucSTAId ) )
1457 {
1458 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1459 "WLAN TL:Invalid station id requested on WLANTL_ClearSTAClient"));
1460 return VOS_STATUS_E_FAULT;
1461 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001462 /*------------------------------------------------------------------------
1463 Extract TL control block
1464 ------------------------------------------------------------------------*/
1465 pTLCb = VOS_GET_TL_CB(pvosGCtx);
1466 if ( NULL == pTLCb )
1467 {
1468 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1469 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_ClearSTAClient"));
1470 return VOS_STATUS_E_FAULT;
1471 }
1472
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301473 if ( NULL == pTLCb->atlSTAClients[ucSTAId] )
1474 {
1475 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1476 "WLAN TL:Client Memory was not allocated on %s", __func__));
1477 return VOS_STATUS_E_FAILURE;
1478 }
1479
1480 if ( 0 == pTLCb->atlSTAClients[ucSTAId]->ucExists )
Jeff Johnson295189b2012-06-20 16:38:30 -07001481 {
1482 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1483 "WLAN TL:Station was not previously registered on WLANTL_ClearSTAClient"));
1484 return VOS_STATUS_E_EXISTS;
1485 }
1486
1487 /* Delete BA sessions on all TID's */
Leo Chang6b6faaf2014-01-24 21:21:26 -08001488 for (ucIndex = 0; ucIndex < WLAN_MAX_TID ; ucIndex++)
Jeff Johnson295189b2012-06-20 16:38:30 -07001489 {
Leo Chang6b6faaf2014-01-24 21:21:26 -08001490 WLANTL_BaSessionDel(pvosGCtx, ucSTAId, ucIndex);
1491 vos_lock_destroy(&pTLCb->atlSTAClients[ucSTAId]->atlBAReorderInfo[ucIndex].reorderLock);
Jeff Johnson295189b2012-06-20 16:38:30 -07001492 }
1493
Sunil Ravid5406f22013-01-22 00:18:31 -08001494#ifdef FEATURE_WLAN_TDLS
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301495 /* decrement ucTdlsPeerCount only if it is non-zero */
1496 if(WLAN_STA_TDLS == pTLCb->atlSTAClients[ucSTAId]->wSTADesc.wSTAType
Sunil Ravid5406f22013-01-22 00:18:31 -08001497 && pTLCb->ucTdlsPeerCount)
1498 pTLCb->ucTdlsPeerCount--;
1499#endif
1500
Jeff Johnson295189b2012-06-20 16:38:30 -07001501 /*------------------------------------------------------------------------
1502 Clear station
1503 ------------------------------------------------------------------------*/
1504 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
1505 "WLAN TL:Clearing STA Client ID: %d", ucSTAId ));
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301506 WLANTL_CleanSTA(pTLCb->atlSTAClients[ucSTAId], 1 /*empty packets*/);
Jeff Johnson295189b2012-06-20 16:38:30 -07001507
1508 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
1509 "WLAN TL:Clearing STA Reset History RSSI and Region number"));
1510 pTLCb->hoSupport.currentHOState.historyRSSI = 0;
1511 pTLCb->hoSupport.currentHOState.regionNumber = 0;
1512
1513 return VOS_STATUS_SUCCESS;
1514}/* WLANTL_ClearSTAClient */
1515
1516/*===========================================================================
1517
1518 FUNCTION WLANTL_ChangeSTAState
1519
1520 DESCRIPTION
1521
1522 HDD will make this notification whenever a change occurs in the
1523 connectivity state of a particular STA.
1524
1525 DEPENDENCIES
1526
1527 A station must have been registered before the change state can be
1528 called.
1529
1530 RESTRICTION: A station is being notified as authenticated before the
1531 keys are installed in HW. This way if a frame is received
1532 before the keys are installed DPU will drop that frame.
1533
1534 Main thread has higher priority that Tx and Rx threads thus guaranteeing
1535 the following:
1536 - a station will be in assoc state in TL before TL receives any data
1537 for it
1538
1539 PARAMETERS
1540
1541 pvosGCtx: pointer to the global vos context; a handle to TL's
1542 control block can be extracted from its context
1543 ucSTAId: identifier for the STA that is pending transmission
1544 tlSTAState: the new state of the connection to the given station
1545
1546
1547 RETURN VALUE
1548
1549 The result code associated with performing the operation
1550
1551 VOS_STATUS_E_INVAL: Input parameters are invalid
1552 VOS_STATUS_E_FAULT: Station ID is outside array boundaries or pointer to
1553 TL cb is NULL ; access would cause a page fault
1554 VOS_STATUS_E_EXISTS: Station was not registered
1555 VOS_STATUS_SUCCESS: Everything is good :)
1556
1557 SIDE EFFECTS
1558
1559============================================================================*/
1560VOS_STATUS
1561WLANTL_ChangeSTAState
1562(
1563 v_PVOID_t pvosGCtx,
1564 v_U8_t ucSTAId,
1565 WLANTL_STAStateType tlSTAState
1566)
1567{
1568 WLANTL_CbType* pTLCb = NULL;
1569 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
1570
1571 /*------------------------------------------------------------------------
1572 Sanity check
1573 ------------------------------------------------------------------------*/
1574 if ( tlSTAState >= WLANTL_STA_MAX_STATE )
1575 {
1576 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1577 "WLAN TL:Invalid parameter sent on WLANTL_ChangeSTAState"));
1578 return VOS_STATUS_E_INVAL;
1579 }
1580
1581 if ( WLANTL_STA_ID_INVALID( ucSTAId ) )
1582 {
1583 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1584 "WLAN TL:Invalid station id requested on WLANTL_ChangeSTAState"));
1585 return VOS_STATUS_E_FAULT;
1586 }
1587
1588 /*------------------------------------------------------------------------
1589 Extract TL control block and check existance
1590 ------------------------------------------------------------------------*/
1591 pTLCb = VOS_GET_TL_CB(pvosGCtx);
1592 if ( NULL == pTLCb )
1593 {
1594 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1595 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_ChangeSTAState"));
1596 return VOS_STATUS_E_FAULT;
1597 }
1598
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301599 if ( NULL == pTLCb->atlSTAClients[ucSTAId] )
1600 {
1601 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1602 "WLAN TL:Client Memory was not allocated on %s", __func__));
1603 return VOS_STATUS_E_FAILURE;
1604 }
1605
1606 if ( 0 == pTLCb->atlSTAClients[ucSTAId]->ucExists )
Jeff Johnson295189b2012-06-20 16:38:30 -07001607 {
1608 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1609 "WLAN TL:Station was not previously registered on WLANTL_ChangeSTAState"));
1610 return VOS_STATUS_E_EXISTS;
1611 }
1612
1613 /*------------------------------------------------------------------------
1614 Change STA state
1615 No need to lock this operation, see restrictions above
1616 ------------------------------------------------------------------------*/
1617 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
1618 "WLAN TL:Changing state for STA Client ID: %d from %d to %d",
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301619 ucSTAId, pTLCb->atlSTAClients[ucSTAId]->tlState, tlSTAState));
Jeff Johnson295189b2012-06-20 16:38:30 -07001620
Katya Nigam42e16e82014-02-04 16:28:55 +05301621 MTRACE(vos_trace(VOS_MODULE_ID_TL,
1622 TRACE_CODE_TL_STA_STATE, ucSTAId,tlSTAState ));
1623
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301624 pTLCb->atlSTAClients[ucSTAId]->tlState = tlSTAState;
Jeff Johnson295189b2012-06-20 16:38:30 -07001625
1626 return VOS_STATUS_SUCCESS;
1627}/* WLANTL_ChangeSTAState */
1628
1629/*===========================================================================
1630
Gopichand Nakkala8b54e912013-03-11 10:44:21 +05301631 FUNCTION WLANTL_STAPtkInstalled
1632
1633 DESCRIPTION
1634
1635 HDD will make this notification whenever PTK is installed for the STA
1636
1637 DEPENDENCIES
1638
1639 A station must have been registered before the change state can be
1640 called.
1641
1642 PARAMETERS
1643
1644 pvosGCtx: pointer to the global vos context; a handle to TL's
1645 control block can be extracted from its context
1646 ucSTAId: identifier for the STA for which Pairwise key is
1647 installed
1648
1649 RETURN VALUE
1650
1651 The result code associated with performing the operation
1652
1653 VOS_STATUS_E_FAULT: Station ID is outside array boundaries or pointer to
1654 TL cb is NULL ; access would cause a page fault
1655 VOS_STATUS_E_EXISTS: Station was not registered
1656 VOS_STATUS_SUCCESS: Everything is good :)
1657
1658 SIDE EFFECTS
1659
1660============================================================================*/
1661VOS_STATUS
1662WLANTL_STAPtkInstalled
1663(
1664 v_PVOID_t pvosGCtx,
1665 v_U8_t ucSTAId
1666)
1667{
1668 WLANTL_CbType* pTLCb = NULL;
1669 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
1670
1671 /*------------------------------------------------------------------------
1672 Sanity check
1673 ------------------------------------------------------------------------*/
1674
1675 if ( WLANTL_STA_ID_INVALID( ucSTAId ) )
1676 {
1677 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1678 "WLAN TL:Invalid station id requested on WLANTL_ChangeSTAState"));
1679 return VOS_STATUS_E_FAULT;
1680 }
1681
1682 /*------------------------------------------------------------------------
1683 Extract TL control block and check existance
1684 ------------------------------------------------------------------------*/
1685 pTLCb = VOS_GET_TL_CB(pvosGCtx);
1686 if ( NULL == pTLCb )
1687 {
1688 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1689 FL("WLAN TL:Invalid TL pointer from pvosGCtx")));
1690 return VOS_STATUS_E_FAULT;
1691 }
1692
1693 if ( NULL == pTLCb->atlSTAClients[ucSTAId] )
1694 {
1695 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1696 FL("WLAN TL:Client Memory was not allocated")));
1697 return VOS_STATUS_E_FAILURE;
1698 }
1699
1700 if ( 0 == pTLCb->atlSTAClients[ucSTAId]->ucExists )
1701 {
1702 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1703 FL("WLAN TL:Station was not previously registered")));
1704 return VOS_STATUS_E_EXISTS;
1705 }
1706
1707 pTLCb->atlSTAClients[ucSTAId]->ptkInstalled = 1;
1708
1709 return VOS_STATUS_SUCCESS;
1710}/* WLANTL_STAPtkInstalled */
1711
1712/*===========================================================================
1713
Madan Mohan Koyyalamudifc1d1fe2012-10-18 15:07:12 -07001714 FUNCTION WLANTL_GetSTAState
1715
1716 DESCRIPTION
1717
1718 Returns connectivity state of a particular STA.
1719
1720 DEPENDENCIES
1721
1722 A station must have been registered before its state can be retrieved.
1723
1724
1725 PARAMETERS
1726
1727 IN
1728 pvosGCtx: pointer to the global vos context; a handle to TL's
1729 control block can be extracted from its context
1730 ucSTAId: identifier of the station
1731
1732 OUT
1733 ptlSTAState: the current state of the connection to the given station
1734
1735
1736 RETURN VALUE
1737
1738 The result code associated with performing the operation
1739
1740 VOS_STATUS_E_INVAL: Input parameters are invalid
1741 VOS_STATUS_E_FAULT: Station ID is outside array boundaries or pointer to
1742 TL cb is NULL ; access would cause a page fault
1743 VOS_STATUS_E_EXISTS: Station was not registered
1744 VOS_STATUS_SUCCESS: Everything is good :)
1745
1746 SIDE EFFECTS
1747
1748============================================================================*/
1749VOS_STATUS
1750WLANTL_GetSTAState
1751(
1752 v_PVOID_t pvosGCtx,
1753 v_U8_t ucSTAId,
1754 WLANTL_STAStateType *ptlSTAState
1755)
1756{
1757 WLANTL_CbType* pTLCb = NULL;
1758 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
1759
1760 /*------------------------------------------------------------------------
1761 Sanity check
1762 ------------------------------------------------------------------------*/
1763 if ( NULL == ptlSTAState )
1764 {
1765 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1766 "WLAN TL:Invalid parameter sent on WLANTL_GetSTAState"));
1767 return VOS_STATUS_E_INVAL;
1768 }
1769
1770 if ( WLANTL_STA_ID_INVALID( ucSTAId ) )
1771 {
1772 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1773 "WLAN TL:Invalid station id requested on WLANTL_GetSTAState"));
1774 return VOS_STATUS_E_FAULT;
1775 }
1776
1777 /*------------------------------------------------------------------------
1778 Extract TL control block and check existance
1779 ------------------------------------------------------------------------*/
1780 pTLCb = VOS_GET_TL_CB(pvosGCtx);
1781 if ( NULL == pTLCb )
1782 {
1783 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1784 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_GetSTAState"));
1785 return VOS_STATUS_E_FAULT;
1786 }
1787
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301788 if ( NULL == pTLCb->atlSTAClients[ucSTAId] )
1789 {
1790 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1791 "WLAN TL:Client Memory was not allocated on %s", __func__));
1792 return VOS_STATUS_E_FAILURE;
1793 }
1794
1795 if ( 0 == pTLCb->atlSTAClients[ucSTAId]->ucExists )
Madan Mohan Koyyalamudifc1d1fe2012-10-18 15:07:12 -07001796 {
Sunil Ravid5406f22013-01-22 00:18:31 -08001797 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
Madan Mohan Koyyalamudifc1d1fe2012-10-18 15:07:12 -07001798 "WLAN TL:Station was not previously registered on WLANTL_GetSTAState"));
1799 return VOS_STATUS_E_EXISTS;
1800 }
1801
1802 /*------------------------------------------------------------------------
1803 Get STA state
1804 ------------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301805 *ptlSTAState = pTLCb->atlSTAClients[ucSTAId]->tlState;
Madan Mohan Koyyalamudifc1d1fe2012-10-18 15:07:12 -07001806
1807 return VOS_STATUS_SUCCESS;
1808}/* WLANTL_GetSTAState */
1809
Shailender Karmuchia734f332013-04-19 14:02:48 -07001810/*==========================================================================
1811 FUNCTION WLANTL_UpdateSTABssIdforIBSS
1812
1813 DESCRIPTION
1814 HDD will call this API to update the BSSID for this Station.
1815
1816 DEPENDENCIES
1817 The HDD Should registered the staID with TL before calling this function.
1818
1819 PARAMETERS
1820
1821 IN
1822 pvosGCtx: Pointer to the global vos context; a handle to TL's
1823 or WDA's control block can be extracted from its context
1824 IN
1825 ucSTAId The Station ID for Bssid to be updated
1826 IN
1827 pBssid BSSID to be updated
1828
1829 RETURN VALUE
1830 The result code associated with performing the operation
1831
1832 VOS_STATUS_E_INVAL: Input parameters are invalid
1833 VOS_STATUS_E_FAULT: Station ID is outside array boundaries or pointer to
1834 TL cb is NULL ; access would cause a page fault
1835 VOS_STATUS_E_EXISTS: Station was not registered
1836 VOS_STATUS_SUCCESS: Everything is good :)
1837
1838 SIDE EFFECTS
1839============================================================================*/
1840
1841
1842VOS_STATUS
1843WLANTL_UpdateSTABssIdforIBSS
1844(
1845 v_PVOID_t pvosGCtx,
1846 v_U8_t ucSTAId,
1847 v_U8_t *pBssid
1848)
1849{
1850 WLANTL_CbType* pTLCb = NULL;
1851 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
1852
1853 /*------------------------------------------------------------------------
1854 Sanity check
1855 ------------------------------------------------------------------------*/
1856 if ( WLANTL_STA_ID_INVALID( ucSTAId ) )
1857 {
1858 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1859 "WLAN TL:Invalid station id requested %s", __func__));
1860 return VOS_STATUS_E_FAULT;
1861 }
1862
1863 /*------------------------------------------------------------------------
1864 Extract TL control block and check existance
1865 ------------------------------------------------------------------------*/
1866 pTLCb = VOS_GET_TL_CB(pvosGCtx);
1867 if ( NULL == pTLCb )
1868 {
1869 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1870 "WLAN TL:Invalid TL pointer from pvosGCtx %s", __func__));
1871 return VOS_STATUS_E_FAULT;
1872 }
1873
1874 if ( NULL == pTLCb->atlSTAClients[ucSTAId] )
1875 {
1876 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1877 "WLAN TL:Client Memory was not allocated on %s", __func__));
1878 return VOS_STATUS_E_FAILURE;
1879 }
1880
1881 if ( 0 == pTLCb->atlSTAClients[ucSTAId]->ucExists )
1882 {
1883 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
1884 "WLAN TL:Station was not previously registered %s", __func__));
1885 return VOS_STATUS_E_EXISTS;
1886 }
1887
1888 /*------------------------------------------------------------------------
1889 Update the IBSS BSSID
1890 ------------------------------------------------------------------------*/
1891 vos_mem_copy( &pTLCb->atlSTAClients[ucSTAId]->wSTADesc.vBSSIDforIBSS,
1892 pBssid, sizeof(v_MACADDR_t));
1893
1894 return VOS_STATUS_SUCCESS;
1895}
1896
Madan Mohan Koyyalamudifc1d1fe2012-10-18 15:07:12 -07001897/*===========================================================================
1898
Jeff Johnson295189b2012-06-20 16:38:30 -07001899 FUNCTION WLANTL_STAPktPending
1900
1901 DESCRIPTION
1902
1903 HDD will call this API when a packet is pending transmission in its
1904 queues.
1905
1906 DEPENDENCIES
1907
1908 A station must have been registered before the packet pending
1909 notification can be sent.
1910
1911 RESTRICTION: TL will not count packets for pending notification.
1912 HDD is expected to send the notification only when
1913 non-empty event gets triggered. Worst case scenario
1914 is that TL might end up making a call when Hdds
1915 queues are actually empty.
1916
1917 PARAMETERS
1918
1919 pvosGCtx: pointer to the global vos context; a handle to TL's
1920 control block can be extracted from its context
1921 ucSTAId: identifier for the STA that is pending transmission
1922
1923 RETURN VALUE
1924
1925 The result code associated with performing the operation
1926
1927 VOS_STATUS_E_INVAL: Input parameters are invalid
1928 VOS_STATUS_E_FAULT: Station ID is outside array boundaries or pointer
1929 to TL cb is NULL ; access would cause a page fault
1930 VOS_STATUS_E_EXISTS: Station was not registered
1931 VOS_STATUS_SUCCESS: Everything is good :)
1932
1933 SIDE EFFECTS
1934
1935============================================================================*/
1936VOS_STATUS
1937WLANTL_STAPktPending
1938(
1939 v_PVOID_t pvosGCtx,
1940 v_U8_t ucSTAId,
1941 WLANTL_ACEnumType ucAc
1942)
1943{
1944 WLANTL_CbType* pTLCb = NULL;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301945 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07001946 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
1947
1948 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
1949 "WLAN TL:Packet pending indication for STA: %d AC: %d", ucSTAId, ucAc);
1950
1951 /*------------------------------------------------------------------------
1952 Sanity check
1953 ------------------------------------------------------------------------*/
1954 if ( WLANTL_STA_ID_INVALID( ucSTAId ) )
1955 {
1956 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1957 "WLAN TL:Invalid station id requested on WLANTL_STAPktPending"));
1958 return VOS_STATUS_E_FAULT;
1959 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001960 /*------------------------------------------------------------------------
1961 Extract TL control block and check existance
1962 ------------------------------------------------------------------------*/
1963 pTLCb = VOS_GET_TL_CB(pvosGCtx);
1964 if ( NULL == pTLCb )
1965 {
1966 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1967 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_STAPktPending"));
1968 return VOS_STATUS_E_FAULT;
1969 }
1970
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301971 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
1972
1973 if ( NULL == pClientSTA )
1974 {
1975 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1976 "WLAN TL:Client Memory was not allocated on %s", __func__));
1977 return VOS_STATUS_E_FAILURE;
1978 }
1979
1980 if ( 0 == pClientSTA->ucExists )
Jeff Johnson295189b2012-06-20 16:38:30 -07001981 {
1982 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1983 "WLAN TL:Station was not previously registered on WLANTL_STAPktPending"));
1984 return VOS_STATUS_E_EXISTS;
1985 }
1986
1987 /*---------------------------------------------------------------------
1988 Temporary fix to enable TL to fetch packets when multiple peers join
1989 an IBSS. To fix CR177301. Needs to go away when the actual fix of
1990 going through all STA's in round robin fashion gets merged in from
1991 BT AMP branch.
1992 --------------------------------------------------------------------*/
1993 pTLCb->ucRegisteredStaId = ucSTAId;
1994
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301995 if( WLANTL_STA_CONNECTED == pClientSTA->tlState )
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -07001996 { /* EAPOL_HI_PRIORITY : need to find out whether EAPOL is pending before
1997 WLANTL_FetchPacket()/WLANTL_TxConn() is called.
1998 change STA_AUTHENTICATED != tlState to CONNECTED == tlState
1999 to make sure TL is indeed waiting for EAPOL.
2000 Just in the case when STA got disconnected shortly after connectection */
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302001 pClientSTA->ucEapolPktPending = 1;
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -07002002
Katya Nigam42e16e82014-02-04 16:28:55 +05302003 MTRACE(vos_trace(VOS_MODULE_ID_TL,
2004 TRACE_CODE_TL_EAPOL_PKT_PENDING, ucSTAId, ucAc));
2005
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -07002006 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07002007 "WLAN TL:Packet pending indication for STA: %d AC: %d State: %d",
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302008 ucSTAId, ucAc, pClientSTA->tlState);
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07002009 }
2010
Jeff Johnson295189b2012-06-20 16:38:30 -07002011 /*-----------------------------------------------------------------------
2012 Enable this AC in the AC mask in order for TL to start servicing it
2013 Set packet pending flag
2014 To avoid race condition, serialize the updation of AC and AC mask
2015 through WLANTL_TX_STAID_AC_IND message.
2016 -----------------------------------------------------------------------*/
Jeff Johnson295189b2012-06-20 16:38:30 -07002017
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302018 pClientSTA->aucACMask[ucAc] = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07002019
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302020 vos_atomic_set_U8( &pClientSTA->ucPktPending, 1);
Jeff Johnson295189b2012-06-20 16:38:30 -07002021
2022 /*------------------------------------------------------------------------
2023 Check if there are enough resources for transmission and tx is not
2024 suspended.
2025 ------------------------------------------------------------------------*/
Madan Mohan Koyyalamudi24a00f92012-10-22 15:21:02 -07002026 if (( pTLCb->uResCount >= WDA_TLI_MIN_RES_DATA ) &&
2027 ( 0 == pTLCb->ucTxSuspended ))
Jeff Johnson295189b2012-06-20 16:38:30 -07002028 {
Katya Nigam42e16e82014-02-04 16:28:55 +05302029 MTRACE(vos_trace(VOS_MODULE_ID_TL, TRACE_CODE_TL_STA_PKT_PENDING,
2030 ucSTAId, pClientSTA->tlState ));
2031
Jeff Johnson295189b2012-06-20 16:38:30 -07002032 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
2033 "Issuing Xmit start request to BAL"));
2034 WDA_DS_StartXmit(pvosGCtx);
2035 }
2036 else
2037 {
2038 /*---------------------------------------------------------------------
2039 No error code is sent because TL will resume tx autonomously if
2040 resources become available or tx gets resumed
2041 ---------------------------------------------------------------------*/
Madan Mohan Koyyalamudi179e6fe2012-10-15 15:31:08 -07002042 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
Jeff Johnson295189b2012-06-20 16:38:30 -07002043 "WLAN TL:Request to send but condition not met. Res: %d,Suspend: %d",
Madan Mohan Koyyalamudi48139e32012-10-11 14:43:56 -07002044 pTLCb->uResCount, pTLCb->ucTxSuspended );
Jeff Johnson295189b2012-06-20 16:38:30 -07002045 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002046 return VOS_STATUS_SUCCESS;
2047}/* WLANTL_STAPktPending */
2048
2049/*==========================================================================
2050
2051 FUNCTION WLANTL_SetSTAPriority
2052
2053 DESCRIPTION
2054
2055 TL exposes this API to allow upper layers a rough control over the
2056 priority of transmission for a given station when supporting multiple
2057 connections.
2058
2059 DEPENDENCIES
2060
2061 A station must have been registered before the change in priority can be
2062 called.
2063
2064 PARAMETERS
2065
2066 pvosGCtx: pointer to the global vos context; a handle to TL's
2067 control block can be extracted from its context
2068 ucSTAId: identifier for the STA that has to change priority
2069
2070 RETURN VALUE
2071
2072 The result code associated with performing the operation
2073
2074 VOS_STATUS_E_INVAL: Input parameters are invalid
2075 VOS_STATUS_E_FAULT: Station ID is outside array boundaries or pointer
2076 to TL cb is NULL ; access would cause a page fault
2077 VOS_STATUS_E_EXISTS: Station was not registered
2078 VOS_STATUS_SUCCESS: Everything is good :)
2079
2080 SIDE EFFECTS
2081
2082============================================================================*/
2083VOS_STATUS
2084WLANTL_SetSTAPriority
2085(
2086 v_PVOID_t pvosGCtx,
2087 v_U8_t ucSTAId,
2088 WLANTL_STAPriorityType tlSTAPri
2089)
2090{
2091 WLANTL_CbType* pTLCb = NULL;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302092 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002093 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
2094
2095 /*------------------------------------------------------------------------
2096 Sanity check
2097 ------------------------------------------------------------------------*/
2098 if ( WLANTL_STA_ID_INVALID( ucSTAId ) )
2099 {
2100 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2101 "WLAN TL:Invalid station id requested on WLANTL_SetSTAPriority"));
2102 return VOS_STATUS_E_FAULT;
2103 }
2104
2105 /*------------------------------------------------------------------------
2106 Extract TL control block
2107 ------------------------------------------------------------------------*/
2108 pTLCb = VOS_GET_TL_CB(pvosGCtx);
2109 if ( NULL == pTLCb )
2110 {
2111 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2112 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_SetSTAPriority"));
2113 return VOS_STATUS_E_FAULT;
2114 }
2115
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302116 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
2117
2118 if ( NULL == pClientSTA )
2119 {
2120 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2121 "WLAN TL:Client Memory was not allocated on %s", __func__));
2122 return VOS_STATUS_E_FAILURE;
2123 }
2124
2125 if ( 0 == pClientSTA->ucExists )
Jeff Johnson295189b2012-06-20 16:38:30 -07002126 {
2127 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2128 "WLAN TL:Station was not previously registered on WLANTL_SetSTAPriority"));
2129 return VOS_STATUS_E_EXISTS;
2130 }
2131
2132 /*------------------------------------------------------------------------
2133 Re-analize if lock is needed when adding multiple stations
2134 ------------------------------------------------------------------------*/
2135 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
2136 "WLAN TL:Changing state for STA Pri ID: %d from %d to %d",
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302137 ucSTAId, pClientSTA->tlPri, tlSTAPri));
2138 pClientSTA->tlPri = tlSTAPri;
Jeff Johnson295189b2012-06-20 16:38:30 -07002139
2140 return VOS_STATUS_SUCCESS;
2141}/* WLANTL_SetSTAPriority */
2142
2143
2144/*----------------------------------------------------------------------------
2145 INTERACTION WITH BAP
2146 ---------------------------------------------------------------------------*/
2147
2148/*==========================================================================
2149
2150 FUNCTION WLANTL_RegisterBAPClient
2151
2152 DESCRIPTION
2153 Called by SME to register itself as client for non-data BT-AMP packets.
2154
2155 DEPENDENCIES
2156 TL must be initialized before this function can be called.
2157
2158 PARAMETERS
2159
2160 IN
2161 pvosGCtx: pointer to the global vos context; a handle to TL's
2162 or SME's control block can be extracted from its context
2163 pfnTlBAPRxFrm: pointer to the receive processing routine for non-data
2164 BT-AMP packets
2165 pfnFlushOpCompleteCb:
2166 pointer to the call back function, for the Flush operation
2167 completion.
2168
2169
2170 RETURN VALUE
2171
2172 The result code associated with performing the operation
2173
2174 VOS_STATUS_E_INVAL: Input parameters are invalid
2175 VOS_STATUS_E_FAULT: Station ID is outside array boundaries or pointer
2176 to TL cb is NULL ; access would cause a page fault
2177 VOS_STATUS_E_EXISTS: BAL client was already registered
2178 VOS_STATUS_SUCCESS: Everything is good :)
2179
2180 SIDE EFFECTS
2181
2182============================================================================*/
2183VOS_STATUS
2184WLANTL_RegisterBAPClient
2185(
2186 v_PVOID_t pvosGCtx,
2187 WLANTL_BAPRxCBType pfnTlBAPRxFrm,
2188 WLANTL_FlushOpCompCBType pfnFlushOpCompleteCb
2189)
2190{
2191 WLANTL_CbType* pTLCb = NULL;
2192 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
2193
2194 /*------------------------------------------------------------------------
2195 Sanity check
2196 ------------------------------------------------------------------------*/
2197 if ( NULL == pfnTlBAPRxFrm )
2198 {
2199 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2200 "WLAN TL:Invalid parameter sent on WLANTL_RegisterBAPClient"));
2201 return VOS_STATUS_E_INVAL;
2202 }
2203
2204 if ( NULL == pfnFlushOpCompleteCb )
2205 {
2206 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2207 "Invalid Flush Complete Cb parameter sent on WLANTL_RegisterBAPClient"));
2208 return VOS_STATUS_E_INVAL;
2209 }
2210
2211 /*------------------------------------------------------------------------
2212 Extract TL control block
2213 ------------------------------------------------------------------------*/
2214 pTLCb = VOS_GET_TL_CB(pvosGCtx);
2215 if ( NULL == pTLCb )
2216 {
2217 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2218 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_RegisterBAPClient"));
2219 return VOS_STATUS_E_FAULT;
2220 }
2221
2222 /*------------------------------------------------------------------------
2223 Make sure this is the first registration attempt
2224 ------------------------------------------------------------------------*/
2225 if ( 0 != pTLCb->tlBAPClient.ucExists )
2226 {
2227 pTLCb->tlBAPClient.ucExists++;
2228 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2229 "WLAN TL:BAP client was already registered"));
2230 return VOS_STATUS_E_EXISTS;
2231 }
2232
2233 /*------------------------------------------------------------------------
2234 Register station with TL
2235 ------------------------------------------------------------------------*/
2236 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
2237 "WLAN TL:Registering BAP Client" ));
2238
2239 pTLCb->tlBAPClient.ucExists++;
2240
2241 if ( NULL != pfnTlBAPRxFrm )
2242 {
2243 pTLCb->tlBAPClient.pfnTlBAPRx = pfnTlBAPRxFrm;
2244 }
2245
2246 pTLCb->tlBAPClient.pfnFlushOpCompleteCb = pfnFlushOpCompleteCb;
2247
2248 pTLCb->tlBAPClient.vosPendingDataBuff = NULL;
2249
2250 return VOS_STATUS_SUCCESS;
2251}/* WLANTL_RegisterBAPClient */
2252
2253
2254/*==========================================================================
2255
2256 FUNCTION WLANTL_TxBAPFrm
2257
2258 DESCRIPTION
2259 BAP calls this when it wants to send a frame to the module
2260
2261 DEPENDENCIES
2262 BAP must be registered with TL before this function can be called.
2263
2264 RESTRICTION: BAP CANNOT push any packets to TL until it did not receive
2265 a tx complete from the previous packet, that means BAP
2266 sends one packet, wait for tx complete and then
2267 sends another one
2268
2269 If BAP sends another packet before TL manages to process the
2270 previously sent packet call will end in failure
2271
2272 PARAMETERS
2273
2274 IN
2275 pvosGCtx: pointer to the global vos context; a handle to TL's
2276 or BAP's control block can be extracted from its context
2277 vosDataBuff: pointer to the vOSS buffer containing the packet to be
2278 transmitted
2279 pMetaInfo: meta information about the packet
2280 pfnTlBAPTxComp: pointer to a transmit complete routine for notifying
2281 the result of the operation over the bus
2282
2283 RETURN VALUE
2284 The result code associated with performing the operation
2285
2286 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
2287 page fault
2288 VOS_STATUS_E_EXISTS: BAL client was not yet registered
2289 VOS_STATUS_E_BUSY: The previous BT-AMP packet was not yet transmitted
2290 VOS_STATUS_SUCCESS: Everything is good :)
2291
2292 Other failure messages may be returned from the BD header handling
2293 routines, please check apropriate API for more info.
2294
2295 SIDE EFFECTS
2296
2297============================================================================*/
2298VOS_STATUS
2299WLANTL_TxBAPFrm
2300(
2301 v_PVOID_t pvosGCtx,
2302 vos_pkt_t* vosDataBuff,
2303 WLANTL_MetaInfoType* pMetaInfo,
2304 WLANTL_TxCompCBType pfnTlBAPTxComp
2305)
2306{
2307 WLANTL_CbType* pTLCb = NULL;
2308 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
2309 v_MACADDR_t vDestMacAddr;
2310 v_U16_t usPktLen;
2311 v_U8_t ucStaId = 0;
2312 v_U8_t extraHeadSpace = 0;
2313 v_U8_t ucWDSEnabled = 0;
2314 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
2315
2316 /*------------------------------------------------------------------------
2317 Sanity check
2318 Extract TL control block
2319 ------------------------------------------------------------------------*/
2320 pTLCb = VOS_GET_TL_CB(pvosGCtx);
2321 if ( NULL == pTLCb )
2322 {
2323 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2324 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_TxBAPFrm"));
2325 return VOS_STATUS_E_FAULT;
2326 }
2327
2328 /*------------------------------------------------------------------------
2329 Ensure that BAP client was registered previously
2330 ------------------------------------------------------------------------*/
2331 if (( 0 == pTLCb->tlBAPClient.ucExists ) ||
2332 ( WLANTL_STA_ID_INVALID(pTLCb->tlBAPClient.ucBAPSTAId) ))
2333 {
2334 pTLCb->tlBAPClient.ucExists++;
2335 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2336 "WLAN TL:BAP client not register on WLANTL_TxBAPFrm"));
2337 return VOS_STATUS_E_EXISTS;
2338 }
2339
2340 /*------------------------------------------------------------------------
2341 Check if any BT-AMP Frm is pending
2342 ------------------------------------------------------------------------*/
2343 if ( NULL != pTLCb->tlBAPClient.vosPendingDataBuff )
2344 {
2345 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2346 "WLAN TL:BT-AMP Frame already pending tx in TL on WLANTL_TxBAPFrm"));
2347 return VOS_STATUS_E_BUSY;
2348 }
2349
2350 /*------------------------------------------------------------------------
2351 Save buffer and notify BAL; no lock is needed if the above restriction
2352 is met
2353 Save the tx complete fnct pointer as tl specific data in the vos buffer
2354 ------------------------------------------------------------------------*/
2355
2356 /*------------------------------------------------------------------------
2357 Translate 802.3 frame to 802.11
2358 ------------------------------------------------------------------------*/
2359 ucStaId = pTLCb->tlBAPClient.ucBAPSTAId;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302360 if ( NULL == pTLCb->atlSTAClients[ucStaId] )
2361 {
2362 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2363 "WLAN TL:Client Memory was not allocated on %s", __func__));
2364 return VOS_STATUS_E_FAILURE;
2365 }
2366 if (( 0 == pMetaInfo->ucDisableFrmXtl ) &&
2367 ( 0 != pTLCb->atlSTAClients[ucStaId]->wSTADesc.ucSwFrameTXXlation ))
Jeff Johnson295189b2012-06-20 16:38:30 -07002368 {
Kiran Venkatappacab0d352012-12-17 13:09:22 -08002369 vosStatus = WLANTL_Translate8023To80211Header( vosDataBuff, &vosStatus,
2370 pTLCb, &ucStaId,
Ravi Joshid0699502013-07-08 15:48:47 -07002371 pMetaInfo, &ucWDSEnabled,
2372 &extraHeadSpace);
Jeff Johnson295189b2012-06-20 16:38:30 -07002373
2374 if ( VOS_STATUS_SUCCESS != vosStatus )
2375 {
2376 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2377 "WLAN TL:Error when translating header WLANTL_TxBAPFrm"));
2378
2379 return vosStatus;
2380 }
2381
2382 pMetaInfo->ucDisableFrmXtl = 1;
2383 }
2384
2385 /*-------------------------------------------------------------------------
2386 Call HAL to fill BD header
2387 -------------------------------------------------------------------------*/
2388
2389 /* Adding Type, SubType which was missing for EAPOL from BAP */
2390 pMetaInfo->ucType |= (WLANTL_80211_DATA_TYPE << 4);
2391 pMetaInfo->ucType |= (WLANTL_80211_DATA_QOS_SUBTYPE);
2392
2393 vosStatus = WDA_DS_BuildTxPacketInfo( pvosGCtx, vosDataBuff ,
2394 &vDestMacAddr, pMetaInfo->ucDisableFrmXtl,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302395 &usPktLen, pTLCb->atlSTAClients[ucStaId]->wSTADesc.ucQosEnabled,
Jeff Johnson295189b2012-06-20 16:38:30 -07002396 ucWDSEnabled, extraHeadSpace, pMetaInfo->ucType,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302397 &pTLCb->atlSTAClients[ucStaId]->wSTADesc.vSelfMACAddress,
Jeff Johnson295189b2012-06-20 16:38:30 -07002398 pMetaInfo->ucTID, 0 /* No ACK */, pMetaInfo->usTimeStamp,
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -07002399 pMetaInfo->ucIsEapol || pMetaInfo->ucIsWai, pMetaInfo->ucUP );
Jeff Johnson295189b2012-06-20 16:38:30 -07002400
2401 if ( VOS_STATUS_SUCCESS != vosStatus )
2402 {
2403 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2404 "WLAN TL:Failed while building TX header %d", vosStatus));
2405 return vosStatus;
2406 }
2407
2408 if ( NULL != pfnTlBAPTxComp )
2409 {
2410 vos_pkt_set_user_data_ptr( vosDataBuff, VOS_PKT_USER_DATA_ID_TL,
2411 (v_PVOID_t)pfnTlBAPTxComp);
2412 }
2413 else
2414 {
2415 vos_pkt_set_user_data_ptr( vosDataBuff, VOS_PKT_USER_DATA_ID_TL,
2416 (v_PVOID_t)WLANTL_TxCompDefaultCb);
2417
2418 }
2419
2420 vos_atomic_set_U32( (v_U32_t*)&pTLCb->tlBAPClient.vosPendingDataBuff,
2421 (v_U32_t)vosDataBuff);
2422
2423 /*------------------------------------------------------------------------
2424 Check if thre are enough resources for transmission and tx is not
2425 suspended.
2426 ------------------------------------------------------------------------*/
2427 if (( pTLCb->uResCount >= WDA_TLI_MIN_RES_BAP ) &&
2428 ( 0 == pTLCb->ucTxSuspended ))
2429 {
2430 WDA_DS_StartXmit(pvosGCtx);
2431 }
2432 else
2433 {
2434 /*---------------------------------------------------------------------
2435 No error code is sent because TL will resume tx autonomously if
2436 resources become available or tx gets resumed
2437 ---------------------------------------------------------------------*/
2438 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
2439 "WLAN TL:Request to send from BAP but condition not met.Res: %d,"
2440 "Suspend: %d", pTLCb->uResCount, pTLCb->ucTxSuspended ));
2441 }
2442
2443 return VOS_STATUS_SUCCESS;
2444}/* WLANTL_TxBAPFrm */
2445
2446
2447/*----------------------------------------------------------------------------
2448 INTERACTION WITH SME
2449 ---------------------------------------------------------------------------*/
2450
2451/*==========================================================================
2452
2453 FUNCTION WLANTL_GetRssi
2454
2455 DESCRIPTION
2456 TL will extract the RSSI information from every data packet from the
2457 ongoing traffic and will store it. It will provide the result to SME
2458 upon request.
2459
2460 DEPENDENCIES
2461
2462 WARNING: the read and write of this value will not be protected
2463 by locks, therefore the information obtained after a read
2464 might not always be consistent.
2465
2466 PARAMETERS
2467
2468 IN
2469 pvosGCtx: pointer to the global vos context; a handle to TL's
2470 or SME's control block can be extracted from its context
2471 ucSTAId: station identifier for the requested value
2472
2473 OUT
2474 puRssi: the average value of the RSSI
2475
2476
2477 RETURN VALUE
2478 The result code associated with performing the operation
2479
2480 VOS_STATUS_E_INVAL: Input parameters are invalid
2481 VOS_STATUS_E_FAULT: Station ID is outside array boundaries or pointer
2482 to TL cb is NULL ; access would cause a page fault
2483 VOS_STATUS_E_EXISTS: STA was not yet registered
2484 VOS_STATUS_SUCCESS: Everything is good :)
2485
2486 SIDE EFFECTS
2487
2488============================================================================*/
2489VOS_STATUS
2490WLANTL_GetRssi
2491(
2492 v_PVOID_t pvosGCtx,
2493 v_U8_t ucSTAId,
2494 v_S7_t* pRssi
2495)
2496{
2497 WLANTL_CbType* pTLCb = NULL;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302498 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002499 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
2500
2501 /*------------------------------------------------------------------------
2502 Sanity check
2503 ------------------------------------------------------------------------*/
2504 if ( NULL == pRssi )
2505 {
2506 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2507 "WLAN TL:Invalid parameter sent on WLANTL_GetRssi"));
2508 return VOS_STATUS_E_INVAL;
2509 }
2510
2511 if ( WLANTL_STA_ID_INVALID( ucSTAId ) )
2512 {
2513 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2514 "WLAN TL:Invalid station id requested on WLANTL_GetRssi"));
2515 return VOS_STATUS_E_FAULT;
2516 }
2517
2518 /*------------------------------------------------------------------------
2519 Extract TL control block and check existance
2520 ------------------------------------------------------------------------*/
2521 pTLCb = VOS_GET_TL_CB(pvosGCtx);
2522 if ( NULL == pTLCb )
2523 {
2524 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2525 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_GetRssi"));
2526 return VOS_STATUS_E_FAULT;
2527 }
2528
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302529 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
2530
2531 if ( NULL == pClientSTA )
2532 {
2533 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2534 "WLAN TL:Client Memory was not allocated on %s", __func__));
2535 return VOS_STATUS_E_FAILURE;
2536 }
2537
2538 if ( 0 == pClientSTA->ucExists )
Jeff Johnson295189b2012-06-20 16:38:30 -07002539 {
2540 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2541 "WLAN TL:Station was not previously registered on WLANTL_GetRssi"));
2542 return VOS_STATUS_E_EXISTS;
2543 }
2544
2545 /*------------------------------------------------------------------------
2546 Copy will not be locked; please read restriction
2547 ------------------------------------------------------------------------*/
Katya Nigam5c2e5f62013-11-15 19:19:11 +05302548 if(pTLCb->isBMPS || IS_ACTIVEMODE_OFFLOAD_FEATURE_ENABLE)
Jeff Johnson295189b2012-06-20 16:38:30 -07002549 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302550 *pRssi = pClientSTA->rssiAvgBmps;
Jeff Johnson295189b2012-06-20 16:38:30 -07002551 /* Check If RSSI is zero because we are reading rssAvgBmps updated by HAL in
2552 previous GetStatsRequest. It may be updated as zero by Hal because EnterBmps
2553 might not have happend by that time. Hence reading the most recent Rssi
2554 calcluated by TL*/
2555 if(0 == *pRssi)
2556 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302557 *pRssi = pClientSTA->rssiAvg;
Jeff Johnson295189b2012-06-20 16:38:30 -07002558 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002559 }
2560 else
2561 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302562 *pRssi = pClientSTA->rssiAvg;
Jeff Johnson295189b2012-06-20 16:38:30 -07002563 }
2564
2565 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
Jeff Johnson32d95a32012-09-10 13:15:23 -07002566 "WLAN TL:WLANTL_GetRssi for STA: %d RSSI: %d%s",
2567 ucSTAId, *pRssi,
2568 pTLCb->isBMPS ? " in BMPS" : ""));
Jeff Johnson295189b2012-06-20 16:38:30 -07002569
2570 return VOS_STATUS_SUCCESS;
2571}/* WLANTL_GetRssi */
2572
2573/*==========================================================================
2574
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05302575 FUNCTION WLANTL_GetSnr
2576
2577 DESCRIPTION
2578 TL will extract the SNR information from every data packet from the
2579 ongoing traffic and will store it. It will provide the result to SME
2580 upon request.
2581
2582 DEPENDENCIES
2583
2584 WARNING: the read and write of this value will not be protected
2585 by locks, therefore the information obtained after a read
2586 might not always be consistent.
2587
2588 PARAMETERS
2589
2590 IN
2591 pvosGCtx: pointer to the global vos context; a handle to TL's
2592 or SME's control block can be extracted from its context
2593 ucSTAId: station identifier for the requested value
2594
2595 OUT
2596 pSnr: the average value of the SNR
2597
2598
2599 RETURN VALUE
2600 The result code associated with performing the operation
2601
2602 VOS_STATUS_E_INVAL: Input parameters are invalid
2603 VOS_STATUS_E_FAULT: Station ID is outside array boundaries or pointer
2604 to TL cb is NULL ; access would cause a page fault
2605 VOS_STATUS_E_EXISTS: STA was not yet registered
2606 VOS_STATUS_SUCCESS: Everything is good :)
2607
2608 SIDE EFFECTS
2609
2610============================================================================*/
2611VOS_STATUS
2612WLANTL_GetSnr
2613(
2614 tANI_U8 ucSTAId,
2615 tANI_S8* pSnr
2616)
2617{
2618 WLANTL_CbType* pTLCb = NULL;
2619 WLANTL_STAClientType* pClientSTA = NULL;
2620 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
2621
2622 /*------------------------------------------------------------------------
2623 Sanity check
2624 ------------------------------------------------------------------------*/
2625 if (NULL == pSnr)
2626 {
2627 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2628 "WLAN TL:Invalid parameter sent on %s", __func__));
2629 return VOS_STATUS_E_INVAL;
2630 }
2631
2632 if (WLANTL_STA_ID_INVALID(ucSTAId))
2633 {
2634 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2635 "WLAN TL:Invalid station id requested on %s", __func__));
2636 return VOS_STATUS_E_FAULT;
2637 }
2638
2639 /*------------------------------------------------------------------------
2640 Extract TL control block and check existance
2641 ------------------------------------------------------------------------*/
2642 pTLCb = VOS_GET_TL_CB(vos_get_global_context(VOS_MODULE_ID_TL, NULL));
2643 if (NULL == pTLCb)
2644 {
2645 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2646 "WLAN TL:Invalid TL pointer from pvosGCtx on %s", __func__));
2647 return VOS_STATUS_E_FAULT;
2648 }
2649
2650 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
2651
2652 if (NULL == pClientSTA)
2653 {
2654 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2655 "WLAN TL:Client Memory was not allocated on %s", __func__));
2656 return VOS_STATUS_E_FAILURE;
2657 }
2658
2659 if (0 == pClientSTA->ucExists)
2660 {
2661 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2662 "WLAN TL:Station was not previously registered on %s", __func__));
2663 return VOS_STATUS_E_EXISTS;
2664 }
2665
2666 /*------------------------------------------------------------------------
2667 Copy will not be locked; please read restriction
2668 ------------------------------------------------------------------------*/
2669 if (pTLCb->isBMPS)
2670 {
2671 *pSnr = pClientSTA->snrAvgBmps;
2672 }
2673 else
2674 {
2675 /* SNR is averaged over WLANTL_MAX_SNR_DATA_SAMPLES, if there are not enough
2676 * data samples (snridx) to calculate the average then return the
2677 * average for the window of prevoius 20 packets. And if there aren't
2678 * enough samples and the average for previous window of 20 packets is
2679 * not available then return a predefined value
2680 *
2681 * NOTE: the SNR_HACK_BMPS value is defined to 127, documents from HW
2682 * team reveal that the SNR value has a ceiling well below 127 dBm,
2683 * so if SNR has value of 127 the userspace applications can know that
2684 * the SNR has not been computed yet because enough data was not
2685 * available for SNR calculation
2686 */
2687 if (pClientSTA->snrIdx > (WLANTL_MAX_SNR_DATA_SAMPLES/2)
2688 || !(pClientSTA->prevSnrAvg))
2689 {
2690 *pSnr = pClientSTA->snrSum / pClientSTA->snrIdx;
2691 }
2692 else if (pClientSTA->prevSnrAvg)
2693 {
2694 *pSnr = pClientSTA->prevSnrAvg;
2695 }
2696 else
2697 {
2698 *pSnr = SNR_HACK_BMPS;
2699 }
2700 }
2701
2702 VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
2703 "WLAN TL:WLANTL_GetSnr for STA: %d SNR: %d%s",
2704 ucSTAId, *pSnr,
2705 pTLCb->isBMPS ? " in BMPS" : "");
2706
2707 return VOS_STATUS_SUCCESS;
2708}/* WLANTL_GetSnr */
2709/*==========================================================================
2710
Jeff Johnson295189b2012-06-20 16:38:30 -07002711 FUNCTION WLANTL_GetLinkQuality
2712
2713 DESCRIPTION
2714 TL will extract the SNR information from every data packet from the
2715 ongoing traffic and will store it. It will provide the result to SME
2716 upon request.
2717
2718 DEPENDENCIES
2719
2720 WARNING: the read and write of this value will not be protected
2721 by locks, therefore the information obtained after a read
2722 might not always be consistent.
2723
2724 PARAMETERS
2725
2726 IN
2727 pvosGCtx: pointer to the global vos context; a handle to TL's
2728 or SME's control block can be extracted from its context
2729 ucSTAId: station identifier for the requested value
2730
2731 OUT
2732 puLinkQuality: the average value of the SNR
2733
2734
2735 RETURN VALUE
2736 The result code associated with performing the operation
2737
2738 VOS_STATUS_E_INVAL: Input parameters are invalid
2739 VOS_STATUS_E_FAULT: Station ID is outside array boundaries or pointer
2740 to TL cb is NULL ; access would cause a page fault
2741 VOS_STATUS_E_EXISTS: STA was not yet registered
2742 VOS_STATUS_SUCCESS: Everything is good :)
2743
2744 SIDE EFFECTS
2745
2746============================================================================*/
2747VOS_STATUS
2748WLANTL_GetLinkQuality
2749(
2750 v_PVOID_t pvosGCtx,
2751 v_U8_t ucSTAId,
2752 v_U32_t* puLinkQuality
2753)
2754{
2755 WLANTL_CbType* pTLCb = NULL;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302756 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002757
2758 /*------------------------------------------------------------------------
2759 Sanity check
2760 ------------------------------------------------------------------------*/
2761 if ( NULL == puLinkQuality )
2762 {
2763 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2764 "Invalid parameter sent on WLANTL_GetLinkQuality"));
2765 return VOS_STATUS_E_INVAL;
2766 }
2767
2768 if ( WLANTL_STA_ID_INVALID( ucSTAId ) )
2769 {
2770 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2771 "Invalid station id requested on WLANTL_GetLinkQuality"));
2772 return VOS_STATUS_E_FAULT;
2773 }
2774
2775 /*------------------------------------------------------------------------
2776 Extract TL control block and check existance
2777 ------------------------------------------------------------------------*/
2778 pTLCb = VOS_GET_TL_CB(pvosGCtx);
2779 if ( NULL == pTLCb )
2780 {
2781 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2782 "Invalid TL pointer from pvosGCtx on WLANTL_GetLinkQuality"));
2783 return VOS_STATUS_E_FAULT;
2784 }
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302785 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
Jeff Johnson295189b2012-06-20 16:38:30 -07002786
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302787 if ( NULL == pClientSTA )
2788 {
2789 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2790 "WLAN TL:Client Memory was not allocated on %s", __func__));
2791 return VOS_STATUS_E_FAILURE;
2792 }
2793
2794 if ( 0 == pClientSTA->ucExists )
Jeff Johnson295189b2012-06-20 16:38:30 -07002795 {
2796 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2797 "Station was not previously registered on WLANTL_GetLinkQuality"));
2798 return VOS_STATUS_E_EXISTS;
2799 }
2800
2801 /*------------------------------------------------------------------------
2802 Copy will not be locked; please read restriction
2803 ------------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302804 *puLinkQuality = pClientSTA->uLinkQualityAvg;
Jeff Johnson295189b2012-06-20 16:38:30 -07002805
2806 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
2807 "WLANTL_GetLinkQuality for STA: %d LinkQuality: %d", ucSTAId, *puLinkQuality));
2808
2809 return VOS_STATUS_SUCCESS;
2810}/* WLANTL_GetLinkQuality */
2811
2812/*==========================================================================
2813
2814 FUNCTION WLANTL_FlushStaTID
2815
2816 DESCRIPTION
2817 TL provides this API as an interface to SME (BAP) layer. TL inturn posts a
2818 message to HAL. This API is called by the SME inorder to perform a flush
2819 operation.
2820
2821 DEPENDENCIES
2822
2823 PARAMETERS
2824
2825 IN
2826 pvosGCtx: pointer to the global vos context; a handle to TL's
2827 or SME's control block can be extracted from its context
2828 ucSTAId: station identifier for the requested value
2829 ucTid: Tspec ID for the new BA session
2830
2831 OUT
2832 The response for this post is received in the main thread, via a response
2833 message from HAL to TL.
2834
2835 RETURN VALUE
2836 VOS_STATUS_SUCCESS: Everything is good :)
2837
2838 SIDE EFFECTS
2839============================================================================*/
2840VOS_STATUS
2841WLANTL_FlushStaTID
2842(
2843 v_PVOID_t pvosGCtx,
2844 v_U8_t ucSTAId,
2845 v_U8_t ucTid
2846)
2847{
2848 WLANTL_CbType* pTLCb = NULL;
2849 tpFlushACReq FlushACReqPtr = NULL;
2850 vos_msg_t vosMessage;
2851
2852
2853 if ( WLANTL_STA_ID_INVALID( ucSTAId ) )
2854 {
2855 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2856 "Invalid station id requested on WLANTL_FlushStaTID"));
2857 return VOS_STATUS_E_FAULT;
2858 }
2859
2860 /*------------------------------------------------------------------------
2861 Extract TL control block and check existance
2862 ------------------------------------------------------------------------*/
2863 pTLCb = VOS_GET_TL_CB(pvosGCtx);
2864 if ( NULL == pTLCb )
2865 {
2866 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2867 "Invalid TL pointer from pvosGCtx on WLANTL_FlushStaTID"));
2868 return VOS_STATUS_E_FAULT;
2869 }
2870
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302871 if ( NULL == pTLCb->atlSTAClients[ucSTAId] )
2872 {
2873 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2874 "WLAN TL:Client Memory was not allocated on %s", __func__));
2875 return VOS_STATUS_E_FAILURE;
2876 }
2877
2878 if ( 0 == pTLCb->atlSTAClients[ucSTAId]->ucExists )
Jeff Johnson295189b2012-06-20 16:38:30 -07002879 {
2880 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2881 "Station was not previously registered on WLANTL_FlushStaTID"));
2882 return VOS_STATUS_E_EXISTS;
2883 }
2884
2885 /*------------------------------------------------------------------------
2886 We need to post a message with the STA, TID value to HAL. HAL performs the flush
2887 ------------------------------------------------------------------------*/
2888 FlushACReqPtr = vos_mem_malloc(sizeof(tFlushACReq));
2889
2890 if ( NULL == FlushACReqPtr )
2891 {
2892 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2893 "WLAN TL: fatal failure, cannot allocate Flush Req structure"));
2894 VOS_ASSERT(0);
2895 return VOS_STATUS_E_NOMEM;
2896 }
2897
2898 // Start constructing the message for HAL
2899 FlushACReqPtr->mesgType = SIR_TL_HAL_FLUSH_AC_REQ;
2900 FlushACReqPtr->mesgLen = sizeof(tFlushACReq);
2901 FlushACReqPtr->mesgLen = sizeof(tFlushACReq);
2902 FlushACReqPtr->ucSTAId = ucSTAId;
2903 FlushACReqPtr->ucTid = ucTid;
2904
2905 vosMessage.type = WDA_TL_FLUSH_AC_REQ;
2906 vosMessage.bodyptr = (void *)FlushACReqPtr;
2907
2908 vos_mq_post_message(VOS_MQ_ID_WDA, &vosMessage);
2909 return VOS_STATUS_SUCCESS;
2910}
2911
2912
2913/*----------------------------------------------------------------------------
2914 INTERACTION WITH PE
2915 ---------------------------------------------------------------------------*/
2916
2917/*==========================================================================
2918
2919 FUNCTION WLANTL_RegisterMgmtFrmClient
2920
2921 DESCRIPTION
2922 Called by PE to register as a client for management frames delivery.
2923
2924 DEPENDENCIES
2925 TL must be initialized before this API can be called.
2926
2927 PARAMETERS
2928
2929 IN
2930 pvosGCtx: pointer to the global vos context; a handle to
2931 TL's control block can be extracted from its context
2932 pfnTlMgmtFrmRx: pointer to the receive processing routine for
2933 management frames
2934
2935 RETURN VALUE
2936 The result code associated with performing the operation
2937
2938 VOS_STATUS_E_INVAL: Input parameters are invalid
2939 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
2940 page fault
2941 VOS_STATUS_E_EXISTS: Mgmt Frame client was already registered
2942 VOS_STATUS_SUCCESS: Everything is good :)
2943
2944 SIDE EFFECTS
2945
2946============================================================================*/
2947VOS_STATUS
2948WLANTL_RegisterMgmtFrmClient
2949(
2950 v_PVOID_t pvosGCtx,
2951 WLANTL_MgmtFrmRxCBType pfnTlMgmtFrmRx
2952)
2953{
2954 WLANTL_CbType* pTLCb = NULL;
2955 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
2956
2957 /*------------------------------------------------------------------------
2958 Sanity check
2959 ------------------------------------------------------------------------*/
2960 if ( NULL == pfnTlMgmtFrmRx )
2961 {
2962 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2963 "WLAN TL:Invalid parameter sent on WLANTL_RegisterMgmtFrmClient"));
2964 return VOS_STATUS_E_INVAL;
2965 }
2966
2967 /*------------------------------------------------------------------------
2968 Extract TL control block
2969 ------------------------------------------------------------------------*/
2970 pTLCb = VOS_GET_TL_CB(pvosGCtx);
2971 if ( NULL == pTLCb )
2972 {
2973 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2974 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_ChangeSTAState"));
2975 return VOS_STATUS_E_FAULT;
2976 }
2977
2978 /*------------------------------------------------------------------------
2979 Make sure this is the first registration attempt
2980 ------------------------------------------------------------------------*/
2981 if ( 0 != pTLCb->tlMgmtFrmClient.ucExists )
2982 {
2983 pTLCb->tlMgmtFrmClient.ucExists++;
2984 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2985 "WLAN TL:Management frame client was already registered"));
2986 return VOS_STATUS_E_EXISTS;
2987 }
2988
2989 /*------------------------------------------------------------------------
2990 Register station with TL
2991 ------------------------------------------------------------------------*/
2992 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
2993 "WLAN TL:Registering Management Frame Client" ));
2994
2995 pTLCb->tlMgmtFrmClient.ucExists++;
2996
2997 if ( NULL != pfnTlMgmtFrmRx )
2998 {
2999 pTLCb->tlMgmtFrmClient.pfnTlMgmtFrmRx = pfnTlMgmtFrmRx;
3000 }
3001
3002 pTLCb->tlMgmtFrmClient.vosPendingDataBuff = NULL;
3003
3004 return VOS_STATUS_SUCCESS;
3005}/* WLANTL_RegisterMgmtFrmClient */
3006
3007/*==========================================================================
3008
3009 FUNCTION WLANTL_DeRegisterMgmtFrmClient
3010
3011 DESCRIPTION
3012 Called by PE to deregister as a client for management frames delivery.
3013
3014 DEPENDENCIES
3015 TL must be initialized before this API can be called.
3016
3017 PARAMETERS
3018
3019 IN
3020 pvosGCtx: pointer to the global vos context; a handle to
3021 TL's control block can be extracted from its context
3022 RETURN VALUE
3023 The result code associated with performing the operation
3024
3025 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
3026 page fault
3027 VOS_STATUS_E_EXISTS: Mgmt Frame client was never registered
3028 VOS_STATUS_SUCCESS: Everything is good :)
3029
3030 SIDE EFFECTS
3031
3032============================================================================*/
3033VOS_STATUS
3034WLANTL_DeRegisterMgmtFrmClient
3035(
3036 v_PVOID_t pvosGCtx
3037)
3038{
3039 WLANTL_CbType* pTLCb = NULL;
3040 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
3041
3042 /*------------------------------------------------------------------------
3043 Extract TL control block
3044 ------------------------------------------------------------------------*/
3045 pTLCb = VOS_GET_TL_CB(pvosGCtx);
3046 if ( NULL == pTLCb )
3047 {
3048 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3049 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_ChangeSTAState"));
3050 return VOS_STATUS_E_FAULT;
3051 }
3052
3053 /*------------------------------------------------------------------------
3054 Make sure this is the first registration attempt
3055 ------------------------------------------------------------------------*/
3056 if ( 0 == pTLCb->tlMgmtFrmClient.ucExists )
3057 {
3058 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3059 "WLAN TL:Management frame client was never registered"));
3060 return VOS_STATUS_E_EXISTS;
3061 }
3062
3063 /*------------------------------------------------------------------------
3064 Clear registration with TL
3065 ------------------------------------------------------------------------*/
3066 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
3067 "WLAN TL:Deregistering Management Frame Client" ));
3068
3069 pTLCb->tlMgmtFrmClient.pfnTlMgmtFrmRx = WLANTL_MgmtFrmRxDefaultCb;
3070 if ( NULL != pTLCb->tlMgmtFrmClient.vosPendingDataBuff)
3071 {
3072 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
3073 "WLAN TL:Management cache buffer not empty on deregistering"
3074 " - dropping packet" ));
3075 vos_pkt_return_packet(pTLCb->tlMgmtFrmClient.vosPendingDataBuff);
3076
3077 pTLCb->tlMgmtFrmClient.vosPendingDataBuff = NULL;
3078 }
3079
3080 pTLCb->tlMgmtFrmClient.ucExists = 0;
3081
3082 return VOS_STATUS_SUCCESS;
3083}/* WLANTL_RegisterMgmtFrmClient */
3084
3085/*==========================================================================
3086
3087 FUNCTION WLANTL_TxMgmtFrm
3088
3089 DESCRIPTION
3090 Called by PE when it want to send out a management frame.
3091 HAL will also use this API for the few frames it sends out, they are not
3092 management frames howevere it is accepted that an exception will be
3093 allowed ONLY for the usage of HAL.
3094 Generic data frames SHOULD NOT travel through this function.
3095
3096 DEPENDENCIES
3097 TL must be initialized before this API can be called.
3098
3099 RESTRICTION: If PE sends another packet before TL manages to process the
3100 previously sent packet call will end in failure
3101
3102 Frames comming through here must be 802.11 frames, frame
3103 translation in UMA will be automatically disabled.
3104
3105 PARAMETERS
3106
3107 IN
3108 pvosGCtx: pointer to the global vos context;a handle to TL's
3109 control block can be extracted from its context
3110 vosFrmBuf: pointer to a vOSS buffer containing the management
3111 frame to be transmitted
3112 usFrmLen: the length of the frame to be transmitted; information
3113 is already included in the vOSS buffer
3114 wFrmType: the type of the frame being transmitted
3115 tid: tid used to transmit this frame
3116 pfnCompTxFunc: function pointer to the transmit complete routine
3117 pvBDHeader: pointer to the BD header, if NULL it means it was not
3118 yet constructed and it lies within TL's responsibility
3119 to do so; if not NULL it is expected that it was
3120 already packed inside the vos packet
3121 ucAckResponse: flag notifying it an interrupt is needed for the
3122 acknowledgement received when the frame is sent out
3123 the air and ; the interrupt will be processed by HAL,
3124 only one such frame can be pending in the system at
3125 one time.
3126
3127
3128 RETURN VALUE
3129 The result code associated with performing the operation
3130
3131 VOS_STATUS_E_INVAL: Input parameters are invalid
3132 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
3133 page fault
3134 VOS_STATUS_E_EXISTS: Mgmt Frame client was not yet registered
3135 VOS_STATUS_E_BUSY: The previous Mgmt packet was not yet transmitted
3136 VOS_STATUS_SUCCESS: Everything is good :)
3137
3138 Other failure messages may be returned from the BD header handling
3139 routines, please check apropriate API for more info.
3140
3141 SIDE EFFECTS
3142
3143============================================================================*/
3144VOS_STATUS
3145WLANTL_TxMgmtFrm
3146(
3147 v_PVOID_t pvosGCtx,
3148 vos_pkt_t* vosFrmBuf,
3149 v_U16_t usFrmLen,
3150 v_U8_t wFrmType,
3151 v_U8_t ucTid,
3152 WLANTL_TxCompCBType pfnCompTxFunc,
3153 v_PVOID_t pvBDHeader,
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05303154 v_U32_t ucAckResponse
Jeff Johnson295189b2012-06-20 16:38:30 -07003155)
3156{
3157 WLANTL_CbType* pTLCb = NULL;
3158 v_MACADDR_t vDestMacAddr;
3159 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
3160 v_U16_t usPktLen;
3161 v_U32_t usTimeStamp = 0;
3162 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
3163
3164 /*------------------------------------------------------------------------
3165 Sanity check
3166 ------------------------------------------------------------------------*/
3167 if ( NULL == vosFrmBuf )
3168 {
3169 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3170 "WLAN TL:Invalid parameter sent on WLANTL_TxMgmtFrm"));
3171 return VOS_STATUS_E_INVAL;
3172 }
3173
3174 /*------------------------------------------------------------------------
3175 Extract TL control block
3176 ------------------------------------------------------------------------*/
3177 pTLCb = VOS_GET_TL_CB(pvosGCtx);
3178 if ( NULL == pTLCb )
3179 {
3180 TLLOGP(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_FATAL,
3181 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_TxMgmtFrm"));
3182 return VOS_STATUS_E_FAULT;
3183 }
3184
3185 /*------------------------------------------------------------------------
3186 Ensure that management frame client was previously registered
3187 ------------------------------------------------------------------------*/
3188 if ( 0 == pTLCb->tlMgmtFrmClient.ucExists )
3189 {
3190 pTLCb->tlMgmtFrmClient.ucExists++;
3191 TLLOGP(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_FATAL,
3192 "WLAN TL:Management Frame client not register on WLANTL_TxMgmtFrm"));
3193 return VOS_STATUS_E_EXISTS;
3194 }
3195
3196 /*------------------------------------------------------------------------
3197 Check if any Mgmt Frm is pending
3198 ------------------------------------------------------------------------*/
3199 //vosTempBuff = pTLCb->tlMgmtFrmClient.vosPendingDataBuff;
3200 if ( NULL != pTLCb->tlMgmtFrmClient.vosPendingDataBuff )
3201 {
3202
3203 TLLOGP(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_FATAL,
3204 "WLAN TL:Management Frame already pending tx in TL: failing old one"));
3205
3206
3207 /*Failing the tx for the previous packet enqued by PE*/
3208 //vos_atomic_set_U32( (v_U32_t*)&pTLCb->tlMgmtFrmClient.vosPendingDataBuff,
3209 // (v_U32_t)NULL);
3210
3211 //vos_pkt_get_user_data_ptr( vosTempBuff, VOS_PKT_USER_DATA_ID_TL,
3212 // (v_PVOID_t)&pfnTxComp);
3213
3214 /*it should never be NULL - default handler should be registered if none*/
3215 //if ( NULL == pfnTxComp )
3216 //{
3217 // VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3218 // "NULL pointer to Tx Complete on WLANTL_TxMgmtFrm");
3219 // VOS_ASSERT(0);
3220 // return VOS_STATUS_E_FAULT;
3221 //}
3222
3223 //pfnTxComp( pvosGCtx, vosTempBuff, VOS_STATUS_E_RESOURCES );
3224 //return VOS_STATUS_E_BUSY;
3225
3226
3227 //pfnCompTxFunc( pvosGCtx, vosFrmBuf, VOS_STATUS_E_RESOURCES);
3228 return VOS_STATUS_E_RESOURCES;
3229 }
3230
3231
3232 /*------------------------------------------------------------------------
3233 Check if BD header was build, if not construct
3234 ------------------------------------------------------------------------*/
3235 if ( NULL == pvBDHeader )
3236 {
3237 v_MACADDR_t* pvAddr2MacAddr;
3238 v_U8_t uQosHdr = VOS_FALSE;
3239
3240 /* Get address 2 of Mangement Frame to give to WLANHAL_FillTxBd */
3241 vosStatus = vos_pkt_peek_data( vosFrmBuf,
3242 WLANTL_MAC_ADDR_ALIGN(1) + VOS_MAC_ADDR_SIZE,
3243 (v_PVOID_t)&pvAddr2MacAddr, VOS_MAC_ADDR_SIZE);
3244
3245 if ( VOS_STATUS_SUCCESS != vosStatus )
3246 {
3247 TLLOGP(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_FATAL,
3248 "WLAN TL:Failed while attempting to get addr2 %d", vosStatus));
3249 return vosStatus;
3250 }
Gopichand Nakkala0f3eb5c2013-05-07 16:48:38 +05303251
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003252 /* ESE IAPP/TDLS Frame which are data frames but technically used
Jeff Johnson295189b2012-06-20 16:38:30 -07003253 * for management functionality comes through route.
3254 */
3255 if (WLANTL_IS_QOS_DATA_FRAME(wFrmType)) \
3256 {
3257 uQosHdr = VOS_TRUE;
3258 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003259 /*----------------------------------------------------------------------
3260 Call WDA to build TX header
3261 ----------------------------------------------------------------------*/
3262 vosStatus = WDA_DS_BuildTxPacketInfo( pvosGCtx, vosFrmBuf , &vDestMacAddr,
3263 1 /* always 802.11 frames*/, &usPktLen, uQosHdr /*qos not enabled !!!*/,
3264 0 /* WDS off */, 0, wFrmType, pvAddr2MacAddr, ucTid,
3265 ucAckResponse, usTimeStamp, 0, 0 );
3266
3267
3268 if ( !VOS_IS_STATUS_SUCCESS(vosStatus) )
3269 {
3270 TLLOGP(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_FATAL,
3271 "WLAN TL:Failed while attempting to build TX header %d", vosStatus));
3272 return vosStatus;
3273 }
3274 }/* if BD header not present */
3275
3276 /*------------------------------------------------------------------------
3277 Save buffer and notify BAL; no lock is needed if the above restriction
3278 is met
3279 Save the tx complete fnct pointer as tl specific data in the vos buffer
3280 ------------------------------------------------------------------------*/
3281 if ( NULL != pfnCompTxFunc )
3282 {
3283 vos_pkt_set_user_data_ptr( vosFrmBuf, VOS_PKT_USER_DATA_ID_TL,
3284 (v_PVOID_t)pfnCompTxFunc);
3285 }
3286 else
3287 {
3288 vos_pkt_set_user_data_ptr( vosFrmBuf, VOS_PKT_USER_DATA_ID_TL,
3289 (v_PVOID_t)WLANTL_TxCompDefaultCb);
3290
3291 }
3292
3293 vos_atomic_set_U32( (v_U32_t*)&pTLCb->tlMgmtFrmClient.vosPendingDataBuff,
3294 (v_U32_t)vosFrmBuf);
3295
3296 /*------------------------------------------------------------------------
3297 Check if thre are enough resources for transmission and tx is not
3298 suspended.
3299 ------------------------------------------------------------------------*/
3300 if ( pTLCb->uResCount >= WDA_TLI_MIN_RES_MF )
3301 {
3302 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
3303 "WLAN TL:Issuing Xmit start request to BAL for MGMT"));
3304 vosStatus = WDA_DS_StartXmit(pvosGCtx);
3305 if(VOS_STATUS_SUCCESS != vosStatus)
3306 {
3307 TLLOGP(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_FATAL,
3308 "WLAN TL:WDA_DS_StartXmit fails. vosStatus %d", vosStatus));
3309 vos_atomic_set_U32( (v_U32_t*)&pTLCb->tlMgmtFrmClient.vosPendingDataBuff,0);
3310 }
3311 return vosStatus;
3312
3313 }
3314 else
3315 {
3316 /*---------------------------------------------------------------------
3317 No error code is sent because TL will resume tx autonomously if
3318 resources become available or tx gets resumed
3319 ---------------------------------------------------------------------*/
3320 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
3321 "WLAN TL:Request to send for Mgmt Frm but condition not met. Res: %d",
3322 pTLCb->uResCount));
3323 }
3324
3325 return VOS_STATUS_SUCCESS;
3326}/* WLANTL_TxMgmtFrm */
3327
3328/*----------------------------------------------------------------------------
3329 INTERACTION WITH HAL
3330 ---------------------------------------------------------------------------*/
3331
3332/*==========================================================================
3333
3334 FUNCTION WLANTL_ResetNotification
3335
3336 DESCRIPTION
3337 HAL notifies TL when the module is being reset.
3338 Currently not used.
3339
3340 DEPENDENCIES
3341
3342 PARAMETERS
3343
3344 IN
3345 pvosGCtx: pointer to the global vos context; a handle to TL's
3346 control block can be extracted from its context
3347
3348
3349 RETURN VALUE
3350 The result code associated with performing the operation
3351
3352 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
3353 page fault
3354 VOS_STATUS_SUCCESS: Everything is good :)
3355
3356 SIDE EFFECTS
3357
3358============================================================================*/
3359VOS_STATUS
3360WLANTL_ResetNotification
3361(
3362 v_PVOID_t pvosGCtx
3363)
3364{
3365 WLANTL_CbType* pTLCb = NULL;
3366 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
3367
3368 /*------------------------------------------------------------------------
3369 Sanity check
3370 Extract TL control block
3371 ------------------------------------------------------------------------*/
3372 pTLCb = VOS_GET_TL_CB(pvosGCtx);
3373 if ( NULL == pTLCb )
3374 {
3375 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3376 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_ResetNotification"));
3377 return VOS_STATUS_E_FAULT;
3378 }
3379
3380 WLANTL_CleanCB(pTLCb, 1 /*empty all queues and pending packets*/);
3381 return VOS_STATUS_SUCCESS;
3382}/* WLANTL_ResetNotification */
3383
3384/*==========================================================================
3385
3386 FUNCTION WLANTL_SuspendDataTx
3387
3388 DESCRIPTION
3389 HAL calls this API when it wishes to suspend transmission for a
3390 particular STA.
3391
3392 DEPENDENCIES
3393 The STA for which the request is made must be first registered with
3394 TL by HDD.
3395
3396 RESTRICTION: In case of a suspend, the flag write and read will not be
3397 locked: worst case scenario one more packet can get
3398 through before the flag gets updated (we can make this
3399 write atomic as well to guarantee consistency)
3400
3401 PARAMETERS
3402
3403 IN
3404 pvosGCtx: pointer to the global vos context; a handle to TL's
3405 control block can be extracted from its context
3406 pucSTAId: identifier of the station for which the request is made;
3407 a value of NULL assumes suspend on all active station
3408 pfnSuspendTxCB: pointer to the suspend result notification in case the
3409 call is asynchronous
3410
3411
3412 RETURN VALUE
3413 The result code associated with performing the operation
3414
3415 VOS_STATUS_E_FAULT: Station ID is outside array boundaries or pointer
3416 to TL cb is NULL ; access would cause a page fault
3417 VOS_STATUS_E_EXISTS: Station was not registered
3418 VOS_STATUS_SUCCESS: Everything is good :)
3419
3420 SIDE EFFECTS
3421
3422============================================================================*/
3423
3424VOS_STATUS
3425WLANTL_SuspendDataTx
3426(
3427 v_PVOID_t pvosGCtx,
3428 v_U8_t* pucSTAId,
3429 WLANTL_SuspendCBType pfnSuspendTx
3430)
3431{
3432 WLANTL_CbType* pTLCb = NULL;
3433 vos_msg_t vosMsg;
Jeff Johnson295189b2012-06-20 16:38:30 -07003434
3435 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
3436
3437 /*------------------------------------------------------------------------
3438 Sanity check
3439 Extract TL control block
3440 ------------------------------------------------------------------------*/
3441 pTLCb = VOS_GET_TL_CB(pvosGCtx);
Hoonki Lee14621352013-04-16 17:51:19 -07003442 if ( NULL == pTLCb )
Jeff Johnson295189b2012-06-20 16:38:30 -07003443 {
3444 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3445 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_SuspendDataTx"));
3446 return VOS_STATUS_E_FAULT;
3447 }
3448
3449 /*------------------------------------------------------------------------
3450 Check the type of request: generic suspend, or per station suspend
3451 ------------------------------------------------------------------------*/
Hoonki Lee14621352013-04-16 17:51:19 -07003452 if (NULL == pucSTAId)
Jeff Johnson295189b2012-06-20 16:38:30 -07003453 {
3454 /* General Suspend Request received */
3455 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
3456 "WLAN TL:General suspend requested"));
Hoonki Lee14621352013-04-16 17:51:19 -07003457 vos_atomic_set_U8( &pTLCb->ucTxSuspended, 1);
Jeff Johnson295189b2012-06-20 16:38:30 -07003458 vosMsg.reserved = WLAN_MAX_STA_COUNT;
3459 }
3460 else
3461 {
Hoonki Lee14621352013-04-16 17:51:19 -07003462 if ( WLANTL_STA_ID_INVALID( *pucSTAId ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07003463 {
Hoonki Lee14621352013-04-16 17:51:19 -07003464 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3465 "WLAN TL:Invalid station id %d requested on WLANTL_SuspendDataTx", *pucSTAId));
3466 return VOS_STATUS_E_FAULT;
3467 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003468
Gopichand Nakkalae5fef6c2013-06-19 18:04:23 +05303469 if ( NULL == pTLCb->atlSTAClients[*pucSTAId] )
3470 {
3471 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3472 "WLAN TL:Invalid pTLCb->atlSTAClients pointer for STA Id :%d on "
3473 "WLANTL_SuspendDataTx", *pucSTAId));
3474 return VOS_STATUS_E_FAULT;
3475 }
3476
3477 if ( 0 == pTLCb->atlSTAClients[*pucSTAId]->ucExists )
Hoonki Lee14621352013-04-16 17:51:19 -07003478 {
3479 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3480 "WLAN TL:Station %d was not previously registered on WLANTL_SuspendDataTx", *pucSTAId));
3481 return VOS_STATUS_E_EXISTS;
3482 }
3483
3484 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
3485 "WLAN TL:Suspend request for station: %d", *pucSTAId));
3486 vos_atomic_set_U8( &pTLCb->atlSTAClients[*pucSTAId]->ucTxSuspended, 1);
Jeff Johnson295189b2012-06-20 16:38:30 -07003487 vosMsg.reserved = *pucSTAId;
3488 }
3489
3490 /*------------------------------------------------------------------------
3491 Serialize request through TX thread
3492 ------------------------------------------------------------------------*/
3493 vosMsg.type = WLANTL_TX_SIG_SUSPEND;
3494 vosMsg.bodyptr = (v_PVOID_t)pfnSuspendTx;
3495
Katya Nigam42e16e82014-02-04 16:28:55 +05303496 MTRACE(vos_trace(VOS_MODULE_ID_TL, TRACE_CODE_TL_SUSPEND_DATA_TX,
3497 vosMsg.reserved , 0 ));
3498
Jeff Johnson295189b2012-06-20 16:38:30 -07003499 if(!VOS_IS_STATUS_SUCCESS(vos_tx_mq_serialize( VOS_MQ_ID_TL, &vosMsg)))
3500 {
3501 VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003502 " %s fails to post message", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003503 }
3504
3505 return VOS_STATUS_SUCCESS;
3506}/* WLANTL_SuspendDataTx */
3507
3508/*==========================================================================
3509
3510 FUNCTION WLANTL_ResumeDataTx
3511
3512 DESCRIPTION
3513 Called by HAL to resume data transmission for a given STA.
3514
3515 WARNING: If a station was individually suspended a global resume will
3516 not resume that station
3517
3518 DEPENDENCIES
3519
3520 PARAMETERS
3521
3522 IN
3523 pvosGCtx: pointer to the global vos context; a handle to TL's
3524 control block can be extracted from its context
3525 pucSTAId: identifier of the station which is being resumed; NULL
3526 translates into global resume
3527
3528 RETURN VALUE
3529 The result code associated with performing the operation
3530
3531 VOS_STATUS_E_FAULT: Station ID is outside array boundaries or pointer
3532 to TL cb is NULL ; access would cause a page fault
3533 VOS_STATUS_E_EXISTS: Station was not registered
3534 VOS_STATUS_SUCCESS: Everything is good :)
3535
3536 SIDE EFFECTS
3537
3538============================================================================*/
3539
3540VOS_STATUS
3541WLANTL_ResumeDataTx
3542(
3543 v_PVOID_t pvosGCtx,
3544 v_U8_t* pucSTAId
3545)
3546{
3547 WLANTL_CbType* pTLCb = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07003548 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
3549
3550 /*------------------------------------------------------------------------
3551 Sanity check
3552 Extract TL control block
3553 ------------------------------------------------------------------------*/
3554 pTLCb = VOS_GET_TL_CB(pvosGCtx);
Hoonki Lee14621352013-04-16 17:51:19 -07003555 if ( NULL == pTLCb )
Jeff Johnson295189b2012-06-20 16:38:30 -07003556 {
3557 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3558 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_ResumeDataTx"));
3559 return VOS_STATUS_E_FAULT;
3560 }
3561
Jeff Johnson295189b2012-06-20 16:38:30 -07003562 /*------------------------------------------------------------------------
3563 Check to see the type of resume
3564 ------------------------------------------------------------------------*/
Hoonki Lee14621352013-04-16 17:51:19 -07003565 if ( NULL == pucSTAId )
Jeff Johnson295189b2012-06-20 16:38:30 -07003566 {
Katya Nigam42e16e82014-02-04 16:28:55 +05303567 MTRACE(vos_trace(VOS_MODULE_ID_TL, TRACE_CODE_TL_RESUME_DATA_TX,
3568 41 , 0 ));
3569
Jeff Johnson295189b2012-06-20 16:38:30 -07003570 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
3571 "WLAN TL:General resume requested"));
3572 vos_atomic_set_U8( &pTLCb->ucTxSuspended, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07003573 }
3574 else
3575 {
Katya Nigam42e16e82014-02-04 16:28:55 +05303576 MTRACE(vos_trace(VOS_MODULE_ID_TL, TRACE_CODE_TL_RESUME_DATA_TX,
3577 *pucSTAId , 0 ));
3578
Hoonki Lee14621352013-04-16 17:51:19 -07003579 if ( WLANTL_STA_ID_INVALID( *pucSTAId ))
Jeff Johnson295189b2012-06-20 16:38:30 -07003580 {
Hoonki Lee14621352013-04-16 17:51:19 -07003581 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3582 "WLAN TL:Invalid station id %d requested on WLANTL_ResumeDataTx", *pucSTAId));
3583 return VOS_STATUS_E_FAULT;
3584 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003585
Gopichand Nakkalae5fef6c2013-06-19 18:04:23 +05303586 if ( NULL == pTLCb->atlSTAClients[*pucSTAId] )
3587 {
3588 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3589 "WLAN TL:Invalid pTLCb->atlSTAClients pointer for STA Id :%d on "
3590 "WLANTL_ResumeDataTx", *pucSTAId));
3591 return VOS_STATUS_E_FAULT;
3592 }
3593
3594 if ( 0 == pTLCb->atlSTAClients[*pucSTAId]->ucExists )
Hoonki Lee14621352013-04-16 17:51:19 -07003595 {
3596 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3597 "WLAN TL:Station %d was not previously registered on WLANTL_ResumeDataTx", *pucSTAId));
3598 return VOS_STATUS_E_EXISTS;
3599 }
3600
3601 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
3602 "WLAN TL:Resume request for station: %d", *pucSTAId));
3603 vos_atomic_set_U8( &pTLCb->atlSTAClients[*pucSTAId]->ucTxSuspended, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07003604 }
3605
3606 /*------------------------------------------------------------------------
3607 Resuming transmission
3608 ------------------------------------------------------------------------*/
Hoonki Lee14621352013-04-16 17:51:19 -07003609 if (( pTLCb->uResCount >= WDA_TLI_MIN_RES_MF ) &&
3610 ( 0 == pTLCb->ucTxSuspended ))
Jeff Johnson295189b2012-06-20 16:38:30 -07003611 {
3612 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
3613 "WLAN TL:Resuming transmission"));
3614 return WDA_DS_StartXmit(pvosGCtx);
3615 }
3616
3617 return VOS_STATUS_SUCCESS;
3618}/* WLANTL_ResumeDataTx */
3619
3620/*==========================================================================
3621 FUNCTION WLANTL_SuspendCB
3622
3623 DESCRIPTION
3624 Callback function for serializing Suspend signal through Tx thread
3625
3626 DEPENDENCIES
3627 Just notify HAL that suspend in TL is complete.
3628
3629 PARAMETERS
3630
3631 IN
3632 pvosGCtx: pointer to the global vos context; a handle to TL's
3633 control block can be extracted from its context
3634 pUserData: user data sent with the callback
3635
3636 RETURN VALUE
3637 The result code associated with performing the operation
3638
3639 VOS_STATUS_E_INVAL: invalid input parameters
3640 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
3641 page fault
3642 VOS_STATUS_SUCCESS: Everything is good :)
3643
3644
3645 SIDE EFFECTS
3646
3647============================================================================*/
3648VOS_STATUS
3649WLANTL_SuspendCB
3650(
3651 v_PVOID_t pvosGCtx,
3652 WLANTL_SuspendCBType pfnSuspendCB,
3653 v_U16_t usReserved
3654)
3655{
3656 WLANTL_CbType* pTLCb = NULL;
3657 v_U8_t ucSTAId = (v_U8_t)usReserved;
3658 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
3659
3660 /*------------------------------------------------------------------------
3661 Sanity check
3662 ------------------------------------------------------------------------*/
3663 if ( NULL == pfnSuspendCB )
3664 {
3665 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
3666 "WLAN TL: No Call back processing requested WLANTL_SuspendCB"));
3667 return VOS_STATUS_SUCCESS;
3668 }
3669
3670 /*------------------------------------------------------------------------
3671 Extract TL control block
3672 ------------------------------------------------------------------------*/
3673 pTLCb = VOS_GET_TL_CB(pvosGCtx);
3674 if ( NULL == pTLCb )
3675 {
3676 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3677 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_SuspendCB"));
3678 return VOS_STATUS_E_FAULT;
3679 }
3680
3681 if ( WLANTL_STA_ID_INVALID( ucSTAId ) )
3682 {
3683 pfnSuspendCB(pvosGCtx, NULL, VOS_STATUS_SUCCESS);
3684 }
3685 else
3686 {
3687 pfnSuspendCB(pvosGCtx, &ucSTAId, VOS_STATUS_SUCCESS);
3688 }
3689
3690 return VOS_STATUS_SUCCESS;
3691}/*WLANTL_SuspendCB*/
3692
3693
3694/*----------------------------------------------------------------------------
3695 CLIENT INDEPENDENT INTERFACE
3696 ---------------------------------------------------------------------------*/
3697
3698/*==========================================================================
3699
3700 FUNCTION WLANTL_GetTxPktCount
3701
3702 DESCRIPTION
3703 TL will provide the number of transmitted packets counted per
3704 STA per TID.
3705
3706 DEPENDENCIES
3707
3708 PARAMETERS
3709
3710 IN
3711 pvosGCtx: pointer to the global vos context; a handle to TL's
3712 control block can be extracted from its context
3713 ucSTAId: identifier of the station
3714 ucTid: identifier of the tspec
3715
3716 OUT
3717 puTxPktCount: the number of packets tx packet for this STA and TID
3718
3719 RETURN VALUE
3720 The result code associated with performing the operation
3721
3722 VOS_STATUS_E_INVAL: Input parameters are invalid
3723 VOS_STATUS_E_FAULT: Station ID is outside array boundaries or pointer
3724 to TL cb is NULL ; access would cause a page fault
3725 VOS_STATUS_E_EXISTS: Station was not registered
3726 VOS_STATUS_SUCCESS: Everything is good :)
3727
3728 SIDE EFFECTS
3729
3730============================================================================*/
3731VOS_STATUS
3732WLANTL_GetTxPktCount
3733(
3734 v_PVOID_t pvosGCtx,
3735 v_U8_t ucSTAId,
3736 v_U8_t ucTid,
3737 v_U32_t* puTxPktCount
3738)
3739{
3740 WLANTL_CbType* pTLCb = NULL;
3741 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
3742
3743 /*------------------------------------------------------------------------
3744 Sanity check
3745 ------------------------------------------------------------------------*/
3746 if ( NULL == puTxPktCount )
3747 {
3748 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3749 "WLAN TL:Invalid parameter sent on WLANTL_GetTxPktCount"));
3750 return VOS_STATUS_E_INVAL;
3751 }
3752
3753 if ( WLANTL_STA_ID_INVALID( ucSTAId ) || WLANTL_TID_INVALID( ucTid) )
3754 {
3755 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3756 "WLAN TL:Invalid station id %d/tid %d requested on WLANTL_GetTxPktCount",
3757 ucSTAId, ucTid));
3758 return VOS_STATUS_E_FAULT;
3759 }
3760
3761 /*------------------------------------------------------------------------
3762 Extract TL control block and check if station exists
3763 ------------------------------------------------------------------------*/
3764 pTLCb = VOS_GET_TL_CB(pvosGCtx);
3765 if ( NULL == pTLCb )
3766 {
3767 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3768 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_GetTxPktCount"));
3769 return VOS_STATUS_E_FAULT;
3770 }
3771
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05303772 if ( NULL == pTLCb->atlSTAClients[ucSTAId] )
3773 {
3774 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3775 "WLAN TL:Client Memory was not allocated on %s", __func__));
3776 return VOS_STATUS_E_FAILURE;
3777 }
3778
3779 if ( 0 == pTLCb->atlSTAClients[ucSTAId]->ucExists )
Jeff Johnson295189b2012-06-20 16:38:30 -07003780 {
3781 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3782 "WLAN TL:Station was not previously registered on WLANTL_GetTxPktCount %d",
3783 ucSTAId));
3784 return VOS_STATUS_E_EXISTS;
3785 }
3786
3787 /*------------------------------------------------------------------------
3788 Return data
3789 ------------------------------------------------------------------------*/
3790 //VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_MED,
3791 // "WLAN TL:Requested tx packet count for STA: %d, TID: %d",
3792 // ucSTAId, ucTid);
3793
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05303794 *puTxPktCount = pTLCb->atlSTAClients[ucSTAId]->auTxCount[ucTid];
Jeff Johnson295189b2012-06-20 16:38:30 -07003795
3796 return VOS_STATUS_SUCCESS;
3797}/* WLANTL_GetTxPktCount */
3798
3799/*==========================================================================
3800
3801 FUNCTION WLANTL_GetRxPktCount
3802
3803 DESCRIPTION
3804 TL will provide the number of received packets counted per
3805 STA per TID.
3806
3807 DEPENDENCIES
3808
3809 PARAMETERS
3810
3811 IN
3812 pvosGCtx: pointer to the global vos context; a handle to TL's
3813 control block can be extracted from its context
3814 ucSTAId: identifier of the station
3815 ucTid: identifier of the tspec
3816
3817 OUT
3818 puTxPktCount: the number of packets rx packet for this STA and TID
3819
3820 RETURN VALUE
3821 The result code associated with performing the operation
3822
3823 VOS_STATUS_E_INVAL: Input parameters are invalid
3824 VOS_STATUS_E_FAULT: Station ID is outside array boundaries or pointer
3825 to TL cb is NULL ; access would cause a page fault
3826 VOS_STATUS_E_EXISTS: Station was not registered
3827 VOS_STATUS_SUCCESS: Everything is good :)
3828
3829 SIDE EFFECTS
3830
3831============================================================================*/
3832VOS_STATUS
3833WLANTL_GetRxPktCount
3834(
3835 v_PVOID_t pvosGCtx,
3836 v_U8_t ucSTAId,
3837 v_U8_t ucTid,
3838 v_U32_t* puRxPktCount
3839)
3840{
3841 WLANTL_CbType* pTLCb = NULL;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05303842 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07003843 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
3844
3845 /*------------------------------------------------------------------------
3846 Sanity check
3847 ------------------------------------------------------------------------*/
3848 if ( NULL == puRxPktCount )
3849 {
3850 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3851 "WLAN TL:Invalid parameter sent on WLANTL_GetRxPktCount"));
3852 return VOS_STATUS_E_INVAL;
3853 }
3854
3855 if ( WLANTL_STA_ID_INVALID( ucSTAId ) || WLANTL_TID_INVALID( ucTid) )
3856 {
3857 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3858 "WLAN TL:Invalid station id %d/tid %d requested on WLANTL_GetRxPktCount",
3859 ucSTAId, ucTid));
3860 return VOS_STATUS_E_FAULT;
3861 }
3862
3863 /*------------------------------------------------------------------------
3864 Extract TL control block and existance
3865 ------------------------------------------------------------------------*/
3866 pTLCb = VOS_GET_TL_CB(pvosGCtx);
3867 if ( NULL == pTLCb )
3868 {
3869 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3870 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_GetRxPktCount"));
3871 return VOS_STATUS_E_FAULT;
3872 }
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05303873 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
Jeff Johnson295189b2012-06-20 16:38:30 -07003874
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05303875 if ( NULL == pClientSTA )
3876 {
3877 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3878 "WLAN TL:Client Memory was not allocated on %s", __func__));
3879 return VOS_STATUS_E_FAILURE;
3880 }
3881
3882 if ( 0 == pClientSTA->ucExists )
Jeff Johnson295189b2012-06-20 16:38:30 -07003883 {
3884 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3885 "WLAN TL:Station was not previously registered on WLANTL_GetRxPktCount"));
3886 return VOS_STATUS_E_EXISTS;
3887 }
3888
3889 /*------------------------------------------------------------------------
3890 Return data
3891 ------------------------------------------------------------------------*/
3892 TLLOG3(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_MED,
3893 "WLAN TL:Requested rx packet count for STA: %d, TID: %d",
3894 ucSTAId, ucTid));
3895
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05303896 *puRxPktCount = pClientSTA->auRxCount[ucTid];
Jeff Johnson295189b2012-06-20 16:38:30 -07003897
3898 return VOS_STATUS_SUCCESS;
3899}/* WLANTL_GetRxPktCount */
3900
Jeff Johnson295189b2012-06-20 16:38:30 -07003901VOS_STATUS
3902WLANTL_TxFCFrame
3903(
3904 v_PVOID_t pvosGCtx
3905);
Jeff Johnson295189b2012-06-20 16:38:30 -07003906/*============================================================================
3907 TL INTERNAL API DEFINITION
3908============================================================================*/
3909
3910/*==========================================================================
3911
3912 FUNCTION WLANTL_GetFrames
3913
3914 DESCRIPTION
3915
3916 BAL calls this function at the request of the lower bus interface.
3917 When this request is being received TL will retrieve packets from HDD
3918 in accordance with the priority rules and the count supplied by BAL.
3919
3920 DEPENDENCIES
3921
3922 HDD must have registered with TL at least one STA before this function
3923 can be called.
3924
3925 PARAMETERS
3926
3927 IN
3928 pvosGCtx: pointer to the global vos context; a handle to TL's
3929 or BAL's control block can be extracted from its context
3930 uSize: maximum size accepted by the lower layer
3931 uFlowMask TX flow control mask for Prima. Each bit is defined as
3932 WDA_TXFlowEnumType
3933
3934 OUT
3935 vosDataBuff: it will contain a pointer to the first buffer supplied
3936 by TL, if there is more than one packet supplied, TL
3937 will chain them through vOSS buffers
3938
3939 RETURN VALUE
3940
3941 The result code associated with performing the operation
3942
3943 1 or more: number of required resources if there are still frames to fetch
3944 0 : error or HDD queues are drained
3945
3946 SIDE EFFECTS
3947
3948 NOTE
3949
3950 Featurized uFlowMask. If we want to remove featurization, we need to change
3951 BAL on Volans.
3952
3953============================================================================*/
3954v_U32_t
3955WLANTL_GetFrames
3956(
3957 v_PVOID_t pvosGCtx,
3958 vos_pkt_t **ppFrameDataBuff,
3959 v_U32_t uSize,
Jeff Johnson295189b2012-06-20 16:38:30 -07003960 v_U8_t uFlowMask,
Jeff Johnson295189b2012-06-20 16:38:30 -07003961 v_BOOL_t* pbUrgent
3962)
3963{
3964 vos_pkt_t** pvosDataBuff = (vos_pkt_t**)ppFrameDataBuff;
3965 WLANTL_CbType* pTLCb = NULL;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05303966 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07003967 v_U32_t uRemaining = uSize;
3968 vos_pkt_t* vosRoot;
3969 vos_pkt_t* vosTempBuf;
3970 WLANTL_STAFuncType pfnSTAFsm;
3971 v_U16_t usPktLen;
3972 v_U32_t uResLen;
3973 v_U8_t ucSTAId;
3974 v_U8_t ucAC;
3975 vos_pkt_t* vosDataBuff;
3976 v_U32_t uTotalPktLen;
3977 v_U32_t i=0;
Tushnim Bhattacharyya39a8f182013-02-20 18:10:30 -08003978 v_U32_t j=0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003979 v_U32_t ucResult = 0;
3980 VOS_STATUS vosStatus;
3981 WLANTL_STAEventType wSTAEvent;
3982 tBssSystemRole systemRole;
3983 tpAniSirGlobal pMac;
3984 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
3985
3986 /*------------------------------------------------------------------------
3987 Sanity check
3988 Extract TL control block
3989 ------------------------------------------------------------------------*/
3990 pTLCb = VOS_GET_TL_CB(pvosGCtx);
3991 if (( NULL == pTLCb ) || ( NULL == pvosDataBuff ))
3992 {
3993 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3994 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_ChangeSTAState"));
3995 return ucResult;
3996 }
3997
3998 pMac = vos_get_context(VOS_MODULE_ID_PE, pvosGCtx);
3999 if ( NULL == pMac )
4000 {
4001 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004002 "%s: Invalid pMac", __func__));
Jeff Johnson295189b2012-06-20 16:38:30 -07004003 return ucResult;
4004 }
4005
4006 vosDataBuff = pTLCb->vosDummyBuf; /* Just to avoid checking for NULL at
4007 each iteration */
4008
Jeff Johnson295189b2012-06-20 16:38:30 -07004009 pTLCb->uResCount = uSize;
Jeff Johnson295189b2012-06-20 16:38:30 -07004010
4011 /*-----------------------------------------------------------------------
4012 Save the root as we will walk this chain as we fill it
4013 -----------------------------------------------------------------------*/
4014 vosRoot = vosDataBuff;
4015
4016 /*-----------------------------------------------------------------------
4017 There is still data - until FSM function says otherwise
4018 -----------------------------------------------------------------------*/
4019 pTLCb->bUrgent = FALSE;
4020
Jeff Johnson295189b2012-06-20 16:38:30 -07004021 while (( pTLCb->tlConfigInfo.uMinFramesProcThres < pTLCb->uResCount ) &&
4022 ( 0 < uRemaining ))
Jeff Johnson295189b2012-06-20 16:38:30 -07004023 {
4024 systemRole = wdaGetGlobalSystemRole(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -07004025#ifdef WLAN_SOFTAP_FLOWCTRL_EN
4026/* FIXME: The code has been disabled since it is creating issues in power save */
4027 if (eSYSTEM_AP_ROLE == systemRole)
4028 {
4029 if (pTLCb->done_once == 0 && NULL == pTLCb->vosTxFCBuf)
4030 {
4031 WLANTL_TxFCFrame (pvosGCtx);
4032 pTLCb->done_once ++;
4033 }
4034 }
4035 if ( NULL != pTLCb->vosTxFCBuf )
4036 {
4037 //there is flow control packet waiting to be sent
4038 WDA_TLI_PROCESS_FRAME_LEN( pTLCb->vosTxFCBuf, usPktLen, uResLen, uTotalPktLen);
4039
4040 if ( ( pTLCb->uResCount > uResLen ) &&
Jeff Johnson9b5dc4d2013-02-22 21:28:47 -08004041 ( uRemaining > uTotalPktLen ) &&
4042 ( uFlowMask & ( 1 << WDA_TXFLOW_FC ) ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07004043 {
4044 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
4045 "WLAN TL:Chaining FC frame first on GetFrame"));
4046
4047 vos_pkt_chain_packet( vosDataBuff, pTLCb->vosTxFCBuf, 1 /*true*/ );
4048
4049 vos_atomic_set_U32( (v_U32_t*)&pTLCb->vosTxFCBuf, (v_U32_t)NULL);
4050
4051 /*FC frames cannot be delayed*/
4052 pTLCb->bUrgent = TRUE;
4053
4054 /*Update remaining len from SSC */
4055 uRemaining -= (usPktLen + WDA_DXE_HEADER_SIZE);
4056
4057 /*Update resource count */
4058 pTLCb->uResCount -= uResLen;
4059 }
4060 else
4061 {
4062 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004063 "WLAN TL:send fc out of source %s", __func__));
Jeff Johnson295189b2012-06-20 16:38:30 -07004064 ucResult = ( pTLCb->uResCount > uResLen )?VOS_TRUE:VOS_FALSE;
4065 break; /* Out of resources or reached max len */
4066 }
4067 }
4068 else
4069#endif //WLAN_SOFTAP_FLOWCTRL_EN
Jeff Johnson295189b2012-06-20 16:38:30 -07004070
Jeff Johnson9b5dc4d2013-02-22 21:28:47 -08004071 if (( NULL != pTLCb->tlMgmtFrmClient.vosPendingDataBuff ) &&
4072 ( uFlowMask & ( 1 << WDA_TXFLOW_MGMT ) ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07004073 {
4074 WDA_TLI_PROCESS_FRAME_LEN( pTLCb->tlMgmtFrmClient.vosPendingDataBuff,
4075 usPktLen, uResLen, uTotalPktLen);
4076
Manjunathappa Prakashfb585462013-12-23 19:07:07 -08004077 if (usPktLen > WLANTL_MAX_ALLOWED_LEN)
4078 {
4079 usPktLen = WLANTL_MAX_ALLOWED_LEN;
4080 VOS_ASSERT(0);
4081 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004082
4083 if ( ( pTLCb->uResCount > uResLen ) &&
Jeff Johnson9b5dc4d2013-02-22 21:28:47 -08004084 ( uRemaining > uTotalPktLen ) &&
4085 ( uFlowMask & ( 1 << WDA_TXFLOW_MGMT ) ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07004086 {
4087 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
4088 "WLAN TL:Chaining management frame on GetFrame"));
4089
4090 vos_pkt_chain_packet( vosDataBuff,
4091 pTLCb->tlMgmtFrmClient.vosPendingDataBuff,
4092 1 /*true*/ );
4093
4094 vos_atomic_set_U32( (v_U32_t*)&pTLCb->tlMgmtFrmClient.
4095 vosPendingDataBuff, (v_U32_t)NULL);
4096
4097 /*management frames cannot be delayed*/
4098 pTLCb->bUrgent = TRUE;
4099
4100 /*Update remaining len from SSC */
4101 uRemaining -= (usPktLen + WDA_DXE_HEADER_SIZE);
4102
4103 /*Update resource count */
4104 pTLCb->uResCount -= uResLen;
4105 }
4106 else
4107 {
4108 ucResult = ( pTLCb->uResCount > uResLen )?VOS_TRUE:VOS_FALSE;
4109 break; /* Out of resources or reached max len */
4110 }
4111 }
4112 else if (( pTLCb->tlBAPClient.vosPendingDataBuff ) &&
4113 ( WDA_TLI_MIN_RES_BAP <= pTLCb->uResCount ) &&
Gopichand Nakkala7e48ca72012-12-31 14:15:07 -08004114 ( 0 == pTLCb->ucTxSuspended ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07004115 {
4116 WDA_TLI_PROCESS_FRAME_LEN( pTLCb->tlBAPClient.vosPendingDataBuff,
4117 usPktLen, uResLen, uTotalPktLen);
4118
Manjunathappa Prakashfb585462013-12-23 19:07:07 -08004119 if (usPktLen > WLANTL_MAX_ALLOWED_LEN)
4120 {
4121 usPktLen = WLANTL_MAX_ALLOWED_LEN;
4122 VOS_ASSERT(0);
4123 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004124
4125 if ( ( pTLCb->uResCount > (uResLen + WDA_TLI_MIN_RES_MF ) ) &&
4126 ( uRemaining > uTotalPktLen ))
4127 {
4128 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
4129 "WLAN TL:Chaining BT-AMP frame on GetFrame"));
4130
4131 vos_pkt_chain_packet( vosDataBuff,
4132 pTLCb->tlBAPClient.vosPendingDataBuff,
4133 1 /*true*/ );
4134
4135 /*BAP frames cannot be delayed*/
4136 pTLCb->bUrgent = TRUE;
4137
4138 vos_atomic_set_U32( (v_U32_t*)&pTLCb->tlBAPClient.vosPendingDataBuff,
4139 (v_U32_t)NULL);
4140
4141 /*Update remaining len from SSC */
4142 uRemaining -= (usPktLen + WDA_DXE_HEADER_SIZE);
4143
4144 /*Update resource count */
4145 pTLCb->uResCount -= uResLen;
4146 }
4147 else
4148 {
Jeff Johnson295189b2012-06-20 16:38:30 -07004149 ucResult = uResLen + WDA_TLI_MIN_RES_MF;
Jeff Johnson295189b2012-06-20 16:38:30 -07004150 break; /* Out of resources or reached max len */
4151 }
4152 }
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -07004153 /* note: this feature implemented only after WLAN_INGETRATED_SOC */
4154 /* search 'EAPOL_HI_PRIORITY' will show EAPOL HI_PRIORITY change in TL and WDI
4155 by default, EAPOL will be treated as higher priority, which means
4156 use mgmt_pool and DXE_TX_HI prority channel.
4157 this is introduced to address EAPOL failure under high background traffic
4158 with multi-channel concurrent mode. But this change works in SCC or standalone, too.
4159 see CR#387009 and WCNSOS-8
4160 */
4161 else if (( WDA_TLI_MIN_RES_MF <= pTLCb->uResCount )&&
4162 ( 0 == pTLCb->ucTxSuspended ) &&
4163 ( uFlowMask & ( 1 << WDA_TXFLOW_MGMT ) )
4164 )
4165 {
4166 vosTempBuf = NULL;
4167 /*---------------------------------------------------------------------
4168 Check to see if there was any EAPOL packet is pending
4169 *--------------------------------------------------------------------*/
4170 for ( i = 0; i < WLAN_MAX_STA_COUNT; i++)
4171 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304172 if ((NULL != pTLCb->atlSTAClients[i]) &&
4173 (pTLCb->atlSTAClients[i]->ucExists) &&
4174 (0 == pTLCb->atlSTAClients[i]->ucTxSuspended) &&
Tushnim Bhattacharyya39a8f182013-02-20 18:10:30 -08004175 (WLANTL_STA_CONNECTED == pTLCb->atlSTAClients[i]->tlState) &&
4176 (pTLCb->atlSTAClients[i]->ucPktPending)
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -07004177 )
4178 break;
4179 }
4180
4181 if (i >= WLAN_MAX_STA_COUNT)
4182 {
4183 /* No More to Serve Exit Get Frames */
4184 break;
4185 }
4186 /* Serve EAPOL frame with HI_FLOW_MASK */
4187 ucSTAId = i;
4188
Katya Nigam42e16e82014-02-04 16:28:55 +05304189 MTRACE(vos_trace(VOS_MODULE_ID_TL,
4190 TRACE_CODE_TL_GET_FRAMES_EAPOL, ucSTAId, pTLCb->atlSTAClients[i]->tlState));
4191
Tushnim Bhattacharyya39a8f182013-02-20 18:10:30 -08004192 for (j = WLANTL_MAX_AC ; j > 0; j--)
4193 {
4194 if (0 != pTLCb->atlSTAClients[ucSTAId]->aucACMask[j-1])
4195 {
4196 pTLCb->atlSTAClients[ucSTAId]->ucCurrentAC = j-1;
4197 pTLCb->uCurServedAC = j-1;
4198 }
4199 }
4200
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304201 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
4202
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -07004203 wSTAEvent = WLANTL_TX_EVENT;
4204
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304205 pfnSTAFsm = tlSTAFsm[pClientSTA->tlState].
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -07004206 pfnSTATbl[wSTAEvent];
4207
4208 if ( NULL != pfnSTAFsm )
4209 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304210 pClientSTA->ucNoMoreData = 0;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004211 vosStatus = pfnSTAFsm( pvosGCtx, ucSTAId, &vosTempBuf, VOS_FALSE);
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -07004212
4213 if (( VOS_STATUS_SUCCESS != vosStatus ) &&
4214 ( NULL != vosTempBuf ))
4215 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304216 pClientSTA->pfnSTATxComp( pvosGCtx, vosTempBuf, vosStatus );
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -07004217 vosTempBuf = NULL;
4218 break;
4219 }/* status success*/
4220 }
4221
4222 if (NULL != vosTempBuf)
4223 {
4224 WDA_TLI_PROCESS_FRAME_LEN( vosTempBuf, usPktLen, uResLen, uTotalPktLen);
4225
Manjunathappa Prakashfb585462013-12-23 19:07:07 -08004226 if (usPktLen > WLANTL_MAX_ALLOWED_LEN)
4227 {
4228 usPktLen = WLANTL_MAX_ALLOWED_LEN;
4229 VOS_ASSERT(0);
4230 }
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -07004231
4232 TLLOG4(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_LOW,
4233 "WLAN TL:Resources needed by frame: %d", uResLen));
4234
4235 if ( ( pTLCb->uResCount >= (uResLen + WDA_TLI_MIN_RES_MF ) ) &&
4236 ( uRemaining > uTotalPktLen )
4237 )
4238 {
4239 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
4240 "WLAN TL:Chaining data frame on GetFrame"));
4241
4242 vos_pkt_chain_packet( vosDataBuff, vosTempBuf, 1 /*true*/ );
4243
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -07004244 /*EAPOL frame cannot be delayed*/
4245 pTLCb->bUrgent = TRUE;
4246
4247 vosTempBuf = NULL;
4248
4249 /*Update remaining len from SSC */
4250 uRemaining -= (usPktLen + WDA_DXE_HEADER_SIZE);
4251
4252 /*Update resource count */
4253 pTLCb->uResCount -= uResLen;
4254
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -07004255 //fow control update
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304256 pClientSTA->uIngress_length += uResLen;
4257 pClientSTA->uBuffThresholdMax = (pClientSTA->uBuffThresholdMax >= uResLen) ?
4258 (pClientSTA->uBuffThresholdMax - uResLen) : 0;
Tushnim Bhattacharyya39a8f182013-02-20 18:10:30 -08004259 pClientSTA->ucEapolPktPending = 0;
4260 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
4261 "WLAN TL:GetFrames STA: %d EAPOLPktPending %d",
4262 ucSTAId, pClientSTA->ucEapolPktPending);
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -07004263 }
4264 }
4265 else
4266 { // no EAPOL frames exit Get frames
Tushnim Bhattacharyya39a8f182013-02-20 18:10:30 -08004267 TLLOG2(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
4268 "WLAN TL:GetFrames STA: %d, no EAPOL frame, continue.",
4269 ucSTAId));
4270 continue;
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -07004271 }
4272 }
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -07004273
Jeff Johnson9b5dc4d2013-02-22 21:28:47 -08004274 else if (( WDA_TLI_MIN_RES_DATA <= pTLCb->uResCount ) &&
4275 ( 0 == pTLCb->ucTxSuspended ) &&
4276 (( uFlowMask & ( 1 << WDA_TXFLOW_AC_BK ) ) ||
4277 ( uFlowMask & ( 1 << WDA_TXFLOW_AC_BE ) ) ||
4278 ( uFlowMask & ( 1 << WDA_TXFLOW_AC_VI ) ) ||
4279 ( uFlowMask & ( 1 << WDA_TXFLOW_AC_VO ) )) )
Jeff Johnson295189b2012-06-20 16:38:30 -07004280 {
4281 /*---------------------------------------------------------------------
4282 Check to see if there was any packet left behind previously due to
4283 size constraints
4284 ---------------------------------------------------------------------*/
4285 vosTempBuf = NULL;
4286
4287 if ( NULL != pTLCb->vosTempBuf )
4288 {
4289 vosTempBuf = pTLCb->vosTempBuf;
4290 pTLCb->vosTempBuf = NULL;
4291 ucSTAId = pTLCb->ucCachedSTAId;
4292 ucAC = pTLCb->ucCachedAC;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304293
4294 if ( NULL == pTLCb->atlSTAClients[ucSTAId] )
4295 {
4296 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
4297 "WLAN TL:Client Memory was not allocated on %s", __func__));
Madan Mohan Koyylamudi64258222013-01-30 14:35:10 +05304298 continue;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304299 }
4300
4301 pTLCb->atlSTAClients[ucSTAId]->ucNoMoreData = 0;
Madan Mohan Koyylamudi64258222013-01-30 14:35:10 +05304302 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
Jeff Johnson295189b2012-06-20 16:38:30 -07004303
4304 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
4305 "WLAN TL:Chaining cached data frame on GetFrame"));
4306 }
4307 else
4308 {
4309 WLAN_TLGetNextTxIds( pvosGCtx, &ucSTAId);
4310 if (ucSTAId >= WLAN_MAX_STA_COUNT)
4311 {
4312 /* Packets start coming in even after insmod Without *
4313 starting Hostapd or Interface being up *
4314 During which cases STAID is invaled and hence
4315 the check. HalMsg_ScnaComplete Triggers */
4316
4317 break;
4318 }
4319 /* ucCurrentAC should have correct AC to be served by calling
4320 WLAN_TLGetNextTxIds */
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304321 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304322 if ( NULL == pClientSTA )
4323 {
4324 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
4325 "WLAN TL:Client Memory was not allocated on %s", __func__));
Madan Mohan Koyylamudi64258222013-01-30 14:35:10 +05304326 continue;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304327 }
4328
4329 ucAC = pClientSTA->ucCurrentAC;
4330
4331 pClientSTA->ucNoMoreData = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07004332 TLLOG4(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_LOW,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004333 "WLAN TL: %s get one data frame, station ID %d ", __func__, ucSTAId));
Jeff Johnson295189b2012-06-20 16:38:30 -07004334 /*-------------------------------------------------------------------
4335 Check to see that STA is valid and tx is not suspended
4336 -------------------------------------------------------------------*/
4337 if ( ( ! WLANTL_STA_ID_INVALID( ucSTAId ) ) &&
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304338 ( 0 == pClientSTA->ucTxSuspended ) &&
4339 ( 0 == pClientSTA->fcStaTxDisabled) )
Jeff Johnson295189b2012-06-20 16:38:30 -07004340 {
4341 TLLOG4(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_LOW,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004342 "WLAN TL: %s sta id valid and not suspended ",__func__));
Jeff Johnson295189b2012-06-20 16:38:30 -07004343 wSTAEvent = WLANTL_TX_EVENT;
4344
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304345 pfnSTAFsm = tlSTAFsm[pClientSTA->tlState].
Jeff Johnson295189b2012-06-20 16:38:30 -07004346 pfnSTATbl[wSTAEvent];
4347
4348 if ( NULL != pfnSTAFsm )
4349 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304350 pClientSTA->ucNoMoreData = 0;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004351 vosStatus = pfnSTAFsm( pvosGCtx, ucSTAId, &vosTempBuf, VOS_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07004352
4353 if (( VOS_STATUS_SUCCESS != vosStatus ) &&
4354 ( NULL != vosTempBuf ))
4355 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304356 pClientSTA->pfnSTATxComp( pvosGCtx,
Jeff Johnson295189b2012-06-20 16:38:30 -07004357 vosTempBuf,
4358 vosStatus );
4359 vosTempBuf = NULL;
4360 }/* status success*/
4361 }/*NULL function state*/
4362 }/* valid STA id and ! suspended*/
4363 else
4364 {
4365 if ( ! WLANTL_STA_ID_INVALID( ucSTAId ) )
4366 {
4367 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
4368 "WLAN TL:Not fetching frame because suspended for sta ID %d",
4369 ucSTAId));
4370 }
4371 }
4372 }/* data */
4373
4374 if ( NULL != vosTempBuf )
4375 {
4376 WDA_TLI_PROCESS_FRAME_LEN( vosTempBuf, usPktLen, uResLen, uTotalPktLen);
4377
Manjunathappa Prakashfb585462013-12-23 19:07:07 -08004378 if (usPktLen > WLANTL_MAX_ALLOWED_LEN)
4379 {
4380 usPktLen = WLANTL_MAX_ALLOWED_LEN;
4381 VOS_ASSERT(0);
4382 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004383
4384 TLLOG4(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_LOW,
4385 "WLAN TL:Resources needed by frame: %d", uResLen));
4386
4387 if ( ( pTLCb->uResCount >= (uResLen + WDA_TLI_MIN_RES_BAP ) ) &&
Jeff Johnson9b5dc4d2013-02-22 21:28:47 -08004388 ( uRemaining > uTotalPktLen ) &&
4389 ( uFlowMask & ( 1 << ucAC ) ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07004390 {
4391 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
4392 "WLAN TL:Chaining data frame on GetFrame"));
4393
4394 vos_pkt_chain_packet( vosDataBuff, vosTempBuf, 1 /*true*/ );
4395 vosTempBuf = NULL;
4396
4397 /*Update remaining len from SSC */
4398 uRemaining -= (usPktLen + WDA_DXE_HEADER_SIZE);
4399
4400 /*Update resource count */
4401 pTLCb->uResCount -= uResLen;
4402
Jeff Johnson295189b2012-06-20 16:38:30 -07004403 //fow control update
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304404 pClientSTA->uIngress_length += uResLen;
4405 pClientSTA->uBuffThresholdMax = (pClientSTA->uBuffThresholdMax >= uResLen) ?
4406 (pClientSTA->uBuffThresholdMax - uResLen) : 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004407
4408 }
4409 else
4410 {
4411 /* Store this for later tx - already fetched from HDD */
4412 pTLCb->vosTempBuf = vosTempBuf;
4413 pTLCb->ucCachedSTAId = ucSTAId;
4414 pTLCb->ucCachedAC = ucAC;
Jeff Johnson295189b2012-06-20 16:38:30 -07004415 ucResult = uResLen + WDA_TLI_MIN_RES_BAP;
4416 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
4417 "min %d res required by TL.", ucResult ));
Jeff Johnson295189b2012-06-20 16:38:30 -07004418 break; /* Out of resources or reached max len */
4419 }
4420 }
4421 else
4422 {
4423 for ( i = 0; i < WLAN_MAX_STA_COUNT; i++)
4424 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304425 if (NULL != pTLCb->atlSTAClients[i] && (pTLCb->atlSTAClients[i]->ucExists) &&
4426 (pTLCb->atlSTAClients[i]->ucPktPending))
Jeff Johnson295189b2012-06-20 16:38:30 -07004427 {
4428 /* There is station to be Served */
4429 break;
4430 }
4431 }
4432 if (i >= WLAN_MAX_STA_COUNT)
4433 {
4434 /* No More to Serve Exit Get Frames */
4435 break;
4436 }
4437 else
4438 {
4439 /* More to be Served */
4440 continue;
4441 }
4442 }
4443 }
4444 else
4445 {
4446 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
4447 "WLAN TL:Returning from GetFrame: resources = %d suspended = %d",
4448 pTLCb->uResCount, pTLCb->ucTxSuspended));
Jeff Johnson295189b2012-06-20 16:38:30 -07004449 /* TL is starving even when DXE is not in low resource condition
4450 Return min resource number required and Let DXE deceide what to do */
4451 if(( 0 == pTLCb->ucTxSuspended ) &&
4452 (( uFlowMask & ( 1 << WDA_TXFLOW_AC_BK ) ) ||
4453 ( uFlowMask & ( 1 << WDA_TXFLOW_AC_BE ) ) ||
4454 ( uFlowMask & ( 1 << WDA_TXFLOW_AC_VI ) ) ||
4455 ( uFlowMask & ( 1 << WDA_TXFLOW_AC_VO ) )))
4456 {
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07004457 TLLOG1(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -07004458 "WLAN TL:Returning from GetFrame: resources = %d",
4459 pTLCb->uResCount));
4460 ucResult = WDA_TLI_MIN_RES_DATA;
4461 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004462 break; /*out of min data resources*/
4463 }
4464
4465 pTLCb->usPendingTxCompleteCount++;
4466 /* Move data buffer up one packet */
4467 vos_pkt_walk_packet_chain( vosDataBuff, &vosDataBuff, 0/*false*/ );
4468 }
4469
4470 /*----------------------------------------------------------------------
4471 Packet chain starts at root + 1
4472 ----------------------------------------------------------------------*/
4473 vos_pkt_walk_packet_chain( vosRoot, &vosDataBuff, 1/*true*/ );
4474
4475 *pvosDataBuff = vosDataBuff;
Manjunathappa Prakashfb585462013-12-23 19:07:07 -08004476 if (pbUrgent)
4477 {
4478 *pbUrgent = pTLCb->bUrgent;
4479 }
4480 else
4481 {
4482 VOS_ASSERT( pbUrgent );
4483 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004484 return ucResult;
4485}/* WLANTL_GetFrames */
4486
4487
4488/*==========================================================================
4489
4490 FUNCTION WLANTL_TxComp
4491
4492 DESCRIPTION
4493 It is being called by BAL upon asynchronous notification of the packet
4494 or packets being sent over the bus.
4495
4496 DEPENDENCIES
4497 Tx complete cannot be called without a previous transmit.
4498
4499 PARAMETERS
4500
4501 IN
4502 pvosGCtx: pointer to the global vos context; a handle to TL's
4503 or BAL's control block can be extracted from its context
4504 vosDataBuff: it will contain a pointer to the first buffer for which
4505 the BAL report is being made, if there is more then one
4506 packet they will be chained using vOSS buffers.
4507 wTxStatus: the status of the transmitted packet, see above chapter
4508 on HDD interaction for a list of possible values
4509
4510 RETURN VALUE
4511 The result code associated with performing the operation
4512
4513 VOS_STATUS_E_INVAL: Input parameters are invalid
4514 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
4515 page fault
4516 VOS_STATUS_E_EXISTS: Station was not registered
4517 VOS_STATUS_SUCCESS: Everything is good :)
4518
4519 SIDE EFFECTS
4520
4521============================================================================*/
4522VOS_STATUS
4523WLANTL_TxComp
4524(
4525 v_PVOID_t pvosGCtx,
4526 vos_pkt_t *pFrameDataBuff,
4527 VOS_STATUS wTxStatus
4528)
4529{
4530 vos_pkt_t* vosDataBuff = (vos_pkt_t*)pFrameDataBuff;
4531 WLANTL_CbType* pTLCb = NULL;
4532 WLANTL_TxCompCBType pfnTxComp = NULL;
4533 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07004534 vos_pkt_t* vosTempTx = NULL;
4535
4536 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
4537
4538 /*------------------------------------------------------------------------
4539 Sanity check
4540 ------------------------------------------------------------------------*/
4541 if ( NULL == vosDataBuff )
4542 {
4543 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
4544 "WLAN TL:Extraneous NULL data pointer on WLANTL_TxComp"));
4545 return VOS_STATUS_E_INVAL;
4546 }
4547
4548 /*------------------------------------------------------------------------
4549 Extract TL control block
4550 ------------------------------------------------------------------------*/
4551 pTLCb = VOS_GET_TL_CB(pvosGCtx);
4552 if ( NULL == pTLCb )
4553 {
4554 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
4555 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_TxComp"));
4556 return VOS_STATUS_E_FAULT;
4557 }
4558
4559 while ((0 < pTLCb->usPendingTxCompleteCount) &&
4560 ( VOS_STATUS_SUCCESS == vosStatus ) &&
4561 ( NULL != vosDataBuff))
4562 {
4563 vos_pkt_get_user_data_ptr( vosDataBuff, VOS_PKT_USER_DATA_ID_TL,
4564 (v_PVOID_t)&pfnTxComp);
4565
4566 /*it should never be NULL - default handler should be registered if none*/
4567 if ( NULL == pfnTxComp )
4568 {
4569 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
4570 "WLAN TL:NULL pointer to Tx Complete on WLANTL_TxComp"));
4571 VOS_ASSERT(0);
4572 return VOS_STATUS_E_FAULT;
4573 }
4574
4575 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05304576 "WLAN TL:Calling Tx complete for pkt %p in function %p",
Jeff Johnson295189b2012-06-20 16:38:30 -07004577 vosDataBuff, pfnTxComp));
4578
4579 vosTempTx = vosDataBuff;
4580 vosStatus = vos_pkt_walk_packet_chain( vosDataBuff,
4581 &vosDataBuff, 1/*true*/);
4582
4583 pfnTxComp( pvosGCtx, vosTempTx, wTxStatus );
4584
4585 pTLCb->usPendingTxCompleteCount--;
4586 }
4587
Jeff Johnson295189b2012-06-20 16:38:30 -07004588
4589 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
4590 "WLAN TL: current TL values are: resources = %d "
4591 "pTLCb->usPendingTxCompleteCount = %d",
4592 pTLCb->uResCount, pTLCb->usPendingTxCompleteCount));
4593
4594 return VOS_STATUS_SUCCESS;
4595}/* WLANTL_TxComp */
4596
4597/*==========================================================================
4598
4599 FUNCTION WLANTL_CacheSTAFrame
4600
4601 DESCRIPTION
4602 Internal utility function for for caching incoming data frames that do
4603 not have a registered station yet.
4604
4605 DEPENDENCIES
4606 TL must be initiailized before this function gets called.
4607 In order to benefit from thsi caching, the components must ensure that
4608 they will only register with TL at the moment when they are fully setup
4609 and ready to receive incoming data
4610
4611 PARAMETERS
4612
4613 IN
4614
4615 pTLCb: TL control block
4616 ucSTAId: station id
4617 vosTempBuff: the data packet
4618 uDPUSig: DPU signature of the incoming packet
4619 bBcast: true if packet had the MC/BC bit set
4620
4621 RETURN VALUE
4622 The result code associated with performing the operation
4623
4624 VOS_STATUS_E_FAULT: pointer to TL cb is NULL or STA Id invalid ; access
4625 would cause a page fault
4626 VOS_STATUS_SUCCESS: Everything is good :)
4627
4628 SIDE EFFECTS
4629
4630============================================================================*/
4631static VOS_STATUS
4632WLANTL_CacheSTAFrame
4633(
4634 WLANTL_CbType* pTLCb,
4635 v_U8_t ucSTAId,
4636 vos_pkt_t* vosTempBuff,
4637 v_U32_t uDPUSig,
4638 v_U8_t bBcast,
4639 v_U8_t ucFrmType
4640)
4641{
4642 v_U8_t ucUcastSig;
4643 v_U8_t ucBcastSig;
4644 v_BOOL_t bOldSTAPkt;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304645 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004646 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
4647
4648 /*-------------------------------------------------------------------------
4649 Sanity check
4650 -------------------------------------------------------------------------*/
4651 if (( NULL == pTLCb ) || ( NULL == vosTempBuff ) )
4652 {
4653 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05304654 "WLAN TL: Invalid input pointer on WLANTL_CacheSTAFrame TL %p"
4655 " Packet %p", pTLCb, vosTempBuff ));
Jeff Johnson295189b2012-06-20 16:38:30 -07004656 return VOS_STATUS_E_FAULT;
4657 }
4658
4659 if ( WLANTL_STA_ID_INVALID( ucSTAId ) )
4660 {
4661 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
4662 "WLAN TL:Invalid station id requested on WLANTL_CacheSTAFrame"));
4663 return VOS_STATUS_E_FAULT;
4664 }
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304665 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
4666
4667 if ( NULL == pClientSTA )
4668 {
4669 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
4670 "WLAN TL:Client Memory was not allocated on %s", __func__));
4671 return VOS_STATUS_E_FAILURE;
4672 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004673
4674 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
4675 "WLAN TL:Attempting to cache pkt for STA %d, BD DPU Sig: %d with sig UC: %d, BC: %d",
4676 ucSTAId, uDPUSig,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304677 pClientSTA->wSTADesc.ucUcastSig,
4678 pClientSTA->wSTADesc.ucBcastSig));
Jeff Johnson295189b2012-06-20 16:38:30 -07004679
4680 if(WLANTL_IS_CTRL_FRAME(ucFrmType))
4681 {
4682 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
4683 "WLAN TL: No need to cache CTRL frame. Dropping"));
4684 vos_pkt_return_packet(vosTempBuff);
4685 return VOS_STATUS_SUCCESS;
4686 }
4687
4688 /*-------------------------------------------------------------------------
4689 Check if the packet that we are trying to cache belongs to the old
4690 registered station (if any) or the new (potentially)upcoming station
4691
4692 - If the STA with this Id was never registered with TL - the signature
4693 will be invalid;
4694 - If the STA was previously registered TL will have cached the former
4695 set of DPU signatures
4696 -------------------------------------------------------------------------*/
4697 if ( bBcast )
4698 {
4699 ucBcastSig = (v_U8_t)uDPUSig;
4700 bOldSTAPkt = (( WLAN_TL_INVALID_B_SIG !=
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304701 pClientSTA->wSTADesc.ucBcastSig ) &&
4702 ( ucBcastSig == pClientSTA->wSTADesc.ucBcastSig ));
Jeff Johnson295189b2012-06-20 16:38:30 -07004703 }
4704 else
4705 {
4706 ucUcastSig = (v_U8_t)uDPUSig;
4707 bOldSTAPkt = (( WLAN_TL_INVALID_U_SIG !=
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304708 pClientSTA->wSTADesc.ucUcastSig ) &&
4709 ( ucUcastSig == pClientSTA->wSTADesc.ucUcastSig ));
Jeff Johnson295189b2012-06-20 16:38:30 -07004710 }
4711
4712 /*------------------------------------------------------------------------
4713 If the value of the DPU SIG matches the old, this packet will not
4714 be cached as it belonged to the former association
4715 In case the SIG does not match - this is a packet for a potentially new
4716 associated station
4717 -------------------------------------------------------------------------*/
Varun Reddy Yeturua39b9902013-01-18 15:48:32 -08004718 if ( bOldSTAPkt || bBcast )
Jeff Johnson295189b2012-06-20 16:38:30 -07004719 {
4720 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
4721 "WLAN TL:Data packet matches old sig for sig DPU: %d UC: %d, "
4722 "BC: %d - dropping",
4723 uDPUSig,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304724 pClientSTA->wSTADesc.ucUcastSig,
4725 pClientSTA->wSTADesc.ucBcastSig));
Jeff Johnson295189b2012-06-20 16:38:30 -07004726 vos_pkt_return_packet(vosTempBuff);
4727 }
4728 else
4729 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304730 if ( NULL == pClientSTA->vosBegCachedFrame )
Jeff Johnson295189b2012-06-20 16:38:30 -07004731 {
4732 /*this is the first frame that we are caching */
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304733 pClientSTA->vosBegCachedFrame = vosTempBuff;
Jeff Johnson295189b2012-06-20 16:38:30 -07004734 }
4735 else
4736 {
4737 /*this is a subsequent frame that we are caching: chain to the end */
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304738 vos_pkt_chain_packet(pClientSTA->vosEndCachedFrame,
Jeff Johnson295189b2012-06-20 16:38:30 -07004739 vosTempBuff, VOS_TRUE);
4740 }
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304741 pClientSTA->vosEndCachedFrame = vosTempBuff;
Jeff Johnson295189b2012-06-20 16:38:30 -07004742 }/*else new packet*/
4743
4744 return VOS_STATUS_SUCCESS;
4745}/*WLANTL_CacheSTAFrame*/
4746
4747/*==========================================================================
4748
4749 FUNCTION WLANTL_FlushCachedFrames
4750
4751 DESCRIPTION
4752 Internal utility function used by TL to flush the station cache
4753
4754 DEPENDENCIES
4755 TL must be initiailized before this function gets called.
4756
4757 PARAMETERS
4758
4759 IN
4760
4761 vosDataBuff: it will contain a pointer to the first cached buffer
4762 received,
4763
4764 RETURN VALUE
4765 The result code associated with performing the operation
4766
4767 VOS_STATUS_SUCCESS: Everything is good :)
4768
4769 SIDE EFFECTS
4770
4771 NOTE
4772 This function doesn't re-initialize vosDataBuff to NULL. It's caller's
4773 responsibility to do so, if required, after this function call.
4774 Because of this restriction, we decide to make this function to static
4775 so that upper layer doesn't need to be aware of this restriction.
4776
4777============================================================================*/
4778static VOS_STATUS
4779WLANTL_FlushCachedFrames
4780(
4781 vos_pkt_t* vosDataBuff
4782)
4783{
4784 /*----------------------------------------------------------------------
4785 Return the entire chain to vos if there are indeed cache frames
4786 ----------------------------------------------------------------------*/
4787 if ( NULL != vosDataBuff )
4788 {
4789 vos_pkt_return_packet(vosDataBuff);
4790 }
4791
4792 return VOS_STATUS_SUCCESS;
4793}/*WLANTL_FlushCachedFrames*/
4794
4795/*==========================================================================
4796
4797 FUNCTION WLANTL_ForwardSTAFrames
4798
4799 DESCRIPTION
4800 Internal utility function for either forwarding cached data to the station after
4801 the station has been registered, or flushing cached data if the station has not
4802 been registered.
4803
4804
4805 DEPENDENCIES
4806 TL must be initiailized before this function gets called.
4807
4808 PARAMETERS
4809
4810 IN
4811
4812 pTLCb: TL control block
4813 ucSTAId: station id
4814
4815 RETURN VALUE
4816 The result code associated with performing the operation
4817
4818 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
4819 page fault
4820 VOS_STATUS_SUCCESS: Everything is good :)
4821
4822 SIDE EFFECTS
4823 This function doesn't re-initialize vosDataBuff to NULL. It's caller's
4824 responsibility to do so, if required, after this function call.
4825 Because of this restriction, we decide to make this function to static
4826 so that upper layer doesn't need to be aware of this restriction.
4827
4828============================================================================*/
4829static VOS_STATUS
4830WLANTL_ForwardSTAFrames
4831(
4832 void* pvosGCtx,
4833 v_U8_t ucSTAId,
4834 v_U8_t ucUcastSig,
4835 v_U8_t ucBcastSig
4836)
4837{
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304838 WLANTL_CbType* pTLCb = NULL;
4839 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004840 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
4841
4842 /*-------------------------------------------------------------------------
4843 Sanity check
4844 -------------------------------------------------------------------------*/
4845 pTLCb = VOS_GET_TL_CB(pvosGCtx);
4846 if ( NULL == pTLCb )
4847 {
4848 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05304849 "WLAN TL: Invalid input pointer on WLANTL_ForwardSTAFrames TL %p",
Jeff Johnson295189b2012-06-20 16:38:30 -07004850 pTLCb ));
4851 return VOS_STATUS_E_FAULT;
4852 }
4853
4854 if ( WLANTL_STA_ID_INVALID( ucSTAId ) )
4855 {
4856 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
4857 "WLAN TL:Invalid station id requested on WLANTL_ForwardSTAFrames"));
4858 return VOS_STATUS_E_FAULT;
4859 }
4860
4861 //WLAN_TL_LOCK_STA_CACHE(pTLCb->atlSTAClients[ucSTAId]);
4862
4863 /*------------------------------------------------------------------------
4864 Check if station has not been registered in the mean while
4865 if not registered, flush cached frames.
4866 ------------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304867 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
4868
4869 if ( NULL == pClientSTA )
4870 {
4871 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
4872 "WLAN TL:Client Memory was not allocated on %s", __func__));
4873 return VOS_STATUS_E_FAILURE;
4874 }
4875
4876 if ( 0 == pClientSTA->ucExists )
Jeff Johnson295189b2012-06-20 16:38:30 -07004877 {
4878 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
4879 "WLAN TL:Station has been deleted for STA %d - flushing cache", ucSTAId));
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304880 WLANTL_FlushCachedFrames(pClientSTA->vosBegCachedFrame);
Jeff Johnson295189b2012-06-20 16:38:30 -07004881 goto done;
4882 }
4883
4884 /*------------------------------------------------------------------------
4885 Forwarding cache frames received while the station was in the process
4886 of being registered with the rest of the SW components
4887
4888 Access to the cache must be locked; similarly updating the signature and
4889 the existence flag must be synchronized because these values are checked
4890 during cached
4891 ------------------------------------------------------------------------*/
4892 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
4893 "WLAN TL:Preparing to fwd packets for STA %d", ucSTAId));
4894
4895 /*-----------------------------------------------------------------------
4896 Save the new signature values
4897 ------------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304898 pClientSTA->wSTADesc.ucUcastSig = ucUcastSig;
4899 pClientSTA->wSTADesc.ucBcastSig = ucBcastSig;
Jeff Johnson295189b2012-06-20 16:38:30 -07004900
4901 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
4902 "WLAN TL:Fwd-ing packets for STA %d UC %d BC %d",
4903 ucSTAId, ucUcastSig, ucBcastSig));
4904
4905 /*-------------------------------------------------------------------------
4906 Check to see if we have any cached data to forward
4907 -------------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304908 if ( NULL != pClientSTA->vosBegCachedFrame )
Jeff Johnson295189b2012-06-20 16:38:30 -07004909 {
4910 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
4911 "WLAN TL: Fwd-ing Cached packets for station %d", ucSTAId ));
4912
4913 WLANTL_RxCachedFrames( pTLCb,
4914 ucSTAId,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304915 pClientSTA->vosBegCachedFrame);
Jeff Johnson295189b2012-06-20 16:38:30 -07004916 }
4917 else
4918 {
4919 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
4920 "WLAN TL: NO cached packets for station %d", ucSTAId ));
4921 }
4922
4923done:
4924 /*-------------------------------------------------------------------------
4925 Clear the station cache
4926 -------------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304927 pClientSTA->vosBegCachedFrame = NULL;
4928 pClientSTA->vosEndCachedFrame = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004929
4930 /*-----------------------------------------------------------------------
4931 After all the init is complete we can mark the existance flag
4932 ----------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304933 pClientSTA->ucRxBlocked = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004934
4935 //WLAN_TL_UNLOCK_STA_CACHE(pTLCb->atlSTAClients[ucSTAId]);
4936 return VOS_STATUS_SUCCESS;
4937
4938}/*WLANTL_ForwardSTAFrames*/
4939
4940
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004941#if defined(FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_ESE_UPLOAD)
Jeff Johnson295189b2012-06-20 16:38:30 -07004942/*==========================================================================
4943
4944 FUNCTION WLANTL_IsIAPPFrame
4945
4946 DESCRIPTION
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004947 Internal utility function for detecting incoming ESE IAPP frames
Jeff Johnson295189b2012-06-20 16:38:30 -07004948
4949 DEPENDENCIES
4950
4951 PARAMETERS
4952
4953 IN
4954
4955 pvBDHeader: pointer to the BD header
4956 vosTempBuff: the data packet
4957
4958 IN/OUT
4959 pFirstDataPktArrived: static from caller function; used for rssi
4960 computation
4961 RETURN VALUE
4962 The result code associated with performing the operation
4963
4964 VOS_TRUE: It is a IAPP frame
4965 VOS_FALSE: It is NOT IAPP frame
4966
4967 SIDE EFFECTS
4968
4969============================================================================*/
4970v_BOOL_t
4971WLANTL_IsIAPPFrame
4972(
4973 v_PVOID_t pvBDHeader,
4974 vos_pkt_t* vosTempBuff
4975)
4976{
4977 v_U16_t usMPDUDOffset;
4978 v_U8_t ucOffset;
4979 v_U8_t ucSnapHdr[WLANTL_LLC_SNAP_SIZE];
4980 v_SIZE_t usSnapHdrSize = WLANTL_LLC_SNAP_SIZE;
4981 VOS_STATUS vosStatus;
4982
4983 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
4984
4985 /*------------------------------------------------------------------------
4986 Check if OUI field is present.
4987 -------------------------------------------------------------------------*/
4988 if ( VOS_FALSE == WDA_IS_RX_LLC_PRESENT(pvBDHeader) )
4989 {
4990 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
4991 "WLAN TL:LLC header removed, cannot determine BT-AMP type -"
4992 "dropping pkt"));
4993 /* Drop packet */
4994 vos_pkt_return_packet(vosTempBuff);
4995 return VOS_TRUE;
4996 }
4997 usMPDUDOffset = (v_U8_t)WDA_GET_RX_MPDU_DATA_OFFSET(pvBDHeader);
4998 ucOffset = (v_U8_t)usMPDUDOffset + WLANTL_LLC_SNAP_OFFSET;
4999
5000 vosStatus = vos_pkt_extract_data( vosTempBuff, ucOffset,
5001 (v_PVOID_t)ucSnapHdr, &usSnapHdrSize);
5002
5003 if (( VOS_STATUS_SUCCESS != vosStatus))
5004 {
5005 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
5006 "Unable to extract Snap Hdr of data packet -"
5007 "dropping pkt"));
5008 return VOS_FALSE;
5009 }
5010
5011 /*------------------------------------------------------------------------
5012 Check if this is IAPP frame by matching Aironet Snap hdr.
5013 -------------------------------------------------------------------------*/
5014 // Compare returns 1 if values are same and 0
5015 // if not the same.
5016 if (( WLANTL_LLC_SNAP_SIZE != usSnapHdrSize ) ||
5017 ( 0 == vos_mem_compare(ucSnapHdr, (v_PVOID_t)WLANTL_AIRONET_SNAP_HEADER,
5018 WLANTL_LLC_SNAP_SIZE ) ))
5019 {
5020 return VOS_FALSE;
5021 }
5022
5023 return VOS_TRUE;
5024
5025}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005026#endif //FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07005027
5028/*==========================================================================
5029
5030 FUNCTION WLANTL_ProcessBAPFrame
5031
5032 DESCRIPTION
5033 Internal utility function for processing incoming BT-AMP frames
5034
5035 DEPENDENCIES
5036 TL must be initiailized before this function gets called.
5037 Bothe the BT-AMP station and the BAP Ctrl path must have been previously
5038 registered with TL.
5039
5040 PARAMETERS
5041
5042 IN
5043
5044 pvBDHeader: pointer to the BD header
5045 vosTempBuff: the data packet
5046 pTLCb: TL control block
5047 ucSTAId: station id
5048
5049 IN/OUT
5050 pFirstDataPktArrived: static from caller function; used for rssi
5051 computation
5052 RETURN VALUE
5053 The result code associated with performing the operation
5054
5055 VOS_STATUS_E_INVAL: Input parameters are invalid
5056 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
5057 page fault
5058 VOS_STATUS_SUCCESS: Everything is good :)
5059
5060 SIDE EFFECTS
5061
5062============================================================================*/
5063v_BOOL_t
5064WLANTL_ProcessBAPFrame
5065(
5066 v_PVOID_t pvBDHeader,
5067 vos_pkt_t* vosTempBuff,
5068 WLANTL_CbType* pTLCb,
5069 v_U8_t* pFirstDataPktArrived,
5070 v_U8_t ucSTAId
5071)
5072{
5073 v_U16_t usMPDUDOffset;
5074 v_U8_t ucOffset;
5075 v_U8_t ucOUI[WLANTL_LLC_OUI_SIZE];
5076 v_SIZE_t usOUISize = WLANTL_LLC_OUI_SIZE;
5077 VOS_STATUS vosStatus;
5078 v_U16_t usType;
5079 v_SIZE_t usTypeLen = sizeof(usType);
5080 v_U8_t ucMPDUHOffset;
5081 v_U8_t ucMPDUHLen = 0;
5082 v_U16_t usActualHLen = 0;
5083
5084 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
5085
5086 /*------------------------------------------------------------------------
5087 Extract OUI and type from LLC and validate; if non-data send to BAP
5088 -------------------------------------------------------------------------*/
5089 if ( VOS_FALSE == WDA_IS_RX_LLC_PRESENT(pvBDHeader) )
5090 {
5091 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
5092 "WLAN TL:LLC header removed, cannot determine BT-AMP type -"
5093 "dropping pkt"));
5094 /* Drop packet */
5095 vos_pkt_return_packet(vosTempBuff);
5096 return VOS_TRUE;
5097 }
5098
5099 usMPDUDOffset = (v_U8_t)WDA_GET_RX_MPDU_DATA_OFFSET(pvBDHeader);
5100 ucMPDUHOffset = (v_U8_t)WDA_GET_RX_MPDU_HEADER_OFFSET(pvBDHeader);
5101 ucMPDUHLen = (v_U8_t)WDA_GET_RX_MPDU_HEADER_LEN(pvBDHeader);
5102 ucOffset = (v_U8_t)usMPDUDOffset + WLANTL_LLC_OUI_OFFSET;
5103
5104 vosStatus = vos_pkt_extract_data( vosTempBuff, ucOffset,
5105 (v_PVOID_t)ucOUI, &usOUISize);
5106
5107#if 0
5108 // Compare returns 1 if values are same and 0
5109 // if not the same.
5110 if (( WLANTL_LLC_OUI_SIZE != usOUISize ) ||
5111 ( 0 == vos_mem_compare(ucOUI, (v_PVOID_t)WLANTL_BT_AMP_OUI,
5112 WLANTL_LLC_OUI_SIZE ) ))
5113 {
5114 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
5115 "LLC header points to diff OUI in BT-AMP station -"
5116 "dropping pkt"));
5117 /* Drop packet */
5118 vos_pkt_return_packet(vosTempBuff);
5119 return VOS_TRUE;
5120 }
5121#endif
5122 /*------------------------------------------------------------------------
5123 Extract LLC OUI and ensure that this is indeed a BT-AMP frame
5124 ------------------------------------------------------------------------*/
5125 vosStatus = vos_pkt_extract_data( vosTempBuff,
5126 ucOffset + WLANTL_LLC_OUI_SIZE,
5127 (v_PVOID_t)&usType, &usTypeLen);
5128
5129 if (( VOS_STATUS_SUCCESS != vosStatus) ||
5130 ( sizeof(usType) != usTypeLen ))
5131 {
5132 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
5133 "Unable to extract type on incoming BAP packet -"
5134 "dropping pkt"));
5135 /* Drop packet */
5136 vos_pkt_return_packet(vosTempBuff);
5137 return VOS_TRUE;
5138 }
5139
5140 /*------------------------------------------------------------------------
5141 Check if this is BT-AMP data or ctrl packet(RSN, LinkSvision, ActivityR)
5142 ------------------------------------------------------------------------*/
5143 usType = vos_be16_to_cpu(usType);
5144
5145 if (WLANTL_BAP_IS_NON_DATA_PKT_TYPE(usType))
5146 {
5147 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
5148 "WLAN TL:Non-data packet received over BT-AMP link: %d, => BAP",
5149 usType));
5150
5151 /*Flatten packet as BAP expects to be able to peek*/
5152 if ( VOS_STATUS_SUCCESS != vos_pkt_flatten_rx_pkt(&vosTempBuff))
5153 {
5154 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
5155 "WLAN TL:Cannot flatten BT-AMP packet - dropping"));
5156 /* Drop packet */
5157 vos_pkt_return_packet(vosTempBuff);
5158 return VOS_TRUE;
5159 }
5160
5161 /* Send packet to BAP client*/
Jeff Johnson295189b2012-06-20 16:38:30 -07005162 if ( VOS_STATUS_SUCCESS != WDA_DS_TrimRxPacketInfo( vosTempBuff ) )
5163 {
5164 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
5165 "WLAN TL:BD header corrupted - dropping packet"));
5166 /* Drop packet */
5167 vos_pkt_return_packet(vosTempBuff);
5168 return VOS_TRUE;
5169 }
5170
5171 if ( 0 == WDA_GET_RX_FT_DONE(pvBDHeader) )
5172 {
5173 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
5174 "Non-data packet received over BT-AMP link: Sending it for "
5175 "frame Translation"));
5176
5177 if (usMPDUDOffset > ucMPDUHOffset)
5178 {
5179 usActualHLen = usMPDUDOffset - ucMPDUHOffset;
5180 }
5181
5182 /* software frame translation for BTAMP WDS.*/
5183 WLANTL_Translate80211To8023Header( vosTempBuff, &vosStatus, usActualHLen,
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005184 ucMPDUHLen, pTLCb,ucSTAId, VOS_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07005185
5186 }
5187 if (pTLCb->tlBAPClient.pfnTlBAPRx)
5188 pTLCb->tlBAPClient.pfnTlBAPRx( vos_get_global_context(VOS_MODULE_ID_TL,pTLCb),
5189 vosTempBuff,
5190 (WLANTL_BAPFrameEnumType)usType );
Manjunathappa Prakashfb585462013-12-23 19:07:07 -08005191 else
5192 {
5193 VOS_ASSERT(0);
5194 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005195
5196 return VOS_TRUE;
5197 }
5198 else
5199 {
5200 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
5201 "WLAN TL: BAP DATA packet received over BT-AMP link: %d, => BAP",
5202 usType));
5203 /*!!!FIX ME!!*/
5204 #if 0
5205 /*--------------------------------------------------------------------
5206 For data packet collect phy stats RSSI and Link Quality
5207 Calculate the RSSI average and save it. Continuous average is done.
5208 --------------------------------------------------------------------*/
5209 if ( *pFirstDataPktArrived == 0)
5210 {
5211 pTLCb->atlSTAClients[ucSTAId].rssiAvg =
5212 WLANHAL_GET_RSSI_AVERAGE( pvBDHeader );
5213 pTLCb->atlSTAClients[ucSTAId].uLinkQualityAvg =
5214 WLANHAL_RX_BD_GET_SNR( pvBDHeader );
5215
5216 // Rcvd 1st pkt, start average from next time
5217 *pFirstDataPktArrived = 1;
5218 }
5219 else
5220 {
5221 pTLCb->atlSTAClients[ucSTAId].rssiAvg =
5222 (WLANHAL_GET_RSSI_AVERAGE( pvBDHeader ) +
5223 pTLCb->atlSTAClients[ucSTAId].rssiAvg)/2;
5224 pTLCb->atlSTAClients[ucSTAId].uLinkQualityAvg =
5225 (WLANHAL_RX_BD_GET_SNR( pvBDHeader ) +
5226 pTLCb->atlSTAClients[ucSTAId].uLinkQualityAvg)/2;
5227 }/*Else, first data packet*/
5228 #endif
5229 }/*BT-AMP data packet*/
5230
5231 return VOS_FALSE;
5232}/*WLANTL_ProcessBAPFrame*/
5233
Jeff Johnson295189b2012-06-20 16:38:30 -07005234
5235/*==========================================================================
5236
5237 FUNCTION WLANTL_ProcessFCFrame
5238
5239 DESCRIPTION
5240 Internal utility function for processing incoming Flow Control frames. Enable
5241 or disable LWM mode based on the information.
5242
5243 DEPENDENCIES
5244 TL must be initiailized before this function gets called.
5245 FW sends up special flow control frame.
5246
5247 PARAMETERS
5248
5249 IN
5250 pvosGCtx pointer to vos global context
5251 pvBDHeader: pointer to the BD header
5252 pTLCb: TL control block
5253 pvBDHeader pointer to BD header.
5254
5255 IN/OUT
5256 pFirstDataPktArrived: static from caller function; used for rssi
5257 computation
5258 RETURN VALUE
5259 The result code associated with performing the operation
5260
5261 VOS_STATUS_E_INVAL: Input frame are invalid
5262 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
5263 page fault
5264 VOS_STATUS_SUCCESS: Everything is good :)
5265
5266 SIDE EFFECTS
5267 The ingress and egress of each station will be updated. If needed, LWM mode will
5268 be enabled or disabled based on the flow control algorithm.
5269
5270============================================================================*/
5271v_BOOL_t
5272WLANTL_ProcessFCFrame
5273(
5274 v_PVOID_t pvosGCtx,
5275 vos_pkt_t* pvosDataBuff,
5276 v_PVOID_t pvBDHeader
5277)
5278{
5279#if 1 //enable processing of only fcStaTxDisabled bitmap for now. the else part is old better qos code.
5280 // need to revisit the old code for full implementation.
Hoonki Lee14621352013-04-16 17:51:19 -07005281 v_U8_t ucSTAId;
5282 v_U16_t ucStaValidBitmap;
5283 v_U16_t ucStaTxDisabledBitmap;
5284 WLANTL_CbType* pTLCb = NULL;
5285 #ifdef TL_DEBUG_FC
5286 v_U32_t rxTimeStamp;
5287 v_U32_t curTick;
5288 #endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005289 /*------------------------------------------------------------------------
Hoonki Lee14621352013-04-16 17:51:19 -07005290 Extract TL control block
Jeff Johnson295189b2012-06-20 16:38:30 -07005291 ------------------------------------------------------------------------*/
5292 pTLCb = VOS_GET_TL_CB(pvosGCtx);
5293 if ( NULL == pTLCb )
5294 {
5295 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
5296 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_SuspendDataTx"));
5297 return VOS_STATUS_E_FAULT;
5298 }
Hoonki Lee14621352013-04-16 17:51:19 -07005299 ucStaValidBitmap = WDA_GET_RX_FC_VALID_STA_MASK(pvBDHeader);
5300 ucStaTxDisabledBitmap = WDA_GET_RX_FC_STA_TX_DISABLED_BITMAP(pvBDHeader);
5301#ifdef TL_DEBUG_FC
5302 rxTimeStamp = WDA_GET_RX_TIMESTAMP(pvBDHeader);
5303 /* hard code of MTU_GLOBAL_TIMER_ADDR to calculate the time between generated and processed */
5304 wpalReadRegister(0x03081400+0x1D4, &curTick);
Jeff Johnson295189b2012-06-20 16:38:30 -07005305
Jeff Johnson295189b2012-06-20 16:38:30 -07005306 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Arif Hussainf2b00992013-11-17 21:46:15 -08005307 "%ld (%ld-%ld): Disabled %x Valid %x", curTick > rxTimeStamp ? curTick - rxTimeStamp : rxTimeStamp - (0xFFFFFFFF - curTick),
Hoonki Lee14621352013-04-16 17:51:19 -07005308 curTick, rxTimeStamp, ucStaTxDisabledBitmap, ucStaValidBitmap));
5309#endif
5310 for(ucSTAId = 0; ucStaValidBitmap != 0; ucStaValidBitmap >>=1, ucStaTxDisabledBitmap >>= 1, ucSTAId ++)
Jeff Johnson295189b2012-06-20 16:38:30 -07005311 {
Hoonki Lee14621352013-04-16 17:51:19 -07005312 if ( (0 == (ucStaValidBitmap & 0x1)) || (pTLCb->atlSTAClients[ucSTAId] && (0 == pTLCb->atlSTAClients[ucSTAId]->ucExists)) )
5313 continue;
5314
5315 if (ucStaTxDisabledBitmap & 0x1)
5316 {
5317 WLANTL_SuspendDataTx(pvosGCtx, &ucSTAId, NULL);
5318 }
5319 else
5320 {
5321 WLANTL_ResumeDataTx(pvosGCtx, &ucSTAId);
5322 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005323 }
5324
5325#else
5326 VOS_STATUS vosStatus;
5327 tpHalFcRxBd pvFcRxBd = NULL;
5328 v_U8_t ucBitCheck = 0x1;
5329 v_U8_t ucStaValid = 0;
5330 v_U8_t ucSTAId = 0;
5331
5332 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
5333 "Received FC Response");
5334 if ( (NULL == pTLCb) || (NULL == pvosDataBuff))
5335 {
5336 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Arif Hussainf2b00992013-11-17 21:46:15 -08005337 "WLAN TL:Invalid pointer in %s", __func__));
Jeff Johnson295189b2012-06-20 16:38:30 -07005338 return VOS_STATUS_E_FAULT;
5339 }
5340 vosStatus = vos_pkt_peek_data( pvosDataBuff, 0, (v_PVOID_t)&pvFcRxBd,
5341 sizeof(tHalFcRxBd));
5342
5343 if ( (VOS_STATUS_SUCCESS != vosStatus) || (NULL == pvFcRxBd) )
5344 {
5345 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
5346 "WLAN TL:wrong FC Rx packet"));
5347 return VOS_STATUS_E_INVAL;
5348 }
5349
5350 // need to swap bytes in the FC contents.
5351 WLANHAL_SwapFcRxBd(&pvFcRxBd->fcSTATxQLen[0]);
5352
5353 //logic to enable/disable LWM mode for each station
5354 for( ucStaValid = (v_U8_t)pvFcRxBd->fcSTAValidMask; ucStaValid; ucStaValid >>= 1, ucBitCheck <<= 1, ucSTAId ++)
5355 {
5356 if ( (0 == (ucStaValid & 0x1)) || (0 == pTLCb->atlSTAClients[ucSTAId].ucExists) )
5357 {
5358 continue;
5359 }
5360
5361 if ( pvFcRxBd->fcSTAThreshIndMask & ucBitCheck )
5362 {
5363 //LWM event is reported by FW. Able to fetch more packet
5364 if( pTLCb->atlSTAClients[ucSTAId].ucLwmModeEnabled )
5365 {
5366 //Now memory usage is below LWM. Station can send more packets.
5367 pTLCb->atlSTAClients[ucSTAId].ucLwmEventReported = TRUE;
5368 }
5369 else
5370 {
5371 TLLOG4(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_LOW,
Arif Hussainf2b00992013-11-17 21:46:15 -08005372 "WLAN TL: FW report LWM event but the station %d is not in LWM mode", ucSTAId));
Jeff Johnson295189b2012-06-20 16:38:30 -07005373 }
5374 }
5375
5376 //calculate uEgress_length/uIngress_length only after receiving enough packets
5377 if (WLANTL_LWM_INGRESS_SAMPLE_THRESHOLD <= pTLCb->atlSTAClients[ucSTAId].uIngress_length)
5378 {
5379 //check memory usage info to see whether LWM mode should be enabled for the station
5380 v_U32_t uEgress_length = pTLCb->atlSTAClients[ucSTAId].uIngress_length +
5381 pTLCb->atlSTAClients[ucSTAId].bmuMemConsumed - pvFcRxBd->fcSTATxQLen[ucSTAId];
5382
5383 //if ((float)uEgress_length/(float)pTLCb->atlSTAClients[ucSTAId].uIngress_length
5384 // <= WLANTL_LWM_EGRESS_INGRESS_THRESHOLD)
5385 if ( (pTLCb->atlSTAClients[ucSTAId].uIngress_length > uEgress_length) &&
5386 ((pTLCb->atlSTAClients[ucSTAId].uIngress_length - uEgress_length ) >=
5387 (pTLCb->atlSTAClients[ucSTAId].uIngress_length >> 2))
5388 )
5389 {
5390 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
Arif Hussainf2b00992013-11-17 21:46:15 -08005391 "WLAN TL:Enable LWM mode for station %d", ucSTAId));
Jeff Johnson295189b2012-06-20 16:38:30 -07005392 pTLCb->atlSTAClients[ucSTAId].ucLwmModeEnabled = TRUE;
5393 }
5394 else
5395 {
5396 if( pTLCb->atlSTAClients[ucSTAId].ucLwmModeEnabled )
5397 {
5398 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
Arif Hussainf2b00992013-11-17 21:46:15 -08005399 "WLAN TL:Disable LWM mode for station %d", ucSTAId));
Jeff Johnson295189b2012-06-20 16:38:30 -07005400 pTLCb->atlSTAClients[ucSTAId].ucLwmModeEnabled = FALSE;
5401 }
5402
5403 }
5404
5405 //remember memory usage in FW starting from this round
5406 pTLCb->atlSTAClients[ucSTAId].bmuMemConsumed = pvFcRxBd->fcSTATxQLen[ucSTAId];
5407 pTLCb->atlSTAClients[ucSTAId].uIngress_length = 0;
5408 } //(WLANTL_LWM_INGRESS_SAMPLE_THRESHOLD <= pTLCb->atlSTAClients[ucSTAId].uIngress_length)
5409
5410 if( pTLCb->atlSTAClients[ucSTAId].ucLwmModeEnabled )
5411 {
5412 //always update current maximum allowed memeory usage
5413 pTLCb->atlSTAClients[ucSTAId].uBuffThresholdMax = WLANTL_STA_BMU_THRESHOLD_MAX -
5414 pvFcRxBd->fcSTATxQLen[ucSTAId];
5415 }
5416
5417 }
5418#endif
5419
5420 return VOS_STATUS_SUCCESS;
5421}
Jeff Johnson295189b2012-06-20 16:38:30 -07005422
5423
5424/*==========================================================================
5425
5426 FUNCTION WLANTL_RxFrames
5427
5428 DESCRIPTION
5429 Callback registered by TL and called by BAL when a packet is received
5430 over the bus. Upon the call of this function TL will make the necessary
5431 decision with regards to the forwarding or queuing of this packet and
5432 the layer it needs to be delivered to.
5433
5434 DEPENDENCIES
5435 TL must be initiailized before this function gets called.
5436 If the frame carried is a data frame then the station for which it is
5437 destined to must have been previously registered with TL.
5438
5439 PARAMETERS
5440
5441 IN
5442 pvosGCtx: pointer to the global vos context; a handle to TL's
5443 or BAL's control block can be extracted from its context
5444
5445 vosDataBuff: it will contain a pointer to the first buffer received,
5446 if there is more then one packet they will be chained
5447 using vOSS buffers.
5448
5449 RETURN VALUE
5450 The result code associated with performing the operation
5451
5452 VOS_STATUS_E_INVAL: Input parameters are invalid
5453 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
5454 page fault
5455 VOS_STATUS_SUCCESS: Everything is good :)
5456
5457 SIDE EFFECTS
5458
5459============================================================================*/
5460VOS_STATUS
5461WLANTL_RxFrames
5462(
5463 v_PVOID_t pvosGCtx,
5464 vos_pkt_t *pFrameDataBuff
5465)
5466{
5467 vos_pkt_t* vosDataBuff = (vos_pkt_t*)pFrameDataBuff;
5468 WLANTL_CbType* pTLCb = NULL;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05305469 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005470 WLANTL_STAFuncType pfnSTAFsm;
5471 vos_pkt_t* vosTempBuff;
5472 v_U8_t ucSTAId;
5473 VOS_STATUS vosStatus;
5474 v_U8_t ucFrmType;
5475 v_PVOID_t pvBDHeader = NULL;
5476 WLANTL_STAEventType wSTAEvent = WLANTL_RX_EVENT;
5477 v_U8_t ucTid = 0;
5478 v_BOOL_t broadcast = VOS_FALSE;
5479 v_BOOL_t selfBcastLoopback = VOS_FALSE;
Madan Mohan Koyyalamudidfd6aa82012-10-18 20:18:43 -07005480 static v_U8_t first_data_pkt_arrived;
Jeff Johnson295189b2012-06-20 16:38:30 -07005481 v_U32_t uDPUSig;
Jeff Johnson295189b2012-06-20 16:38:30 -07005482 v_U16_t usPktLen;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08005483#ifdef FEATURE_WLAN_TDLS_INTERNAL
5484 v_U8_t ucMPDUHLen = 0 ;
5485 v_U16_t usEtherType = 0;
5486#endif
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005487 v_BOOL_t bForwardIAPPwithLLC = VOS_FALSE;
5488
Jeff Johnson295189b2012-06-20 16:38:30 -07005489 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
5490
5491 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
5492 "WLAN TL:TL Receive Frames called"));
5493
5494 /*------------------------------------------------------------------------
5495 Sanity check
5496 ------------------------------------------------------------------------*/
5497 if ( NULL == vosDataBuff )
5498 {
5499 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
5500 "WLAN TL:Invalid parameter sent on WLANTL_RxFrames"));
5501 return VOS_STATUS_E_INVAL;
5502 }
5503
Katya Nigam3802f202013-12-16 19:27:14 +05305504 /*------------------------------------------------------------------------
5505 Popolaute timestamp as the time when packet arrives
5506 ---------------------------------------------------------------------- */
5507 vosDataBuff->timestamp = vos_timer_get_system_ticks();
5508
Jeff Johnson295189b2012-06-20 16:38:30 -07005509 /*------------------------------------------------------------------------
5510 Extract TL control block
5511 ------------------------------------------------------------------------*/
5512 pTLCb = VOS_GET_TL_CB(pvosGCtx);
5513 if ( NULL == pTLCb )
5514 {
5515 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
5516 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_ChangeSTAState"));
5517 return VOS_STATUS_E_FAULT;
5518 }
5519
5520 /*---------------------------------------------------------------------
5521 Save the initial buffer - this is the first received buffer
5522 ---------------------------------------------------------------------*/
5523 vosTempBuff = vosDataBuff;
5524
5525 while ( NULL != vosTempBuff )
5526 {
Madan Mohan Koyyalamudia148e1e2012-11-30 14:52:59 -08005527 broadcast = VOS_FALSE;
5528 selfBcastLoopback = VOS_FALSE;
5529
Jeff Johnson295189b2012-06-20 16:38:30 -07005530 vos_pkt_walk_packet_chain( vosDataBuff, &vosDataBuff, 1/*true*/ );
5531
5532 /*---------------------------------------------------------------------
5533 Peek at BD header - do not remove
5534 !!! Optimize me: only part of header is needed; not entire one
5535 ---------------------------------------------------------------------*/
5536 vosStatus = WDA_DS_PeekRxPacketInfo( vosTempBuff, (v_PVOID_t)&pvBDHeader, 1/*Swap BD*/ );
5537
5538 if ( NULL == pvBDHeader )
5539 {
5540 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
5541 "WLAN TL:Cannot extract BD header"));
5542 /* Drop packet */
5543 vos_pkt_return_packet(vosTempBuff);
5544 vosTempBuff = vosDataBuff;
5545 continue;
5546 }
5547
Jeff Johnson295189b2012-06-20 16:38:30 -07005548 /*---------------------------------------------------------------------
5549 Check if FC frame reported from FW
5550 ---------------------------------------------------------------------*/
5551 if(WDA_IS_RX_FC(pvBDHeader))
5552 {
5553 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
5554 "WLAN TL:receive one FC frame"));
5555
5556 WLANTL_ProcessFCFrame(pvosGCtx, vosTempBuff, pvBDHeader);
5557 /* Drop packet */
5558 vos_pkt_return_packet(vosTempBuff);
5559 vosTempBuff = vosDataBuff;
5560 continue;
5561 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005562
5563 /* AMSDU HW bug fix
5564 * After 2nd AMSDU subframe HW could not handle BD correctly
5565 * HAL workaround is needed */
5566 if(WDA_GET_RX_ASF(pvBDHeader))
5567 {
5568 WDA_DS_RxAmsduBdFix(pvosGCtx, pvBDHeader);
5569 }
5570
5571 /*---------------------------------------------------------------------
5572 Extract frame control field from 802.11 header if present
5573 (frame translation not done)
5574 ---------------------------------------------------------------------*/
5575
5576 vosStatus = WDA_DS_GetFrameTypeSubType( pvosGCtx, vosTempBuff,
5577 pvBDHeader, &ucFrmType );
5578 if ( VOS_STATUS_SUCCESS != vosStatus )
5579 {
5580 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
5581 "WLAN TL:Cannot extract Frame Control Field"));
5582 /* Drop packet */
5583 vos_pkt_return_packet(vosTempBuff);
5584 vosTempBuff = vosDataBuff;
5585 continue;
5586 }
5587
Mohit Khanna698ba2a2012-12-04 15:08:18 -08005588#ifdef FEATURE_WLAN_TDLS_INTERNAL
5589 if ( WLANTL_IS_DATA_FRAME(ucFrmType))
5590 {
5591 ucMPDUHLen = (v_U8_t)WDA_GET_RX_MPDU_HEADER_LEN(pvBDHeader);
5592 WLANTL_GetEtherType_2(pvBDHeader, vosTempBuff, ucMPDUHLen, &usEtherType) ;
5593 }
5594#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005595 vos_pkt_get_packet_length(vosTempBuff, &usPktLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07005596
5597 /*---------------------------------------------------------------------
5598 Check if management and send to PE
5599 ---------------------------------------------------------------------*/
5600
Mohit Khanna698ba2a2012-12-04 15:08:18 -08005601 if ( WLANTL_IS_MGMT_FRAME(ucFrmType)
5602#ifdef FEATURE_WLAN_TDLS_INTERNAL
5603 || (WLANTL_IS_TDLS_FRAME(usEtherType))
5604#endif
5605 )
Jeff Johnson295189b2012-06-20 16:38:30 -07005606 {
5607 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
5608 "WLAN TL:Sending packet to management client"));
5609 if ( VOS_STATUS_SUCCESS != vos_pkt_flatten_rx_pkt(&vosTempBuff))
5610 {
5611 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
5612 "WLAN TL:Cannot flatten packet - dropping"));
5613 /* Drop packet */
5614 vos_pkt_return_packet(vosTempBuff);
5615 vosTempBuff = vosDataBuff;
5616 continue;
5617 }
5618 ucSTAId = (v_U8_t)WDA_GET_RX_STAID( pvBDHeader );
5619 /* Read RSSI and update */
5620 if(!WLANTL_STA_ID_INVALID(ucSTAId))
5621 {
5622#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
5623 /* Read RSSI and update */
5624 vosStatus = WLANTL_HSHandleRXFrame(pvosGCtx,
5625 WLANTL_MGMT_FRAME_TYPE,
5626 pvBDHeader,
5627 ucSTAId,
5628 VOS_FALSE,
5629 NULL);
5630#else
5631 vosStatus = WLANTL_ReadRSSI(pvosGCtx, pvBDHeader, ucSTAId);
5632#endif
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05305633 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
5634 {
5635 TLLOGW(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
5636 "Handle RX Management Frame fail within Handoff "
5637 "support module"));
5638 /* Do Not Drop packet at here
5639 * Revisit why HO module return fail
5640 * vos_pkt_return_packet(vosTempBuff);
5641 * vosTempBuff = vosDataBuff;
5642 * continue;
5643 */
5644 }
5645 vosStatus = WLANTL_ReadSNR(pvosGCtx, pvBDHeader, ucSTAId);
5646
5647 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
5648 {
5649 TLLOGW(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
5650 FL("Failed to Read SNR")));
5651 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005652 }
5653
Jeff Johnson295189b2012-06-20 16:38:30 -07005654 pTLCb->tlMgmtFrmClient.pfnTlMgmtFrmRx( pvosGCtx, vosTempBuff);
5655 }
5656 else /* Data Frame */
5657 {
5658 ucSTAId = (v_U8_t)WDA_GET_RX_STAID( pvBDHeader );
5659 ucTid = (v_U8_t)WDA_GET_RX_TID( pvBDHeader );
5660
5661 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
5662 "WLAN TL:Data packet received for STA %d", ucSTAId));
5663
5664 /*------------------------------------------------------------------
5665 This should be corrected when multipe sta support is added !!!
5666 for now bcast frames will be sent to the last registered STA
5667 ------------------------------------------------------------------*/
5668 if ( WDA_IS_RX_BCAST(pvBDHeader))
5669 {
5670 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
5671 "WLAN TL:TL rx Bcast frame - sending to last registered station"));
5672 broadcast = VOS_TRUE;
5673
5674 /*-------------------------------------------------------------------
5675 If Addr1 is b/mcast, but Addr3 is our own self MAC, it is a b/mcast
5676 pkt we sent looping back to us. To be dropped if we are non BTAMP
5677 -------------------------------------------------------------------*/
5678 if( WLANHAL_RX_BD_ADDR3_SELF_IDX ==
5679 (v_U8_t)WDA_GET_RX_ADDR3_IDX( pvBDHeader ))
5680 {
5681 selfBcastLoopback = VOS_TRUE;
5682 }
5683 }/*if bcast*/
5684
5685 if ( WLANTL_STA_ID_INVALID(ucSTAId) )
5686 {
5687 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
5688 "WLAN TL:STA ID invalid - dropping pkt"));
5689 /* Drop packet */
5690 vos_pkt_return_packet(vosTempBuff);
5691 vosTempBuff = vosDataBuff;
5692 continue;
5693 }
5694
5695 /*----------------------------------------------------------------------
5696 No need to lock cache access because cache manipulation only happens
5697 in the transport thread/task context
5698 - These frames are to be forwarded to the station upon registration
5699 which happens in the main thread context
5700 The caching here can happen in either Tx or Rx thread depending
5701 on the current SSC scheduling
5702 - also we need to make sure that the frames in the cache are fwd-ed to
5703 the station before the new incoming ones
5704 -----------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05305705 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
5706 if (NULL == pClientSTA)
5707 {
5708 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
5709 "WLAN TL:STA not allocated memory. Dropping packet"));
5710 vos_pkt_return_packet(vosTempBuff);
5711 vosTempBuff = vosDataBuff;
5712 continue;
5713 }
5714
Hoonki Lee5305c3a2013-04-29 23:28:59 -07005715#ifdef FEATURE_WLAN_TDLS
5716 if (( pClientSTA->ucExists ) &&
5717 (WLAN_STA_TDLS == pClientSTA->wSTADesc.wSTAType) &&
5718 (pClientSTA->ucTxSuspended))
5719 vos_atomic_set_U8( &pClientSTA->ucTxSuspended, 0 );
5720 else if ( !broadcast && (pClientSTA->ucExists == 0 ) )
5721 {
5722 tpSirMacMgmtHdr pMacHeader = WDA_GET_RX_MAC_HEADER( pvBDHeader );
5723
5724 /* from the direct peer while it is not registered to TL yet */
5725 if ( (pMacHeader->fc.fromDS == 0) &&
5726 (pMacHeader->fc.toDS == 0) )
5727 {
5728 v_U8_t ucAddr3STAId;
5729
5730 ucAddr3STAId = WDA_GET_RX_ADDR3_IDX(pvBDHeader);
5731
5732 if ( WLANTL_STA_ID_INVALID(ucAddr3STAId) )
5733 {
5734 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
5735 "WLAN TL:STA ID %d invalid - dropping pkt", ucAddr3STAId));
5736 /* Drop packet */
5737 vos_pkt_return_packet(vosTempBuff);
5738 vosTempBuff = vosDataBuff;
5739 continue;
5740 }
5741
5742 if (!(pTLCb->atlSTAClients[ucAddr3STAId] && pTLCb->atlSTAClients[ucAddr3STAId]->ucExists &&
5743 (WLAN_STA_INFRA == pTLCb->atlSTAClients[ucAddr3STAId]->wSTADesc.wSTAType) &&
5744 (WLANTL_STA_AUTHENTICATED == pTLCb->atlSTAClients[ucAddr3STAId]->tlState)))
5745 {
5746 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
Arif Hussainf2b00992013-11-17 21:46:15 -08005747 "%s: staId %d addr3Id %d tlState %d. Unkown Receiver/Transmitter Dropping packet", __func__,
Hoonki Lee5305c3a2013-04-29 23:28:59 -07005748 ucSTAId, ucAddr3STAId, pTLCb->atlSTAClients[ucAddr3STAId]->tlState));
5749 vos_pkt_return_packet(vosTempBuff);
5750 vosTempBuff = vosDataBuff;
5751 continue;
5752 }
5753 else
5754 {
5755 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
Arif Hussainf2b00992013-11-17 21:46:15 -08005756 "%s: staId %d doesn't exist, but mapped to AP staId %d", __func__,
Hoonki Lee5305c3a2013-04-29 23:28:59 -07005757 ucSTAId, ucAddr3STAId));
5758 ucSTAId = ucAddr3STAId;
5759 pClientSTA = pTLCb->atlSTAClients[ucAddr3STAId];
5760 }
5761 }
5762 }
5763#endif
5764
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05305765 if ((( 0 == pClientSTA->ucExists ) ||
5766 ( (0 != pClientSTA->ucRxBlocked)
Jeff Johnson295189b2012-06-20 16:38:30 -07005767 ///@@@: xg: no checking in SOFTAP for now, will revisit later
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05305768 && (WLAN_STA_SOFTAP != pClientSTA->wSTADesc.wSTAType)
Jeff Johnson295189b2012-06-20 16:38:30 -07005769 ) ||
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05305770 ( WLANTL_STA_DISCONNECTED == pClientSTA->tlState)) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07005771 /*Dont buffer Broadcast/Multicast frames. If AP transmits bursts of Broadcast/Multicast data frames,
5772 * libra buffers all Broadcast/Multicast packets after authentication with AP,
5773 * So it will lead to low resource condition in Rx Data Path.*/
5774 ((WDA_IS_RX_BCAST(pvBDHeader) == 0)))
5775 {
5776 uDPUSig = WDA_GET_RX_DPUSIG( pvBDHeader );
5777 //Station has not yet been registered with TL - cache the frame
Hoonki Lee5305c3a2013-04-29 23:28:59 -07005778 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
Arif Hussainf2b00992013-11-17 21:46:15 -08005779 "%s: staId %d exist %d tlState %d cache rx frame", __func__, ucSTAId,
Hoonki Lee5305c3a2013-04-29 23:28:59 -07005780 pClientSTA->ucExists, pClientSTA->tlState));
Jeff Johnson295189b2012-06-20 16:38:30 -07005781 WLANTL_CacheSTAFrame( pTLCb, ucSTAId, vosTempBuff, uDPUSig, broadcast, ucFrmType);
5782 vosTempBuff = vosDataBuff;
5783 continue;
5784 }
5785
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005786#ifdef FEATURE_WLAN_ESE_UPLOAD
5787 if ((pClientSTA->wSTADesc.ucIsEseSta)|| broadcast)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005788 {
5789 /*--------------------------------------------------------------------
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005790 Filter the IAPP frames for ESE connection;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005791 if data it will return false and it
5792 will be routed through the regular data path
5793 --------------------------------------------------------------------*/
5794 if ( WLANTL_IsIAPPFrame(pvBDHeader,
5795 vosTempBuff))
5796 {
5797 bForwardIAPPwithLLC = VOS_TRUE;
5798 }
5799 }
5800#endif
5801
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005802#if defined(FEATURE_WLAN_ESE) && !defined(FEATURE_WLAN_ESE_UPLOAD)
5803 if ((pClientSTA->wSTADesc.ucIsEseSta)|| broadcast)
Jeff Johnson295189b2012-06-20 16:38:30 -07005804 {
5805 /*--------------------------------------------------------------------
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005806 Filter the IAPP frames for ESE connection;
Jeff Johnson295189b2012-06-20 16:38:30 -07005807 if data it will return false and it
5808 will be routed through the regular data path
5809 --------------------------------------------------------------------*/
5810 if ( WLANTL_IsIAPPFrame(pvBDHeader,
5811 vosTempBuff))
5812 {
5813 if ( VOS_STATUS_SUCCESS != vos_pkt_flatten_rx_pkt(&vosTempBuff))
5814 {
5815 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
5816 "WLAN TL:Cannot flatten packet - dropping"));
5817 /* Drop packet */
5818 vos_pkt_return_packet(vosTempBuff);
5819 } else {
5820
5821 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005822 "WLAN TL: Received ESE IAPP Frame"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005823
5824 pTLCb->tlMgmtFrmClient.pfnTlMgmtFrmRx( pvosGCtx, vosTempBuff);
5825 }
5826 vosTempBuff = vosDataBuff;
5827 continue;
5828 }
5829 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005830#endif /* defined(FEATURE_WLAN_ESE) && !defined(FEATURE_WLAN_ESE_UPLOAD) */
Jeff Johnson295189b2012-06-20 16:38:30 -07005831
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05305832 if ( WLAN_STA_BT_AMP == pClientSTA->wSTADesc.wSTAType )
Jeff Johnson295189b2012-06-20 16:38:30 -07005833 {
5834 /*--------------------------------------------------------------------
5835 Process the ctrl BAP frame; if data it will return false and it
5836 will be routed through the regular data path
5837 --------------------------------------------------------------------*/
5838 if ( WLANTL_ProcessBAPFrame( pvBDHeader,
5839 vosTempBuff,
5840 pTLCb,
5841 &first_data_pkt_arrived,
5842 ucSTAId))
5843 {
5844 vosTempBuff = vosDataBuff;
5845 continue;
5846 }
5847 }/*if BT-AMP station*/
5848 else if(selfBcastLoopback == VOS_TRUE)
5849 {
5850 /* Drop packet */
5851 vos_pkt_return_packet(vosTempBuff);
5852 vosTempBuff = vosDataBuff;
5853 continue;
5854 }
5855
5856 /*---------------------------------------------------------------------
5857 Data packet received, send to state machine
5858 ---------------------------------------------------------------------*/
5859 wSTAEvent = WLANTL_RX_EVENT;
5860
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05305861 pfnSTAFsm = tlSTAFsm[pClientSTA->tlState].
Jeff Johnson295189b2012-06-20 16:38:30 -07005862 pfnSTATbl[wSTAEvent];
5863
5864 if ( NULL != pfnSTAFsm )
5865 {
5866#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
5867 /* Read RSSI and update */
5868 vosStatus = WLANTL_HSHandleRXFrame(pvosGCtx,
5869 WLANTL_DATA_FRAME_TYPE,
5870 pvBDHeader,
5871 ucSTAId,
5872 broadcast,
5873 vosTempBuff);
5874 broadcast = VOS_FALSE;
5875#else
5876 vosStatus = WLANTL_ReadRSSI(pvosGCtx, pvBDHeader, ucSTAId);
5877#endif /*FEATURE_WLAN_GEN6_ROAMING*/
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05305878 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
Jeff Johnson295189b2012-06-20 16:38:30 -07005879 {
5880 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
5881 "Handle RX Data Frame fail within Handoff support module"));
5882 /* Do Not Drop packet at here
5883 * Revisit why HO module return fail
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05305884 * vos_pkt_return_packet(vosTempBuff);
5885 * vosTempBuff = vosDataBuff;
5886 * continue;
Jeff Johnson295189b2012-06-20 16:38:30 -07005887 */
5888 }
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05305889 vosStatus = WLANTL_ReadSNR(pvosGCtx, pvBDHeader, ucSTAId);
5890
5891 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
5892 {
5893 TLLOGW(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
5894 FL("Failed to Read SNR")));
5895 }
5896
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005897 pfnSTAFsm( pvosGCtx, ucSTAId, &vosTempBuff, bForwardIAPPwithLLC);
Jeff Johnson295189b2012-06-20 16:38:30 -07005898 }
5899 else
5900 {
5901 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
5902 "WLAN TL:NULL state function, STA:%d, State: %d- dropping packet",
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05305903 ucSTAId, pClientSTA->tlState));
Jeff Johnson295189b2012-06-20 16:38:30 -07005904 /* Drop packet */
5905 vos_pkt_return_packet(vosTempBuff);
5906 vosTempBuff = vosDataBuff;
5907 continue;
5908 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005909 }/* else data frame*/
5910
5911 vosTempBuff = vosDataBuff;
5912 }/*while chain*/
5913
5914 return VOS_STATUS_SUCCESS;
5915}/* WLANTL_RxFrames */
5916
5917
5918/*==========================================================================
5919
5920 FUNCTION WLANTL_RxCachedFrames
5921
5922 DESCRIPTION
5923 Utility function used by TL to forward the cached frames to a particular
5924 station;
5925
5926 DEPENDENCIES
5927 TL must be initiailized before this function gets called.
5928 If the frame carried is a data frame then the station for which it is
5929 destined to must have been previously registered with TL.
5930
5931 PARAMETERS
5932
5933 IN
5934 pTLCb: pointer to TL handle
5935
5936 ucSTAId: station for which we need to forward the packets
5937
5938 vosDataBuff: it will contain a pointer to the first cached buffer
5939 received, if there is more then one packet they will be
5940 chained using vOSS buffers.
5941
5942 RETURN VALUE
5943 The result code associated with performing the operation
5944
5945 VOS_STATUS_E_INVAL: Input parameters are invalid
5946 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
5947 page fault
5948 VOS_STATUS_SUCCESS: Everything is good :)
5949
5950 SIDE EFFECTS
5951
5952============================================================================*/
5953VOS_STATUS
5954WLANTL_RxCachedFrames
5955(
5956 WLANTL_CbType* pTLCb,
5957 v_U8_t ucSTAId,
5958 vos_pkt_t* vosDataBuff
5959)
5960{
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05305961 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005962 WLANTL_STAFuncType pfnSTAFsm;
5963 vos_pkt_t* vosTempBuff;
5964 VOS_STATUS vosStatus;
5965 v_PVOID_t pvBDHeader = NULL;
5966 WLANTL_STAEventType wSTAEvent = WLANTL_RX_EVENT;
5967 v_U8_t ucTid = 0;
5968 v_BOOL_t broadcast = VOS_FALSE;
5969 v_BOOL_t bSigMatch = VOS_FALSE;
5970 v_BOOL_t selfBcastLoopback = VOS_FALSE;
Madan Mohan Koyyalamudidfd6aa82012-10-18 20:18:43 -07005971 static v_U8_t first_data_pkt_arrived;
Jeff Johnson295189b2012-06-20 16:38:30 -07005972 v_U32_t uDPUSig;
5973 v_U8_t ucUcastSig;
5974 v_U8_t ucBcastSig;
5975 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
5976
5977 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
5978 "WLAN TL:TL Receive Cached Frames called"));
5979
5980 /*------------------------------------------------------------------------
5981 Sanity check
5982 ------------------------------------------------------------------------*/
5983 if ( NULL == vosDataBuff )
5984 {
5985 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
5986 "WLAN TL:Invalid parameter sent on WLANTL_RxFrames"));
5987 return VOS_STATUS_E_INVAL;
5988 }
5989
5990 /*---------------------------------------------------------------------
5991 Save the initial buffer - this is the first received buffer
5992 ---------------------------------------------------------------------*/
5993 vosTempBuff = vosDataBuff;
5994
5995 while ( NULL != vosTempBuff )
5996 {
Madan Mohan Koyyalamudia148e1e2012-11-30 14:52:59 -08005997 broadcast = VOS_FALSE;
5998 selfBcastLoopback = VOS_FALSE;
5999
Jeff Johnson295189b2012-06-20 16:38:30 -07006000 vos_pkt_walk_packet_chain( vosDataBuff, &vosDataBuff, 1/*true*/ );
6001
6002 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
6003 "WLAN TL:Sending new cached packet to station %d", ucSTAId));
6004 /*---------------------------------------------------------------------
6005 Peek at BD header - do not remove
6006 !!! Optimize me: only part of header is needed; not entire one
6007 ---------------------------------------------------------------------*/
6008 vosStatus = WDA_DS_PeekRxPacketInfo( vosTempBuff, (v_PVOID_t)&pvBDHeader, 0 );
6009
6010 if ( NULL == pvBDHeader )
6011 {
6012 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6013 "WLAN TL:Cannot extract BD header"));
6014 /* Drop packet */
6015 vos_pkt_return_packet(vosTempBuff);
6016 vosTempBuff = vosDataBuff;
6017 continue;
6018 }
6019
6020 uDPUSig = WDA_GET_RX_DPUSIG( pvBDHeader );
6021
6022 /* AMSDU HW bug fix
6023 * After 2nd AMSDU subframe HW could not handle BD correctly
6024 * HAL workaround is needed */
6025 if(WDA_GET_RX_ASF(pvBDHeader))
6026 {
6027 WDA_DS_RxAmsduBdFix(vos_get_global_context(VOS_MODULE_ID_TL,pTLCb),
6028 pvBDHeader);
6029 }
6030
6031 ucTid = (v_U8_t)WDA_GET_RX_TID( pvBDHeader );
6032
6033 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
6034 "WLAN TL:Data packet cached for STA %d", ucSTAId);
6035
6036 /*------------------------------------------------------------------
6037 This should be corrected when multipe sta support is added !!!
6038 for now bcast frames will be sent to the last registered STA
6039 ------------------------------------------------------------------*/
6040 if ( WDA_IS_RX_BCAST(pvBDHeader))
6041 {
6042 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
6043 "WLAN TL:TL rx Bcast frame "));
6044 broadcast = VOS_TRUE;
6045
6046 /* If Addr1 is b/mcast, but Addr3 is our own self MAC, it is a b/mcast
6047 * pkt we sent looping back to us. To be dropped if we are non BTAMP
6048 */
6049 if( WLANHAL_RX_BD_ADDR3_SELF_IDX ==
6050 (v_U8_t)WDA_GET_RX_ADDR3_IDX( pvBDHeader ))
6051 {
6052 selfBcastLoopback = VOS_TRUE;
6053 }
6054 }/*if bcast*/
6055
6056 /*-------------------------------------------------------------------------
6057 Check if the packet that we cached matches the DPU signature of the
6058 newly added station
6059 -------------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306060 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
6061
6062
6063 if ( NULL == pClientSTA )
6064 {
6065 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6066 "WLAN TL:Client Memory was not allocated on %s", __func__));
6067 return VOS_STATUS_E_FAILURE;
6068 }
6069
Jeff Johnson295189b2012-06-20 16:38:30 -07006070 if ( broadcast )
6071 {
6072 ucBcastSig = (v_U8_t)uDPUSig;
6073 bSigMatch = (( WLAN_TL_INVALID_B_SIG !=
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306074 pClientSTA->wSTADesc.ucBcastSig ) &&
6075 ( ucBcastSig == pClientSTA->wSTADesc.ucBcastSig ));
Jeff Johnson295189b2012-06-20 16:38:30 -07006076 }
6077 else
6078 {
6079 ucUcastSig = (v_U8_t)uDPUSig;
6080 bSigMatch = (( WLAN_TL_INVALID_U_SIG !=
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306081 pClientSTA->wSTADesc.ucUcastSig ) &&
6082 ( ucUcastSig == pClientSTA->wSTADesc.ucUcastSig ));
Jeff Johnson295189b2012-06-20 16:38:30 -07006083 }
6084
6085 /*-------------------------------------------------------------------------
6086 If the packet doesn't match - drop it
6087 -------------------------------------------------------------------------*/
6088 if ( !bSigMatch )
6089 {
Rajesh Chauhana6b08f42013-06-18 19:01:26 -07006090 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_MED,
Jeff Johnson295189b2012-06-20 16:38:30 -07006091 "WLAN TL: Cached packet does not match DPU Sig of the new STA - drop "
6092 " DPU Sig %d UC %d BC %d B %d",
6093 uDPUSig,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306094 pClientSTA->wSTADesc.ucUcastSig,
Rajesh Chauhana6b08f42013-06-18 19:01:26 -07006095 pClientSTA->wSTADesc.ucBcastSig,
Jeff Johnson295189b2012-06-20 16:38:30 -07006096 broadcast));
6097
6098 /* Drop packet */
6099 vos_pkt_return_packet(vosTempBuff);
6100 vosTempBuff = vosDataBuff;
6101 continue;
6102
6103 }/*if signature mismatch*/
6104
6105 /*------------------------------------------------------------------------
6106 Check if BT-AMP frame:
6107 - additional processing needed in this case to separate BT-AMP date
6108 from BT-AMP Ctrl path
6109 ------------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306110 if ( WLAN_STA_BT_AMP == pClientSTA->wSTADesc.wSTAType )
Jeff Johnson295189b2012-06-20 16:38:30 -07006111 {
6112 /*--------------------------------------------------------------------
6113 Process the ctrl BAP frame; if data it will return false and it
6114 will be routed through the regular data path
6115 --------------------------------------------------------------------*/
6116 if ( WLANTL_ProcessBAPFrame( pvBDHeader,
6117 vosTempBuff,
6118 pTLCb,
6119 &first_data_pkt_arrived,
6120 ucSTAId))
6121 {
6122 vosTempBuff = vosDataBuff;
6123 continue;
6124 }
6125 }/*if BT-AMP station*/
6126 else if(selfBcastLoopback == VOS_TRUE)
6127 {
6128 /* Drop packet */
6129 vos_pkt_return_packet(vosTempBuff);
6130 vosTempBuff = vosDataBuff;
6131 continue;
6132 }
6133
6134 /*---------------------------------------------------------------------
6135 Data packet received, send to state machine
6136 ---------------------------------------------------------------------*/
6137 wSTAEvent = WLANTL_RX_EVENT;
6138
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306139 pfnSTAFsm = tlSTAFsm[pClientSTA->tlState].
Jeff Johnson295189b2012-06-20 16:38:30 -07006140 pfnSTATbl[wSTAEvent];
6141
6142 if ( NULL != pfnSTAFsm )
6143 {
6144#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
6145 /* Read RSSI and update */
6146 vosStatus = WLANTL_HSHandleRXFrame(vos_get_global_context(
6147 VOS_MODULE_ID_TL,pTLCb),
6148 WLANTL_DATA_FRAME_TYPE,
6149 pvBDHeader,
6150 ucSTAId,
6151 broadcast,
6152 vosTempBuff);
6153 broadcast = VOS_FALSE;
6154#else
6155 vosStatus = WLANTL_ReadRSSI(vos_get_global_context(VOS_MODULE_ID_TL,pTLCb), pvBDHeader, ucSTAId);
6156#endif /*FEATURE_WLAN_GEN6_ROAMING*/
6157 if(!VOS_IS_STATUS_SUCCESS(vosStatus))
6158 {
6159 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6160 "Handle RX Data Frame fail within Handoff support module"));
6161 /* Do Not Drop packet at here
6162 * Revisit why HO module return fail
6163 vos_pkt_return_packet(vosTempBuff);
6164 vosTempBuff = vosDataBuff;
6165 continue;
6166 */
6167 }
6168 pfnSTAFsm( vos_get_global_context(VOS_MODULE_ID_TL,pTLCb), ucSTAId,
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07006169 &vosTempBuff, VOS_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07006170 }
6171 else
6172 {
6173 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6174 "WLAN TL:NULL state function, STA:%d, State: %d- dropping packet",
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306175 ucSTAId, pClientSTA->tlState));
Jeff Johnson295189b2012-06-20 16:38:30 -07006176 /* Drop packet */
6177 vos_pkt_return_packet(vosTempBuff);
6178 vosTempBuff = vosDataBuff;
6179 continue;
6180 }
6181
6182 vosTempBuff = vosDataBuff;
6183 }/*while chain*/
6184
6185 return VOS_STATUS_SUCCESS;
6186}/* WLANTL_RxCachedFrames */
6187
6188/*==========================================================================
6189 FUNCTION WLANTL_ResourceCB
6190
6191 DESCRIPTION
6192 Called by the TL when it has packets available for transmission.
6193
6194 DEPENDENCIES
6195 The TL must be registered with BAL before this function can be called.
6196
6197 PARAMETERS
6198
6199 IN
6200 pvosGCtx: pointer to the global vos context; a handle to TL's
6201 or BAL's control block can be extracted from its context
6202
6203 RETURN VALUE
6204 The result code associated with performing the operation
6205
6206 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
6207 page fault
6208 VOS_STATUS_SUCCESS: Everything is good :)
6209
6210 SIDE EFFECTS
6211
6212============================================================================*/
6213VOS_STATUS
6214WLANTL_ResourceCB
6215(
6216 v_PVOID_t pvosGCtx,
6217 v_U32_t uCount
6218)
6219{
6220 WLANTL_CbType* pTLCb = NULL;
6221 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
6222
6223 /*------------------------------------------------------------------------
6224 Sanity check
6225 Extract TL control block
6226 ------------------------------------------------------------------------*/
6227 pTLCb = VOS_GET_TL_CB(pvosGCtx);
6228 if ( NULL == pTLCb )
6229 {
6230 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6231 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_ChangeSTAState"));
6232 return VOS_STATUS_E_FAULT;
6233 }
6234
6235 pTLCb->uResCount = uCount;
6236
6237
6238 /*-----------------------------------------------------------------------
6239 Resume Tx if enough res and not suspended
6240 -----------------------------------------------------------------------*/
6241 if (( pTLCb->uResCount >= WDA_TLI_MIN_RES_MF ) &&
6242 ( 0 == pTLCb->ucTxSuspended ))
6243 {
6244 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
6245 "WLAN TL:Issuing Xmit start request to BAL for avail res ASYNC"));
6246 return WDA_DS_StartXmit(pvosGCtx);
6247 }
6248
6249 return VOS_STATUS_SUCCESS;
6250}/* WLANTL_ResourceCB */
6251
6252
Gopichand Nakkala11acd112012-12-31 16:04:04 -08006253/*==========================================================================
6254 FUNCTION WLANTL_IsTxXmitPending
6255
6256 DESCRIPTION
6257 Called by the WDA when it wants to know whether WDA_DS_TX_START_XMIT msg
6258 is pending in TL msg queue
6259
6260 DEPENDENCIES
6261 The TL must be registered with WDA before this function can be called.
6262
6263 PARAMETERS
6264
6265 IN
6266 pvosGCtx: pointer to the global vos context; a handle to TL's
6267 or WDA's control block can be extracted from its context
6268
6269 RETURN VALUE
6270 The result code associated with performing the operation
6271
6272 0: No WDA_DS_TX_START_XMIT msg pending
6273 1: Msg WDA_DS_TX_START_XMIT already pending in TL msg queue
6274
6275 SIDE EFFECTS
6276
6277============================================================================*/
6278v_BOOL_t
6279WLANTL_IsTxXmitPending
6280(
6281 v_PVOID_t pvosGCtx
6282)
6283{
6284
6285 WLANTL_CbType* pTLCb = NULL;
6286 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
6287
6288 /*------------------------------------------------------------------------
6289 Sanity check
6290 Extract TL control block
6291 ------------------------------------------------------------------------*/
6292 pTLCb = VOS_GET_TL_CB(pvosGCtx);
6293 if ( NULL == pTLCb )
6294 {
6295 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_FATAL,
6296 "WLAN TL:Invalid TL pointer from pvosGCtx in WLANTL_IsTxXmitPending "));
6297 return FALSE;
6298 }
6299
6300 return pTLCb->isTxTranmitMsgPending;
6301
6302}/*WLANTL_IsTxXmitPending */
6303
6304/*==========================================================================
6305 FUNCTION WLANTL_SetTxXmitPending
6306
6307 DESCRIPTION
6308 Called by the WDA when it wants to indicate that WDA_DS_TX_START_XMIT msg
6309 is pending in TL msg queue
6310
6311 DEPENDENCIES
6312 The TL must be registered with WDA before this function can be called.
6313
6314 PARAMETERS
6315
6316 IN
6317 pvosGCtx: pointer to the global vos context; a handle to TL's
6318 or WDA's control block can be extracted from its context
6319
6320 RETURN VALUE None
6321
6322 SIDE EFFECTS
6323
6324============================================================================*/
6325
6326v_VOID_t
6327WLANTL_SetTxXmitPending
6328(
6329 v_PVOID_t pvosGCtx
6330)
6331{
6332
6333 WLANTL_CbType* pTLCb = NULL;
6334 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
6335
6336 /*------------------------------------------------------------------------
6337 Sanity check
6338 Extract TL control block
6339 ------------------------------------------------------------------------*/
6340 pTLCb = VOS_GET_TL_CB(pvosGCtx);
6341 if ( NULL == pTLCb )
6342 {
6343 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_FATAL,
6344 "WLAN TL:Invalid TL pointer from pvosGCtx in WLANTL_SetTxXmitPending"));
6345 return;
6346 }
6347
6348 pTLCb->isTxTranmitMsgPending = 1;
6349 return;
6350
6351}/*WLANTL_SetTxXmitPending */
6352
6353/*==========================================================================
6354 FUNCTION WLANTL_ClearTxXmitPending
6355
6356 DESCRIPTION
6357 Called by the WDA when it wants to indicate that no WDA_DS_TX_START_XMIT msg
6358 is pending in TL msg queue
6359
6360 DEPENDENCIES
6361 The TL must be registered with WDA before this function can be called.
6362
6363 PARAMETERS
6364
6365 IN
6366 pvosGCtx: pointer to the global vos context; a handle to TL's
6367 or WDA's control block can be extracted from its context
6368
6369 RETURN VALUE None
6370
6371 SIDE EFFECTS
6372
6373============================================================================*/
6374
6375v_VOID_t
6376WLANTL_ClearTxXmitPending
6377(
6378 v_PVOID_t pvosGCtx
6379)
6380{
6381
6382 WLANTL_CbType* pTLCb = NULL;
6383 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
6384
6385 /*------------------------------------------------------------------------
6386 Sanity check
6387 Extract TL control block
6388 ------------------------------------------------------------------------*/
6389 pTLCb = VOS_GET_TL_CB(pvosGCtx);
6390 if ( NULL == pTLCb )
6391 {
6392 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_FATAL,
6393 "WLAN TL:Invalid TL pointer from pvosGCtx in WLANTL_ClearTxXmitPending "));
6394 return;
6395 }
6396
6397 pTLCb->isTxTranmitMsgPending = 0;
6398 return;
6399}/*WLANTL_ClearTxXmitPending */
6400
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05306401/*==========================================================================
6402 FUNCTION WLANTL_TxThreadDebugHandler
6403
6404 DESCRIPTION
6405 Printing TL Snapshot dump, processed under TxThread context, currently
6406 information regarding the global TlCb struture. Dumps information related
6407 to per active STA connection currently in use by TL.
6408
6409 DEPENDENCIES
6410 The TL must be initialized before this gets called.
6411
6412 PARAMETERS
6413
6414 IN
6415 pvosGCtx: pointer to the global vos context; a handle to TL's
6416 or WDA's control block can be extracted from its context
6417
6418 RETURN VALUE None
6419
6420 SIDE EFFECTS
6421
6422============================================================================*/
6423
6424v_VOID_t
6425WLANTL_TxThreadDebugHandler
6426(
6427 v_PVOID_t *pVosContext
6428)
6429{
6430 WLANTL_CbType* pTLCb = NULL;
6431 WLANTL_STAClientType* pClientSTA = NULL;
6432 int i = 0;
6433 tWDA_CbContext *pWDA = NULL;
6434
6435 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_FATAL,
6436 "WLAN TL: %s Enter ", __func__));
6437
6438 pTLCb = VOS_GET_TL_CB(pVosContext);
6439 pWDA = (tWDA_CbContext *)vos_get_global_context(VOS_MODULE_ID_WDA, pVosContext);
6440
6441 if ( NULL == pVosContext || NULL == pTLCb )
6442 {
6443 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6444 "Global VoS Context or TL Context are NULL"));
6445 return;
6446 }
6447
6448 if (NULL != pWDA)
6449 {
6450 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6451 "WDA uTxFlowMask: %d", pWDA->uTxFlowMask));
6452 }
6453 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6454 "************************TL DUMP INFORMATION**************"));
6455
6456 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6457 "uDelayedTriggerFrmInt:%d\tuMinFramesProcThres:%d",
6458 pTLCb->tlConfigInfo.uDelayedTriggerFrmInt,
6459 pTLCb->tlConfigInfo.uMinFramesProcThres));
6460
6461 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6462 "Management Frame Client exists: %d",
6463 pTLCb->tlMgmtFrmClient.ucExists));
6464 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6465 "usPendingTxCompleteCount: %d\tucTxSuspended: %d",
6466 pTLCb->usPendingTxCompleteCount,
6467 pTLCb->ucTxSuspended));
6468
6469 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6470 "uResCount: %d", pTLCb->uResCount));
6471
6472 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6473 "ucRegisteredStaId: %d\tucCurrentSTA: %d",
6474 pTLCb->ucRegisteredStaId, pTLCb->ucCurrentSTA));
6475
6476 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6477 "UrgentFrameProcessing: %s\tuFramesProcThres: %d",
6478 (pTLCb->bUrgent?"True":"False"), pTLCb->uFramesProcThres));
6479
6480 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6481 "isTxTranmitMsgPending: %d\t isBMPS: %s",
6482 pTLCb->isTxTranmitMsgPending, pTLCb->isBMPS?"True":"False"));
6483
6484#ifdef FEATURE_WLAN_TDLS
6485 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6486 "TDLS Peer Count: %d", pTLCb->ucTdlsPeerCount));
6487#endif
6488
6489 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6490 "++++++++++++++++++++Registerd Client Information++++++++++"));
6491
6492 for ( i =0; i<WLAN_MAX_STA_COUNT; i++ )
6493 {
6494 pClientSTA = pTLCb->atlSTAClients[i];
6495 if( NULL == pClientSTA || 0 == pClientSTA->ucExists)
6496 {
6497 continue;
6498 }
6499
6500 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6501 "######################STA Index: %d ############################",i));
6502 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR, "WLAN_STADescType:"));
6503 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6504 "STAId: %d\t STA MAC Address: %pM", pClientSTA->wSTADesc.ucSTAId,
6505 pClientSTA->wSTADesc.vSTAMACAddress.bytes));
6506 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6507 "STA Type: %d\tProtectedFrame: %d",
6508 pClientSTA->wSTADesc.wSTAType, pClientSTA->wSTADesc.ucProtectedFrame));
6509 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6510 "QoS: %d\tRxFrameTrans: %d\tTxFrameTrans: %d",
6511 pClientSTA->wSTADesc.ucQosEnabled, pClientSTA->wSTADesc.ucSwFrameRXXlation,
6512 pClientSTA->wSTADesc.ucSwFrameTXXlation));
6513 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6514 "ucUcastSig: %d\tucBcastSig: %d", pClientSTA->wSTADesc.ucUcastSig,
6515 pClientSTA->wSTADesc.ucBcastSig));
6516
6517 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6518 "ClientIndex: %d\t Exists: %d", i, pClientSTA->ucExists));
6519 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6520 "TL State: %d\t TL Priority: %d", pClientSTA->tlState,
6521 pClientSTA->tlPri));
6522 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6523 "ucTxSuspended: %d\tucPktPending: %d", pClientSTA->ucTxSuspended,
6524 pClientSTA->ucPktPending));
6525 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6526 "ucEAPOLPktPending: %d\tucNoMoreData: %d",
6527 pClientSTA->ucEapolPktPending, pClientSTA->ucNoMoreData));
6528 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6529 "ucRxBlocked: %d\t fcStaTxDisabled: %d", pClientSTA->ucRxBlocked,
6530 pClientSTA->fcStaTxDisabled));
6531 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6532 "ucCurrentAC: %d\tucServicedAC: %d", pClientSTA->ucCurrentAC,
6533 pClientSTA->ucServicedAC));
6534 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6535 "TID: %d\tautTxCount[0]: %d\tauRxCount[0]: %d",0, pClientSTA->auTxCount[0],
6536 pClientSTA->auRxCount[0]));
6537 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6538 "aucAcMask[0]: %d\taucAcMask[1]: %d\taucAcMask[2]: %d\taucAcMask[3]: %d\t",
6539 pClientSTA->aucACMask[0], pClientSTA->aucACMask[1],
6540 pClientSTA->aucACMask[2], pClientSTA->aucACMask[3]));
6541 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6542 "ucCurrentWeight: %d", pClientSTA->ucCurrentWeight));
6543
6544 if( WLAN_STA_SOFTAP == pClientSTA->wSTADesc.wSTAType)
6545 {
6546 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6547 "TrafficStatistics for SOFTAP Station:"));
6548 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6549 "RUF=%d\tRMF=%d\tRBF=%d", pClientSTA->trafficStatistics.rxUCFcnt,
6550 pClientSTA->trafficStatistics.rxMCFcnt,
6551 pClientSTA->trafficStatistics.rxBCFcnt));
6552 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6553 "RUB=%d\tRMB=%d\tRBB=%d", pClientSTA->trafficStatistics.rxUCBcnt,
6554 pClientSTA->trafficStatistics.rxMCBcnt,
6555 pClientSTA->trafficStatistics.rxBCBcnt));
6556 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6557 "TUF=%d\tTMF=%d\tTBF=%d", pClientSTA->trafficStatistics.txUCFcnt,
6558 pClientSTA->trafficStatistics.txMCFcnt,
6559 pClientSTA->trafficStatistics.txBCFcnt));
6560 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6561 "TUB=%d\tTMB=%d\tTBB=%d", pClientSTA->trafficStatistics.txUCBcnt,
6562 pClientSTA->trafficStatistics.txMCBcnt,
6563 pClientSTA->trafficStatistics.txBCBcnt));
6564 }
6565 }
6566 return;
6567}
6568
6569/*==========================================================================
6570 FUNCTION WLANTL_TLDebugMessage
6571
6572 DESCRIPTION
6573 Post a TL Snapshot request, posts message in TxThread.
6574
6575 DEPENDENCIES
6576 The TL must be initialized before this gets called.
6577
6578 PARAMETERS
6579
6580 IN
6581 displaySnapshot Boolean showing whether to dump the snapshot or not.
6582
6583 RETURN VALUE None
6584
6585 SIDE EFFECTS
6586
6587============================================================================*/
6588
6589v_VOID_t
6590WLANTL_TLDebugMessage
6591(
6592 v_BOOL_t displaySnapshot
6593)
6594{
6595 vos_msg_t vosMsg;
6596 VOS_STATUS status;
6597
6598 if(displaySnapshot)
6599 {
6600 vosMsg.reserved = 0;
6601 vosMsg.bodyptr = NULL;
6602 vosMsg.type = WLANTL_TX_SNAPSHOT;
6603
6604 status = vos_tx_mq_serialize( VOS_MODULE_ID_TL, &vosMsg);
6605 if(status != VOS_STATUS_SUCCESS)
6606 {
6607 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR, "TX Msg Posting Failed with status: %d",status));
6608 return;
6609 }
6610 }
6611 return;
6612}
Jeff Johnson295189b2012-06-20 16:38:30 -07006613
6614/*============================================================================
6615 TL STATE MACHINE
6616============================================================================*/
6617
6618/*==========================================================================
6619 FUNCTION WLANTL_STATxConn
6620
6621 DESCRIPTION
6622 Transmit in connected state - only EAPOL and WAI packets allowed
6623
6624 DEPENDENCIES
6625 The STA must be registered with TL before this function can be called.
6626
6627 PARAMETERS
6628
6629 IN
6630 pvosGCtx: pointer to the global vos context; a handle to TL's
6631 control block can be extracted from its context
6632 ucSTAId: identifier of the station being processed
6633 vosDataBuff: pointer to the tx vos buffer
6634
6635 RETURN VALUE
6636 The result code associated with performing the operation
6637
6638 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
6639 page fault
6640 VOS_STATUS_SUCCESS: Everything is good :)
6641
6642 Other return values are possible coming from the called functions.
6643 Please check API for additional info.
6644
6645 SIDE EFFECTS
6646
6647============================================================================*/
6648VOS_STATUS
6649WLANTL_STATxConn
6650(
6651 v_PVOID_t pvosGCtx,
6652 v_U8_t ucSTAId,
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07006653 vos_pkt_t** pvosDataBuff,
6654 v_BOOL_t bForwardIAPPwithLLC
Jeff Johnson295189b2012-06-20 16:38:30 -07006655)
6656{
6657 v_U16_t usPktLen;
6658 VOS_STATUS vosStatus;
6659 v_MACADDR_t vDestMacAddr;
6660 vos_pkt_t* vosDataBuff = NULL;
6661 WLANTL_CbType* pTLCb = NULL;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306662 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07006663 WLANTL_MetaInfoType tlMetaInfo;
6664 v_U8_t ucTypeSubtype = 0;
6665 v_U8_t ucTid;
6666 v_U8_t extraHeadSpace = 0;
6667 v_U8_t ucWDSEnabled = 0;
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07006668 v_U8_t ucAC, ucACMask, i;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05306669 v_U32_t txFlag = HAL_TX_NO_ENCRYPTION_MASK;
Jeff Johnson295189b2012-06-20 16:38:30 -07006670 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
6671
6672 /*------------------------------------------------------------------------
6673 Sanity check
6674 Extract TL control block
6675 ------------------------------------------------------------------------*/
6676 pTLCb = VOS_GET_TL_CB(pvosGCtx);
6677 if ( NULL == pTLCb )
6678 {
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07006679 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6680 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_STATxConn");
Jeff Johnson295189b2012-06-20 16:38:30 -07006681 *pvosDataBuff = NULL;
6682 return VOS_STATUS_E_FAULT;
6683 }
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306684 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
6685
6686 if ( NULL == pClientSTA )
6687 {
6688 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6689 "WLAN TL:Client Memory was not allocated on %s", __func__));
6690 return VOS_STATUS_E_FAILURE;
6691 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006692
6693 /*-------------------------------------------------------------------
6694 Disable AC temporary - if successfull retrieve re-enable
6695 The order is justified because of the possible scenario
6696 - TL tryes to fetch packet for AC and it returns NULL
6697 - TL analyzes the data it has received to see if there are
6698 any more pkts available for AC -> if not TL will disable AC
6699 - however it is possible that while analyzing results TL got
6700 preempted by a pending indication where the mask was again set
6701 TL will not check again and as a result when it resumes
6702 execution it will disable AC
6703 To prevent this the AC will be disabled here and if retrieve
6704 is successfull it will be re-enabled
6705 -------------------------------------------------------------------*/
6706
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07006707
6708 //LTI:pTLCb->atlSTAClients[ucSTAId].
6709 //LTI: aucACMask[pTLCb->atlSTAClients[ucSTAId].ucCurrentAC] = 0;
6710
6711 /*------------------------------------------------------------------------
6712 Fetch packet from HDD
6713 ------------------------------------------------------------------------*/
Sunil Ravid5406f22013-01-22 00:18:31 -08006714#ifdef FEATURE_WLAN_TDLS
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306715 if ((WLAN_STA_SOFTAP != pClientSTA->wSTADesc.wSTAType) &&
Sunil Ravid5406f22013-01-22 00:18:31 -08006716 (!vos_concurrent_sessions_running()) &&
6717 !pTLCb->ucTdlsPeerCount)
6718 {
6719#else
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306720 if ((WLAN_STA_SOFTAP != pClientSTA->wSTADesc.wSTAType) &&
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07006721 (!vos_concurrent_sessions_running()))
6722 {
Sunil Ravid5406f22013-01-22 00:18:31 -08006723#endif
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306724 ucAC = pClientSTA->ucCurrentAC;
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07006725
6726 /*-------------------------------------------------------------------
6727 Disable AC temporary - if successfull retrieve re-enable
6728 The order is justified because of the possible scenario
6729 - TL tryes to fetch packet for AC and it returns NULL
6730 - TL analyzes the data it has received to see if there are
6731 any more pkts available for AC -> if not TL will disable AC
6732 - however it is possible that while analyzing results TL got
6733 preempted by a pending indication where the mask was again set
6734 TL will not check again and as a result when it resumes
6735 execution it will disable AC
6736 To prevent this the AC will be disabled here and if retrieve
6737 is successfull it will be re-enabled
6738 -------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306739 pClientSTA->aucACMask[ucAC] = 0;
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07006740 }
6741 else
6742 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306743 //softap case
6744 ucAC = pTLCb->uCurServedAC;
6745 pClientSTA->aucACMask[ucAC] = 0;
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07006746 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006747
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306748 /*You make an initial assumption that HDD has no more data and if the
Jeff Johnson295189b2012-06-20 16:38:30 -07006749 assumption was wrong you reset the flags to their original state
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306750 This will prevent from exposing a race condition between checking with HDD
Jeff Johnson295189b2012-06-20 16:38:30 -07006751 for packets and setting the flags to false*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306752 //LTI: vos_atomic_set_U8( &pTLCb->atlSTAClients[ucSTAId].ucPktPending, 0);
6753 //LTI: pTLCb->atlSTAClients[ucSTAId].ucNoMoreData = 1;
6754 vos_atomic_set_U8( &pClientSTA->ucPktPending, 0);
6755 WLAN_TL_AC_ARRAY_2_MASK( pClientSTA, ucACMask, i);
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306756 /*You make an initial assumption that HDD has no more data and if the
6757 assumption was wrong you reset the flags to their original state
6758 This will prevent from exposing a race condition between checking with HDD
6759 for packets and setting the flags to false*/
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07006760 if ( 0 == ucACMask )
6761 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306762 pClientSTA->ucNoMoreData = 1;
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07006763 }
6764 else
6765 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306766 vos_atomic_set_U8( &pClientSTA->ucPktPending, 1);
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07006767 }
6768
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07006769
Madan Mohan Koyyalamudid93f4942012-10-05 15:05:40 -07006770 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07006771 "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 +05306772 ucAC, ucACMask, pClientSTA->ucPktPending);
Jeff Johnson295189b2012-06-20 16:38:30 -07006773
6774 /*------------------------------------------------------------------------
6775 Fetch tx packet from HDD
6776 ------------------------------------------------------------------------*/
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07006777//LTI
6778#if 0
Jeff Johnson295189b2012-06-20 16:38:30 -07006779 if (WLAN_STA_SOFTAP != pTLCb->atlSTAClients[ucSTAId].wSTADesc.wSTAType &&
6780 (!vos_concurrent_sessions_running()))
6781 {
Jeff Johnson295189b2012-06-20 16:38:30 -07006782 // don't set 0.
6783 //vos_atomic_set_U8( &pTLCb->atlSTAClients[ucSTAId].ucPktPending, 0);
6784 vosStatus = pTLCb->atlSTAClients[ucSTAId].pfnSTAFetchPkt( pvosGCtx,
6785 &ucSTAId,
6786 pTLCb->atlSTAClients[ucSTAId].ucCurrentAC,
6787 &vosDataBuff, &tlMetaInfo );
Jeff Johnson295189b2012-06-20 16:38:30 -07006788 }
6789 else
6790 {
6791 //softap case
6792 WLANTL_ACEnumType ucAC = pTLCb->uCurServedAC;
6793 vosStatus = pTLCb->atlSTAClients[ucSTAId].pfnSTAFetchPkt( pvosGCtx,
6794 &ucSTAId,
6795 ucAC,
6796 &vosDataBuff, &tlMetaInfo );
6797 }
6798#endif
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07006799
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306800 vosStatus = pClientSTA->pfnSTAFetchPkt( pvosGCtx,
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07006801 &ucSTAId,
6802 ucAC,
6803 &vosDataBuff, &tlMetaInfo );
Jeff Johnson295189b2012-06-20 16:38:30 -07006804
6805 if (( VOS_STATUS_SUCCESS != vosStatus ) || ( NULL == vosDataBuff ))
6806 {
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07006807 TLLOG1(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -07006808 "WLAN TL:No more data at HDD status %d", vosStatus));
6809 *pvosDataBuff = NULL;
6810
6811 /*--------------------------------------------------------------------
6812 Reset AC for the serviced station to the highest priority AC
6813 -> due to no more data at the station
6814 Even if this AC is not supported by the station, correction will be
6815 made in the main TL loop
6816 --------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306817 pClientSTA->ucCurrentAC = WLANTL_AC_VO;
6818 pClientSTA->ucCurrentWeight = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07006819
Madan Mohan Koyyalamudid8000342012-11-08 14:55:26 -08006820 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07006821 "WLAN TL: WLANTL_STATxConn no more packets in HDD for AC: %d AC Mask: %d",
6822 ucAC, ucACMask);
6823
Jeff Johnson295189b2012-06-20 16:38:30 -07006824 return vosStatus;
6825 }
6826
6827 /*There are still packets in HDD - set back the pending packets and
6828 the no more data assumption*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306829 vos_atomic_set_U8( &pClientSTA->ucPktPending, 1);
6830 pClientSTA->ucNoMoreData = 0;
6831 pClientSTA->aucACMask[ucAC] = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07006832
Jeff Johnson295189b2012-06-20 16:38:30 -07006833#ifdef WLAN_PERF
6834 vos_pkt_set_user_data_ptr( vosDataBuff, VOS_PKT_USER_DATA_ID_BAL,
6835 (v_PVOID_t)0);
6836
6837#endif /*WLAN_PERF*/
6838
6839
6840#ifdef FEATURE_WLAN_WAPI
6841 /*------------------------------------------------------------------------
6842 If the packet is neither an Eapol packet nor a WAI packet then drop it
6843 ------------------------------------------------------------------------*/
6844 if ( 0 == tlMetaInfo.ucIsEapol && 0 == tlMetaInfo.ucIsWai )
6845 {
Madan Mohan Koyyalamudid93f4942012-10-05 15:05:40 -07006846 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -07006847 "WLAN TL:Only EAPOL or WAI packets allowed before authentication"));
6848
6849 /* Fail tx for packet */
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306850 pClientSTA->pfnSTATxComp( pvosGCtx, vosDataBuff,
Jeff Johnson295189b2012-06-20 16:38:30 -07006851 VOS_STATUS_E_BADMSG);
6852 vosDataBuff = NULL;
6853 *pvosDataBuff = NULL;
6854 return VOS_STATUS_SUCCESS;
6855 }
6856#else
6857 if ( 0 == tlMetaInfo.ucIsEapol )
6858 {
6859 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
6860 "WLAN TL:Received non EAPOL packet before authentication"));
6861
6862 /* Fail tx for packet */
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306863 pClientSTA->pfnSTATxComp( pvosGCtx, vosDataBuff,
Jeff Johnson295189b2012-06-20 16:38:30 -07006864 VOS_STATUS_E_BADMSG);
6865 vosDataBuff = NULL;
6866 *pvosDataBuff = NULL;
6867 return VOS_STATUS_SUCCESS;
6868 }
6869#endif /* FEATURE_WLAN_WAPI */
6870
6871 /*-------------------------------------------------------------------------
6872 Check TID
6873 -------------------------------------------------------------------------*/
6874 ucTid = tlMetaInfo.ucTID;
6875
6876 /*Make sure TID is valid*/
6877 if ( WLANTL_TID_INVALID(ucTid))
6878 {
Rajesh Chauhan2df40bf2013-08-22 11:26:12 -07006879 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
Jeff Johnson295189b2012-06-20 16:38:30 -07006880 "WLAN TL:Invalid TID sent in meta info %d - defaulting to 0 (BE)",
6881 ucTid));
6882 ucTid = 0;
6883 }
6884
6885 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
6886 "WLAN TL:Attaching BD header to pkt on WLANTL_STATxConn"));
6887
6888#ifdef FEATURE_WLAN_WAPI
6889 /*------------------------------------------------------------------------
6890 Translate 802.3 frame to 802.11 if Frame translation is enabled or if
6891 frame is a WAI frame.
6892 ------------------------------------------------------------------------*/
6893 if ( ( 1 == tlMetaInfo.ucIsWai ) ||
6894 ( 0 == tlMetaInfo.ucDisableFrmXtl ) )
6895#else
6896 /*------------------------------------------------------------------------
6897 Translate 802.3 frame to 802.11 if Frame translation is enabled
6898 ------------------------------------------------------------------------*/
6899 if ( ( 0 == tlMetaInfo.ucDisableFrmXtl ) &&
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306900 ( 0 != pClientSTA->wSTADesc.ucSwFrameTXXlation) )
Jeff Johnson295189b2012-06-20 16:38:30 -07006901#endif //#ifdef FEATURE_WLAN_WAPI
6902 {
Kiran Venkatappacab0d352012-12-17 13:09:22 -08006903 vosStatus = WLANTL_Translate8023To80211Header( vosDataBuff, &vosStatus,
6904 pTLCb, &ucSTAId,
Ravi Joshid0699502013-07-08 15:48:47 -07006905 &tlMetaInfo, &ucWDSEnabled,
6906 &extraHeadSpace);
Jeff Johnson295189b2012-06-20 16:38:30 -07006907 if ( VOS_STATUS_SUCCESS != vosStatus )
6908 {
6909 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6910 "WLAN TL:Error when translating header WLANTL_STATxConn"));
6911
6912 return vosStatus;
6913 }
6914
6915 tlMetaInfo.ucDisableFrmXtl = 1;
6916 }
6917
6918 /*-------------------------------------------------------------------------
6919 Call HAL to fill BD header
6920 -------------------------------------------------------------------------*/
6921 ucTypeSubtype |= (WLANTL_80211_DATA_TYPE << 4);
6922
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306923 if ( pClientSTA->wSTADesc.ucQosEnabled )
Jeff Johnson295189b2012-06-20 16:38:30 -07006924 {
6925 ucTypeSubtype |= (WLANTL_80211_DATA_QOS_SUBTYPE);
6926 }
6927
Gopichand Nakkala8b54e912013-03-11 10:44:21 +05306928#ifdef FEATURE_WLAN_WAPI
6929 /* TL State does not transition to AUTHENTICATED till GTK is installed, So in
6930 * case of WPA where GTK handshake is done after the 4 way handshake, the
6931 * unicast 2/2 EAPOL packet from the STA->AP has to be encrypted even before
6932 * the TL is in authenticated state. Since the PTK has been installed
6933 * already (after the 4 way handshake) we make sure that all traffic
6934 * is encrypted henceforth.(Note: TL is still not in AUTHENTICATED state so
6935 * we will only allow EAPOL data or WAI in case of WAPI)
6936 */
6937 if (tlMetaInfo.ucIsEapol && pClientSTA->ptkInstalled)
6938 {
6939 txFlag = 0;
6940 }
6941#else
6942 if (pClientSTA->ptkInstalled)
6943 {
6944 txFlag = 0;
6945 }
6946#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006947
6948 vosStatus = (VOS_STATUS)WDA_DS_BuildTxPacketInfo( pvosGCtx, vosDataBuff , &vDestMacAddr,
6949 tlMetaInfo.ucDisableFrmXtl, &usPktLen,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306950 pClientSTA->wSTADesc.ucQosEnabled, ucWDSEnabled,
Jeff Johnson295189b2012-06-20 16:38:30 -07006951 extraHeadSpace,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306952 ucTypeSubtype, &pClientSTA->wSTADesc.vSelfMACAddress,
Gopichand Nakkala8b54e912013-03-11 10:44:21 +05306953 ucTid, txFlag,
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -07006954 tlMetaInfo.usTimeStamp, tlMetaInfo.ucIsEapol || tlMetaInfo.ucIsWai, tlMetaInfo.ucUP );
Jeff Johnson295189b2012-06-20 16:38:30 -07006955
6956 if ( VOS_STATUS_SUCCESS != vosStatus )
6957 {
6958 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6959 "WLAN TL:Failed while attempting to fill BD %d", vosStatus));
6960 *pvosDataBuff = NULL;
6961 return vosStatus;
6962 }
6963
6964 /*-----------------------------------------------------------------------
6965 Update tx counter for BA session query for tx side
6966 !1 - should this be done for EAPOL frames?
6967 -----------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306968 pClientSTA->auTxCount[ucTid]++;
Jeff Johnson295189b2012-06-20 16:38:30 -07006969
6970 vos_pkt_set_user_data_ptr( vosDataBuff, VOS_PKT_USER_DATA_ID_TL,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306971 (v_PVOID_t)pClientSTA->pfnSTATxComp );
Jeff Johnson295189b2012-06-20 16:38:30 -07006972
6973 /*------------------------------------------------------------------------
6974 Save data to input pointer for TL core
6975 ------------------------------------------------------------------------*/
6976 *pvosDataBuff = vosDataBuff;
6977 /*security frames cannot be delayed*/
6978 pTLCb->bUrgent = TRUE;
6979
Jeff Johnson295189b2012-06-20 16:38:30 -07006980 /* TX Statistics */
6981 if (!(tlMetaInfo.ucBcast || tlMetaInfo.ucMcast))
6982 {
6983 /* This is TX UC frame */
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306984 pClientSTA->trafficStatistics.txUCFcnt++;
6985 pClientSTA->trafficStatistics.txUCBcnt += usPktLen;
Jeff Johnson295189b2012-06-20 16:38:30 -07006986 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006987
6988 return VOS_STATUS_SUCCESS;
6989}/* WLANTL_STATxConn */
6990
6991
6992/*==========================================================================
6993 FUNCTION WLANTL_STATxAuth
6994
6995 DESCRIPTION
6996 Transmit in authenticated state - all data allowed
6997
6998 DEPENDENCIES
6999 The STA must be registered with TL before this function can be called.
7000
7001 PARAMETERS
7002
7003 IN
7004 pvosGCtx: pointer to the global vos context; a handle to TL's
7005 control block can be extracted from its context
7006 ucSTAId: identifier of the station being processed
7007 vosDataBuff: pointer to the tx vos buffer
7008
7009 RETURN VALUE
7010 The result code associated with performing the operation
7011
7012 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
7013 page fault
7014 VOS_STATUS_SUCCESS: Everything is good :)
7015
7016 Other return values are possible coming from the called functions.
7017 Please check API for additional info.
7018
7019 SIDE EFFECTS
7020
7021============================================================================*/
7022VOS_STATUS
7023WLANTL_STATxAuth
7024(
7025 v_PVOID_t pvosGCtx,
7026 v_U8_t ucSTAId,
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07007027 vos_pkt_t** pvosDataBuff,
7028 v_BOOL_t bForwardIAPPwithLLC
Jeff Johnson295189b2012-06-20 16:38:30 -07007029)
7030{
7031 v_U16_t usPktLen;
7032 VOS_STATUS vosStatus;
7033 v_MACADDR_t vDestMacAddr;
7034 vos_pkt_t* vosDataBuff = NULL;
7035 WLANTL_CbType* pTLCb = NULL;
7036 WLANTL_MetaInfoType tlMetaInfo;
7037 v_U8_t ucTypeSubtype = 0;
7038 WLANTL_ACEnumType ucAC;
7039 WLANTL_ACEnumType ucNextAC;
7040 v_U8_t ucTid;
7041 v_U8_t ucSwFrmXtl = 0;
7042 v_U8_t extraHeadSpace = 0;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307043 WLANTL_STAClientType *pStaClient = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07007044 v_U8_t ucWDSEnabled = 0;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05307045 v_U32_t ucTxFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07007046 v_U8_t ucACMask, i;
7047 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
7048
7049 /*------------------------------------------------------------------------
7050 Sanity check
7051 Extract TL control block
7052 ------------------------------------------------------------------------*/
7053 pTLCb = VOS_GET_TL_CB(pvosGCtx);
7054 if (( NULL == pTLCb ) || ( NULL == pvosDataBuff ))
7055 {
7056 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson0298bd02013-11-14 19:58:38 -08007057 "WLAN TL:Invalid input params on WLANTL_STATxAuth TL %p DB %p",
Jeff Johnson295189b2012-06-20 16:38:30 -07007058 pTLCb, pvosDataBuff));
7059 if (NULL != pvosDataBuff)
7060 {
7061 *pvosDataBuff = NULL;
7062 }
7063 if(NULL != pTLCb)
7064 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307065 if ( NULL == pTLCb->atlSTAClients[ucSTAId] )
7066 {
7067 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7068 "WLAN TL:Client Memory was not allocated on %s", __func__));
7069 return VOS_STATUS_E_FAILURE;
7070 }
7071 pTLCb->atlSTAClients[ucSTAId]->ucNoMoreData = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07007072 }
7073 return VOS_STATUS_E_FAULT;
7074 }
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307075 pStaClient = pTLCb->atlSTAClients[ucSTAId];
Jeff Johnson295189b2012-06-20 16:38:30 -07007076
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307077 if ( NULL == pStaClient )
7078 {
7079 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7080 "WLAN TL:Client Memory was not allocated on %s", __func__));
7081 return VOS_STATUS_E_FAILURE;
7082 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007083
7084 vos_mem_zero(&tlMetaInfo, sizeof(tlMetaInfo));
7085 /*------------------------------------------------------------------------
7086 Fetch packet from HDD
7087 ------------------------------------------------------------------------*/
Sunil Ravid5406f22013-01-22 00:18:31 -08007088#ifdef FEATURE_WLAN_TDLS
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307089 if ((WLAN_STA_SOFTAP != pStaClient->wSTADesc.wSTAType) &&
Sunil Ravid5406f22013-01-22 00:18:31 -08007090 (!vos_concurrent_sessions_running()) &&
7091 !pTLCb->ucTdlsPeerCount)
7092 {
7093#else
Jeff Johnson295189b2012-06-20 16:38:30 -07007094 if ((WLAN_STA_SOFTAP != pStaClient->wSTADesc.wSTAType) &&
7095 (!vos_concurrent_sessions_running()))
7096 {
7097#endif
7098 ucAC = pStaClient->ucCurrentAC;
7099
7100 /*-------------------------------------------------------------------
7101 Disable AC temporary - if successfull retrieve re-enable
7102 The order is justified because of the possible scenario
7103 - TL tryes to fetch packet for AC and it returns NULL
7104 - TL analyzes the data it has received to see if there are
7105 any more pkts available for AC -> if not TL will disable AC
7106 - however it is possible that while analyzing results TL got
7107 preempted by a pending indication where the mask was again set
7108 TL will not check again and as a result when it resumes
7109 execution it will disable AC
7110 To prevent this the AC will be disabled here and if retrieve
7111 is successfull it will be re-enabled
7112 -------------------------------------------------------------------*/
7113 pStaClient->aucACMask[pStaClient->ucCurrentAC] = 0;
7114
7115 // don't reset it, as other AC queues in HDD may have packets
7116 //vos_atomic_set_U8( &pStaClient->ucPktPending, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07007117 }
7118 else
7119 {
7120 //softap case
7121 ucAC = pTLCb->uCurServedAC;
7122 pStaClient->aucACMask[ucAC] = 0;
7123
7124 //vos_atomic_set_U8( &pStaClient->ucPktPending, 0);
7125 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007126
7127 WLAN_TL_AC_ARRAY_2_MASK( pStaClient, ucACMask, i);
Jeff Johnson295189b2012-06-20 16:38:30 -07007128 /*You make an initial assumption that HDD has no more data and if the
7129 assumption was wrong you reset the flags to their original state
7130 This will prevent from exposing a race condition between checking with HDD
7131 for packets and setting the flags to false*/
7132 if ( 0 == ucACMask )
7133 {
7134 vos_atomic_set_U8( &pStaClient->ucPktPending, 0);
7135 pStaClient->ucNoMoreData = 1;
7136 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007137
7138 vosStatus = pStaClient->pfnSTAFetchPkt( pvosGCtx,
7139 &ucSTAId,
7140 ucAC,
7141 &vosDataBuff, &tlMetaInfo );
7142
7143
7144 if (( VOS_STATUS_SUCCESS != vosStatus ) || ( NULL == vosDataBuff ))
7145 {
7146
7147 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
7148 "WLAN TL:Failed while attempting to fetch pkt from HDD %d",
7149 vosStatus);
7150 *pvosDataBuff = NULL;
7151 /*--------------------------------------------------------------------
7152 Reset AC for the serviced station to the highest priority AC
7153 -> due to no more data at the station
7154 Even if this AC is not supported by the station, correction will be
7155 made in the main TL loop
7156 --------------------------------------------------------------------*/
7157 pStaClient->ucCurrentAC = WLANTL_AC_VO;
7158 pStaClient->ucCurrentWeight = 0;
7159
7160 return vosStatus;
7161 }
7162
Jeff Johnsone7245742012-09-05 17:12:55 -07007163 WLANTL_StatHandleTXFrame(pvosGCtx, ucSTAId, vosDataBuff, NULL, &tlMetaInfo);
Jeff Johnsone7245742012-09-05 17:12:55 -07007164
Jeff Johnson295189b2012-06-20 16:38:30 -07007165 /*There are still packets in HDD - set back the pending packets and
7166 the no more data assumption*/
7167 vos_atomic_set_U8( &pStaClient->ucPktPending, 1);
7168 pStaClient->ucNoMoreData = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07007169
Jeff Johnson295189b2012-06-20 16:38:30 -07007170 if (WLAN_STA_SOFTAP != pStaClient->wSTADesc.wSTAType)
7171 {
Jeff Johnson295189b2012-06-20 16:38:30 -07007172 // don't need to set it, as we don't reset it in this function.
7173 //vos_atomic_set_U8( &pTLCb->atlSTAClients[ucSTAId].ucPktPending, 1);
Jeff Johnson295189b2012-06-20 16:38:30 -07007174 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007175
7176#ifdef WLAN_PERF
7177 vos_pkt_set_user_data_ptr( vosDataBuff, VOS_PKT_USER_DATA_ID_BAL,
7178 (v_PVOID_t)0);
7179#endif /*WLAN_PERF*/
7180
7181 /*-------------------------------------------------------------------------
7182 Check TID
7183 -------------------------------------------------------------------------*/
7184 ucTid = tlMetaInfo.ucTID;
7185
7186 /*Make sure TID is valid*/
7187 if ( WLANTL_TID_INVALID(ucTid))
7188 {
Rajesh Chauhan2df40bf2013-08-22 11:26:12 -07007189 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
Jeff Johnson295189b2012-06-20 16:38:30 -07007190 "WLAN TL:Invalid TID sent in meta info %d - defaulting to 0 (BE)",
7191 ucTid));
7192 ucTid = 0;
7193 }
7194
7195 /*Save for UAPSD timer consideration*/
7196 pStaClient->ucServicedAC = ucAC;
7197
7198 if ( ucAC == pStaClient->ucCurrentAC )
7199 {
7200 pStaClient->aucACMask[pStaClient->ucCurrentAC] = 1;
7201 pStaClient->ucCurrentWeight--;
7202 }
7203 else
7204 {
7205 pStaClient->ucCurrentAC = ucAC;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307206 pStaClient->ucCurrentWeight = pTLCb->tlConfigInfo.ucAcWeights[ucAC] - 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07007207
7208 pStaClient->aucACMask[pStaClient->ucCurrentAC] = 1;
7209
7210 }
7211
Jeff Johnson295189b2012-06-20 16:38:30 -07007212 if (WLAN_STA_SOFTAP != pStaClient->wSTADesc.wSTAType)
7213 {
Jeff Johnson295189b2012-06-20 16:38:30 -07007214 if ( 0 == pStaClient->ucCurrentWeight )
7215 {
7216 WLANTL_ACEnumType tempAC = ucAC;
7217 /*-----------------------------------------------------------------------
7218 Choose next AC - !!! optimize me
7219 -----------------------------------------------------------------------*/
7220 while ( 0 != ucACMask )
7221 {
7222 ucNextAC = (WLANTL_ACEnumType)(( tempAC - 1 ) & WLANTL_MASK_AC);
7223 if ( 0 != pStaClient->aucACMask[ucNextAC] )
7224 {
7225 pStaClient->ucCurrentAC = ucNextAC;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307226 pStaClient->ucCurrentWeight = pTLCb->tlConfigInfo.ucAcWeights[ucNextAC];
Jeff Johnson295189b2012-06-20 16:38:30 -07007227
7228 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
7229 "WLAN TL: Changing serviced AC to: %d with Weight: %d",
7230 pStaClient->ucCurrentAC ,
7231 pStaClient->ucCurrentWeight));
7232 break;
7233 }
7234 tempAC = ucNextAC;
7235 }
7236 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007237 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007238
7239 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
7240 "WLAN TL:Attaching BD header to pkt on WLANTL_STATxAuth"));
7241
7242 /*------------------------------------------------------------------------
7243 Translate 802.3 frame to 802.11
7244 ------------------------------------------------------------------------*/
7245 if ( 0 == tlMetaInfo.ucDisableFrmXtl )
7246 {
7247 /* Needs frame translation */
7248 // if the client has not enabled SW-only frame translation
7249 // and if the frame is a unicast frame
7250 // (HW frame translation does not support multiple broadcast domains
7251 // so we use SW frame translation for broadcast/multicast frames)
7252#ifdef FEATURE_WLAN_WAPI
7253 // and if the frame is not a WAPI frame
7254#endif
7255 // then use HW_based frame translation
7256
7257 if ( ( 0 == pStaClient->wSTADesc.ucSwFrameTXXlation ) &&
7258 ( 0 == tlMetaInfo.ucBcast ) &&
7259 ( 0 == tlMetaInfo.ucMcast )
7260#ifdef FEATURE_WLAN_WAPI
7261 && ( tlMetaInfo.ucIsWai != 1 )
7262#endif
7263 )
7264 {
7265#ifdef WLAN_PERF
7266 v_U32_t uFastFwdOK = 0;
7267
7268 /* HW based translation. See if the frame could be fast forwarded */
7269 WDA_TLI_FastHwFwdDataFrame( pvosGCtx, vosDataBuff , &vosStatus,
7270 &uFastFwdOK, &tlMetaInfo, &pStaClient->wSTADesc);
7271
7272 if( VOS_STATUS_SUCCESS == vosStatus )
7273 {
7274 if(uFastFwdOK)
7275 {
7276 /* Packet could be fast forwarded now */
7277 vos_pkt_set_user_data_ptr( vosDataBuff, VOS_PKT_USER_DATA_ID_TL,
7278 (v_PVOID_t)pStaClient->pfnSTATxComp );
7279
7280 *pvosDataBuff = vosDataBuff;
7281
7282 /* TODO: Do we really need to update WLANTL_HSHandleTXFrame()
7283 stats for every pkt? */
7284 pStaClient->auTxCount[tlMetaInfo.ucTID]++;
7285 return vosStatus;
7286 }
7287 /* can't be fast forwarded, fall through normal (slow) path. */
7288 }
7289 else
7290 {
7291
7292 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7293 "WLAN TL:Failed while attempting to fastFwd BD %d", vosStatus));
7294 *pvosDataBuff = NULL;
7295 return vosStatus;
7296 }
7297#endif /*WLAN_PERF*/
7298 }
7299 else
7300 {
7301 /* SW based translation */
7302
7303#ifdef FEATURE_WLAN_WAPI
7304 gUcIsWai = tlMetaInfo.ucIsWai,
7305#endif
7306
Kiran Venkatappacab0d352012-12-17 13:09:22 -08007307 vosStatus = WLANTL_Translate8023To80211Header( vosDataBuff, &vosStatus,
7308 pTLCb, &ucSTAId,
Ravi Joshid0699502013-07-08 15:48:47 -07007309 &tlMetaInfo, &ucWDSEnabled,
7310 &extraHeadSpace);
Jeff Johnson295189b2012-06-20 16:38:30 -07007311 if ( VOS_STATUS_SUCCESS != vosStatus )
7312 {
7313 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7314 "WLAN TL:Error when translating header WLANTL_STATxAuth"));
7315 return vosStatus;
7316 }
7317
7318 TLLOG4(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_LOW,
Arif Hussainf2b00992013-11-17 21:46:15 -08007319 "WLAN TL software translation success"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007320 ucSwFrmXtl = 1;
7321 tlMetaInfo.ucDisableFrmXtl = 1;
7322 }
7323 }
Gopichand Nakkala574f6d12013-06-27 19:38:43 +05307324#ifdef FEATURE_WLAN_TDLS
7325 /*In case of TDLS, if the packet is destined to TDLS STA ucSTAId may
7326 change. so update the pStaClient accordingly */
7327 pStaClient = pTLCb->atlSTAClients[ucSTAId];
Jeff Johnson295189b2012-06-20 16:38:30 -07007328
Gopichand Nakkala574f6d12013-06-27 19:38:43 +05307329 if ( NULL == pStaClient )
7330 {
7331 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7332 "pStaClient is NULL %s", __func__));
7333 return VOS_STATUS_E_FAILURE;
7334 }
7335#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007336 /*-------------------------------------------------------------------------
7337 Call HAL to fill BD header
7338 -------------------------------------------------------------------------*/
7339 ucTypeSubtype |= (WLANTL_80211_DATA_TYPE << 4);
7340
7341 if ( pStaClient->wSTADesc.ucQosEnabled )
7342 {
7343 ucTypeSubtype |= (WLANTL_80211_DATA_QOS_SUBTYPE);
7344 }
7345
7346 ucTxFlag = (0 != pStaClient->wUAPSDInfo[ucAC].ucSet)?
7347 HAL_TRIGGER_ENABLED_AC_MASK:0;
7348
7349#ifdef FEATURE_WLAN_WAPI
7350 if ( pStaClient->wSTADesc.ucIsWapiSta == 1 )
7351 {
7352#ifdef LIBRA_WAPI_SUPPORT
7353 ucTxFlag = ucTxFlag | HAL_WAPI_STA_MASK;
7354#endif //LIBRA_WAPI_SUPPORT
7355 if ( tlMetaInfo.ucIsWai == 1 )
7356 {
7357 ucTxFlag = ucTxFlag | HAL_TX_NO_ENCRYPTION_MASK;
7358 }
7359 }
7360#endif /* FEATURE_WLAN_WAPI */
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007361#ifdef FEATURE_WLAN_TDLS
7362 if ( pStaClient->wSTADesc.wSTAType == WLAN_STA_TDLS )
7363 {
7364 ucTxFlag = ucTxFlag | HAL_TDLS_PEER_STA_MASK;
7365 }
7366#endif /* FEATURE_WLAN_TDLS */
Jeff Johnson295189b2012-06-20 16:38:30 -07007367
7368 vosStatus = (VOS_STATUS)WDA_DS_BuildTxPacketInfo( pvosGCtx,
7369 vosDataBuff , &vDestMacAddr,
7370 tlMetaInfo.ucDisableFrmXtl, &usPktLen,
7371 pStaClient->wSTADesc.ucQosEnabled, ucWDSEnabled,
7372 extraHeadSpace,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307373 ucTypeSubtype, &pStaClient->wSTADesc.vSelfMACAddress,
Jeff Johnson295189b2012-06-20 16:38:30 -07007374 ucTid, ucTxFlag, tlMetaInfo.usTimeStamp,
7375 tlMetaInfo.ucIsEapol, tlMetaInfo.ucUP );
7376
7377 if(!VOS_IS_STATUS_SUCCESS(vosStatus))
7378 {
7379 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7380 "Fill TX BD Error status %d", vosStatus));
7381
7382 return vosStatus;
7383 }
7384
Jeff Johnson295189b2012-06-20 16:38:30 -07007385 /* TX Statistics */
7386 if (!(tlMetaInfo.ucBcast || tlMetaInfo.ucMcast))
7387 {
7388 /* This is TX UC frame */
7389 pStaClient->trafficStatistics.txUCFcnt++;
7390 pStaClient->trafficStatistics.txUCBcnt += usPktLen;
7391 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007392
Kiran Venkatappacab0d352012-12-17 13:09:22 -08007393#ifndef FEATURE_WLAN_TDLS
Jeff Johnson295189b2012-06-20 16:38:30 -07007394 /*-----------------------------------------------------------------------
7395 Update tx counter for BA session query for tx side
7396 -----------------------------------------------------------------------*/
7397 pStaClient->auTxCount[ucTid]++;
Kiran Venkatappacab0d352012-12-17 13:09:22 -08007398#else
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307399 pTLCb->atlSTAClients[ucSTAId]->auTxCount[ucTid]++;
Kiran Venkatappacab0d352012-12-17 13:09:22 -08007400#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007401
7402 /* This code is to send traffic with lower priority AC when we does not
7403 get admitted to send it. Today HAL does not downgrade AC so this code
7404 does not get executed.(In other words, HAL doesnÂ’t change tid. The if
7405 statement is always false.)
7406 NOTE: In the case of LA downgrade occurs in HDD (that was the change
7407 Phani made during WMM-AC plugfest). If WM & BMP also took this approach,
7408 then there will be no need for any AC downgrade logic in TL/WDI. */
7409#if 0
7410 if (( ucTid != tlMetaInfo.ucTID ) &&
7411 ( 0 != pStaClient->wSTADesc.ucQosEnabled ) &&
7412 ( 0 != ucSwFrmXtl ))
7413 {
7414 /*---------------------------------------------------------------------
7415 !! FIX me: Once downgrading is clear put in the proper change
7416 ---------------------------------------------------------------------*/
7417 ucQCOffset = WLANHAL_TX_BD_HEADER_SIZE + WLANTL_802_11_HEADER_LEN;
7418
7419 //!!!Fix this replace peek with extract
7420 vos_pkt_peek_data( vosDataBuff, ucQCOffset,(v_PVOID_t)&pucQosCtrl,
7421 sizeof(*pucQosCtrl));
7422 *pucQosCtrl = ucTid; //? proper byte order
7423 }
7424#endif
7425
7426 if ( VOS_STATUS_SUCCESS != vosStatus )
7427 {
7428 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7429 "WLAN TL:Failed while attempting to fill BD %d", vosStatus));
7430 *pvosDataBuff = NULL;
7431 return vosStatus;
7432 }
7433
7434 vos_pkt_set_user_data_ptr( vosDataBuff, VOS_PKT_USER_DATA_ID_TL,
7435 (v_PVOID_t)pStaClient->pfnSTATxComp );
7436
7437 *pvosDataBuff = vosDataBuff;
7438
7439 /*BE & BK can be delayed, VO and VI not frames cannot be delayed*/
7440 if ( pStaClient->ucServicedAC > WLANTL_AC_BE )
7441 {
7442 pTLCb->bUrgent= TRUE;
7443 }
7444
7445 return VOS_STATUS_SUCCESS;
7446}/* WLANTL_STATxAuth */
7447
7448/*==========================================================================
7449 FUNCTION WLANTL_STATxDisc
7450
7451 DESCRIPTION
7452 Transmit in disconnected state - no data allowed
7453
7454 DEPENDENCIES
7455 The STA must be registered with TL before this function can be called.
7456
7457 PARAMETERS
7458
7459 IN
7460 pvosGCtx: pointer to the global vos context; a handle to TL's
7461 control block can be extracted from its context
7462 ucSTAId: identifier of the station being processed
7463 vosDataBuff: pointer to the tx vos buffer
7464
7465 RETURN VALUE
7466 The result code associated with performing the operation
7467
7468 VOS_STATUS_SUCCESS: Everything is good :)
7469
7470 SIDE EFFECTS
7471
7472============================================================================*/
7473VOS_STATUS
7474WLANTL_STATxDisc
7475(
7476 v_PVOID_t pvosGCtx,
7477 v_U8_t ucSTAId,
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07007478 vos_pkt_t** pvosDataBuff,
7479 v_BOOL_t bForwardIAPPwithLLC
Jeff Johnson295189b2012-06-20 16:38:30 -07007480)
7481{
7482 WLANTL_CbType* pTLCb = NULL;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307483 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07007484 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
7485
Jeff Johnson295189b2012-06-20 16:38:30 -07007486 /*------------------------------------------------------------------------
7487 Sanity check
7488 Extract TL control block
7489 ------------------------------------------------------------------------*/
7490 pTLCb = VOS_GET_TL_CB(pvosGCtx);
7491 if ( NULL == pTLCb )
7492 {
7493 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7494 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_STATxAuth"));
7495 *pvosDataBuff = NULL;
7496 return VOS_STATUS_E_FAULT;
7497 }
7498
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307499 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
7500
7501 if ( NULL == pClientSTA )
7502 {
7503 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7504 "WLAN TL:Client Memory was not allocated on %s", __func__));
7505 return VOS_STATUS_E_FAILURE;
7506 }
7507
Jeff Johnson295189b2012-06-20 16:38:30 -07007508 /*------------------------------------------------------------------------
7509 Error
7510 ------------------------------------------------------------------------*/
7511 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
7512 "WLAN TL:Packet should not be transmitted in state disconnected ignoring"
7513 " request"));
7514
7515 *pvosDataBuff = NULL;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307516 pClientSTA->ucNoMoreData = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07007517
7518 //Should not be anything pending in disconnect state
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307519 vos_atomic_set_U8( &pClientSTA->ucPktPending, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07007520
7521 return VOS_STATUS_SUCCESS;
7522}/* WLANTL_STATxDisc */
7523
7524/*==========================================================================
7525 FUNCTION WLANTL_STARxConn
7526
7527 DESCRIPTION
7528 Receive in connected state - only EAPOL
7529
7530 DEPENDENCIES
7531 The STA must be registered with TL before this function can be called.
7532
7533 PARAMETERS
7534
7535 IN
7536 pvosGCtx: pointer to the global vos context; a handle to TL's
7537 control block can be extracted from its context
7538 ucSTAId: identifier of the station being processed
7539 vosDataBuff: pointer to the tx/rx vos buffer
7540
7541 RETURN VALUE
7542 The result code associated with performing the operation
7543
7544 VOS_STATUS_E_INVAL: invalid input parameters
7545 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
7546 page fault
7547 VOS_STATUS_SUCCESS: Everything is good :)
7548
7549 SIDE EFFECTS
7550
7551============================================================================*/
7552VOS_STATUS
7553WLANTL_STARxConn
7554(
7555 v_PVOID_t pvosGCtx,
7556 v_U8_t ucSTAId,
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07007557 vos_pkt_t** pvosDataBuff,
7558 v_BOOL_t bForwardIAPPwithLLC
Jeff Johnson295189b2012-06-20 16:38:30 -07007559)
7560{
7561 WLANTL_CbType* pTLCb = NULL;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307562 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07007563 v_U16_t usEtherType = 0;
7564 v_U16_t usPktLen;
7565 v_U8_t ucMPDUHOffset;
7566 v_U16_t usMPDUDOffset;
7567 v_U16_t usMPDULen;
7568 v_U8_t ucMPDUHLen;
7569 v_U16_t usActualHLen = 0;
7570 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
7571 vos_pkt_t* vosDataBuff;
7572 v_PVOID_t aucBDHeader;
7573 v_U8_t ucTid;
7574 WLANTL_RxMetaInfoType wRxMetaInfo;
7575 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
7576
7577 /*------------------------------------------------------------------------
7578 Sanity check
7579 ------------------------------------------------------------------------*/
7580 if (( NULL == pvosDataBuff ) || ( NULL == ( vosDataBuff = *pvosDataBuff )))
7581 {
7582 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7583 "WLAN TL:Invalid parameter sent on WLANTL_STARxConn"));
7584 return VOS_STATUS_E_INVAL;
7585 }
7586
7587 /*------------------------------------------------------------------------
7588 Extract TL control block
7589 ------------------------------------------------------------------------*/
7590 pTLCb = VOS_GET_TL_CB(pvosGCtx);
7591 if ( NULL == pTLCb )
7592 {
7593 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7594 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_ChangeSTAState"));
7595 return VOS_STATUS_E_FAULT;
7596 }
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307597 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
7598
7599 if ( NULL == pClientSTA )
7600 {
7601 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7602 "WLAN TL:Client Memory was not allocated on %s", __func__));
7603 return VOS_STATUS_E_FAILURE;
7604 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007605
7606 /*------------------------------------------------------------------------
7607 Extract BD header and check if valid
7608 ------------------------------------------------------------------------*/
7609 vosStatus = WDA_DS_PeekRxPacketInfo( vosDataBuff, (v_PVOID_t)&aucBDHeader, 0/*Swap BD*/ );
7610
7611 if ( NULL == aucBDHeader )
7612 {
7613 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7614 "WLAN TL:Cannot extract BD header"));
7615 VOS_ASSERT( 0 );
7616 return VOS_STATUS_E_FAULT;
7617 }
7618
7619
7620 ucMPDUHOffset = (v_U8_t)WDA_GET_RX_MPDU_HEADER_OFFSET(aucBDHeader);
7621 usMPDUDOffset = (v_U16_t)WDA_GET_RX_MPDU_DATA_OFFSET(aucBDHeader);
7622 usMPDULen = (v_U16_t)WDA_GET_RX_MPDU_LEN(aucBDHeader);
7623 ucMPDUHLen = (v_U8_t)WDA_GET_RX_MPDU_HEADER_LEN(aucBDHeader);
7624 ucTid = (v_U8_t)WDA_GET_RX_TID(aucBDHeader);
7625
7626 vos_pkt_get_packet_length( vosDataBuff, &usPktLen);
7627
7628 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
7629 "WLAN TL:BD header processing data: HO %d DO %d Len %d HLen %d",
7630 ucMPDUHOffset, usMPDUDOffset, usMPDULen, ucMPDUHLen));
7631
7632 /*It will cut out the 802.11 header if not used*/
7633 if ( VOS_STATUS_SUCCESS != WDA_DS_TrimRxPacketInfo( vosDataBuff ) )
7634 {
7635 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
7636 "WLAN TL:BD header corrupted - dropping packet"));
7637 /* Drop packet */
7638 vos_pkt_return_packet(vosDataBuff);
7639 return VOS_STATUS_SUCCESS;
7640 }
7641
7642 vosStatus = WLANTL_GetEtherType(aucBDHeader,vosDataBuff,ucMPDUHLen,&usEtherType);
7643
7644 if( VOS_IS_STATUS_SUCCESS(vosStatus) )
7645 {
7646#ifdef FEATURE_WLAN_WAPI
7647 /* If frame is neither an EAPOL frame nor a WAI frame then we drop the frame*/
7648 /* TODO: Do we need a check to see if we are in WAPI mode? If not is it possible */
7649 /* that we get an EAPOL packet in WAPI mode or vice versa? */
7650 if ( WLANTL_LLC_8021X_TYPE != usEtherType && WLANTL_LLC_WAI_TYPE != usEtherType )
7651 {
Sunil Ravid5406f22013-01-22 00:18:31 -08007652 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07007653 "WLAN TL:RX Frame not EAPOL or WAI EtherType %d - dropping", usEtherType );
Jeff Johnson295189b2012-06-20 16:38:30 -07007654 /* Drop packet */
7655 vos_pkt_return_packet(vosDataBuff);
7656 }
7657#else
7658 if ( WLANTL_LLC_8021X_TYPE != usEtherType )
7659 {
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07007660 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7661 "WLAN TL:RX Frame not EAPOL EtherType %d - dropping", usEtherType);
Jeff Johnson295189b2012-06-20 16:38:30 -07007662 /* Drop packet */
7663 vos_pkt_return_packet(vosDataBuff);
7664 }
7665#endif /* FEATURE_WLAN_WAPI */
7666 else /* Frame is an EAPOL frame or a WAI frame*/
7667 {
Katya Nigam42e16e82014-02-04 16:28:55 +05307668 MTRACE(vos_trace(VOS_MODULE_ID_TL,
7669 TRACE_CODE_TL_RX_CONN_EAPOL, ucSTAId, usEtherType ));
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07007670
Madan Mohan Koyyalamudid8000342012-11-08 14:55:26 -08007671 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07007672 "WLAN TL:RX Frame EAPOL EtherType %d - processing", usEtherType);
7673
Jeff Johnson295189b2012-06-20 16:38:30 -07007674 if (( 0 == WDA_GET_RX_FT_DONE(aucBDHeader) ) &&
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307675 ( 0 != pClientSTA->wSTADesc.ucSwFrameRXXlation))
Jeff Johnson295189b2012-06-20 16:38:30 -07007676 {
7677 if (usMPDUDOffset > ucMPDUHOffset)
7678 {
7679 usActualHLen = usMPDUDOffset - ucMPDUHOffset;
7680 }
7681
7682 vosStatus = WLANTL_Translate80211To8023Header( vosDataBuff, &vosStatus, usActualHLen,
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07007683 ucMPDUHLen, pTLCb, ucSTAId, bForwardIAPPwithLLC);
Jeff Johnson295189b2012-06-20 16:38:30 -07007684
7685 if ( VOS_STATUS_SUCCESS != vosStatus )
7686 {
7687 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7688 "WLAN TL:Failed to translate from 802.11 to 802.3 - dropping"));
7689 /* Drop packet */
7690 vos_pkt_return_packet(vosDataBuff);
7691 return vosStatus;
7692 }
7693 }
7694 /*-------------------------------------------------------------------
7695 Increment receive counter
7696 -------------------------------------------------------------------*/
Madan Mohan Koyyalamudic0e5bd82012-09-18 17:12:27 -07007697 if ( !WLANTL_TID_INVALID( ucTid) )
7698 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307699 pClientSTA->auRxCount[ucTid]++;
Madan Mohan Koyyalamudic0e5bd82012-09-18 17:12:27 -07007700 }
7701 else
7702 {
7703 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7704 "WLAN TL:Invalid tid %d (Station ID %d) on %s",
7705 ucTid, ucSTAId, __func__));
7706 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007707
7708 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
7709 "WLAN TL:Sending EAPoL frame to station %d AC %d", ucSTAId, ucTid));
7710
7711 /*-------------------------------------------------------------------
7712 !!!Assuming TID = UP mapping
7713 -------------------------------------------------------------------*/
7714 wRxMetaInfo.ucUP = ucTid;
7715
Jeff Johnson295189b2012-06-20 16:38:30 -07007716 TLLOG4(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_LOW,
Arif Hussainf2b00992013-11-17 21:46:15 -08007717 "WLAN TL %s:Sending data chain to station", __func__));
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307718 if ( WLAN_STA_SOFTAP == pClientSTA->wSTADesc.wSTAType )
Jeff Johnson295189b2012-06-20 16:38:30 -07007719 {
7720 wRxMetaInfo.ucDesSTAId = WLAN_RX_SAP_SELF_STA_ID;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307721 pClientSTA->pfnSTARx( pvosGCtx, vosDataBuff, ucSTAId,
Jeff Johnson295189b2012-06-20 16:38:30 -07007722 &wRxMetaInfo );
7723 }
7724 else
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307725 pClientSTA->pfnSTARx( pvosGCtx, vosDataBuff, ucSTAId,
Jeff Johnson295189b2012-06-20 16:38:30 -07007726 &wRxMetaInfo );
7727 }/*EAPOL frame or WAI frame*/
7728 }/*vos status success*/
7729
7730 return VOS_STATUS_SUCCESS;
7731}/* WLANTL_STARxConn */
7732
Jeff Johnson295189b2012-06-20 16:38:30 -07007733/*==========================================================================
7734 FUNCTION WLANTL_FwdPktToHDD
7735
7736 DESCRIPTION
7737 Determine the Destation Station ID and route the Frame to Upper Layer
7738
7739 DEPENDENCIES
7740
7741 PARAMETERS
7742
7743 IN
7744 pvosGCtx: pointer to the global vos context; a handle to TL's
7745 control block can be extracted from its context
7746 ucSTAId: identifier of the station being processed
7747 vosDataBuff: pointer to the rx vos buffer
7748
7749 RETURN VALUE
7750 The result code associated with performing the operation
7751
7752 VOS_STATUS_E_INVAL: invalid input parameters
7753 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
7754 page fault
7755 VOS_STATUS_SUCCESS: Everything is good :)
7756
7757 SIDE EFFECTS
7758
7759============================================================================*/
7760
7761VOS_STATUS
7762WLANTL_FwdPktToHDD
7763(
7764 v_PVOID_t pvosGCtx,
7765 vos_pkt_t* pvosDataBuff,
7766 v_U8_t ucSTAId
7767)
7768{
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307769 v_MACADDR_t DestMacAddress;
7770 v_MACADDR_t *pDestMacAddress = &DestMacAddress;
7771 v_SIZE_t usMacAddSize = VOS_MAC_ADDR_SIZE;
Jeff Johnson295189b2012-06-20 16:38:30 -07007772 WLANTL_CbType* pTLCb = NULL;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307773 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07007774 vos_pkt_t* vosDataBuff ;
7775 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307776 v_U32_t STAMetaInfo;
7777 vos_pkt_t* vosNextDataBuff ;
7778 v_U8_t ucDesSTAId;
Jeff Johnson295189b2012-06-20 16:38:30 -07007779 WLANTL_RxMetaInfoType wRxMetaInfo;
7780
Jeff Johnson295189b2012-06-20 16:38:30 -07007781 /*------------------------------------------------------------------------
7782 Sanity check
7783 ------------------------------------------------------------------------*/
7784 if (( NULL == pvosDataBuff ) || ( NULL == ( vosDataBuff = pvosDataBuff )))
7785 {
7786 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7787 "WLAN TL:Invalid parameter sent on WLANTL_FwdPktToHdd"));
7788 return VOS_STATUS_E_INVAL;
7789 }
7790
7791 /*------------------------------------------------------------------------
7792 Extract TL control block
7793 ------------------------------------------------------------------------*/
7794 pTLCb = VOS_GET_TL_CB(pvosGCtx);
7795 if ( NULL == pTLCb )
7796 {
7797 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7798 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_FwdPktToHdd"));
7799 return VOS_STATUS_E_FAULT;
7800 }
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307801
Tushnim Bhattacharyya5dd94562013-03-20 20:15:03 -07007802 if(WLANTL_STA_ID_INVALID(ucSTAId))
7803 {
7804 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,"ucSTAId %d is not valid",
7805 ucSTAId));
7806 return VOS_STATUS_E_INVAL;
7807 }
7808
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307809 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
7810
7811 if ( NULL == pClientSTA )
7812 {
7813 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7814 "WLAN TL:Client Memory was not allocated on %s", __func__));
7815 return VOS_STATUS_E_FAILURE;
7816 }
7817
Jeff Johnson295189b2012-06-20 16:38:30 -07007818 /* This the change required for SoftAp to handle Reordered Buffer. Since a STA
7819 may have packets destined to multiple destinations we have to process each packet
7820 at a time and determine its Destination. So the Voschain provided by Reorder code
7821 is unchain and forwarded to Upper Layer after Determining the Destination */
7822
7823 vosDataBuff = pvosDataBuff;
7824 while (vosDataBuff != NULL)
7825 {
7826 vos_pkt_walk_packet_chain( vosDataBuff, &vosNextDataBuff, 1/*true*/ );
7827 vos_pkt_get_user_data_ptr( vosDataBuff, VOS_PKT_USER_DATA_ID_TL,
7828 (v_PVOID_t *)&STAMetaInfo );
7829 wRxMetaInfo.ucUP = (v_U8_t)(STAMetaInfo & WLANTL_AC_MASK);
Gopichand Nakkala976e3252013-01-03 15:45:56 -08007830 ucDesSTAId = (v_U8_t)((STAMetaInfo) >> WLANTL_STAID_OFFSET);
Jeff Johnson295189b2012-06-20 16:38:30 -07007831
7832 vosStatus = vos_pkt_extract_data( vosDataBuff, 0, (v_VOID_t *)pDestMacAddress, &usMacAddSize);
7833 if ( VOS_STATUS_SUCCESS != vosStatus )
7834 {
7835 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Arif Hussainf2b00992013-11-17 21:46:15 -08007836 "WLAN TL: recv corrupted data packet"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007837 vos_pkt_return_packet(vosDataBuff);
7838 return vosStatus;
7839 }
7840
Arif Hussaina7c8e412013-11-20 11:06:42 -08007841 TLLOG4(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_LOW,
7842 "station mac "MAC_ADDRESS_STR,
7843 MAC_ADDR_ARRAY(pDestMacAddress->bytes)));
Jeff Johnson295189b2012-06-20 16:38:30 -07007844
7845 if (vos_is_macaddr_broadcast( pDestMacAddress ) || vos_is_macaddr_group(pDestMacAddress))
7846 {
7847 // destination is mc/bc station
7848 ucDesSTAId = WLAN_RX_BCMC_STA_ID;
7849 TLLOG4(VOS_TRACE( VOS_MODULE_ID_HDD_SOFTAP, VOS_TRACE_LEVEL_INFO_LOW,
Arif Hussainf2b00992013-11-17 21:46:15 -08007850 "%s: BC/MC packet, id %d", __func__, WLAN_RX_BCMC_STA_ID));
Jeff Johnson295189b2012-06-20 16:38:30 -07007851 }
7852 else
7853 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307854 if (vos_is_macaddr_equal(pDestMacAddress, &pClientSTA->wSTADesc.vSelfMACAddress))
Jeff Johnson295189b2012-06-20 16:38:30 -07007855 {
7856 // destination is AP itself
7857 ucDesSTAId = WLAN_RX_SAP_SELF_STA_ID;
7858 TLLOG4(VOS_TRACE( VOS_MODULE_ID_HDD_SOFTAP, VOS_TRACE_LEVEL_INFO_LOW,
Arif Hussainf2b00992013-11-17 21:46:15 -08007859 "%s: packet to AP itself, id %d", __func__, WLAN_RX_SAP_SELF_STA_ID));
Jeff Johnson295189b2012-06-20 16:38:30 -07007860 }
Madan Mohan Koyylamudi64258222013-01-30 14:35:10 +05307861 else if (( WLAN_MAX_STA_COUNT <= ucDesSTAId ) || (NULL != pTLCb->atlSTAClients[ucDesSTAId] && pTLCb->atlSTAClients[ucDesSTAId]->ucExists == 0))
Jeff Johnson295189b2012-06-20 16:38:30 -07007862 {
7863 // destination station is something else
7864 TLLOG4(VOS_TRACE( VOS_MODULE_ID_HDD_SOFTAP, VOS_TRACE_LEVEL_INFO_LOW,
Arif Hussainf2b00992013-11-17 21:46:15 -08007865 "%s: get an station index larger than WLAN_MAX_STA_COUNT %d", __func__, ucDesSTAId));
Jeff Johnson295189b2012-06-20 16:38:30 -07007866 ucDesSTAId = WLAN_RX_SAP_SELF_STA_ID;
7867 }
7868
7869
7870 //loopback unicast station comes here
7871 }
7872
7873 wRxMetaInfo.ucUP = (v_U8_t)(STAMetaInfo & WLANTL_AC_MASK);
7874 wRxMetaInfo.ucDesSTAId = ucDesSTAId;
7875
Madan Mohan Koyyalamudi6c2977d2013-09-04 15:42:45 +05307876 vosStatus = pClientSTA->pfnSTARx( pvosGCtx, vosDataBuff, ucDesSTAId,
Jeff Johnson295189b2012-06-20 16:38:30 -07007877 &wRxMetaInfo );
Madan Mohan Koyyalamudi6c2977d2013-09-04 15:42:45 +05307878 if ( VOS_STATUS_SUCCESS != vosStatus )
7879 {
7880 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Arif Hussainf2b00992013-11-17 21:46:15 -08007881 "WLAN TL: failed to send pkt to HDD"));
Madan Mohan Koyyalamudi6c2977d2013-09-04 15:42:45 +05307882 vos_pkt_return_packet(vosDataBuff);
7883
7884 return vosStatus;
7885 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007886 vosDataBuff = vosNextDataBuff;
7887 }
7888 return VOS_STATUS_SUCCESS;
7889}
Jeff Johnson295189b2012-06-20 16:38:30 -07007890
7891/*==========================================================================
7892 FUNCTION WLANTL_STARxAuth
7893
7894 DESCRIPTION
7895 Receive in authenticated state - all data allowed
7896
7897 DEPENDENCIES
7898 The STA must be registered with TL before this function can be called.
7899
7900 PARAMETERS
7901
7902 IN
7903 pvosGCtx: pointer to the global vos context; a handle to TL's
7904 control block can be extracted from its context
7905 ucSTAId: identifier of the station being processed
7906 vosDataBuff: pointer to the rx vos buffer
7907
7908 RETURN VALUE
7909 The result code associated with performing the operation
7910
7911 VOS_STATUS_E_INVAL: invalid input parameters
7912 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
7913 page fault
7914 VOS_STATUS_SUCCESS: Everything is good :)
7915
7916 SIDE EFFECTS
7917
7918============================================================================*/
7919VOS_STATUS
7920WLANTL_STARxAuth
7921(
7922 v_PVOID_t pvosGCtx,
7923 v_U8_t ucSTAId,
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07007924 vos_pkt_t** pvosDataBuff,
7925 v_BOOL_t bForwardIAPPwithLLC
Jeff Johnson295189b2012-06-20 16:38:30 -07007926)
7927{
7928 WLANTL_CbType* pTLCb = NULL;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307929 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07007930 v_U8_t ucAsf; /* AMSDU sub frame */
7931 v_U16_t usMPDUDOffset;
7932 v_U8_t ucMPDUHOffset;
7933 v_U16_t usMPDULen;
7934 v_U8_t ucMPDUHLen;
7935 v_U16_t usActualHLen = 0;
7936 v_U8_t ucTid;
7937#ifdef FEATURE_WLAN_WAPI
Jeff Johnsone0343db2013-04-03 16:39:24 -07007938 v_U16_t usEtherType = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07007939#endif
7940 v_U16_t usPktLen;
7941 vos_pkt_t* vosDataBuff ;
7942 v_PVOID_t aucBDHeader;
7943 VOS_STATUS vosStatus;
7944 WLANTL_RxMetaInfoType wRxMetaInfo;
Madan Mohan Koyyalamudidfd6aa82012-10-18 20:18:43 -07007945 static v_U8_t ucPMPDUHLen;
Gopichand Nakkala976e3252013-01-03 15:45:56 -08007946 v_U32_t* STAMetaInfoPtr;
Jeff Johnson295189b2012-06-20 16:38:30 -07007947 v_U8_t ucEsf=0; /* first subframe of AMSDU flag */
7948 v_U64_t ullcurrentReplayCounter=0; /*current replay counter*/
7949 v_U64_t ullpreviousReplayCounter=0; /*previous replay counter*/
7950 v_U16_t ucUnicastBroadcastType=0; /*It denotes whether received frame is UC or BC*/
Madan Mohan Koyyalamudi4fe30172012-10-18 20:13:40 -07007951 struct _BARFrmStruct *pBarFrame = NULL;
7952
Jeff Johnson295189b2012-06-20 16:38:30 -07007953 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
7954
7955 /*------------------------------------------------------------------------
7956 Sanity check
7957 ------------------------------------------------------------------------*/
7958 if (( NULL == pvosDataBuff ) || ( NULL == ( vosDataBuff = *pvosDataBuff )))
7959 {
7960 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7961 "WLAN TL:Invalid parameter sent on WLANTL_STARxAuth"));
7962 return VOS_STATUS_E_INVAL;
7963 }
7964
7965 /*------------------------------------------------------------------------
7966 Extract TL control block
7967 ------------------------------------------------------------------------*/
7968 pTLCb = VOS_GET_TL_CB(pvosGCtx);
7969 if ( NULL == pTLCb )
7970 {
7971 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7972 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_STARxAuth"));
7973 return VOS_STATUS_E_FAULT;
7974 }
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307975 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
7976
7977 if ( NULL == pClientSTA )
7978 {
7979 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7980 "WLAN TL:Client Memory was not allocated on %s", __func__));
7981 return VOS_STATUS_E_FAILURE;
7982 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007983
7984 /*------------------------------------------------------------------------
7985 Extract BD header and check if valid
7986 ------------------------------------------------------------------------*/
7987 WDA_DS_PeekRxPacketInfo( vosDataBuff, (v_PVOID_t)&aucBDHeader, 0 );
7988
7989 ucMPDUHOffset = (v_U8_t)WDA_GET_RX_MPDU_HEADER_OFFSET(aucBDHeader);
7990 usMPDUDOffset = (v_U16_t)WDA_GET_RX_MPDU_DATA_OFFSET(aucBDHeader);
7991 usMPDULen = (v_U16_t)WDA_GET_RX_MPDU_LEN(aucBDHeader);
7992 ucMPDUHLen = (v_U8_t)WDA_GET_RX_MPDU_HEADER_LEN(aucBDHeader);
7993 ucTid = (v_U8_t)WDA_GET_RX_TID(aucBDHeader);
7994
Madan Mohan Koyyalamudi4fe30172012-10-18 20:13:40 -07007995 /* Fix for a hardware bug.
7996 * H/W does not update the tid field in BD header for BAR frames.
7997 * Fix is to read the tid field from MAC header of BAR frame */
7998 if( (WDA_GET_RX_TYPE(aucBDHeader) == SIR_MAC_CTRL_FRAME) &&
7999 (WDA_GET_RX_SUBTYPE(aucBDHeader) == SIR_MAC_CTRL_BAR))
8000 {
8001 pBarFrame = (struct _BARFrmStruct *)(WDA_GET_RX_MAC_HEADER(aucBDHeader));
8002 ucTid = pBarFrame->barControl.numTID;
8003 }
8004
Jeff Johnson295189b2012-06-20 16:38:30 -07008005 /*Host based replay check is needed for unicast data frames*/
8006 ucUnicastBroadcastType = (v_U16_t)WDA_IS_RX_BCAST(aucBDHeader);
Jeff Johnson295189b2012-06-20 16:38:30 -07008007 if(0 != ucMPDUHLen)
8008 {
8009 ucPMPDUHLen = ucMPDUHLen;
8010 }
8011
8012 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
8013 "WLAN TL:BD header processing data: HO %d DO %d Len %d HLen %d"
8014 " Tid %d BD %d",
8015 ucMPDUHOffset, usMPDUDOffset, usMPDULen, ucMPDUHLen, ucTid,
8016 WLANHAL_RX_BD_HEADER_SIZE));
8017
8018 vos_pkt_get_packet_length( vosDataBuff, &usPktLen);
8019
8020 if ( VOS_STATUS_SUCCESS != WDA_DS_TrimRxPacketInfo( vosDataBuff ) )
8021 {
8022 if((WDA_GET_RX_ASF(aucBDHeader) && !WDA_GET_RX_ESF(aucBDHeader)))
8023 {
8024 /* AMSDU case, ucMPDUHOffset = 0
8025 * it should be hancdled seperatly */
8026 if(( usMPDUDOffset > ucMPDUHOffset ) &&
8027 ( usMPDULen >= ucMPDUHLen ) && ( usPktLen >= usMPDULen ) &&
8028 ( !WLANTL_TID_INVALID(ucTid) ))
8029 {
8030 ucMPDUHOffset = usMPDUDOffset - WLANTL_MPDU_HEADER_LEN;
8031 }
8032 else
8033 {
8034 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
8035 "WLAN TL:BD header corrupted - dropping packet"));
8036 /* Drop packet */
8037 vos_pkt_return_packet(vosDataBuff);
8038 return VOS_STATUS_SUCCESS;
8039 }
8040 }
8041 else
8042 {
8043 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
8044 "WLAN TL:BD header corrupted - dropping packet"));
8045 /* Drop packet */
8046 vos_pkt_return_packet(vosDataBuff);
8047 return VOS_STATUS_SUCCESS;
8048 }
8049 }
8050
8051#ifdef FEATURE_WLAN_WAPI
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308052 if ( pClientSTA->wSTADesc.ucIsWapiSta )
Jeff Johnson295189b2012-06-20 16:38:30 -07008053 {
8054 vosStatus = WLANTL_GetEtherType(aucBDHeader, vosDataBuff, ucMPDUHLen, &usEtherType);
8055 if( VOS_IS_STATUS_SUCCESS(vosStatus) )
8056 {
8057 if ( WLANTL_LLC_WAI_TYPE == usEtherType )
8058 {
8059 if ( !( WLANHAL_RX_IS_UNPROTECTED_WPI_FRAME(aucBDHeader)) )
8060 {
8061 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8062 "WLAN TL:WAI frame was received encrypted - dropping"));
8063 /* Drop packet */
8064 /*Temporary fix added to fix wapi rekey issue*/
8065 //vos_pkt_return_packet(vosDataBuff);
8066 //return vosStatus; //returning success
8067 }
8068 }
8069 else
8070 {
8071 if ( WLANHAL_RX_IS_UNPROTECTED_WPI_FRAME(aucBDHeader) )
8072 {
8073 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8074 "WLAN TL:Non-WAI frame was received unencrypted - dropping"));
8075 /* Drop packet */
8076 vos_pkt_return_packet(vosDataBuff);
8077 return vosStatus; //returning success
8078 }
8079 }
8080 }
8081 else //could not extract EtherType - this should not happen
8082 {
8083 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008084 "WLAN TL:Could not extract EtherType"));
8085 //Packet is already freed
Jeff Johnson295189b2012-06-20 16:38:30 -07008086 return vosStatus; //returning failure
Jeff Johnson295189b2012-06-20 16:38:30 -07008087 }
8088 }
8089#endif /* FEATURE_WLAN_WAPI */
8090
8091 /*----------------------------------------------------------------------
8092 Increment receive counter
8093 !! not sure this is the best place to increase this - pkt might be
8094 dropped below or delayed in TL's queues
8095 - will leave it here for now
8096 ------------------------------------------------------------------------*/
Madan Mohan Koyyalamudic0e5bd82012-09-18 17:12:27 -07008097 if ( !WLANTL_TID_INVALID( ucTid) )
8098 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308099 pClientSTA->auRxCount[ucTid]++;
Madan Mohan Koyyalamudic0e5bd82012-09-18 17:12:27 -07008100 }
8101 else
8102 {
8103 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8104 "WLAN TL:Invalid tid %d (Station ID %d) on %s",
8105 ucTid, ucSTAId, __func__));
8106 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008107
8108 /*------------------------------------------------------------------------
8109 Check if AMSDU and send for processing if so
8110 ------------------------------------------------------------------------*/
8111 ucAsf = (v_U8_t)WDA_GET_RX_ASF(aucBDHeader);
8112
8113 if ( 0 != ucAsf )
8114 {
8115 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
8116 "WLAN TL:Packet is AMSDU sub frame - sending for completion"));
8117 vosStatus = WLANTL_AMSDUProcess( pvosGCtx, &vosDataBuff, aucBDHeader, ucSTAId,
8118 ucMPDUHLen, usMPDULen );
8119 if(NULL == vosDataBuff)
8120 {
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008121 //Packet is already freed
Jeff Johnson295189b2012-06-20 16:38:30 -07008122 return VOS_STATUS_SUCCESS;
8123 }
8124 }
8125 /* After AMSDU header handled
8126 * AMSDU frame just same with normal frames */
8127 /*-------------------------------------------------------------------
8128 Translating header if necesary
8129 !! Fix me: rmv comments below
8130 ----------------------------------------------------------------------*/
8131 if (( 0 == WDA_GET_RX_FT_DONE(aucBDHeader) ) &&
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308132 ( 0 != pClientSTA->wSTADesc.ucSwFrameRXXlation) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07008133 ( WLANTL_IS_DATA_FRAME(WDA_GET_RX_TYPE_SUBTYPE(aucBDHeader)) ))
8134 {
8135 if(0 == ucMPDUHLen)
8136 {
8137 ucMPDUHLen = ucPMPDUHLen;
8138 }
8139 if (usMPDUDOffset > ucMPDUHOffset)
8140 {
8141 usActualHLen = usMPDUDOffset - ucMPDUHOffset;
8142 }
8143 vosStatus = WLANTL_Translate80211To8023Header( vosDataBuff, &vosStatus, usActualHLen,
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07008144 ucMPDUHLen, pTLCb, ucSTAId, bForwardIAPPwithLLC);
Jeff Johnson295189b2012-06-20 16:38:30 -07008145
8146 if ( VOS_STATUS_SUCCESS != vosStatus )
8147 {
8148 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8149 "WLAN TL:Failed to translate from 802.11 to 802.3 - dropping"));
8150 /* Drop packet */
8151 vos_pkt_return_packet(vosDataBuff);
8152 return vosStatus;
8153 }
8154 }
8155 /* Softap requires additional Info such as Destination STAID and Access
8156 Category. Voschain or Buffer returned by BA would be unchain and this
8157 Meta Data would help in routing the packets to appropriate Destination */
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308158 if( WLAN_STA_SOFTAP == pClientSTA->wSTADesc.wSTAType)
Jeff Johnson295189b2012-06-20 16:38:30 -07008159 {
Arun Kumar Khandavalli37cfc222014-01-09 22:32:40 +05308160 STAMetaInfoPtr = (v_U32_t *)(uintptr_t)(ucTid | (WDA_GET_RX_ADDR3_IDX(aucBDHeader) << WLANTL_STAID_OFFSET));
Jeff Johnson295189b2012-06-20 16:38:30 -07008161 vos_pkt_set_user_data_ptr( vosDataBuff, VOS_PKT_USER_DATA_ID_TL,
8162 (v_PVOID_t)STAMetaInfoPtr);
8163 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008164
8165 /*------------------------------------------------------------------------
8166 Check to see if re-ordering session is in place
8167 ------------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308168 if ( 0 != pClientSTA->atlBAReorderInfo[ucTid].ucExists )
Jeff Johnson295189b2012-06-20 16:38:30 -07008169 {
8170 WLANTL_MSDUReorder( pTLCb, &vosDataBuff, aucBDHeader, ucSTAId, ucTid );
8171 }
8172
Jeff Johnson295189b2012-06-20 16:38:30 -07008173if(0 == ucUnicastBroadcastType
8174#ifdef FEATURE_ON_CHIP_REORDERING
8175 && (WLANHAL_IsOnChipReorderingEnabledForTID(pvosGCtx, ucSTAId, ucTid) != TRUE)
8176#endif
8177)
8178{
8179 /* replay check code : check whether replay check is needed or not */
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308180 if(VOS_TRUE == pClientSTA->ucIsReplayCheckValid)
Jeff Johnson295189b2012-06-20 16:38:30 -07008181 {
8182 /* replay check is needed for the station */
8183
8184 /* check whether frame is AMSDU frame */
8185 if ( 0 != ucAsf )
8186 {
8187 /* Since virgo can't send AMSDU frames this leg of the code
8188 was not tested properly, it needs to be tested properly*/
8189 /* Frame is AMSDU frame. As per 802.11n only first
8190 subframe will have replay counter */
8191 ucEsf = WDA_GET_RX_ESF( aucBDHeader );
8192 if( 0 != ucEsf )
8193 {
8194 v_BOOL_t status;
8195 /* Getting 48-bit replay counter from the RX BD */
8196 ullcurrentReplayCounter = WDA_DS_GetReplayCounter(aucBDHeader);
8197
8198 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Arif Hussainf2b00992013-11-17 21:46:15 -08008199 "WLAN TL: AMSDU currentReplayCounter [0x%llX]",ullcurrentReplayCounter);
Jeff Johnson295189b2012-06-20 16:38:30 -07008200
8201 /* Getting 48-bit previous replay counter from TL control block */
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308202 ullpreviousReplayCounter = pClientSTA->ullReplayCounter[ucTid];
Jeff Johnson295189b2012-06-20 16:38:30 -07008203
8204 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Arif Hussainf2b00992013-11-17 21:46:15 -08008205 "WLAN TL: AMSDU previousReplayCounter [0x%llX]",ullpreviousReplayCounter);
Jeff Johnson295189b2012-06-20 16:38:30 -07008206
8207 /* It is first subframe of AMSDU thus it
8208 conatains replay counter perform the
8209 replay check for this first subframe*/
8210 status = WLANTL_IsReplayPacket( ullcurrentReplayCounter, ullpreviousReplayCounter);
8211 if(VOS_FALSE == status)
8212 {
8213 /* Not a replay paket, update previous replay counter in TL CB */
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308214 pClientSTA->ullReplayCounter[ucTid] = ullcurrentReplayCounter;
Jeff Johnson295189b2012-06-20 16:38:30 -07008215 }
8216 else
8217 {
8218 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Arif Hussainf2b00992013-11-17 21:46:15 -08008219 "WLAN TL: AMSDU Drop the replay packet with PN : [0x%llX]",ullcurrentReplayCounter);
Jeff Johnson295189b2012-06-20 16:38:30 -07008220
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308221 pClientSTA->ulTotalReplayPacketsDetected++;
Jeff Johnson295189b2012-06-20 16:38:30 -07008222 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Arif Hussainf2b00992013-11-17 21:46:15 -08008223 "WLAN TL: AMSDU total dropped replay packets on STA ID %X is [0x%X]",
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308224 ucSTAId, pClientSTA->ulTotalReplayPacketsDetected);
Jeff Johnson295189b2012-06-20 16:38:30 -07008225
8226 /* Drop the packet */
8227 vos_pkt_return_packet(vosDataBuff);
8228 return VOS_STATUS_SUCCESS;
8229 }
8230 }
8231 }
8232 else
8233 {
8234 v_BOOL_t status;
8235
8236 /* Getting 48-bit replay counter from the RX BD */
8237 ullcurrentReplayCounter = WDA_DS_GetReplayCounter(aucBDHeader);
8238
8239 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Arif Hussainf2b00992013-11-17 21:46:15 -08008240 "WLAN TL: Non-AMSDU currentReplayCounter [0x%llX]",ullcurrentReplayCounter);
Jeff Johnson295189b2012-06-20 16:38:30 -07008241
8242 /* Getting 48-bit previous replay counter from TL control block */
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308243 ullpreviousReplayCounter = pClientSTA->ullReplayCounter[ucTid];
Jeff Johnson295189b2012-06-20 16:38:30 -07008244
8245 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Arif Hussainf2b00992013-11-17 21:46:15 -08008246 "WLAN TL: Non-AMSDU previousReplayCounter [0x%llX]",ullpreviousReplayCounter);
Jeff Johnson295189b2012-06-20 16:38:30 -07008247
8248 /* It is not AMSDU frame so perform
8249 reaply check for each packet, as
8250 each packet contains valid replay counter*/
8251 status = WLANTL_IsReplayPacket( ullcurrentReplayCounter, ullpreviousReplayCounter);
8252 if(VOS_FALSE == status)
8253 {
8254 /* Not a replay paket, update previous replay counter in TL CB */
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308255 pClientSTA->ullReplayCounter[ucTid] = ullcurrentReplayCounter;
Jeff Johnson295189b2012-06-20 16:38:30 -07008256 }
8257 else
8258 {
8259 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Arif Hussainf2b00992013-11-17 21:46:15 -08008260 "WLAN TL: Non-AMSDU Drop the replay packet with PN : [0x%llX]",ullcurrentReplayCounter);
Jeff Johnson295189b2012-06-20 16:38:30 -07008261
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308262 pClientSTA->ulTotalReplayPacketsDetected++;
Jeff Johnson295189b2012-06-20 16:38:30 -07008263 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Arif Hussainf2b00992013-11-17 21:46:15 -08008264 "WLAN TL: Non-AMSDU total dropped replay packets on STA ID %X is [0x%X]",
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308265 ucSTAId, pClientSTA->ulTotalReplayPacketsDetected);
Jeff Johnson295189b2012-06-20 16:38:30 -07008266
8267 /* Repaly packet, drop the packet */
8268 vos_pkt_return_packet(vosDataBuff);
8269 return VOS_STATUS_SUCCESS;
8270 }
8271 }
8272 }
8273}
8274/*It is a broadast packet DPU has already done replay check for
8275 broadcast packets no need to do replay check of these packets*/
Jeff Johnson295189b2012-06-20 16:38:30 -07008276
8277 if ( NULL != vosDataBuff )
8278 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308279 if( WLAN_STA_SOFTAP == pClientSTA->wSTADesc.wSTAType)
Jeff Johnson295189b2012-06-20 16:38:30 -07008280 {
8281 WLANTL_FwdPktToHDD( pvosGCtx, vosDataBuff, ucSTAId );
8282 }
8283 else
Jeff Johnson295189b2012-06-20 16:38:30 -07008284 {
8285 wRxMetaInfo.ucUP = ucTid;
Shailender Karmuchi13c0d082013-03-26 14:41:39 -07008286 wRxMetaInfo.rssiAvg = pClientSTA->rssiAvg;
Gopichand Nakkala4a2fc1a2013-05-17 16:59:39 +05308287#ifdef FEATURE_WLAN_TDLS
8288 if (WLAN_STA_TDLS == pClientSTA->wSTADesc.wSTAType)
8289 {
8290 wRxMetaInfo.isStaTdls = TRUE;
8291 }
8292 else
8293 {
8294 wRxMetaInfo.isStaTdls = FALSE;
8295 }
8296#endif
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308297 pClientSTA->pfnSTARx( pvosGCtx, vosDataBuff, ucSTAId,
Jeff Johnson295189b2012-06-20 16:38:30 -07008298 &wRxMetaInfo );
8299 }
8300 }/* if not NULL */
8301
8302 return VOS_STATUS_SUCCESS;
8303}/* WLANTL_STARxAuth */
8304
8305
8306/*==========================================================================
8307 FUNCTION WLANTL_STARxDisc
8308
8309 DESCRIPTION
8310 Receive in disconnected state - no data allowed
8311
8312 DEPENDENCIES
8313 The STA must be registered with TL before this function can be called.
8314
8315 PARAMETERS
8316
8317 IN
8318 pvosGCtx: pointer to the global vos context; a handle to TL's
8319 control block can be extracted from its context
8320 ucSTAId: identifier of the station being processed
8321 vosDataBuff: pointer to the rx vos buffer
8322
8323 RETURN VALUE
8324 The result code associated with performing the operation
8325
8326 VOS_STATUS_SUCCESS: Everything is good :)
8327
8328 SIDE EFFECTS
8329
8330============================================================================*/
8331VOS_STATUS
8332WLANTL_STARxDisc
8333(
8334 v_PVOID_t pvosGCtx,
8335 v_U8_t ucSTAId,
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07008336 vos_pkt_t** pvosDataBuff,
8337 v_BOOL_t bForwardIAPPwithLLC
Jeff Johnson295189b2012-06-20 16:38:30 -07008338)
8339{
8340 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
8341
8342 /*------------------------------------------------------------------------
8343 Sanity check
8344 ------------------------------------------------------------------------*/
8345 if (( NULL == pvosDataBuff ) || ( NULL == *pvosDataBuff ))
8346 {
8347 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8348 "WLAN TL:Invalid parameter sent on WLANTL_STARxDisc"));
8349 return VOS_STATUS_E_INVAL;
8350 }
8351
8352 /*------------------------------------------------------------------------
8353 Error - drop packet
8354 ------------------------------------------------------------------------*/
8355 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8356 "WLAN TL:Packet should not be received in state disconnected"
8357 " - dropping"));
8358 vos_pkt_return_packet(*pvosDataBuff);
8359 *pvosDataBuff = NULL;
8360
8361 return VOS_STATUS_SUCCESS;
8362}/* WLANTL_STARxDisc */
8363
8364/*==========================================================================
8365 Processing main loops for MAIN and TX threads
8366 ==========================================================================*/
8367
8368/*==========================================================================
8369 FUNCTION WLANTL_McProcessMsg
8370
8371 DESCRIPTION
8372 Called by VOSS when a message was serialized for TL through the
8373 main thread/task.
8374
8375 DEPENDENCIES
8376 The TL must be initialized before this function can be called.
8377
8378 PARAMETERS
8379
8380 IN
8381 pvosGCtx: pointer to the global vos context; a handle to TL's
8382 control block can be extracted from its context
8383 message: type and content of the message
8384
8385
8386 RETURN VALUE
8387 The result code associated with performing the operation
8388
8389 VOS_STATUS_E_INVAL: invalid input parameters
8390 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
8391 page fault
8392 VOS_STATUS_SUCCESS: Everything is good :)
8393
8394 SIDE EFFECTS
8395
8396============================================================================*/
8397VOS_STATUS
8398WLANTL_McProcessMsg
8399(
8400 v_PVOID_t pvosGCtx,
8401 vos_msg_t* message
8402)
8403{
8404 WLANTL_CbType* pTLCb = NULL;
8405 tAddBAInd* ptAddBaInd = NULL;
8406 tDelBAInd* ptDelBaInd = NULL;
8407 tAddBARsp* ptAddBaRsp = NULL;
8408 vos_msg_t vosMessage;
8409 VOS_STATUS vosStatus;
8410 tpFlushACRsp FlushACRspPtr;
8411 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
8412
8413 /*------------------------------------------------------------------------
8414 Sanity check
8415 ------------------------------------------------------------------------*/
8416 if ( NULL == message )
8417 {
8418 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8419 "WLAN TL:Invalid parameter sent on WLANTL_ProcessMainMessage"));
8420 return VOS_STATUS_E_INVAL;
8421 }
8422
8423 /*------------------------------------------------------------------------
8424 Extract TL control block
8425 ------------------------------------------------------------------------*/
8426 pTLCb = VOS_GET_TL_CB(pvosGCtx);
8427 if ( NULL == pTLCb )
8428 {
8429 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8430 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_ProcessMainMessage"));
8431 return VOS_STATUS_E_FAULT;
8432 }
8433
8434 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
8435 "WLAN TL:Received message: %d through main flow", message->type));
8436
8437 switch( message->type )
8438 {
8439 case WDA_TL_FLUSH_AC_RSP:
8440 // Extract the message from the message body
8441 FlushACRspPtr = (tpFlushACRsp)(message->bodyptr);
8442 // Make sure the call back function is not null.
Tushnim Bhattacharyya5dd94562013-03-20 20:15:03 -07008443 if ( NULL == pTLCb->tlBAPClient.pfnFlushOpCompleteCb )
8444 {
8445 VOS_ASSERT(0);
8446 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8447 "WLAN TL:Invalid TL pointer pfnFlushOpCompleteCb"));
8448 return VOS_STATUS_E_FAULT;
8449 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008450
8451 TLLOG2(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
8452 "Received message: Flush complete received by TL"));
8453
8454 // Since we have the response back from HAL, just call the BAP client
8455 // registered call back from TL. There is only 1 possible
8456 // BAP client. So directly reference tlBAPClient
8457 pTLCb->tlBAPClient.pfnFlushOpCompleteCb( pvosGCtx,
8458 FlushACRspPtr->ucSTAId,
8459 FlushACRspPtr->ucTid, FlushACRspPtr->status );
8460
8461 // Free the PAL memory, we are done with it.
8462 TLLOG2(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
8463 "Flush complete received by TL: Freeing %p", FlushACRspPtr));
8464 vos_mem_free((v_VOID_t *)FlushACRspPtr);
8465 break;
8466
8467 case WDA_HDD_ADDBA_REQ:
8468 ptAddBaInd = (tAddBAInd*)(message->bodyptr);
8469 vosStatus = WLANTL_BaSessionAdd( pvosGCtx,
8470 ptAddBaInd->baSession.baSessionID,
8471 ptAddBaInd->baSession.STAID,
8472 ptAddBaInd->baSession.baTID,
8473 (v_U32_t)ptAddBaInd->baSession.baBufferSize,
8474 ptAddBaInd->baSession.winSize,
8475 ptAddBaInd->baSession.SSN);
8476 ptAddBaRsp = vos_mem_malloc(sizeof(*ptAddBaRsp));
8477
8478 if ( NULL == ptAddBaRsp )
8479 {
8480 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8481 "WLAN TL: fatal failure, cannot allocate BA Rsp structure"));
8482 VOS_ASSERT(0);
8483 return VOS_STATUS_E_NOMEM;
8484 }
8485
8486 if ( VOS_STATUS_SUCCESS == vosStatus )
8487 {
8488 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
8489 "WLAN TL: Sending success indication to HAL for ADD BA"));
8490 /*Send success*/
8491 ptAddBaRsp->mesgType = WDA_HDD_ADDBA_RSP;
8492 vosMessage.type = WDA_HDD_ADDBA_RSP;
8493 }
8494 else
8495 {
8496 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
8497 "WLAN TL: Sending failure indication to HAL for ADD BA"));
8498
8499 /*Send failure*/
8500 ptAddBaRsp->mesgType = WDA_BA_FAIL_IND;
8501 vosMessage.type = WDA_BA_FAIL_IND;
8502 }
8503
8504 ptAddBaRsp->mesgLen = sizeof(tAddBARsp);
8505 ptAddBaRsp->baSessionID = ptAddBaInd->baSession.baSessionID;
8506 /* This is default, reply win size has to be handled BA module, FIX THIS */
8507 ptAddBaRsp->replyWinSize = WLANTL_MAX_WINSIZE;
8508 vosMessage.bodyptr = ptAddBaRsp;
8509
8510 vos_mq_post_message( VOS_MQ_ID_WDA, &vosMessage );
8511 WLANTL_McFreeMsg (pvosGCtx, message);
8512 break;
8513 case WDA_DELETEBA_IND:
8514 ptDelBaInd = (tDelBAInd*)(message->bodyptr);
8515 vosStatus = WLANTL_BaSessionDel(pvosGCtx,
8516 ptDelBaInd->staIdx,
8517 ptDelBaInd->baTID);
8518
8519 if ( VOS_STATUS_SUCCESS != vosStatus )
8520 {
8521 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8522 "WLAN TL: Failed to del BA session STA:%d TID:%d Status :%d",
8523 ptDelBaInd->staIdx,
8524 ptDelBaInd->baTID,
8525 vosStatus));
8526 }
8527 WLANTL_McFreeMsg (pvosGCtx, message);
8528 break;
8529 default:
8530 /*no processing for now*/
8531 break;
8532 }
8533
8534 return VOS_STATUS_SUCCESS;
8535}/* WLANTL_ProcessMainMessage */
8536
8537/*==========================================================================
8538 FUNCTION WLANTL_McFreeMsg
8539
8540 DESCRIPTION
8541 Called by VOSS to free a given TL message on the Main thread when there
8542 are messages pending in the queue when the whole system is been reset.
8543 For now, TL does not allocate any body so this function shout translate
8544 into a NOOP
8545
8546 DEPENDENCIES
8547 The TL must be initialized before this function can be called.
8548
8549 PARAMETERS
8550
8551 IN
8552 pvosGCtx: pointer to the global vos context; a handle to TL's
8553 control block can be extracted from its context
8554 message: type and content of the message
8555
8556
8557 RETURN VALUE
8558 The result code associated with performing the operation
8559
8560 VOS_STATUS_SUCCESS: Everything is good :)
8561
8562 SIDE EFFECTS
8563
8564============================================================================*/
8565VOS_STATUS
8566WLANTL_McFreeMsg
8567(
8568 v_PVOID_t pvosGCtx,
8569 vos_msg_t* message
8570)
8571{
8572 WLANTL_CbType* pTLCb = NULL;
8573 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
8574
8575 /*------------------------------------------------------------------------
8576 Sanity check
8577 ------------------------------------------------------------------------*/
8578 if ( NULL == message )
8579 {
8580 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8581 "WLAN TL:Invalid parameter sent on WLANTL_McFreeMsg"));
8582 return VOS_STATUS_E_INVAL;
8583 }
8584
8585 /*------------------------------------------------------------------------
8586 Extract TL control block
8587 ------------------------------------------------------------------------*/
8588 pTLCb = VOS_GET_TL_CB(pvosGCtx);
8589 if ( NULL == pTLCb )
8590 {
8591 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8592 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_McFreeMsg"));
8593 return VOS_STATUS_E_FAULT;
8594 }
8595
8596 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
8597 "WLAN TL:Received message: %d through main free", message->type));
8598
8599 switch( message->type )
8600 {
8601 case WDA_HDD_ADDBA_REQ:
8602 case WDA_DELETEBA_IND:
8603 /*vos free body pointer*/
8604 vos_mem_free(message->bodyptr);
8605 message->bodyptr = NULL;
8606 break;
8607 default:
8608 /*no processing for now*/
8609 break;
8610 }
8611
8612 return VOS_STATUS_SUCCESS;
8613}/*WLANTL_McFreeMsg*/
8614
8615/*==========================================================================
8616 FUNCTION WLANTL_TxProcessMsg
8617
8618 DESCRIPTION
8619 Called by VOSS when a message was serialized for TL through the
8620 tx thread/task.
8621
8622 DEPENDENCIES
8623 The TL must be initialized before this function can be called.
8624
8625 PARAMETERS
8626
8627 IN
8628 pvosGCtx: pointer to the global vos context; a handle to TL's
8629 control block can be extracted from its context
8630 message: type and content of the message
8631
8632
8633 RETURN VALUE
8634 The result code associated with performing the operation
8635
8636 VOS_STATUS_E_INVAL: invalid input parameters
8637 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
8638 page fault
8639 VOS_STATUS_SUCCESS: Everything is good :)
8640
8641 Other values can be returned as a result of a function call, please check
8642 corresponding API for more info.
8643 SIDE EFFECTS
8644
8645============================================================================*/
8646VOS_STATUS
8647WLANTL_TxProcessMsg
8648(
8649 v_PVOID_t pvosGCtx,
8650 vos_msg_t* message
8651)
8652{
8653 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
8654 v_U32_t uData;
8655 v_U8_t ucSTAId;
8656 v_U8_t ucUcastSig;
8657 v_U8_t ucBcastSig;
Jeff Johnson295189b2012-06-20 16:38:30 -07008658 void (*callbackRoutine) (void *callbackContext);
8659 void *callbackContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07008660 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
8661
8662 /*------------------------------------------------------------------------
8663 Sanity check
8664 ------------------------------------------------------------------------*/
8665 if ( NULL == message )
8666 {
8667 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8668 "WLAN TL:Invalid parameter sent on WLANTL_ProcessTxMessage"));
8669 return VOS_STATUS_E_INVAL;
8670 }
8671
8672 /*------------------------------------------------------------------------
8673 Process message
8674 ------------------------------------------------------------------------*/
8675 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
8676 "WLAN TL:Received message: %d through tx flow", message->type));
8677
8678 switch( message->type )
8679 {
8680 case WLANTL_TX_SIG_SUSPEND:
8681 vosStatus = WLANTL_SuspendCB( pvosGCtx,
8682 (WLANTL_SuspendCBType)message->bodyptr,
8683 message->reserved);
8684 break;
8685 case WLANTL_TX_RES_NEEDED:
8686 vosStatus = WLANTL_GetTxResourcesCB( pvosGCtx );
8687 break;
8688
8689 case WLANTL_TX_FWD_CACHED:
8690 /*---------------------------------------------------------------------
8691 The data sent with the message has the following structure:
8692 | 00 | ucBcastSignature | ucUcastSignature | ucSTAID |
8693 each field above is one byte
8694 ---------------------------------------------------------------------*/
Jeff Johnsond86c05a2013-11-10 18:50:34 -08008695 uData = message->bodyval;
Jeff Johnson295189b2012-06-20 16:38:30 -07008696 ucSTAId = ( uData & 0x000000FF);
8697 ucUcastSig = ( uData & 0x0000FF00)>>8;
8698 ucBcastSig = (v_U8_t)(( uData & 0x00FF0000)>>16);
8699 vosStatus = WLANTL_ForwardSTAFrames( pvosGCtx, ucSTAId,
8700 ucUcastSig, ucBcastSig);
8701 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008702 case WDA_DS_TX_START_XMIT:
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05308703 WLANTL_ClearTxXmitPending(pvosGCtx);
8704 vosStatus = WDA_DS_TxFrames( pvosGCtx );
Jeff Johnson295189b2012-06-20 16:38:30 -07008705 break;
8706
8707 case WDA_DS_FINISH_ULA:
Arun Kumar Khandavalli8d1979d2014-01-09 21:12:25 +05308708 callbackContext = message->bodyptr;
8709 callbackRoutine = message->callback;
8710 if ( NULL != callbackRoutine )
8711 {
8712 callbackRoutine(callbackContext);
8713 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008714 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008715
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05308716 case WLANTL_TX_SNAPSHOT:
8717 /*Dumping TL State and then continuing to print
8718 the DXE Dump*/
8719 WLANTL_TxThreadDebugHandler(pvosGCtx);
8720 WDA_TransportChannelDebug(NULL, VOS_TRUE, VOS_FALSE);
8721 break;
8722
Jeff Johnson295189b2012-06-20 16:38:30 -07008723 default:
8724 /*no processing for now*/
8725 break;
8726 }
8727
8728 return vosStatus;
8729}/* WLANTL_TxProcessMsg */
8730
8731/*==========================================================================
8732 FUNCTION WLANTL_McFreeMsg
8733
8734 DESCRIPTION
8735 Called by VOSS to free a given TL message on the Main thread when there
8736 are messages pending in the queue when the whole system is been reset.
8737 For now, TL does not allocate any body so this function shout translate
8738 into a NOOP
8739
8740 DEPENDENCIES
8741 The TL must be initialized before this function can be called.
8742
8743 PARAMETERS
8744
8745 IN
8746 pvosGCtx: pointer to the global vos context; a handle to TL's
8747 control block can be extracted from its context
8748 message: type and content of the message
8749
8750
8751 RETURN VALUE
8752 The result code associated with performing the operation
8753
8754 VOS_STATUS_SUCCESS: Everything is good :)
8755
8756 SIDE EFFECTS
8757
8758============================================================================*/
8759VOS_STATUS
8760WLANTL_TxFreeMsg
8761(
8762 v_PVOID_t pvosGCtx,
8763 vos_msg_t* message
8764)
8765{
8766 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
8767
8768 /*Nothing to do for now!!!*/
8769 return VOS_STATUS_SUCCESS;
8770}/*WLANTL_TxFreeMsg*/
8771
Jeff Johnson295189b2012-06-20 16:38:30 -07008772/*==========================================================================
8773
8774 FUNCTION WLANTL_TxFCFrame
8775
8776 DESCRIPTION
8777 Internal utility function to send FC frame. Enable
8778 or disable LWM mode based on the information.
8779
8780 DEPENDENCIES
8781 TL must be initiailized before this function gets called.
8782 FW sends up special flow control frame.
8783
8784 PARAMETERS
8785
8786 IN
8787 pvosGCtx: pointer to the global vos context; a handle to TL's
8788 control block can be extracted from its context
8789
8790 RETURN VALUE
8791 The result code associated with performing the operation
8792
8793 VOS_STATUS_E_INVAL: Input pointers are NULL.
8794 VOS_STATUS_E_FAULT: Something is wrong.
8795 VOS_STATUS_SUCCESS: Everything is good.
8796
8797 SIDE EFFECTS
8798 Newly formed FC frame is generated and waits to be transmitted. Previously unsent frame will
8799 be released.
8800
8801============================================================================*/
8802VOS_STATUS
8803WLANTL_TxFCFrame
8804(
8805 v_PVOID_t pvosGCtx
8806)
8807{
8808#if 0
8809 WLANTL_CbType* pTLCb = NULL;
8810 VOS_STATUS vosStatus;
8811 tpHalFcTxBd pvFcTxBd = NULL;
8812 vos_pkt_t * pPacket = NULL;
8813 v_U8_t ucSTAId = 0;
8814 v_U8_t ucBitCheck = 1;
8815
8816 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008817 "WLAN TL: Send FC frame %s", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07008818
8819 /*------------------------------------------------------------------------
8820 Sanity check
8821 ------------------------------------------------------------------------*/
8822 if ( NULL == pvosGCtx )
8823 {
8824 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008825 "WLAN TL:Invalid parameter %s", __func__));
Jeff Johnson295189b2012-06-20 16:38:30 -07008826 return VOS_STATUS_E_INVAL;
8827 }
8828 /*------------------------------------------------------------------------
8829 Extract TL control block
8830 ------------------------------------------------------------------------*/
8831 pTLCb = VOS_GET_TL_CB(pvosGCtx);
8832
8833 if (NULL == pTLCb)
8834 {
8835 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008836 "WLAN TL:Invalid pointer in %s \n", __func__));
Jeff Johnson295189b2012-06-20 16:38:30 -07008837 return VOS_STATUS_E_INVAL;
8838 }
8839
8840 //Get one voss packet
8841 vosStatus = vos_pkt_get_packet( &pPacket, VOS_PKT_TYPE_TX_802_11_MGMT, sizeof(tHalFcTxBd), 1,
8842 VOS_FALSE, NULL, NULL );
8843
8844 if ( VOS_STATUS_SUCCESS != vosStatus )
8845 {
8846 return VOS_STATUS_E_INVAL;
8847 }
8848
8849 vosStatus = vos_pkt_reserve_head( pPacket, (void *)&pvFcTxBd, sizeof(tHalFcTxBd));
8850
8851 if( VOS_STATUS_SUCCESS != vosStatus )
8852 {
8853 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008854 "%s: failed to reserve FC TX BD %d\n",__func__, sizeof(tHalFcTxBd)));
Jeff Johnson295189b2012-06-20 16:38:30 -07008855 vos_pkt_return_packet( pPacket );
8856 return VOS_STATUS_E_FAULT;
8857 }
8858
8859 //Generate most recent tlFCInfo. Most fields are correct.
8860 pTLCb->tlFCInfo.fcSTAThreshEnabledMask = 0;
8861 pTLCb->tlFCInfo.fcSTATxMoreDataMask = 0;
8862 for( ucSTAId = 0, ucBitCheck = 1 ; ucSTAId < WLAN_MAX_STA_COUNT; ucBitCheck <<= 1, ucSTAId ++)
8863 {
8864 if (0 == pTLCb->atlSTAClients[ucSTAId].ucExists)
8865 {
8866 continue;
8867 }
8868
8869 if (pTLCb->atlSTAClients[ucSTAId].ucPktPending)
8870 {
8871 pTLCb->tlFCInfo.fcSTATxMoreDataMask |= ucBitCheck;
8872 }
8873
8874 if ( (pTLCb->atlSTAClients[ucSTAId].ucLwmModeEnabled) &&
8875 (pTLCb->atlSTAClients[ucSTAId].bmuMemConsumed > pTLCb->atlSTAClients[ucSTAId].uLwmThreshold))
8876 {
8877 pTLCb->tlFCInfo.fcSTAThreshEnabledMask |= ucBitCheck;
8878
8879 pTLCb->tlFCInfo.fcSTAThresh[ucSTAId] = (tANI_U8)pTLCb->atlSTAClients[ucSTAId].uLwmThreshold;
8880
8881 pTLCb->atlSTAClients[ucSTAId].ucLwmEventReported = FALSE;
8882 }
8883
8884 }
8885
8886 //request immediate feedback
8887 pTLCb->tlFCInfo.fcConfig |= 0x4;
8888
8889 //fill in BD to sent
8890 vosStatus = WLANHAL_FillFcTxBd(pvosGCtx, &pTLCb->tlFCInfo, (void *)pvFcTxBd);
8891
8892 if( VOS_STATUS_SUCCESS != vosStatus )
8893 {
8894 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008895 "%s: Fill FC TX BD unsuccessful\n", __func__));
Jeff Johnson295189b2012-06-20 16:38:30 -07008896 vos_pkt_return_packet( pPacket );
8897 return VOS_STATUS_E_FAULT;
8898 }
8899
8900 if (NULL != pTLCb->vosTxFCBuf)
8901 {
8902 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008903 "%s: Previous FC TX BD not sent\n", __func__));
Jeff Johnson295189b2012-06-20 16:38:30 -07008904 vos_pkt_return_packet(pTLCb->vosTxFCBuf);
8905 }
8906
8907 pTLCb->vosTxFCBuf = pPacket;
8908
8909 vos_pkt_set_user_data_ptr( pPacket, VOS_PKT_USER_DATA_ID_TL,
8910 (v_PVOID_t)WLANTL_TxCompDefaultCb);
8911 vosStatus = WDA_DS_StartXmit(pvosGCtx);
8912
8913 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008914 "WLAN TL: send FC frame leave %s", __func__));
Jeff Johnson295189b2012-06-20 16:38:30 -07008915#endif
8916 return VOS_STATUS_SUCCESS;
8917}
8918
Jeff Johnson295189b2012-06-20 16:38:30 -07008919
8920/*==========================================================================
8921 FUNCTION WLANTL_GetTxResourcesCB
8922
8923 DESCRIPTION
8924 Processing function for Resource needed signal. A request will be issued
8925 to BAL to get more tx resources.
8926
8927 DEPENDENCIES
8928 The TL must be initialized before this function can be called.
8929
8930 PARAMETERS
8931
8932 IN
8933 pvosGCtx: pointer to the global vos context; a handle to TL's
8934 control block can be extracted from its context
8935
8936
8937 RETURN VALUE
8938 The result code associated with performing the operation
8939
8940 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
8941 page fault
8942 VOS_STATUS_SUCCESS: Everything is good :)
8943
8944 Other values can be returned as a result of a function call, please check
8945 corresponding API for more info.
8946 SIDE EFFECTS
8947
8948============================================================================*/
8949VOS_STATUS
8950WLANTL_GetTxResourcesCB
8951(
8952 v_PVOID_t pvosGCtx
8953)
8954{
8955 WLANTL_CbType* pTLCb = NULL;
8956 v_U32_t uResCount = WDA_TLI_MIN_RES_DATA;
8957 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
8958 v_U8_t ucMgmt = 0;
8959 v_U8_t ucBAP = 0;
8960 v_U8_t ucData = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07008961#ifdef WLAN_SOFTAP_FLOWCTRL_EN
8962 tBssSystemRole systemRole;
8963 tpAniSirGlobal pMac;
8964#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07008965 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
8966 /*------------------------------------------------------------------------
8967 Extract TL control block
8968 ------------------------------------------------------------------------*/
8969 pTLCb = VOS_GET_TL_CB(pvosGCtx);
8970 if ( NULL == pTLCb )
8971 {
8972 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8973 "WLAN TL:Invalid TL pointer from pvosGCtx on"
8974 " WLANTL_ProcessTxMessage"));
8975 return VOS_STATUS_E_FAULT;
8976 }
8977
8978 /*------------------------------------------------------------------------
8979 Get tx resources from BAL
8980 ------------------------------------------------------------------------*/
8981 vosStatus = WDA_DS_GetTxResources( pvosGCtx, &uResCount );
8982
8983 if ( (VOS_STATUS_SUCCESS != vosStatus) && (VOS_STATUS_E_RESOURCES != vosStatus))
8984 {
8985 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8986 "WLAN TL:TL failed to get resources from BAL, Err: %d",
8987 vosStatus));
8988 return vosStatus;
8989 }
8990
8991 /* Currently only Linux BAL returns the E_RESOURCES error code when it is running
8992 out of BD/PDUs. To make use of this interrupt for throughput enhancement, similar
8993 changes should be done in BAL code of AMSS and WM */
8994 if (VOS_STATUS_E_RESOURCES == vosStatus)
8995 {
8996#ifdef VOLANS_PERF
8997 WLANHAL_EnableIdleBdPduInterrupt(pvosGCtx, (tANI_U8)bdPduInterruptGetThreshold);
8998 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
8999 "WLAN TL: Enabling Idle BD/PDU interrupt, Current resources = %d", uResCount);
9000#else
9001 return VOS_STATUS_E_FAILURE;
9002#endif
9003 }
9004
9005 pTLCb->uResCount = uResCount;
9006
9007
Jeff Johnson295189b2012-06-20 16:38:30 -07009008#ifdef WLAN_SOFTAP_FLOWCTRL_EN
9009 /* FIXME: disabled since creating issues in power-save, needs to be addressed */
9010 pTLCb->sendFCFrame ++;
9011 pMac = vos_get_context(VOS_MODULE_ID_WDA, pvosGCtx);
9012 systemRole = wdaGetGlobalSystemRole(pMac);
9013 if (eSYSTEM_AP_ROLE == systemRole)
9014 {
9015 if (pTLCb->sendFCFrame % 16 == 0)
9016 {
9017 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
9018 "Transmit FC"));
9019 WLANTL_TxFCFrame (pvosGCtx);
9020 }
9021 }
9022#endif //WLAN_SOFTAP_FLOWCTRL_EN
Jeff Johnson295189b2012-06-20 16:38:30 -07009023
9024 ucData = ( pTLCb->uResCount >= WDA_TLI_MIN_RES_DATA );
9025 ucBAP = ( pTLCb->uResCount >= WDA_TLI_MIN_RES_BAP ) &&
9026 ( NULL != pTLCb->tlBAPClient.vosPendingDataBuff );
9027 ucMgmt = ( pTLCb->uResCount >= WDA_TLI_MIN_RES_MF ) &&
9028 ( NULL != pTLCb->tlMgmtFrmClient.vosPendingDataBuff );
9029
9030 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
9031 "WLAN TL: Eval Resume tx Res: %d DATA: %d BAP: %d MGMT: %d",
9032 pTLCb->uResCount, ucData, ucBAP, ucMgmt));
9033
9034 if (( 0 == pTLCb->ucTxSuspended ) &&
9035 (( 0 != ucData ) || ( 0 != ucMgmt ) || ( 0 != ucBAP ) ) )
9036 {
9037 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
9038 "Issuing Xmit start request to BAL for avail res SYNC"));
9039 vosStatus =WDA_DS_StartXmit(pvosGCtx);
9040 }
9041 return vosStatus;
9042}/*WLANTL_GetTxResourcesCB*/
9043
9044/*==========================================================================
9045 Utility functions
9046 ==========================================================================*/
9047
9048/*==========================================================================
9049 FUNCTION WLANTL_Translate8023To80211Header
9050
9051 DESCRIPTION
9052 Inline function for translating and 802.11 header into an 802.3 header.
9053
9054 DEPENDENCIES
9055
9056
9057 PARAMETERS
9058
9059 IN
9060 pTLCb: TL control block
Kiran Venkatappaa044eb92012-12-17 15:48:49 -08009061 IN/OUT
9062 ucStaId: station ID. Incase of TDLS, this returns actual TDLS
9063 station ID used
Jeff Johnson295189b2012-06-20 16:38:30 -07009064
9065 IN/OUT
9066 vosDataBuff: vos data buffer, will contain the new header on output
9067
9068 OUT
9069 pvosStatus: status of the operation
9070
9071 RETURN VALUE
9072
9073 VOS_STATUS_SUCCESS: Everything is good :)
9074
9075 Other error codes might be returned from the vos api used in the function
9076 please check those return values.
9077
9078 SIDE EFFECTS
9079
9080============================================================================*/
Kiran Venkatappacab0d352012-12-17 13:09:22 -08009081VOS_STATUS
9082WLANTL_Translate8023To80211Header
9083(
9084 vos_pkt_t* vosDataBuff,
9085 VOS_STATUS* pvosStatus,
9086 WLANTL_CbType* pTLCb,
9087 v_U8_t *pucStaId,
Ravi Joshid0699502013-07-08 15:48:47 -07009088 WLANTL_MetaInfoType *tlMetaInfo,
Kiran Venkatappacab0d352012-12-17 13:09:22 -08009089 v_U8_t *ucWDSEnabled,
9090 v_U8_t *extraHeadSpace
9091)
Jeff Johnson295189b2012-06-20 16:38:30 -07009092{
9093 WLANTL_8023HeaderType w8023Header;
9094 WLANTL_80211HeaderType *pw80211Header; // Allocate an aligned BD and then fill it.
9095 VOS_STATUS vosStatus;
9096 v_U8_t MandatoryucHeaderSize = WLAN80211_MANDATORY_HEADER_SIZE;
9097 v_U8_t ucHeaderSize = 0;
9098 v_VOID_t *ppvBDHeader = NULL;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309099 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07009100 v_U8_t ucQoSOffset = WLAN80211_MANDATORY_HEADER_SIZE;
Kiran Venkatappacab0d352012-12-17 13:09:22 -08009101 v_U8_t ucStaId;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009102#ifdef FEATURE_WLAN_ESE_UPLOAD
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009103 v_BOOL_t bIAPPTxwithLLC = VOS_FALSE;
9104 v_SIZE_t wIAPPSnapSize = WLANTL_LLC_HEADER_LEN;
9105 v_U8_t wIAPPSnap[WLANTL_LLC_HEADER_LEN] = {0};
9106#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009107 *ucWDSEnabled = 0; // default WDS off.
9108 vosStatus = vos_pkt_pop_head( vosDataBuff, &w8023Header,
9109 sizeof(w8023Header));
9110
9111 if ( VOS_STATUS_SUCCESS != vosStatus )
9112 {
9113 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9114 "WLAN TL: Packet pop header fails on WLANTL_Translate8023To80211Header"));
9115 return vosStatus;
9116 }
9117
Kiran Venkatappacab0d352012-12-17 13:09:22 -08009118 if( NULL == pucStaId )
9119 {
9120 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9121 "WLAN TL: Invalid pointer for StaId"));
9122 return VOS_STATUS_E_INVAL;
9123 }
9124 ucStaId = *pucStaId;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309125 pClientSTA = pTLCb->atlSTAClients[ucStaId];
9126
9127 if ( NULL == pClientSTA )
9128 {
9129 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9130 "WLAN TL:Client Memory was not allocated on %s", __func__));
9131 return VOS_STATUS_E_FAILURE;
9132 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -08009133
Kiran Venkatappaa044eb92012-12-17 15:48:49 -08009134#ifdef FEATURE_WLAN_TDLS
9135
Madan Mohan Koyylamudi64258222013-01-30 14:35:10 +05309136 if ( WLAN_STA_INFRA == pTLCb->atlSTAClients[ucStaId]->wSTADesc.wSTAType
9137 && pTLCb->ucTdlsPeerCount )
Kiran Venkatappacab0d352012-12-17 13:09:22 -08009138 {
9139 v_U8_t ucIndex = 0;
9140 for ( ucIndex = 0; ucIndex < WLAN_MAX_STA_COUNT ; ucIndex++)
9141 {
Madan Mohan Koyylamudi64258222013-01-30 14:35:10 +05309142 if ( ucIndex != ucStaId && pTLCb->atlSTAClients[ucIndex] && pTLCb->atlSTAClients[ucIndex]->ucExists &&
Gopichand Nakkala471708b2013-06-04 20:03:01 +05309143 (pTLCb->atlSTAClients[ucIndex]->tlState == WLANTL_STA_AUTHENTICATED) &&
9144 (!pTLCb->atlSTAClients[ucIndex]->ucTxSuspended) &&
Madan Mohan Koyylamudi64258222013-01-30 14:35:10 +05309145 vos_mem_compare( (void*)pTLCb->atlSTAClients[ucIndex]->wSTADesc.vSTAMACAddress.bytes,
Kiran Venkatappacab0d352012-12-17 13:09:22 -08009146 (void*)w8023Header.vDA, 6) )
9147 {
9148 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_LOW,
9149 "WLAN TL: Got a TDLS station. Using that index"));
9150 ucStaId = ucIndex;
9151 *pucStaId = ucStaId;
Madan Mohan Koyylamudi64258222013-01-30 14:35:10 +05309152 pClientSTA = pTLCb->atlSTAClients[ucStaId];
9153 if ( NULL == pClientSTA )
9154 {
9155 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9156 "WLAN TL:Client Memory was not allocated on %s", __func__));
9157 return VOS_STATUS_E_FAILURE;
9158 }
Kiran Venkatappacab0d352012-12-17 13:09:22 -08009159 break;
9160 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -08009161 }
Kiran Venkatappacab0d352012-12-17 13:09:22 -08009162 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -08009163#endif
9164
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009165#ifdef FEATURE_WLAN_ESE_UPLOAD
9166if ((0 == w8023Header.usLenType) && (pClientSTA->wSTADesc.ucIsEseSta))
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009167{
9168 vos_pkt_extract_data(vosDataBuff,0,&wIAPPSnap[0],&wIAPPSnapSize);
9169 if (vos_mem_compare(wIAPPSnap,WLANTL_AIRONET_SNAP_HEADER,WLANTL_LLC_HEADER_LEN))
9170 {
9171 /*The SNAP and the protocol type are already in the data buffer.
9172 They are filled by the application (wpa_supplicant). So, Skip Adding LLC below.*/
9173 bIAPPTxwithLLC = VOS_TRUE;
9174 }
9175 else
9176 {
9177 bIAPPTxwithLLC = VOS_FALSE;
9178 }
9179}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009180#endif /* FEATURE_WLAN_ESE_UPLOAD */
Jeff Johnson295189b2012-06-20 16:38:30 -07009181
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009182 if ((0 != pClientSTA->wSTADesc.ucAddRmvLLC)
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009183#ifdef FEATURE_WLAN_ESE_UPLOAD
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009184 && (!bIAPPTxwithLLC)
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009185#endif /* FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009186 )
Jeff Johnson295189b2012-06-20 16:38:30 -07009187 {
9188 /* Push the length */
9189 vosStatus = vos_pkt_push_head(vosDataBuff,
9190 &w8023Header.usLenType, sizeof(w8023Header.usLenType));
9191
9192 if ( VOS_STATUS_SUCCESS != vosStatus )
9193 {
9194 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9195 "WLAN TL: Packet push ether type fails on"
9196 " WLANTL_Translate8023To80211Header"));
9197 return vosStatus;
9198 }
9199
9200#ifdef BTAMP_TEST
9201 // The STA side will execute this, a hack to test BTAMP by using the
9202 // infra setup. On real BTAMP this will come from BAP itself.
9203 {
9204 static v_U8_t WLANTL_BT_AMP_LLC_HEADER[] = {0xAA, 0xAA, 0x03, 0x00, 0x19, 0x58 };
9205 vosStatus = vos_pkt_push_head(vosDataBuff, WLANTL_BT_AMP_LLC_HEADER,
9206 sizeof(WLANTL_BT_AMP_LLC_HEADER));
9207
9208 if ( VOS_STATUS_SUCCESS != vosStatus )
9209 {
9210 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9211 "WLAN TL: Packet push LLC header fails on"
9212 " WLANTL_Translate8023To80211Header"));
9213 return vosStatus;
9214 }
9215 }
9216#else
9217 vosStatus = vos_pkt_push_head(vosDataBuff, WLANTL_LLC_HEADER,
9218 sizeof(WLANTL_LLC_HEADER));
9219
9220 if ( VOS_STATUS_SUCCESS != vosStatus )
9221 {
9222 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9223 "WLAN TL: Packet push LLC header fails on"
9224 " WLANTL_Translate8023To80211Header"));
9225 return vosStatus;
9226 }
9227#endif
9228 }/*If add LLC is enabled*/
9229 else
9230 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009231#ifdef FEATURE_WLAN_ESE_UPLOAD
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009232 bIAPPTxwithLLC = VOS_FALSE; /*Reset the Flag here to start afresh with the next TX pkt*/
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009233#endif /* FEATURE_WLAN_ESE_UPLOAD */
Jeff Johnson295189b2012-06-20 16:38:30 -07009234 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
9235 "WLAN TL: STA Client registered to not remove LLC"
9236 " WLANTL_Translate8023To80211Header"));
9237 }
9238
9239#ifdef BTAMP_TEST
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309240 pClientSTA->wSTADesc.wSTAType = WLAN_STA_BT_AMP;
Jeff Johnson295189b2012-06-20 16:38:30 -07009241#endif
9242
9243 // Find the space required for the 802.11 header format
9244 // based on the frame control fields.
9245 ucHeaderSize = MandatoryucHeaderSize;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309246 if (pClientSTA->wSTADesc.ucQosEnabled)
Jeff Johnson295189b2012-06-20 16:38:30 -07009247 {
9248 ucHeaderSize += sizeof(pw80211Header->usQosCtrl);
9249 }
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309250 if (pClientSTA->wSTADesc.wSTAType == WLAN_STA_BT_AMP)
Jeff Johnson295189b2012-06-20 16:38:30 -07009251 {
9252 ucHeaderSize += sizeof(pw80211Header->optvA4);
Jeff Johnson295189b2012-06-20 16:38:30 -07009253 ucQoSOffset += sizeof(pw80211Header->optvA4);
Jeff Johnson295189b2012-06-20 16:38:30 -07009254 }
9255
9256 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
9257 " WLANTL_Translate8023To80211Header : Header size = %d ", ucHeaderSize));
9258
9259 vos_pkt_reserve_head( vosDataBuff, &ppvBDHeader, ucHeaderSize );
9260 if ( NULL == ppvBDHeader )
9261 {
9262 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9263 "WLAN TL:VOSS packet corrupted "));
9264 *pvosStatus = VOS_STATUS_E_INVAL;
9265 return *pvosStatus;
9266 }
9267
Jeff Johnson295189b2012-06-20 16:38:30 -07009268
9269 // OK now we have the space. Fill the 80211 header
9270 /* Fill A2 */
9271 pw80211Header = (WLANTL_80211HeaderType *)(ppvBDHeader);
9272 // only clear the required space.
9273 vos_mem_set( pw80211Header, ucHeaderSize, 0 );
9274 vos_mem_copy( pw80211Header->vA2, w8023Header.vSA, VOS_MAC_ADDR_SIZE);
9275
9276
9277#ifdef FEATURE_WLAN_WAPI
Gopichand Nakkala8b54e912013-03-11 10:44:21 +05309278 if (( WLANTL_STA_AUTHENTICATED == pClientSTA->tlState ||
9279 pClientSTA->ptkInstalled ) && gUcIsWai != 1)
Jeff Johnson295189b2012-06-20 16:38:30 -07009280#else
Gopichand Nakkala8b54e912013-03-11 10:44:21 +05309281 if ( WLANTL_STA_AUTHENTICATED == pClientSTA->tlState ||
9282 pClientSTA->ptkInstalled )
Jeff Johnson295189b2012-06-20 16:38:30 -07009283#endif
9284 {
9285 pw80211Header->wFrmCtrl.wep =
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309286 pClientSTA->wSTADesc.ucProtectedFrame;
Jeff Johnson295189b2012-06-20 16:38:30 -07009287 }
9288
9289 pw80211Header->usDurationId = 0;
9290 pw80211Header->usSeqCtrl = 0;
9291
9292 pw80211Header->wFrmCtrl.type = WLANTL_80211_DATA_TYPE;
9293
9294
9295
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309296 if(pClientSTA->wSTADesc.ucQosEnabled)
Jeff Johnson295189b2012-06-20 16:38:30 -07009297 {
9298 pw80211Header->wFrmCtrl.subType = WLANTL_80211_DATA_QOS_SUBTYPE;
9299
Ravi Joshid0699502013-07-08 15:48:47 -07009300 *((v_U16_t *)((v_U8_t *)ppvBDHeader + ucQoSOffset)) = tlMetaInfo->ucUP;
Jeff Johnson295189b2012-06-20 16:38:30 -07009301
9302 }
9303 else
9304 {
9305 pw80211Header->wFrmCtrl.subType = 0;
9306
9307 // NO NO NO - there is not enough memory allocated to write the QOS ctrl
9308 // field, it will overwrite the first 2 bytes of the data packet(LLC header)
9309 // pw80211Header->usQosCtrl = 0;
9310 }
9311
9312
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309313 switch( pClientSTA->wSTADesc.wSTAType )
Jeff Johnson295189b2012-06-20 16:38:30 -07009314 {
Ravi Joshid0699502013-07-08 15:48:47 -07009315 case WLAN_STA_IBSS:
Jeff Johnson295189b2012-06-20 16:38:30 -07009316 pw80211Header->wFrmCtrl.toDS = 0;
9317 pw80211Header->wFrmCtrl.fromDS = 0;
Ravi Joshid0699502013-07-08 15:48:47 -07009318
9319 /*
9320 * If the frame is a multicast frame, then, the Address1
9321 * should be the destination address filled in the packet. Which is
9322 * the multicast address. Otherwise, set it to BSSID
9323 */
9324 if (0 == tlMetaInfo->ucBcast && 1 == tlMetaInfo->ucMcast)
9325 {
9326 vos_copy_macaddr( (v_MACADDR_t*)&pw80211Header->vA1,
9327 (v_MACADDR_t*)&w8023Header.vDA);
9328 }
9329 else
9330 {
9331 vos_copy_macaddr( (v_MACADDR_t*)&pw80211Header->vA1,
9332 &pClientSTA->wSTADesc.vSTAMACAddress);
9333 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009334 vos_mem_copy( pw80211Header->vA3,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309335 &pClientSTA->wSTADesc.vBSSIDforIBSS ,
Jeff Johnson295189b2012-06-20 16:38:30 -07009336 VOS_MAC_ADDR_SIZE);
9337 break;
9338
Ravi Joshid0699502013-07-08 15:48:47 -07009339 case WLAN_STA_BT_AMP:
Jeff Johnson295189b2012-06-20 16:38:30 -07009340 *ucWDSEnabled = 1; // WDS on.
9341 pw80211Header->wFrmCtrl.toDS = 1;
9342 pw80211Header->wFrmCtrl.fromDS = 1;
9343 vos_copy_macaddr( (v_MACADDR_t*)&pw80211Header->vA1,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309344 &pClientSTA->wSTADesc.vSTAMACAddress);
Jeff Johnson295189b2012-06-20 16:38:30 -07009345 vos_mem_copy( pw80211Header->vA2,
Ravi Joshid0699502013-07-08 15:48:47 -07009346 w8023Header.vSA, VOS_MAC_ADDR_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -07009347 vos_copy_macaddr( (v_MACADDR_t*)&pw80211Header->vA3,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309348 &pClientSTA->wSTADesc.vSTAMACAddress);
Jeff Johnson295189b2012-06-20 16:38:30 -07009349 /* fill the optional A4 header */
9350 vos_mem_copy( pw80211Header->optvA4,
Ravi Joshid0699502013-07-08 15:48:47 -07009351 w8023Header.vSA, VOS_MAC_ADDR_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -07009352 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
Arif Hussainf2b00992013-11-17 21:46:15 -08009353 "BTAMP CASE NOW ---------staid=%d",
Ravi Joshid0699502013-07-08 15:48:47 -07009354 ucStaId));
Jeff Johnson295189b2012-06-20 16:38:30 -07009355 break;
9356
Ravi Joshid0699502013-07-08 15:48:47 -07009357 case WLAN_STA_SOFTAP:
Jeff Johnson295189b2012-06-20 16:38:30 -07009358 *ucWDSEnabled = 0; // WDS off.
9359 pw80211Header->wFrmCtrl.toDS = 0;
9360 pw80211Header->wFrmCtrl.fromDS = 1;
9361 /*Copy the DA to A1*/
9362 vos_mem_copy( pw80211Header->vA1, w8023Header.vDA , VOS_MAC_ADDR_SIZE);
9363 vos_copy_macaddr( (v_MACADDR_t*)&pw80211Header->vA2,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309364 &pClientSTA->wSTADesc.vSelfMACAddress);
Jeff Johnson295189b2012-06-20 16:38:30 -07009365 vos_mem_copy( pw80211Header->vA3,
Ravi Joshid0699502013-07-08 15:48:47 -07009366 w8023Header.vSA, VOS_MAC_ADDR_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -07009367 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
Arif Hussainf2b00992013-11-17 21:46:15 -08009368 "sw 802 to 80211 softap case ---------staid=%d",
Ravi Joshid0699502013-07-08 15:48:47 -07009369 ucStaId));
Jeff Johnson295189b2012-06-20 16:38:30 -07009370 break;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08009371#ifdef FEATURE_WLAN_TDLS
Ravi Joshid0699502013-07-08 15:48:47 -07009372 case WLAN_STA_TDLS:
Mohit Khanna698ba2a2012-12-04 15:08:18 -08009373 pw80211Header->wFrmCtrl.toDS = 0;
9374 pw80211Header->wFrmCtrl.fromDS = 0;
9375 /*Fix me*/
9376 vos_copy_macaddr( (v_MACADDR_t*)&pw80211Header->vA1,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309377 &pClientSTA->wSTADesc.vSTAMACAddress);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08009378 vos_mem_copy( pw80211Header->vA3,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309379 &pClientSTA->wSTADesc.vBSSIDforIBSS ,
Mohit Khanna698ba2a2012-12-04 15:08:18 -08009380 VOS_MAC_ADDR_SIZE);
9381 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
Arif Hussainf2b00992013-11-17 21:46:15 -08009382 ("TL:TDLS CASE NOW ---------staid=%d"), ucStaId);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08009383 break;
9384#endif
Ravi Joshid0699502013-07-08 15:48:47 -07009385 case WLAN_STA_INFRA:
9386 default:
Jeff Johnson295189b2012-06-20 16:38:30 -07009387 pw80211Header->wFrmCtrl.toDS = 1;
9388 pw80211Header->wFrmCtrl.fromDS = 0;
9389 vos_copy_macaddr( (v_MACADDR_t*)&pw80211Header->vA1,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309390 &pClientSTA->wSTADesc.vSTAMACAddress);
Jeff Johnson295189b2012-06-20 16:38:30 -07009391 vos_mem_copy( pw80211Header->vA3, w8023Header.vDA , VOS_MAC_ADDR_SIZE);
9392 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
Arif Hussainf2b00992013-11-17 21:46:15 -08009393 "REGULAR INFRA LINK CASE---------staid=%d",
Ravi Joshid0699502013-07-08 15:48:47 -07009394 ucStaId));
Jeff Johnson295189b2012-06-20 16:38:30 -07009395 break;
9396 }
9397 // OK now we have the space. Fill the 80211 header
9398 /* Fill A2 */
9399 pw80211Header = (WLANTL_80211HeaderType *)(ppvBDHeader);
9400 return VOS_STATUS_SUCCESS;
9401}/*WLANTL_Translate8023To80211Header*/
9402
9403
9404/*=============================================================================
9405 BEGIN LOG FUNCTION !!! Remove me or clean me
9406=============================================================================*/
Ravi Kumar Vaishnavb7652402013-01-18 19:05:15 -08009407#if 0 //def WLANTL_DEBUG
Jeff Johnson295189b2012-06-20 16:38:30 -07009408
9409#define WLANTL_DEBUG_FRAME_BYTE_PER_LINE 16
9410#define WLANTL_DEBUG_FRAME_BYTE_PER_BYTE 4
9411
9412static v_VOID_t WLANTL_DebugFrame
9413(
9414 v_PVOID_t dataPointer,
9415 v_U32_t dataSize
9416)
9417{
9418 v_U8_t lineBuffer[WLANTL_DEBUG_FRAME_BYTE_PER_LINE];
9419 v_U32_t numLines;
9420 v_U32_t numBytes;
9421 v_U32_t idx;
9422 v_U8_t *linePointer;
9423
9424 numLines = dataSize / WLANTL_DEBUG_FRAME_BYTE_PER_LINE;
9425 numBytes = dataSize % WLANTL_DEBUG_FRAME_BYTE_PER_LINE;
9426 linePointer = (v_U8_t *)dataPointer;
9427
9428 TLLOGE(VOS_TRACE(VOS_MODULE_ID_SAL, VOS_TRACE_LEVEL_ERROR, "WLAN TL:Frame Debug Frame Size %d, Pointer 0x%p", dataSize, dataPointer));
9429 for(idx = 0; idx < numLines; idx++)
9430 {
9431 memset(lineBuffer, 0, WLANTL_DEBUG_FRAME_BYTE_PER_LINE);
9432 memcpy(lineBuffer, linePointer, WLANTL_DEBUG_FRAME_BYTE_PER_LINE);
9433 TLLOGE(VOS_TRACE(VOS_MODULE_ID_SAL, VOS_TRACE_LEVEL_ERROR,
9434 "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",
9435 lineBuffer[0], lineBuffer[1], lineBuffer[2], lineBuffer[3], lineBuffer[4], lineBuffer[5], lineBuffer[6], lineBuffer[7],
9436 lineBuffer[8], lineBuffer[9], lineBuffer[10], lineBuffer[11], lineBuffer[12], lineBuffer[13], lineBuffer[14], lineBuffer[15]));
9437 linePointer += WLANTL_DEBUG_FRAME_BYTE_PER_LINE;
9438 }
9439
9440 if(0 == numBytes)
9441 return;
9442
9443 memset(lineBuffer, 0, WLANTL_DEBUG_FRAME_BYTE_PER_LINE);
9444 memcpy(lineBuffer, linePointer, numBytes);
9445 for(idx = 0; idx < WLANTL_DEBUG_FRAME_BYTE_PER_LINE / WLANTL_DEBUG_FRAME_BYTE_PER_BYTE; idx++)
9446 {
9447 TLLOGE(VOS_TRACE(VOS_MODULE_ID_SAL, VOS_TRACE_LEVEL_ERROR, "WLAN TL:0x%2x 0x%2x 0x%2x 0x%2x",
9448 lineBuffer[idx * WLANTL_DEBUG_FRAME_BYTE_PER_BYTE], lineBuffer[1 + idx * WLANTL_DEBUG_FRAME_BYTE_PER_BYTE],
9449 lineBuffer[2 + idx * WLANTL_DEBUG_FRAME_BYTE_PER_BYTE], lineBuffer[3 + idx * WLANTL_DEBUG_FRAME_BYTE_PER_BYTE]));
9450 if(((idx + 1) * WLANTL_DEBUG_FRAME_BYTE_PER_BYTE) >= numBytes)
9451 break;
9452 }
9453
9454 return;
9455}
9456#endif
9457
9458/*=============================================================================
9459 END LOG FUNCTION
9460=============================================================================*/
9461
9462/*==========================================================================
9463 FUNCTION WLANTL_Translate80211To8023Header
9464
9465 DESCRIPTION
9466 Inline function for translating and 802.11 header into an 802.3 header.
9467
9468 DEPENDENCIES
9469
9470
9471 PARAMETERS
9472
9473 IN
9474 pTLCb: TL control block
9475 ucStaId: station ID
9476 ucHeaderLen: Length of the header from BD
9477 ucActualHLen: Length of header including padding or any other trailers
9478
9479 IN/OUT
9480 vosDataBuff: vos data buffer, will contain the new header on output
9481
9482 OUT
9483 pvosStatus: status of the operation
9484
9485 RETURN VALUE
9486
9487 The result code associated with performing the operation
9488 VOS_STATUS_SUCCESS: Everything is good :)
9489
9490 SIDE EFFECTS
9491
9492============================================================================*/
9493VOS_STATUS
9494WLANTL_Translate80211To8023Header
9495(
9496 vos_pkt_t* vosDataBuff,
9497 VOS_STATUS* pvosStatus,
9498 v_U16_t usActualHLen,
9499 v_U8_t ucHeaderLen,
9500 WLANTL_CbType* pTLCb,
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009501 v_U8_t ucSTAId,
9502 v_BOOL_t bForwardIAPPwithLLC
Jeff Johnson295189b2012-06-20 16:38:30 -07009503)
9504{
9505 WLANTL_8023HeaderType w8023Header;
9506 WLANTL_80211HeaderType w80211Header;
9507 v_U8_t aucLLCHeader[WLANTL_LLC_HEADER_LEN];
9508 VOS_STATUS vosStatus;
9509 v_U16_t usDataStartOffset = 0;
9510 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
9511
9512 if ( sizeof(w80211Header) < ucHeaderLen )
9513 {
9514 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
9515 "Warning !: Check the header size for the Rx frame structure=%d received=%dn",
9516 sizeof(w80211Header), ucHeaderLen));
9517 ucHeaderLen = sizeof(w80211Header);
9518 }
9519
9520 // This will take care of headers of all sizes, 3 address, 3 addr QOS,
9521 // WDS non-QOS and WDS QoS etc. We have space for all in the 802.11 header structure.
9522 vosStatus = vos_pkt_pop_head( vosDataBuff, &w80211Header, ucHeaderLen);
9523
9524 if ( VOS_STATUS_SUCCESS != vosStatus )
9525 {
9526 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9527 "WLAN TL: Failed to pop 80211 header from packet %d",
9528 vosStatus));
9529
9530 return vosStatus;
9531 }
9532
9533 switch ( w80211Header.wFrmCtrl.fromDS )
9534 {
9535 case 0:
Jeff Johnson295189b2012-06-20 16:38:30 -07009536 if ( w80211Header.wFrmCtrl.toDS )
9537 {
9538 //SoftAP AP mode
9539 vos_mem_copy( w8023Header.vDA, w80211Header.vA3, VOS_MAC_ADDR_SIZE);
9540 vos_mem_copy( w8023Header.vSA, w80211Header.vA2, VOS_MAC_ADDR_SIZE);
9541 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
Arif Hussainf2b00992013-11-17 21:46:15 -08009542 "WLAN TL SoftAP: 802 3 DA %08x SA %08x",
Jeff Johnson295189b2012-06-20 16:38:30 -07009543 w8023Header.vDA, w8023Header.vSA));
9544 }
9545 else
9546 {
9547 /* IBSS */
9548 vos_mem_copy( w8023Header.vDA, w80211Header.vA1, VOS_MAC_ADDR_SIZE);
9549 vos_mem_copy( w8023Header.vSA, w80211Header.vA2, VOS_MAC_ADDR_SIZE);
9550 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009551 break;
9552 case 1:
9553 if ( w80211Header.wFrmCtrl.toDS )
9554 {
9555 /* BT-AMP case */
9556 vos_mem_copy( w8023Header.vDA, w80211Header.vA1, VOS_MAC_ADDR_SIZE);
9557 vos_mem_copy( w8023Header.vSA, w80211Header.vA2, VOS_MAC_ADDR_SIZE);
9558 }
9559 else
9560 { /* Infra */
9561 vos_mem_copy( w8023Header.vDA, w80211Header.vA1, VOS_MAC_ADDR_SIZE);
9562 vos_mem_copy( w8023Header.vSA, w80211Header.vA3, VOS_MAC_ADDR_SIZE);
9563 }
9564 break;
9565 }
9566
9567 if( usActualHLen > ucHeaderLen )
9568 {
9569 usDataStartOffset = usActualHLen - ucHeaderLen;
9570 }
9571
9572 if ( 0 < usDataStartOffset )
9573 {
9574 vosStatus = vos_pkt_trim_head( vosDataBuff, usDataStartOffset );
9575
9576 if ( VOS_STATUS_SUCCESS != vosStatus )
9577 {
9578 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9579 "WLAN TL: Failed to trim header from packet %d",
9580 vosStatus));
9581 return vosStatus;
9582 }
9583 }
9584
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309585 if ( NULL == pTLCb->atlSTAClients[ucSTAId] )
9586 {
9587 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9588 "WLAN TL:Client Memory was not allocated on %s", __func__));
9589 return VOS_STATUS_E_FAILURE;
9590 }
9591
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009592 if ( 0 != pTLCb->atlSTAClients[ucSTAId]->wSTADesc.ucAddRmvLLC
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009593#ifdef FEATURE_WLAN_ESE_UPLOAD
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009594 && (!bForwardIAPPwithLLC)
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009595#endif /* FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009596 )
Jeff Johnson295189b2012-06-20 16:38:30 -07009597 {
9598 // Extract the LLC header
9599 vosStatus = vos_pkt_pop_head( vosDataBuff, aucLLCHeader,
9600 WLANTL_LLC_HEADER_LEN);
9601
9602 if ( VOS_STATUS_SUCCESS != vosStatus )
9603 {
9604 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9605 "WLAN TL: Failed to pop LLC header from packet %d",
9606 vosStatus));
9607
9608 return vosStatus;
9609 }
9610
9611 //Extract the length
9612 vos_mem_copy(&w8023Header.usLenType,
9613 &aucLLCHeader[WLANTL_LLC_HEADER_LEN - sizeof(w8023Header.usLenType)],
9614 sizeof(w8023Header.usLenType) );
9615 }
9616 else
9617 {
9618 vosStatus = vos_pkt_get_packet_length(vosDataBuff,
9619 &w8023Header.usLenType);
9620
9621 if ( VOS_STATUS_SUCCESS != vosStatus )
9622 {
9623 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9624 "WLAN TL: Failed to get packet length %d",
9625 vosStatus));
9626
9627 return vosStatus;
9628 }
9629
9630 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
9631 "WLAN TL: BTAMP len (ethertype) fld = %d",
9632 w8023Header.usLenType));
9633 w8023Header.usLenType = vos_cpu_to_be16(w8023Header.usLenType);
9634 }
9635
9636 vos_pkt_push_head(vosDataBuff, &w8023Header, sizeof(w8023Header));
9637
9638#ifdef BTAMP_TEST
9639 {
9640 // AP side will execute this.
9641 v_U8_t *temp_w8023Header = NULL;
9642 vosStatus = vos_pkt_peek_data( vosDataBuff, 0,
9643 &temp_w8023Header, sizeof(w8023Header) );
9644 }
9645#endif
9646#if 0 /*TL_DEBUG*/
9647 vos_pkt_get_packet_length(vosDataBuff, &usLen);
9648 vos_pkt_pop_head( vosDataBuff, aucData, usLen);
9649
9650 WLANTL_DebugFrame(aucData, usLen);
9651
9652 vos_pkt_push_head(vosDataBuff, aucData, usLen);
9653
9654#endif
9655
9656 *pvosStatus = VOS_STATUS_SUCCESS;
9657
9658 return VOS_STATUS_SUCCESS;
9659}/*WLANTL_Translate80211To8023Header*/
9660
Madan Mohan Koyyalamudia148e1e2012-11-30 14:52:59 -08009661/*==========================================================================
9662 FUNCTION WLANTL_FindFrameTypeBcMcUc
9663
9664 DESCRIPTION
9665 Utility function to find whether received frame is broadcast, multicast
9666 or unicast.
9667
9668 DEPENDENCIES
9669 The STA must be registered with TL before this function can be called.
9670
9671 PARAMETERS
9672
9673 IN
9674 pTLCb: pointer to the TL's control block
9675 ucSTAId: identifier of the station being processed
9676 vosDataBuff: pointer to the vos buffer
9677
9678 IN/OUT
9679 pucBcMcUc: pointer to buffer, will contain frame type on return
9680
9681 RETURN VALUE
9682 The result code associated with performing the operation
9683
9684 VOS_STATUS_E_INVAL: invalid input parameters
9685 VOS_STATUS_E_BADMSG: failed to extract info from data buffer
9686 VOS_STATUS_SUCCESS: success
9687
9688 SIDE EFFECTS
9689 None.
9690============================================================================*/
9691VOS_STATUS
9692WLANTL_FindFrameTypeBcMcUc
9693(
9694 WLANTL_CbType *pTLCb,
9695 v_U8_t ucSTAId,
9696 vos_pkt_t *vosDataBuff,
9697 v_U8_t *pucBcMcUc
9698)
9699{
9700 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
9701 v_PVOID_t aucBDHeader;
9702 v_PVOID_t pvPeekData;
9703 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
9704
9705 /*------------------------------------------------------------------------
9706 Sanity check
9707 ------------------------------------------------------------------------*/
9708 if ((NULL == pTLCb) ||
9709 (NULL == vosDataBuff) ||
9710 (NULL == pucBcMcUc))
9711 {
9712 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9713 "WLAN TL:Invalid parameter in WLANTL_FindFrameTypeBcMcUc"));
9714 return VOS_STATUS_E_INVAL;
9715 }
9716
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309717 if ( NULL == pTLCb->atlSTAClients[ucSTAId] )
9718 {
9719 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9720 "WLAN TL:Client Memory was not allocated on %s", __func__));
9721 return VOS_STATUS_E_FAILURE;
9722 }
9723
Madan Mohan Koyyalamudia148e1e2012-11-30 14:52:59 -08009724 /*------------------------------------------------------------------------
9725 Extract BD header and check if valid
9726 ------------------------------------------------------------------------*/
9727 vosStatus = WDA_DS_PeekRxPacketInfo(vosDataBuff, (v_PVOID_t)&aucBDHeader, 0/*Swap BD*/ );
9728
9729 if (NULL == aucBDHeader)
9730 {
9731 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9732 "WLAN TL:WLANTL_FindFrameTypeBcMcUc - Cannot extract BD header"));
9733 VOS_ASSERT(0);
9734 return VOS_STATUS_E_BADMSG;
9735 }
9736
9737 if ((0 == WDA_GET_RX_FT_DONE(aucBDHeader)) &&
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309738 (0 != pTLCb->atlSTAClients[ucSTAId]->wSTADesc.ucSwFrameRXXlation))
Madan Mohan Koyyalamudia148e1e2012-11-30 14:52:59 -08009739 {
9740 /* Its an 802.11 frame, extract MAC address 1 */
9741 TLLOG2(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
9742 "WLAN TL:WLANTL_FindFrameTypeBcMcUc - 802.11 frame, peeking Addr1"));
9743 vosStatus = vos_pkt_peek_data(vosDataBuff, WLANTL_MAC_ADDR_ALIGN(1),
9744 (v_PVOID_t)&pvPeekData, VOS_MAC_ADDR_SIZE);
9745 }
9746 else
9747 {
9748 /* Its an 802.3 frame, extract Destination MAC address */
9749 TLLOG2(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
9750 "WLAN TL:WLANTL_FindFrameTypeBcMcUc - 802.3 frame, peeking DA"));
9751 vosStatus = vos_pkt_peek_data(vosDataBuff, WLANTL_MAC_ADDR_ALIGN(0),
9752 (v_PVOID_t)&pvPeekData, VOS_MAC_ADDR_SIZE);
9753 }
9754
9755 if (VOS_STATUS_SUCCESS != vosStatus)
9756 {
9757 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9758 "WLAN TL:WLANTL_FindFrameTypeBcMcUc - Failed to peek MAC address"));
9759 return vosStatus;
9760 }
9761
9762 if (((tANI_U8 *)pvPeekData)[0] == 0xff)
9763 {
9764 *pucBcMcUc = WLANTL_FRAME_TYPE_BCAST;
9765 }
9766 else
9767 {
9768 if ((((tANI_U8 *)pvPeekData)[0] & 0x01) == 0x01)
9769 *pucBcMcUc = WLANTL_FRAME_TYPE_MCAST;
9770 else
9771 *pucBcMcUc = WLANTL_FRAME_TYPE_UCAST;
9772 }
9773
9774 TLLOG2(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
9775 "WLAN TL:WLANTL_FindFrameTypeBcMcUc - Addr1Byte1 is: %x",
9776 ((tANI_U8 *)pvPeekData)[0]));
9777
9778 return VOS_STATUS_SUCCESS;
9779}
9780
Jeff Johnson295189b2012-06-20 16:38:30 -07009781#if 0
9782#ifdef WLAN_PERF
9783/*==========================================================================
9784 FUNCTION WLANTL_FastHwFwdDataFrame
9785
9786 DESCRIPTION
9787 Fast path function to quickly forward a data frame if HAL determines BD
9788 signature computed here matches the signature inside current VOSS packet.
9789 If there is a match, HAL and TL fills in the swapped packet length into
9790 BD header and DxE header, respectively. Otherwise, packet goes back to
9791 normal (slow) path and a new BD signature would be tagged into BD in this
9792 VOSS packet later by the WLANHAL_FillTxBd() function.
9793
9794 DEPENDENCIES
9795
9796 PARAMETERS
9797
9798 IN
9799 pvosGCtx VOS context
9800 vosDataBuff Ptr to VOSS packet
9801 pMetaInfo For getting frame's TID
9802 pStaInfo For checking STA type
9803
9804 OUT
9805 pvosStatus returned status
9806 puFastFwdOK Flag to indicate whether frame could be fast forwarded
9807
9808 RETURN VALUE
9809 No return.
9810
9811 SIDE EFFECTS
9812
9813============================================================================*/
9814static void
9815WLANTL_FastHwFwdDataFrame
9816(
9817 v_PVOID_t pvosGCtx,
9818 vos_pkt_t* vosDataBuff,
9819 VOS_STATUS* pvosStatus,
9820 v_U32_t* puFastFwdOK,
9821 WLANTL_MetaInfoType* pMetaInfo,
9822 WLAN_STADescType* pStaInfo
9823
9824)
9825{
9826 v_PVOID_t pvPeekData;
9827 v_U8_t ucDxEBDWLANHeaderLen = WLANTL_BD_HEADER_LEN(0) + sizeof(WLANBAL_sDXEHeaderType);
9828 v_U8_t ucIsUnicast;
9829 WLANBAL_sDXEHeaderType *pDxEHeader;
9830 v_PVOID_t pvBDHeader;
9831 v_PVOID_t pucBuffPtr;
9832 v_U16_t usPktLen;
9833
9834 /*-----------------------------------------------------------------------
9835 Extract packet length
9836 -----------------------------------------------------------------------*/
9837
9838 vos_pkt_get_packet_length( vosDataBuff, &usPktLen);
9839
9840 /*-----------------------------------------------------------------------
9841 Extract MAC address
9842 -----------------------------------------------------------------------*/
9843 *pvosStatus = vos_pkt_peek_data( vosDataBuff,
9844 WLANTL_MAC_ADDR_ALIGN(0),
9845 (v_PVOID_t)&pvPeekData,
9846 VOS_MAC_ADDR_SIZE );
9847
9848 if ( VOS_STATUS_SUCCESS != *pvosStatus )
9849 {
9850 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9851 "WLAN TL:Failed while attempting to extract MAC Addr %d",
9852 *pvosStatus));
9853 *pvosStatus = VOS_STATUS_E_INVAL;
9854 return;
9855 }
9856
9857 /*-----------------------------------------------------------------------
9858 Reserve head room for DxE header, BD, and WLAN header
9859 -----------------------------------------------------------------------*/
9860
9861 vos_pkt_reserve_head( vosDataBuff, &pucBuffPtr,
9862 ucDxEBDWLANHeaderLen );
9863 if ( NULL == pucBuffPtr )
9864 {
9865 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9866 "WLAN TL:No enough space in VOSS packet %p for DxE/BD/WLAN header", vosDataBuff));
9867 *pvosStatus = VOS_STATUS_E_INVAL;
9868 return;
9869 }
9870 pDxEHeader = (WLANBAL_sDXEHeaderType *)pucBuffPtr;
9871 pvBDHeader = (v_PVOID_t) &pDxEHeader[1];
9872
9873 /* UMA Tx acceleration is enabled.
9874 * UMA would help convert frames to 802.11, fill partial BD fields and
9875 * construct LLC header. To further accelerate this kind of frames,
9876 * HAL would attempt to reuse the BD descriptor if the BD signature
9877 * matches to the saved BD descriptor.
9878 */
9879 if(pStaInfo->wSTAType == WLAN_STA_IBSS)
9880 ucIsUnicast = !(((tANI_U8 *)pvPeekData)[0] & 0x01);
9881 else
9882 ucIsUnicast = 1;
9883
9884 *puFastFwdOK = (v_U32_t) WLANHAL_TxBdFastFwd(pvosGCtx, pvPeekData, pMetaInfo->ucTID, ucIsUnicast, pvBDHeader, usPktLen );
9885
9886 /* Can't be fast forwarded. Trim the VOS head back to original location. */
9887 if(! *puFastFwdOK){
9888 vos_pkt_trim_head(vosDataBuff, ucDxEBDWLANHeaderLen);
9889 }else{
9890 /* could be fast forwarded. Now notify BAL DxE header filling could be completely skipped
9891 */
9892 v_U32_t uPacketSize = WLANTL_BD_HEADER_LEN(0) + usPktLen;
9893 vos_pkt_set_user_data_ptr( vosDataBuff, VOS_PKT_USER_DATA_ID_BAL,
9894 (v_PVOID_t)uPacketSize);
9895 pDxEHeader->size = SWAP_ENDIAN_UINT32(uPacketSize);
9896 }
9897 *pvosStatus = VOS_STATUS_SUCCESS;
9898 return;
9899}
9900#endif /*WLAN_PERF*/
9901#endif
9902
9903#if 0
9904/*==========================================================================
9905 FUNCTION WLANTL_PrepareBDHeader
9906
9907 DESCRIPTION
9908 Inline function for preparing BD header before HAL processing.
9909
9910 DEPENDENCIES
9911 Just notify HAL that suspend in TL is complete.
9912
9913 PARAMETERS
9914
9915 IN
9916 vosDataBuff: vos data buffer
9917 ucDisableFrmXtl: is frame xtl disabled
9918
9919 OUT
9920 ppvBDHeader: it will contain the BD header
9921 pvDestMacAdddr: it will contain the destination MAC address
9922 pvosStatus: status of the combined processing
9923 pusPktLen: packet len.
9924
9925 RETURN VALUE
9926 No return.
9927
9928 SIDE EFFECTS
9929
9930============================================================================*/
9931void
9932WLANTL_PrepareBDHeader
9933(
9934 vos_pkt_t* vosDataBuff,
9935 v_PVOID_t* ppvBDHeader,
9936 v_MACADDR_t* pvDestMacAdddr,
9937 v_U8_t ucDisableFrmXtl,
9938 VOS_STATUS* pvosStatus,
9939 v_U16_t* pusPktLen,
9940 v_U8_t ucQosEnabled,
9941 v_U8_t ucWDSEnabled,
9942 v_U8_t extraHeadSpace
9943)
9944{
9945 v_U8_t ucHeaderOffset;
9946 v_U8_t ucHeaderLen;
Jeff Johnson295189b2012-06-20 16:38:30 -07009947 v_U8_t ucBDHeaderLen = WLANTL_BD_HEADER_LEN(ucDisableFrmXtl);
9948
9949 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
9950 /*-------------------------------------------------------------------------
9951 Get header pointer from VOSS
9952 !!! make sure reserve head zeros out the memory
9953 -------------------------------------------------------------------------*/
9954 vos_pkt_get_packet_length( vosDataBuff, pusPktLen);
9955
9956 if ( WLANTL_MAC_HEADER_LEN(ucDisableFrmXtl) > *pusPktLen )
9957 {
9958 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9959 "WLAN TL: Length of the packet smaller than expected network"
9960 " header %d", *pusPktLen ));
9961
9962 *pvosStatus = VOS_STATUS_E_INVAL;
9963 return;
9964 }
9965
9966 vos_pkt_reserve_head( vosDataBuff, ppvBDHeader,
9967 ucBDHeaderLen );
9968 if ( NULL == *ppvBDHeader )
9969 {
9970 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9971 "WLAN TL:VOSS packet corrupted on Attach BD header"));
9972 *pvosStatus = VOS_STATUS_E_INVAL;
9973 return;
9974 }
9975
9976 /*-----------------------------------------------------------------------
9977 Extract MAC address
9978 -----------------------------------------------------------------------*/
Jeff Johnson295189b2012-06-20 16:38:30 -07009979 {
9980 v_SIZE_t usMacAddrSize = VOS_MAC_ADDR_SIZE;
9981 *pvosStatus = vos_pkt_extract_data( vosDataBuff,
9982 ucBDHeaderLen +
9983 WLANTL_MAC_ADDR_ALIGN(ucDisableFrmXtl),
9984 (v_PVOID_t)pvDestMacAdddr,
9985 &usMacAddrSize );
9986 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009987 if ( VOS_STATUS_SUCCESS != *pvosStatus )
9988 {
9989 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9990 "WLAN TL:Failed while attempting to extract MAC Addr %d",
9991 *pvosStatus));
9992 }
9993 else
9994 {
9995 /*---------------------------------------------------------------------
9996 Fill MPDU info fields:
9997 - MPDU data start offset
9998 - MPDU header start offset
9999 - MPDU header length
10000 - MPDU length - this is a 16b field - needs swapping
10001 --------------------------------------------------------------------*/
10002 ucHeaderOffset = ucBDHeaderLen;
10003 ucHeaderLen = WLANTL_MAC_HEADER_LEN(ucDisableFrmXtl);
10004
10005 if ( 0 != ucDisableFrmXtl )
10006 {
10007 if ( 0 != ucQosEnabled )
10008 {
10009 ucHeaderLen += WLANTL_802_11_HEADER_QOS_CTL;
10010 }
10011
10012 // Similar to Qos we need something for WDS format !
10013 if ( ucWDSEnabled != 0 )
10014 {
10015 // If we have frame translation enabled
10016 ucHeaderLen += WLANTL_802_11_HEADER_ADDR4_LEN;
10017 }
10018 if ( extraHeadSpace != 0 )
10019 {
10020 // Decrease the packet length with the extra padding after the header
10021 *pusPktLen = *pusPktLen - extraHeadSpace;
10022 }
10023 }
10024
10025 WLANHAL_TX_BD_SET_MPDU_HEADER_LEN( *ppvBDHeader, ucHeaderLen);
10026 WLANHAL_TX_BD_SET_MPDU_HEADER_OFFSET( *ppvBDHeader, ucHeaderOffset);
10027 WLANHAL_TX_BD_SET_MPDU_DATA_OFFSET( *ppvBDHeader,
10028 ucHeaderOffset + ucHeaderLen + extraHeadSpace);
10029 WLANHAL_TX_BD_SET_MPDU_LEN( *ppvBDHeader, *pusPktLen);
10030
10031 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
10032 "WLAN TL: VALUES ARE HLen=%x Hoff=%x doff=%x len=%x ex=%d",
10033 ucHeaderLen, ucHeaderOffset,
10034 (ucHeaderOffset + ucHeaderLen + extraHeadSpace),
10035 *pusPktLen, extraHeadSpace));
10036 }/* if peek MAC success*/
10037
10038}/* WLANTL_PrepareBDHeader */
10039#endif
10040
Jeff Johnson295189b2012-06-20 16:38:30 -070010041//THIS IS A HACK AND NEEDS TO BE FIXED FOR CONCURRENCY
10042/*==========================================================================
10043 FUNCTION WLAN_TLGetNextTxIds
10044
10045 DESCRIPTION
10046 Gets the next station and next AC in the list that should be served by the TL.
10047
10048 Multiple Station Scheduling and TL queue management.
10049
10050 4 HDD BC/MC data packet queue status is specified as Station 0's status. Weights used
10051 in WFQ algorith are initialized in WLANTL_OPEN and contained in tlConfigInfo field.
10052 Each station has fields of ucPktPending and AC mask to tell whether a AC has traffic
10053 or not.
10054
10055 Stations are served in a round-robin fashion from highest priority to lowest priority.
10056 The number of round-robin times of each prioirty equals to the WFQ weights and differetiates
10057 the traffic of different prioirty. As such, stations can not provide low priority packets if
10058 high priority packets are all served.
10059
10060 DEPENDENCIES
10061
10062 PARAMETERS
10063
10064 IN
10065 pvosGCtx: pointer to the global vos context; a handle to TL's
10066 control block can be extracted from its context
10067
10068 OUT
10069 pucSTAId: Station ID
10070
10071 RETURN VALUE
10072 The result code associated with performing the operation
10073
10074 VOS_STATUS_SUCCESS: Everything is good
10075
10076 SIDE EFFECTS
10077
10078 TL context contains currently served station ID in ucCurrentSTA field, currently served AC
10079 in uCurServedAC field, and unserved weights of current AC in uCurLeftWeight.
10080 When existing from the function, these three fields are changed accordingly.
10081
10082============================================================================*/
10083VOS_STATUS
10084WLAN_TLAPGetNextTxIds
10085(
10086 v_PVOID_t pvosGCtx,
10087 v_U8_t* pucSTAId
10088)
10089{
10090 WLANTL_CbType* pTLCb;
10091 v_U8_t ucACFilter = 1;
10092 v_U8_t ucNextSTA ;
10093 v_BOOL_t isServed = TRUE; //current round has find a packet or not
10094 v_U8_t ucACLoopNum = WLANTL_AC_VO + 1; //number of loop to go
10095 v_U8_t uFlowMask; // TX FlowMask from WDA
10096 uint8 ucACMask;
Gopichand Nakkala96237bc2013-01-04 12:20:29 -080010097 uint8 i = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070010098 /*------------------------------------------------------------------------
10099 Extract TL control block
10100 ------------------------------------------------------------------------*/
10101 //ENTER();
10102
10103 pTLCb = VOS_GET_TL_CB(pvosGCtx);
10104 if ( NULL == pTLCb )
10105 {
10106 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
10107 "WLAN TL:Invalid TL pointer from pvosGCtx on WLAN_TLAPGetNextTxIds"));
10108 return VOS_STATUS_E_FAULT;
10109 }
10110
10111 if ( VOS_STATUS_SUCCESS != WDA_DS_GetTxFlowMask( pvosGCtx, &uFlowMask ) )
10112 {
10113 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
10114 "WLAN TL:Failed to retrieve Flow control mask from WDA"));
10115 return VOS_STATUS_E_FAULT;
10116 }
10117
10118 ucNextSTA = pTLCb->ucCurrentSTA;
10119
10120 ++ucNextSTA;
10121
10122 if ( WLAN_MAX_STA_COUNT <= ucNextSTA )
10123 {
10124 //one round is done.
10125 ucNextSTA = 0;
10126 pTLCb->ucCurLeftWeight--;
10127 isServed = FALSE;
10128 if ( 0 == pTLCb->ucCurLeftWeight )
10129 {
10130 //current prioirty is done
10131 if ( WLANTL_AC_BK == (WLANTL_ACEnumType)pTLCb->uCurServedAC )
10132 {
10133 //end of current VO, VI, BE, BK loop. Reset priority.
10134 pTLCb->uCurServedAC = WLANTL_AC_VO;
10135 }
10136 else
10137 {
10138 pTLCb->uCurServedAC --;
10139 }
10140
10141 pTLCb->ucCurLeftWeight = pTLCb->tlConfigInfo.ucAcWeights[pTLCb->uCurServedAC];
10142
10143 } // (0 == pTLCb->ucCurLeftWeight)
10144 } //( WLAN_MAX_STA_COUNT == ucNextSTA )
10145
10146 //decide how many loops to go. if current loop is partial, do one extra to make sure
10147 //we cover every station
10148 if ((1 == pTLCb->ucCurLeftWeight) && (ucNextSTA != 0))
10149 {
10150 ucACLoopNum ++; // now is 5 loops
10151 }
10152
10153 /* Start with highest priority. ucNextSTA, pTLCb->uCurServedAC, pTLCb->ucCurLeftWeight
10154 all have previous values.*/
10155 for (; ucACLoopNum > 0; ucACLoopNum--)
10156 {
10157
10158 ucACFilter = 1 << pTLCb->uCurServedAC;
10159
10160 // pTLCb->ucCurLeftWeight keeps previous results.
10161 for (; (pTLCb->ucCurLeftWeight > 0) && (uFlowMask & ucACFilter); pTLCb->ucCurLeftWeight-- )
10162 {
10163
10164 for ( ; ucNextSTA < WLAN_MAX_STA_COUNT; ucNextSTA ++ )
10165 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053010166 if(NULL == pTLCb->atlSTAClients[ucNextSTA])
10167 {
10168 continue;
10169 }
10170 WLAN_TL_AC_ARRAY_2_MASK (pTLCb->atlSTAClients[ucNextSTA], ucACMask, i);
Jeff Johnson295189b2012-06-20 16:38:30 -070010171
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053010172 if ( (0 == pTLCb->atlSTAClients[ucNextSTA]->ucExists) ||
10173 ((0 == pTLCb->atlSTAClients[ucNextSTA]->ucPktPending) && !(ucACMask)) ||
Jeff Johnson295189b2012-06-20 16:38:30 -070010174 (0 == (ucACMask & ucACFilter)) )
10175
10176 {
Tushnim Bhattacharyya39a8f182013-02-20 18:10:30 -080010177 //current station does not exist or have any packet to serve.
10178 continue;
10179 }
10180
10181 if (WLANTL_STA_AUTHENTICATED != pTLCb->atlSTAClients[ucNextSTA]->tlState)
10182 {
10183 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
10184 "%s Sta %d not in auth state so skipping it.",
10185 __func__, ucNextSTA));
Jeff Johnson295189b2012-06-20 16:38:30 -070010186 continue;
10187 }
10188
10189 //go to next station if current station can't send due to flow control
10190 //Station is allowed to send when it is not in LWM mode. When station is in LWM mode,
10191 //station is allowed to send only after FW reports FW memory is below threshold and on-fly
10192 //packets are less then allowed value
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053010193 if ( (TRUE == pTLCb->atlSTAClients[ucNextSTA]->ucLwmModeEnabled) &&
10194 ((FALSE == pTLCb->atlSTAClients[ucNextSTA]->ucLwmEventReported) ||
10195 (0 < pTLCb->atlSTAClients[ucNextSTA]->uBuffThresholdMax))
Jeff Johnson295189b2012-06-20 16:38:30 -070010196 )
10197 {
10198 continue;
10199 }
10200
10201
10202 // Find a station. Weight is updated already.
10203 *pucSTAId = ucNextSTA;
10204 pTLCb->ucCurrentSTA = ucNextSTA;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053010205 pTLCb->atlSTAClients[*pucSTAId]->ucCurrentAC = pTLCb->uCurServedAC;
Jeff Johnson295189b2012-06-20 16:38:30 -070010206
10207 TLLOG4(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_LOW,
10208 " TL serve one station AC: %d W: %d StaId: %d",
10209 pTLCb->uCurServedAC, pTLCb->ucCurLeftWeight, pTLCb->ucCurrentSTA ));
10210
10211 return VOS_STATUS_SUCCESS;
10212 } //STA loop
10213
10214 ucNextSTA = 0;
10215 if ( FALSE == isServed )
10216 {
10217 //current loop finds no packet.no need to repeat for the same priority
10218 break;
10219 }
10220 //current loop is partial loop. go for one more loop.
10221 isServed = FALSE;
10222
10223 } //Weight loop
10224
10225 if (WLANTL_AC_BK == pTLCb->uCurServedAC)
10226 {
10227 pTLCb->uCurServedAC = WLANTL_AC_VO;
10228 }
10229 else
10230 {
10231 pTLCb->uCurServedAC--;
10232 }
10233 pTLCb->ucCurLeftWeight = pTLCb->tlConfigInfo.ucAcWeights[pTLCb->uCurServedAC];
10234
10235 }// AC loop
10236
10237 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
Arif Hussainf2b00992013-11-17 21:46:15 -080010238 " TL can't find one station to serve" ));
Jeff Johnson295189b2012-06-20 16:38:30 -070010239
10240 pTLCb->uCurServedAC = WLANTL_AC_BK;
10241 pTLCb->ucCurLeftWeight = 1;
10242 //invalid number will be captured by caller
10243 pTLCb->ucCurrentSTA = WLAN_MAX_STA_COUNT;
10244
10245 *pucSTAId = pTLCb->ucCurrentSTA;
Jeff Johnson295189b2012-06-20 16:38:30 -070010246 return VOS_STATUS_E_FAULT;
10247}
10248
10249
10250/*==========================================================================
10251 FUNCTION WLAN_TLGetNextTxIds
10252
10253 DESCRIPTION
10254 Gets the next station and next AC in the list
10255
10256 DEPENDENCIES
10257
10258 PARAMETERS
10259
10260 IN
10261 pvosGCtx: pointer to the global vos context; a handle to TL's
10262 control block can be extracted from its context
10263
10264 OUT
10265 pucSTAId: Station ID
10266
10267
10268 RETURN VALUE
10269 The result code associated with performing the operation
10270
10271 VOS_STATUS_SUCCESS: Everything is good :)
10272
10273 SIDE EFFECTS
10274
10275============================================================================*/
10276VOS_STATUS
10277WLAN_TLGetNextTxIds
10278(
10279 v_PVOID_t pvosGCtx,
10280 v_U8_t* pucSTAId
10281)
10282{
10283 WLANTL_CbType* pTLCb;
10284 v_U8_t ucNextAC;
10285 v_U8_t ucNextSTA;
10286 v_U8_t ucCount;
10287 v_U8_t uFlowMask; // TX FlowMask from WDA
10288 v_U8_t ucACMask = 0;
10289 v_U8_t i = 0;
10290
10291 tBssSystemRole systemRole; //RG HACK to be removed
10292 tpAniSirGlobal pMac;
10293
10294 pMac = vos_get_context(VOS_MODULE_ID_PE, pvosGCtx);
10295 if ( NULL == pMac )
10296 {
10297 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070010298 "%s: Invalid pMac", __func__));
Jeff Johnson295189b2012-06-20 16:38:30 -070010299 return VOS_STATUS_E_FAULT;
10300 }
10301
10302 systemRole = wdaGetGlobalSystemRole(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -070010303
Jeff Johnson295189b2012-06-20 16:38:30 -070010304 /*------------------------------------------------------------------------
10305 Extract TL control block
10306 ------------------------------------------------------------------------*/
10307 pTLCb = VOS_GET_TL_CB(pvosGCtx);
10308 if ( NULL == pTLCb )
10309 {
10310 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
10311 "WLAN TL:Invalid TL pointer from pvosGCtx on WLAN_TLGetNextTxIds"));
10312 return VOS_STATUS_E_FAULT;
10313 }
10314
Sunil Ravid5406f22013-01-22 00:18:31 -080010315#ifdef FEATURE_WLAN_TDLS
10316 if ((eSYSTEM_AP_ROLE == systemRole) || (vos_concurrent_sessions_running()) || pTLCb->ucTdlsPeerCount)
10317#else
10318 if ((eSYSTEM_AP_ROLE == systemRole) || (vos_concurrent_sessions_running()))
10319#endif
10320 {
10321 return WLAN_TLAPGetNextTxIds(pvosGCtx,pucSTAId);
10322 }
10323
10324
Jeff Johnson295189b2012-06-20 16:38:30 -070010325 if ( VOS_STATUS_SUCCESS != WDA_DS_GetTxFlowMask( pvosGCtx, &uFlowMask ) )
10326 {
10327 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
10328 "WLAN TL:Failed to retrieve Flow control mask from WDA"));
10329 return VOS_STATUS_E_FAULT;
10330 }
10331
10332 /*STA id - no priority yet implemented */
10333 /*-----------------------------------------------------------------------
10334 Choose the next STA for tx - for now go in a round robin fashion
10335 through all the stations that have pending packets
10336 -------------------------------------------------------------------------*/
10337 ucNextSTA = pTLCb->ucCurrentSTA;
10338
10339 pTLCb->ucCurrentSTA = WLAN_MAX_STA_COUNT;
10340 for ( ucCount = 0;
10341 ucCount < WLAN_MAX_STA_COUNT;
10342 ucCount++ )
10343 {
10344 ucNextSTA = ( (ucNextSTA+1) >= WLAN_MAX_STA_COUNT )?0:(ucNextSTA+1);
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053010345 if(NULL == pTLCb->atlSTAClients[ucNextSTA])
10346 {
10347 continue;
10348 }
10349 if (( pTLCb->atlSTAClients[ucNextSTA]->ucExists ) &&
10350 ( pTLCb->atlSTAClients[ucNextSTA]->ucPktPending ))
Jeff Johnson295189b2012-06-20 16:38:30 -070010351 {
Tushnim Bhattacharyya39a8f182013-02-20 18:10:30 -080010352 if (WLANTL_STA_AUTHENTICATED == pTLCb->atlSTAClients[ucNextSTA]->tlState)
10353 {
10354 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
10355 "STA ID: %d on WLAN_TLGetNextTxIds", *pucSTAId));
10356 pTLCb->ucCurrentSTA = ucNextSTA;
10357 break;
Tushnim Bhattacharyya5dd94562013-03-20 20:15:03 -070010358 }
10359 else
10360 {
Tushnim Bhattacharyya39a8f182013-02-20 18:10:30 -080010361 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
10362 "%s Sta %d is not in auth state, skipping this sta.",
10363 __func__, ucNextSTA));
Tushnim Bhattacharyya5dd94562013-03-20 20:15:03 -070010364 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010365 }
10366 }
10367
10368 *pucSTAId = pTLCb->ucCurrentSTA;
10369
10370 if ( WLANTL_STA_ID_INVALID( *pucSTAId ) )
10371 {
10372 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
10373 "WLAN TL:No station registered with TL at this point"));
10374
10375 return VOS_STATUS_E_FAULT;
10376
10377 }
10378
10379 /*Convert the array to a mask for easier operation*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053010380 WLAN_TL_AC_ARRAY_2_MASK( pTLCb->atlSTAClients[*pucSTAId], ucACMask, i);
Jeff Johnson295189b2012-06-20 16:38:30 -070010381
10382 if ( 0 == ucACMask )
10383 {
10384 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
10385 "WLAN TL: Mask 0 "
10386 "STA ID: %d on WLAN_TLGetNextTxIds", *pucSTAId));
10387
10388 /*setting STA id to invalid if mask is 0*/
10389 *pucSTAId = WLAN_MAX_STA_COUNT;
10390
10391 return VOS_STATUS_E_FAULT;
10392 }
10393
10394 /*-----------------------------------------------------------------------
10395 AC is updated whenever a packet is fetched from HDD -> the current
10396 weight of such an AC cannot be 0 -> in this case TL is expected to
10397 exit this function at this point during the main Tx loop
10398 -----------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053010399 if ( 0 < pTLCb->atlSTAClients[*pucSTAId]->ucCurrentWeight )
Jeff Johnson295189b2012-06-20 16:38:30 -070010400 {
10401 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
10402 "WLAN TL: Maintaining serviced AC to: %d for Weight: %d",
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053010403 pTLCb->atlSTAClients[*pucSTAId]->ucCurrentAC ,
10404 pTLCb->atlSTAClients[*pucSTAId]->ucCurrentWeight));
Jeff Johnson295189b2012-06-20 16:38:30 -070010405 return VOS_STATUS_SUCCESS;
10406 }
10407
10408 /*-----------------------------------------------------------------------
10409 Choose highest priority AC - !!! optimize me
10410 -----------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053010411 ucNextAC = pTLCb->atlSTAClients[*pucSTAId]->ucCurrentAC;
Jeff Johnson295189b2012-06-20 16:38:30 -070010412 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
10413 "Next AC: %d", ucNextAC));
10414
10415 while ( 0 != ucACMask )
10416 {
10417 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
10418 " AC Mask: %d Next: %d Res : %d",
10419 ucACMask, ( 1 << ucNextAC ), ( ucACMask & ( 1 << ucNextAC ))));
10420
10421 if ( 0 != ( ucACMask & ( 1 << ucNextAC ) & uFlowMask ))
10422 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053010423 pTLCb->atlSTAClients[*pucSTAId]->ucCurrentAC =
Jeff Johnson295189b2012-06-20 16:38:30 -070010424 (WLANTL_ACEnumType)ucNextAC;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053010425 pTLCb->atlSTAClients[*pucSTAId]->ucCurrentWeight =
Jeff Johnson295189b2012-06-20 16:38:30 -070010426 pTLCb->tlConfigInfo.ucAcWeights[ucNextAC];
10427
10428 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
10429 "WLAN TL: Switching serviced AC to: %d with Weight: %d",
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053010430 pTLCb->atlSTAClients[*pucSTAId]->ucCurrentAC ,
10431 pTLCb->atlSTAClients[*pucSTAId]->ucCurrentWeight));
Jeff Johnson295189b2012-06-20 16:38:30 -070010432 break;
10433 }
10434
10435 ucNextAC = ( ucNextAC - 1 ) & WLANTL_MASK_AC;
10436
10437 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
10438 "Next AC %d", ucNextAC));
10439
10440 }
10441
10442 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
10443 " C AC: %d C W: %d",
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053010444 pTLCb->atlSTAClients[*pucSTAId]->ucCurrentAC,
10445 pTLCb->atlSTAClients[*pucSTAId]->ucCurrentWeight));
Jeff Johnson295189b2012-06-20 16:38:30 -070010446
10447 return VOS_STATUS_SUCCESS;
10448}/* WLAN_TLGetNextTxIds */
10449
Jeff Johnson295189b2012-06-20 16:38:30 -070010450
10451
10452/*==========================================================================
10453 DEFAULT HANDLERS: Registered at initialization with TL
10454 ==========================================================================*/
10455
10456/*==========================================================================
10457
10458 FUNCTION WLANTL_MgmtFrmRxDefaultCb
10459
10460 DESCRIPTION
10461 Default Mgmt Frm rx callback: asserts all the time. If this function gets
10462 called it means there is no registered rx cb pointer for Mgmt Frm.
10463
10464 DEPENDENCIES
10465
10466 PARAMETERS
10467 Not used.
10468
10469 RETURN VALUE
10470
10471 VOS_STATUS_E_FAILURE: Always FAILURE.
10472
10473============================================================================*/
10474VOS_STATUS
10475WLANTL_MgmtFrmRxDefaultCb
10476(
10477 v_PVOID_t pvosGCtx,
10478 v_PVOID_t vosBuff
10479)
10480{
10481 if ( NULL != vosBuff )
10482 {
10483 TLLOGP(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_FATAL,
10484 "WLAN TL:Fatal failure: No registered Mgmt Frm client on pkt RX"));
10485 /* Drop packet */
10486 vos_pkt_return_packet((vos_pkt_t *)vosBuff);
10487 }
10488
Jeff Johnson295189b2012-06-20 16:38:30 -070010489 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
10490 "WLAN TL: No registered Mgmt Frm client on pkt RX. Load/Unload in progress, Ignore"));
Jeff Johnson295189b2012-06-20 16:38:30 -070010491
10492 return VOS_STATUS_E_FAILURE;
10493}/*WLANTL_MgmtFrmRxDefaultCb*/
10494
10495/*==========================================================================
10496
Madan Mohan Koyyalamudi6c2977d2013-09-04 15:42:45 +053010497 FUNCTION WLANTL_BAPRxDefaultCb
Jeff Johnson295189b2012-06-20 16:38:30 -070010498
10499 DESCRIPTION
10500 Default BAP rx callback: asserts all the time. If this function gets
10501 called it means there is no registered rx cb pointer for BAP.
10502
10503 DEPENDENCIES
10504
10505 PARAMETERS
10506 Not used.
10507
10508 RETURN VALUE
10509
10510 VOS_STATUS_E_FAILURE: Always FAILURE.
10511
10512============================================================================*/
10513VOS_STATUS
10514WLANTL_BAPRxDefaultCb
10515(
10516 v_PVOID_t pvosGCtx,
10517 vos_pkt_t* vosDataBuff,
10518 WLANTL_BAPFrameEnumType frameType
10519)
10520{
10521 TLLOGP(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_FATAL,
10522 "WLAN TL:Fatal failure: No registered BAP client on BAP pkt RX"));
10523#ifndef BTAMP_TEST
10524 VOS_ASSERT(0);
10525#endif
10526 return VOS_STATUS_E_FAILURE;
10527}/*WLANTL_MgmtFrmRxDefaultCb*/
10528
10529/*==========================================================================
10530
10531 FUNCTION WLANTL_STARxDefaultCb
10532
10533 DESCRIPTION
10534 Default STA rx callback: asserts all the time. If this function gets
10535 called it means there is no registered rx cb pointer for station.
10536 (Mem corruption most likely, it should never happen)
10537
10538 DEPENDENCIES
10539
10540 PARAMETERS
10541 Not used.
10542
10543 RETURN VALUE
10544
10545 VOS_STATUS_E_FAILURE: Always FAILURE.
10546
10547============================================================================*/
10548VOS_STATUS
10549WLANTL_STARxDefaultCb
10550(
10551 v_PVOID_t pvosGCtx,
10552 vos_pkt_t* vosDataBuff,
10553 v_U8_t ucSTAId,
10554 WLANTL_RxMetaInfoType* pRxMetaInfo
10555)
10556{
10557 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
10558 "WLAN TL: No registered STA client rx cb for STAID: %d dropping pkt",
10559 ucSTAId));
10560 vos_pkt_return_packet(vosDataBuff);
Madan Mohan Koyyalamudi6c2977d2013-09-04 15:42:45 +053010561 return VOS_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070010562}/*WLANTL_MgmtFrmRxDefaultCb*/
10563
10564
10565/*==========================================================================
10566
10567 FUNCTION WLANTL_STAFetchPktDefaultCb
10568
10569 DESCRIPTION
10570 Default fetch callback: asserts all the time. If this function gets
10571 called it means there is no registered fetch cb pointer for station.
10572 (Mem corruption most likely, it should never happen)
10573
10574 DEPENDENCIES
10575
10576 PARAMETERS
10577 Not used.
10578
10579 RETURN VALUE
10580
10581 VOS_STATUS_E_FAILURE: Always FAILURE.
10582
10583============================================================================*/
10584VOS_STATUS
10585WLANTL_STAFetchPktDefaultCb
10586(
10587 v_PVOID_t pvosGCtx,
10588 v_U8_t* pucSTAId,
10589 WLANTL_ACEnumType ucAC,
10590 vos_pkt_t** vosDataBuff,
10591 WLANTL_MetaInfoType* tlMetaInfo
10592)
10593{
10594 TLLOGP(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_FATAL,
10595 "WLAN TL:Fatal failure: No registered STA client on data pkt RX"));
10596 VOS_ASSERT(0);
10597 return VOS_STATUS_E_FAILURE;
10598}/*WLANTL_MgmtFrmRxDefaultCb*/
10599
10600/*==========================================================================
10601
10602 FUNCTION WLANTL_TxCompDefaultCb
10603
10604 DESCRIPTION
10605 Default tx complete handler. It will release the completed pkt to
10606 prevent memory leaks.
10607
10608 PARAMETERS
10609
10610 IN
10611 pvosGCtx: pointer to the global vos context; a handle to
10612 TL/HAL/PE/BAP/HDD control block can be extracted from
10613 its context
10614 vosDataBuff: pointer to the VOSS data buffer that was transmitted
10615 wTxSTAtus: status of the transmission
10616
10617
10618 RETURN VALUE
10619 The result code associated with performing the operation; please
10620 check vos_pkt_return_packet for possible error codes.
10621
10622 Please check vos_pkt_return_packet API for possible return values.
10623
10624============================================================================*/
10625VOS_STATUS
10626WLANTL_TxCompDefaultCb
10627(
10628 v_PVOID_t pvosGCtx,
10629 vos_pkt_t* vosDataBuff,
10630 VOS_STATUS wTxSTAtus
10631)
10632{
10633 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
10634 "WLAN TL:TXComp not registered, releasing pkt to prevent mem leak"));
10635 return vos_pkt_return_packet(vosDataBuff);
10636}/*WLANTL_TxCompDefaultCb*/
10637
10638
10639/*==========================================================================
10640 Cleanup functions
10641 ==========================================================================*/
10642
10643/*==========================================================================
10644
10645 FUNCTION WLANTL_CleanCB
10646
10647 DESCRIPTION
10648 Cleans TL control block
10649
10650 DEPENDENCIES
10651
10652 PARAMETERS
10653
10654 IN
10655 pTLCb: pointer to TL's control block
10656 ucEmpty: set if TL has to clean up the queues and release pedning pkts
10657
10658 RETURN VALUE
10659 The result code associated with performing the operation
10660
10661 VOS_STATUS_E_INVAL: invalid input parameters
10662 VOS_STATUS_SUCCESS: Everything is good :)
10663
10664 SIDE EFFECTS
10665
10666============================================================================*/
10667VOS_STATUS
10668WLANTL_CleanCB
10669(
10670 WLANTL_CbType* pTLCb,
10671 v_U8_t ucEmpty
10672)
10673{
10674 v_U8_t ucIndex;
10675 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
10676
10677 /*-------------------------------------------------------------------------
10678 Sanity check
10679 -------------------------------------------------------------------------*/
10680 if ( NULL == pTLCb )
10681 {
10682 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
10683 "WLAN TL:Invalid parameter sent on WLANTL_CleanCB"));
10684 return VOS_STATUS_E_INVAL;
10685 }
10686
10687 /* number of packets sent to BAL waiting for tx complete confirmation */
10688 pTLCb->usPendingTxCompleteCount = 0;
10689
10690 /* global suspend flag */
10691 vos_atomic_set_U8( &pTLCb->ucTxSuspended, 1);
10692
10693 /* resource flag */
10694 pTLCb->uResCount = 0;
10695
10696
10697 /*-------------------------------------------------------------------------
10698 Client stations
10699 -------------------------------------------------------------------------*/
10700 for ( ucIndex = 0; ucIndex < WLAN_MAX_STA_COUNT ; ucIndex++)
10701 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053010702 if(NULL != pTLCb->atlSTAClients[ucIndex])
10703 {
10704 WLANTL_CleanSTA( pTLCb->atlSTAClients[ucIndex], ucEmpty);
10705 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010706 }
10707
10708 /*-------------------------------------------------------------------------
10709 Management Frame client
10710 -------------------------------------------------------------------------*/
10711 pTLCb->tlMgmtFrmClient.ucExists = 0;
10712
10713 if ( ( 0 != ucEmpty) &&
10714 ( NULL != pTLCb->tlMgmtFrmClient.vosPendingDataBuff ))
10715 {
10716 vos_pkt_return_packet(pTLCb->tlMgmtFrmClient.vosPendingDataBuff);
10717 }
10718
10719 pTLCb->tlMgmtFrmClient.vosPendingDataBuff = NULL;
10720
10721 /* set to a default cb in order to prevent constant checking for NULL */
10722 pTLCb->tlMgmtFrmClient.pfnTlMgmtFrmRx = WLANTL_MgmtFrmRxDefaultCb;
10723
10724 /*-------------------------------------------------------------------------
10725 BT AMP client
10726 -------------------------------------------------------------------------*/
10727 pTLCb->tlBAPClient.ucExists = 0;
10728
10729 if (( 0 != ucEmpty) &&
10730 ( NULL != pTLCb->tlBAPClient.vosPendingDataBuff ))
10731 {
10732 vos_pkt_return_packet(pTLCb->tlBAPClient.vosPendingDataBuff);
10733 }
10734
10735 if (( 0 != ucEmpty) &&
10736 ( NULL != pTLCb->vosDummyBuf ))
10737 {
10738 vos_pkt_return_packet(pTLCb->vosDummyBuf);
10739 }
10740
10741 pTLCb->tlBAPClient.vosPendingDataBuff = NULL;
10742
10743 pTLCb->vosDummyBuf = NULL;
10744 pTLCb->vosTempBuf = NULL;
10745 pTLCb->ucCachedSTAId = WLAN_MAX_STA_COUNT;
10746
10747 /* set to a default cb in order to prevent constant checking for NULL */
10748 pTLCb->tlBAPClient.pfnTlBAPRx = WLANTL_BAPRxDefaultCb;
10749
10750 pTLCb->ucRegisteredStaId = WLAN_MAX_STA_COUNT;
10751
10752 return VOS_STATUS_SUCCESS;
10753
10754}/* WLANTL_CleanCB*/
10755
10756/*==========================================================================
10757
10758 FUNCTION WLANTL_CleanSTA
10759
10760 DESCRIPTION
10761 Cleans a station control block.
10762
10763 DEPENDENCIES
10764
10765 PARAMETERS
10766
10767 IN
10768 pvosGCtx: pointer to the global vos context; a handle to TL's
10769 control block can be extracted from its context
10770 ucEmpty: if set the queues and pending pkts will be emptyed
10771
10772 RETURN VALUE
10773 The result code associated with performing the operation
10774
10775 VOS_STATUS_E_INVAL: invalid input parameters
10776 VOS_STATUS_SUCCESS: Everything is good :)
10777
10778 SIDE EFFECTS
10779
10780============================================================================*/
10781VOS_STATUS
10782WLANTL_CleanSTA
10783(
10784 WLANTL_STAClientType* ptlSTAClient,
10785 v_U8_t ucEmpty
10786)
10787{
10788 v_U8_t ucIndex;
10789 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
10790
10791 /*-------------------------------------------------------------------------
10792 Sanity check
10793 -------------------------------------------------------------------------*/
10794 if ( NULL == ptlSTAClient )
10795 {
10796 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
10797 "WLAN TL:Invalid parameter sent on WLANTL_CleanSTA"));
10798 return VOS_STATUS_E_INVAL;
10799 }
10800
10801 /*------------------------------------------------------------------------
10802 Clear station from TL
10803 ------------------------------------------------------------------------*/
10804 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
10805 "WLAN TL: Clearing STA Client ID: %d, Empty flag: %d",
10806 ptlSTAClient->wSTADesc.ucSTAId, ucEmpty ));
10807
10808 ptlSTAClient->pfnSTARx = WLANTL_STARxDefaultCb;
10809 ptlSTAClient->pfnSTATxComp = WLANTL_TxCompDefaultCb;
10810 ptlSTAClient->pfnSTAFetchPkt = WLANTL_STAFetchPktDefaultCb;
10811
10812 ptlSTAClient->tlState = WLANTL_STA_INIT;
10813 ptlSTAClient->tlPri = WLANTL_STA_PRI_NORMAL;
10814
10815 vos_zero_macaddr( &ptlSTAClient->wSTADesc.vSTAMACAddress );
10816 vos_zero_macaddr( &ptlSTAClient->wSTADesc.vBSSIDforIBSS );
10817 vos_zero_macaddr( &ptlSTAClient->wSTADesc.vSelfMACAddress );
10818
10819 ptlSTAClient->wSTADesc.ucSTAId = 0;
10820 ptlSTAClient->wSTADesc.wSTAType = WLAN_STA_MAX;
10821
10822 ptlSTAClient->wSTADesc.ucQosEnabled = 0;
10823 ptlSTAClient->wSTADesc.ucAddRmvLLC = 0;
10824 ptlSTAClient->wSTADesc.ucSwFrameTXXlation = 0;
10825 ptlSTAClient->wSTADesc.ucSwFrameRXXlation = 0;
10826 ptlSTAClient->wSTADesc.ucProtectedFrame = 0;
10827
10828 /*-------------------------------------------------------------------------
10829 AMSDU information for the STA
10830 -------------------------------------------------------------------------*/
10831 if ( ( 0 != ucEmpty ) &&
10832 ( NULL != ptlSTAClient->vosAMSDUChainRoot ))
10833 {
Madan Mohan Koyyalamudic0e5bd82012-09-18 17:12:27 -070010834 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_FATAL,
Jeff Johnson0298bd02013-11-14 19:58:38 -080010835 "WLAN TL:Non NULL vosAMSDUChainRoot on WLANTL_CleanSTA, "
Madan Mohan Koyyalamudic0e5bd82012-09-18 17:12:27 -070010836 "suspecting a memory corruption"));
10837
Jeff Johnson295189b2012-06-20 16:38:30 -070010838 }
10839
10840 ptlSTAClient->vosAMSDUChain = NULL;
10841 ptlSTAClient->vosAMSDUChainRoot = NULL;
10842
10843 vos_mem_zero( (v_PVOID_t)ptlSTAClient->aucMPDUHeader,
10844 WLANTL_MPDU_HEADER_LEN);
10845 ptlSTAClient->ucMPDUHeaderLen = 0;
10846
10847 /*-------------------------------------------------------------------------
10848 Reordering information for the STA
10849 -------------------------------------------------------------------------*/
10850 for ( ucIndex = 0; ucIndex < WLAN_MAX_TID ; ucIndex++)
10851 {
10852 if(0 == ptlSTAClient->atlBAReorderInfo[ucIndex].ucExists)
10853 {
10854 continue;
10855 }
10856 if(NULL != ptlSTAClient->atlBAReorderInfo[ucIndex].reorderBuffer)
10857 {
10858 ptlSTAClient->atlBAReorderInfo[ucIndex].reorderBuffer->isAvailable = VOS_TRUE;
10859 memset(&ptlSTAClient->atlBAReorderInfo[ucIndex].reorderBuffer->arrayBuffer[0], 0, WLANTL_MAX_WINSIZE * sizeof(v_PVOID_t));
10860 }
10861 vos_timer_destroy(&ptlSTAClient->atlBAReorderInfo[ucIndex].agingTimer);
10862 memset(&ptlSTAClient->atlBAReorderInfo[ucIndex], 0, sizeof(WLANTL_BAReorderType));
10863 }
10864
10865 /*-------------------------------------------------------------------------
10866 QOS information for the STA
10867 -------------------------------------------------------------------------*/
10868 ptlSTAClient->ucCurrentAC = WLANTL_AC_VO;
10869 ptlSTAClient->ucCurrentWeight = 0;
10870 ptlSTAClient->ucServicedAC = WLANTL_AC_BK;
10871
10872 vos_mem_zero( ptlSTAClient->aucACMask, sizeof(ptlSTAClient->aucACMask));
10873 vos_mem_zero( &ptlSTAClient->wUAPSDInfo, sizeof(ptlSTAClient->wUAPSDInfo));
10874
10875
10876 /*--------------------------------------------------------------------
10877 Stats info
10878 --------------------------------------------------------------------*/
10879 vos_mem_zero( ptlSTAClient->auRxCount,
10880 sizeof(ptlSTAClient->auRxCount[0])* WLAN_MAX_TID);
10881 vos_mem_zero( ptlSTAClient->auTxCount,
10882 sizeof(ptlSTAClient->auTxCount[0])* WLAN_MAX_TID);
10883 ptlSTAClient->rssiAvg = 0;
10884
10885 /*Tx not suspended and station fully registered*/
10886 vos_atomic_set_U8( &ptlSTAClient->ucTxSuspended, 0);
10887 vos_atomic_set_U8( &ptlSTAClient->ucNoMoreData, 1);
10888
10889 if ( 0 == ucEmpty )
10890 {
10891 ptlSTAClient->wSTADesc.ucUcastSig = WLAN_TL_INVALID_U_SIG;
10892 ptlSTAClient->wSTADesc.ucBcastSig = WLAN_TL_INVALID_B_SIG;
10893 }
10894
10895 ptlSTAClient->ucExists = 0;
10896
10897 /*--------------------------------------------------------------------
10898 Statistics info
10899 --------------------------------------------------------------------*/
10900 memset(&ptlSTAClient->trafficStatistics,
10901 0,
10902 sizeof(WLANTL_TRANSFER_STA_TYPE));
10903
10904 /*fix me!!: add new values from the TL Cb for cleanup */
10905 return VOS_STATUS_SUCCESS;
10906}/* WLANTL_CleanSTA */
10907
10908
10909/*==========================================================================
10910 FUNCTION WLANTL_EnableUAPSDForAC
10911
10912 DESCRIPTION
10913 Called by HDD to enable UAPSD. TL in turn calls WDA API to enable the
10914 logic in FW/SLM to start sending trigger frames. Previously TL had the
10915 trigger frame logic which later moved down to FW. Hence
10916 HDD -> TL -> WDA -> FW call flow.
10917
10918 DEPENDENCIES
10919 The TL must be initialized before this function can be called.
10920
10921 PARAMETERS
10922
10923 IN
10924 pvosGCtx: pointer to the global vos context; a handle to TL's
10925 control block can be extracted from its context
10926 ucSTAId: station Id
10927 ucAC: AC for which U-APSD is being enabled
10928 ucTid: TID for which U-APSD is setup
10929 ucUP: used to place in the trigger frame generation
10930 ucServiceInt: service interval used by TL to send trigger frames
10931 ucSuspendInt: suspend interval used by TL to determine that an
10932 app is idle and should start sending trigg frms less often
10933 wTSDir: direction of TSpec
10934
10935 RETURN VALUE
10936 The result code associated with performing the operation
10937
10938 VOS_STATUS_SUCCESS: Everything is good :)
10939
10940 SIDE EFFECTS
10941
10942============================================================================*/
10943VOS_STATUS
10944WLANTL_EnableUAPSDForAC
10945(
10946 v_PVOID_t pvosGCtx,
10947 v_U8_t ucSTAId,
10948 WLANTL_ACEnumType ucAC,
10949 v_U8_t ucTid,
10950 v_U8_t ucUP,
10951 v_U32_t uServiceInt,
10952 v_U32_t uSuspendInt,
10953 WLANTL_TSDirType wTSDir
10954)
10955{
10956
10957 WLANTL_CbType* pTLCb = NULL;
10958 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
10959 tUapsdInfo halUAPSDInfo;
10960 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
10961
10962 /*------------------------------------------------------------------------
10963 Sanity check
10964 Extract TL control block
10965 ------------------------------------------------------------------------*/
10966 pTLCb = VOS_GET_TL_CB(pvosGCtx);
10967 if (( NULL == pTLCb ) || WLANTL_STA_ID_INVALID( ucSTAId )
Gopichand Nakkala574f6d12013-06-27 19:38:43 +053010968 || WLANTL_AC_INVALID(ucAC))
Jeff Johnson295189b2012-06-20 16:38:30 -070010969 {
10970 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
10971 "WLAN TL:Invalid input params on WLANTL_EnableUAPSDForAC"
Gopichand Nakkala574f6d12013-06-27 19:38:43 +053010972 " TL: %p STA: %d AC: %d",
10973 pTLCb, ucSTAId, ucAC));
Jeff Johnson295189b2012-06-20 16:38:30 -070010974 return VOS_STATUS_E_FAULT;
10975 }
10976
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053010977 if ( NULL == pTLCb->atlSTAClients[ucSTAId] )
10978 {
10979 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
10980 "WLAN TL:Client Memory was not allocated on %s", __func__));
10981 return VOS_STATUS_E_FAILURE;
10982 }
10983
Jeff Johnson295189b2012-06-20 16:38:30 -070010984 /*Set this flag in order to remember that this is a trigger enabled AC*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053010985 pTLCb->atlSTAClients[ucSTAId]->wUAPSDInfo[ucAC].ucSet = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -070010986
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053010987#ifdef FEATURE_WLAN_TDLS
10988 if(pTLCb->atlSTAClients[ucSTAId]->wSTADesc.wSTAType != WLAN_STA_TDLS)
10989#endif
10990 {
10991 if( 0 == uServiceInt )
10992 {
10993 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi198ade32013-09-29 03:52:25 +053010994 "WLAN TL:Input params on WLANTL_EnableUAPSDForAC"
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053010995 " SI: %d", uServiceInt ));
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053010996 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010997
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053010998 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
10999 "WLAN TL:Enabling U-APSD in FW for STA: %d AC: %d SI: %d SPI: %d "
11000 "DI: %d",
11001 ucSTAId, ucAC, uServiceInt, uSuspendInt,
11002 pTLCb->tlConfigInfo.uDelayedTriggerFrmInt));
Jeff Johnson295189b2012-06-20 16:38:30 -070011003
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053011004 /*Save all info for HAL*/
11005 halUAPSDInfo.staidx = ucSTAId;
11006 halUAPSDInfo.ac = ucAC;
11007 halUAPSDInfo.up = ucUP;
11008 halUAPSDInfo.srvInterval = uServiceInt;
11009 halUAPSDInfo.susInterval = uSuspendInt;
11010 halUAPSDInfo.delayInterval = pTLCb->tlConfigInfo.uDelayedTriggerFrmInt;
11011
11012 /*Notify HAL*/
11013 vosStatus = WDA_EnableUapsdAcParams(pvosGCtx, ucSTAId, &halUAPSDInfo);
11014 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011015 return vosStatus;
11016
11017}/*WLANTL_EnableUAPSDForAC*/
11018
11019
11020/*==========================================================================
11021 FUNCTION WLANTL_DisableUAPSDForAC
11022
11023 DESCRIPTION
11024 Called by HDD to disable UAPSD. TL in turn calls WDA API to disable the
11025 logic in FW/SLM to stop sending trigger frames. Previously TL had the
11026 trigger frame logic which later moved down to FW. Hence
11027 HDD -> TL -> WDA -> FW call flow.
11028
11029 DEPENDENCIES
11030 The TL must be initialized before this function can be called.
11031
11032 PARAMETERS
11033
11034 IN
11035 pvosGCtx: pointer to the global vos context; a handle to TL's
11036 control block can be extracted from its context
11037 ucSTAId: station Id
11038 ucAC: AC for which U-APSD is being enabled
11039
11040
11041 RETURN VALUE
11042 The result code associated with performing the operation
11043
11044 VOS_STATUS_SUCCESS: Everything is good :)
11045
11046 SIDE EFFECTS
11047
11048============================================================================*/
11049VOS_STATUS
11050WLANTL_DisableUAPSDForAC
11051(
11052 v_PVOID_t pvosGCtx,
11053 v_U8_t ucSTAId,
11054 WLANTL_ACEnumType ucAC
11055)
11056{
11057 WLANTL_CbType* pTLCb;
11058 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
11059
11060 /*------------------------------------------------------------------------
11061 Sanity check
11062 Extract TL control block
11063 ------------------------------------------------------------------------*/
11064 pTLCb = VOS_GET_TL_CB(pvosGCtx);
11065 if (( NULL == pTLCb ) || WLANTL_STA_ID_INVALID( ucSTAId )
11066 || WLANTL_AC_INVALID(ucAC) )
11067 {
11068 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11069 "WLAN TL:Invalid input params on WLANTL_DisableUAPSDForAC"
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +053011070 " TL: %p STA: %d AC: %d", pTLCb, ucSTAId, ucAC ));
Jeff Johnson295189b2012-06-20 16:38:30 -070011071 return VOS_STATUS_E_FAULT;
11072 }
11073
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053011074 if ( NULL == pTLCb->atlSTAClients[ucSTAId] )
11075 {
11076 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11077 "WLAN TL:Client Memory was not allocated on %s", __func__));
11078 return VOS_STATUS_E_FAILURE;
11079 }
11080
Jeff Johnson295189b2012-06-20 16:38:30 -070011081 /*Reset this flag as this is no longer a trigger enabled AC*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053011082 pTLCb->atlSTAClients[ucSTAId]->wUAPSDInfo[ucAC].ucSet = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -070011083
11084 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
11085 "WLAN TL:Disabling U-APSD in FW for STA: %d AC: %d ",
11086 ucSTAId, ucAC));
11087
11088 /*Notify HAL*/
11089 WDA_DisableUapsdAcParams(pvosGCtx, ucSTAId, ucAC);
11090
11091 return VOS_STATUS_SUCCESS;
11092}/* WLANTL_DisableUAPSDForAC */
11093
11094#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
11095/*==========================================================================
11096 FUNCTION WLANTL_RegRSSIIndicationCB
11097
11098 DESCRIPTION Registration function to get notification if RSSI cross
11099 threshold.
11100 Client should register threshold, direction, and notification
11101 callback function pointer
11102
11103 DEPENDENCIES NONE
11104
11105 PARAMETERS in pAdapter - Global handle
11106 in rssiValue - RSSI threshold value
11107 in triggerEvent - Cross direction should be notified
11108 UP, DOWN, and CROSS
11109 in crossCBFunction - Notification CB Function
11110 in usrCtxt - user context
11111
11112 RETURN VALUE VOS_STATUS
11113
11114 SIDE EFFECTS NONE
11115
11116============================================================================*/
11117VOS_STATUS WLANTL_RegRSSIIndicationCB
11118(
11119 v_PVOID_t pAdapter,
11120 v_S7_t rssiValue,
11121 v_U8_t triggerEvent,
11122 WLANTL_RSSICrossThresholdCBType crossCBFunction,
11123 VOS_MODULE_ID moduleID,
11124 v_PVOID_t usrCtxt
11125)
11126{
11127 VOS_STATUS status = VOS_STATUS_SUCCESS;
11128
11129 status = WLANTL_HSRegRSSIIndicationCB(pAdapter,
11130 rssiValue,
11131 triggerEvent,
11132 crossCBFunction,
11133 moduleID,
11134 usrCtxt);
11135
11136 return status;
11137}
11138
11139/*==========================================================================
11140 FUNCTION WLANTL_DeregRSSIIndicationCB
11141
11142 DESCRIPTION Remove specific threshold from list
11143
11144 DEPENDENCIES NONE
11145
11146 PARAMETERS in pAdapter - Global handle
11147 in rssiValue - RSSI threshold value
11148 in triggerEvent - Cross direction should be notified
11149 UP, DOWN, and CROSS
11150
11151 RETURN VALUE VOS_STATUS
11152
11153 SIDE EFFECTS NONE
11154
11155============================================================================*/
11156VOS_STATUS WLANTL_DeregRSSIIndicationCB
11157(
11158 v_PVOID_t pAdapter,
11159 v_S7_t rssiValue,
11160 v_U8_t triggerEvent,
11161 WLANTL_RSSICrossThresholdCBType crossCBFunction,
11162 VOS_MODULE_ID moduleID
11163)
11164{
11165 VOS_STATUS status = VOS_STATUS_SUCCESS;
11166
11167 status = WLANTL_HSDeregRSSIIndicationCB(pAdapter,
11168 rssiValue,
11169 triggerEvent,
11170 crossCBFunction,
11171 moduleID);
11172 return status;
11173}
11174
11175/*==========================================================================
11176 FUNCTION WLANTL_SetAlpha
11177
11178 DESCRIPTION ALPLA is weight value to calculate AVG RSSI
11179 avgRSSI = (ALPHA * historyRSSI) + ((10 - ALPHA) * newRSSI)
11180 avgRSSI has (ALPHA * 10)% of history RSSI weight and
11181 (10 - ALPHA)% of newRSSI weight
11182 This portion is dynamically configurable.
11183 Default is ?
11184
11185 DEPENDENCIES NONE
11186
11187 PARAMETERS in pAdapter - Global handle
11188 in valueAlpah - ALPHA
11189
11190 RETURN VALUE VOS_STATUS
11191
11192 SIDE EFFECTS NONE
11193
11194============================================================================*/
11195VOS_STATUS WLANTL_SetAlpha
11196(
11197 v_PVOID_t pAdapter,
11198 v_U8_t valueAlpha
11199)
11200{
11201 VOS_STATUS status = VOS_STATUS_SUCCESS;
11202
11203 status = WLANTL_HSSetAlpha(pAdapter, valueAlpha);
11204 return status;
11205}
11206
11207/*==========================================================================
11208
11209 FUNCTION
11210
11211 DESCRIPTION
11212
11213 PARAMETERS
11214
11215 RETURN VALUE
11216
11217============================================================================*/
11218VOS_STATUS WLANTL_BMPSRSSIRegionChangedNotification
11219(
11220 v_PVOID_t pAdapter,
11221 tpSirRSSINotification pRSSINotification
11222)
11223{
11224 VOS_STATUS status = VOS_STATUS_SUCCESS;
11225
11226 status = WLANTL_HSBMPSRSSIRegionChangedNotification(pAdapter, pRSSINotification);
11227 return status;
11228}
11229
11230/*==========================================================================
11231 FUNCTION WLANTL_RegGetTrafficStatus
11232
11233 DESCRIPTION Registration function for traffic status monitoring
11234 During measure period count data frames.
11235 If frame count is larger then IDLE threshold set as traffic ON
11236 or OFF.
11237 And traffic status is changed send report to client with
11238 registered callback function
11239
11240 DEPENDENCIES NONE
11241
11242 PARAMETERS in pAdapter - Global handle
11243 in idleThreshold - Traffic on or off threshold
11244 in measurePeriod - Traffic state check period
11245 in trfficStatusCB - traffic status changed notification
11246 CB function
11247 in usrCtxt - user context
11248
11249 RETURN VALUE VOS_STATUS
11250
11251 SIDE EFFECTS NONE
11252
11253============================================================================*/
11254VOS_STATUS WLANTL_RegGetTrafficStatus
11255(
11256 v_PVOID_t pAdapter,
11257 v_U32_t idleThreshold,
11258 v_U32_t measurePeriod,
11259 WLANTL_TrafficStatusChangedCBType trfficStatusCB,
11260 v_PVOID_t usrCtxt
11261)
11262{
11263 VOS_STATUS status = VOS_STATUS_SUCCESS;
11264
11265 status = WLANTL_HSRegGetTrafficStatus(pAdapter,
11266 idleThreshold,
11267 measurePeriod,
11268 trfficStatusCB,
11269 usrCtxt);
11270 return status;
11271}
11272#endif
11273/*==========================================================================
11274 FUNCTION WLANTL_GetStatistics
11275
11276 DESCRIPTION Get traffic statistics for identified station
11277
11278 DEPENDENCIES NONE
11279
11280 PARAMETERS in pAdapter - Global handle
11281 in statType - specific statistics field to reset
11282 out statBuffer - traffic statistics buffer
11283
11284 RETURN VALUE VOS_STATUS
11285
11286 SIDE EFFECTS NONE
11287
11288============================================================================*/
11289VOS_STATUS WLANTL_GetStatistics
11290(
11291 v_PVOID_t pAdapter,
11292 WLANTL_TRANSFER_STA_TYPE *statBuffer,
11293 v_U8_t STAid
11294)
11295{
11296 WLANTL_CbType *pTLCb = VOS_GET_TL_CB(pAdapter);
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053011297 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070011298 VOS_STATUS status = VOS_STATUS_SUCCESS;
11299 WLANTL_TRANSFER_STA_TYPE *statistics = NULL;
11300
11301 /*------------------------------------------------------------------------
11302 Sanity check
11303 Extract TL control block
11304 ------------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053011305 if ( NULL == pTLCb )
Jeff Johnson295189b2012-06-20 16:38:30 -070011306 {
11307 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11308 "WLAN TL:Invalid TL pointer on WLANTL_GetStatistics"));
11309 return VOS_STATUS_E_FAULT;
11310 }
11311
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053011312 pClientSTA = pTLCb->atlSTAClients[STAid];
11313
11314 if ( NULL == pClientSTA )
11315 {
11316 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11317 "WLAN TL:Client Memory was not allocated on %s", __func__));
11318 return VOS_STATUS_E_FAILURE;
11319 }
11320
11321 if(0 == pClientSTA->ucExists)
Jeff Johnson295189b2012-06-20 16:38:30 -070011322 {
11323 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11324 "WLAN TL: %d STA ID does not exist", STAid));
11325 return VOS_STATUS_E_INVAL;
11326 }
11327
11328 if(NULL == statBuffer)
11329 {
11330 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11331 "WLAN TL:Invalid TL statistics buffer pointer on WLANTL_GetStatistics"));
11332 return VOS_STATUS_E_INVAL;
11333 }
11334
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053011335 statistics = &pClientSTA->trafficStatistics;
Katya Nigam493ff652014-02-11 14:31:04 +053011336 vos_mem_copy(statBuffer, statistics, sizeof(WLANTL_TRANSFER_STA_TYPE));
Jeff Johnson295189b2012-06-20 16:38:30 -070011337
11338 return status;
11339}
11340
11341/*==========================================================================
11342 FUNCTION WLANTL_ResetStatistics
11343
11344 DESCRIPTION Reset statistics structure for identified station ID
11345 Reset means set values as 0
11346
11347 DEPENDENCIES NONE
11348
11349 PARAMETERS in pAdapter - Global handle
11350 in statType - specific statistics field to reset
11351
11352 RETURN VALUE VOS_STATUS
11353
11354 SIDE EFFECTS NONE
11355
11356============================================================================*/
11357VOS_STATUS WLANTL_ResetStatistics
11358(
11359 v_PVOID_t pAdapter,
11360 v_U8_t STAid
11361)
11362{
11363 WLANTL_CbType *pTLCb = VOS_GET_TL_CB(pAdapter);
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053011364 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070011365 VOS_STATUS status = VOS_STATUS_SUCCESS;
11366 WLANTL_TRANSFER_STA_TYPE *statistics = NULL;
11367
11368 /*------------------------------------------------------------------------
11369 Sanity check
11370 Extract TL control block
11371 ------------------------------------------------------------------------*/
11372 if (NULL == pTLCb)
11373 {
11374 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11375 "WLAN TL:Invalid TL pointer on WLANTL_GetStatistics"));
11376 return VOS_STATUS_E_FAULT;
11377 }
11378
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053011379 pClientSTA = pTLCb->atlSTAClients[STAid];
11380
11381 if ( NULL == pClientSTA )
11382 {
11383 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11384 "WLAN TL:Client Memory was not allocated on %s", __func__));
11385 return VOS_STATUS_E_FAILURE;
11386 }
11387
11388 if(0 == pClientSTA->ucExists)
Jeff Johnson295189b2012-06-20 16:38:30 -070011389 {
11390 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11391 "WLAN TL: %d STA ID does not exist", STAid));
11392 return VOS_STATUS_E_INVAL;
11393 }
11394
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053011395 statistics = &pClientSTA->trafficStatistics;
Jeff Johnson295189b2012-06-20 16:38:30 -070011396 vos_mem_zero((v_VOID_t *)statistics, sizeof(WLANTL_TRANSFER_STA_TYPE));
11397
11398 return status;
11399}
11400
11401/*==========================================================================
11402 FUNCTION WLANTL_GetSpecStatistic
11403
11404 DESCRIPTION Get specific field within statistics structure for
11405 identified station ID
11406
11407 DEPENDENCIES NONE
11408
11409 PARAMETERS in pAdapter - Global handle
11410 in statType - specific statistics field to reset
11411 in STAid - Station ID
11412 out buffer - Statistic value
11413
11414 RETURN VALUE VOS_STATUS
11415
11416 SIDE EFFECTS NONE
11417
11418============================================================================*/
11419VOS_STATUS WLANTL_GetSpecStatistic
11420(
11421 v_PVOID_t pAdapter,
11422 WLANTL_TRANSFER_STATIC_TYPE statType,
11423 v_U32_t *buffer,
11424 v_U8_t STAid
11425)
11426{
11427 WLANTL_CbType *pTLCb = VOS_GET_TL_CB(pAdapter);
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053011428 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070011429 VOS_STATUS status = VOS_STATUS_SUCCESS;
11430 WLANTL_TRANSFER_STA_TYPE *statistics = NULL;
11431
11432 /*------------------------------------------------------------------------
11433 Sanity check
11434 Extract TL control block
11435 ------------------------------------------------------------------------*/
11436 if (NULL == pTLCb)
11437 {
11438 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11439 "WLAN TL:Invalid TL pointer on WLANTL_GetStatistics"));
11440 return VOS_STATUS_E_FAULT;
11441 }
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053011442 pClientSTA = pTLCb->atlSTAClients[STAid];
Jeff Johnson295189b2012-06-20 16:38:30 -070011443
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053011444 if ( NULL == pClientSTA )
11445 {
11446 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11447 "WLAN TL:Client Memory was not allocated on %s", __func__));
11448 return VOS_STATUS_E_FAILURE;
11449 }
11450
11451 if(0 == pClientSTA->ucExists)
Jeff Johnson295189b2012-06-20 16:38:30 -070011452 {
11453 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11454 "WLAN TL: %d STA ID does not exist", STAid));
11455 return VOS_STATUS_E_INVAL;
11456 }
11457
11458 if(NULL == buffer)
11459 {
11460 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11461 "WLAN TL:Invalid TL statistic buffer pointer on WLANTL_GetStatistics"));
11462 return VOS_STATUS_E_INVAL;
11463 }
11464
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053011465 statistics = &pClientSTA->trafficStatistics;
Jeff Johnson295189b2012-06-20 16:38:30 -070011466 switch(statType)
11467 {
11468 case WLANTL_STATIC_TX_UC_FCNT:
11469 *buffer = statistics->txUCFcnt;
11470 break;
11471
11472 case WLANTL_STATIC_TX_MC_FCNT:
11473 *buffer = statistics->txMCFcnt;
11474 break;
11475
11476 case WLANTL_STATIC_TX_BC_FCNT:
11477 *buffer = statistics->txBCFcnt;
11478 break;
11479
11480 case WLANTL_STATIC_TX_UC_BCNT:
11481 *buffer = statistics->txUCBcnt;
11482 break;
11483
11484 case WLANTL_STATIC_TX_MC_BCNT:
11485 *buffer = statistics->txMCBcnt;
11486 break;
11487
11488 case WLANTL_STATIC_TX_BC_BCNT:
11489 *buffer = statistics->txBCBcnt;
11490 break;
11491
11492 case WLANTL_STATIC_RX_UC_FCNT:
11493 *buffer = statistics->rxUCFcnt;
11494 break;
11495
11496 case WLANTL_STATIC_RX_MC_FCNT:
11497 *buffer = statistics->rxMCFcnt;
11498 break;
11499
11500 case WLANTL_STATIC_RX_BC_FCNT:
11501 *buffer = statistics->rxBCFcnt;
11502 break;
11503
11504 case WLANTL_STATIC_RX_UC_BCNT:
11505 *buffer = statistics->rxUCBcnt;
11506 break;
11507
11508 case WLANTL_STATIC_RX_MC_BCNT:
11509 *buffer = statistics->rxMCBcnt;
11510 break;
11511
11512 case WLANTL_STATIC_RX_BC_BCNT:
11513 *buffer = statistics->rxBCBcnt;
11514 break;
11515
11516 case WLANTL_STATIC_RX_BCNT:
11517 *buffer = statistics->rxBcnt;
11518 break;
11519
11520 case WLANTL_STATIC_RX_BCNT_CRC_OK:
11521 *buffer = statistics->rxBcntCRCok;
11522 break;
11523
11524 case WLANTL_STATIC_RX_RATE:
11525 *buffer = statistics->rxRate;
11526 break;
11527
11528 default:
11529 *buffer = 0;
11530 status = VOS_STATUS_E_INVAL;
11531 break;
11532 }
11533
11534
11535 return status;
11536}
11537
11538/*==========================================================================
11539 FUNCTION WLANTL_ResetSpecStatistic
11540
11541 DESCRIPTION Reset specific field within statistics structure for
11542 identified station ID
11543 Reset means set as 0
11544
11545 DEPENDENCIES NONE
11546
11547 PARAMETERS in pAdapter - Global handle
11548 in statType - specific statistics field to reset
11549 in STAid - Station ID
11550
11551 RETURN VALUE VOS_STATUS
11552
11553 SIDE EFFECTS NONE
11554
11555============================================================================*/
11556VOS_STATUS WLANTL_ResetSpecStatistic
11557(
11558 v_PVOID_t pAdapter,
11559 WLANTL_TRANSFER_STATIC_TYPE statType,
11560 v_U8_t STAid
11561)
11562{
11563 WLANTL_CbType *pTLCb = VOS_GET_TL_CB(pAdapter);
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053011564 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070011565 VOS_STATUS status = VOS_STATUS_SUCCESS;
11566 WLANTL_TRANSFER_STA_TYPE *statistics = NULL;
11567
11568 /*------------------------------------------------------------------------
11569 Sanity check
11570 Extract TL control block
11571 ------------------------------------------------------------------------*/
11572 if (NULL == pTLCb)
11573 {
11574 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11575 "WLAN TL:Invalid TL pointer on WLANTL_GetStatistics"));
11576 return VOS_STATUS_E_FAULT;
11577 }
11578
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053011579 pClientSTA = pTLCb->atlSTAClients[STAid];
11580
11581 if ( NULL == pClientSTA )
11582 {
11583 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11584 "WLAN TL:Client Memory was not allocated on %s", __func__));
11585 return VOS_STATUS_E_FAILURE;
11586 }
11587
11588 if(0 == pClientSTA->ucExists)
Jeff Johnson295189b2012-06-20 16:38:30 -070011589 {
11590 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11591 "WLAN TL: %d STA ID does not exist", STAid));
11592 return VOS_STATUS_E_INVAL;
11593 }
11594
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053011595 statistics = &pClientSTA->trafficStatistics;
Jeff Johnson295189b2012-06-20 16:38:30 -070011596 switch(statType)
11597 {
11598 case WLANTL_STATIC_TX_UC_FCNT:
11599 statistics->txUCFcnt = 0;
11600 break;
11601
11602 case WLANTL_STATIC_TX_MC_FCNT:
11603 statistics->txMCFcnt = 0;
11604 break;
11605
11606 case WLANTL_STATIC_TX_BC_FCNT:
11607 statistics->txBCFcnt = 0;
11608 break;
11609
11610 case WLANTL_STATIC_TX_UC_BCNT:
11611 statistics->txUCBcnt = 0;
11612 break;
11613
11614 case WLANTL_STATIC_TX_MC_BCNT:
11615 statistics->txMCBcnt = 0;
11616 break;
11617
11618 case WLANTL_STATIC_TX_BC_BCNT:
11619 statistics->txBCBcnt = 0;
11620 break;
11621
11622 case WLANTL_STATIC_RX_UC_FCNT:
11623 statistics->rxUCFcnt = 0;
11624 break;
11625
11626 case WLANTL_STATIC_RX_MC_FCNT:
11627 statistics->rxMCFcnt = 0;
11628 break;
11629
11630 case WLANTL_STATIC_RX_BC_FCNT:
11631 statistics->rxBCFcnt = 0;
11632 break;
11633
11634 case WLANTL_STATIC_RX_UC_BCNT:
11635 statistics->rxUCBcnt = 0;
11636 break;
11637
11638 case WLANTL_STATIC_RX_MC_BCNT:
11639 statistics->rxMCBcnt = 0;
11640 break;
11641
11642 case WLANTL_STATIC_RX_BC_BCNT:
11643 statistics->rxBCBcnt = 0;
11644 break;
11645
11646 case WLANTL_STATIC_RX_BCNT:
11647 statistics->rxBcnt = 0;
11648 break;
11649
11650 case WLANTL_STATIC_RX_BCNT_CRC_OK:
11651 statistics->rxBcntCRCok = 0;
11652 break;
11653
11654 case WLANTL_STATIC_RX_RATE:
11655 statistics->rxRate = 0;
11656 break;
11657
11658 default:
11659 status = VOS_STATUS_E_INVAL;
11660 break;
11661 }
11662
11663 return status;
11664}
11665
11666
11667/*==========================================================================
11668
11669 FUNCTION
11670
11671 DESCRIPTION Read RSSI value out of a RX BD
11672
11673 PARAMETERS: Caller must validate all parameters
11674
11675 RETURN VALUE
11676
11677============================================================================*/
11678VOS_STATUS WLANTL_ReadRSSI
11679(
11680 v_PVOID_t pAdapter,
11681 v_PVOID_t pBDHeader,
11682 v_U8_t STAid
11683)
11684{
11685 WLANTL_CbType *tlCtxt = VOS_GET_TL_CB(pAdapter);
11686 v_S7_t currentRSSI, currentRSSI0, currentRSSI1;
11687
11688
11689 if(NULL == tlCtxt)
11690 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070011691 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR, "%s Invalid TL handle", __func__));
Jeff Johnson295189b2012-06-20 16:38:30 -070011692 return VOS_STATUS_E_INVAL;
11693 }
11694
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053011695 if ( NULL == tlCtxt->atlSTAClients[STAid] )
11696 {
11697 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11698 "WLAN TL:Client Memory was not allocated on %s", __func__));
11699 return VOS_STATUS_E_FAILURE;
11700 }
11701
Jeff Johnson295189b2012-06-20 16:38:30 -070011702 currentRSSI0 = WLANTL_GETRSSI0(pBDHeader);
11703 currentRSSI1 = WLANTL_GETRSSI1(pBDHeader);
11704 currentRSSI = (currentRSSI0 > currentRSSI1) ? currentRSSI0 : currentRSSI1;
11705
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053011706 tlCtxt->atlSTAClients[STAid]->rssiAvg = currentRSSI;
Jeff Johnson295189b2012-06-20 16:38:30 -070011707
11708 return VOS_STATUS_SUCCESS;
11709}
11710
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053011711/*==========================================================================
11712
11713 FUNCTION
11714
11715 DESCRIPTION Read SNR value out of a RX BD
11716
11717 PARAMETERS: Caller must validate all parameters
11718
11719 RETURN VALUE
11720
11721============================================================================*/
11722VOS_STATUS WLANTL_ReadSNR
11723(
11724 v_PVOID_t pAdapter,
11725 v_PVOID_t pBDHeader,
11726 v_U8_t STAid
11727)
11728{
11729 WLANTL_CbType *tlCtxt = VOS_GET_TL_CB(pAdapter);
11730 v_S7_t currentSNR;
11731
11732
11733 if (NULL == tlCtxt)
11734 {
11735 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11736 "%s Invalid TL handle", __func__));
11737 return VOS_STATUS_E_INVAL;
11738 }
11739
11740 if (NULL == tlCtxt->atlSTAClients[STAid])
11741 {
11742 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11743 "WLAN TL:Client Memory was not allocated on %s", __func__));
11744 return VOS_STATUS_E_FAILURE;
11745 }
11746
11747 currentSNR = WLANTL_GETSNR(pBDHeader);
11748
Madan Mohan Koyyalamudi43acf032013-09-27 04:33:28 +053011749 /* SNR reported in the Buffer Descriptor is scaled up by 2(SNR*2),
11750 * Get the correct SNR value
11751 */
11752 currentSNR = currentSNR >> 1;
11753
11754 /* SNR reported by HW cannot be more than 35dB due to HW limitations */
11755 currentSNR = (WLANTL_MAX_HW_SNR > currentSNR ? currentSNR :
11756 WLANTL_MAX_HW_SNR);
11757
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053011758 TLLOG2(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
11759 "%s: snrsum: %d snridx: %d prevsnravg: %d",
11760 __func__,
11761 tlCtxt->atlSTAClients[STAid]->snrSum,
11762 tlCtxt->atlSTAClients[STAid]->snrIdx,
11763 tlCtxt->atlSTAClients[STAid]->prevSnrAvg));
11764
11765 /* The SNR returned for all purposes is the average SNR over
11766 * WLANTL_MAX_SNR_DATA_SMAPLES.When data samples
11767 * > WLANTL_MAX_SNR_DATA_SAMPLES are obtained,
11768 * store the average of the samples in prevSnrAvg
11769 * and start a new averaging window. The prevSnrAvg is used when
11770 * enough data samples are not available when applications
11771 * actually query for SNR.
11772 *
11773 * SEE: WLANTL_GetSnr()
11774 */
11775 if (tlCtxt->atlSTAClients[STAid]->snrIdx >= WLANTL_MAX_SNR_DATA_SAMPLES)
11776 {
11777 tlCtxt->atlSTAClients[STAid]->prevSnrAvg =
11778 tlCtxt->atlSTAClients[STAid]->snrSum /
11779 tlCtxt->atlSTAClients[STAid]->snrIdx;
11780 tlCtxt->atlSTAClients[STAid]->snrSum = 0;
11781 tlCtxt->atlSTAClients[STAid]->snrIdx = 0;
11782 }
11783 tlCtxt->atlSTAClients[STAid]->snrSum += currentSNR;
11784 tlCtxt->atlSTAClients[STAid]->snrIdx += 1;
11785
11786 return VOS_STATUS_SUCCESS;
11787}
Jeff Johnson295189b2012-06-20 16:38:30 -070011788
11789/*
11790 DESCRIPTION
11791 TL returns the weight currently maintained in TL.
11792 IN
11793 pvosGCtx: pointer to the global vos context; a handle to TL's
11794 or SME's control block can be extracted from its context
11795
11796 OUT
11797 pACWeights: Caller allocated memory for filling in weights
11798
11799 RETURN VALUE VOS_STATUS
11800*/
11801VOS_STATUS
11802WLANTL_GetACWeights
11803(
11804 v_PVOID_t pvosGCtx,
11805 v_U8_t* pACWeights
11806)
11807{
11808 WLANTL_CbType* pTLCb = NULL;
11809 v_U8_t ucIndex;
11810 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
11811
11812 /*------------------------------------------------------------------------
11813 Sanity check
11814 ------------------------------------------------------------------------*/
11815 if ( NULL == pACWeights )
11816 {
11817 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11818 "WLAN TL:Invalid parameter sent on WLANTL_GetACWeights"));
11819 return VOS_STATUS_E_INVAL;
11820 }
11821
11822 /*------------------------------------------------------------------------
11823 Extract TL control block and check existance
11824 ------------------------------------------------------------------------*/
11825 pTLCb = VOS_GET_TL_CB(pvosGCtx);
11826 if ( NULL == pTLCb )
11827 {
11828 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11829 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_GetACWeights"));
11830 return VOS_STATUS_E_FAULT;
11831 }
11832 for ( ucIndex = 0; ucIndex < WLANTL_MAX_AC ; ucIndex++)
11833 {
11834 pACWeights[ucIndex] = pTLCb->tlConfigInfo.ucAcWeights[ucIndex];
11835 }
11836
11837 return VOS_STATUS_SUCCESS;
11838}
11839
11840
11841
11842/*
11843 DESCRIPTION
11844 Change the weight currently maintained by TL.
11845 IN
11846 pvosGCtx: pointer to the global vos context; a handle to TL's
11847 or SME's control block can be extracted from its context
11848 pACWeights: Caller allocated memory contain the weights to use
11849
11850
11851 RETURN VALUE VOS_STATUS
11852*/
11853VOS_STATUS
11854WLANTL_SetACWeights
11855(
11856 v_PVOID_t pvosGCtx,
11857 v_U8_t* pACWeights
11858)
11859{
11860 WLANTL_CbType* pTLCb = NULL;
11861 v_U8_t ucIndex;
11862 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
11863
11864 /*------------------------------------------------------------------------
11865 Sanity check
11866 ------------------------------------------------------------------------*/
11867 if ( NULL == pACWeights )
11868 {
11869 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11870 "WLAN TL:Invalid parameter sent on WLANTL_GetACWeights"));
11871 return VOS_STATUS_E_INVAL;
11872 }
11873
11874 /*------------------------------------------------------------------------
11875 Extract TL control block and check existance
11876 ------------------------------------------------------------------------*/
11877 pTLCb = VOS_GET_TL_CB(pvosGCtx);
11878 if ( NULL == pTLCb )
11879 {
11880 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11881 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_GetACWeights"));
11882 return VOS_STATUS_E_FAULT;
11883 }
11884 for ( ucIndex = 0; ucIndex < WLANTL_MAX_AC ; ucIndex++)
11885 {
11886 pTLCb->tlConfigInfo.ucAcWeights[ucIndex] = pACWeights[ucIndex];
11887 }
11888
11889 return VOS_STATUS_SUCCESS;
11890}
11891
11892
11893/*==========================================================================
11894
11895 FUNCTION
11896
11897 DESCRIPTION
11898
11899 PARAMETERS
11900
11901 RETURN VALUE
11902
11903============================================================================*/
11904void WLANTL_PowerStateChangedCB
11905(
11906 v_PVOID_t pAdapter,
11907 tPmcState newState
11908)
11909{
11910 WLANTL_CbType *tlCtxt = VOS_GET_TL_CB(pAdapter);
11911
11912 if (NULL == tlCtxt)
11913 {
11914 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +053011915 "%s: Invalid TL Control Block", __func__ );
Jeff Johnson295189b2012-06-20 16:38:30 -070011916 return;
11917 }
11918
11919 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO, "Power state changed, new state is %d", newState );
11920 switch(newState)
11921 {
11922 case FULL_POWER:
11923 tlCtxt->isBMPS = VOS_FALSE;
11924 break;
11925
11926 case BMPS:
11927#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
11928 WLANTL_SetFWRSSIThresholds(pAdapter);
11929#endif
11930
11931 tlCtxt->isBMPS = VOS_TRUE;
11932 break;
11933
11934 case IMPS:
11935 case LOW_POWER:
11936 case REQUEST_BMPS:
11937 case REQUEST_FULL_POWER:
11938 case REQUEST_IMPS:
11939 case STOPPED:
11940 case REQUEST_START_UAPSD:
11941 case REQUEST_STOP_UAPSD:
11942 case UAPSD:
11943 case REQUEST_STANDBY:
11944 case STANDBY:
11945 case REQUEST_ENTER_WOWL:
11946 case REQUEST_EXIT_WOWL:
11947 case WOWL:
11948 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN, "Not handle this events %d", newState ));
11949 break;
11950
11951 default:
11952 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR, "Not a valid event %d", newState ));
11953 break;
11954 }
11955
11956 return;
11957}
11958/*==========================================================================
11959 FUNCTION WLANTL_GetEtherType
11960
11961 DESCRIPTION Extract Ether type information from the BD
11962
11963 DEPENDENCIES NONE
11964
11965 PARAMETERS in aucBDHeader - BD header
11966 in vosDataBuff - data buffer
11967 in ucMPDUHLen - MPDU header length
11968 out pUsEtherType - pointer to Ethertype
11969
11970 RETURN VALUE VOS_STATUS_SUCCESS : if the EtherType is successfully extracted
11971 VOS_STATUS_FAILURE : if the EtherType extraction failed and
11972 the packet was dropped
11973
11974 SIDE EFFECTS NONE
11975
11976============================================================================*/
11977static VOS_STATUS WLANTL_GetEtherType
11978(
11979 v_U8_t * aucBDHeader,
11980 vos_pkt_t * vosDataBuff,
11981 v_U8_t ucMPDUHLen,
11982 v_U16_t * pUsEtherType
11983)
11984{
11985 v_U8_t ucOffset;
11986 v_U16_t usEtherType = *pUsEtherType;
11987 v_SIZE_t usLLCSize = sizeof(usEtherType);
11988 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
11989
11990 /*------------------------------------------------------------------------
11991 Check if LLC is present - if not, TL is unable to determine type
11992 ------------------------------------------------------------------------*/
11993 if ( VOS_FALSE == WDA_IS_RX_LLC_PRESENT( aucBDHeader ) )
11994 {
11995 ucOffset = WLANTL_802_3_HEADER_LEN - sizeof(usEtherType);
11996 }
11997 else
11998 {
11999 ucOffset = ucMPDUHLen + WLANTL_LLC_PROTO_TYPE_OFFSET;
12000 }
12001
12002 /*------------------------------------------------------------------------
12003 Extract LLC type
12004 ------------------------------------------------------------------------*/
12005 vosStatus = vos_pkt_extract_data( vosDataBuff, ucOffset,
12006 (v_PVOID_t)&usEtherType, &usLLCSize);
12007
12008 if (( VOS_STATUS_SUCCESS != vosStatus ) ||
12009 ( sizeof(usEtherType) != usLLCSize ))
12010
12011 {
12012 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
12013 "WLAN TL:Error extracting Ether type from data packet"));
12014 /* Drop packet */
12015 vos_pkt_return_packet(vosDataBuff);
12016 vosStatus = VOS_STATUS_E_FAILURE;
12017 }
12018 else
12019 {
12020 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
12021 "WLAN TL:Ether type retrieved before endianess conv: %d",
12022 usEtherType));
12023
12024 usEtherType = vos_be16_to_cpu(usEtherType);
12025 *pUsEtherType = usEtherType;
12026
12027 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
12028 "WLAN TL:Ether type retrieved: %d", usEtherType));
12029 }
12030
12031 return vosStatus;
12032}
12033
Jeff Johnson295189b2012-06-20 16:38:30 -070012034/*==========================================================================
12035 FUNCTION WLANTL_GetSoftAPStatistics
12036
12037 DESCRIPTION Collect the cumulative statistics for all Softap stations
12038
12039 DEPENDENCIES NONE
12040
12041 PARAMETERS in pvosGCtx - Pointer to the global vos context
12042 bReset - If set TL statistics will be cleared after reading
12043 out statsSum - pointer to collected statistics
12044
12045 RETURN VALUE VOS_STATUS_SUCCESS : if the Statistics are successfully extracted
12046
12047 SIDE EFFECTS NONE
12048
12049============================================================================*/
12050VOS_STATUS WLANTL_GetSoftAPStatistics(v_PVOID_t pAdapter, WLANTL_TRANSFER_STA_TYPE *statsSum, v_BOOL_t bReset)
12051{
12052 v_U8_t i = 0;
12053 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
12054 WLANTL_CbType *pTLCb = VOS_GET_TL_CB(pAdapter);
12055 WLANTL_TRANSFER_STA_TYPE statBufferTemp;
12056 vos_mem_zero((v_VOID_t *)&statBufferTemp, sizeof(WLANTL_TRANSFER_STA_TYPE));
12057 vos_mem_zero((v_VOID_t *)statsSum, sizeof(WLANTL_TRANSFER_STA_TYPE));
12058
12059
12060 if ( NULL == pTLCb )
12061 {
12062 return VOS_STATUS_E_FAULT;
12063 }
12064
12065 // Sum up all the statistics for stations of Soft AP from TL
12066 for (i = 0; i < WLAN_MAX_STA_COUNT; i++)
12067 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053012068 if ( NULL == pTLCb->atlSTAClients[i])
12069 {
12070 continue;
12071 }
12072 if (pTLCb->atlSTAClients[i]->wSTADesc.wSTAType == WLAN_STA_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -070012073 {
12074 vosStatus = WLANTL_GetStatistics(pAdapter, &statBufferTemp, i);// Can include staId 1 because statistics not collected for it
12075
12076 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
12077 return VOS_STATUS_E_FAULT;
12078
12079 // Add to the counters
12080 statsSum->txUCFcnt += statBufferTemp.txUCFcnt;
12081 statsSum->txMCFcnt += statBufferTemp.txMCFcnt;
12082 statsSum->txBCFcnt += statBufferTemp.txBCFcnt;
12083 statsSum->txUCBcnt += statBufferTemp.txUCBcnt;
12084 statsSum->txMCBcnt += statBufferTemp.txMCBcnt;
12085 statsSum->txBCBcnt += statBufferTemp.txBCBcnt;
12086 statsSum->rxUCFcnt += statBufferTemp.rxUCFcnt;
12087 statsSum->rxMCFcnt += statBufferTemp.rxMCFcnt;
12088 statsSum->rxBCFcnt += statBufferTemp.rxBCFcnt;
12089 statsSum->rxUCBcnt += statBufferTemp.rxUCBcnt;
12090 statsSum->rxMCBcnt += statBufferTemp.rxMCBcnt;
12091 statsSum->rxBCBcnt += statBufferTemp.rxBCBcnt;
12092
12093 if (bReset)
12094 {
12095 vosStatus = WLANTL_ResetStatistics(pAdapter, i);
12096 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
12097 return VOS_STATUS_E_FAULT;
12098 }
12099 }
12100 }
12101
12102 return vosStatus;
12103}
Mohit Khanna698ba2a2012-12-04 15:08:18 -080012104#ifdef FEATURE_WLAN_TDLS_INTERNAL
12105/*==========================================================================
12106 FUNCTION WLANTL_GetEtherType_2
12107
12108 DESCRIPTION Extract Ether type information from the BD
12109
12110 DEPENDENCIES NONE
12111
12112 PARAMETERS in aucBDHeader - BD header
12113 in vosDataBuff - data buffer
12114 in ucMPDUHLen - MPDU header length
12115 out pUsEtherType - pointer to Ethertype
12116
12117 RETURN VALUE VOS_STATUS_SUCCESS : if the EtherType is successfully extracted
12118 VOS_STATUS_FAILURE : if the EtherType extraction failed and
12119 the packet was dropped
12120
12121 SIDE EFFECTS NONE
12122
12123============================================================================*/
12124static VOS_STATUS WLANTL_GetEtherType_2
12125(
12126 v_U8_t * aucBDHeader,
12127 vos_pkt_t * vosDataBuff,
12128 v_U8_t ucMPDUHLen,
12129 v_U16_t * pUsEtherType
12130)
12131{
12132 v_U8_t ucOffset;
12133 v_U16_t usEtherType = *pUsEtherType;
12134 v_SIZE_t usLLCSize = sizeof(usEtherType);
12135 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
12136 //v_U8_t ucLLCHeader;
12137 v_U8_t ucMPDUHOffset ;
12138 /*------------------------------------------------------------------------
12139 Check if LLC is present - if not, TL is unable to determine type
12140 ------------------------------------------------------------------------*/
12141 //ucMPDUHOffset = (v_U8_t)WLANHAL_RX_BD_GET_MPDU_H_OFFSET(aucBDHeader) ;
12142 //ucLLCHeader = (v_U8_t)WLANHAL_RX_BD_GET_LLC(aucBDHeader);
12143 ucMPDUHOffset = (v_U8_t)WDA_GET_RX_MPDU_HEADER_OFFSET(aucBDHeader);
12144
12145 if ( VOS_TRUE == WDA_IS_RX_LLC_PRESENT(aucBDHeader) )
12146 {
12147 ucOffset = ucMPDUHOffset + WLANTL_802_3_HEADER_LEN - sizeof(usEtherType);
12148 }
12149 else
12150 {
12151 ucOffset = WLANHAL_RX_BD_HEADER_SIZE + ucMPDUHLen
12152 + WLANTL_LLC_PROTO_TYPE_OFFSET;
12153 }
12154
12155 /*------------------------------------------------------------------------
12156 Extract LLC type
12157 ------------------------------------------------------------------------*/
12158 vosStatus = vos_pkt_extract_data( vosDataBuff, ucOffset,
12159 (v_PVOID_t)&usEtherType, &usLLCSize);
12160
12161 /* TODO: Do it in better way */
12162 if(vos_be16_to_cpu(usEtherType) == 0x890d)
12163 {
12164 VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Arif Hussainf2b00992013-11-17 21:46:15 -080012165 ("TDLS frame llc %x"), vos_be16_to_cpu(usEtherType)) ;
Mohit Khanna698ba2a2012-12-04 15:08:18 -080012166 }
12167
12168 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
12169 "WLAN TL:Ether type retrieved before endianess conv: %d",
12170 usEtherType);
12171
12172 usEtherType = vos_be16_to_cpu(usEtherType);
12173 *pUsEtherType = usEtherType;
12174
12175 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
12176 "WLAN TL:Ether type retrieved: %d", usEtherType);
12177
12178 return vosStatus;
12179}
12180#endif /* FEATURE_WLAN_TDLS */
12181
Jeff Johnson295189b2012-06-20 16:38:30 -070012182/*===============================================================================
12183 FUNCTION WLANTL_IsReplayPacket
12184
12185 DESCRIPTION This function does replay check for valid stations
12186
12187 DEPENDENCIES Validity of replay check must be done before the function
12188 is called
12189
12190 PARAMETERS currentReplayCounter current replay counter taken from RX BD
12191 previousReplayCounter previous replay counter taken from TL CB
12192
12193 RETRUN VOS_TRUE packet is a replay packet
12194 VOS_FALSE packet is not a replay packet
12195
12196 SIDE EFFECTS none
12197 ===============================================================================*/
12198v_BOOL_t
12199WLANTL_IsReplayPacket
12200(
12201 v_U64_t ullcurrentReplayCounter,
12202 v_U64_t ullpreviousReplayCounter
12203)
12204{
12205 /* Do the replay check by comparing previous received replay counter with
12206 current received replay counter*/
12207 if(ullpreviousReplayCounter < ullcurrentReplayCounter)
12208 {
12209 /* Valid packet not replay */
12210 return VOS_FALSE;
12211 }
12212 else
12213 {
12214
12215 /* Current packet number is less than or equal to previuos received
12216 packet no, this means current packet is replay packet */
12217 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
12218 "WLAN TL: Replay packet found with replay counter :[0x%llX]",ullcurrentReplayCounter);
12219
12220 return VOS_TRUE;
12221 }
12222}
12223
12224#if 0
12225/*===============================================================================
12226 FUNCTION WLANTL_GetReplayCounterFromRxBD
12227
12228 DESCRIPTION This function extracts 48-bit replay packet number from RX BD
12229
12230 DEPENDENCIES Validity of replay check must be done before the function
12231 is called
12232
12233 PARAMETERS pucRxHeader pointer to RX BD header
12234
12235 RETRUN v_U64_t Packet number extarcted from RX BD
12236
12237 SIDE EFFECTS none
12238 ===============================================================================*/
12239v_U64_t
12240WLANTL_GetReplayCounterFromRxBD
12241(
12242 v_U8_t *pucRxBDHeader
12243)
12244{
12245/* 48-bit replay counter is created as follows
12246 from RX BD 6 byte PMI command:
12247 Addr : AES/TKIP
12248 0x38 : pn3/tsc3
12249 0x39 : pn2/tsc2
12250 0x3a : pn1/tsc1
12251 0x3b : pn0/tsc0
12252
12253 0x3c : pn5/tsc5
12254 0x3d : pn4/tsc4 */
12255
12256#ifdef ANI_BIG_BYTE_ENDIAN
12257 v_U64_t ullcurrentReplayCounter = 0;
12258 /* Getting 48-bit replay counter from the RX BD */
12259 ullcurrentReplayCounter = WLANHAL_RX_BD_GET_PMICMD_20TO23(pucRxBDHeader);
12260 ullcurrentReplayCounter <<= 16;
12261 ullcurrentReplayCounter |= (( WLANHAL_RX_BD_GET_PMICMD_24TO25(pucRxBDHeader) & 0xFFFF0000) >> 16);
12262 return ullcurrentReplayCounter;
12263#else
12264 v_U64_t ullcurrentReplayCounter = 0;
12265 /* Getting 48-bit replay counter from the RX BD */
12266 ullcurrentReplayCounter = (WLANHAL_RX_BD_GET_PMICMD_24TO25(pucRxBDHeader) & 0x0000FFFF);
12267 ullcurrentReplayCounter <<= 32;
12268 ullcurrentReplayCounter |= WLANHAL_RX_BD_GET_PMICMD_20TO23(pucRxBDHeader);
12269 return ullcurrentReplayCounter;
12270#endif
12271}
12272#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070012273
12274/*===============================================================================
12275 FUNCTION WLANTL_PostResNeeded
12276
12277 DESCRIPTION This function posts message to TL to reserve BD/PDU memory
12278
12279 DEPENDENCIES None
12280
12281 PARAMETERS pvosGCtx
12282
12283 RETURN None
12284
12285 SIDE EFFECTS none
12286 ===============================================================================*/
12287
12288void WLANTL_PostResNeeded(v_PVOID_t pvosGCtx)
12289{
12290 vos_msg_t vosMsg;
12291
12292 vosMsg.reserved = 0;
12293 vosMsg.bodyptr = NULL;
12294 vosMsg.type = WLANTL_TX_RES_NEEDED;
12295 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
12296 "WLAN TL: BD/PDU available interrupt received, Posting message to TL");
12297 if(!VOS_IS_STATUS_SUCCESS(vos_tx_mq_serialize( VOS_MQ_ID_TL, &vosMsg)))
12298 {
12299 VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070012300 " %s fails to post message", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070012301 }
12302}
12303
12304/*===============================================================================
12305 FUNCTION WLANTL_UpdateRssiBmps
12306
12307 DESCRIPTION This function updates the TL's RSSI (in BMPS mode)
12308
12309 DEPENDENCIES None
12310
12311 PARAMETERS
12312
12313 pvosGCtx VOS context VOS Global context
12314 staId Station ID Station ID
12315 rssi RSSI (BMPS mode) RSSI in BMPS mode
12316
12317 RETURN None
12318
12319 SIDE EFFECTS none
12320 ===============================================================================*/
12321
12322void WLANTL_UpdateRssiBmps(v_PVOID_t pvosGCtx, v_U8_t staId, v_S7_t rssi)
12323{
12324 WLANTL_CbType* pTLCb = VOS_GET_TL_CB(pvosGCtx);
12325
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053012326 if (NULL != pTLCb && NULL != pTLCb->atlSTAClients[staId])
Jeff Johnson295189b2012-06-20 16:38:30 -070012327 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053012328 pTLCb->atlSTAClients[staId]->rssiAvgBmps = rssi;
Jeff Johnson295189b2012-06-20 16:38:30 -070012329 }
12330}
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053012331
12332/*===============================================================================
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053012333 FUNCTION WLANTL_UpdateSnrBmps
12334
12335 DESCRIPTION This function updates the TL's SNR (in BMPS mode)
12336
12337 DEPENDENCIES None
12338
12339 PARAMETERS
12340
12341 pvosGCtx VOS context VOS Global context
12342 staId Station ID Station ID
12343 snr SNR (BMPS mode) SNR in BMPS mode
12344
12345 RETURN None
12346
12347 SIDE EFFECTS none
12348 ===============================================================================*/
12349
12350void WLANTL_UpdateSnrBmps(v_PVOID_t pvosGCtx, v_U8_t staId, v_S7_t snr)
12351{
12352 WLANTL_CbType* pTLCb = VOS_GET_TL_CB(pvosGCtx);
12353
12354 if (NULL != pTLCb && NULL != pTLCb->atlSTAClients[staId])
12355 {
12356 pTLCb->atlSTAClients[staId]->snrAvgBmps = snr;
12357 }
12358}
12359
12360/*===============================================================================
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053012361 FUNCTION WLANTL_UpdateLinkCapacity
12362
12363 DESCRIPTION This function updates the STA's Link Capacity in TL
12364
12365 DEPENDENCIES None
12366
12367 PARAMETERS
12368
12369 pvosGCtx VOS context VOS Global context
12370 staId Station ID Station ID
12371 linkCapacity linkCapacity Link Capacity
12372
12373 RETURN None
12374
12375 SIDE EFFECTS none
12376 ===============================================================================*/
12377
12378void WLANTL_UpdateLinkCapacity(v_PVOID_t pvosGCtx, v_U8_t staId, v_U32_t linkCapacity)
12379{
12380 WLANTL_CbType* pTLCb = VOS_GET_TL_CB(pvosGCtx);
12381
12382 if (NULL != pTLCb && NULL != pTLCb->atlSTAClients[staId])
12383 {
12384 pTLCb->atlSTAClients[staId]->linkCapacity = linkCapacity;
12385 }
12386}
12387
12388
12389/*===========================================================================
12390
12391 FUNCTION WLANTL_GetSTALinkCapacity
12392
12393 DESCRIPTION
12394
12395 Returns Link Capacity of a particular STA.
12396
12397 DEPENDENCIES
12398
12399 A station must have been registered before its state can be retrieved.
12400
12401
12402 PARAMETERS
12403
12404 IN
12405 pvosGCtx: pointer to the global vos context; a handle to TL's
12406 control block can be extracted from its context
12407 ucSTAId: identifier of the station
12408
12409 OUT
12410 plinkCapacity: the current link capacity the connection to
12411 the given station
12412
12413
12414 RETURN VALUE
12415
12416 The result code associated with performing the operation
12417
12418 VOS_STATUS_E_INVAL: Input parameters are invalid
12419 VOS_STATUS_E_FAULT: Station ID is outside array boundaries or pointer to
12420 TL cb is NULL ; access would cause a page fault
12421 VOS_STATUS_E_EXISTS: Station was not registered
12422 VOS_STATUS_SUCCESS: Everything is good :)
12423
12424 SIDE EFFECTS
12425
12426============================================================================*/
12427VOS_STATUS
12428WLANTL_GetSTALinkCapacity
12429(
12430 v_PVOID_t pvosGCtx,
12431 v_U8_t ucSTAId,
12432 v_U32_t *plinkCapacity
12433)
12434{
12435 WLANTL_CbType* pTLCb = NULL;
12436 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
12437
12438 /*------------------------------------------------------------------------
12439 Sanity check
12440 ------------------------------------------------------------------------*/
12441 if ( NULL == plinkCapacity )
12442 {
12443 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
12444 FL("WLAN TL:Invalid parameter")));
12445 return VOS_STATUS_E_INVAL;
12446 }
12447
12448 if ( WLANTL_STA_ID_INVALID( ucSTAId ) )
12449 {
12450 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
12451 FL("WLAN TL:Invalid station id")));
12452 return VOS_STATUS_E_FAULT;
12453 }
12454
12455 /*------------------------------------------------------------------------
12456 Extract TL control block and check existance
12457 ------------------------------------------------------------------------*/
12458 pTLCb = VOS_GET_TL_CB(pvosGCtx);
12459 if ( NULL == pTLCb )
12460 {
12461 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
12462 FL("WLAN TL:Invalid TL pointer from pvosGCtx")));
12463 return VOS_STATUS_E_FAULT;
12464 }
12465
12466 if ( NULL == pTLCb->atlSTAClients[ucSTAId] )
12467 {
12468 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
12469 FL("WLAN TL:Client Memory was not allocated")));
12470 return VOS_STATUS_E_FAILURE;
12471 }
12472
12473 if ( 0 == pTLCb->atlSTAClients[ucSTAId]->ucExists )
12474 {
12475 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
12476 FL("WLAN TL:Station was not previously registered")));
12477 return VOS_STATUS_E_EXISTS;
12478 }
12479
12480 /*------------------------------------------------------------------------
12481 Get STA state
12482 ------------------------------------------------------------------------*/
12483 *plinkCapacity = pTLCb->atlSTAClients[ucSTAId]->linkCapacity;
12484
12485 return VOS_STATUS_SUCCESS;
12486}/* WLANTL_GetSTALinkCapacity */