blob: 10b58647e96ccd12d5e44b94d07417291a22f7d9 [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05302 * Copyright (c) 2012-2015 The Linux Foundation. All rights reserved.
Kiet Lam1ed83fc2014-02-19 01:15:45 -08003 *
4 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
5 *
6 *
7 * Permission to use, copy, modify, and/or distribute this software for
8 * any purpose with or without fee is hereby granted, provided that the
9 * above copyright notice and this permission notice appear in all
10 * copies.
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
13 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
14 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
15 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
16 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
17 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
18 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19 * PERFORMANCE OF THIS SOFTWARE.
20 */
21
22/*
Kiet Lama7f454d2014-07-24 12:04:06 -070023 * This file was originally distributed by Qualcomm Atheros, Inc.
24 * under proprietary terms before Copyright ownership was assigned
25 * to the Linux Foundation.
Gopichand Nakkala92f07d82013-01-08 21:16:34 -080026 */
Kiet Lam1ed83fc2014-02-19 01:15:45 -080027
28
Kiet Lama7f454d2014-07-24 12:04:06 -070029
30
Jeff Johnson295189b2012-06-20 16:38:30 -070031/*===========================================================================
32
33
34 W L A N _ Q C T _ T L . C
35
36 OVERVIEW:
37
38 This software unit holds the implementation of the WLAN Transport Layer.
39
40 The functions externalized by this module are to be called ONLY by other
41 WLAN modules that properly register with the Transport Layer initially.
42
43 DEPENDENCIES:
44
45 Are listed for each API below.
46
47
Jeff Johnson295189b2012-06-20 16:38:30 -070048===========================================================================*/
49
50/*===========================================================================
51
52 EDIT HISTORY FOR FILE
53
54
55 This section contains comments describing changes made to the module.
56 Notice that changes are listed in reverse chronological order.
57
58
59 $Header$$DateTime$$Author$
60
61
62 when who what, where, why
63---------- --- --------------------------------------------------------
642010-07-13 c_shinde Fixed an issue where WAPI rekeying was failing because
65 WAI frame sent out during rekeying had the protected bit
66 set to 1.
672010-05-06 rnair Changed name of variable from usLlcType to usEtherType
68 Changed function name from GetLLCType to GetEtherType
69 Fixed 802.3 to 802.11 frame translation issue where two
70 bytes of the LLC header was getting overwritten in the
71 non-Qos path
722010-05-06 rnair RxAuth path fix for modifying the header before ether
73 type is retreived (Detected while testing rekeying
74 in WAPI Volans)
752010-02-19 bad Fixed 802.11 to 802.3 ft issues with WAPI
762010-02-19 rnair WAPI: If frame is a WAI frame in TxConn and TxAuth, TL
77 does frame translation.
782010-02-01 rnair WAPI: Fixed a bug where the value of ucIsWapiSta was not
79 being set in the TL control block in the RegisterSTA func.
802010-01-08 lti Added TL Data Caching
812009-11-04 rnair WAPI: Moving common functionality to a seperate function
82 called WLANTL_GetLLCType
832009-10-15 rnair WAPI: Featurizing WAPI code
842009-10-09 rnair WAPI: Modifications to authenticated state handling of Rx data
852009-10-06 rnair Adding support for WAPI
862009-09-22 lti Add deregistration API for management client
872009-07-16 rnair Temporary fix to let TL fetch packets when multiple
88 peers exist in an IBSS
892009-06-10 lti Fix for checking TID value of meta info on TX - prevent
90 memory overwrite
91 Fix for properly checking the sta id for resuming trigger
92 frame generation
932009-05-14 lti Fix for sending out trigger frames
942009-05-15 lti Addr3 filtering
952009-04-13 lti Assert if packet larger then allowed
96 Drop packet that fails flatten
972009-04-02 lti Performance fixes for TL
982009-02-19 lti Added fix for LLC management on Rx Connect
992009-01-16 lti Replaced peek data with extract data for non BD opertions
100 Extracted frame control in Tl and pass to HAL for frame
101 type evaluation
1022009-02-02 sch Add handoff support
1032008-12-09 lti Fixes for AMSS compilation
104 Removed assert on receive when there is no station
1052008-12-02 lti Fix fo trigger frame generation
1062008-10-31 lti Fix fo TL tx suspend
1072008-10-01 lti Merged in fixes from reordering
108 Disabled part of UAPSD functionality in TL
109 (will be re-enabled once UAPSD is tested)
110 Fix for UAPSD multiple enable
1112008-08-10 lti Fixes following UAPSD testing
112 Fixed infinite loop on mask computation when STA no reg
1132008-08-06 lti Fixes after QOS unit testing
1142008-08-06 lti Added QOS support
1152008-07-23 lti Fix for vos packet draining
1162008-07-17 lti Fix for data type value
117 Added frame translation code in TL
118 Avoid returning failure to PE in case previous frame is
119 still pending; fail previous and cache new one for tx
120 Get frames returning boolean true if more frames are pending
1212008-07-03 lti Fixes following pre-integration testing
1222008-06-26 lti Fixes following unit testing
123 Added alloc and free for TL context
124 Using atomic set u8 instead of u32
1252008-05-16 lti Created module
126
127===========================================================================*/
128
129/*----------------------------------------------------------------------------
130 * Include Files
131 * -------------------------------------------------------------------------*/
132#include "wlan_qct_tl.h"
133#include "wlan_qct_wda.h"
134#include "wlan_qct_tli.h"
135#include "wlan_qct_tli_ba.h"
136#include "wlan_qct_tl_hosupport.h"
Katya Nigam42e16e82014-02-04 16:28:55 +0530137#include "vos_types.h"
138#include "vos_trace.h"
139#include "wlan_qct_tl_trace.h"
Jeff Johnson295189b2012-06-20 16:38:30 -0700140#include "tlDebug.h"
141#ifdef FEATURE_WLAN_WAPI
142/*Included to access WDI_RxBdType */
143#include "wlan_qct_wdi_bd.h"
144#endif
145/*Enables debugging behavior in TL*/
146#define TL_DEBUG
Hoonki Lee14621352013-04-16 17:51:19 -0700147/*Enables debugging FC control frame in TL*/
148//#define TL_DEBUG_FC
Jeff Johnson295189b2012-06-20 16:38:30 -0700149//#define WLAN_SOFTAP_FLOWCTRL_EN
Jeff Johnson295189b2012-06-20 16:38:30 -0700150//#define BTAMP_TEST
Hoonki Lee14621352013-04-16 17:51:19 -0700151#ifdef TL_DEBUG_FC
152#include <wlan_qct_pal_status.h>
153#include <wlan_qct_pal_device.h> // wpalReadRegister
154#endif
155
Jeff Johnson295189b2012-06-20 16:38:30 -0700156/*----------------------------------------------------------------------------
157 * Preprocessor Definitions and Constants
158 * -------------------------------------------------------------------------*/
159/*LLC header value*/
160static v_U8_t WLANTL_LLC_HEADER[] = {0xAA, 0xAA, 0x03, 0x00, 0x00, 0x00 };
161
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800162#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -0700163/*Aironet SNAP header value*/
164static v_U8_t WLANTL_AIRONET_SNAP_HEADER[] = {0xAA, 0xAA, 0x03, 0x00, 0x40, 0x96, 0x00, 0x00 };
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800165#endif //FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -0700166
167/*BT-AMP packet LLC OUI value*/
168const v_U8_t WLANTL_BT_AMP_OUI[] = {0x00, 0x19, 0x58 };
169
Dino Mycle3b9536d2014-07-09 22:05:24 +0530170#ifdef WLAN_FEATURE_LINK_LAYER_STATS
171extern const v_U8_t WLANTL_TID_2_AC[WLAN_MAX_TID];
172
173#endif
174
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530175#define WLANTL_MAX_SNR_DATA_SAMPLES 20
Jeff Johnson295189b2012-06-20 16:38:30 -0700176
177#ifdef VOLANS_PERF
178#define WLANTL_BD_PDU_INTERRUPT_ENABLE_THRESHOLD 120
179#define WLANTL_BD_PDU_INTERRUPT_GET_THRESHOLD 120
180
181/* TL BD/PDU threshold to enable interrupt */
182int bdPduInterruptEnableThreshold = WLANTL_BD_PDU_INTERRUPT_ENABLE_THRESHOLD;
183int bdPduInterruptGetThreshold = WLANTL_BD_PDU_INTERRUPT_GET_THRESHOLD;
184#endif /* VOLANS_PERF */
185
186/*-----------------------------------*
187 | Type(2b) | Sub-type(4b) |
188 *-----------------------------------*/
189#define WLANTL_IS_DATA_FRAME(_type_sub) \
190 ( WLANTL_DATA_FRAME_TYPE == ( (_type_sub) & 0x30 ))
191
192#define WLANTL_IS_QOS_DATA_FRAME(_type_sub) \
193 (( WLANTL_DATA_FRAME_TYPE == ( (_type_sub) & 0x30 )) && \
194 ( WLANTL_80211_DATA_QOS_SUBTYPE == ( (_type_sub) & 0xF )))
195
196#define WLANTL_IS_MGMT_FRAME(_type_sub) \
197 ( WLANTL_MGMT_FRAME_TYPE == ( (_type_sub) & 0x30 ))
198
Dino Mycle3b9536d2014-07-09 22:05:24 +0530199#define WLANTL_IS_MGMT_ACTION_FRAME(_type_sub) \
200 (( WLANTL_MGMT_FRAME_TYPE == ( (_type_sub) & 0x30 )) && \
201 ( ( WLANTL_80211_MGMT_ACTION_SUBTYPE == ( (_type_sub) & 0xF )) || \
202 ( WLANTL_80211_MGMT_ACTION_NO_ACK_SUBTYPE == ( (_type_sub) & 0xF ))))
203
Siddharth Bhal4551b102014-10-09 21:36:36 +0530204#define WLANTL_IS_PROBE_REQ(_type_sub) \
205 ( WLANTL_MGMT_PROBE_REQ_FRAME_TYPE == ( (_type_sub) & 0x3F ))
206
Jeff Johnson295189b2012-06-20 16:38:30 -0700207#define WLANTL_IS_CTRL_FRAME(_type_sub) \
208 ( WLANTL_CTRL_FRAME_TYPE == ( (_type_sub) & 0x30 ))
209
Mohit Khanna698ba2a2012-12-04 15:08:18 -0800210#ifdef FEATURE_WLAN_TDLS
211#define WLANTL_IS_TDLS_FRAME(_eth_type) \
212 ( WLANTL_LLC_TDLS_TYPE == ( _eth_type))
213#endif
214
Jeff Johnson295189b2012-06-20 16:38:30 -0700215/*MAX Allowed len processed by TL - MAx MTU + 802.3 header + BD+DXE+XTL*/
Madan Mohan Koyyalamudia53c4dc2012-11-13 10:35:42 -0800216#define WLANTL_MAX_ALLOWED_LEN (1514 + 100)
Jeff Johnson295189b2012-06-20 16:38:30 -0700217
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +0530218#define WLANTL_DATA_FLOW_MASK 0x0F
Jeff Johnson295189b2012-06-20 16:38:30 -0700219
Jeff Johnson295189b2012-06-20 16:38:30 -0700220//some flow_control define
221//LWM mode will be enabled for this station if the egress/ingress falls below this ratio
222#define WLANTL_LWM_EGRESS_INGRESS_THRESHOLD (0.75)
223
224//Get enough sample to do the LWM related calculation
225#define WLANTL_LWM_INGRESS_SAMPLE_THRESHOLD (64)
226
227//Maximal on-fly packet per station in LWM mode
228#define WLANTL_STA_BMU_THRESHOLD_MAX (256)
229
230#define WLANTL_AC_MASK (0x7)
Gopichand Nakkala976e3252013-01-03 15:45:56 -0800231#define WLANTL_STAID_OFFSET (0x6)
Jeff Johnson295189b2012-06-20 16:38:30 -0700232
233/* UINT32 type endian swap */
234#define SWAP_ENDIAN_UINT32(a) ((a) = ((a) >> 0x18 ) |(((a) & 0xFF0000) >> 0x08) | \
235 (((a) & 0xFF00) << 0x08) | (((a) & 0xFF) << 0x18))
236
Madan Mohan Koyyalamudi43acf032013-09-27 04:33:28 +0530237/* Maximum value of SNR that can be calculated by the HW */
238#define WLANTL_MAX_HW_SNR 35
Jeff Johnson295189b2012-06-20 16:38:30 -0700239
Jeff Johnson295189b2012-06-20 16:38:30 -0700240/*----------------------------------------------------------------------------
241 * Type Declarations
242 * -------------------------------------------------------------------------*/
243#define TL_LITTLE_BIT_ENDIAN
244
245typedef struct
246{
247
Jeff Johnson295189b2012-06-20 16:38:30 -0700248
249 v_U8_t protVer :2;
250 v_U8_t type :2;
251 v_U8_t subType :4;
252
253 v_U8_t toDS :1;
254 v_U8_t fromDS :1;
255 v_U8_t moreFrag :1;
256 v_U8_t retry :1;
257 v_U8_t powerMgmt :1;
258 v_U8_t moreData :1;
259 v_U8_t wep :1;
260 v_U8_t order :1;
261
Jeff Johnson295189b2012-06-20 16:38:30 -0700262
263} WLANTL_MACFCType;
264
265/* 802.11 header */
266typedef struct
267{
268 /* Frame control field */
269 WLANTL_MACFCType wFrmCtrl;
270
271 /* Duration ID */
272 v_U16_t usDurationId;
273
274 /* Address 1 field */
275 v_U8_t vA1[VOS_MAC_ADDR_SIZE];
276
277 /* Address 2 field */
278 v_U8_t vA2[VOS_MAC_ADDR_SIZE];
279
280 /* Address 3 field */
281 v_U8_t vA3[VOS_MAC_ADDR_SIZE];
282
283 /* Sequence control field */
284 v_U16_t usSeqCtrl;
285
286 // Find the size of the mandatory header size.
287#define WLAN80211_MANDATORY_HEADER_SIZE \
288 (sizeof(WLANTL_MACFCType) + sizeof(v_U16_t) + \
289 (3 * (sizeof(v_U8_t) * VOS_MAC_ADDR_SIZE)) + \
290 sizeof(v_U16_t))
291
292 /* Optional A4 address */
293 v_U8_t optvA4[VOS_MAC_ADDR_SIZE];
294
295 /* Optional QOS control field */
296 v_U16_t usQosCtrl;
297}WLANTL_80211HeaderType;
298
299/* 802.3 header */
300typedef struct
301{
302 /* Destination address field */
303 v_U8_t vDA[VOS_MAC_ADDR_SIZE];
304
305 /* Source address field */
306 v_U8_t vSA[VOS_MAC_ADDR_SIZE];
307
308 /* Length field */
309 v_U16_t usLenType;
310}WLANTL_8023HeaderType;
311
312/*----------------------------------------------------------------------------
313 * Global Data Definitions
314 * -------------------------------------------------------------------------*/
315#define WLAN_TL_INVALID_U_SIG 255
316#define WLAN_TL_INVALID_B_SIG 255
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +0530317#define ENTER() VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO, "Enter:%s", __func__)
318
Jeff Johnson295189b2012-06-20 16:38:30 -0700319#define WLAN_TL_AC_ARRAY_2_MASK( _pSTA, _ucACMask, i ) \
320 do\
321 {\
322 _ucACMask = 0; \
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +0530323 for ( i = 0; i < WLANTL_NUM_TX_QUEUES; i++ ) \
Jeff Johnson295189b2012-06-20 16:38:30 -0700324 { \
325 if ( 0 != (_pSTA)->aucACMask[i] ) \
326 { \
327 _ucACMask |= ( 1 << i ); \
328 } \
329 } \
330 } while (0);
331
332/*----------------------------------------------------------------------------
333 * Static Variable Definitions
334 * -------------------------------------------------------------------------*/
335
336/*----------------------------------------------------------------------------
337 * Static Function Declarations and Definitions
338 * -------------------------------------------------------------------------*/
339
340static VOS_STATUS
341WLANTL_GetEtherType
342(
343 v_U8_t * aucBDHeader,
344 vos_pkt_t * vosDataBuff,
345 v_U8_t ucMPDUHLen,
346 v_U16_t * usEtherType
347);
348
349#ifdef FEATURE_WLAN_WAPI
350/*---------------------------------------------------------------------------
351 * Adding a global variable to be used when doing frame translation in TxAuth
352 * state so as to not set the protected bit to 1 in the case of WAI frames
353 *---------------------------------------------------------------------------*/
Madan Mohan Koyyalamudidfd6aa82012-10-18 20:18:43 -0700354v_U8_t gUcIsWai;
Jeff Johnson295189b2012-06-20 16:38:30 -0700355#endif
356
357/*----------------------------------------------------------------------------
358 * Externalized Function Definitions
359* -------------------------------------------------------------------------*/
360
361/*----------------------------------------------------------------------------
362 * Function Declarations and Documentation
363 * -------------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +0530364/*==========================================================================
365
366 FUNCTION WLANTL_FreeClientMemory
367
368 DESCRIPTION
369 It frees up the memory allocated to all the STA clients in TLCB block
370 Can be called inside Close, Stop or when some FAULT occurs
371
372 DEPENDENCIES
373
374 PARAMETERS
375
376 IN
377 pClientSTA: Pointer to the global client pointer array
378
379 RETURN VALUE
380
381 SIDE EFFECTS
382
383============================================================================*/
384void WLANTL_FreeClientMemory
385(WLANTL_STAClientType* pClientSTA[WLAN_MAX_STA_COUNT])
386{
387 v_U32_t i = 0;
388 for(i =0; i < WLAN_MAX_STA_COUNT; i++)
389 {
390 if( NULL != pClientSTA[i] )
391 {
392 vos_mem_free(pClientSTA[i]);
393 }
394 pClientSTA[i] = NULL;
395 }
396 return;
397}
Jeff Johnson295189b2012-06-20 16:38:30 -0700398
399/*==========================================================================
400
401 FUNCTION WLANTL_Open
402
403 DESCRIPTION
404 Called by HDD at driver initialization. TL will initialize all its
405 internal resources and will wait for the call to start to register
406 with the other modules.
407
408 DEPENDENCIES
409
410 PARAMETERS
411
412 IN
413 pvosGCtx: pointer to the global vos context; a handle to TL's
414 control block can be extracted from its context
415 pTLConfig: TL Configuration
416
417 RETURN VALUE
418 The result code associated with performing the operation
419
420 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a page
421 fault
422 VOS_STATUS_SUCCESS: Everything is good :)
423
424 SIDE EFFECTS
425
426============================================================================*/
427VOS_STATUS
428WLANTL_Open
429(
430 v_PVOID_t pvosGCtx,
431 WLANTL_ConfigInfoType* pTLConfig
432)
433{
434 WLANTL_CbType* pTLCb = NULL;
435 v_U8_t ucIndex;
436 tHalHandle smeContext;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +0530437 v_U32_t i = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700438#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
439 VOS_STATUS status = VOS_STATUS_SUCCESS;
440#endif
441 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
442
443 /*------------------------------------------------------------------------
444 Sanity check
445 Extract TL control block
446 ------------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +0530447 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -0700448 vos_alloc_context( pvosGCtx, VOS_MODULE_ID_TL,
449 (void*)&pTLCb, sizeof(WLANTL_CbType));
450
451 pTLCb = VOS_GET_TL_CB(pvosGCtx);
452 if (( NULL == pTLCb ) || ( NULL == pTLConfig ) )
453 {
Madan Mohan Koyyalamudic0e5bd82012-09-18 17:12:27 -0700454 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_FATAL,
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +0530455 "WLAN TL: Invalid input pointer on WLANTL_Open TL %p Config %p", pTLCb, pTLConfig ));
Jeff Johnson295189b2012-06-20 16:38:30 -0700456 return VOS_STATUS_E_FAULT;
457 }
458
Madan Mohan Koyyalamudic0e5bd82012-09-18 17:12:27 -0700459 /* Set the default log level to VOS_TRACE_LEVEL_ERROR */
460 vos_trace_setLevel(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR);
461
Jeff Johnson295189b2012-06-20 16:38:30 -0700462 smeContext = vos_get_context(VOS_MODULE_ID_SME, pvosGCtx);
463 if ( NULL == smeContext )
464 {
465 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700466 "%s: Invalid smeContext", __func__));
Jeff Johnson295189b2012-06-20 16:38:30 -0700467 return VOS_STATUS_E_FAULT;
468 }
469
470 /* Zero out the memory so we are OK, when CleanCB is called.*/
471 vos_mem_zero((v_VOID_t *)pTLCb, sizeof(WLANTL_CbType));
472
473 /*------------------------------------------------------------------------
474 Clean up TL control block, initialize all values
475 ------------------------------------------------------------------------*/
476 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
477 "WLAN TL:WLANTL_Open"));
478
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +0530479 for ( i =0; i<WLAN_MAX_STA_COUNT; i++ )
Jeff Johnson295189b2012-06-20 16:38:30 -0700480 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +0530481 if ( i < WLAN_NON32_STA_COUNT )
482 {
483 pTLCb->atlSTAClients[i] = vos_mem_malloc(sizeof(WLANTL_STAClientType));
484 /* Allocating memory for LEGACY STA COUNT so as to avoid regression issues. */
485 if ( NULL == pTLCb->atlSTAClients[i] )
486 {
487 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR, "WLAN TL: StaClient allocation failed"));
488 WLANTL_FreeClientMemory(pTLCb->atlSTAClients);
489 vos_free_context(pvosGCtx, VOS_MODULE_ID_TL, pTLCb);
490 return VOS_STATUS_E_FAULT;
491 }
492 vos_mem_zero((v_VOID_t *) pTLCb->atlSTAClients[i], sizeof(WLANTL_STAClientType));
493 }
494 else
495 {
496 pTLCb->atlSTAClients[i] = NULL;
497 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700498 }
499
Sushant Kaushikf4a27972015-04-16 16:48:00 +0530500 pTLCb->reorderBufferPool = vos_mem_vmalloc(sizeof(WLANTL_REORDER_BUFFER_T) * WLANTL_MAX_BA_SESSION);
Jeff Johnson295189b2012-06-20 16:38:30 -0700501 if (NULL == pTLCb->reorderBufferPool)
502 {
Arif Hussainf2b00992013-11-17 21:46:15 -0800503 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 +0530504 WLANTL_FreeClientMemory(pTLCb->atlSTAClients);
Jeff Johnson295189b2012-06-20 16:38:30 -0700505 vos_free_context(pvosGCtx, VOS_MODULE_ID_TL, pTLCb);
506 return VOS_STATUS_E_FAULT;
Jeff Johnson295189b2012-06-20 16:38:30 -0700507 }
508
509 vos_mem_zero((v_VOID_t *)pTLCb->reorderBufferPool, sizeof(WLANTL_REORDER_BUFFER_T) * WLANTL_MAX_BA_SESSION);
510
511 WLANTL_CleanCB(pTLCb, 0 /*do not empty*/);
512
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +0530513 for ( ucIndex = 0; ucIndex < WLANTL_NUM_TX_QUEUES ; ucIndex++)
Jeff Johnson295189b2012-06-20 16:38:30 -0700514 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +0530515 pTLCb->tlConfigInfo.ucAcWeights[ucIndex] = pTLConfig->ucAcWeights[ucIndex];
Jeff Johnson295189b2012-06-20 16:38:30 -0700516 }
517
Dhanashri Atred8c20a32014-01-03 17:20:55 -0800518 for ( ucIndex = 0; ucIndex < WLANTL_MAX_AC ; ucIndex++)
519 {
520 pTLCb->tlConfigInfo.ucReorderAgingTime[ucIndex] = pTLConfig->ucReorderAgingTime[ucIndex];
521 }
522
Jeff Johnson295189b2012-06-20 16:38:30 -0700523 // scheduling init to be the last one of previous round
524 pTLCb->uCurServedAC = WLANTL_AC_BK;
525 pTLCb->ucCurLeftWeight = 1;
526 pTLCb->ucCurrentSTA = WLAN_MAX_STA_COUNT-1;
527
528#if 0
529 //flow control field init
530 vos_mem_zero(&pTLCb->tlFCInfo, sizeof(tFcTxParams_type));
531 //bit 0: set (Bd/pdu count) bit 1: set (request station PS change notification)
532 pTLCb->tlFCInfo.fcConfig = 0x1;
533#endif
534
535 pTLCb->vosTxFCBuf = NULL;
536 pTLCb->tlConfigInfo.uMinFramesProcThres =
537 pTLConfig->uMinFramesProcThres;
Jeff Johnson295189b2012-06-20 16:38:30 -0700538
Sunil Ravid5406f22013-01-22 00:18:31 -0800539#ifdef FEATURE_WLAN_TDLS
540 pTLCb->ucTdlsPeerCount = 0;
541#endif
542
Jeff Johnson295189b2012-06-20 16:38:30 -0700543 pTLCb->tlConfigInfo.uDelayedTriggerFrmInt =
544 pTLConfig->uDelayedTriggerFrmInt;
545
546 /*------------------------------------------------------------------------
547 Allocate internal resources
548 ------------------------------------------------------------------------*/
549 vos_pkt_get_packet(&pTLCb->vosDummyBuf, VOS_PKT_TYPE_RX_RAW, 1, 1,
550 1/*true*/,NULL, NULL);
551
552 WLANTL_InitBAReorderBuffer(pvosGCtx);
553#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
554 /* Initialize Handoff support modue
555 * RSSI measure and Traffic state monitoring */
556 status = WLANTL_HSInit(pvosGCtx);
557 if(!VOS_IS_STATUS_SUCCESS(status))
558 {
559 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
560 "Handoff support module init fail"));
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +0530561 WLANTL_FreeClientMemory(pTLCb->atlSTAClients);
Sushant Kaushikf4a27972015-04-16 16:48:00 +0530562 vos_mem_vfree(pTLCb->reorderBufferPool);
Jeff Johnson295189b2012-06-20 16:38:30 -0700563 vos_free_context(pvosGCtx, VOS_MODULE_ID_TL, pTLCb);
564 return status;
565 }
566#endif
567
568 pTLCb->isBMPS = VOS_FALSE;
569 pmcRegisterDeviceStateUpdateInd( smeContext,
570 WLANTL_PowerStateChangedCB, pvosGCtx );
571
572 return VOS_STATUS_SUCCESS;
573}/* WLANTL_Open */
574
575/*==========================================================================
576
577 FUNCTION WLANTL_Start
578
579 DESCRIPTION
580 Called by HDD as part of the overall start procedure. TL will use this
581 call to register with BAL as a transport layer entity.
582
583 DEPENDENCIES
584
585 PARAMETERS
586
587 IN
588 pvosGCtx: pointer to the global vos context; a handle to TL's
589 control block can be extracted from its context
590
591 RETURN VALUE
592 The result code associated with performing the operation
593
594 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a page
595 fault
596 VOS_STATUS_SUCCESS: Everything is good :)
597
598 Other codes can be returned as a result of a BAL failure; see BAL API
599 for more info
600
601 SIDE EFFECTS
602
603============================================================================*/
604VOS_STATUS
605WLANTL_Start
606(
607 v_PVOID_t pvosGCtx
608)
609{
610 WLANTL_CbType* pTLCb = NULL;
611 v_U32_t uResCount = WDA_TLI_MIN_RES_DATA;
612 VOS_STATUS vosStatus;
613 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
614
615 /*------------------------------------------------------------------------
616 Sanity check
617 Extract TL control block
618 ------------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +0530619 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -0700620 pTLCb = VOS_GET_TL_CB(pvosGCtx);
621 if ( NULL == pTLCb )
622 {
623 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
624 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_Start"));
625 return VOS_STATUS_E_FAULT;
626 }
627
628 /*------------------------------------------------------------------------
629 Register with WDA as transport layer client
630 Request resources for tx from bus
631 ------------------------------------------------------------------------*/
632 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
633 "WLAN TL:WLAN TL:WLANTL_Start"));
634
Katya Nigam42e16e82014-02-04 16:28:55 +0530635 tlTraceInit();
Jeff Johnson295189b2012-06-20 16:38:30 -0700636 vosStatus = WDA_DS_Register( pvosGCtx,
637 WLANTL_TxComp,
638 WLANTL_RxFrames,
639 WLANTL_GetFrames,
640 WLANTL_ResourceCB,
641 WDA_TLI_MIN_RES_DATA,
642 pvosGCtx,
643 &uResCount );
644
645 if ( VOS_STATUS_SUCCESS != vosStatus )
646 {
647 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
648 "WLAN TL:TL failed to register with BAL/WDA, Err: %d",
649 vosStatus));
650 return vosStatus;
651 }
652
653 /* Enable transmission */
654 vos_atomic_set_U8( &pTLCb->ucTxSuspended, 0);
655
656 pTLCb->uResCount = uResCount;
Jeff Johnson295189b2012-06-20 16:38:30 -0700657 return VOS_STATUS_SUCCESS;
658}/* WLANTL_Start */
659
660/*==========================================================================
661
662 FUNCTION WLANTL_Stop
663
664 DESCRIPTION
665 Called by HDD to stop operation in TL, before close. TL will suspend all
666 frame transfer operation and will wait for the close request to clean up
667 its resources.
668
669 DEPENDENCIES
670
671 PARAMETERS
672
673 IN
674 pvosGCtx: pointer to the global vos context; a handle to TL's
675 control block can be extracted from its context
676
677 RETURN VALUE
678 The result code associated with performing the operation
679
680 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a page
681 fault
682 VOS_STATUS_SUCCESS: Everything is good :)
683
684 SIDE EFFECTS
685
686============================================================================*/
687VOS_STATUS
688WLANTL_Stop
689(
690 v_PVOID_t pvosGCtx
691)
692{
693 WLANTL_CbType* pTLCb = NULL;
694 v_U8_t ucIndex;
695 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
696
697 /*------------------------------------------------------------------------
698 Sanity check
699 Extract TL control block
700 ------------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +0530701 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -0700702 pTLCb = VOS_GET_TL_CB(pvosGCtx);
703 if ( NULL == pTLCb )
704 {
705 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
706 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_ChangeSTAState"));
707 return VOS_STATUS_E_FAULT;
708 }
709
710 /*------------------------------------------------------------------------
711 Stop TL and empty Station list
712 ------------------------------------------------------------------------*/
713 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
714 "WLAN TL:WLANTL_Stop"));
715
716 /* Disable transmission */
717 vos_atomic_set_U8( &pTLCb->ucTxSuspended, 1);
718
719 if ( NULL != pTLCb->tlMgmtFrmClient.vosPendingDataBuff )
720 {
721 vos_pkt_return_packet(pTLCb->tlMgmtFrmClient.vosPendingDataBuff);
722 pTLCb->tlMgmtFrmClient.vosPendingDataBuff = NULL;
723 }
724
725 if ( NULL != pTLCb->tlBAPClient.vosPendingDataBuff )
726 {
727 vos_pkt_return_packet(pTLCb->tlBAPClient.vosPendingDataBuff);
728 pTLCb->tlBAPClient.vosPendingDataBuff = NULL;
729 }
730
731#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
732 if(VOS_STATUS_SUCCESS != WLANTL_HSStop(pvosGCtx))
733 {
734 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
735 "Handoff Support module stop fail"));
736 }
737#endif
738
739 /*-------------------------------------------------------------------------
740 Clean client stations
741 -------------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +0530742 for ( ucIndex = 0; ucIndex < WLAN_MAX_STA_COUNT; ucIndex++)
Jeff Johnson295189b2012-06-20 16:38:30 -0700743 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +0530744 if ( NULL != pTLCb->atlSTAClients[ucIndex] )
745 {
746 WLANTL_CleanSTA(pTLCb->atlSTAClients[ucIndex], 1 /*empty all queues*/);
747 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700748 }
749
750
751 return VOS_STATUS_SUCCESS;
752}/* WLANTL_Stop */
753
754/*==========================================================================
755
756 FUNCTION WLANTL_Close
757
758 DESCRIPTION
759 Called by HDD during general driver close procedure. TL will clean up
760 all the internal resources.
761
762 DEPENDENCIES
763
764 PARAMETERS
765
766 IN
767 pvosGCtx: pointer to the global vos context; a handle to TL's
768 control block can be extracted from its context
769
770 RETURN VALUE
771 The result code associated with performing the operation
772
773 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a page
774 fault
775 VOS_STATUS_SUCCESS: Everything is good :)
776
777 SIDE EFFECTS
778
779============================================================================*/
780VOS_STATUS
781WLANTL_Close
782(
783 v_PVOID_t pvosGCtx
784)
785{
786 WLANTL_CbType* pTLCb = NULL;
787 tHalHandle smeContext;
788 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
789
790 /*------------------------------------------------------------------------
791 Sanity check
792 Extract TL control block
793 ------------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +0530794 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -0700795 pTLCb = VOS_GET_TL_CB(pvosGCtx);
796 if ( NULL == pTLCb )
797 {
798 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
799 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_ChangeSTAState"));
800 return VOS_STATUS_E_FAULT;
801 }
802 /*------------------------------------------------------------------------
803 Deregister from PMC
804 ------------------------------------------------------------------------*/
805 smeContext = vos_get_context(VOS_MODULE_ID_SME, pvosGCtx);
806 if ( NULL == smeContext )
807 {
808 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700809 "%s: Invalid smeContext", __func__));
Jeff Johnson295189b2012-06-20 16:38:30 -0700810 // continue so that we can cleanup as much as possible
811 }
812 else
813 {
814 pmcDeregisterDeviceStateUpdateInd( smeContext, WLANTL_PowerStateChangedCB );
815 }
816
817#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
818 if(VOS_STATUS_SUCCESS != WLANTL_HSDeInit(pvosGCtx))
819 {
820 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
821 "Handoff Support module DeInit fail"));
822 }
823#endif
824
825 /*------------------------------------------------------------------------
826 Cleanup TL control block.
827 ------------------------------------------------------------------------*/
828 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
829 "WLAN TL: WLANTL_Close"));
830 WLANTL_CleanCB(pTLCb, 1 /* empty queues/lists/pkts if any*/);
831
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +0530832 WLANTL_FreeClientMemory(pTLCb->atlSTAClients);
833
Sushant Kaushikf4a27972015-04-16 16:48:00 +0530834 vos_mem_vfree(pTLCb->reorderBufferPool);
Jeff Johnson295189b2012-06-20 16:38:30 -0700835
836 /*------------------------------------------------------------------------
837 Free TL context from VOSS global
838 ------------------------------------------------------------------------*/
839 vos_free_context(pvosGCtx, VOS_MODULE_ID_TL, pTLCb);
840 return VOS_STATUS_SUCCESS;
841}/* WLANTL_Close */
842
843/*----------------------------------------------------------------------------
844 INTERACTION WITH HDD
845 ---------------------------------------------------------------------------*/
846/*==========================================================================
847
848 FUNCTION WLANTL_ConfigureSwFrameTXXlationForAll
849
850 DESCRIPTION
851 Function to disable/enable frame translation for all association stations.
852
853 DEPENDENCIES
854
855 PARAMETERS
856 IN
857 pvosGCtx: VOS context
858 EnableFrameXlation TRUE means enable SW translation for all stations.
859 .
860
861 RETURN VALUE
862
863 void.
864
865============================================================================*/
866void
867WLANTL_ConfigureSwFrameTXXlationForAll
868(
869 v_PVOID_t pvosGCtx,
870 v_BOOL_t enableFrameXlation
871)
872{
873 v_U8_t ucIndex;
874 /*------------------------------------------------------------------------
875 Extract TL control block
876 ------------------------------------------------------------------------*/
877 WLANTL_CbType* pTLCb = VOS_GET_TL_CB(pvosGCtx);
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +0530878 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -0700879 if ( NULL == pTLCb )
880 {
881 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
882 "WLAN TL:Invalid TL pointer from pvosGCtx on "
883 "WLANTL_ConfigureSwFrameTXXlationForAll"));
884 return;
885 }
886
887 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
888 "WLANTL_ConfigureSwFrameTXXlationForAll: Configure SW frameXlation %d",
889 enableFrameXlation));
890
891 for ( ucIndex = 0; ucIndex < WLAN_MAX_TID; ucIndex++)
892 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +0530893 pClientSTA = pTLCb->atlSTAClients[ucIndex];
894 if ( NULL != pClientSTA && 0 != pClientSTA->ucExists )
Jeff Johnson295189b2012-06-20 16:38:30 -0700895 {
896#ifdef WLAN_SOFTAP_VSTA_FEATURE
897 // if this station was not allocated resources to perform HW-based
898 // TX frame translation then force SW-based TX frame translation
899 // otherwise use the frame translation supplied by the client
900 if (!WDA_IsHwFrameTxTranslationCapable(pvosGCtx, ucIndex))
901 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +0530902 pClientSTA->wSTADesc.ucSwFrameTXXlation = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -0700903 }
904 else
905#endif
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +0530906 pClientSTA->wSTADesc.ucSwFrameTXXlation = enableFrameXlation;
Jeff Johnson295189b2012-06-20 16:38:30 -0700907 }
908 }
909}
910
911/*===========================================================================
912
913 FUNCTION WLANTL_StartForwarding
914
915 DESCRIPTION
916
917 This function is used to ask serialization through TX thread of the
918 cached frame forwarding (if statation has been registered in the mean while)
919 or flushing (if station has not been registered by the time)
920
921 In case of forwarding, upper layer is only required to call WLANTL_RegisterSTAClient()
922 and doesn't need to call this function explicitly. TL will handle this inside
923 WLANTL_RegisterSTAClient().
924
925 In case of flushing, upper layer is required to call this function explicitly
926
927 DEPENDENCIES
928
929 TL must have been initialized before this gets called.
930
931
932 PARAMETERS
933
934 ucSTAId: station id
935
936 RETURN VALUE
937
938 The result code associated with performing the operation
939 Please check return values of vos_tx_mq_serialize.
940
941 SIDE EFFECTS
942 If TL was asked to perform WLANTL_CacheSTAFrame() in WLANTL_RxFrames(),
943 either WLANTL_RegisterSTAClient() or this function must be called
944 within reasonable time. Otherwise, TL will keep cached vos buffer until
945 one of this function is called, and may end up with system buffer exhasution.
946
947 It's an upper layer's responsibility to call this function in case of
948 flushing
949
950============================================================================*/
951
952VOS_STATUS
953WLANTL_StartForwarding
954(
955 v_U8_t ucSTAId,
956 v_U8_t ucUcastSig,
957 v_U8_t ucBcastSig
958)
959{
960 vos_msg_t sMessage;
961 v_U32_t uData;
962 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
963
964 /* Signal the OS to serialize our event */
965 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
966 "Serializing TL Start Forwarding Cached for control STA %d",
967 ucSTAId );
968
969 vos_mem_zero( &sMessage, sizeof(vos_msg_t) );
970
971 uData = ucSTAId | (ucUcastSig << 8 ) | (ucBcastSig << 16);
Jeff Johnsond86c05a2013-11-10 18:50:34 -0800972 sMessage.bodyval = uData;
Katya Nigam664f5032014-05-05 12:24:32 +0530973 sMessage.type = WLANTL_RX_FWD_CACHED;
Jeff Johnson295189b2012-06-20 16:38:30 -0700974
Katya Nigam664f5032014-05-05 12:24:32 +0530975 return vos_rx_mq_serialize(VOS_MQ_ID_TL, &sMessage);
Jeff Johnson295189b2012-06-20 16:38:30 -0700976
977} /* WLANTL_StartForwarding() */
978
979/*===========================================================================
980
Katya Nigam63902932014-06-26 19:04:23 +0530981 FUNCTION WLANTL_EnableCaching
982
983 DESCRIPTION
984
985 This function is used to enable caching only when assoc/reassoc req is send.
986 that is cache packets only for such STA ID.
987
988
989 DEPENDENCIES
990
991 TL must have been initialized before this gets called.
992
993
994 PARAMETERS
995
996 staId: station id
997
998 RETURN VALUE
999
1000 none
1001
1002============================================================================*/
1003void WLANTL_EnableCaching(v_U8_t staId)
1004{
1005 v_PVOID_t pvosGCtx= vos_get_global_context(VOS_MODULE_ID_TL,NULL);
1006 WLANTL_CbType* pTLCb = VOS_GET_TL_CB(pvosGCtx);
1007 if ( NULL == pTLCb )
1008 {
1009 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1010 "WLAN TL:Invalid TL pointer from pvosGCtx on "
1011 "WLANTL_EnableCaching"));
1012 return;
1013 }
1014 pTLCb->atlSTAClients[staId]->enableCaching = 1;
1015}
1016
1017/*===========================================================================
1018
Jeff Johnson295189b2012-06-20 16:38:30 -07001019 FUNCTION WLANTL_AssocFailed
1020
1021 DESCRIPTION
1022
1023 This function is used by PE to notify TL that cache needs to flushed'
1024 when association is not successfully completed
1025
1026 Internally, TL post a message to TX_Thread to serialize the request to
1027 keep lock-free mechanism.
1028
1029
1030 DEPENDENCIES
1031
1032 TL must have been initialized before this gets called.
1033
1034
1035 PARAMETERS
1036
1037 ucSTAId: station id
1038
1039 RETURN VALUE
1040
1041 none
1042
1043 SIDE EFFECTS
1044 There may be race condition that PE call this API and send another association
1045 request immediately with same staId before TX_thread can process the message.
1046
1047 To avoid this, we might need PE to wait for TX_thread process the message,
1048 but this is not currently implemented.
1049
1050============================================================================*/
1051void WLANTL_AssocFailed(v_U8_t staId)
1052{
1053 // flushing frames and forwarding frames uses the same message
1054 // the only difference is what happens when the message is processed
1055 // if the STA exist, the frames will be forwarded
1056 // and if it doesn't exist, the frames will be flushed
1057 // in this case we know it won't exist so the DPU index signature values don't matter
Mihir Sheteae6f02b2014-04-11 19:49:21 +05301058 MTRACE(vos_trace(VOS_MODULE_ID_TL, TRACE_CODE_TL_ASSOC_FAILED,
1059 staId, 0));
1060
Jeff Johnson295189b2012-06-20 16:38:30 -07001061 if(!VOS_IS_STATUS_SUCCESS(WLANTL_StartForwarding(staId,0,0)))
1062 {
1063 VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Mihir Sheteb7337272014-04-11 15:53:08 +05301064 " %s fails to start forwarding (staId %d)", __func__, staId);
Jeff Johnson295189b2012-06-20 16:38:30 -07001065 }
1066}
Nirav Shah4f765af2015-01-21 19:51:30 +05301067
Nirav Shah4b53d4b2015-05-08 05:35:00 -07001068 /*===========================================================================
Jeff Johnson295189b2012-06-20 16:38:30 -07001069
1070 FUNCTION WLANTL_Finish_ULA
1071
1072 DESCRIPTION
1073 This function is used by HDD to notify TL to finish Upper layer authentication
1074 incase the last EAPOL packet is pending in the TL queue.
1075 To avoid the race condition between sme set key and the last EAPOL packet
1076 the HDD module calls this function just before calling the sme_RoamSetKey.
1077
1078 DEPENDENCIES
1079
1080 TL must have been initialized before this gets called.
Nirav Shah4f765af2015-01-21 19:51:30 +05301081
Jeff Johnson295189b2012-06-20 16:38:30 -07001082 PARAMETERS
1083
Nirav Shah4b53d4b2015-05-08 05:35:00 -07001084 callbackRoutine: HDD Callback function.
1085 callbackContext : HDD userdata context.
Nirav Shah4f765af2015-01-21 19:51:30 +05301086
Jeff Johnson295189b2012-06-20 16:38:30 -07001087 RETURN VALUE
1088
1089 VOS_STATUS_SUCCESS/VOS_STATUS_FAILURE
Nirav Shah4f765af2015-01-21 19:51:30 +05301090
Jeff Johnson295189b2012-06-20 16:38:30 -07001091 SIDE EFFECTS
Nirav Shah4f765af2015-01-21 19:51:30 +05301092
Jeff Johnson295189b2012-06-20 16:38:30 -07001093============================================================================*/
1094
1095VOS_STATUS WLANTL_Finish_ULA( void (*callbackRoutine) (void *callbackContext),
Nirav Shah4b53d4b2015-05-08 05:35:00 -07001096 void *callbackContext)
Jeff Johnson295189b2012-06-20 16:38:30 -07001097{
Nirav Shah4b53d4b2015-05-08 05:35:00 -07001098 return WDA_DS_FinishULA( callbackRoutine, callbackContext);
Nirav Shah4f765af2015-01-21 19:51:30 +05301099}
Jeff Johnson295189b2012-06-20 16:38:30 -07001100
Nirav Shah4b53d4b2015-05-08 05:35:00 -07001101
Jeff Johnson295189b2012-06-20 16:38:30 -07001102/*===========================================================================
1103
1104 FUNCTION WLANTL_RegisterSTAClient
1105
1106 DESCRIPTION
1107
1108 This function is used by HDD to register as a client for data services
1109 with TL. HDD will call this API for each new station that it adds,
1110 thus having the flexibility of registering different callback for each
1111 STA it services.
1112
1113 DEPENDENCIES
1114
1115 TL must have been initialized before this gets called.
1116
1117 Restriction:
1118 Main thread will have higher priority that Tx and Rx threads thus
1119 guaranteeing that a station will be added before any data can be
1120 received for it. (This enables TL to be lock free)
1121
1122 PARAMETERS
1123
1124 pvosGCtx: pointer to the global vos context; a handle to TL's
1125 control block can be extracted from its context
1126 pfnStARx: function pointer to the receive packet handler from HDD
1127 pfnSTATxComp: function pointer to the transmit complete confirmation
1128 handler from HDD
1129 pfnSTAFetchPkt: function pointer to the packet retrieval routine in HDD
1130 wSTADescType: STA Descriptor, contains information related to the
1131 new added STA
1132
1133 RETURN VALUE
1134
1135 The result code associated with performing the operation
1136
1137 VOS_STATUS_E_INVAL: Input parameters are invalid
1138 VOS_STATUS_E_FAULT: Station ID is outside array boundaries or pointer to
1139 TL cb is NULL ; access would cause a page fault
1140 VOS_STATUS_E_EXISTS: Station was already registered
1141 VOS_STATUS_SUCCESS: Everything is good :)
1142
1143 SIDE EFFECTS
1144
1145============================================================================*/
1146VOS_STATUS
1147WLANTL_RegisterSTAClient
1148(
1149 v_PVOID_t pvosGCtx,
1150 WLANTL_STARxCBType pfnSTARx,
1151 WLANTL_TxCompCBType pfnSTATxComp,
1152 WLANTL_STAFetchPktCBType pfnSTAFetchPkt,
1153 WLAN_STADescType* pwSTADescType,
1154 v_S7_t rssi
1155)
1156{
1157 WLANTL_CbType* pTLCb = NULL;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301158 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07001159 v_U8_t ucTid = 0;/*Local variable to clear previous replay counters of STA on all TIDs*/
Jeff Johnson295189b2012-06-20 16:38:30 -07001160 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
1161
1162 /*------------------------------------------------------------------------
1163 Sanity check
1164 ------------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301165 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -07001166 if (( NULL == pwSTADescType ) || ( NULL == pfnSTARx ) ||
1167 ( NULL == pfnSTAFetchPkt ))
1168 {
1169 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1170 "WLAN TL:Invalid parameter sent on WLANTL_RegisterSTAClient"));
1171 return VOS_STATUS_E_INVAL;
1172 }
1173
1174 if ( WLANTL_STA_ID_INVALID( pwSTADescType->ucSTAId ) )
1175 {
1176 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1177 "WLAN TL:Invalid station id requested on WLANTL_RegisterSTAClient"));
1178 return VOS_STATUS_E_FAULT;
1179 }
1180
1181 /*------------------------------------------------------------------------
1182 Extract TL control block
1183 ------------------------------------------------------------------------*/
1184 pTLCb = VOS_GET_TL_CB(pvosGCtx);
1185 if ( NULL == pTLCb )
1186 {
1187 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1188 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_RegisterSTAClient"));
1189 return VOS_STATUS_E_FAULT;
1190 }
1191
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301192 //Code for checking and allocating memory for new STA
1193 if ( NULL == pTLCb->atlSTAClients[pwSTADescType->ucSTAId] ){
1194 pTLCb->atlSTAClients[pwSTADescType->ucSTAId] = vos_mem_malloc(sizeof(WLANTL_STAClientType));
1195 if ( NULL == pTLCb->atlSTAClients[pwSTADescType->ucSTAId] ){
1196 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1197 "WLAN TL: STA Client memory allocation failed in WLANTL_RegisterSTAClient"));
1198 return VOS_STATUS_E_FAILURE;
1199 }
1200 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
1201 "WLAN TL: STA Client memory allocation in WLANTL_RegisterSTAClient"));
1202 vos_mem_zero((v_VOID_t *) pTLCb->atlSTAClients[pwSTADescType->ucSTAId],sizeof(WLANTL_STAClientType));
1203 }
1204
1205 //Assigning the pointer to local variable for easy access in future
1206 pClientSTA = pTLCb->atlSTAClients[pwSTADescType->ucSTAId];
1207 if ( 0 != pClientSTA->ucExists )
Jeff Johnson295189b2012-06-20 16:38:30 -07001208 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301209 pClientSTA->ucExists++;
Jeff Johnson295189b2012-06-20 16:38:30 -07001210 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1211 "WLAN TL:Station was already registered on WLANTL_RegisterSTAClient"));
1212 return VOS_STATUS_E_EXISTS;
1213 }
1214
1215 /*------------------------------------------------------------------------
1216 Register station with TL
1217 ------------------------------------------------------------------------*/
Katya Nigam42e16e82014-02-04 16:28:55 +05301218 MTRACE(vos_trace(VOS_MODULE_ID_TL, TRACE_CODE_TL_REGISTER_STA_CLIENT,
1219 pwSTADescType->ucSTAId, (unsigned )
1220 (*(pwSTADescType->vSTAMACAddress.bytes+2)<<24 |
1221 *(pwSTADescType->vSTAMACAddress.bytes+3)<<16 |
1222 *(pwSTADescType->vSTAMACAddress.bytes+4)<<8 |
1223 *(pwSTADescType->vSTAMACAddress.bytes+5))));
1224
Jeff Johnson295189b2012-06-20 16:38:30 -07001225 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
1226 "WLAN TL:Registering STA Client ID: %d", pwSTADescType->ucSTAId ));
1227
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301228 pClientSTA->pfnSTARx = pfnSTARx;
1229 pClientSTA->pfnSTAFetchPkt = pfnSTAFetchPkt;
Jeff Johnson295189b2012-06-20 16:38:30 -07001230
1231 /* Only register if different from NULL - TL default Tx Comp Cb will
1232 release the vos packet */
1233 if ( NULL != pfnSTATxComp )
1234 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301235 pClientSTA->pfnSTATxComp = pfnSTATxComp;
Jeff Johnson295189b2012-06-20 16:38:30 -07001236 }
1237
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301238 pClientSTA->tlState = WLANTL_STA_INIT;
1239 pClientSTA->tlPri = WLANTL_STA_PRI_NORMAL;
1240 pClientSTA->wSTADesc.ucSTAId = pwSTADescType->ucSTAId;
Gopichand Nakkala8b54e912013-03-11 10:44:21 +05301241 pClientSTA->ptkInstalled = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001242
1243 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
1244 "WLAN TL:Registering STA Client ID: %d with UC %d and BC %d",
1245 pwSTADescType->ucSTAId,
1246 pwSTADescType->ucUcastSig, pwSTADescType->ucBcastSig));
1247
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301248 pClientSTA->wSTADesc.wSTAType = pwSTADescType->wSTAType;
Jeff Johnson295189b2012-06-20 16:38:30 -07001249
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301250 pClientSTA->wSTADesc.ucQosEnabled = pwSTADescType->ucQosEnabled;
Jeff Johnson295189b2012-06-20 16:38:30 -07001251
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301252 pClientSTA->wSTADesc.ucAddRmvLLC = pwSTADescType->ucAddRmvLLC;
Jeff Johnson295189b2012-06-20 16:38:30 -07001253
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301254 pClientSTA->wSTADesc.ucProtectedFrame = pwSTADescType->ucProtectedFrame;
Jeff Johnson295189b2012-06-20 16:38:30 -07001255
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001256#ifdef FEATURE_WLAN_ESE
1257 pClientSTA->wSTADesc.ucIsEseSta = pwSTADescType->ucIsEseSta;
Jeff Johnson295189b2012-06-20 16:38:30 -07001258
1259 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001260 "WLAN TL:Registering STA Client ID: %d QoS %d Add LLC %d ProtFrame %d EseSta %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07001261 pwSTADescType->ucSTAId,
1262 pwSTADescType->ucQosEnabled,
1263 pwSTADescType->ucAddRmvLLC,
1264 pwSTADescType->ucProtectedFrame,
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001265 pwSTADescType->ucIsEseSta));
Jeff Johnson295189b2012-06-20 16:38:30 -07001266#else
1267
1268 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
1269 "WLAN TL:Registering STA Client ID: %d QoS %d Add LLC %d ProtFrame %d",
1270 pwSTADescType->ucSTAId,
1271 pwSTADescType->ucQosEnabled,
1272 pwSTADescType->ucAddRmvLLC,
1273 pwSTADescType->ucProtectedFrame));
1274
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001275#endif //FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07001276#ifdef WLAN_SOFTAP_VSTA_FEATURE
1277 // if this station was not allocated resources to perform HW-based
1278 // TX frame translation then force SW-based TX frame translation
1279 // otherwise use the frame translation supplied by the client
1280
1281 if (!WDA_IsHwFrameTxTranslationCapable(pvosGCtx, pwSTADescType->ucSTAId)
1282 || ( WLAN_STA_BT_AMP == pwSTADescType->wSTAType))
1283 {
1284 pwSTADescType->ucSwFrameTXXlation = 1;
1285 }
1286#endif
1287
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301288 pClientSTA->wSTADesc.ucSwFrameTXXlation = pwSTADescType->ucSwFrameTXXlation;
1289 pClientSTA->wSTADesc.ucSwFrameRXXlation = pwSTADescType->ucSwFrameRXXlation;
Jeff Johnson295189b2012-06-20 16:38:30 -07001290
1291#ifdef FEATURE_WLAN_WAPI
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301292 pClientSTA->wSTADesc.ucIsWapiSta = pwSTADescType->ucIsWapiSta;
Jeff Johnson295189b2012-06-20 16:38:30 -07001293#endif /* FEATURE_WLAN_WAPI */
1294
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301295 vos_copy_macaddr( &pClientSTA->wSTADesc.vSTAMACAddress, &pwSTADescType->vSTAMACAddress);
Jeff Johnson295189b2012-06-20 16:38:30 -07001296
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301297 vos_copy_macaddr( &pClientSTA->wSTADesc.vBSSIDforIBSS, &pwSTADescType->vBSSIDforIBSS);
Jeff Johnson295189b2012-06-20 16:38:30 -07001298
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301299 vos_copy_macaddr( &pClientSTA->wSTADesc.vSelfMACAddress, &pwSTADescType->vSelfMACAddress);
Jeff Johnson295189b2012-06-20 16:38:30 -07001300
Jeff Johnson295189b2012-06-20 16:38:30 -07001301 /* In volans release L replay check is done at TL */
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301302 pClientSTA->ucIsReplayCheckValid = pwSTADescType->ucIsReplayCheckValid;
1303 pClientSTA->ulTotalReplayPacketsDetected = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001304/*Clear replay counters of the STA on all TIDs*/
1305 for(ucTid = 0; ucTid < WLANTL_MAX_TID ; ucTid++)
1306 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301307 pClientSTA->ullReplayCounter[ucTid] = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001308 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001309
1310 /*--------------------------------------------------------------------
1311 Set the AC for the registered station to the highest priority AC
1312 Even if this AC is not supported by the station, correction will be
1313 made in the main TL loop after the supported mask is properly
1314 updated in the pending packets call
1315 --------------------------------------------------------------------*/
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05301316 pClientSTA->ucCurrentAC = WLANTL_AC_HIGH_PRIO;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301317 pClientSTA->ucCurrentWeight = 0;
1318 pClientSTA->ucServicedAC = WLANTL_AC_BK;
1319 pClientSTA->ucEapolPktPending = 0;
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -07001320
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301321 vos_mem_zero( pClientSTA->aucACMask, sizeof(pClientSTA->aucACMask));
Jeff Johnson295189b2012-06-20 16:38:30 -07001322
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301323 vos_mem_zero( &pClientSTA->wUAPSDInfo, sizeof(pClientSTA->wUAPSDInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -07001324
1325 /*--------------------------------------------------------------------
1326 Reordering info and AMSDU de-aggregation
1327 --------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301328 vos_mem_zero( pClientSTA->atlBAReorderInfo,
1329 sizeof(pClientSTA->atlBAReorderInfo[0])*
Jeff Johnson295189b2012-06-20 16:38:30 -07001330 WLAN_MAX_TID);
1331
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301332 vos_mem_zero( pClientSTA->aucMPDUHeader,
Jeff Johnson295189b2012-06-20 16:38:30 -07001333 WLANTL_MPDU_HEADER_LEN);
1334
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301335 pClientSTA->ucMPDUHeaderLen = 0;
1336 pClientSTA->vosAMSDUChain = NULL;
1337 pClientSTA->vosAMSDUChainRoot = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07001338
1339
Leo Chang6b6faaf2014-01-24 21:21:26 -08001340 /* Reorder LOCK
1341 * During handle normal RX frame within RX thread,
1342 * if MC thread try to preempt, ADDBA, DELBA, TIMER
1343 * Context should be protected from race */
1344 for (ucTid = 0; ucTid < WLAN_MAX_TID ; ucTid++)
1345 {
1346 if (!VOS_IS_STATUS_SUCCESS(
1347 vos_lock_init(&pClientSTA->atlBAReorderInfo[ucTid].reorderLock)))
1348 {
1349 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1350 "Lock Init Fail"));
1351 return VOS_STATUS_E_FAILURE;
1352 }
1353 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001354 /*--------------------------------------------------------------------
1355 Stats info
1356 --------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301357 vos_mem_zero( pClientSTA->auRxCount,
1358 sizeof(pClientSTA->auRxCount[0])*
Jeff Johnson295189b2012-06-20 16:38:30 -07001359 WLAN_MAX_TID);
1360
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301361 vos_mem_zero( pClientSTA->auTxCount,
1362 sizeof(pClientSTA->auRxCount[0])*
Jeff Johnson295189b2012-06-20 16:38:30 -07001363 WLAN_MAX_TID);
1364 /* Initial RSSI is always reported as zero because TL doesnt have enough
1365 data to calculate RSSI. So to avoid reporting zero, we are initializing
1366 RSSI with RSSI saved in BssDescription during scanning. */
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301367 pClientSTA->rssiAvg = rssi;
Shailender Karmuchi13c0d082013-03-26 14:41:39 -07001368#ifdef FEATURE_WLAN_TDLS
1369 if(WLAN_STA_TDLS == pClientSTA->wSTADesc.wSTAType)
1370 {
1371 /* If client is TDLS, use TDLS specific alpha */
1372 pClientSTA->rssiAlpha = WLANTL_HO_TDLS_ALPHA;
1373 }
1374 else
1375 {
1376 pClientSTA->rssiAlpha = WLANTL_HO_DEFAULT_ALPHA;
1377 }
1378#else
1379 pClientSTA->rssiAlpha = WLANTL_HO_DEFAULT_ALPHA;
1380#endif /* FEATURE_WLAN_TDLS */
Dino Mycle3b9536d2014-07-09 22:05:24 +05301381#ifdef WLAN_FEATURE_LINK_LAYER_STATS
1382 pClientSTA->rssiDataAlpha = WLANTL_HO_DEFAULT_ALPHA;
1383 pClientSTA->interfaceStats.accessCategoryStats[0].ac = WLANTL_AC_BK;
1384 pClientSTA->interfaceStats.accessCategoryStats[1].ac = WLANTL_AC_BE;
1385 pClientSTA->interfaceStats.accessCategoryStats[2].ac = WLANTL_AC_VI;
1386 pClientSTA->interfaceStats.accessCategoryStats[3].ac = WLANTL_AC_VO;
1387#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001388
1389 /*Tx not suspended and station fully registered*/
1390 vos_atomic_set_U8(
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301391 &pClientSTA->ucTxSuspended, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07001392
1393 /* Used until multiple station support will be added*/
1394 pTLCb->ucRegisteredStaId = pwSTADescType->ucSTAId;
1395
1396 /* Save the BAP station ID for future usage */
1397 if ( WLAN_STA_BT_AMP == pwSTADescType->wSTAType )
1398 {
1399 pTLCb->tlBAPClient.ucBAPSTAId = pwSTADescType->ucSTAId;
1400 }
1401
1402 /*------------------------------------------------------------------------
1403 Statistics info
1404 -----------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301405 memset(&pClientSTA->trafficStatistics,
Jeff Johnson295189b2012-06-20 16:38:30 -07001406 0, sizeof(WLANTL_TRANSFER_STA_TYPE));
1407
1408
1409 /*------------------------------------------------------------------------
1410 Start with the state suggested by client caller
1411 -----------------------------------------------------------------------*/
Madan Mohan Koyylamudi64258222013-01-30 14:35:10 +05301412 pClientSTA->tlState = pwSTADescType->ucInitState;
Jeff Johnson295189b2012-06-20 16:38:30 -07001413 /*-----------------------------------------------------------------------
1414 After all the init is complete we can mark the existance flag
1415 ----------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301416 pClientSTA->ucExists++;
Jeff Johnson295189b2012-06-20 16:38:30 -07001417
Jeff Johnson295189b2012-06-20 16:38:30 -07001418 //flow control fields init
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301419 pClientSTA->ucLwmModeEnabled = FALSE;
1420 pClientSTA->ucLwmEventReported = FALSE;
1421 pClientSTA->bmuMemConsumed = 0;
1422 pClientSTA->uIngress_length = 0;
1423 pClientSTA->uBuffThresholdMax = WLANTL_STA_BMU_THRESHOLD_MAX;
Jeff Johnson295189b2012-06-20 16:38:30 -07001424
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301425 pClientSTA->uLwmThreshold = WLANTL_STA_BMU_THRESHOLD_MAX / 3;
Jeff Johnson295189b2012-06-20 16:38:30 -07001426
1427 //@@@ HDDSOFTAP does not queue unregistered packet for now
1428 if ( WLAN_STA_SOFTAP != pwSTADescType->wSTAType )
1429 {
Jeff Johnson295189b2012-06-20 16:38:30 -07001430 /*------------------------------------------------------------------------
1431 Forward received frames while STA was not yet registered
1432 - ----------------------------------------------------------------------*/
1433 if(!VOS_IS_STATUS_SUCCESS(WLANTL_StartForwarding( pwSTADescType->ucSTAId,
1434 pwSTADescType->ucUcastSig,
1435 pwSTADescType->ucBcastSig)))
1436 {
1437 VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001438 " %s fails to start forwarding", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001439 }
Sunil Ravid5406f22013-01-22 00:18:31 -08001440#ifdef FEATURE_WLAN_TDLS
1441 if( WLAN_STA_TDLS == pwSTADescType->wSTAType )
1442 pTLCb->ucTdlsPeerCount++;
1443#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001444 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001445 return VOS_STATUS_SUCCESS;
1446}/* WLANTL_RegisterSTAClient */
1447
1448/*===========================================================================
1449
1450 FUNCTION WLANTL_ClearSTAClient
1451
1452 DESCRIPTION
1453
1454 HDD will call this API when it no longer needs data services for the
1455 particular station.
1456
1457 DEPENDENCIES
1458
1459 A station must have been registered before the clear registration is
1460 called.
1461
1462 PARAMETERS
1463
1464 pvosGCtx: pointer to the global vos context; a handle to TL's
1465 control block can be extracted from its context
1466 ucSTAId: identifier for the STA to be cleared
1467
1468 RETURN VALUE
1469
1470 The result code associated with performing the operation
1471
1472 VOS_STATUS_E_FAULT: Station ID is outside array boundaries or pointer to
1473 TL cb is NULL ; access would cause a page fault
1474 VOS_STATUS_E_EXISTS: Station was not registered
1475 VOS_STATUS_SUCCESS: Everything is good :)
1476
1477 SIDE EFFECTS
1478
1479============================================================================*/
1480VOS_STATUS
1481WLANTL_ClearSTAClient
1482(
1483 v_PVOID_t pvosGCtx,
1484 v_U8_t ucSTAId
1485)
1486{
1487 WLANTL_CbType* pTLCb = NULL;
1488 v_U8_t ucIndex;
1489 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
1490
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301491 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -07001492 /*------------------------------------------------------------------------
1493 Sanity check
1494 ------------------------------------------------------------------------*/
1495 if ( WLANTL_STA_ID_INVALID( ucSTAId ) )
1496 {
1497 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1498 "WLAN TL:Invalid station id requested on WLANTL_ClearSTAClient"));
1499 return VOS_STATUS_E_FAULT;
1500 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001501 /*------------------------------------------------------------------------
1502 Extract TL control block
1503 ------------------------------------------------------------------------*/
1504 pTLCb = VOS_GET_TL_CB(pvosGCtx);
1505 if ( NULL == pTLCb )
1506 {
1507 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1508 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_ClearSTAClient"));
1509 return VOS_STATUS_E_FAULT;
1510 }
1511
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301512 if ( NULL == pTLCb->atlSTAClients[ucSTAId] )
1513 {
1514 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1515 "WLAN TL:Client Memory was not allocated on %s", __func__));
1516 return VOS_STATUS_E_FAILURE;
1517 }
1518
1519 if ( 0 == pTLCb->atlSTAClients[ucSTAId]->ucExists )
Jeff Johnson295189b2012-06-20 16:38:30 -07001520 {
1521 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1522 "WLAN TL:Station was not previously registered on WLANTL_ClearSTAClient"));
Siddharth Bhalaef8ee12014-04-02 00:09:45 +05301523 /* Clean packets cached for the STA */
1524 WLANTL_StartForwarding(ucSTAId,0,0);
Jeff Johnson295189b2012-06-20 16:38:30 -07001525 return VOS_STATUS_E_EXISTS;
1526 }
1527
1528 /* Delete BA sessions on all TID's */
Leo Chang6b6faaf2014-01-24 21:21:26 -08001529 for (ucIndex = 0; ucIndex < WLAN_MAX_TID ; ucIndex++)
Jeff Johnson295189b2012-06-20 16:38:30 -07001530 {
Leo Chang6b6faaf2014-01-24 21:21:26 -08001531 WLANTL_BaSessionDel(pvosGCtx, ucSTAId, ucIndex);
1532 vos_lock_destroy(&pTLCb->atlSTAClients[ucSTAId]->atlBAReorderInfo[ucIndex].reorderLock);
Jeff Johnson295189b2012-06-20 16:38:30 -07001533 }
1534
Sunil Ravid5406f22013-01-22 00:18:31 -08001535#ifdef FEATURE_WLAN_TDLS
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301536 /* decrement ucTdlsPeerCount only if it is non-zero */
1537 if(WLAN_STA_TDLS == pTLCb->atlSTAClients[ucSTAId]->wSTADesc.wSTAType
Sunil Ravid5406f22013-01-22 00:18:31 -08001538 && pTLCb->ucTdlsPeerCount)
1539 pTLCb->ucTdlsPeerCount--;
1540#endif
1541
Jeff Johnson295189b2012-06-20 16:38:30 -07001542 /*------------------------------------------------------------------------
1543 Clear station
1544 ------------------------------------------------------------------------*/
1545 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
1546 "WLAN TL:Clearing STA Client ID: %d", ucSTAId ));
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301547 WLANTL_CleanSTA(pTLCb->atlSTAClients[ucSTAId], 1 /*empty packets*/);
Jeff Johnson295189b2012-06-20 16:38:30 -07001548
1549 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
1550 "WLAN TL:Clearing STA Reset History RSSI and Region number"));
1551 pTLCb->hoSupport.currentHOState.historyRSSI = 0;
1552 pTLCb->hoSupport.currentHOState.regionNumber = 0;
1553
1554 return VOS_STATUS_SUCCESS;
1555}/* WLANTL_ClearSTAClient */
1556
1557/*===========================================================================
1558
1559 FUNCTION WLANTL_ChangeSTAState
1560
1561 DESCRIPTION
1562
1563 HDD will make this notification whenever a change occurs in the
1564 connectivity state of a particular STA.
1565
1566 DEPENDENCIES
1567
1568 A station must have been registered before the change state can be
1569 called.
1570
1571 RESTRICTION: A station is being notified as authenticated before the
1572 keys are installed in HW. This way if a frame is received
1573 before the keys are installed DPU will drop that frame.
1574
1575 Main thread has higher priority that Tx and Rx threads thus guaranteeing
1576 the following:
1577 - a station will be in assoc state in TL before TL receives any data
1578 for it
1579
1580 PARAMETERS
1581
1582 pvosGCtx: pointer to the global vos context; a handle to TL's
1583 control block can be extracted from its context
1584 ucSTAId: identifier for the STA that is pending transmission
1585 tlSTAState: the new state of the connection to the given station
1586
1587
1588 RETURN VALUE
1589
1590 The result code associated with performing the operation
1591
1592 VOS_STATUS_E_INVAL: Input parameters are invalid
1593 VOS_STATUS_E_FAULT: Station ID is outside array boundaries or pointer to
1594 TL cb is NULL ; access would cause a page fault
1595 VOS_STATUS_E_EXISTS: Station was not registered
1596 VOS_STATUS_SUCCESS: Everything is good :)
1597
1598 SIDE EFFECTS
1599
1600============================================================================*/
1601VOS_STATUS
1602WLANTL_ChangeSTAState
1603(
1604 v_PVOID_t pvosGCtx,
1605 v_U8_t ucSTAId,
1606 WLANTL_STAStateType tlSTAState
1607)
1608{
1609 WLANTL_CbType* pTLCb = NULL;
1610 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
1611
1612 /*------------------------------------------------------------------------
1613 Sanity check
1614 ------------------------------------------------------------------------*/
1615 if ( tlSTAState >= WLANTL_STA_MAX_STATE )
1616 {
1617 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1618 "WLAN TL:Invalid parameter sent on WLANTL_ChangeSTAState"));
1619 return VOS_STATUS_E_INVAL;
1620 }
1621
1622 if ( WLANTL_STA_ID_INVALID( ucSTAId ) )
1623 {
1624 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1625 "WLAN TL:Invalid station id requested on WLANTL_ChangeSTAState"));
1626 return VOS_STATUS_E_FAULT;
1627 }
1628
1629 /*------------------------------------------------------------------------
1630 Extract TL control block and check existance
1631 ------------------------------------------------------------------------*/
1632 pTLCb = VOS_GET_TL_CB(pvosGCtx);
1633 if ( NULL == pTLCb )
1634 {
1635 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1636 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_ChangeSTAState"));
1637 return VOS_STATUS_E_FAULT;
1638 }
1639
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301640 if ( NULL == pTLCb->atlSTAClients[ucSTAId] )
1641 {
1642 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1643 "WLAN TL:Client Memory was not allocated on %s", __func__));
1644 return VOS_STATUS_E_FAILURE;
1645 }
1646
1647 if ( 0 == pTLCb->atlSTAClients[ucSTAId]->ucExists )
Jeff Johnson295189b2012-06-20 16:38:30 -07001648 {
1649 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1650 "WLAN TL:Station was not previously registered on WLANTL_ChangeSTAState"));
1651 return VOS_STATUS_E_EXISTS;
1652 }
1653
1654 /*------------------------------------------------------------------------
1655 Change STA state
1656 No need to lock this operation, see restrictions above
1657 ------------------------------------------------------------------------*/
1658 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
1659 "WLAN TL:Changing state for STA Client ID: %d from %d to %d",
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301660 ucSTAId, pTLCb->atlSTAClients[ucSTAId]->tlState, tlSTAState));
Jeff Johnson295189b2012-06-20 16:38:30 -07001661
Katya Nigam42e16e82014-02-04 16:28:55 +05301662 MTRACE(vos_trace(VOS_MODULE_ID_TL,
1663 TRACE_CODE_TL_STA_STATE, ucSTAId,tlSTAState ));
1664
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301665 pTLCb->atlSTAClients[ucSTAId]->tlState = tlSTAState;
Jeff Johnson295189b2012-06-20 16:38:30 -07001666
1667 return VOS_STATUS_SUCCESS;
1668}/* WLANTL_ChangeSTAState */
1669
1670/*===========================================================================
1671
Agarwal Ashish16020c42014-12-29 22:01:11 +05301672 FUNCTION WLANTL_UpdateTdlsSTAClient
1673
1674 DESCRIPTION
1675
1676 HDD will call this API when ENABLE_LINK happens and HDD want to
1677 register QoS or other params for TDLS peers.
1678
1679 DEPENDENCIES
1680
1681 A station must have been registered before the WMM/QOS registration is
1682 called.
1683
1684 PARAMETERS
1685
1686 pvosGCtx: pointer to the global vos context; a handle to TL's
1687 control block can be extracted from its context
1688 wSTADescType: STA Descriptor, contains information related to the
1689 new added STA
1690
1691 RETURN VALUE
1692
1693 The result code associated with performing the operation
1694
1695 VOS_STATUS_E_FAULT: Station ID is outside array boundaries or pointer to
1696 TL cb is NULL ; access would cause a page fault
1697 VOS_STATUS_E_EXISTS: Station was not registered
1698 VOS_STATUS_SUCCESS: Everything is good :)
1699
1700 SIDE EFFECTS
1701
1702============================================================================*/
1703
1704VOS_STATUS
1705WLANTL_UpdateTdlsSTAClient
1706(
1707 v_PVOID_t pvosGCtx,
1708 WLAN_STADescType* pwSTADescType
1709)
1710{
1711 WLANTL_CbType* pTLCb = NULL;
1712 WLANTL_STAClientType* pClientSTA = NULL;
1713 /*------------------------------------------------------------------------
1714 Extract TL control block
1715 ------------------------------------------------------------------------*/
1716 pTLCb = VOS_GET_TL_CB(pvosGCtx);
1717 if ( NULL == pTLCb || ( WLAN_MAX_STA_COUNT <= pwSTADescType->ucSTAId))
1718 {
1719 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1720 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_UpdateTdlsSTAClient"));
1721 return VOS_STATUS_E_FAULT;
1722 }
1723
1724 pClientSTA = pTLCb->atlSTAClients[pwSTADescType->ucSTAId];
1725 if ((NULL == pClientSTA) || 0 == pClientSTA->ucExists)
1726 {
1727 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1728 "WLAN TL:Station not exists"));
1729 return VOS_STATUS_E_FAILURE;
1730 }
1731
1732 pClientSTA->wSTADesc.ucQosEnabled = pwSTADescType->ucQosEnabled;
1733
1734 return VOS_STATUS_SUCCESS;
1735
1736}
1737
Katya Nigame7b69a82015-04-28 15:24:06 +05301738VOS_STATUS WLANTL_SetMonRxCbk(v_PVOID_t pvosGCtx, WLANTL_MonRxCBType pfnMonRx)
1739{
1740 WLANTL_CbType* pTLCb = NULL ;
1741 pTLCb = VOS_GET_TL_CB(pvosGCtx);
1742 if ( NULL == pTLCb )
1743 {
1744 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1745 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_RegisterSTAClient"));
1746 return VOS_STATUS_E_FAULT;
1747 }
1748 pTLCb->pfnMonRx = pfnMonRx;
1749 return VOS_STATUS_SUCCESS;
1750}
1751
1752void WLANTL_SetIsConversionReq(v_PVOID_t pvosGCtx, v_BOOL_t isConversionReq)
1753{
1754 WLANTL_CbType* pTLCb = NULL ;
1755 pTLCb = VOS_GET_TL_CB(pvosGCtx);
1756 if ( NULL == pTLCb )
1757 {
1758 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1759 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_RegisterSTAClient"));
1760 return;
1761 }
1762 pTLCb->isConversionReq = isConversionReq;
1763 return;
1764}
1765
Agarwal Ashish16020c42014-12-29 22:01:11 +05301766
1767/*===========================================================================
1768
Gopichand Nakkala8b54e912013-03-11 10:44:21 +05301769 FUNCTION WLANTL_STAPtkInstalled
1770
1771 DESCRIPTION
1772
1773 HDD will make this notification whenever PTK is installed for the STA
1774
1775 DEPENDENCIES
1776
1777 A station must have been registered before the change state can be
1778 called.
1779
1780 PARAMETERS
1781
1782 pvosGCtx: pointer to the global vos context; a handle to TL's
1783 control block can be extracted from its context
1784 ucSTAId: identifier for the STA for which Pairwise key is
1785 installed
1786
1787 RETURN VALUE
1788
1789 The result code associated with performing the operation
1790
1791 VOS_STATUS_E_FAULT: Station ID is outside array boundaries or pointer to
1792 TL cb is NULL ; access would cause a page fault
1793 VOS_STATUS_E_EXISTS: Station was not registered
1794 VOS_STATUS_SUCCESS: Everything is good :)
1795
1796 SIDE EFFECTS
1797
1798============================================================================*/
1799VOS_STATUS
1800WLANTL_STAPtkInstalled
1801(
1802 v_PVOID_t pvosGCtx,
1803 v_U8_t ucSTAId
1804)
1805{
1806 WLANTL_CbType* pTLCb = NULL;
1807 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
1808
1809 /*------------------------------------------------------------------------
1810 Sanity check
1811 ------------------------------------------------------------------------*/
1812
1813 if ( WLANTL_STA_ID_INVALID( ucSTAId ) )
1814 {
1815 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1816 "WLAN TL:Invalid station id requested on WLANTL_ChangeSTAState"));
1817 return VOS_STATUS_E_FAULT;
1818 }
1819
1820 /*------------------------------------------------------------------------
1821 Extract TL control block and check existance
1822 ------------------------------------------------------------------------*/
1823 pTLCb = VOS_GET_TL_CB(pvosGCtx);
1824 if ( NULL == pTLCb )
1825 {
1826 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1827 FL("WLAN TL:Invalid TL pointer from pvosGCtx")));
1828 return VOS_STATUS_E_FAULT;
1829 }
1830
1831 if ( NULL == pTLCb->atlSTAClients[ucSTAId] )
1832 {
1833 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1834 FL("WLAN TL:Client Memory was not allocated")));
1835 return VOS_STATUS_E_FAILURE;
1836 }
1837
1838 if ( 0 == pTLCb->atlSTAClients[ucSTAId]->ucExists )
1839 {
1840 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1841 FL("WLAN TL:Station was not previously registered")));
1842 return VOS_STATUS_E_EXISTS;
1843 }
1844
1845 pTLCb->atlSTAClients[ucSTAId]->ptkInstalled = 1;
1846
1847 return VOS_STATUS_SUCCESS;
1848}/* WLANTL_STAPtkInstalled */
1849
1850/*===========================================================================
1851
Madan Mohan Koyyalamudifc1d1fe2012-10-18 15:07:12 -07001852 FUNCTION WLANTL_GetSTAState
1853
1854 DESCRIPTION
1855
1856 Returns connectivity state of a particular STA.
1857
1858 DEPENDENCIES
1859
1860 A station must have been registered before its state can be retrieved.
1861
1862
1863 PARAMETERS
1864
1865 IN
1866 pvosGCtx: pointer to the global vos context; a handle to TL's
1867 control block can be extracted from its context
1868 ucSTAId: identifier of the station
1869
1870 OUT
1871 ptlSTAState: the current state of the connection to the given station
1872
1873
1874 RETURN VALUE
1875
1876 The result code associated with performing the operation
1877
1878 VOS_STATUS_E_INVAL: Input parameters are invalid
1879 VOS_STATUS_E_FAULT: Station ID is outside array boundaries or pointer to
1880 TL cb is NULL ; access would cause a page fault
1881 VOS_STATUS_E_EXISTS: Station was not registered
1882 VOS_STATUS_SUCCESS: Everything is good :)
1883
1884 SIDE EFFECTS
1885
1886============================================================================*/
1887VOS_STATUS
1888WLANTL_GetSTAState
1889(
1890 v_PVOID_t pvosGCtx,
1891 v_U8_t ucSTAId,
1892 WLANTL_STAStateType *ptlSTAState
1893)
1894{
1895 WLANTL_CbType* pTLCb = NULL;
1896 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
1897
1898 /*------------------------------------------------------------------------
1899 Sanity check
1900 ------------------------------------------------------------------------*/
1901 if ( NULL == ptlSTAState )
1902 {
1903 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1904 "WLAN TL:Invalid parameter sent on WLANTL_GetSTAState"));
1905 return VOS_STATUS_E_INVAL;
1906 }
1907
1908 if ( WLANTL_STA_ID_INVALID( ucSTAId ) )
1909 {
1910 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1911 "WLAN TL:Invalid station id requested on WLANTL_GetSTAState"));
1912 return VOS_STATUS_E_FAULT;
1913 }
1914
1915 /*------------------------------------------------------------------------
1916 Extract TL control block and check existance
1917 ------------------------------------------------------------------------*/
1918 pTLCb = VOS_GET_TL_CB(pvosGCtx);
1919 if ( NULL == pTLCb )
1920 {
1921 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1922 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_GetSTAState"));
1923 return VOS_STATUS_E_FAULT;
1924 }
1925
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301926 if ( NULL == pTLCb->atlSTAClients[ucSTAId] )
1927 {
1928 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1929 "WLAN TL:Client Memory was not allocated on %s", __func__));
1930 return VOS_STATUS_E_FAILURE;
1931 }
1932
1933 if ( 0 == pTLCb->atlSTAClients[ucSTAId]->ucExists )
Madan Mohan Koyyalamudifc1d1fe2012-10-18 15:07:12 -07001934 {
Sunil Ravid5406f22013-01-22 00:18:31 -08001935 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
Madan Mohan Koyyalamudifc1d1fe2012-10-18 15:07:12 -07001936 "WLAN TL:Station was not previously registered on WLANTL_GetSTAState"));
1937 return VOS_STATUS_E_EXISTS;
1938 }
1939
1940 /*------------------------------------------------------------------------
1941 Get STA state
1942 ------------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301943 *ptlSTAState = pTLCb->atlSTAClients[ucSTAId]->tlState;
Madan Mohan Koyyalamudifc1d1fe2012-10-18 15:07:12 -07001944
1945 return VOS_STATUS_SUCCESS;
1946}/* WLANTL_GetSTAState */
1947
Shailender Karmuchia734f332013-04-19 14:02:48 -07001948/*==========================================================================
1949 FUNCTION WLANTL_UpdateSTABssIdforIBSS
1950
1951 DESCRIPTION
1952 HDD will call this API to update the BSSID for this Station.
1953
1954 DEPENDENCIES
1955 The HDD Should registered the staID with TL before calling this function.
1956
1957 PARAMETERS
1958
1959 IN
1960 pvosGCtx: Pointer to the global vos context; a handle to TL's
1961 or WDA's control block can be extracted from its context
1962 IN
1963 ucSTAId The Station ID for Bssid to be updated
1964 IN
1965 pBssid BSSID to be updated
1966
1967 RETURN VALUE
1968 The result code associated with performing the operation
1969
1970 VOS_STATUS_E_INVAL: Input parameters are invalid
1971 VOS_STATUS_E_FAULT: Station ID is outside array boundaries or pointer to
1972 TL cb is NULL ; access would cause a page fault
1973 VOS_STATUS_E_EXISTS: Station was not registered
1974 VOS_STATUS_SUCCESS: Everything is good :)
1975
1976 SIDE EFFECTS
1977============================================================================*/
1978
1979
1980VOS_STATUS
1981WLANTL_UpdateSTABssIdforIBSS
1982(
1983 v_PVOID_t pvosGCtx,
1984 v_U8_t ucSTAId,
1985 v_U8_t *pBssid
1986)
1987{
1988 WLANTL_CbType* pTLCb = NULL;
1989 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
1990
1991 /*------------------------------------------------------------------------
1992 Sanity check
1993 ------------------------------------------------------------------------*/
1994 if ( WLANTL_STA_ID_INVALID( ucSTAId ) )
1995 {
1996 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1997 "WLAN TL:Invalid station id requested %s", __func__));
1998 return VOS_STATUS_E_FAULT;
1999 }
2000
2001 /*------------------------------------------------------------------------
2002 Extract TL control block and check existance
2003 ------------------------------------------------------------------------*/
2004 pTLCb = VOS_GET_TL_CB(pvosGCtx);
2005 if ( NULL == pTLCb )
2006 {
2007 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2008 "WLAN TL:Invalid TL pointer from pvosGCtx %s", __func__));
2009 return VOS_STATUS_E_FAULT;
2010 }
2011
2012 if ( NULL == pTLCb->atlSTAClients[ucSTAId] )
2013 {
2014 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2015 "WLAN TL:Client Memory was not allocated on %s", __func__));
2016 return VOS_STATUS_E_FAILURE;
2017 }
2018
2019 if ( 0 == pTLCb->atlSTAClients[ucSTAId]->ucExists )
2020 {
2021 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
2022 "WLAN TL:Station was not previously registered %s", __func__));
2023 return VOS_STATUS_E_EXISTS;
2024 }
2025
2026 /*------------------------------------------------------------------------
2027 Update the IBSS BSSID
2028 ------------------------------------------------------------------------*/
2029 vos_mem_copy( &pTLCb->atlSTAClients[ucSTAId]->wSTADesc.vBSSIDforIBSS,
2030 pBssid, sizeof(v_MACADDR_t));
2031
2032 return VOS_STATUS_SUCCESS;
2033}
2034
Madan Mohan Koyyalamudifc1d1fe2012-10-18 15:07:12 -07002035/*===========================================================================
2036
Jeff Johnson295189b2012-06-20 16:38:30 -07002037 FUNCTION WLANTL_STAPktPending
2038
2039 DESCRIPTION
2040
2041 HDD will call this API when a packet is pending transmission in its
2042 queues.
2043
2044 DEPENDENCIES
2045
2046 A station must have been registered before the packet pending
2047 notification can be sent.
2048
2049 RESTRICTION: TL will not count packets for pending notification.
2050 HDD is expected to send the notification only when
2051 non-empty event gets triggered. Worst case scenario
2052 is that TL might end up making a call when Hdds
2053 queues are actually empty.
2054
2055 PARAMETERS
2056
2057 pvosGCtx: pointer to the global vos context; a handle to TL's
2058 control block can be extracted from its context
2059 ucSTAId: identifier for the STA that is pending transmission
2060
2061 RETURN VALUE
2062
2063 The result code associated with performing the operation
2064
2065 VOS_STATUS_E_INVAL: Input parameters are invalid
2066 VOS_STATUS_E_FAULT: Station ID is outside array boundaries or pointer
2067 to TL cb is NULL ; access would cause a page fault
2068 VOS_STATUS_E_EXISTS: Station was not registered
2069 VOS_STATUS_SUCCESS: Everything is good :)
2070
2071 SIDE EFFECTS
2072
2073============================================================================*/
2074VOS_STATUS
2075WLANTL_STAPktPending
2076(
2077 v_PVOID_t pvosGCtx,
2078 v_U8_t ucSTAId,
2079 WLANTL_ACEnumType ucAc
2080)
2081{
2082 WLANTL_CbType* pTLCb = NULL;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302083 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002084 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
2085
2086 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
2087 "WLAN TL:Packet pending indication for STA: %d AC: %d", ucSTAId, ucAc);
2088
2089 /*------------------------------------------------------------------------
2090 Sanity check
2091 ------------------------------------------------------------------------*/
2092 if ( WLANTL_STA_ID_INVALID( ucSTAId ) )
2093 {
2094 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2095 "WLAN TL:Invalid station id requested on WLANTL_STAPktPending"));
2096 return VOS_STATUS_E_FAULT;
2097 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002098 /*------------------------------------------------------------------------
2099 Extract TL control block and check existance
2100 ------------------------------------------------------------------------*/
2101 pTLCb = VOS_GET_TL_CB(pvosGCtx);
2102 if ( NULL == pTLCb )
2103 {
2104 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2105 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_STAPktPending"));
2106 return VOS_STATUS_E_FAULT;
2107 }
2108
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302109 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
2110
2111 if ( NULL == pClientSTA )
2112 {
2113 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2114 "WLAN TL:Client Memory was not allocated on %s", __func__));
2115 return VOS_STATUS_E_FAILURE;
2116 }
2117
2118 if ( 0 == pClientSTA->ucExists )
Jeff Johnson295189b2012-06-20 16:38:30 -07002119 {
Katya Nigamb130d572014-11-24 16:38:16 +05302120 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07002121 "WLAN TL:Station was not previously registered on WLANTL_STAPktPending"));
2122 return VOS_STATUS_E_EXISTS;
2123 }
2124
2125 /*---------------------------------------------------------------------
2126 Temporary fix to enable TL to fetch packets when multiple peers join
2127 an IBSS. To fix CR177301. Needs to go away when the actual fix of
2128 going through all STA's in round robin fashion gets merged in from
2129 BT AMP branch.
2130 --------------------------------------------------------------------*/
2131 pTLCb->ucRegisteredStaId = ucSTAId;
2132
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302133 if( WLANTL_STA_CONNECTED == pClientSTA->tlState )
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -07002134 { /* EAPOL_HI_PRIORITY : need to find out whether EAPOL is pending before
2135 WLANTL_FetchPacket()/WLANTL_TxConn() is called.
2136 change STA_AUTHENTICATED != tlState to CONNECTED == tlState
2137 to make sure TL is indeed waiting for EAPOL.
2138 Just in the case when STA got disconnected shortly after connectection */
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302139 pClientSTA->ucEapolPktPending = 1;
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -07002140
Katya Nigam42e16e82014-02-04 16:28:55 +05302141 MTRACE(vos_trace(VOS_MODULE_ID_TL,
2142 TRACE_CODE_TL_EAPOL_PKT_PENDING, ucSTAId, ucAc));
2143
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -07002144 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07002145 "WLAN TL:Packet pending indication for STA: %d AC: %d State: %d",
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302146 ucSTAId, ucAc, pClientSTA->tlState);
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07002147 }
2148
Jeff Johnson295189b2012-06-20 16:38:30 -07002149 /*-----------------------------------------------------------------------
2150 Enable this AC in the AC mask in order for TL to start servicing it
2151 Set packet pending flag
2152 To avoid race condition, serialize the updation of AC and AC mask
2153 through WLANTL_TX_STAID_AC_IND message.
2154 -----------------------------------------------------------------------*/
Jeff Johnson295189b2012-06-20 16:38:30 -07002155
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302156 pClientSTA->aucACMask[ucAc] = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07002157
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302158 vos_atomic_set_U8( &pClientSTA->ucPktPending, 1);
Jeff Johnson295189b2012-06-20 16:38:30 -07002159
Mihir Shete5d148f12014-12-16 17:54:49 +05302160 MTRACE(vos_trace(VOS_MODULE_ID_TL, TRACE_CODE_TL_STA_PKT_PENDING, ucSTAId,
2161 (pTLCb->ucTxSuspended << 31) |
2162 ((pTLCb->uResCount >= WDA_TLI_MIN_RES_DATA) << 30) |
2163 pClientSTA->tlState));
2164
Jeff Johnson295189b2012-06-20 16:38:30 -07002165 /*------------------------------------------------------------------------
2166 Check if there are enough resources for transmission and tx is not
2167 suspended.
2168 ------------------------------------------------------------------------*/
Nirav Shah4b53d4b2015-05-08 05:35:00 -07002169 if (( pTLCb->uResCount >= WDA_TLI_MIN_RES_DATA ) &&
2170 ( 0 == pTLCb->ucTxSuspended ))
Jeff Johnson295189b2012-06-20 16:38:30 -07002171 {
Katya Nigam42e16e82014-02-04 16:28:55 +05302172
Jeff Johnson295189b2012-06-20 16:38:30 -07002173 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
2174 "Issuing Xmit start request to BAL"));
2175 WDA_DS_StartXmit(pvosGCtx);
2176 }
2177 else
2178 {
2179 /*---------------------------------------------------------------------
2180 No error code is sent because TL will resume tx autonomously if
2181 resources become available or tx gets resumed
2182 ---------------------------------------------------------------------*/
Madan Mohan Koyyalamudi179e6fe2012-10-15 15:31:08 -07002183 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
Jeff Johnson295189b2012-06-20 16:38:30 -07002184 "WLAN TL:Request to send but condition not met. Res: %d,Suspend: %d",
Madan Mohan Koyyalamudi48139e32012-10-11 14:43:56 -07002185 pTLCb->uResCount, pTLCb->ucTxSuspended );
Jeff Johnson295189b2012-06-20 16:38:30 -07002186 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002187 return VOS_STATUS_SUCCESS;
2188}/* WLANTL_STAPktPending */
2189
2190/*==========================================================================
2191
2192 FUNCTION WLANTL_SetSTAPriority
2193
2194 DESCRIPTION
2195
2196 TL exposes this API to allow upper layers a rough control over the
2197 priority of transmission for a given station when supporting multiple
2198 connections.
2199
2200 DEPENDENCIES
2201
2202 A station must have been registered before the change in priority can be
2203 called.
2204
2205 PARAMETERS
2206
2207 pvosGCtx: pointer to the global vos context; a handle to TL's
2208 control block can be extracted from its context
2209 ucSTAId: identifier for the STA that has to change priority
2210
2211 RETURN VALUE
2212
2213 The result code associated with performing the operation
2214
2215 VOS_STATUS_E_INVAL: Input parameters are invalid
2216 VOS_STATUS_E_FAULT: Station ID is outside array boundaries or pointer
2217 to TL cb is NULL ; access would cause a page fault
2218 VOS_STATUS_E_EXISTS: Station was not registered
2219 VOS_STATUS_SUCCESS: Everything is good :)
2220
2221 SIDE EFFECTS
2222
2223============================================================================*/
2224VOS_STATUS
2225WLANTL_SetSTAPriority
2226(
2227 v_PVOID_t pvosGCtx,
2228 v_U8_t ucSTAId,
2229 WLANTL_STAPriorityType tlSTAPri
2230)
2231{
2232 WLANTL_CbType* pTLCb = NULL;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302233 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002234 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
2235
2236 /*------------------------------------------------------------------------
2237 Sanity check
2238 ------------------------------------------------------------------------*/
2239 if ( WLANTL_STA_ID_INVALID( ucSTAId ) )
2240 {
2241 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2242 "WLAN TL:Invalid station id requested on WLANTL_SetSTAPriority"));
2243 return VOS_STATUS_E_FAULT;
2244 }
2245
2246 /*------------------------------------------------------------------------
2247 Extract TL control block
2248 ------------------------------------------------------------------------*/
2249 pTLCb = VOS_GET_TL_CB(pvosGCtx);
2250 if ( NULL == pTLCb )
2251 {
2252 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2253 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_SetSTAPriority"));
2254 return VOS_STATUS_E_FAULT;
2255 }
2256
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302257 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
2258
2259 if ( NULL == pClientSTA )
2260 {
2261 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2262 "WLAN TL:Client Memory was not allocated on %s", __func__));
2263 return VOS_STATUS_E_FAILURE;
2264 }
2265
2266 if ( 0 == pClientSTA->ucExists )
Jeff Johnson295189b2012-06-20 16:38:30 -07002267 {
2268 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2269 "WLAN TL:Station was not previously registered on WLANTL_SetSTAPriority"));
2270 return VOS_STATUS_E_EXISTS;
2271 }
2272
2273 /*------------------------------------------------------------------------
2274 Re-analize if lock is needed when adding multiple stations
2275 ------------------------------------------------------------------------*/
2276 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
2277 "WLAN TL:Changing state for STA Pri ID: %d from %d to %d",
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302278 ucSTAId, pClientSTA->tlPri, tlSTAPri));
2279 pClientSTA->tlPri = tlSTAPri;
Jeff Johnson295189b2012-06-20 16:38:30 -07002280
2281 return VOS_STATUS_SUCCESS;
2282}/* WLANTL_SetSTAPriority */
2283
2284
2285/*----------------------------------------------------------------------------
2286 INTERACTION WITH BAP
2287 ---------------------------------------------------------------------------*/
2288
2289/*==========================================================================
2290
2291 FUNCTION WLANTL_RegisterBAPClient
2292
2293 DESCRIPTION
2294 Called by SME to register itself as client for non-data BT-AMP packets.
2295
2296 DEPENDENCIES
2297 TL must be initialized before this function can be called.
2298
2299 PARAMETERS
2300
2301 IN
2302 pvosGCtx: pointer to the global vos context; a handle to TL's
2303 or SME's control block can be extracted from its context
2304 pfnTlBAPRxFrm: pointer to the receive processing routine for non-data
2305 BT-AMP packets
2306 pfnFlushOpCompleteCb:
2307 pointer to the call back function, for the Flush operation
2308 completion.
2309
2310
2311 RETURN VALUE
2312
2313 The result code associated with performing the operation
2314
2315 VOS_STATUS_E_INVAL: Input parameters are invalid
2316 VOS_STATUS_E_FAULT: Station ID is outside array boundaries or pointer
2317 to TL cb is NULL ; access would cause a page fault
2318 VOS_STATUS_E_EXISTS: BAL client was already registered
2319 VOS_STATUS_SUCCESS: Everything is good :)
2320
2321 SIDE EFFECTS
2322
2323============================================================================*/
2324VOS_STATUS
2325WLANTL_RegisterBAPClient
2326(
2327 v_PVOID_t pvosGCtx,
2328 WLANTL_BAPRxCBType pfnTlBAPRxFrm,
2329 WLANTL_FlushOpCompCBType pfnFlushOpCompleteCb
2330)
2331{
2332 WLANTL_CbType* pTLCb = NULL;
2333 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
2334
2335 /*------------------------------------------------------------------------
2336 Sanity check
2337 ------------------------------------------------------------------------*/
2338 if ( NULL == pfnTlBAPRxFrm )
2339 {
2340 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2341 "WLAN TL:Invalid parameter sent on WLANTL_RegisterBAPClient"));
2342 return VOS_STATUS_E_INVAL;
2343 }
2344
2345 if ( NULL == pfnFlushOpCompleteCb )
2346 {
2347 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2348 "Invalid Flush Complete Cb parameter sent on WLANTL_RegisterBAPClient"));
2349 return VOS_STATUS_E_INVAL;
2350 }
2351
2352 /*------------------------------------------------------------------------
2353 Extract TL control block
2354 ------------------------------------------------------------------------*/
2355 pTLCb = VOS_GET_TL_CB(pvosGCtx);
2356 if ( NULL == pTLCb )
2357 {
2358 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2359 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_RegisterBAPClient"));
2360 return VOS_STATUS_E_FAULT;
2361 }
2362
2363 /*------------------------------------------------------------------------
2364 Make sure this is the first registration attempt
2365 ------------------------------------------------------------------------*/
2366 if ( 0 != pTLCb->tlBAPClient.ucExists )
2367 {
2368 pTLCb->tlBAPClient.ucExists++;
2369 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2370 "WLAN TL:BAP client was already registered"));
2371 return VOS_STATUS_E_EXISTS;
2372 }
2373
2374 /*------------------------------------------------------------------------
2375 Register station with TL
2376 ------------------------------------------------------------------------*/
2377 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
2378 "WLAN TL:Registering BAP Client" ));
2379
2380 pTLCb->tlBAPClient.ucExists++;
2381
2382 if ( NULL != pfnTlBAPRxFrm )
2383 {
2384 pTLCb->tlBAPClient.pfnTlBAPRx = pfnTlBAPRxFrm;
2385 }
2386
2387 pTLCb->tlBAPClient.pfnFlushOpCompleteCb = pfnFlushOpCompleteCb;
2388
2389 pTLCb->tlBAPClient.vosPendingDataBuff = NULL;
2390
2391 return VOS_STATUS_SUCCESS;
2392}/* WLANTL_RegisterBAPClient */
2393
2394
2395/*==========================================================================
2396
2397 FUNCTION WLANTL_TxBAPFrm
2398
2399 DESCRIPTION
2400 BAP calls this when it wants to send a frame to the module
2401
2402 DEPENDENCIES
2403 BAP must be registered with TL before this function can be called.
2404
2405 RESTRICTION: BAP CANNOT push any packets to TL until it did not receive
2406 a tx complete from the previous packet, that means BAP
2407 sends one packet, wait for tx complete and then
2408 sends another one
2409
2410 If BAP sends another packet before TL manages to process the
2411 previously sent packet call will end in failure
2412
2413 PARAMETERS
2414
2415 IN
2416 pvosGCtx: pointer to the global vos context; a handle to TL's
2417 or BAP's control block can be extracted from its context
2418 vosDataBuff: pointer to the vOSS buffer containing the packet to be
2419 transmitted
2420 pMetaInfo: meta information about the packet
2421 pfnTlBAPTxComp: pointer to a transmit complete routine for notifying
2422 the result of the operation over the bus
2423
2424 RETURN VALUE
2425 The result code associated with performing the operation
2426
2427 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
2428 page fault
2429 VOS_STATUS_E_EXISTS: BAL client was not yet registered
2430 VOS_STATUS_E_BUSY: The previous BT-AMP packet was not yet transmitted
2431 VOS_STATUS_SUCCESS: Everything is good :)
2432
2433 Other failure messages may be returned from the BD header handling
2434 routines, please check apropriate API for more info.
2435
2436 SIDE EFFECTS
2437
2438============================================================================*/
2439VOS_STATUS
2440WLANTL_TxBAPFrm
2441(
2442 v_PVOID_t pvosGCtx,
2443 vos_pkt_t* vosDataBuff,
2444 WLANTL_MetaInfoType* pMetaInfo,
2445 WLANTL_TxCompCBType pfnTlBAPTxComp
2446)
2447{
2448 WLANTL_CbType* pTLCb = NULL;
2449 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
2450 v_MACADDR_t vDestMacAddr;
2451 v_U16_t usPktLen;
2452 v_U8_t ucStaId = 0;
2453 v_U8_t extraHeadSpace = 0;
2454 v_U8_t ucWDSEnabled = 0;
2455 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
2456
2457 /*------------------------------------------------------------------------
2458 Sanity check
2459 Extract TL control block
2460 ------------------------------------------------------------------------*/
2461 pTLCb = VOS_GET_TL_CB(pvosGCtx);
2462 if ( NULL == pTLCb )
2463 {
2464 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2465 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_TxBAPFrm"));
2466 return VOS_STATUS_E_FAULT;
2467 }
2468
2469 /*------------------------------------------------------------------------
2470 Ensure that BAP client was registered previously
2471 ------------------------------------------------------------------------*/
2472 if (( 0 == pTLCb->tlBAPClient.ucExists ) ||
2473 ( WLANTL_STA_ID_INVALID(pTLCb->tlBAPClient.ucBAPSTAId) ))
2474 {
2475 pTLCb->tlBAPClient.ucExists++;
2476 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2477 "WLAN TL:BAP client not register on WLANTL_TxBAPFrm"));
2478 return VOS_STATUS_E_EXISTS;
2479 }
2480
2481 /*------------------------------------------------------------------------
2482 Check if any BT-AMP Frm is pending
2483 ------------------------------------------------------------------------*/
2484 if ( NULL != pTLCb->tlBAPClient.vosPendingDataBuff )
2485 {
2486 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2487 "WLAN TL:BT-AMP Frame already pending tx in TL on WLANTL_TxBAPFrm"));
2488 return VOS_STATUS_E_BUSY;
2489 }
2490
2491 /*------------------------------------------------------------------------
2492 Save buffer and notify BAL; no lock is needed if the above restriction
2493 is met
2494 Save the tx complete fnct pointer as tl specific data in the vos buffer
2495 ------------------------------------------------------------------------*/
2496
2497 /*------------------------------------------------------------------------
2498 Translate 802.3 frame to 802.11
2499 ------------------------------------------------------------------------*/
2500 ucStaId = pTLCb->tlBAPClient.ucBAPSTAId;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302501 if ( NULL == pTLCb->atlSTAClients[ucStaId] )
2502 {
2503 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2504 "WLAN TL:Client Memory was not allocated on %s", __func__));
2505 return VOS_STATUS_E_FAILURE;
2506 }
2507 if (( 0 == pMetaInfo->ucDisableFrmXtl ) &&
2508 ( 0 != pTLCb->atlSTAClients[ucStaId]->wSTADesc.ucSwFrameTXXlation ))
Jeff Johnson295189b2012-06-20 16:38:30 -07002509 {
Kiran Venkatappacab0d352012-12-17 13:09:22 -08002510 vosStatus = WLANTL_Translate8023To80211Header( vosDataBuff, &vosStatus,
2511 pTLCb, &ucStaId,
Ravi Joshid0699502013-07-08 15:48:47 -07002512 pMetaInfo, &ucWDSEnabled,
2513 &extraHeadSpace);
Jeff Johnson295189b2012-06-20 16:38:30 -07002514
2515 if ( VOS_STATUS_SUCCESS != vosStatus )
2516 {
2517 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2518 "WLAN TL:Error when translating header WLANTL_TxBAPFrm"));
2519
2520 return vosStatus;
2521 }
2522
2523 pMetaInfo->ucDisableFrmXtl = 1;
2524 }
2525
2526 /*-------------------------------------------------------------------------
2527 Call HAL to fill BD header
2528 -------------------------------------------------------------------------*/
2529
2530 /* Adding Type, SubType which was missing for EAPOL from BAP */
2531 pMetaInfo->ucType |= (WLANTL_80211_DATA_TYPE << 4);
2532 pMetaInfo->ucType |= (WLANTL_80211_DATA_QOS_SUBTYPE);
2533
2534 vosStatus = WDA_DS_BuildTxPacketInfo( pvosGCtx, vosDataBuff ,
2535 &vDestMacAddr, pMetaInfo->ucDisableFrmXtl,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302536 &usPktLen, pTLCb->atlSTAClients[ucStaId]->wSTADesc.ucQosEnabled,
Jeff Johnson295189b2012-06-20 16:38:30 -07002537 ucWDSEnabled, extraHeadSpace, pMetaInfo->ucType,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302538 &pTLCb->atlSTAClients[ucStaId]->wSTADesc.vSelfMACAddress,
Jeff Johnson295189b2012-06-20 16:38:30 -07002539 pMetaInfo->ucTID, 0 /* No ACK */, pMetaInfo->usTimeStamp,
Ganesh Kondabattini10e67352015-03-16 17:41:57 +05302540 pMetaInfo->ucIsEapol || pMetaInfo->ucIsWai, pMetaInfo->ucUP,
2541 pMetaInfo->ucTxBdToken);
Jeff Johnson295189b2012-06-20 16:38:30 -07002542
2543 if ( VOS_STATUS_SUCCESS != vosStatus )
2544 {
2545 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2546 "WLAN TL:Failed while building TX header %d", vosStatus));
2547 return vosStatus;
2548 }
2549
2550 if ( NULL != pfnTlBAPTxComp )
2551 {
2552 vos_pkt_set_user_data_ptr( vosDataBuff, VOS_PKT_USER_DATA_ID_TL,
2553 (v_PVOID_t)pfnTlBAPTxComp);
2554 }
2555 else
2556 {
2557 vos_pkt_set_user_data_ptr( vosDataBuff, VOS_PKT_USER_DATA_ID_TL,
2558 (v_PVOID_t)WLANTL_TxCompDefaultCb);
2559
2560 }
2561
Arun Kumar Khandavalli0af8d3c2014-02-07 18:05:11 +05302562 vos_atomic_set( (uintptr_t*)&pTLCb->tlBAPClient.vosPendingDataBuff,
2563 (uintptr_t)vosDataBuff);
Jeff Johnson295189b2012-06-20 16:38:30 -07002564
2565 /*------------------------------------------------------------------------
2566 Check if thre are enough resources for transmission and tx is not
2567 suspended.
2568 ------------------------------------------------------------------------*/
2569 if (( pTLCb->uResCount >= WDA_TLI_MIN_RES_BAP ) &&
2570 ( 0 == pTLCb->ucTxSuspended ))
2571 {
2572 WDA_DS_StartXmit(pvosGCtx);
2573 }
2574 else
2575 {
2576 /*---------------------------------------------------------------------
2577 No error code is sent because TL will resume tx autonomously if
2578 resources become available or tx gets resumed
2579 ---------------------------------------------------------------------*/
2580 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
2581 "WLAN TL:Request to send from BAP but condition not met.Res: %d,"
2582 "Suspend: %d", pTLCb->uResCount, pTLCb->ucTxSuspended ));
2583 }
2584
2585 return VOS_STATUS_SUCCESS;
2586}/* WLANTL_TxBAPFrm */
2587
2588
2589/*----------------------------------------------------------------------------
2590 INTERACTION WITH SME
2591 ---------------------------------------------------------------------------*/
2592
2593/*==========================================================================
2594
2595 FUNCTION WLANTL_GetRssi
2596
2597 DESCRIPTION
2598 TL will extract the RSSI information from every data packet from the
2599 ongoing traffic and will store it. It will provide the result to SME
2600 upon request.
2601
2602 DEPENDENCIES
2603
2604 WARNING: the read and write of this value will not be protected
2605 by locks, therefore the information obtained after a read
2606 might not always be consistent.
2607
2608 PARAMETERS
2609
2610 IN
2611 pvosGCtx: pointer to the global vos context; a handle to TL's
2612 or SME's control block can be extracted from its context
2613 ucSTAId: station identifier for the requested value
2614
2615 OUT
2616 puRssi: the average value of the RSSI
2617
2618
2619 RETURN VALUE
2620 The result code associated with performing the operation
2621
2622 VOS_STATUS_E_INVAL: Input parameters are invalid
2623 VOS_STATUS_E_FAULT: Station ID is outside array boundaries or pointer
2624 to TL cb is NULL ; access would cause a page fault
2625 VOS_STATUS_E_EXISTS: STA was not yet registered
2626 VOS_STATUS_SUCCESS: Everything is good :)
2627
2628 SIDE EFFECTS
2629
2630============================================================================*/
2631VOS_STATUS
2632WLANTL_GetRssi
2633(
2634 v_PVOID_t pvosGCtx,
2635 v_U8_t ucSTAId,
2636 v_S7_t* pRssi
2637)
2638{
2639 WLANTL_CbType* pTLCb = NULL;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302640 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002641 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
2642
2643 /*------------------------------------------------------------------------
2644 Sanity check
2645 ------------------------------------------------------------------------*/
2646 if ( NULL == pRssi )
2647 {
2648 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2649 "WLAN TL:Invalid parameter sent on WLANTL_GetRssi"));
2650 return VOS_STATUS_E_INVAL;
2651 }
2652
2653 if ( WLANTL_STA_ID_INVALID( ucSTAId ) )
2654 {
2655 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2656 "WLAN TL:Invalid station id requested on WLANTL_GetRssi"));
2657 return VOS_STATUS_E_FAULT;
2658 }
2659
2660 /*------------------------------------------------------------------------
2661 Extract TL control block and check existance
2662 ------------------------------------------------------------------------*/
2663 pTLCb = VOS_GET_TL_CB(pvosGCtx);
2664 if ( NULL == pTLCb )
2665 {
2666 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2667 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_GetRssi"));
2668 return VOS_STATUS_E_FAULT;
2669 }
2670
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302671 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
2672
2673 if ( NULL == pClientSTA )
2674 {
2675 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2676 "WLAN TL:Client Memory was not allocated on %s", __func__));
2677 return VOS_STATUS_E_FAILURE;
2678 }
2679
2680 if ( 0 == pClientSTA->ucExists )
Jeff Johnson295189b2012-06-20 16:38:30 -07002681 {
2682 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2683 "WLAN TL:Station was not previously registered on WLANTL_GetRssi"));
2684 return VOS_STATUS_E_EXISTS;
2685 }
2686
2687 /*------------------------------------------------------------------------
2688 Copy will not be locked; please read restriction
2689 ------------------------------------------------------------------------*/
Katya Nigam5c2e5f62013-11-15 19:19:11 +05302690 if(pTLCb->isBMPS || IS_ACTIVEMODE_OFFLOAD_FEATURE_ENABLE)
Jeff Johnson295189b2012-06-20 16:38:30 -07002691 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302692 *pRssi = pClientSTA->rssiAvgBmps;
Jeff Johnson295189b2012-06-20 16:38:30 -07002693 /* Check If RSSI is zero because we are reading rssAvgBmps updated by HAL in
2694 previous GetStatsRequest. It may be updated as zero by Hal because EnterBmps
2695 might not have happend by that time. Hence reading the most recent Rssi
2696 calcluated by TL*/
2697 if(0 == *pRssi)
2698 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302699 *pRssi = pClientSTA->rssiAvg;
Jeff Johnson295189b2012-06-20 16:38:30 -07002700 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002701 }
2702 else
2703 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302704 *pRssi = pClientSTA->rssiAvg;
Jeff Johnson295189b2012-06-20 16:38:30 -07002705 }
2706
2707 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
Jeff Johnson32d95a32012-09-10 13:15:23 -07002708 "WLAN TL:WLANTL_GetRssi for STA: %d RSSI: %d%s",
2709 ucSTAId, *pRssi,
2710 pTLCb->isBMPS ? " in BMPS" : ""));
Jeff Johnson295189b2012-06-20 16:38:30 -07002711
2712 return VOS_STATUS_SUCCESS;
2713}/* WLANTL_GetRssi */
2714
2715/*==========================================================================
2716
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05302717 FUNCTION WLANTL_GetSnr
2718
2719 DESCRIPTION
2720 TL will extract the SNR information from every data packet from the
2721 ongoing traffic and will store it. It will provide the result to SME
2722 upon request.
2723
2724 DEPENDENCIES
2725
2726 WARNING: the read and write of this value will not be protected
2727 by locks, therefore the information obtained after a read
2728 might not always be consistent.
2729
2730 PARAMETERS
2731
2732 IN
2733 pvosGCtx: pointer to the global vos context; a handle to TL's
2734 or SME's control block can be extracted from its context
2735 ucSTAId: station identifier for the requested value
2736
2737 OUT
2738 pSnr: the average value of the SNR
2739
2740
2741 RETURN VALUE
2742 The result code associated with performing the operation
2743
2744 VOS_STATUS_E_INVAL: Input parameters are invalid
2745 VOS_STATUS_E_FAULT: Station ID is outside array boundaries or pointer
2746 to TL cb is NULL ; access would cause a page fault
2747 VOS_STATUS_E_EXISTS: STA was not yet registered
2748 VOS_STATUS_SUCCESS: Everything is good :)
2749
2750 SIDE EFFECTS
2751
2752============================================================================*/
2753VOS_STATUS
2754WLANTL_GetSnr
2755(
2756 tANI_U8 ucSTAId,
2757 tANI_S8* pSnr
2758)
2759{
2760 WLANTL_CbType* pTLCb = NULL;
2761 WLANTL_STAClientType* pClientSTA = NULL;
2762 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
2763
2764 /*------------------------------------------------------------------------
2765 Sanity check
2766 ------------------------------------------------------------------------*/
2767 if (NULL == pSnr)
2768 {
2769 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2770 "WLAN TL:Invalid parameter sent on %s", __func__));
2771 return VOS_STATUS_E_INVAL;
2772 }
2773
2774 if (WLANTL_STA_ID_INVALID(ucSTAId))
2775 {
2776 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2777 "WLAN TL:Invalid station id requested on %s", __func__));
2778 return VOS_STATUS_E_FAULT;
2779 }
2780
2781 /*------------------------------------------------------------------------
2782 Extract TL control block and check existance
2783 ------------------------------------------------------------------------*/
2784 pTLCb = VOS_GET_TL_CB(vos_get_global_context(VOS_MODULE_ID_TL, NULL));
2785 if (NULL == pTLCb)
2786 {
2787 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2788 "WLAN TL:Invalid TL pointer from pvosGCtx on %s", __func__));
2789 return VOS_STATUS_E_FAULT;
2790 }
2791
2792 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
2793
2794 if (NULL == pClientSTA)
2795 {
2796 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2797 "WLAN TL:Client Memory was not allocated on %s", __func__));
2798 return VOS_STATUS_E_FAILURE;
2799 }
2800
2801 if (0 == pClientSTA->ucExists)
2802 {
2803 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2804 "WLAN TL:Station was not previously registered on %s", __func__));
2805 return VOS_STATUS_E_EXISTS;
2806 }
2807
2808 /*------------------------------------------------------------------------
2809 Copy will not be locked; please read restriction
2810 ------------------------------------------------------------------------*/
2811 if (pTLCb->isBMPS)
2812 {
2813 *pSnr = pClientSTA->snrAvgBmps;
2814 }
2815 else
2816 {
2817 /* SNR is averaged over WLANTL_MAX_SNR_DATA_SAMPLES, if there are not enough
2818 * data samples (snridx) to calculate the average then return the
2819 * average for the window of prevoius 20 packets. And if there aren't
2820 * enough samples and the average for previous window of 20 packets is
2821 * not available then return a predefined value
2822 *
2823 * NOTE: the SNR_HACK_BMPS value is defined to 127, documents from HW
2824 * team reveal that the SNR value has a ceiling well below 127 dBm,
2825 * so if SNR has value of 127 the userspace applications can know that
2826 * the SNR has not been computed yet because enough data was not
2827 * available for SNR calculation
2828 */
2829 if (pClientSTA->snrIdx > (WLANTL_MAX_SNR_DATA_SAMPLES/2)
2830 || !(pClientSTA->prevSnrAvg))
2831 {
2832 *pSnr = pClientSTA->snrSum / pClientSTA->snrIdx;
2833 }
2834 else if (pClientSTA->prevSnrAvg)
2835 {
2836 *pSnr = pClientSTA->prevSnrAvg;
2837 }
2838 else
2839 {
2840 *pSnr = SNR_HACK_BMPS;
2841 }
2842 }
2843
2844 VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
2845 "WLAN TL:WLANTL_GetSnr for STA: %d SNR: %d%s",
2846 ucSTAId, *pSnr,
2847 pTLCb->isBMPS ? " in BMPS" : "");
2848
2849 return VOS_STATUS_SUCCESS;
2850}/* WLANTL_GetSnr */
2851/*==========================================================================
2852
Jeff Johnson295189b2012-06-20 16:38:30 -07002853 FUNCTION WLANTL_GetLinkQuality
2854
2855 DESCRIPTION
2856 TL will extract the SNR information from every data packet from the
2857 ongoing traffic and will store it. It will provide the result to SME
2858 upon request.
2859
2860 DEPENDENCIES
2861
2862 WARNING: the read and write of this value will not be protected
2863 by locks, therefore the information obtained after a read
2864 might not always be consistent.
2865
2866 PARAMETERS
2867
2868 IN
2869 pvosGCtx: pointer to the global vos context; a handle to TL's
2870 or SME's control block can be extracted from its context
2871 ucSTAId: station identifier for the requested value
2872
2873 OUT
2874 puLinkQuality: the average value of the SNR
2875
2876
2877 RETURN VALUE
2878 The result code associated with performing the operation
2879
2880 VOS_STATUS_E_INVAL: Input parameters are invalid
2881 VOS_STATUS_E_FAULT: Station ID is outside array boundaries or pointer
2882 to TL cb is NULL ; access would cause a page fault
2883 VOS_STATUS_E_EXISTS: STA was not yet registered
2884 VOS_STATUS_SUCCESS: Everything is good :)
2885
2886 SIDE EFFECTS
2887
2888============================================================================*/
2889VOS_STATUS
2890WLANTL_GetLinkQuality
2891(
2892 v_PVOID_t pvosGCtx,
2893 v_U8_t ucSTAId,
2894 v_U32_t* puLinkQuality
2895)
2896{
2897 WLANTL_CbType* pTLCb = NULL;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302898 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002899
2900 /*------------------------------------------------------------------------
2901 Sanity check
2902 ------------------------------------------------------------------------*/
2903 if ( NULL == puLinkQuality )
2904 {
2905 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2906 "Invalid parameter sent on WLANTL_GetLinkQuality"));
2907 return VOS_STATUS_E_INVAL;
2908 }
2909
2910 if ( WLANTL_STA_ID_INVALID( ucSTAId ) )
2911 {
2912 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2913 "Invalid station id requested on WLANTL_GetLinkQuality"));
2914 return VOS_STATUS_E_FAULT;
2915 }
2916
2917 /*------------------------------------------------------------------------
2918 Extract TL control block and check existance
2919 ------------------------------------------------------------------------*/
2920 pTLCb = VOS_GET_TL_CB(pvosGCtx);
2921 if ( NULL == pTLCb )
2922 {
2923 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2924 "Invalid TL pointer from pvosGCtx on WLANTL_GetLinkQuality"));
2925 return VOS_STATUS_E_FAULT;
2926 }
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302927 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
Jeff Johnson295189b2012-06-20 16:38:30 -07002928
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302929 if ( NULL == pClientSTA )
2930 {
2931 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2932 "WLAN TL:Client Memory was not allocated on %s", __func__));
2933 return VOS_STATUS_E_FAILURE;
2934 }
2935
2936 if ( 0 == pClientSTA->ucExists )
Jeff Johnson295189b2012-06-20 16:38:30 -07002937 {
2938 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2939 "Station was not previously registered on WLANTL_GetLinkQuality"));
2940 return VOS_STATUS_E_EXISTS;
2941 }
2942
2943 /*------------------------------------------------------------------------
2944 Copy will not be locked; please read restriction
2945 ------------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302946 *puLinkQuality = pClientSTA->uLinkQualityAvg;
Jeff Johnson295189b2012-06-20 16:38:30 -07002947
2948 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
2949 "WLANTL_GetLinkQuality for STA: %d LinkQuality: %d", ucSTAId, *puLinkQuality));
2950
2951 return VOS_STATUS_SUCCESS;
2952}/* WLANTL_GetLinkQuality */
2953
2954/*==========================================================================
2955
2956 FUNCTION WLANTL_FlushStaTID
2957
2958 DESCRIPTION
2959 TL provides this API as an interface to SME (BAP) layer. TL inturn posts a
2960 message to HAL. This API is called by the SME inorder to perform a flush
2961 operation.
2962
2963 DEPENDENCIES
2964
2965 PARAMETERS
2966
2967 IN
2968 pvosGCtx: pointer to the global vos context; a handle to TL's
2969 or SME's control block can be extracted from its context
2970 ucSTAId: station identifier for the requested value
2971 ucTid: Tspec ID for the new BA session
2972
2973 OUT
2974 The response for this post is received in the main thread, via a response
2975 message from HAL to TL.
2976
2977 RETURN VALUE
2978 VOS_STATUS_SUCCESS: Everything is good :)
2979
2980 SIDE EFFECTS
2981============================================================================*/
2982VOS_STATUS
2983WLANTL_FlushStaTID
2984(
2985 v_PVOID_t pvosGCtx,
2986 v_U8_t ucSTAId,
2987 v_U8_t ucTid
2988)
2989{
2990 WLANTL_CbType* pTLCb = NULL;
2991 tpFlushACReq FlushACReqPtr = NULL;
2992 vos_msg_t vosMessage;
2993
2994
2995 if ( WLANTL_STA_ID_INVALID( ucSTAId ) )
2996 {
2997 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2998 "Invalid station id requested on WLANTL_FlushStaTID"));
2999 return VOS_STATUS_E_FAULT;
3000 }
3001
3002 /*------------------------------------------------------------------------
3003 Extract TL control block and check existance
3004 ------------------------------------------------------------------------*/
3005 pTLCb = VOS_GET_TL_CB(pvosGCtx);
3006 if ( NULL == pTLCb )
3007 {
3008 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3009 "Invalid TL pointer from pvosGCtx on WLANTL_FlushStaTID"));
3010 return VOS_STATUS_E_FAULT;
3011 }
3012
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05303013 if ( NULL == pTLCb->atlSTAClients[ucSTAId] )
3014 {
3015 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3016 "WLAN TL:Client Memory was not allocated on %s", __func__));
3017 return VOS_STATUS_E_FAILURE;
3018 }
3019
3020 if ( 0 == pTLCb->atlSTAClients[ucSTAId]->ucExists )
Jeff Johnson295189b2012-06-20 16:38:30 -07003021 {
3022 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3023 "Station was not previously registered on WLANTL_FlushStaTID"));
3024 return VOS_STATUS_E_EXISTS;
3025 }
3026
3027 /*------------------------------------------------------------------------
3028 We need to post a message with the STA, TID value to HAL. HAL performs the flush
3029 ------------------------------------------------------------------------*/
3030 FlushACReqPtr = vos_mem_malloc(sizeof(tFlushACReq));
3031
3032 if ( NULL == FlushACReqPtr )
3033 {
3034 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3035 "WLAN TL: fatal failure, cannot allocate Flush Req structure"));
3036 VOS_ASSERT(0);
3037 return VOS_STATUS_E_NOMEM;
3038 }
3039
3040 // Start constructing the message for HAL
3041 FlushACReqPtr->mesgType = SIR_TL_HAL_FLUSH_AC_REQ;
3042 FlushACReqPtr->mesgLen = sizeof(tFlushACReq);
3043 FlushACReqPtr->mesgLen = sizeof(tFlushACReq);
3044 FlushACReqPtr->ucSTAId = ucSTAId;
3045 FlushACReqPtr->ucTid = ucTid;
3046
3047 vosMessage.type = WDA_TL_FLUSH_AC_REQ;
3048 vosMessage.bodyptr = (void *)FlushACReqPtr;
3049
3050 vos_mq_post_message(VOS_MQ_ID_WDA, &vosMessage);
3051 return VOS_STATUS_SUCCESS;
3052}
3053
3054
3055/*----------------------------------------------------------------------------
3056 INTERACTION WITH PE
3057 ---------------------------------------------------------------------------*/
Siddharth Bhal4551b102014-10-09 21:36:36 +05303058/*==========================================================================
Jeff Johnson295189b2012-06-20 16:38:30 -07003059
Siddharth Bhal4551b102014-10-09 21:36:36 +05303060 FUNCTION WLANTL_updateSpoofMacAddr
3061
3062 DESCRIPTION
3063 Called by HDD to update macaddr
3064
3065 DEPENDENCIES
3066 TL must be initialized before this API can be called.
3067
3068 PARAMETERS
3069
3070 IN
3071 pvosGCtx: pointer to the global vos context; a handle to
3072 TL's control block can be extracted from its context
3073 spoofMacAddr: spoofed mac adderess
3074 selfMacAddr: self Mac Address
3075
3076 RETURN VALUE
3077 The result code associated with performing the operation
3078
3079 VOS_STATUS_E_INVAL: Input parameters are invalid
3080 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
3081 page fault
3082 VOS_STATUS_SUCCESS: Everything is good :)
3083
3084 SIDE EFFECTS
3085
3086============================================================================*/
3087VOS_STATUS
3088WLANTL_updateSpoofMacAddr
3089(
3090 v_PVOID_t pvosGCtx,
3091 v_MACADDR_t* spoofMacAddr,
3092 v_MACADDR_t* selfMacAddr
3093)
3094{
3095 WLANTL_CbType* pTLCb = NULL;
3096 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
3097
3098 /*------------------------------------------------------------------------
Siddharth Bhal4551b102014-10-09 21:36:36 +05303099 Extract TL control block
3100 ------------------------------------------------------------------------*/
3101 pTLCb = VOS_GET_TL_CB(pvosGCtx);
3102 if ( NULL == pTLCb )
3103 {
3104 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3105 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_ChangeSTAState");
3106 return VOS_STATUS_E_FAULT;
3107 }
3108
3109 vos_mem_copy(pTLCb->spoofMacAddr.selfMac.bytes, selfMacAddr,
3110 VOS_MAC_ADDRESS_LEN);
3111 vos_mem_copy(pTLCb->spoofMacAddr.spoofMac.bytes, spoofMacAddr,
3112 VOS_MAC_ADDRESS_LEN);
3113
3114 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_LOW,
3115 "TL: SelfSTA mac Addr for current Scan "MAC_ADDRESS_STR,
3116 MAC_ADDR_ARRAY(pTLCb->spoofMacAddr.selfMac.bytes));
3117
3118 return VOS_STATUS_SUCCESS;
3119}/* WLANTL_updateSpoofMacAddr */
Jeff Johnson295189b2012-06-20 16:38:30 -07003120/*==========================================================================
3121
3122 FUNCTION WLANTL_RegisterMgmtFrmClient
3123
3124 DESCRIPTION
3125 Called by PE to register as a client for management frames delivery.
3126
3127 DEPENDENCIES
3128 TL must be initialized before this API can be called.
3129
3130 PARAMETERS
3131
3132 IN
3133 pvosGCtx: pointer to the global vos context; a handle to
3134 TL's control block can be extracted from its context
3135 pfnTlMgmtFrmRx: pointer to the receive processing routine for
3136 management frames
3137
3138 RETURN VALUE
3139 The result code associated with performing the operation
3140
3141 VOS_STATUS_E_INVAL: Input parameters are invalid
3142 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
3143 page fault
3144 VOS_STATUS_E_EXISTS: Mgmt Frame client was already registered
3145 VOS_STATUS_SUCCESS: Everything is good :)
3146
3147 SIDE EFFECTS
3148
3149============================================================================*/
3150VOS_STATUS
3151WLANTL_RegisterMgmtFrmClient
3152(
3153 v_PVOID_t pvosGCtx,
3154 WLANTL_MgmtFrmRxCBType pfnTlMgmtFrmRx
3155)
3156{
3157 WLANTL_CbType* pTLCb = NULL;
3158 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
3159
3160 /*------------------------------------------------------------------------
3161 Sanity check
3162 ------------------------------------------------------------------------*/
3163 if ( NULL == pfnTlMgmtFrmRx )
3164 {
3165 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3166 "WLAN TL:Invalid parameter sent on WLANTL_RegisterMgmtFrmClient"));
3167 return VOS_STATUS_E_INVAL;
3168 }
3169
3170 /*------------------------------------------------------------------------
3171 Extract TL control block
3172 ------------------------------------------------------------------------*/
3173 pTLCb = VOS_GET_TL_CB(pvosGCtx);
3174 if ( NULL == pTLCb )
3175 {
3176 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3177 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_ChangeSTAState"));
3178 return VOS_STATUS_E_FAULT;
3179 }
3180
3181 /*------------------------------------------------------------------------
3182 Make sure this is the first registration attempt
3183 ------------------------------------------------------------------------*/
3184 if ( 0 != pTLCb->tlMgmtFrmClient.ucExists )
3185 {
3186 pTLCb->tlMgmtFrmClient.ucExists++;
3187 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3188 "WLAN TL:Management frame client was already registered"));
3189 return VOS_STATUS_E_EXISTS;
3190 }
3191
3192 /*------------------------------------------------------------------------
3193 Register station with TL
3194 ------------------------------------------------------------------------*/
3195 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
3196 "WLAN TL:Registering Management Frame Client" ));
3197
3198 pTLCb->tlMgmtFrmClient.ucExists++;
3199
3200 if ( NULL != pfnTlMgmtFrmRx )
3201 {
3202 pTLCb->tlMgmtFrmClient.pfnTlMgmtFrmRx = pfnTlMgmtFrmRx;
3203 }
3204
3205 pTLCb->tlMgmtFrmClient.vosPendingDataBuff = NULL;
3206
3207 return VOS_STATUS_SUCCESS;
3208}/* WLANTL_RegisterMgmtFrmClient */
3209
3210/*==========================================================================
3211
3212 FUNCTION WLANTL_DeRegisterMgmtFrmClient
3213
3214 DESCRIPTION
3215 Called by PE to deregister as a client for management frames delivery.
3216
3217 DEPENDENCIES
3218 TL must be initialized before this API can be called.
3219
3220 PARAMETERS
3221
3222 IN
3223 pvosGCtx: pointer to the global vos context; a handle to
3224 TL's control block can be extracted from its context
3225 RETURN VALUE
3226 The result code associated with performing the operation
3227
3228 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
3229 page fault
3230 VOS_STATUS_E_EXISTS: Mgmt Frame client was never registered
3231 VOS_STATUS_SUCCESS: Everything is good :)
3232
3233 SIDE EFFECTS
3234
3235============================================================================*/
3236VOS_STATUS
3237WLANTL_DeRegisterMgmtFrmClient
3238(
3239 v_PVOID_t pvosGCtx
3240)
3241{
3242 WLANTL_CbType* pTLCb = NULL;
3243 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
3244
3245 /*------------------------------------------------------------------------
3246 Extract TL control block
3247 ------------------------------------------------------------------------*/
3248 pTLCb = VOS_GET_TL_CB(pvosGCtx);
3249 if ( NULL == pTLCb )
3250 {
3251 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3252 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_ChangeSTAState"));
3253 return VOS_STATUS_E_FAULT;
3254 }
3255
3256 /*------------------------------------------------------------------------
3257 Make sure this is the first registration attempt
3258 ------------------------------------------------------------------------*/
3259 if ( 0 == pTLCb->tlMgmtFrmClient.ucExists )
3260 {
3261 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3262 "WLAN TL:Management frame client was never registered"));
3263 return VOS_STATUS_E_EXISTS;
3264 }
3265
3266 /*------------------------------------------------------------------------
3267 Clear registration with TL
3268 ------------------------------------------------------------------------*/
3269 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
3270 "WLAN TL:Deregistering Management Frame Client" ));
3271
3272 pTLCb->tlMgmtFrmClient.pfnTlMgmtFrmRx = WLANTL_MgmtFrmRxDefaultCb;
3273 if ( NULL != pTLCb->tlMgmtFrmClient.vosPendingDataBuff)
3274 {
3275 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
3276 "WLAN TL:Management cache buffer not empty on deregistering"
3277 " - dropping packet" ));
3278 vos_pkt_return_packet(pTLCb->tlMgmtFrmClient.vosPendingDataBuff);
3279
3280 pTLCb->tlMgmtFrmClient.vosPendingDataBuff = NULL;
3281 }
3282
3283 pTLCb->tlMgmtFrmClient.ucExists = 0;
3284
3285 return VOS_STATUS_SUCCESS;
3286}/* WLANTL_RegisterMgmtFrmClient */
3287
3288/*==========================================================================
3289
3290 FUNCTION WLANTL_TxMgmtFrm
3291
3292 DESCRIPTION
3293 Called by PE when it want to send out a management frame.
3294 HAL will also use this API for the few frames it sends out, they are not
3295 management frames howevere it is accepted that an exception will be
3296 allowed ONLY for the usage of HAL.
3297 Generic data frames SHOULD NOT travel through this function.
3298
3299 DEPENDENCIES
3300 TL must be initialized before this API can be called.
3301
3302 RESTRICTION: If PE sends another packet before TL manages to process the
3303 previously sent packet call will end in failure
3304
3305 Frames comming through here must be 802.11 frames, frame
3306 translation in UMA will be automatically disabled.
3307
3308 PARAMETERS
3309
3310 IN
3311 pvosGCtx: pointer to the global vos context;a handle to TL's
3312 control block can be extracted from its context
3313 vosFrmBuf: pointer to a vOSS buffer containing the management
3314 frame to be transmitted
3315 usFrmLen: the length of the frame to be transmitted; information
3316 is already included in the vOSS buffer
3317 wFrmType: the type of the frame being transmitted
3318 tid: tid used to transmit this frame
3319 pfnCompTxFunc: function pointer to the transmit complete routine
3320 pvBDHeader: pointer to the BD header, if NULL it means it was not
3321 yet constructed and it lies within TL's responsibility
3322 to do so; if not NULL it is expected that it was
3323 already packed inside the vos packet
3324 ucAckResponse: flag notifying it an interrupt is needed for the
3325 acknowledgement received when the frame is sent out
3326 the air and ; the interrupt will be processed by HAL,
3327 only one such frame can be pending in the system at
3328 one time.
3329
3330
3331 RETURN VALUE
3332 The result code associated with performing the operation
3333
3334 VOS_STATUS_E_INVAL: Input parameters are invalid
3335 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
3336 page fault
3337 VOS_STATUS_E_EXISTS: Mgmt Frame client was not yet registered
3338 VOS_STATUS_E_BUSY: The previous Mgmt packet was not yet transmitted
3339 VOS_STATUS_SUCCESS: Everything is good :)
3340
3341 Other failure messages may be returned from the BD header handling
3342 routines, please check apropriate API for more info.
3343
3344 SIDE EFFECTS
3345
3346============================================================================*/
3347VOS_STATUS
3348WLANTL_TxMgmtFrm
3349(
3350 v_PVOID_t pvosGCtx,
3351 vos_pkt_t* vosFrmBuf,
3352 v_U16_t usFrmLen,
3353 v_U8_t wFrmType,
3354 v_U8_t ucTid,
3355 WLANTL_TxCompCBType pfnCompTxFunc,
3356 v_PVOID_t pvBDHeader,
Ganesh Kondabattini10e67352015-03-16 17:41:57 +05303357 v_U32_t ucAckResponse,
3358 v_U32_t ucTxBdToken
Jeff Johnson295189b2012-06-20 16:38:30 -07003359)
3360{
3361 WLANTL_CbType* pTLCb = NULL;
3362 v_MACADDR_t vDestMacAddr;
3363 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
3364 v_U16_t usPktLen;
3365 v_U32_t usTimeStamp = 0;
3366 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
3367
3368 /*------------------------------------------------------------------------
3369 Sanity check
3370 ------------------------------------------------------------------------*/
3371 if ( NULL == vosFrmBuf )
3372 {
3373 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3374 "WLAN TL:Invalid parameter sent on WLANTL_TxMgmtFrm"));
3375 return VOS_STATUS_E_INVAL;
3376 }
3377
3378 /*------------------------------------------------------------------------
3379 Extract TL control block
3380 ------------------------------------------------------------------------*/
3381 pTLCb = VOS_GET_TL_CB(pvosGCtx);
3382 if ( NULL == pTLCb )
3383 {
3384 TLLOGP(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_FATAL,
3385 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_TxMgmtFrm"));
3386 return VOS_STATUS_E_FAULT;
3387 }
3388
3389 /*------------------------------------------------------------------------
3390 Ensure that management frame client was previously registered
3391 ------------------------------------------------------------------------*/
3392 if ( 0 == pTLCb->tlMgmtFrmClient.ucExists )
3393 {
3394 pTLCb->tlMgmtFrmClient.ucExists++;
3395 TLLOGP(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_FATAL,
3396 "WLAN TL:Management Frame client not register on WLANTL_TxMgmtFrm"));
3397 return VOS_STATUS_E_EXISTS;
3398 }
3399
3400 /*------------------------------------------------------------------------
3401 Check if any Mgmt Frm is pending
3402 ------------------------------------------------------------------------*/
3403 //vosTempBuff = pTLCb->tlMgmtFrmClient.vosPendingDataBuff;
3404 if ( NULL != pTLCb->tlMgmtFrmClient.vosPendingDataBuff )
3405 {
3406
3407 TLLOGP(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_FATAL,
3408 "WLAN TL:Management Frame already pending tx in TL: failing old one"));
3409
3410
3411 /*Failing the tx for the previous packet enqued by PE*/
Arun Kumar Khandavalli0af8d3c2014-02-07 18:05:11 +05303412 //vos_atomic_set( (uintptr_t*)&pTLCb->tlMgmtFrmClient.vosPendingDataBuff,
3413 // (uintptr_t)NULL);
Jeff Johnson295189b2012-06-20 16:38:30 -07003414
3415 //vos_pkt_get_user_data_ptr( vosTempBuff, VOS_PKT_USER_DATA_ID_TL,
3416 // (v_PVOID_t)&pfnTxComp);
3417
3418 /*it should never be NULL - default handler should be registered if none*/
3419 //if ( NULL == pfnTxComp )
3420 //{
3421 // VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3422 // "NULL pointer to Tx Complete on WLANTL_TxMgmtFrm");
3423 // VOS_ASSERT(0);
3424 // return VOS_STATUS_E_FAULT;
3425 //}
3426
3427 //pfnTxComp( pvosGCtx, vosTempBuff, VOS_STATUS_E_RESOURCES );
3428 //return VOS_STATUS_E_BUSY;
3429
3430
3431 //pfnCompTxFunc( pvosGCtx, vosFrmBuf, VOS_STATUS_E_RESOURCES);
3432 return VOS_STATUS_E_RESOURCES;
3433 }
3434
3435
3436 /*------------------------------------------------------------------------
3437 Check if BD header was build, if not construct
3438 ------------------------------------------------------------------------*/
3439 if ( NULL == pvBDHeader )
3440 {
3441 v_MACADDR_t* pvAddr2MacAddr;
3442 v_U8_t uQosHdr = VOS_FALSE;
3443
3444 /* Get address 2 of Mangement Frame to give to WLANHAL_FillTxBd */
3445 vosStatus = vos_pkt_peek_data( vosFrmBuf,
3446 WLANTL_MAC_ADDR_ALIGN(1) + VOS_MAC_ADDR_SIZE,
3447 (v_PVOID_t)&pvAddr2MacAddr, VOS_MAC_ADDR_SIZE);
3448
3449 if ( VOS_STATUS_SUCCESS != vosStatus )
3450 {
3451 TLLOGP(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_FATAL,
3452 "WLAN TL:Failed while attempting to get addr2 %d", vosStatus));
3453 return vosStatus;
3454 }
Gopichand Nakkala0f3eb5c2013-05-07 16:48:38 +05303455
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003456 /* ESE IAPP/TDLS Frame which are data frames but technically used
Jeff Johnson295189b2012-06-20 16:38:30 -07003457 * for management functionality comes through route.
3458 */
3459 if (WLANTL_IS_QOS_DATA_FRAME(wFrmType)) \
3460 {
3461 uQosHdr = VOS_TRUE;
3462 }
Siddharth Bhal4551b102014-10-09 21:36:36 +05303463
3464 if (WLANTL_IS_PROBE_REQ(wFrmType))
3465 {
3466 if (VOS_TRUE == vos_mem_compare((v_VOID_t*) pvAddr2MacAddr,
3467 (v_VOID_t*) &pTLCb->spoofMacAddr.spoofMac, VOS_MAC_ADDRESS_LEN))
3468 {
3469 pvAddr2MacAddr = (v_PVOID_t)pTLCb->spoofMacAddr.selfMac.bytes;
3470 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
3471 "TL: using self sta addr to get staidx for spoofed probe req "
3472 MAC_ADDRESS_STR, MAC_ADDR_ARRAY(pvAddr2MacAddr->bytes));
3473 }
3474 }
3475
Jeff Johnson295189b2012-06-20 16:38:30 -07003476 /*----------------------------------------------------------------------
3477 Call WDA to build TX header
3478 ----------------------------------------------------------------------*/
3479 vosStatus = WDA_DS_BuildTxPacketInfo( pvosGCtx, vosFrmBuf , &vDestMacAddr,
3480 1 /* always 802.11 frames*/, &usPktLen, uQosHdr /*qos not enabled !!!*/,
Siddharth Bhal4551b102014-10-09 21:36:36 +05303481 0 /* WDS off */, 0, wFrmType, pvAddr2MacAddr, ucTid,
Ganesh Kondabattini10e67352015-03-16 17:41:57 +05303482 ucAckResponse, usTimeStamp, 0, 0, ucTxBdToken);
Jeff Johnson295189b2012-06-20 16:38:30 -07003483
3484
3485 if ( !VOS_IS_STATUS_SUCCESS(vosStatus) )
3486 {
3487 TLLOGP(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_FATAL,
3488 "WLAN TL:Failed while attempting to build TX header %d", vosStatus));
3489 return vosStatus;
3490 }
3491 }/* if BD header not present */
3492
3493 /*------------------------------------------------------------------------
3494 Save buffer and notify BAL; no lock is needed if the above restriction
3495 is met
3496 Save the tx complete fnct pointer as tl specific data in the vos buffer
3497 ------------------------------------------------------------------------*/
3498 if ( NULL != pfnCompTxFunc )
3499 {
3500 vos_pkt_set_user_data_ptr( vosFrmBuf, VOS_PKT_USER_DATA_ID_TL,
3501 (v_PVOID_t)pfnCompTxFunc);
3502 }
3503 else
3504 {
3505 vos_pkt_set_user_data_ptr( vosFrmBuf, VOS_PKT_USER_DATA_ID_TL,
3506 (v_PVOID_t)WLANTL_TxCompDefaultCb);
3507
3508 }
Arun Kumar Khandavalli0af8d3c2014-02-07 18:05:11 +05303509 vos_atomic_set( (uintptr_t*)&pTLCb->tlMgmtFrmClient.vosPendingDataBuff,
3510 (uintptr_t)vosFrmBuf);
Jeff Johnson295189b2012-06-20 16:38:30 -07003511
3512 /*------------------------------------------------------------------------
3513 Check if thre are enough resources for transmission and tx is not
3514 suspended.
3515 ------------------------------------------------------------------------*/
3516 if ( pTLCb->uResCount >= WDA_TLI_MIN_RES_MF )
3517 {
3518 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
3519 "WLAN TL:Issuing Xmit start request to BAL for MGMT"));
3520 vosStatus = WDA_DS_StartXmit(pvosGCtx);
3521 if(VOS_STATUS_SUCCESS != vosStatus)
3522 {
3523 TLLOGP(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_FATAL,
3524 "WLAN TL:WDA_DS_StartXmit fails. vosStatus %d", vosStatus));
Arun Kumar Khandavalli0af8d3c2014-02-07 18:05:11 +05303525 vos_atomic_set( (uintptr_t*)&pTLCb->tlMgmtFrmClient.vosPendingDataBuff,0);
Jeff Johnson295189b2012-06-20 16:38:30 -07003526 }
3527 return vosStatus;
3528
3529 }
3530 else
3531 {
3532 /*---------------------------------------------------------------------
3533 No error code is sent because TL will resume tx autonomously if
3534 resources become available or tx gets resumed
3535 ---------------------------------------------------------------------*/
3536 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
3537 "WLAN TL:Request to send for Mgmt Frm but condition not met. Res: %d",
3538 pTLCb->uResCount));
3539 }
3540
3541 return VOS_STATUS_SUCCESS;
3542}/* WLANTL_TxMgmtFrm */
3543
3544/*----------------------------------------------------------------------------
3545 INTERACTION WITH HAL
3546 ---------------------------------------------------------------------------*/
3547
3548/*==========================================================================
3549
3550 FUNCTION WLANTL_ResetNotification
3551
3552 DESCRIPTION
3553 HAL notifies TL when the module is being reset.
3554 Currently not used.
3555
3556 DEPENDENCIES
3557
3558 PARAMETERS
3559
3560 IN
3561 pvosGCtx: pointer to the global vos context; a handle to TL's
3562 control block can be extracted from its context
3563
3564
3565 RETURN VALUE
3566 The result code associated with performing the operation
3567
3568 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
3569 page fault
3570 VOS_STATUS_SUCCESS: Everything is good :)
3571
3572 SIDE EFFECTS
3573
3574============================================================================*/
3575VOS_STATUS
3576WLANTL_ResetNotification
3577(
3578 v_PVOID_t pvosGCtx
3579)
3580{
3581 WLANTL_CbType* pTLCb = NULL;
3582 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
3583
3584 /*------------------------------------------------------------------------
3585 Sanity check
3586 Extract TL control block
3587 ------------------------------------------------------------------------*/
3588 pTLCb = VOS_GET_TL_CB(pvosGCtx);
3589 if ( NULL == pTLCb )
3590 {
3591 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3592 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_ResetNotification"));
3593 return VOS_STATUS_E_FAULT;
3594 }
3595
3596 WLANTL_CleanCB(pTLCb, 1 /*empty all queues and pending packets*/);
3597 return VOS_STATUS_SUCCESS;
3598}/* WLANTL_ResetNotification */
3599
3600/*==========================================================================
3601
3602 FUNCTION WLANTL_SuspendDataTx
3603
3604 DESCRIPTION
3605 HAL calls this API when it wishes to suspend transmission for a
3606 particular STA.
3607
3608 DEPENDENCIES
3609 The STA for which the request is made must be first registered with
3610 TL by HDD.
3611
3612 RESTRICTION: In case of a suspend, the flag write and read will not be
3613 locked: worst case scenario one more packet can get
3614 through before the flag gets updated (we can make this
3615 write atomic as well to guarantee consistency)
3616
3617 PARAMETERS
3618
3619 IN
3620 pvosGCtx: pointer to the global vos context; a handle to TL's
3621 control block can be extracted from its context
3622 pucSTAId: identifier of the station for which the request is made;
3623 a value of NULL assumes suspend on all active station
3624 pfnSuspendTxCB: pointer to the suspend result notification in case the
3625 call is asynchronous
3626
3627
3628 RETURN VALUE
3629 The result code associated with performing the operation
3630
3631 VOS_STATUS_E_FAULT: Station ID is outside array boundaries or pointer
3632 to TL cb is NULL ; access would cause a page fault
3633 VOS_STATUS_E_EXISTS: Station was not registered
3634 VOS_STATUS_SUCCESS: Everything is good :)
3635
3636 SIDE EFFECTS
3637
3638============================================================================*/
3639
3640VOS_STATUS
3641WLANTL_SuspendDataTx
3642(
3643 v_PVOID_t pvosGCtx,
3644 v_U8_t* pucSTAId,
3645 WLANTL_SuspendCBType pfnSuspendTx
3646)
3647{
3648 WLANTL_CbType* pTLCb = NULL;
3649 vos_msg_t vosMsg;
Jeff Johnson295189b2012-06-20 16:38:30 -07003650
3651 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
3652
3653 /*------------------------------------------------------------------------
3654 Sanity check
3655 Extract TL control block
3656 ------------------------------------------------------------------------*/
3657 pTLCb = VOS_GET_TL_CB(pvosGCtx);
Hoonki Lee14621352013-04-16 17:51:19 -07003658 if ( NULL == pTLCb )
Jeff Johnson295189b2012-06-20 16:38:30 -07003659 {
3660 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3661 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_SuspendDataTx"));
3662 return VOS_STATUS_E_FAULT;
3663 }
3664
3665 /*------------------------------------------------------------------------
3666 Check the type of request: generic suspend, or per station suspend
3667 ------------------------------------------------------------------------*/
Hoonki Lee14621352013-04-16 17:51:19 -07003668 if (NULL == pucSTAId)
Jeff Johnson295189b2012-06-20 16:38:30 -07003669 {
3670 /* General Suspend Request received */
3671 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
3672 "WLAN TL:General suspend requested"));
Hoonki Lee14621352013-04-16 17:51:19 -07003673 vos_atomic_set_U8( &pTLCb->ucTxSuspended, 1);
Jeff Johnson295189b2012-06-20 16:38:30 -07003674 vosMsg.reserved = WLAN_MAX_STA_COUNT;
3675 }
3676 else
3677 {
Hoonki Lee14621352013-04-16 17:51:19 -07003678 if ( WLANTL_STA_ID_INVALID( *pucSTAId ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07003679 {
Hoonki Lee14621352013-04-16 17:51:19 -07003680 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3681 "WLAN TL:Invalid station id %d requested on WLANTL_SuspendDataTx", *pucSTAId));
3682 return VOS_STATUS_E_FAULT;
3683 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003684
Gopichand Nakkalae5fef6c2013-06-19 18:04:23 +05303685 if ( NULL == pTLCb->atlSTAClients[*pucSTAId] )
3686 {
3687 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3688 "WLAN TL:Invalid pTLCb->atlSTAClients pointer for STA Id :%d on "
3689 "WLANTL_SuspendDataTx", *pucSTAId));
3690 return VOS_STATUS_E_FAULT;
3691 }
3692
3693 if ( 0 == pTLCb->atlSTAClients[*pucSTAId]->ucExists )
Hoonki Lee14621352013-04-16 17:51:19 -07003694 {
3695 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3696 "WLAN TL:Station %d was not previously registered on WLANTL_SuspendDataTx", *pucSTAId));
3697 return VOS_STATUS_E_EXISTS;
3698 }
3699
3700 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
3701 "WLAN TL:Suspend request for station: %d", *pucSTAId));
3702 vos_atomic_set_U8( &pTLCb->atlSTAClients[*pucSTAId]->ucTxSuspended, 1);
Jeff Johnson295189b2012-06-20 16:38:30 -07003703 vosMsg.reserved = *pucSTAId;
3704 }
3705
3706 /*------------------------------------------------------------------------
3707 Serialize request through TX thread
3708 ------------------------------------------------------------------------*/
3709 vosMsg.type = WLANTL_TX_SIG_SUSPEND;
3710 vosMsg.bodyptr = (v_PVOID_t)pfnSuspendTx;
3711
Katya Nigam42e16e82014-02-04 16:28:55 +05303712 MTRACE(vos_trace(VOS_MODULE_ID_TL, TRACE_CODE_TL_SUSPEND_DATA_TX,
3713 vosMsg.reserved , 0 ));
3714
Jeff Johnson295189b2012-06-20 16:38:30 -07003715 if(!VOS_IS_STATUS_SUCCESS(vos_tx_mq_serialize( VOS_MQ_ID_TL, &vosMsg)))
3716 {
3717 VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003718 " %s fails to post message", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003719 }
3720
3721 return VOS_STATUS_SUCCESS;
3722}/* WLANTL_SuspendDataTx */
3723
3724/*==========================================================================
3725
3726 FUNCTION WLANTL_ResumeDataTx
3727
3728 DESCRIPTION
3729 Called by HAL to resume data transmission for a given STA.
3730
3731 WARNING: If a station was individually suspended a global resume will
3732 not resume that station
3733
3734 DEPENDENCIES
3735
3736 PARAMETERS
3737
3738 IN
3739 pvosGCtx: pointer to the global vos context; a handle to TL's
3740 control block can be extracted from its context
3741 pucSTAId: identifier of the station which is being resumed; NULL
3742 translates into global resume
3743
3744 RETURN VALUE
3745 The result code associated with performing the operation
3746
3747 VOS_STATUS_E_FAULT: Station ID is outside array boundaries or pointer
3748 to TL cb is NULL ; access would cause a page fault
3749 VOS_STATUS_E_EXISTS: Station was not registered
3750 VOS_STATUS_SUCCESS: Everything is good :)
3751
3752 SIDE EFFECTS
3753
3754============================================================================*/
3755
3756VOS_STATUS
3757WLANTL_ResumeDataTx
3758(
3759 v_PVOID_t pvosGCtx,
3760 v_U8_t* pucSTAId
3761)
3762{
3763 WLANTL_CbType* pTLCb = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07003764 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
3765
3766 /*------------------------------------------------------------------------
3767 Sanity check
3768 Extract TL control block
3769 ------------------------------------------------------------------------*/
3770 pTLCb = VOS_GET_TL_CB(pvosGCtx);
Hoonki Lee14621352013-04-16 17:51:19 -07003771 if ( NULL == pTLCb )
Jeff Johnson295189b2012-06-20 16:38:30 -07003772 {
3773 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3774 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_ResumeDataTx"));
3775 return VOS_STATUS_E_FAULT;
3776 }
3777
Jeff Johnson295189b2012-06-20 16:38:30 -07003778 /*------------------------------------------------------------------------
3779 Check to see the type of resume
3780 ------------------------------------------------------------------------*/
Hoonki Lee14621352013-04-16 17:51:19 -07003781 if ( NULL == pucSTAId )
Jeff Johnson295189b2012-06-20 16:38:30 -07003782 {
Katya Nigam42e16e82014-02-04 16:28:55 +05303783 MTRACE(vos_trace(VOS_MODULE_ID_TL, TRACE_CODE_TL_RESUME_DATA_TX,
3784 41 , 0 ));
3785
Jeff Johnson295189b2012-06-20 16:38:30 -07003786 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
3787 "WLAN TL:General resume requested"));
3788 vos_atomic_set_U8( &pTLCb->ucTxSuspended, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07003789 }
3790 else
3791 {
Katya Nigam42e16e82014-02-04 16:28:55 +05303792 MTRACE(vos_trace(VOS_MODULE_ID_TL, TRACE_CODE_TL_RESUME_DATA_TX,
3793 *pucSTAId , 0 ));
3794
Hoonki Lee14621352013-04-16 17:51:19 -07003795 if ( WLANTL_STA_ID_INVALID( *pucSTAId ))
Jeff Johnson295189b2012-06-20 16:38:30 -07003796 {
Hoonki Lee14621352013-04-16 17:51:19 -07003797 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3798 "WLAN TL:Invalid station id %d requested on WLANTL_ResumeDataTx", *pucSTAId));
3799 return VOS_STATUS_E_FAULT;
3800 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003801
Gopichand Nakkalae5fef6c2013-06-19 18:04:23 +05303802 if ( NULL == pTLCb->atlSTAClients[*pucSTAId] )
3803 {
3804 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3805 "WLAN TL:Invalid pTLCb->atlSTAClients pointer for STA Id :%d on "
3806 "WLANTL_ResumeDataTx", *pucSTAId));
3807 return VOS_STATUS_E_FAULT;
3808 }
3809
3810 if ( 0 == pTLCb->atlSTAClients[*pucSTAId]->ucExists )
Hoonki Lee14621352013-04-16 17:51:19 -07003811 {
3812 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3813 "WLAN TL:Station %d was not previously registered on WLANTL_ResumeDataTx", *pucSTAId));
3814 return VOS_STATUS_E_EXISTS;
3815 }
3816
3817 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
3818 "WLAN TL:Resume request for station: %d", *pucSTAId));
3819 vos_atomic_set_U8( &pTLCb->atlSTAClients[*pucSTAId]->ucTxSuspended, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07003820 }
3821
3822 /*------------------------------------------------------------------------
3823 Resuming transmission
3824 ------------------------------------------------------------------------*/
Hoonki Lee14621352013-04-16 17:51:19 -07003825 if (( pTLCb->uResCount >= WDA_TLI_MIN_RES_MF ) &&
3826 ( 0 == pTLCb->ucTxSuspended ))
Jeff Johnson295189b2012-06-20 16:38:30 -07003827 {
3828 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
3829 "WLAN TL:Resuming transmission"));
3830 return WDA_DS_StartXmit(pvosGCtx);
3831 }
3832
3833 return VOS_STATUS_SUCCESS;
3834}/* WLANTL_ResumeDataTx */
3835
3836/*==========================================================================
3837 FUNCTION WLANTL_SuspendCB
3838
3839 DESCRIPTION
3840 Callback function for serializing Suspend signal through Tx thread
3841
3842 DEPENDENCIES
3843 Just notify HAL that suspend in TL is complete.
3844
3845 PARAMETERS
3846
3847 IN
3848 pvosGCtx: pointer to the global vos context; a handle to TL's
3849 control block can be extracted from its context
3850 pUserData: user data sent with the callback
3851
3852 RETURN VALUE
3853 The result code associated with performing the operation
3854
3855 VOS_STATUS_E_INVAL: invalid input parameters
3856 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
3857 page fault
3858 VOS_STATUS_SUCCESS: Everything is good :)
3859
3860
3861 SIDE EFFECTS
3862
3863============================================================================*/
3864VOS_STATUS
3865WLANTL_SuspendCB
3866(
3867 v_PVOID_t pvosGCtx,
3868 WLANTL_SuspendCBType pfnSuspendCB,
3869 v_U16_t usReserved
3870)
3871{
3872 WLANTL_CbType* pTLCb = NULL;
3873 v_U8_t ucSTAId = (v_U8_t)usReserved;
3874 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
3875
3876 /*------------------------------------------------------------------------
3877 Sanity check
3878 ------------------------------------------------------------------------*/
3879 if ( NULL == pfnSuspendCB )
3880 {
3881 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
3882 "WLAN TL: No Call back processing requested WLANTL_SuspendCB"));
3883 return VOS_STATUS_SUCCESS;
3884 }
3885
3886 /*------------------------------------------------------------------------
3887 Extract TL control block
3888 ------------------------------------------------------------------------*/
3889 pTLCb = VOS_GET_TL_CB(pvosGCtx);
3890 if ( NULL == pTLCb )
3891 {
3892 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3893 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_SuspendCB"));
3894 return VOS_STATUS_E_FAULT;
3895 }
3896
3897 if ( WLANTL_STA_ID_INVALID( ucSTAId ) )
3898 {
3899 pfnSuspendCB(pvosGCtx, NULL, VOS_STATUS_SUCCESS);
3900 }
3901 else
3902 {
3903 pfnSuspendCB(pvosGCtx, &ucSTAId, VOS_STATUS_SUCCESS);
3904 }
3905
3906 return VOS_STATUS_SUCCESS;
3907}/*WLANTL_SuspendCB*/
3908
3909
3910/*----------------------------------------------------------------------------
3911 CLIENT INDEPENDENT INTERFACE
3912 ---------------------------------------------------------------------------*/
3913
3914/*==========================================================================
3915
3916 FUNCTION WLANTL_GetTxPktCount
3917
3918 DESCRIPTION
3919 TL will provide the number of transmitted packets counted per
3920 STA per TID.
3921
3922 DEPENDENCIES
3923
3924 PARAMETERS
3925
3926 IN
3927 pvosGCtx: pointer to the global vos context; a handle to TL's
3928 control block can be extracted from its context
3929 ucSTAId: identifier of the station
3930 ucTid: identifier of the tspec
3931
3932 OUT
3933 puTxPktCount: the number of packets tx packet for this STA and TID
3934
3935 RETURN VALUE
3936 The result code associated with performing the operation
3937
3938 VOS_STATUS_E_INVAL: Input parameters are invalid
3939 VOS_STATUS_E_FAULT: Station ID is outside array boundaries or pointer
3940 to TL cb is NULL ; access would cause a page fault
3941 VOS_STATUS_E_EXISTS: Station was not registered
3942 VOS_STATUS_SUCCESS: Everything is good :)
3943
3944 SIDE EFFECTS
3945
3946============================================================================*/
3947VOS_STATUS
3948WLANTL_GetTxPktCount
3949(
3950 v_PVOID_t pvosGCtx,
3951 v_U8_t ucSTAId,
3952 v_U8_t ucTid,
3953 v_U32_t* puTxPktCount
3954)
3955{
3956 WLANTL_CbType* pTLCb = NULL;
3957 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
3958
3959 /*------------------------------------------------------------------------
3960 Sanity check
3961 ------------------------------------------------------------------------*/
3962 if ( NULL == puTxPktCount )
3963 {
3964 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3965 "WLAN TL:Invalid parameter sent on WLANTL_GetTxPktCount"));
3966 return VOS_STATUS_E_INVAL;
3967 }
3968
3969 if ( WLANTL_STA_ID_INVALID( ucSTAId ) || WLANTL_TID_INVALID( ucTid) )
3970 {
3971 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3972 "WLAN TL:Invalid station id %d/tid %d requested on WLANTL_GetTxPktCount",
3973 ucSTAId, ucTid));
3974 return VOS_STATUS_E_FAULT;
3975 }
3976
3977 /*------------------------------------------------------------------------
3978 Extract TL control block and check if station exists
3979 ------------------------------------------------------------------------*/
3980 pTLCb = VOS_GET_TL_CB(pvosGCtx);
3981 if ( NULL == pTLCb )
3982 {
3983 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3984 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_GetTxPktCount"));
3985 return VOS_STATUS_E_FAULT;
3986 }
3987
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05303988 if ( NULL == pTLCb->atlSTAClients[ucSTAId] )
3989 {
3990 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3991 "WLAN TL:Client Memory was not allocated on %s", __func__));
3992 return VOS_STATUS_E_FAILURE;
3993 }
3994
3995 if ( 0 == pTLCb->atlSTAClients[ucSTAId]->ucExists )
Jeff Johnson295189b2012-06-20 16:38:30 -07003996 {
3997 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3998 "WLAN TL:Station was not previously registered on WLANTL_GetTxPktCount %d",
3999 ucSTAId));
4000 return VOS_STATUS_E_EXISTS;
4001 }
4002
4003 /*------------------------------------------------------------------------
4004 Return data
4005 ------------------------------------------------------------------------*/
4006 //VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_MED,
4007 // "WLAN TL:Requested tx packet count for STA: %d, TID: %d",
4008 // ucSTAId, ucTid);
4009
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304010 *puTxPktCount = pTLCb->atlSTAClients[ucSTAId]->auTxCount[ucTid];
Jeff Johnson295189b2012-06-20 16:38:30 -07004011
4012 return VOS_STATUS_SUCCESS;
4013}/* WLANTL_GetTxPktCount */
4014
4015/*==========================================================================
4016
4017 FUNCTION WLANTL_GetRxPktCount
4018
4019 DESCRIPTION
4020 TL will provide the number of received packets counted per
4021 STA per TID.
4022
4023 DEPENDENCIES
4024
4025 PARAMETERS
4026
4027 IN
4028 pvosGCtx: pointer to the global vos context; a handle to TL's
4029 control block can be extracted from its context
4030 ucSTAId: identifier of the station
4031 ucTid: identifier of the tspec
4032
4033 OUT
4034 puTxPktCount: the number of packets rx packet for this STA and TID
4035
4036 RETURN VALUE
4037 The result code associated with performing the operation
4038
4039 VOS_STATUS_E_INVAL: Input parameters are invalid
4040 VOS_STATUS_E_FAULT: Station ID is outside array boundaries or pointer
4041 to TL cb is NULL ; access would cause a page fault
4042 VOS_STATUS_E_EXISTS: Station was not registered
4043 VOS_STATUS_SUCCESS: Everything is good :)
4044
4045 SIDE EFFECTS
4046
4047============================================================================*/
4048VOS_STATUS
4049WLANTL_GetRxPktCount
4050(
4051 v_PVOID_t pvosGCtx,
4052 v_U8_t ucSTAId,
4053 v_U8_t ucTid,
4054 v_U32_t* puRxPktCount
4055)
4056{
4057 WLANTL_CbType* pTLCb = NULL;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304058 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004059 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
4060
4061 /*------------------------------------------------------------------------
4062 Sanity check
4063 ------------------------------------------------------------------------*/
4064 if ( NULL == puRxPktCount )
4065 {
4066 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
4067 "WLAN TL:Invalid parameter sent on WLANTL_GetRxPktCount"));
4068 return VOS_STATUS_E_INVAL;
4069 }
4070
4071 if ( WLANTL_STA_ID_INVALID( ucSTAId ) || WLANTL_TID_INVALID( ucTid) )
4072 {
4073 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
4074 "WLAN TL:Invalid station id %d/tid %d requested on WLANTL_GetRxPktCount",
4075 ucSTAId, ucTid));
4076 return VOS_STATUS_E_FAULT;
4077 }
4078
4079 /*------------------------------------------------------------------------
4080 Extract TL control block and existance
4081 ------------------------------------------------------------------------*/
4082 pTLCb = VOS_GET_TL_CB(pvosGCtx);
4083 if ( NULL == pTLCb )
4084 {
4085 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
4086 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_GetRxPktCount"));
4087 return VOS_STATUS_E_FAULT;
4088 }
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304089 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
Jeff Johnson295189b2012-06-20 16:38:30 -07004090
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304091 if ( NULL == pClientSTA )
4092 {
4093 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
4094 "WLAN TL:Client Memory was not allocated on %s", __func__));
4095 return VOS_STATUS_E_FAILURE;
4096 }
4097
4098 if ( 0 == pClientSTA->ucExists )
Jeff Johnson295189b2012-06-20 16:38:30 -07004099 {
4100 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
4101 "WLAN TL:Station was not previously registered on WLANTL_GetRxPktCount"));
4102 return VOS_STATUS_E_EXISTS;
4103 }
4104
4105 /*------------------------------------------------------------------------
4106 Return data
4107 ------------------------------------------------------------------------*/
4108 TLLOG3(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_MED,
4109 "WLAN TL:Requested rx packet count for STA: %d, TID: %d",
4110 ucSTAId, ucTid));
4111
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304112 *puRxPktCount = pClientSTA->auRxCount[ucTid];
Jeff Johnson295189b2012-06-20 16:38:30 -07004113
4114 return VOS_STATUS_SUCCESS;
4115}/* WLANTL_GetRxPktCount */
4116
Jeff Johnson295189b2012-06-20 16:38:30 -07004117VOS_STATUS
4118WLANTL_TxFCFrame
4119(
4120 v_PVOID_t pvosGCtx
4121);
Jeff Johnson295189b2012-06-20 16:38:30 -07004122/*============================================================================
4123 TL INTERNAL API DEFINITION
4124============================================================================*/
4125
4126/*==========================================================================
4127
4128 FUNCTION WLANTL_GetFrames
4129
4130 DESCRIPTION
4131
4132 BAL calls this function at the request of the lower bus interface.
4133 When this request is being received TL will retrieve packets from HDD
4134 in accordance with the priority rules and the count supplied by BAL.
4135
4136 DEPENDENCIES
4137
4138 HDD must have registered with TL at least one STA before this function
4139 can be called.
4140
4141 PARAMETERS
4142
4143 IN
4144 pvosGCtx: pointer to the global vos context; a handle to TL's
4145 or BAL's control block can be extracted from its context
4146 uSize: maximum size accepted by the lower layer
4147 uFlowMask TX flow control mask for Prima. Each bit is defined as
4148 WDA_TXFlowEnumType
4149
4150 OUT
4151 vosDataBuff: it will contain a pointer to the first buffer supplied
4152 by TL, if there is more than one packet supplied, TL
4153 will chain them through vOSS buffers
4154
4155 RETURN VALUE
4156
4157 The result code associated with performing the operation
4158
4159 1 or more: number of required resources if there are still frames to fetch
4160 0 : error or HDD queues are drained
4161
4162 SIDE EFFECTS
4163
4164 NOTE
4165
4166 Featurized uFlowMask. If we want to remove featurization, we need to change
4167 BAL on Volans.
4168
4169============================================================================*/
4170v_U32_t
4171WLANTL_GetFrames
4172(
4173 v_PVOID_t pvosGCtx,
4174 vos_pkt_t **ppFrameDataBuff,
4175 v_U32_t uSize,
Jeff Johnson295189b2012-06-20 16:38:30 -07004176 v_U8_t uFlowMask,
Jeff Johnson295189b2012-06-20 16:38:30 -07004177 v_BOOL_t* pbUrgent
4178)
4179{
4180 vos_pkt_t** pvosDataBuff = (vos_pkt_t**)ppFrameDataBuff;
4181 WLANTL_CbType* pTLCb = NULL;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304182 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004183 v_U32_t uRemaining = uSize;
4184 vos_pkt_t* vosRoot;
4185 vos_pkt_t* vosTempBuf;
4186 WLANTL_STAFuncType pfnSTAFsm;
4187 v_U16_t usPktLen;
4188 v_U32_t uResLen;
4189 v_U8_t ucSTAId;
4190 v_U8_t ucAC;
4191 vos_pkt_t* vosDataBuff;
4192 v_U32_t uTotalPktLen;
4193 v_U32_t i=0;
Tushnim Bhattacharyya39a8f182013-02-20 18:10:30 -08004194 v_U32_t j=0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004195 v_U32_t ucResult = 0;
4196 VOS_STATUS vosStatus;
4197 WLANTL_STAEventType wSTAEvent;
4198 tBssSystemRole systemRole;
4199 tpAniSirGlobal pMac;
4200 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
4201
4202 /*------------------------------------------------------------------------
4203 Sanity check
4204 Extract TL control block
4205 ------------------------------------------------------------------------*/
4206 pTLCb = VOS_GET_TL_CB(pvosGCtx);
4207 if (( NULL == pTLCb ) || ( NULL == pvosDataBuff ))
4208 {
4209 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
4210 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_ChangeSTAState"));
4211 return ucResult;
4212 }
4213
4214 pMac = vos_get_context(VOS_MODULE_ID_PE, pvosGCtx);
4215 if ( NULL == pMac )
4216 {
4217 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004218 "%s: Invalid pMac", __func__));
Jeff Johnson295189b2012-06-20 16:38:30 -07004219 return ucResult;
4220 }
4221
4222 vosDataBuff = pTLCb->vosDummyBuf; /* Just to avoid checking for NULL at
4223 each iteration */
4224
Jeff Johnson295189b2012-06-20 16:38:30 -07004225 pTLCb->uResCount = uSize;
Jeff Johnson295189b2012-06-20 16:38:30 -07004226
4227 /*-----------------------------------------------------------------------
4228 Save the root as we will walk this chain as we fill it
4229 -----------------------------------------------------------------------*/
4230 vosRoot = vosDataBuff;
4231
4232 /*-----------------------------------------------------------------------
4233 There is still data - until FSM function says otherwise
4234 -----------------------------------------------------------------------*/
4235 pTLCb->bUrgent = FALSE;
4236
Jeff Johnson295189b2012-06-20 16:38:30 -07004237 while (( pTLCb->tlConfigInfo.uMinFramesProcThres < pTLCb->uResCount ) &&
4238 ( 0 < uRemaining ))
Jeff Johnson295189b2012-06-20 16:38:30 -07004239 {
4240 systemRole = wdaGetGlobalSystemRole(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -07004241#ifdef WLAN_SOFTAP_FLOWCTRL_EN
4242/* FIXME: The code has been disabled since it is creating issues in power save */
4243 if (eSYSTEM_AP_ROLE == systemRole)
4244 {
4245 if (pTLCb->done_once == 0 && NULL == pTLCb->vosTxFCBuf)
4246 {
4247 WLANTL_TxFCFrame (pvosGCtx);
4248 pTLCb->done_once ++;
4249 }
4250 }
4251 if ( NULL != pTLCb->vosTxFCBuf )
4252 {
4253 //there is flow control packet waiting to be sent
4254 WDA_TLI_PROCESS_FRAME_LEN( pTLCb->vosTxFCBuf, usPktLen, uResLen, uTotalPktLen);
4255
4256 if ( ( pTLCb->uResCount > uResLen ) &&
Jeff Johnson9b5dc4d2013-02-22 21:28:47 -08004257 ( uRemaining > uTotalPktLen ) &&
4258 ( uFlowMask & ( 1 << WDA_TXFLOW_FC ) ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07004259 {
4260 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
4261 "WLAN TL:Chaining FC frame first on GetFrame"));
4262
4263 vos_pkt_chain_packet( vosDataBuff, pTLCb->vosTxFCBuf, 1 /*true*/ );
4264
Arun Kumar Khandavalli0af8d3c2014-02-07 18:05:11 +05304265 vos_atomic_set( (uintptr_t*)&pTLCb->vosTxFCBuf, (uintptr_t) NULL);
Jeff Johnson295189b2012-06-20 16:38:30 -07004266
4267 /*FC frames cannot be delayed*/
4268 pTLCb->bUrgent = TRUE;
4269
4270 /*Update remaining len from SSC */
4271 uRemaining -= (usPktLen + WDA_DXE_HEADER_SIZE);
4272
4273 /*Update resource count */
4274 pTLCb->uResCount -= uResLen;
4275 }
4276 else
4277 {
4278 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004279 "WLAN TL:send fc out of source %s", __func__));
Jeff Johnson295189b2012-06-20 16:38:30 -07004280 ucResult = ( pTLCb->uResCount > uResLen )?VOS_TRUE:VOS_FALSE;
4281 break; /* Out of resources or reached max len */
4282 }
4283 }
4284 else
4285#endif //WLAN_SOFTAP_FLOWCTRL_EN
Jeff Johnson295189b2012-06-20 16:38:30 -07004286
Jeff Johnson9b5dc4d2013-02-22 21:28:47 -08004287 if (( NULL != pTLCb->tlMgmtFrmClient.vosPendingDataBuff ) &&
4288 ( uFlowMask & ( 1 << WDA_TXFLOW_MGMT ) ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07004289 {
4290 WDA_TLI_PROCESS_FRAME_LEN( pTLCb->tlMgmtFrmClient.vosPendingDataBuff,
4291 usPktLen, uResLen, uTotalPktLen);
4292
Manjunathappa Prakashfb585462013-12-23 19:07:07 -08004293 if (usPktLen > WLANTL_MAX_ALLOWED_LEN)
4294 {
4295 usPktLen = WLANTL_MAX_ALLOWED_LEN;
4296 VOS_ASSERT(0);
4297 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004298
4299 if ( ( pTLCb->uResCount > uResLen ) &&
Jeff Johnson9b5dc4d2013-02-22 21:28:47 -08004300 ( uRemaining > uTotalPktLen ) &&
4301 ( uFlowMask & ( 1 << WDA_TXFLOW_MGMT ) ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07004302 {
4303 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
4304 "WLAN TL:Chaining management frame on GetFrame"));
4305
4306 vos_pkt_chain_packet( vosDataBuff,
4307 pTLCb->tlMgmtFrmClient.vosPendingDataBuff,
4308 1 /*true*/ );
4309
Arun Kumar Khandavalli0af8d3c2014-02-07 18:05:11 +05304310 vos_atomic_set( (uintptr_t*)&pTLCb->tlMgmtFrmClient.
4311 vosPendingDataBuff, (uintptr_t)NULL);
Jeff Johnson295189b2012-06-20 16:38:30 -07004312
4313 /*management frames cannot be delayed*/
4314 pTLCb->bUrgent = TRUE;
4315
4316 /*Update remaining len from SSC */
4317 uRemaining -= (usPktLen + WDA_DXE_HEADER_SIZE);
4318
4319 /*Update resource count */
4320 pTLCb->uResCount -= uResLen;
4321 }
4322 else
4323 {
4324 ucResult = ( pTLCb->uResCount > uResLen )?VOS_TRUE:VOS_FALSE;
4325 break; /* Out of resources or reached max len */
4326 }
4327 }
4328 else if (( pTLCb->tlBAPClient.vosPendingDataBuff ) &&
4329 ( WDA_TLI_MIN_RES_BAP <= pTLCb->uResCount ) &&
Gopichand Nakkala7e48ca72012-12-31 14:15:07 -08004330 ( 0 == pTLCb->ucTxSuspended ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07004331 {
4332 WDA_TLI_PROCESS_FRAME_LEN( pTLCb->tlBAPClient.vosPendingDataBuff,
4333 usPktLen, uResLen, uTotalPktLen);
4334
Manjunathappa Prakashfb585462013-12-23 19:07:07 -08004335 if (usPktLen > WLANTL_MAX_ALLOWED_LEN)
4336 {
4337 usPktLen = WLANTL_MAX_ALLOWED_LEN;
4338 VOS_ASSERT(0);
4339 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004340
4341 if ( ( pTLCb->uResCount > (uResLen + WDA_TLI_MIN_RES_MF ) ) &&
4342 ( uRemaining > uTotalPktLen ))
4343 {
4344 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
4345 "WLAN TL:Chaining BT-AMP frame on GetFrame"));
4346
4347 vos_pkt_chain_packet( vosDataBuff,
4348 pTLCb->tlBAPClient.vosPendingDataBuff,
4349 1 /*true*/ );
4350
4351 /*BAP frames cannot be delayed*/
4352 pTLCb->bUrgent = TRUE;
4353
Arun Kumar Khandavalli0af8d3c2014-02-07 18:05:11 +05304354 vos_atomic_set( (uintptr_t*)&pTLCb->tlBAPClient.vosPendingDataBuff,
4355 (uintptr_t) NULL);
Jeff Johnson295189b2012-06-20 16:38:30 -07004356
4357 /*Update remaining len from SSC */
4358 uRemaining -= (usPktLen + WDA_DXE_HEADER_SIZE);
4359
4360 /*Update resource count */
4361 pTLCb->uResCount -= uResLen;
4362 }
4363 else
4364 {
Jeff Johnson295189b2012-06-20 16:38:30 -07004365 ucResult = uResLen + WDA_TLI_MIN_RES_MF;
Jeff Johnson295189b2012-06-20 16:38:30 -07004366 break; /* Out of resources or reached max len */
4367 }
4368 }
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -07004369 /* note: this feature implemented only after WLAN_INGETRATED_SOC */
4370 /* search 'EAPOL_HI_PRIORITY' will show EAPOL HI_PRIORITY change in TL and WDI
4371 by default, EAPOL will be treated as higher priority, which means
4372 use mgmt_pool and DXE_TX_HI prority channel.
4373 this is introduced to address EAPOL failure under high background traffic
4374 with multi-channel concurrent mode. But this change works in SCC or standalone, too.
4375 see CR#387009 and WCNSOS-8
4376 */
4377 else if (( WDA_TLI_MIN_RES_MF <= pTLCb->uResCount )&&
4378 ( 0 == pTLCb->ucTxSuspended ) &&
4379 ( uFlowMask & ( 1 << WDA_TXFLOW_MGMT ) )
4380 )
4381 {
4382 vosTempBuf = NULL;
4383 /*---------------------------------------------------------------------
4384 Check to see if there was any EAPOL packet is pending
4385 *--------------------------------------------------------------------*/
4386 for ( i = 0; i < WLAN_MAX_STA_COUNT; i++)
4387 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304388 if ((NULL != pTLCb->atlSTAClients[i]) &&
4389 (pTLCb->atlSTAClients[i]->ucExists) &&
4390 (0 == pTLCb->atlSTAClients[i]->ucTxSuspended) &&
Tushnim Bhattacharyya39a8f182013-02-20 18:10:30 -08004391 (WLANTL_STA_CONNECTED == pTLCb->atlSTAClients[i]->tlState) &&
4392 (pTLCb->atlSTAClients[i]->ucPktPending)
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -07004393 )
4394 break;
4395 }
4396
4397 if (i >= WLAN_MAX_STA_COUNT)
4398 {
4399 /* No More to Serve Exit Get Frames */
4400 break;
4401 }
4402 /* Serve EAPOL frame with HI_FLOW_MASK */
4403 ucSTAId = i;
4404
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304405 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
4406
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05304407 MTRACE(vos_trace(VOS_MODULE_ID_TL,
4408 TRACE_CODE_TL_GET_FRAMES_EAPOL, ucSTAId, pClientSTA->tlState));
4409
4410 if (pClientSTA->wSTADesc.wSTAType == WLAN_STA_INFRA)
4411 {
4412 if(0 != pClientSTA->aucACMask[WLANTL_AC_HIGH_PRIO])
4413 {
4414 pClientSTA->ucCurrentAC = WLANTL_AC_HIGH_PRIO;
4415 pTLCb->uCurServedAC = WLANTL_AC_HIGH_PRIO;
4416 }
4417 else
4418 break;
4419 }
4420 else
4421 {
4422 for (j = WLANTL_MAX_AC ; j > 0; j--)
4423 {
4424 if (0 != pClientSTA->aucACMask[j-1])
4425 {
4426 pClientSTA->ucCurrentAC = j-1;
4427 pTLCb->uCurServedAC = j-1;
4428 break;
4429 }
4430 }
4431 }
4432
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -07004433 wSTAEvent = WLANTL_TX_EVENT;
4434
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304435 pfnSTAFsm = tlSTAFsm[pClientSTA->tlState].
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -07004436 pfnSTATbl[wSTAEvent];
4437
4438 if ( NULL != pfnSTAFsm )
4439 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304440 pClientSTA->ucNoMoreData = 0;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004441 vosStatus = pfnSTAFsm( pvosGCtx, ucSTAId, &vosTempBuf, VOS_FALSE);
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -07004442
4443 if (( VOS_STATUS_SUCCESS != vosStatus ) &&
4444 ( NULL != vosTempBuf ))
4445 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304446 pClientSTA->pfnSTATxComp( pvosGCtx, vosTempBuf, vosStatus );
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -07004447 vosTempBuf = NULL;
4448 break;
4449 }/* status success*/
4450 }
4451
4452 if (NULL != vosTempBuf)
4453 {
4454 WDA_TLI_PROCESS_FRAME_LEN( vosTempBuf, usPktLen, uResLen, uTotalPktLen);
4455
Manjunathappa Prakashfb585462013-12-23 19:07:07 -08004456 if (usPktLen > WLANTL_MAX_ALLOWED_LEN)
4457 {
4458 usPktLen = WLANTL_MAX_ALLOWED_LEN;
4459 VOS_ASSERT(0);
4460 }
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -07004461
4462 TLLOG4(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_LOW,
4463 "WLAN TL:Resources needed by frame: %d", uResLen));
4464
4465 if ( ( pTLCb->uResCount >= (uResLen + WDA_TLI_MIN_RES_MF ) ) &&
4466 ( uRemaining > uTotalPktLen )
4467 )
4468 {
4469 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
4470 "WLAN TL:Chaining data frame on GetFrame"));
4471
4472 vos_pkt_chain_packet( vosDataBuff, vosTempBuf, 1 /*true*/ );
4473
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -07004474 /*EAPOL frame cannot be delayed*/
4475 pTLCb->bUrgent = TRUE;
4476
4477 vosTempBuf = NULL;
4478
4479 /*Update remaining len from SSC */
4480 uRemaining -= (usPktLen + WDA_DXE_HEADER_SIZE);
4481
4482 /*Update resource count */
4483 pTLCb->uResCount -= uResLen;
4484
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -07004485 //fow control update
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304486 pClientSTA->uIngress_length += uResLen;
4487 pClientSTA->uBuffThresholdMax = (pClientSTA->uBuffThresholdMax >= uResLen) ?
4488 (pClientSTA->uBuffThresholdMax - uResLen) : 0;
Tushnim Bhattacharyya39a8f182013-02-20 18:10:30 -08004489 pClientSTA->ucEapolPktPending = 0;
4490 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
4491 "WLAN TL:GetFrames STA: %d EAPOLPktPending %d",
4492 ucSTAId, pClientSTA->ucEapolPktPending);
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -07004493 }
4494 }
4495 else
4496 { // no EAPOL frames exit Get frames
Tushnim Bhattacharyya39a8f182013-02-20 18:10:30 -08004497 TLLOG2(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
4498 "WLAN TL:GetFrames STA: %d, no EAPOL frame, continue.",
4499 ucSTAId));
4500 continue;
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -07004501 }
4502 }
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -07004503
Jeff Johnson9b5dc4d2013-02-22 21:28:47 -08004504 else if (( WDA_TLI_MIN_RES_DATA <= pTLCb->uResCount ) &&
4505 ( 0 == pTLCb->ucTxSuspended ) &&
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05304506 ( uFlowMask & WLANTL_DATA_FLOW_MASK))
Jeff Johnson295189b2012-06-20 16:38:30 -07004507 {
4508 /*---------------------------------------------------------------------
4509 Check to see if there was any packet left behind previously due to
4510 size constraints
4511 ---------------------------------------------------------------------*/
4512 vosTempBuf = NULL;
4513
4514 if ( NULL != pTLCb->vosTempBuf )
4515 {
4516 vosTempBuf = pTLCb->vosTempBuf;
4517 pTLCb->vosTempBuf = NULL;
4518 ucSTAId = pTLCb->ucCachedSTAId;
4519 ucAC = pTLCb->ucCachedAC;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304520
4521 if ( NULL == pTLCb->atlSTAClients[ucSTAId] )
4522 {
4523 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
4524 "WLAN TL:Client Memory was not allocated on %s", __func__));
Madan Mohan Koyylamudi64258222013-01-30 14:35:10 +05304525 continue;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304526 }
4527
4528 pTLCb->atlSTAClients[ucSTAId]->ucNoMoreData = 0;
Madan Mohan Koyylamudi64258222013-01-30 14:35:10 +05304529 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
Jeff Johnson295189b2012-06-20 16:38:30 -07004530
4531 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
4532 "WLAN TL:Chaining cached data frame on GetFrame"));
4533 }
4534 else
4535 {
4536 WLAN_TLGetNextTxIds( pvosGCtx, &ucSTAId);
4537 if (ucSTAId >= WLAN_MAX_STA_COUNT)
4538 {
4539 /* Packets start coming in even after insmod Without *
4540 starting Hostapd or Interface being up *
4541 During which cases STAID is invaled and hence
4542 the check. HalMsg_ScnaComplete Triggers */
4543
4544 break;
4545 }
4546 /* ucCurrentAC should have correct AC to be served by calling
4547 WLAN_TLGetNextTxIds */
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304548 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304549 if ( NULL == pClientSTA )
4550 {
4551 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
4552 "WLAN TL:Client Memory was not allocated on %s", __func__));
Madan Mohan Koyylamudi64258222013-01-30 14:35:10 +05304553 continue;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304554 }
4555
4556 ucAC = pClientSTA->ucCurrentAC;
4557
4558 pClientSTA->ucNoMoreData = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07004559 TLLOG4(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_LOW,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004560 "WLAN TL: %s get one data frame, station ID %d ", __func__, ucSTAId));
Jeff Johnson295189b2012-06-20 16:38:30 -07004561 /*-------------------------------------------------------------------
4562 Check to see that STA is valid and tx is not suspended
4563 -------------------------------------------------------------------*/
4564 if ( ( ! WLANTL_STA_ID_INVALID( ucSTAId ) ) &&
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304565 ( 0 == pClientSTA->ucTxSuspended ) &&
4566 ( 0 == pClientSTA->fcStaTxDisabled) )
Jeff Johnson295189b2012-06-20 16:38:30 -07004567 {
4568 TLLOG4(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_LOW,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004569 "WLAN TL: %s sta id valid and not suspended ",__func__));
Jeff Johnson295189b2012-06-20 16:38:30 -07004570 wSTAEvent = WLANTL_TX_EVENT;
4571
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304572 pfnSTAFsm = tlSTAFsm[pClientSTA->tlState].
Jeff Johnson295189b2012-06-20 16:38:30 -07004573 pfnSTATbl[wSTAEvent];
4574
4575 if ( NULL != pfnSTAFsm )
4576 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304577 pClientSTA->ucNoMoreData = 0;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004578 vosStatus = pfnSTAFsm( pvosGCtx, ucSTAId, &vosTempBuf, VOS_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07004579
4580 if (( VOS_STATUS_SUCCESS != vosStatus ) &&
4581 ( NULL != vosTempBuf ))
4582 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304583 pClientSTA->pfnSTATxComp( pvosGCtx,
Jeff Johnson295189b2012-06-20 16:38:30 -07004584 vosTempBuf,
4585 vosStatus );
4586 vosTempBuf = NULL;
4587 }/* status success*/
4588 }/*NULL function state*/
4589 }/* valid STA id and ! suspended*/
4590 else
4591 {
4592 if ( ! WLANTL_STA_ID_INVALID( ucSTAId ) )
4593 {
4594 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
4595 "WLAN TL:Not fetching frame because suspended for sta ID %d",
4596 ucSTAId));
4597 }
4598 }
4599 }/* data */
4600
4601 if ( NULL != vosTempBuf )
4602 {
4603 WDA_TLI_PROCESS_FRAME_LEN( vosTempBuf, usPktLen, uResLen, uTotalPktLen);
4604
Manjunathappa Prakashfb585462013-12-23 19:07:07 -08004605 if (usPktLen > WLANTL_MAX_ALLOWED_LEN)
4606 {
4607 usPktLen = WLANTL_MAX_ALLOWED_LEN;
4608 VOS_ASSERT(0);
4609 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004610
4611 TLLOG4(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_LOW,
4612 "WLAN TL:Resources needed by frame: %d", uResLen));
4613
4614 if ( ( pTLCb->uResCount >= (uResLen + WDA_TLI_MIN_RES_BAP ) ) &&
Jeff Johnson9b5dc4d2013-02-22 21:28:47 -08004615 ( uRemaining > uTotalPktLen ) &&
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05304616 ( uFlowMask & WLANTL_DATA_FLOW_MASK ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07004617 {
4618 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
4619 "WLAN TL:Chaining data frame on GetFrame"));
4620
4621 vos_pkt_chain_packet( vosDataBuff, vosTempBuf, 1 /*true*/ );
4622 vosTempBuf = NULL;
4623
4624 /*Update remaining len from SSC */
4625 uRemaining -= (usPktLen + WDA_DXE_HEADER_SIZE);
4626
4627 /*Update resource count */
4628 pTLCb->uResCount -= uResLen;
4629
Jeff Johnson295189b2012-06-20 16:38:30 -07004630 //fow control update
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304631 pClientSTA->uIngress_length += uResLen;
4632 pClientSTA->uBuffThresholdMax = (pClientSTA->uBuffThresholdMax >= uResLen) ?
4633 (pClientSTA->uBuffThresholdMax - uResLen) : 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004634
4635 }
4636 else
4637 {
4638 /* Store this for later tx - already fetched from HDD */
4639 pTLCb->vosTempBuf = vosTempBuf;
4640 pTLCb->ucCachedSTAId = ucSTAId;
4641 pTLCb->ucCachedAC = ucAC;
Jeff Johnson295189b2012-06-20 16:38:30 -07004642 ucResult = uResLen + WDA_TLI_MIN_RES_BAP;
4643 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
4644 "min %d res required by TL.", ucResult ));
Jeff Johnson295189b2012-06-20 16:38:30 -07004645 break; /* Out of resources or reached max len */
4646 }
4647 }
4648 else
4649 {
4650 for ( i = 0; i < WLAN_MAX_STA_COUNT; i++)
4651 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304652 if (NULL != pTLCb->atlSTAClients[i] && (pTLCb->atlSTAClients[i]->ucExists) &&
4653 (pTLCb->atlSTAClients[i]->ucPktPending))
Jeff Johnson295189b2012-06-20 16:38:30 -07004654 {
4655 /* There is station to be Served */
4656 break;
4657 }
4658 }
4659 if (i >= WLAN_MAX_STA_COUNT)
4660 {
4661 /* No More to Serve Exit Get Frames */
4662 break;
4663 }
4664 else
4665 {
4666 /* More to be Served */
4667 continue;
4668 }
4669 }
4670 }
4671 else
4672 {
4673 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
4674 "WLAN TL:Returning from GetFrame: resources = %d suspended = %d",
4675 pTLCb->uResCount, pTLCb->ucTxSuspended));
Jeff Johnson295189b2012-06-20 16:38:30 -07004676 /* TL is starving even when DXE is not in low resource condition
4677 Return min resource number required and Let DXE deceide what to do */
4678 if(( 0 == pTLCb->ucTxSuspended ) &&
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05304679 ( uFlowMask & WLANTL_DATA_FLOW_MASK ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07004680 {
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07004681 TLLOG1(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -07004682 "WLAN TL:Returning from GetFrame: resources = %d",
4683 pTLCb->uResCount));
4684 ucResult = WDA_TLI_MIN_RES_DATA;
4685 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004686 break; /*out of min data resources*/
4687 }
4688
4689 pTLCb->usPendingTxCompleteCount++;
4690 /* Move data buffer up one packet */
4691 vos_pkt_walk_packet_chain( vosDataBuff, &vosDataBuff, 0/*false*/ );
4692 }
4693
4694 /*----------------------------------------------------------------------
4695 Packet chain starts at root + 1
4696 ----------------------------------------------------------------------*/
4697 vos_pkt_walk_packet_chain( vosRoot, &vosDataBuff, 1/*true*/ );
4698
4699 *pvosDataBuff = vosDataBuff;
Manjunathappa Prakashfb585462013-12-23 19:07:07 -08004700 if (pbUrgent)
4701 {
4702 *pbUrgent = pTLCb->bUrgent;
4703 }
4704 else
4705 {
4706 VOS_ASSERT( pbUrgent );
4707 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004708 return ucResult;
4709}/* WLANTL_GetFrames */
4710
4711
4712/*==========================================================================
4713
4714 FUNCTION WLANTL_TxComp
4715
4716 DESCRIPTION
4717 It is being called by BAL upon asynchronous notification of the packet
4718 or packets being sent over the bus.
4719
4720 DEPENDENCIES
4721 Tx complete cannot be called without a previous transmit.
4722
4723 PARAMETERS
4724
4725 IN
4726 pvosGCtx: pointer to the global vos context; a handle to TL's
4727 or BAL's control block can be extracted from its context
4728 vosDataBuff: it will contain a pointer to the first buffer for which
4729 the BAL report is being made, if there is more then one
4730 packet they will be chained using vOSS buffers.
4731 wTxStatus: the status of the transmitted packet, see above chapter
4732 on HDD interaction for a list of possible values
4733
4734 RETURN VALUE
4735 The result code associated with performing the operation
4736
4737 VOS_STATUS_E_INVAL: Input parameters are invalid
4738 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
4739 page fault
4740 VOS_STATUS_E_EXISTS: Station was not registered
4741 VOS_STATUS_SUCCESS: Everything is good :)
4742
4743 SIDE EFFECTS
4744
4745============================================================================*/
4746VOS_STATUS
4747WLANTL_TxComp
4748(
4749 v_PVOID_t pvosGCtx,
4750 vos_pkt_t *pFrameDataBuff,
4751 VOS_STATUS wTxStatus
4752)
4753{
4754 vos_pkt_t* vosDataBuff = (vos_pkt_t*)pFrameDataBuff;
4755 WLANTL_CbType* pTLCb = NULL;
4756 WLANTL_TxCompCBType pfnTxComp = NULL;
4757 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07004758 vos_pkt_t* vosTempTx = NULL;
4759
4760 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
4761
4762 /*------------------------------------------------------------------------
4763 Sanity check
4764 ------------------------------------------------------------------------*/
4765 if ( NULL == vosDataBuff )
4766 {
4767 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
4768 "WLAN TL:Extraneous NULL data pointer on WLANTL_TxComp"));
4769 return VOS_STATUS_E_INVAL;
4770 }
4771
4772 /*------------------------------------------------------------------------
4773 Extract TL control block
4774 ------------------------------------------------------------------------*/
4775 pTLCb = VOS_GET_TL_CB(pvosGCtx);
4776 if ( NULL == pTLCb )
4777 {
4778 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
4779 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_TxComp"));
4780 return VOS_STATUS_E_FAULT;
4781 }
4782
4783 while ((0 < pTLCb->usPendingTxCompleteCount) &&
4784 ( VOS_STATUS_SUCCESS == vosStatus ) &&
4785 ( NULL != vosDataBuff))
4786 {
4787 vos_pkt_get_user_data_ptr( vosDataBuff, VOS_PKT_USER_DATA_ID_TL,
4788 (v_PVOID_t)&pfnTxComp);
4789
4790 /*it should never be NULL - default handler should be registered if none*/
4791 if ( NULL == pfnTxComp )
4792 {
4793 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
4794 "WLAN TL:NULL pointer to Tx Complete on WLANTL_TxComp"));
4795 VOS_ASSERT(0);
4796 return VOS_STATUS_E_FAULT;
4797 }
4798
4799 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05304800 "WLAN TL:Calling Tx complete for pkt %p in function %p",
Jeff Johnson295189b2012-06-20 16:38:30 -07004801 vosDataBuff, pfnTxComp));
4802
4803 vosTempTx = vosDataBuff;
4804 vosStatus = vos_pkt_walk_packet_chain( vosDataBuff,
4805 &vosDataBuff, 1/*true*/);
4806
4807 pfnTxComp( pvosGCtx, vosTempTx, wTxStatus );
4808
4809 pTLCb->usPendingTxCompleteCount--;
4810 }
4811
Jeff Johnson295189b2012-06-20 16:38:30 -07004812
4813 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
4814 "WLAN TL: current TL values are: resources = %d "
4815 "pTLCb->usPendingTxCompleteCount = %d",
4816 pTLCb->uResCount, pTLCb->usPendingTxCompleteCount));
4817
4818 return VOS_STATUS_SUCCESS;
4819}/* WLANTL_TxComp */
4820
4821/*==========================================================================
4822
4823 FUNCTION WLANTL_CacheSTAFrame
4824
4825 DESCRIPTION
4826 Internal utility function for for caching incoming data frames that do
4827 not have a registered station yet.
4828
4829 DEPENDENCIES
4830 TL must be initiailized before this function gets called.
4831 In order to benefit from thsi caching, the components must ensure that
4832 they will only register with TL at the moment when they are fully setup
4833 and ready to receive incoming data
4834
4835 PARAMETERS
4836
4837 IN
4838
4839 pTLCb: TL control block
4840 ucSTAId: station id
4841 vosTempBuff: the data packet
4842 uDPUSig: DPU signature of the incoming packet
4843 bBcast: true if packet had the MC/BC bit set
4844
4845 RETURN VALUE
4846 The result code associated with performing the operation
4847
4848 VOS_STATUS_E_FAULT: pointer to TL cb is NULL or STA Id invalid ; access
4849 would cause a page fault
4850 VOS_STATUS_SUCCESS: Everything is good :)
4851
4852 SIDE EFFECTS
4853
4854============================================================================*/
4855static VOS_STATUS
4856WLANTL_CacheSTAFrame
4857(
4858 WLANTL_CbType* pTLCb,
4859 v_U8_t ucSTAId,
4860 vos_pkt_t* vosTempBuff,
4861 v_U32_t uDPUSig,
4862 v_U8_t bBcast,
4863 v_U8_t ucFrmType
4864)
4865{
4866 v_U8_t ucUcastSig;
4867 v_U8_t ucBcastSig;
4868 v_BOOL_t bOldSTAPkt;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304869 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004870 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
4871
4872 /*-------------------------------------------------------------------------
4873 Sanity check
4874 -------------------------------------------------------------------------*/
4875 if (( NULL == pTLCb ) || ( NULL == vosTempBuff ) )
4876 {
4877 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05304878 "WLAN TL: Invalid input pointer on WLANTL_CacheSTAFrame TL %p"
4879 " Packet %p", pTLCb, vosTempBuff ));
Jeff Johnson295189b2012-06-20 16:38:30 -07004880 return VOS_STATUS_E_FAULT;
4881 }
4882
4883 if ( WLANTL_STA_ID_INVALID( ucSTAId ) )
4884 {
4885 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
4886 "WLAN TL:Invalid station id requested on WLANTL_CacheSTAFrame"));
4887 return VOS_STATUS_E_FAULT;
4888 }
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304889 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
4890
4891 if ( NULL == pClientSTA )
4892 {
4893 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
4894 "WLAN TL:Client Memory was not allocated on %s", __func__));
4895 return VOS_STATUS_E_FAILURE;
4896 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004897
4898 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
4899 "WLAN TL:Attempting to cache pkt for STA %d, BD DPU Sig: %d with sig UC: %d, BC: %d",
4900 ucSTAId, uDPUSig,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304901 pClientSTA->wSTADesc.ucUcastSig,
4902 pClientSTA->wSTADesc.ucBcastSig));
Jeff Johnson295189b2012-06-20 16:38:30 -07004903
4904 if(WLANTL_IS_CTRL_FRAME(ucFrmType))
4905 {
4906 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
4907 "WLAN TL: No need to cache CTRL frame. Dropping"));
4908 vos_pkt_return_packet(vosTempBuff);
4909 return VOS_STATUS_SUCCESS;
4910 }
4911
4912 /*-------------------------------------------------------------------------
4913 Check if the packet that we are trying to cache belongs to the old
4914 registered station (if any) or the new (potentially)upcoming station
4915
4916 - If the STA with this Id was never registered with TL - the signature
4917 will be invalid;
4918 - If the STA was previously registered TL will have cached the former
4919 set of DPU signatures
4920 -------------------------------------------------------------------------*/
4921 if ( bBcast )
4922 {
4923 ucBcastSig = (v_U8_t)uDPUSig;
4924 bOldSTAPkt = (( WLAN_TL_INVALID_B_SIG !=
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304925 pClientSTA->wSTADesc.ucBcastSig ) &&
4926 ( ucBcastSig == pClientSTA->wSTADesc.ucBcastSig ));
Jeff Johnson295189b2012-06-20 16:38:30 -07004927 }
4928 else
4929 {
4930 ucUcastSig = (v_U8_t)uDPUSig;
4931 bOldSTAPkt = (( WLAN_TL_INVALID_U_SIG !=
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304932 pClientSTA->wSTADesc.ucUcastSig ) &&
4933 ( ucUcastSig == pClientSTA->wSTADesc.ucUcastSig ));
Jeff Johnson295189b2012-06-20 16:38:30 -07004934 }
4935
4936 /*------------------------------------------------------------------------
4937 If the value of the DPU SIG matches the old, this packet will not
4938 be cached as it belonged to the former association
4939 In case the SIG does not match - this is a packet for a potentially new
4940 associated station
4941 -------------------------------------------------------------------------*/
Varun Reddy Yeturua39b9902013-01-18 15:48:32 -08004942 if ( bOldSTAPkt || bBcast )
Jeff Johnson295189b2012-06-20 16:38:30 -07004943 {
4944 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
4945 "WLAN TL:Data packet matches old sig for sig DPU: %d UC: %d, "
4946 "BC: %d - dropping",
4947 uDPUSig,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304948 pClientSTA->wSTADesc.ucUcastSig,
4949 pClientSTA->wSTADesc.ucBcastSig));
Jeff Johnson295189b2012-06-20 16:38:30 -07004950 vos_pkt_return_packet(vosTempBuff);
4951 }
4952 else
4953 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304954 if ( NULL == pClientSTA->vosBegCachedFrame )
Jeff Johnson295189b2012-06-20 16:38:30 -07004955 {
4956 /*this is the first frame that we are caching */
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304957 pClientSTA->vosBegCachedFrame = vosTempBuff;
Mihir Sheteb7337272014-04-11 15:53:08 +05304958
4959 pClientSTA->tlCacheInfo.cacheInitTime = vos_timer_get_system_time();
4960 pClientSTA->tlCacheInfo.cacheDoneTime =
4961 pClientSTA->tlCacheInfo.cacheInitTime;
4962 pClientSTA->tlCacheInfo.cacheSize = 1;
4963
Mihir Sheteae6f02b2014-04-11 19:49:21 +05304964 MTRACE(vos_trace(VOS_MODULE_ID_TL, TRACE_CODE_TL_CACHE_FRAME,
4965 ucSTAId, pClientSTA->tlCacheInfo.cacheSize));
4966
Jeff Johnson295189b2012-06-20 16:38:30 -07004967 }
4968 else
4969 {
4970 /*this is a subsequent frame that we are caching: chain to the end */
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304971 vos_pkt_chain_packet(pClientSTA->vosEndCachedFrame,
Jeff Johnson295189b2012-06-20 16:38:30 -07004972 vosTempBuff, VOS_TRUE);
Mihir Sheteb7337272014-04-11 15:53:08 +05304973
4974 pClientSTA->tlCacheInfo.cacheDoneTime = vos_timer_get_system_time();
4975 pClientSTA->tlCacheInfo.cacheSize ++;
4976
4977 if (pClientSTA->tlCacheInfo.cacheSize % WLANTL_CACHE_TRACE_WATERMARK == 0)
4978 {
4979 VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
4980 "%s: Cache High watermark for staid:%d (%d)",
4981 __func__,ucSTAId, pClientSTA->tlCacheInfo.cacheSize);
Mihir Sheteae6f02b2014-04-11 19:49:21 +05304982 MTRACE(vos_trace(VOS_MODULE_ID_TL, TRACE_CODE_TL_CACHE_FRAME,
4983 ucSTAId, pClientSTA->tlCacheInfo.cacheSize));
Mihir Sheteb7337272014-04-11 15:53:08 +05304984 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004985 }
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304986 pClientSTA->vosEndCachedFrame = vosTempBuff;
Jeff Johnson295189b2012-06-20 16:38:30 -07004987 }/*else new packet*/
4988
4989 return VOS_STATUS_SUCCESS;
4990}/*WLANTL_CacheSTAFrame*/
4991
4992/*==========================================================================
4993
4994 FUNCTION WLANTL_FlushCachedFrames
4995
4996 DESCRIPTION
4997 Internal utility function used by TL to flush the station cache
4998
4999 DEPENDENCIES
5000 TL must be initiailized before this function gets called.
5001
5002 PARAMETERS
5003
5004 IN
5005
5006 vosDataBuff: it will contain a pointer to the first cached buffer
5007 received,
5008
5009 RETURN VALUE
5010 The result code associated with performing the operation
5011
5012 VOS_STATUS_SUCCESS: Everything is good :)
5013
5014 SIDE EFFECTS
5015
5016 NOTE
5017 This function doesn't re-initialize vosDataBuff to NULL. It's caller's
5018 responsibility to do so, if required, after this function call.
5019 Because of this restriction, we decide to make this function to static
5020 so that upper layer doesn't need to be aware of this restriction.
5021
5022============================================================================*/
5023static VOS_STATUS
5024WLANTL_FlushCachedFrames
5025(
5026 vos_pkt_t* vosDataBuff
5027)
5028{
5029 /*----------------------------------------------------------------------
5030 Return the entire chain to vos if there are indeed cache frames
5031 ----------------------------------------------------------------------*/
5032 if ( NULL != vosDataBuff )
5033 {
5034 vos_pkt_return_packet(vosDataBuff);
5035 }
5036
5037 return VOS_STATUS_SUCCESS;
5038}/*WLANTL_FlushCachedFrames*/
5039
5040/*==========================================================================
5041
5042 FUNCTION WLANTL_ForwardSTAFrames
5043
5044 DESCRIPTION
5045 Internal utility function for either forwarding cached data to the station after
5046 the station has been registered, or flushing cached data if the station has not
5047 been registered.
5048
5049
5050 DEPENDENCIES
5051 TL must be initiailized before this function gets called.
5052
5053 PARAMETERS
5054
5055 IN
5056
5057 pTLCb: TL control block
5058 ucSTAId: station id
5059
5060 RETURN VALUE
5061 The result code associated with performing the operation
5062
5063 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
5064 page fault
5065 VOS_STATUS_SUCCESS: Everything is good :)
5066
5067 SIDE EFFECTS
5068 This function doesn't re-initialize vosDataBuff to NULL. It's caller's
5069 responsibility to do so, if required, after this function call.
5070 Because of this restriction, we decide to make this function to static
5071 so that upper layer doesn't need to be aware of this restriction.
5072
5073============================================================================*/
5074static VOS_STATUS
5075WLANTL_ForwardSTAFrames
5076(
5077 void* pvosGCtx,
5078 v_U8_t ucSTAId,
5079 v_U8_t ucUcastSig,
5080 v_U8_t ucBcastSig
5081)
5082{
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05305083 WLANTL_CbType* pTLCb = NULL;
5084 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005085 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
5086
5087 /*-------------------------------------------------------------------------
5088 Sanity check
5089 -------------------------------------------------------------------------*/
5090 pTLCb = VOS_GET_TL_CB(pvosGCtx);
5091 if ( NULL == pTLCb )
5092 {
5093 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05305094 "WLAN TL: Invalid input pointer on WLANTL_ForwardSTAFrames TL %p",
Jeff Johnson295189b2012-06-20 16:38:30 -07005095 pTLCb ));
5096 return VOS_STATUS_E_FAULT;
5097 }
5098
5099 if ( WLANTL_STA_ID_INVALID( ucSTAId ) )
5100 {
5101 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
5102 "WLAN TL:Invalid station id requested on WLANTL_ForwardSTAFrames"));
5103 return VOS_STATUS_E_FAULT;
5104 }
5105
5106 //WLAN_TL_LOCK_STA_CACHE(pTLCb->atlSTAClients[ucSTAId]);
5107
5108 /*------------------------------------------------------------------------
5109 Check if station has not been registered in the mean while
5110 if not registered, flush cached frames.
5111 ------------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05305112 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
5113
5114 if ( NULL == pClientSTA )
5115 {
5116 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
5117 "WLAN TL:Client Memory was not allocated on %s", __func__));
5118 return VOS_STATUS_E_FAILURE;
5119 }
5120
5121 if ( 0 == pClientSTA->ucExists )
Jeff Johnson295189b2012-06-20 16:38:30 -07005122 {
5123 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
5124 "WLAN TL:Station has been deleted for STA %d - flushing cache", ucSTAId));
Mihir Sheteae6f02b2014-04-11 19:49:21 +05305125 MTRACE(vos_trace(VOS_MODULE_ID_TL, TRACE_CODE_TL_FLUSH_CACHED_FRAMES,
5126 ucSTAId, pClientSTA->tlCacheInfo.cacheSize));
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05305127 WLANTL_FlushCachedFrames(pClientSTA->vosBegCachedFrame);
Jeff Johnson295189b2012-06-20 16:38:30 -07005128 goto done;
5129 }
5130
5131 /*------------------------------------------------------------------------
5132 Forwarding cache frames received while the station was in the process
5133 of being registered with the rest of the SW components
5134
5135 Access to the cache must be locked; similarly updating the signature and
5136 the existence flag must be synchronized because these values are checked
5137 during cached
5138 ------------------------------------------------------------------------*/
5139 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
5140 "WLAN TL:Preparing to fwd packets for STA %d", ucSTAId));
5141
5142 /*-----------------------------------------------------------------------
5143 Save the new signature values
5144 ------------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05305145 pClientSTA->wSTADesc.ucUcastSig = ucUcastSig;
5146 pClientSTA->wSTADesc.ucBcastSig = ucBcastSig;
Jeff Johnson295189b2012-06-20 16:38:30 -07005147
5148 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
5149 "WLAN TL:Fwd-ing packets for STA %d UC %d BC %d",
5150 ucSTAId, ucUcastSig, ucBcastSig));
5151
5152 /*-------------------------------------------------------------------------
5153 Check to see if we have any cached data to forward
5154 -------------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05305155 if ( NULL != pClientSTA->vosBegCachedFrame )
Jeff Johnson295189b2012-06-20 16:38:30 -07005156 {
5157 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
5158 "WLAN TL: Fwd-ing Cached packets for station %d", ucSTAId ));
5159
5160 WLANTL_RxCachedFrames( pTLCb,
5161 ucSTAId,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05305162 pClientSTA->vosBegCachedFrame);
Jeff Johnson295189b2012-06-20 16:38:30 -07005163 }
5164 else
5165 {
5166 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
5167 "WLAN TL: NO cached packets for station %d", ucSTAId ));
5168 }
5169
5170done:
5171 /*-------------------------------------------------------------------------
5172 Clear the station cache
5173 -------------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05305174 pClientSTA->vosBegCachedFrame = NULL;
5175 pClientSTA->vosEndCachedFrame = NULL;
Mihir Sheteb7337272014-04-11 15:53:08 +05305176 pClientSTA->tlCacheInfo.cacheSize = 0;
5177 pClientSTA->tlCacheInfo.cacheClearTime = vos_timer_get_system_time();
Jeff Johnson295189b2012-06-20 16:38:30 -07005178
5179 /*-----------------------------------------------------------------------
5180 After all the init is complete we can mark the existance flag
5181 ----------------------------------------------------------------------*/
Katya Nigam63902932014-06-26 19:04:23 +05305182 pClientSTA->enableCaching = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005183
5184 //WLAN_TL_UNLOCK_STA_CACHE(pTLCb->atlSTAClients[ucSTAId]);
5185 return VOS_STATUS_SUCCESS;
5186
5187}/*WLANTL_ForwardSTAFrames*/
5188
5189
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005190#if defined(FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_ESE_UPLOAD)
Jeff Johnson295189b2012-06-20 16:38:30 -07005191/*==========================================================================
5192
5193 FUNCTION WLANTL_IsIAPPFrame
5194
5195 DESCRIPTION
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005196 Internal utility function for detecting incoming ESE IAPP frames
Jeff Johnson295189b2012-06-20 16:38:30 -07005197
5198 DEPENDENCIES
5199
5200 PARAMETERS
5201
5202 IN
5203
5204 pvBDHeader: pointer to the BD header
5205 vosTempBuff: the data packet
5206
5207 IN/OUT
5208 pFirstDataPktArrived: static from caller function; used for rssi
5209 computation
5210 RETURN VALUE
5211 The result code associated with performing the operation
5212
5213 VOS_TRUE: It is a IAPP frame
5214 VOS_FALSE: It is NOT IAPP frame
5215
5216 SIDE EFFECTS
5217
5218============================================================================*/
5219v_BOOL_t
5220WLANTL_IsIAPPFrame
5221(
5222 v_PVOID_t pvBDHeader,
5223 vos_pkt_t* vosTempBuff
5224)
5225{
5226 v_U16_t usMPDUDOffset;
5227 v_U8_t ucOffset;
5228 v_U8_t ucSnapHdr[WLANTL_LLC_SNAP_SIZE];
5229 v_SIZE_t usSnapHdrSize = WLANTL_LLC_SNAP_SIZE;
5230 VOS_STATUS vosStatus;
5231
5232 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
5233
5234 /*------------------------------------------------------------------------
5235 Check if OUI field is present.
5236 -------------------------------------------------------------------------*/
5237 if ( VOS_FALSE == WDA_IS_RX_LLC_PRESENT(pvBDHeader) )
5238 {
5239 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
5240 "WLAN TL:LLC header removed, cannot determine BT-AMP type -"
5241 "dropping pkt"));
5242 /* Drop packet */
5243 vos_pkt_return_packet(vosTempBuff);
5244 return VOS_TRUE;
5245 }
5246 usMPDUDOffset = (v_U8_t)WDA_GET_RX_MPDU_DATA_OFFSET(pvBDHeader);
5247 ucOffset = (v_U8_t)usMPDUDOffset + WLANTL_LLC_SNAP_OFFSET;
5248
5249 vosStatus = vos_pkt_extract_data( vosTempBuff, ucOffset,
5250 (v_PVOID_t)ucSnapHdr, &usSnapHdrSize);
5251
5252 if (( VOS_STATUS_SUCCESS != vosStatus))
5253 {
5254 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
5255 "Unable to extract Snap Hdr of data packet -"
5256 "dropping pkt"));
5257 return VOS_FALSE;
5258 }
5259
5260 /*------------------------------------------------------------------------
5261 Check if this is IAPP frame by matching Aironet Snap hdr.
5262 -------------------------------------------------------------------------*/
5263 // Compare returns 1 if values are same and 0
5264 // if not the same.
5265 if (( WLANTL_LLC_SNAP_SIZE != usSnapHdrSize ) ||
5266 ( 0 == vos_mem_compare(ucSnapHdr, (v_PVOID_t)WLANTL_AIRONET_SNAP_HEADER,
5267 WLANTL_LLC_SNAP_SIZE ) ))
5268 {
5269 return VOS_FALSE;
5270 }
5271
5272 return VOS_TRUE;
5273
5274}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005275#endif //FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07005276
5277/*==========================================================================
5278
5279 FUNCTION WLANTL_ProcessBAPFrame
5280
5281 DESCRIPTION
5282 Internal utility function for processing incoming BT-AMP frames
5283
5284 DEPENDENCIES
5285 TL must be initiailized before this function gets called.
5286 Bothe the BT-AMP station and the BAP Ctrl path must have been previously
5287 registered with TL.
5288
5289 PARAMETERS
5290
5291 IN
5292
5293 pvBDHeader: pointer to the BD header
5294 vosTempBuff: the data packet
5295 pTLCb: TL control block
5296 ucSTAId: station id
5297
5298 IN/OUT
5299 pFirstDataPktArrived: static from caller function; used for rssi
5300 computation
5301 RETURN VALUE
5302 The result code associated with performing the operation
5303
5304 VOS_STATUS_E_INVAL: Input parameters are invalid
5305 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
5306 page fault
5307 VOS_STATUS_SUCCESS: Everything is good :)
5308
5309 SIDE EFFECTS
5310
5311============================================================================*/
5312v_BOOL_t
5313WLANTL_ProcessBAPFrame
5314(
5315 v_PVOID_t pvBDHeader,
5316 vos_pkt_t* vosTempBuff,
5317 WLANTL_CbType* pTLCb,
5318 v_U8_t* pFirstDataPktArrived,
5319 v_U8_t ucSTAId
5320)
5321{
5322 v_U16_t usMPDUDOffset;
5323 v_U8_t ucOffset;
5324 v_U8_t ucOUI[WLANTL_LLC_OUI_SIZE];
5325 v_SIZE_t usOUISize = WLANTL_LLC_OUI_SIZE;
5326 VOS_STATUS vosStatus;
5327 v_U16_t usType;
5328 v_SIZE_t usTypeLen = sizeof(usType);
5329 v_U8_t ucMPDUHOffset;
5330 v_U8_t ucMPDUHLen = 0;
5331 v_U16_t usActualHLen = 0;
5332
5333 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
5334
5335 /*------------------------------------------------------------------------
5336 Extract OUI and type from LLC and validate; if non-data send to BAP
5337 -------------------------------------------------------------------------*/
5338 if ( VOS_FALSE == WDA_IS_RX_LLC_PRESENT(pvBDHeader) )
5339 {
5340 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
5341 "WLAN TL:LLC header removed, cannot determine BT-AMP type -"
5342 "dropping pkt"));
5343 /* Drop packet */
5344 vos_pkt_return_packet(vosTempBuff);
5345 return VOS_TRUE;
5346 }
5347
5348 usMPDUDOffset = (v_U8_t)WDA_GET_RX_MPDU_DATA_OFFSET(pvBDHeader);
5349 ucMPDUHOffset = (v_U8_t)WDA_GET_RX_MPDU_HEADER_OFFSET(pvBDHeader);
5350 ucMPDUHLen = (v_U8_t)WDA_GET_RX_MPDU_HEADER_LEN(pvBDHeader);
5351 ucOffset = (v_U8_t)usMPDUDOffset + WLANTL_LLC_OUI_OFFSET;
5352
5353 vosStatus = vos_pkt_extract_data( vosTempBuff, ucOffset,
5354 (v_PVOID_t)ucOUI, &usOUISize);
5355
5356#if 0
5357 // Compare returns 1 if values are same and 0
5358 // if not the same.
5359 if (( WLANTL_LLC_OUI_SIZE != usOUISize ) ||
5360 ( 0 == vos_mem_compare(ucOUI, (v_PVOID_t)WLANTL_BT_AMP_OUI,
5361 WLANTL_LLC_OUI_SIZE ) ))
5362 {
5363 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
5364 "LLC header points to diff OUI in BT-AMP station -"
5365 "dropping pkt"));
5366 /* Drop packet */
5367 vos_pkt_return_packet(vosTempBuff);
5368 return VOS_TRUE;
5369 }
5370#endif
5371 /*------------------------------------------------------------------------
5372 Extract LLC OUI and ensure that this is indeed a BT-AMP frame
5373 ------------------------------------------------------------------------*/
5374 vosStatus = vos_pkt_extract_data( vosTempBuff,
5375 ucOffset + WLANTL_LLC_OUI_SIZE,
5376 (v_PVOID_t)&usType, &usTypeLen);
5377
5378 if (( VOS_STATUS_SUCCESS != vosStatus) ||
5379 ( sizeof(usType) != usTypeLen ))
5380 {
5381 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
5382 "Unable to extract type on incoming BAP packet -"
5383 "dropping pkt"));
5384 /* Drop packet */
5385 vos_pkt_return_packet(vosTempBuff);
5386 return VOS_TRUE;
5387 }
5388
5389 /*------------------------------------------------------------------------
5390 Check if this is BT-AMP data or ctrl packet(RSN, LinkSvision, ActivityR)
5391 ------------------------------------------------------------------------*/
5392 usType = vos_be16_to_cpu(usType);
5393
5394 if (WLANTL_BAP_IS_NON_DATA_PKT_TYPE(usType))
5395 {
5396 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
5397 "WLAN TL:Non-data packet received over BT-AMP link: %d, => BAP",
5398 usType));
5399
5400 /*Flatten packet as BAP expects to be able to peek*/
5401 if ( VOS_STATUS_SUCCESS != vos_pkt_flatten_rx_pkt(&vosTempBuff))
5402 {
5403 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
5404 "WLAN TL:Cannot flatten BT-AMP packet - dropping"));
5405 /* Drop packet */
5406 vos_pkt_return_packet(vosTempBuff);
5407 return VOS_TRUE;
5408 }
5409
5410 /* Send packet to BAP client*/
Jeff Johnson295189b2012-06-20 16:38:30 -07005411 if ( VOS_STATUS_SUCCESS != WDA_DS_TrimRxPacketInfo( vosTempBuff ) )
5412 {
5413 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
5414 "WLAN TL:BD header corrupted - dropping packet"));
5415 /* Drop packet */
5416 vos_pkt_return_packet(vosTempBuff);
5417 return VOS_TRUE;
5418 }
5419
5420 if ( 0 == WDA_GET_RX_FT_DONE(pvBDHeader) )
5421 {
5422 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
5423 "Non-data packet received over BT-AMP link: Sending it for "
5424 "frame Translation"));
5425
5426 if (usMPDUDOffset > ucMPDUHOffset)
5427 {
5428 usActualHLen = usMPDUDOffset - ucMPDUHOffset;
5429 }
5430
5431 /* software frame translation for BTAMP WDS.*/
5432 WLANTL_Translate80211To8023Header( vosTempBuff, &vosStatus, usActualHLen,
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005433 ucMPDUHLen, pTLCb,ucSTAId, VOS_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07005434
5435 }
5436 if (pTLCb->tlBAPClient.pfnTlBAPRx)
5437 pTLCb->tlBAPClient.pfnTlBAPRx( vos_get_global_context(VOS_MODULE_ID_TL,pTLCb),
5438 vosTempBuff,
5439 (WLANTL_BAPFrameEnumType)usType );
Manjunathappa Prakashfb585462013-12-23 19:07:07 -08005440 else
5441 {
5442 VOS_ASSERT(0);
5443 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005444
5445 return VOS_TRUE;
5446 }
5447 else
5448 {
5449 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
5450 "WLAN TL: BAP DATA packet received over BT-AMP link: %d, => BAP",
5451 usType));
5452 /*!!!FIX ME!!*/
5453 #if 0
5454 /*--------------------------------------------------------------------
5455 For data packet collect phy stats RSSI and Link Quality
5456 Calculate the RSSI average and save it. Continuous average is done.
5457 --------------------------------------------------------------------*/
5458 if ( *pFirstDataPktArrived == 0)
5459 {
5460 pTLCb->atlSTAClients[ucSTAId].rssiAvg =
5461 WLANHAL_GET_RSSI_AVERAGE( pvBDHeader );
5462 pTLCb->atlSTAClients[ucSTAId].uLinkQualityAvg =
5463 WLANHAL_RX_BD_GET_SNR( pvBDHeader );
5464
5465 // Rcvd 1st pkt, start average from next time
5466 *pFirstDataPktArrived = 1;
5467 }
5468 else
5469 {
5470 pTLCb->atlSTAClients[ucSTAId].rssiAvg =
5471 (WLANHAL_GET_RSSI_AVERAGE( pvBDHeader ) +
5472 pTLCb->atlSTAClients[ucSTAId].rssiAvg)/2;
5473 pTLCb->atlSTAClients[ucSTAId].uLinkQualityAvg =
5474 (WLANHAL_RX_BD_GET_SNR( pvBDHeader ) +
5475 pTLCb->atlSTAClients[ucSTAId].uLinkQualityAvg)/2;
5476 }/*Else, first data packet*/
5477 #endif
5478 }/*BT-AMP data packet*/
5479
5480 return VOS_FALSE;
5481}/*WLANTL_ProcessBAPFrame*/
5482
Jeff Johnson295189b2012-06-20 16:38:30 -07005483
5484/*==========================================================================
5485
5486 FUNCTION WLANTL_ProcessFCFrame
5487
5488 DESCRIPTION
5489 Internal utility function for processing incoming Flow Control frames. Enable
5490 or disable LWM mode based on the information.
5491
5492 DEPENDENCIES
5493 TL must be initiailized before this function gets called.
5494 FW sends up special flow control frame.
5495
5496 PARAMETERS
5497
5498 IN
5499 pvosGCtx pointer to vos global context
5500 pvBDHeader: pointer to the BD header
5501 pTLCb: TL control block
5502 pvBDHeader pointer to BD header.
5503
5504 IN/OUT
5505 pFirstDataPktArrived: static from caller function; used for rssi
5506 computation
5507 RETURN VALUE
5508 The result code associated with performing the operation
5509
5510 VOS_STATUS_E_INVAL: Input frame are invalid
5511 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
5512 page fault
5513 VOS_STATUS_SUCCESS: Everything is good :)
5514
5515 SIDE EFFECTS
5516 The ingress and egress of each station will be updated. If needed, LWM mode will
5517 be enabled or disabled based on the flow control algorithm.
5518
5519============================================================================*/
5520v_BOOL_t
5521WLANTL_ProcessFCFrame
5522(
5523 v_PVOID_t pvosGCtx,
5524 vos_pkt_t* pvosDataBuff,
5525 v_PVOID_t pvBDHeader
5526)
5527{
5528#if 1 //enable processing of only fcStaTxDisabled bitmap for now. the else part is old better qos code.
5529 // need to revisit the old code for full implementation.
Hoonki Lee14621352013-04-16 17:51:19 -07005530 v_U8_t ucSTAId;
5531 v_U16_t ucStaValidBitmap;
5532 v_U16_t ucStaTxDisabledBitmap;
5533 WLANTL_CbType* pTLCb = NULL;
5534 #ifdef TL_DEBUG_FC
5535 v_U32_t rxTimeStamp;
5536 v_U32_t curTick;
5537 #endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005538 /*------------------------------------------------------------------------
Hoonki Lee14621352013-04-16 17:51:19 -07005539 Extract TL control block
Jeff Johnson295189b2012-06-20 16:38:30 -07005540 ------------------------------------------------------------------------*/
5541 pTLCb = VOS_GET_TL_CB(pvosGCtx);
5542 if ( NULL == pTLCb )
5543 {
5544 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
5545 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_SuspendDataTx"));
5546 return VOS_STATUS_E_FAULT;
5547 }
Hoonki Lee14621352013-04-16 17:51:19 -07005548 ucStaValidBitmap = WDA_GET_RX_FC_VALID_STA_MASK(pvBDHeader);
5549 ucStaTxDisabledBitmap = WDA_GET_RX_FC_STA_TX_DISABLED_BITMAP(pvBDHeader);
5550#ifdef TL_DEBUG_FC
5551 rxTimeStamp = WDA_GET_RX_TIMESTAMP(pvBDHeader);
5552 /* hard code of MTU_GLOBAL_TIMER_ADDR to calculate the time between generated and processed */
5553 wpalReadRegister(0x03081400+0x1D4, &curTick);
Jeff Johnson295189b2012-06-20 16:38:30 -07005554
Jeff Johnson295189b2012-06-20 16:38:30 -07005555 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Arif Hussainf2b00992013-11-17 21:46:15 -08005556 "%ld (%ld-%ld): Disabled %x Valid %x", curTick > rxTimeStamp ? curTick - rxTimeStamp : rxTimeStamp - (0xFFFFFFFF - curTick),
Hoonki Lee14621352013-04-16 17:51:19 -07005557 curTick, rxTimeStamp, ucStaTxDisabledBitmap, ucStaValidBitmap));
5558#endif
5559 for(ucSTAId = 0; ucStaValidBitmap != 0; ucStaValidBitmap >>=1, ucStaTxDisabledBitmap >>= 1, ucSTAId ++)
Jeff Johnson295189b2012-06-20 16:38:30 -07005560 {
Hoonki Lee14621352013-04-16 17:51:19 -07005561 if ( (0 == (ucStaValidBitmap & 0x1)) || (pTLCb->atlSTAClients[ucSTAId] && (0 == pTLCb->atlSTAClients[ucSTAId]->ucExists)) )
5562 continue;
5563
5564 if (ucStaTxDisabledBitmap & 0x1)
5565 {
5566 WLANTL_SuspendDataTx(pvosGCtx, &ucSTAId, NULL);
5567 }
5568 else
5569 {
5570 WLANTL_ResumeDataTx(pvosGCtx, &ucSTAId);
5571 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005572 }
5573
5574#else
5575 VOS_STATUS vosStatus;
5576 tpHalFcRxBd pvFcRxBd = NULL;
5577 v_U8_t ucBitCheck = 0x1;
5578 v_U8_t ucStaValid = 0;
5579 v_U8_t ucSTAId = 0;
5580
5581 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
5582 "Received FC Response");
5583 if ( (NULL == pTLCb) || (NULL == pvosDataBuff))
5584 {
5585 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Arif Hussainf2b00992013-11-17 21:46:15 -08005586 "WLAN TL:Invalid pointer in %s", __func__));
Jeff Johnson295189b2012-06-20 16:38:30 -07005587 return VOS_STATUS_E_FAULT;
5588 }
5589 vosStatus = vos_pkt_peek_data( pvosDataBuff, 0, (v_PVOID_t)&pvFcRxBd,
5590 sizeof(tHalFcRxBd));
5591
5592 if ( (VOS_STATUS_SUCCESS != vosStatus) || (NULL == pvFcRxBd) )
5593 {
5594 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
5595 "WLAN TL:wrong FC Rx packet"));
5596 return VOS_STATUS_E_INVAL;
5597 }
5598
5599 // need to swap bytes in the FC contents.
5600 WLANHAL_SwapFcRxBd(&pvFcRxBd->fcSTATxQLen[0]);
5601
5602 //logic to enable/disable LWM mode for each station
5603 for( ucStaValid = (v_U8_t)pvFcRxBd->fcSTAValidMask; ucStaValid; ucStaValid >>= 1, ucBitCheck <<= 1, ucSTAId ++)
5604 {
5605 if ( (0 == (ucStaValid & 0x1)) || (0 == pTLCb->atlSTAClients[ucSTAId].ucExists) )
5606 {
5607 continue;
5608 }
5609
5610 if ( pvFcRxBd->fcSTAThreshIndMask & ucBitCheck )
5611 {
5612 //LWM event is reported by FW. Able to fetch more packet
5613 if( pTLCb->atlSTAClients[ucSTAId].ucLwmModeEnabled )
5614 {
5615 //Now memory usage is below LWM. Station can send more packets.
5616 pTLCb->atlSTAClients[ucSTAId].ucLwmEventReported = TRUE;
5617 }
5618 else
5619 {
5620 TLLOG4(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_LOW,
Arif Hussainf2b00992013-11-17 21:46:15 -08005621 "WLAN TL: FW report LWM event but the station %d is not in LWM mode", ucSTAId));
Jeff Johnson295189b2012-06-20 16:38:30 -07005622 }
5623 }
5624
5625 //calculate uEgress_length/uIngress_length only after receiving enough packets
5626 if (WLANTL_LWM_INGRESS_SAMPLE_THRESHOLD <= pTLCb->atlSTAClients[ucSTAId].uIngress_length)
5627 {
5628 //check memory usage info to see whether LWM mode should be enabled for the station
5629 v_U32_t uEgress_length = pTLCb->atlSTAClients[ucSTAId].uIngress_length +
5630 pTLCb->atlSTAClients[ucSTAId].bmuMemConsumed - pvFcRxBd->fcSTATxQLen[ucSTAId];
5631
5632 //if ((float)uEgress_length/(float)pTLCb->atlSTAClients[ucSTAId].uIngress_length
5633 // <= WLANTL_LWM_EGRESS_INGRESS_THRESHOLD)
5634 if ( (pTLCb->atlSTAClients[ucSTAId].uIngress_length > uEgress_length) &&
5635 ((pTLCb->atlSTAClients[ucSTAId].uIngress_length - uEgress_length ) >=
5636 (pTLCb->atlSTAClients[ucSTAId].uIngress_length >> 2))
5637 )
5638 {
5639 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
Arif Hussainf2b00992013-11-17 21:46:15 -08005640 "WLAN TL:Enable LWM mode for station %d", ucSTAId));
Jeff Johnson295189b2012-06-20 16:38:30 -07005641 pTLCb->atlSTAClients[ucSTAId].ucLwmModeEnabled = TRUE;
5642 }
5643 else
5644 {
5645 if( pTLCb->atlSTAClients[ucSTAId].ucLwmModeEnabled )
5646 {
5647 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
Arif Hussainf2b00992013-11-17 21:46:15 -08005648 "WLAN TL:Disable LWM mode for station %d", ucSTAId));
Jeff Johnson295189b2012-06-20 16:38:30 -07005649 pTLCb->atlSTAClients[ucSTAId].ucLwmModeEnabled = FALSE;
5650 }
5651
5652 }
5653
5654 //remember memory usage in FW starting from this round
5655 pTLCb->atlSTAClients[ucSTAId].bmuMemConsumed = pvFcRxBd->fcSTATxQLen[ucSTAId];
5656 pTLCb->atlSTAClients[ucSTAId].uIngress_length = 0;
5657 } //(WLANTL_LWM_INGRESS_SAMPLE_THRESHOLD <= pTLCb->atlSTAClients[ucSTAId].uIngress_length)
5658
5659 if( pTLCb->atlSTAClients[ucSTAId].ucLwmModeEnabled )
5660 {
5661 //always update current maximum allowed memeory usage
5662 pTLCb->atlSTAClients[ucSTAId].uBuffThresholdMax = WLANTL_STA_BMU_THRESHOLD_MAX -
5663 pvFcRxBd->fcSTATxQLen[ucSTAId];
5664 }
5665
5666 }
5667#endif
5668
5669 return VOS_STATUS_SUCCESS;
5670}
Jeff Johnson295189b2012-06-20 16:38:30 -07005671
5672
5673/*==========================================================================
5674
5675 FUNCTION WLANTL_RxFrames
5676
5677 DESCRIPTION
5678 Callback registered by TL and called by BAL when a packet is received
5679 over the bus. Upon the call of this function TL will make the necessary
5680 decision with regards to the forwarding or queuing of this packet and
5681 the layer it needs to be delivered to.
5682
5683 DEPENDENCIES
5684 TL must be initiailized before this function gets called.
5685 If the frame carried is a data frame then the station for which it is
5686 destined to must have been previously registered with TL.
5687
5688 PARAMETERS
5689
5690 IN
5691 pvosGCtx: pointer to the global vos context; a handle to TL's
5692 or BAL's control block can be extracted from its context
5693
5694 vosDataBuff: it will contain a pointer to the first buffer received,
5695 if there is more then one packet they will be chained
5696 using vOSS buffers.
5697
5698 RETURN VALUE
5699 The result code associated with performing the operation
5700
5701 VOS_STATUS_E_INVAL: Input parameters are invalid
5702 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
5703 page fault
5704 VOS_STATUS_SUCCESS: Everything is good :)
5705
5706 SIDE EFFECTS
5707
5708============================================================================*/
5709VOS_STATUS
5710WLANTL_RxFrames
5711(
5712 v_PVOID_t pvosGCtx,
5713 vos_pkt_t *pFrameDataBuff
5714)
5715{
5716 vos_pkt_t* vosDataBuff = (vos_pkt_t*)pFrameDataBuff;
5717 WLANTL_CbType* pTLCb = NULL;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05305718 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005719 WLANTL_STAFuncType pfnSTAFsm;
5720 vos_pkt_t* vosTempBuff;
5721 v_U8_t ucSTAId;
5722 VOS_STATUS vosStatus;
5723 v_U8_t ucFrmType;
5724 v_PVOID_t pvBDHeader = NULL;
5725 WLANTL_STAEventType wSTAEvent = WLANTL_RX_EVENT;
5726 v_U8_t ucTid = 0;
5727 v_BOOL_t broadcast = VOS_FALSE;
5728 v_BOOL_t selfBcastLoopback = VOS_FALSE;
Madan Mohan Koyyalamudidfd6aa82012-10-18 20:18:43 -07005729 static v_U8_t first_data_pkt_arrived;
Jeff Johnson295189b2012-06-20 16:38:30 -07005730 v_U32_t uDPUSig;
Jeff Johnson295189b2012-06-20 16:38:30 -07005731 v_U16_t usPktLen;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005732 v_BOOL_t bForwardIAPPwithLLC = VOS_FALSE;
Dino Mycle3b9536d2014-07-09 22:05:24 +05305733#ifdef WLAN_FEATURE_LINK_LAYER_STATS
5734 v_S7_t currentAvgRSSI = 0;
5735 v_U8_t ac;
5736
5737#endif
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005738
Jeff Johnson295189b2012-06-20 16:38:30 -07005739 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
5740
5741 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
5742 "WLAN TL:TL Receive Frames called"));
5743
5744 /*------------------------------------------------------------------------
5745 Sanity check
5746 ------------------------------------------------------------------------*/
5747 if ( NULL == vosDataBuff )
5748 {
5749 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
5750 "WLAN TL:Invalid parameter sent on WLANTL_RxFrames"));
5751 return VOS_STATUS_E_INVAL;
5752 }
5753
Katya Nigam3802f202013-12-16 19:27:14 +05305754 /*------------------------------------------------------------------------
5755 Popolaute timestamp as the time when packet arrives
5756 ---------------------------------------------------------------------- */
5757 vosDataBuff->timestamp = vos_timer_get_system_ticks();
5758
Jeff Johnson295189b2012-06-20 16:38:30 -07005759 /*------------------------------------------------------------------------
5760 Extract TL control block
5761 ------------------------------------------------------------------------*/
5762 pTLCb = VOS_GET_TL_CB(pvosGCtx);
5763 if ( NULL == pTLCb )
5764 {
5765 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
5766 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_ChangeSTAState"));
5767 return VOS_STATUS_E_FAULT;
5768 }
5769
5770 /*---------------------------------------------------------------------
5771 Save the initial buffer - this is the first received buffer
5772 ---------------------------------------------------------------------*/
5773 vosTempBuff = vosDataBuff;
5774
5775 while ( NULL != vosTempBuff )
5776 {
Madan Mohan Koyyalamudia148e1e2012-11-30 14:52:59 -08005777 broadcast = VOS_FALSE;
5778 selfBcastLoopback = VOS_FALSE;
5779
Jeff Johnson295189b2012-06-20 16:38:30 -07005780 vos_pkt_walk_packet_chain( vosDataBuff, &vosDataBuff, 1/*true*/ );
5781
Katya Nigame7b69a82015-04-28 15:24:06 +05305782 if( vos_get_conparam() == VOS_MONITOR_MODE )
5783 {
5784 if( pTLCb->isConversionReq )
5785 WLANTL_MonTranslate80211To8023Header(vosTempBuff, pTLCb);
5786
5787 pTLCb->pfnMonRx(pvosGCtx, vosTempBuff, pTLCb->isConversionReq);
5788 vosTempBuff = vosDataBuff;
5789 continue;
5790 }
5791
Jeff Johnson295189b2012-06-20 16:38:30 -07005792 /*---------------------------------------------------------------------
5793 Peek at BD header - do not remove
5794 !!! Optimize me: only part of header is needed; not entire one
5795 ---------------------------------------------------------------------*/
5796 vosStatus = WDA_DS_PeekRxPacketInfo( vosTempBuff, (v_PVOID_t)&pvBDHeader, 1/*Swap BD*/ );
5797
5798 if ( NULL == pvBDHeader )
5799 {
5800 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
5801 "WLAN TL:Cannot extract BD header"));
5802 /* Drop packet */
5803 vos_pkt_return_packet(vosTempBuff);
5804 vosTempBuff = vosDataBuff;
5805 continue;
5806 }
5807
Jeff Johnson295189b2012-06-20 16:38:30 -07005808 /*---------------------------------------------------------------------
5809 Check if FC frame reported from FW
5810 ---------------------------------------------------------------------*/
5811 if(WDA_IS_RX_FC(pvBDHeader))
5812 {
5813 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
5814 "WLAN TL:receive one FC frame"));
5815
5816 WLANTL_ProcessFCFrame(pvosGCtx, vosTempBuff, pvBDHeader);
5817 /* Drop packet */
5818 vos_pkt_return_packet(vosTempBuff);
5819 vosTempBuff = vosDataBuff;
5820 continue;
5821 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005822
5823 /* AMSDU HW bug fix
5824 * After 2nd AMSDU subframe HW could not handle BD correctly
5825 * HAL workaround is needed */
5826 if(WDA_GET_RX_ASF(pvBDHeader))
5827 {
5828 WDA_DS_RxAmsduBdFix(pvosGCtx, pvBDHeader);
5829 }
5830
5831 /*---------------------------------------------------------------------
5832 Extract frame control field from 802.11 header if present
5833 (frame translation not done)
5834 ---------------------------------------------------------------------*/
5835
5836 vosStatus = WDA_DS_GetFrameTypeSubType( pvosGCtx, vosTempBuff,
5837 pvBDHeader, &ucFrmType );
5838 if ( VOS_STATUS_SUCCESS != vosStatus )
5839 {
5840 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
5841 "WLAN TL:Cannot extract Frame Control Field"));
5842 /* Drop packet */
5843 vos_pkt_return_packet(vosTempBuff);
5844 vosTempBuff = vosDataBuff;
5845 continue;
5846 }
5847
Jeff Johnson295189b2012-06-20 16:38:30 -07005848 vos_pkt_get_packet_length(vosTempBuff, &usPktLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07005849
5850 /*---------------------------------------------------------------------
5851 Check if management and send to PE
5852 ---------------------------------------------------------------------*/
5853
Deepthi Gowrie89de132015-05-14 12:23:57 +05305854 if ( WLANTL_IS_MGMT_FRAME(ucFrmType))
Jeff Johnson295189b2012-06-20 16:38:30 -07005855 {
5856 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
5857 "WLAN TL:Sending packet to management client"));
5858 if ( VOS_STATUS_SUCCESS != vos_pkt_flatten_rx_pkt(&vosTempBuff))
5859 {
5860 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
5861 "WLAN TL:Cannot flatten packet - dropping"));
5862 /* Drop packet */
5863 vos_pkt_return_packet(vosTempBuff);
5864 vosTempBuff = vosDataBuff;
5865 continue;
5866 }
5867 ucSTAId = (v_U8_t)WDA_GET_RX_STAID( pvBDHeader );
5868 /* Read RSSI and update */
5869 if(!WLANTL_STA_ID_INVALID(ucSTAId))
5870 {
5871#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
5872 /* Read RSSI and update */
5873 vosStatus = WLANTL_HSHandleRXFrame(pvosGCtx,
5874 WLANTL_MGMT_FRAME_TYPE,
5875 pvBDHeader,
5876 ucSTAId,
5877 VOS_FALSE,
5878 NULL);
5879#else
5880 vosStatus = WLANTL_ReadRSSI(pvosGCtx, pvBDHeader, ucSTAId);
5881#endif
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05305882 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
5883 {
5884 TLLOGW(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
5885 "Handle RX Management Frame fail within Handoff "
5886 "support module"));
5887 /* Do Not Drop packet at here
5888 * Revisit why HO module return fail
5889 * vos_pkt_return_packet(vosTempBuff);
5890 * vosTempBuff = vosDataBuff;
5891 * continue;
5892 */
5893 }
5894 vosStatus = WLANTL_ReadSNR(pvosGCtx, pvBDHeader, ucSTAId);
5895
5896 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
5897 {
5898 TLLOGW(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
5899 FL("Failed to Read SNR")));
5900 }
Dino Mycle3b9536d2014-07-09 22:05:24 +05305901#ifdef WLAN_FEATURE_LINK_LAYER_STATS
5902 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
5903 if ( NULL != pClientSTA)
5904 {
5905 pClientSTA->interfaceStats.mgmtRx++;
Dino Mycle3b9536d2014-07-09 22:05:24 +05305906 }
5907#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005908 }
5909
Jeff Johnson295189b2012-06-20 16:38:30 -07005910 pTLCb->tlMgmtFrmClient.pfnTlMgmtFrmRx( pvosGCtx, vosTempBuff);
5911 }
5912 else /* Data Frame */
5913 {
5914 ucSTAId = (v_U8_t)WDA_GET_RX_STAID( pvBDHeader );
5915 ucTid = (v_U8_t)WDA_GET_RX_TID( pvBDHeader );
5916
5917 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
5918 "WLAN TL:Data packet received for STA %d", ucSTAId));
5919
5920 /*------------------------------------------------------------------
5921 This should be corrected when multipe sta support is added !!!
5922 for now bcast frames will be sent to the last registered STA
5923 ------------------------------------------------------------------*/
5924 if ( WDA_IS_RX_BCAST(pvBDHeader))
5925 {
5926 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
5927 "WLAN TL:TL rx Bcast frame - sending to last registered station"));
5928 broadcast = VOS_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07005929 /*-------------------------------------------------------------------
5930 If Addr1 is b/mcast, but Addr3 is our own self MAC, it is a b/mcast
5931 pkt we sent looping back to us. To be dropped if we are non BTAMP
5932 -------------------------------------------------------------------*/
5933 if( WLANHAL_RX_BD_ADDR3_SELF_IDX ==
5934 (v_U8_t)WDA_GET_RX_ADDR3_IDX( pvBDHeader ))
5935 {
5936 selfBcastLoopback = VOS_TRUE;
5937 }
5938 }/*if bcast*/
5939
jagadeesh99d8e632015-04-27 13:21:24 +05305940 if ((WLANTL_STA_ID_INVALID(ucSTAId)) || (WLANTL_TID_INVALID(ucTid)))
Jeff Johnson295189b2012-06-20 16:38:30 -07005941 {
5942 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
jagadeesh99d8e632015-04-27 13:21:24 +05305943 "WLAN TL:STAId %d, Tid %d. Invalid STA ID/TID- dropping pkt",
5944 ucSTAId, ucTid));
Jeff Johnson295189b2012-06-20 16:38:30 -07005945 /* Drop packet */
5946 vos_pkt_return_packet(vosTempBuff);
5947 vosTempBuff = vosDataBuff;
5948 continue;
5949 }
5950
jagadeesh99d8e632015-04-27 13:21:24 +05305951#ifdef WLAN_FEATURE_LINK_LAYER_STATS
5952 ac = WLANTL_TID_2_AC[ucTid];
5953#endif
5954
Jeff Johnson295189b2012-06-20 16:38:30 -07005955 /*----------------------------------------------------------------------
5956 No need to lock cache access because cache manipulation only happens
5957 in the transport thread/task context
5958 - These frames are to be forwarded to the station upon registration
5959 which happens in the main thread context
5960 The caching here can happen in either Tx or Rx thread depending
5961 on the current SSC scheduling
5962 - also we need to make sure that the frames in the cache are fwd-ed to
5963 the station before the new incoming ones
5964 -----------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05305965 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
5966 if (NULL == pClientSTA)
5967 {
5968 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
5969 "WLAN TL:STA not allocated memory. Dropping packet"));
5970 vos_pkt_return_packet(vosTempBuff);
5971 vosTempBuff = vosDataBuff;
5972 continue;
5973 }
5974
Hoonki Lee5305c3a2013-04-29 23:28:59 -07005975#ifdef FEATURE_WLAN_TDLS
5976 if (( pClientSTA->ucExists ) &&
5977 (WLAN_STA_TDLS == pClientSTA->wSTADesc.wSTAType) &&
5978 (pClientSTA->ucTxSuspended))
5979 vos_atomic_set_U8( &pClientSTA->ucTxSuspended, 0 );
5980 else if ( !broadcast && (pClientSTA->ucExists == 0 ) )
5981 {
5982 tpSirMacMgmtHdr pMacHeader = WDA_GET_RX_MAC_HEADER( pvBDHeader );
5983
5984 /* from the direct peer while it is not registered to TL yet */
5985 if ( (pMacHeader->fc.fromDS == 0) &&
5986 (pMacHeader->fc.toDS == 0) )
5987 {
5988 v_U8_t ucAddr3STAId;
5989
5990 ucAddr3STAId = WDA_GET_RX_ADDR3_IDX(pvBDHeader);
5991
5992 if ( WLANTL_STA_ID_INVALID(ucAddr3STAId) )
5993 {
5994 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
5995 "WLAN TL:STA ID %d invalid - dropping pkt", ucAddr3STAId));
5996 /* Drop packet */
5997 vos_pkt_return_packet(vosTempBuff);
5998 vosTempBuff = vosDataBuff;
5999 continue;
6000 }
6001
6002 if (!(pTLCb->atlSTAClients[ucAddr3STAId] && pTLCb->atlSTAClients[ucAddr3STAId]->ucExists &&
6003 (WLAN_STA_INFRA == pTLCb->atlSTAClients[ucAddr3STAId]->wSTADesc.wSTAType) &&
6004 (WLANTL_STA_AUTHENTICATED == pTLCb->atlSTAClients[ucAddr3STAId]->tlState)))
6005 {
6006 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
Arif Hussainf2b00992013-11-17 21:46:15 -08006007 "%s: staId %d addr3Id %d tlState %d. Unkown Receiver/Transmitter Dropping packet", __func__,
Hoonki Lee5305c3a2013-04-29 23:28:59 -07006008 ucSTAId, ucAddr3STAId, pTLCb->atlSTAClients[ucAddr3STAId]->tlState));
6009 vos_pkt_return_packet(vosTempBuff);
6010 vosTempBuff = vosDataBuff;
6011 continue;
6012 }
6013 else
6014 {
6015 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
Arif Hussainf2b00992013-11-17 21:46:15 -08006016 "%s: staId %d doesn't exist, but mapped to AP staId %d", __func__,
Hoonki Lee5305c3a2013-04-29 23:28:59 -07006017 ucSTAId, ucAddr3STAId));
6018 ucSTAId = ucAddr3STAId;
6019 pClientSTA = pTLCb->atlSTAClients[ucAddr3STAId];
6020 }
6021 }
6022 }
6023#endif
6024
Katya Nigam63902932014-06-26 19:04:23 +05306025 if (( pClientSTA->enableCaching == 1 ) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07006026 /*Dont buffer Broadcast/Multicast frames. If AP transmits bursts of Broadcast/Multicast data frames,
6027 * libra buffers all Broadcast/Multicast packets after authentication with AP,
6028 * So it will lead to low resource condition in Rx Data Path.*/
Katya Nigam63902932014-06-26 19:04:23 +05306029 ( WDA_IS_RX_BCAST(pvBDHeader) == 0 ))
Jeff Johnson295189b2012-06-20 16:38:30 -07006030 {
Katya Nigam6201c3e2014-05-27 17:51:42 +05306031 if( WDA_IsSelfSTA(pvosGCtx,ucSTAId))
6032 {
6033 //drop packet for Self STA index
6034 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
6035 "%s: Packet dropped for Self STA with staId %d ", __func__, ucSTAId ));
6036
6037 vos_pkt_return_packet(vosTempBuff);
6038 vosTempBuff = vosDataBuff;
6039 continue;
6040 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006041 uDPUSig = WDA_GET_RX_DPUSIG( pvBDHeader );
6042 //Station has not yet been registered with TL - cache the frame
Hoonki Lee5305c3a2013-04-29 23:28:59 -07006043 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
Arif Hussainf2b00992013-11-17 21:46:15 -08006044 "%s: staId %d exist %d tlState %d cache rx frame", __func__, ucSTAId,
Hoonki Lee5305c3a2013-04-29 23:28:59 -07006045 pClientSTA->ucExists, pClientSTA->tlState));
Jeff Johnson295189b2012-06-20 16:38:30 -07006046 WLANTL_CacheSTAFrame( pTLCb, ucSTAId, vosTempBuff, uDPUSig, broadcast, ucFrmType);
6047 vosTempBuff = vosDataBuff;
6048 continue;
6049 }
6050
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08006051#ifdef FEATURE_WLAN_ESE_UPLOAD
6052 if ((pClientSTA->wSTADesc.ucIsEseSta)|| broadcast)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07006053 {
6054 /*--------------------------------------------------------------------
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08006055 Filter the IAPP frames for ESE connection;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07006056 if data it will return false and it
6057 will be routed through the regular data path
6058 --------------------------------------------------------------------*/
6059 if ( WLANTL_IsIAPPFrame(pvBDHeader,
6060 vosTempBuff))
6061 {
6062 bForwardIAPPwithLLC = VOS_TRUE;
6063 }
6064 }
6065#endif
6066
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08006067#if defined(FEATURE_WLAN_ESE) && !defined(FEATURE_WLAN_ESE_UPLOAD)
6068 if ((pClientSTA->wSTADesc.ucIsEseSta)|| broadcast)
Jeff Johnson295189b2012-06-20 16:38:30 -07006069 {
6070 /*--------------------------------------------------------------------
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08006071 Filter the IAPP frames for ESE connection;
Jeff Johnson295189b2012-06-20 16:38:30 -07006072 if data it will return false and it
6073 will be routed through the regular data path
6074 --------------------------------------------------------------------*/
6075 if ( WLANTL_IsIAPPFrame(pvBDHeader,
6076 vosTempBuff))
6077 {
6078 if ( VOS_STATUS_SUCCESS != vos_pkt_flatten_rx_pkt(&vosTempBuff))
6079 {
6080 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6081 "WLAN TL:Cannot flatten packet - dropping"));
6082 /* Drop packet */
6083 vos_pkt_return_packet(vosTempBuff);
6084 } else {
6085
6086 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08006087 "WLAN TL: Received ESE IAPP Frame"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006088
6089 pTLCb->tlMgmtFrmClient.pfnTlMgmtFrmRx( pvosGCtx, vosTempBuff);
6090 }
6091 vosTempBuff = vosDataBuff;
6092 continue;
6093 }
6094 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08006095#endif /* defined(FEATURE_WLAN_ESE) && !defined(FEATURE_WLAN_ESE_UPLOAD) */
Jeff Johnson295189b2012-06-20 16:38:30 -07006096
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306097 if ( WLAN_STA_BT_AMP == pClientSTA->wSTADesc.wSTAType )
Jeff Johnson295189b2012-06-20 16:38:30 -07006098 {
6099 /*--------------------------------------------------------------------
6100 Process the ctrl BAP frame; if data it will return false and it
6101 will be routed through the regular data path
6102 --------------------------------------------------------------------*/
6103 if ( WLANTL_ProcessBAPFrame( pvBDHeader,
6104 vosTempBuff,
6105 pTLCb,
6106 &first_data_pkt_arrived,
6107 ucSTAId))
6108 {
6109 vosTempBuff = vosDataBuff;
6110 continue;
6111 }
6112 }/*if BT-AMP station*/
6113 else if(selfBcastLoopback == VOS_TRUE)
6114 {
6115 /* Drop packet */
6116 vos_pkt_return_packet(vosTempBuff);
6117 vosTempBuff = vosDataBuff;
6118 continue;
6119 }
6120
6121 /*---------------------------------------------------------------------
6122 Data packet received, send to state machine
6123 ---------------------------------------------------------------------*/
6124 wSTAEvent = WLANTL_RX_EVENT;
6125
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306126 pfnSTAFsm = tlSTAFsm[pClientSTA->tlState].
Jeff Johnson295189b2012-06-20 16:38:30 -07006127 pfnSTATbl[wSTAEvent];
6128
6129 if ( NULL != pfnSTAFsm )
6130 {
6131#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
6132 /* Read RSSI and update */
6133 vosStatus = WLANTL_HSHandleRXFrame(pvosGCtx,
6134 WLANTL_DATA_FRAME_TYPE,
6135 pvBDHeader,
6136 ucSTAId,
6137 broadcast,
6138 vosTempBuff);
6139 broadcast = VOS_FALSE;
6140#else
6141 vosStatus = WLANTL_ReadRSSI(pvosGCtx, pvBDHeader, ucSTAId);
Kiet Lam47325522014-03-10 11:50:46 -07006142#endif
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05306143 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
Jeff Johnson295189b2012-06-20 16:38:30 -07006144 {
6145 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
6146 "Handle RX Data Frame fail within Handoff support module"));
6147 /* Do Not Drop packet at here
6148 * Revisit why HO module return fail
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05306149 * vos_pkt_return_packet(vosTempBuff);
6150 * vosTempBuff = vosDataBuff;
6151 * continue;
Jeff Johnson295189b2012-06-20 16:38:30 -07006152 */
6153 }
Dino Mycle3b9536d2014-07-09 22:05:24 +05306154#ifdef WLAN_FEATURE_LINK_LAYER_STATS
6155 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
6156 if ( NULL != pClientSTA)
6157 {
6158 tpSirMacMgmtHdr pMacHeader = WDA_GET_RX_MAC_HEADER( pvBDHeader );
Mahesh A Saptasagarbbdcf122014-10-28 20:57:11 +05306159 if (!IS_BROADCAST_ADD(pMacHeader->da) && IS_MULTICAST_ADD(pMacHeader->da))
Dino Mycle3b9536d2014-07-09 22:05:24 +05306160 {
6161 pClientSTA->interfaceStats.accessCategoryStats[ac].rxMcast++;
6162 }
6163
6164 WLANTL_HSGetDataRSSI(pvosGCtx, pvBDHeader, ucSTAId,
6165 &currentAvgRSSI);
6166 pClientSTA->interfaceStats.rssiData = currentAvgRSSI;
6167
6168 pClientSTA->interfaceStats.accessCategoryStats[ac].rxMpdu++;
6169 if (WDA_IS_RX_AN_AMPDU (pvBDHeader))
6170 {
6171 pClientSTA->interfaceStats.accessCategoryStats[ac].rxAmpdu++;
6172 }
6173 }
6174
6175
6176#endif
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05306177 vosStatus = WLANTL_ReadSNR(pvosGCtx, pvBDHeader, ucSTAId);
6178
6179 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
6180 {
6181 TLLOGW(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
6182 FL("Failed to Read SNR")));
6183 }
6184
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07006185 pfnSTAFsm( pvosGCtx, ucSTAId, &vosTempBuff, bForwardIAPPwithLLC);
Jeff Johnson295189b2012-06-20 16:38:30 -07006186 }
6187 else
6188 {
6189 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
6190 "WLAN TL:NULL state function, STA:%d, State: %d- dropping packet",
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306191 ucSTAId, pClientSTA->tlState));
Jeff Johnson295189b2012-06-20 16:38:30 -07006192 /* Drop packet */
6193 vos_pkt_return_packet(vosTempBuff);
6194 vosTempBuff = vosDataBuff;
6195 continue;
6196 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006197 }/* else data frame*/
6198
6199 vosTempBuff = vosDataBuff;
6200 }/*while chain*/
6201
6202 return VOS_STATUS_SUCCESS;
6203}/* WLANTL_RxFrames */
6204
Dino Mycle3b9536d2014-07-09 22:05:24 +05306205#ifdef WLAN_FEATURE_LINK_LAYER_STATS
6206/*==========================================================================
6207
6208 FUNCTION WLANTL_CollectInterfaceStats
6209
6210 DESCRIPTION
6211 Utility function used by TL to send the statitics
6212
6213 DEPENDENCIES
6214
6215
6216 PARAMETERS
6217
6218 IN
6219
6220 ucSTAId: station for which the statistics need to collected
6221
6222 vosDataBuff: it will contain the pointer to the corresponding
6223 structure
6224
6225 RETURN VALUE
6226 The result code associated with performing the operation
6227
6228 VOS_STATUS_E_INVAL: Input parameters are invalid
6229 VOS_STATUS_SUCCESS: Everything is good :)
6230
6231 SIDE EFFECTS
6232
6233============================================================================*/
6234VOS_STATUS
6235WLANTL_CollectInterfaceStats
6236(
6237 v_PVOID_t pvosGCtx,
6238 v_U8_t ucSTAId,
6239 WLANTL_InterfaceStatsType *vosDataBuff
6240)
6241{
6242 WLANTL_CbType* pTLCb = NULL;
6243 /*------------------------------------------------------------------------
6244 Sanity check
6245 ------------------------------------------------------------------------*/
6246 if ( WLANTL_STA_ID_INVALID( ucSTAId ) )
6247 {
6248 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6249 "WLAN TL:Invalid station id requested on WLANTL_CollectStats"));
6250 return VOS_STATUS_E_FAULT;
6251 }
6252 /*------------------------------------------------------------------------
6253 Extract TL control block
6254 ------------------------------------------------------------------------*/
6255 pTLCb = VOS_GET_TL_CB(pvosGCtx);
6256 if ( NULL == pTLCb )
6257 {
6258 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6259 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_CollectStats"));
6260 return VOS_STATUS_E_FAULT;
6261 }
6262
6263 if ( NULL == pTLCb->atlSTAClients[ucSTAId] )
6264 {
6265 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6266 "WLAN TL:Client Memory was not allocated on %s", __func__));
6267 return VOS_STATUS_E_FAILURE;
6268 }
Srinivas Dasari98947432014-11-07 19:41:24 +05306269 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
6270 "WLAN TL: collect WIFI_STATS_IFACE results"));
6271
Dino Mycle3b9536d2014-07-09 22:05:24 +05306272 vos_mem_copy(vosDataBuff, &pTLCb->atlSTAClients[ucSTAId]->interfaceStats,
6273 sizeof(WLANTL_InterfaceStatsType));
6274 return VOS_STATUS_SUCCESS;
6275}
6276
Srinivas Dasari98947432014-11-07 19:41:24 +05306277/*==========================================================================
6278
6279 FUNCTION WLANTL_ClearInterfaceStats
6280
6281 DESCRIPTION
6282 Utility function used by TL to clear the statitics
6283
6284 DEPENDENCIES
6285
6286
6287 PARAMETERS
6288
6289 IN
6290
6291 ucSTAId: station for which the statistics need to collected
6292
6293 RETURN VALUE
6294 The result code associated with performing the operation
6295
6296 VOS_STATUS_E_INVAL: Input parameters are invalid
6297 VOS_STATUS_SUCCESS: Everything is good :)
6298
6299 SIDE EFFECTS
6300
6301============================================================================*/
6302VOS_STATUS
6303WLANTL_ClearInterfaceStats
6304(
6305 v_PVOID_t pvosGCtx,
6306 v_U8_t ucSTAId,
6307 v_U8_t statsClearReqMask
6308)
6309{
6310 WLANTL_CbType* pTLCb = NULL;
6311 WLANTL_STAClientType* pClientSTA = NULL;
6312 /*------------------------------------------------------------------------
6313 Sanity check
6314 ------------------------------------------------------------------------*/
6315 if ( WLANTL_STA_ID_INVALID( ucSTAId ) )
6316 {
6317 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6318 "WLAN TL:Invalid station id requested on WLANTL_CollectStats"));
6319 return VOS_STATUS_E_FAULT;
6320 }
6321 /*------------------------------------------------------------------------
6322 Extract TL control block
6323 ------------------------------------------------------------------------*/
6324 pTLCb = VOS_GET_TL_CB(pvosGCtx);
6325 if ( NULL == pTLCb )
6326 {
6327 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
6328 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_CollectStats"));
6329 return VOS_STATUS_E_FAULT;
6330 }
6331
6332 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
6333 if ( NULL == pClientSTA )
6334 {
6335 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
6336 "WLAN TL:Client Memory was not allocated on %s", __func__));
6337 return VOS_STATUS_E_FAILURE;
6338 }
6339
6340 if ((statsClearReqMask & WIFI_STATS_IFACE_AC) ||
6341 (statsClearReqMask & WIFI_STATS_IFACE)) {
6342 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
6343 "WLAN TL:cleared WIFI_STATS_IFACE_AC results"));
6344 pClientSTA->interfaceStats.accessCategoryStats[0].rxMcast = 0;
6345 pClientSTA->interfaceStats.accessCategoryStats[1].rxMcast = 0;
6346 pClientSTA->interfaceStats.accessCategoryStats[2].rxMcast = 0;
6347 pClientSTA->interfaceStats.accessCategoryStats[3].rxMcast = 0;
6348
6349 pClientSTA->interfaceStats.accessCategoryStats[0].rxMpdu = 0;
6350 pClientSTA->interfaceStats.accessCategoryStats[1].rxMpdu = 0;
6351 pClientSTA->interfaceStats.accessCategoryStats[2].rxMpdu = 0;
6352 pClientSTA->interfaceStats.accessCategoryStats[3].rxMpdu = 0;
6353
6354 pClientSTA->interfaceStats.accessCategoryStats[0].rxAmpdu = 0;
6355 pClientSTA->interfaceStats.accessCategoryStats[1].rxAmpdu = 0;
6356 pClientSTA->interfaceStats.accessCategoryStats[2].rxAmpdu = 0;
6357 pClientSTA->interfaceStats.accessCategoryStats[3].rxAmpdu = 0;
6358 }
6359
6360 if (statsClearReqMask & WIFI_STATS_IFACE) {
6361 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
6362 "WLAN TL:cleared WIFI_STATS_IFACE results"));
6363 pClientSTA->interfaceStats.mgmtRx = 0;
6364 pClientSTA->interfaceStats.rssiData = 0;
6365 return VOS_STATUS_SUCCESS;
6366 }
6367
6368 return VOS_STATUS_SUCCESS;
6369}
6370
Dino Mycle3b9536d2014-07-09 22:05:24 +05306371#endif /* WLAN_FEATURE_LINK_LAYER_STATS */
Jeff Johnson295189b2012-06-20 16:38:30 -07006372
6373/*==========================================================================
6374
6375 FUNCTION WLANTL_RxCachedFrames
6376
6377 DESCRIPTION
6378 Utility function used by TL to forward the cached frames to a particular
6379 station;
6380
6381 DEPENDENCIES
6382 TL must be initiailized before this function gets called.
6383 If the frame carried is a data frame then the station for which it is
6384 destined to must have been previously registered with TL.
6385
6386 PARAMETERS
6387
6388 IN
6389 pTLCb: pointer to TL handle
6390
6391 ucSTAId: station for which we need to forward the packets
6392
6393 vosDataBuff: it will contain a pointer to the first cached buffer
6394 received, if there is more then one packet they will be
6395 chained using vOSS buffers.
6396
6397 RETURN VALUE
6398 The result code associated with performing the operation
6399
6400 VOS_STATUS_E_INVAL: Input parameters are invalid
6401 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
6402 page fault
6403 VOS_STATUS_SUCCESS: Everything is good :)
6404
6405 SIDE EFFECTS
6406
6407============================================================================*/
6408VOS_STATUS
6409WLANTL_RxCachedFrames
6410(
6411 WLANTL_CbType* pTLCb,
6412 v_U8_t ucSTAId,
6413 vos_pkt_t* vosDataBuff
6414)
6415{
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306416 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07006417 WLANTL_STAFuncType pfnSTAFsm;
6418 vos_pkt_t* vosTempBuff;
6419 VOS_STATUS vosStatus;
6420 v_PVOID_t pvBDHeader = NULL;
6421 WLANTL_STAEventType wSTAEvent = WLANTL_RX_EVENT;
6422 v_U8_t ucTid = 0;
6423 v_BOOL_t broadcast = VOS_FALSE;
6424 v_BOOL_t bSigMatch = VOS_FALSE;
6425 v_BOOL_t selfBcastLoopback = VOS_FALSE;
Madan Mohan Koyyalamudidfd6aa82012-10-18 20:18:43 -07006426 static v_U8_t first_data_pkt_arrived;
Jeff Johnson295189b2012-06-20 16:38:30 -07006427 v_U32_t uDPUSig;
6428 v_U8_t ucUcastSig;
6429 v_U8_t ucBcastSig;
6430 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
6431
6432 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
6433 "WLAN TL:TL Receive Cached Frames called"));
6434
6435 /*------------------------------------------------------------------------
6436 Sanity check
6437 ------------------------------------------------------------------------*/
6438 if ( NULL == vosDataBuff )
6439 {
6440 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6441 "WLAN TL:Invalid parameter sent on WLANTL_RxFrames"));
6442 return VOS_STATUS_E_INVAL;
6443 }
6444
Mihir Sheteae6f02b2014-04-11 19:49:21 +05306445 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
6446
6447 if ( NULL == pClientSTA )
6448 {
6449 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6450 "WLAN TL:Client Memory was not allocated on %s", __func__));
6451 return VOS_STATUS_E_FAILURE;
6452 }
6453
6454 MTRACE(vos_trace(VOS_MODULE_ID_TL, TRACE_CODE_TL_FORWARD_CACHED_FRAMES,
6455 ucSTAId, 1<<16 | pClientSTA->tlCacheInfo.cacheSize));
6456
Jeff Johnson295189b2012-06-20 16:38:30 -07006457 /*---------------------------------------------------------------------
6458 Save the initial buffer - this is the first received buffer
6459 ---------------------------------------------------------------------*/
6460 vosTempBuff = vosDataBuff;
6461
6462 while ( NULL != vosTempBuff )
6463 {
Madan Mohan Koyyalamudia148e1e2012-11-30 14:52:59 -08006464 broadcast = VOS_FALSE;
6465 selfBcastLoopback = VOS_FALSE;
6466
Jeff Johnson295189b2012-06-20 16:38:30 -07006467 vos_pkt_walk_packet_chain( vosDataBuff, &vosDataBuff, 1/*true*/ );
6468
6469 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
6470 "WLAN TL:Sending new cached packet to station %d", ucSTAId));
6471 /*---------------------------------------------------------------------
6472 Peek at BD header - do not remove
6473 !!! Optimize me: only part of header is needed; not entire one
6474 ---------------------------------------------------------------------*/
6475 vosStatus = WDA_DS_PeekRxPacketInfo( vosTempBuff, (v_PVOID_t)&pvBDHeader, 0 );
6476
6477 if ( NULL == pvBDHeader )
6478 {
6479 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6480 "WLAN TL:Cannot extract BD header"));
6481 /* Drop packet */
6482 vos_pkt_return_packet(vosTempBuff);
6483 vosTempBuff = vosDataBuff;
6484 continue;
6485 }
6486
6487 uDPUSig = WDA_GET_RX_DPUSIG( pvBDHeader );
6488
6489 /* AMSDU HW bug fix
6490 * After 2nd AMSDU subframe HW could not handle BD correctly
6491 * HAL workaround is needed */
6492 if(WDA_GET_RX_ASF(pvBDHeader))
6493 {
6494 WDA_DS_RxAmsduBdFix(vos_get_global_context(VOS_MODULE_ID_TL,pTLCb),
6495 pvBDHeader);
6496 }
6497
6498 ucTid = (v_U8_t)WDA_GET_RX_TID( pvBDHeader );
6499
6500 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
6501 "WLAN TL:Data packet cached for STA %d", ucSTAId);
6502
6503 /*------------------------------------------------------------------
6504 This should be corrected when multipe sta support is added !!!
6505 for now bcast frames will be sent to the last registered STA
6506 ------------------------------------------------------------------*/
6507 if ( WDA_IS_RX_BCAST(pvBDHeader))
6508 {
6509 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
6510 "WLAN TL:TL rx Bcast frame "));
6511 broadcast = VOS_TRUE;
6512
6513 /* If Addr1 is b/mcast, but Addr3 is our own self MAC, it is a b/mcast
6514 * pkt we sent looping back to us. To be dropped if we are non BTAMP
6515 */
6516 if( WLANHAL_RX_BD_ADDR3_SELF_IDX ==
6517 (v_U8_t)WDA_GET_RX_ADDR3_IDX( pvBDHeader ))
6518 {
6519 selfBcastLoopback = VOS_TRUE;
6520 }
6521 }/*if bcast*/
6522
6523 /*-------------------------------------------------------------------------
6524 Check if the packet that we cached matches the DPU signature of the
6525 newly added station
6526 -------------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306527 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
6528
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306529 if ( NULL == pClientSTA )
6530 {
6531 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6532 "WLAN TL:Client Memory was not allocated on %s", __func__));
6533 return VOS_STATUS_E_FAILURE;
6534 }
6535
Jeff Johnson295189b2012-06-20 16:38:30 -07006536 if ( broadcast )
6537 {
6538 ucBcastSig = (v_U8_t)uDPUSig;
6539 bSigMatch = (( WLAN_TL_INVALID_B_SIG !=
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306540 pClientSTA->wSTADesc.ucBcastSig ) &&
6541 ( ucBcastSig == pClientSTA->wSTADesc.ucBcastSig ));
Jeff Johnson295189b2012-06-20 16:38:30 -07006542 }
6543 else
6544 {
6545 ucUcastSig = (v_U8_t)uDPUSig;
6546 bSigMatch = (( WLAN_TL_INVALID_U_SIG !=
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306547 pClientSTA->wSTADesc.ucUcastSig ) &&
6548 ( ucUcastSig == pClientSTA->wSTADesc.ucUcastSig ));
Jeff Johnson295189b2012-06-20 16:38:30 -07006549 }
6550
6551 /*-------------------------------------------------------------------------
6552 If the packet doesn't match - drop it
6553 -------------------------------------------------------------------------*/
6554 if ( !bSigMatch )
6555 {
Rajesh Chauhana6b08f42013-06-18 19:01:26 -07006556 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_MED,
Jeff Johnson295189b2012-06-20 16:38:30 -07006557 "WLAN TL: Cached packet does not match DPU Sig of the new STA - drop "
6558 " DPU Sig %d UC %d BC %d B %d",
6559 uDPUSig,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306560 pClientSTA->wSTADesc.ucUcastSig,
Rajesh Chauhana6b08f42013-06-18 19:01:26 -07006561 pClientSTA->wSTADesc.ucBcastSig,
Jeff Johnson295189b2012-06-20 16:38:30 -07006562 broadcast));
6563
6564 /* Drop packet */
6565 vos_pkt_return_packet(vosTempBuff);
6566 vosTempBuff = vosDataBuff;
6567 continue;
6568
6569 }/*if signature mismatch*/
6570
6571 /*------------------------------------------------------------------------
6572 Check if BT-AMP frame:
6573 - additional processing needed in this case to separate BT-AMP date
6574 from BT-AMP Ctrl path
6575 ------------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306576 if ( WLAN_STA_BT_AMP == pClientSTA->wSTADesc.wSTAType )
Jeff Johnson295189b2012-06-20 16:38:30 -07006577 {
6578 /*--------------------------------------------------------------------
6579 Process the ctrl BAP frame; if data it will return false and it
6580 will be routed through the regular data path
6581 --------------------------------------------------------------------*/
6582 if ( WLANTL_ProcessBAPFrame( pvBDHeader,
6583 vosTempBuff,
6584 pTLCb,
6585 &first_data_pkt_arrived,
6586 ucSTAId))
6587 {
6588 vosTempBuff = vosDataBuff;
6589 continue;
6590 }
6591 }/*if BT-AMP station*/
6592 else if(selfBcastLoopback == VOS_TRUE)
6593 {
6594 /* Drop packet */
6595 vos_pkt_return_packet(vosTempBuff);
6596 vosTempBuff = vosDataBuff;
6597 continue;
6598 }
6599
6600 /*---------------------------------------------------------------------
6601 Data packet received, send to state machine
6602 ---------------------------------------------------------------------*/
6603 wSTAEvent = WLANTL_RX_EVENT;
6604
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306605 pfnSTAFsm = tlSTAFsm[pClientSTA->tlState].
Jeff Johnson295189b2012-06-20 16:38:30 -07006606 pfnSTATbl[wSTAEvent];
6607
6608 if ( NULL != pfnSTAFsm )
6609 {
6610#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
6611 /* Read RSSI and update */
6612 vosStatus = WLANTL_HSHandleRXFrame(vos_get_global_context(
6613 VOS_MODULE_ID_TL,pTLCb),
6614 WLANTL_DATA_FRAME_TYPE,
6615 pvBDHeader,
6616 ucSTAId,
6617 broadcast,
6618 vosTempBuff);
6619 broadcast = VOS_FALSE;
6620#else
6621 vosStatus = WLANTL_ReadRSSI(vos_get_global_context(VOS_MODULE_ID_TL,pTLCb), pvBDHeader, ucSTAId);
Kiet Lam47325522014-03-10 11:50:46 -07006622#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006623 if(!VOS_IS_STATUS_SUCCESS(vosStatus))
6624 {
6625 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6626 "Handle RX Data Frame fail within Handoff support module"));
6627 /* Do Not Drop packet at here
6628 * Revisit why HO module return fail
6629 vos_pkt_return_packet(vosTempBuff);
6630 vosTempBuff = vosDataBuff;
6631 continue;
6632 */
6633 }
6634 pfnSTAFsm( vos_get_global_context(VOS_MODULE_ID_TL,pTLCb), ucSTAId,
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07006635 &vosTempBuff, VOS_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07006636 }
6637 else
6638 {
6639 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6640 "WLAN TL:NULL state function, STA:%d, State: %d- dropping packet",
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306641 ucSTAId, pClientSTA->tlState));
Jeff Johnson295189b2012-06-20 16:38:30 -07006642 /* Drop packet */
6643 vos_pkt_return_packet(vosTempBuff);
6644 vosTempBuff = vosDataBuff;
6645 continue;
6646 }
6647
6648 vosTempBuff = vosDataBuff;
6649 }/*while chain*/
6650
6651 return VOS_STATUS_SUCCESS;
6652}/* WLANTL_RxCachedFrames */
6653
6654/*==========================================================================
Katya Nigam664f5032014-05-05 12:24:32 +05306655 FUNCTION WLANTL_RxProcessMsg
6656
6657 DESCRIPTION
6658 Called by VOSS when a message was serialized for TL through the
6659 rx thread/task.
6660
6661 DEPENDENCIES
6662 The TL must be initialized before this function can be called.
6663
6664 PARAMETERS
6665
6666 IN
6667 pvosGCtx: pointer to the global vos context; a handle to TL's
6668 control block can be extracted from its context
6669 message: type and content of the message
6670
6671
6672 RETURN VALUE
6673 The result code associated with performing the operation
6674
6675 VOS_STATUS_E_INVAL: invalid input parameters
6676 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
6677 page fault
6678 VOS_STATUS_SUCCESS: Everything is good :)
6679
6680 Other values can be returned as a result of a function call, please check
6681 corresponding API for more info.
6682 SIDE EFFECTS
6683
6684============================================================================*/
6685VOS_STATUS
6686WLANTL_RxProcessMsg
6687(
6688 v_PVOID_t pvosGCtx,
6689 vos_msg_t* message
6690)
6691{
6692 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
6693 v_U32_t uData;
6694 v_U8_t ucSTAId;
6695 v_U8_t ucUcastSig;
6696 v_U8_t ucBcastSig;
6697
6698 /*------------------------------------------------------------------------
6699 Sanity check
6700 ------------------------------------------------------------------------*/
6701 if ( NULL == message )
6702 {
6703 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6704 "WLAN TL:Invalid parameter sent on WLANTL_RxProcessMessage"));
6705 return VOS_STATUS_E_INVAL;
6706 }
6707
6708 /*------------------------------------------------------------------------
6709 Process message
6710 ------------------------------------------------------------------------*/
6711 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
6712 "WLAN TL:Received message: %d through rx flow", message->type));
6713
6714 switch( message->type )
6715 {
6716
6717 case WLANTL_RX_FWD_CACHED:
6718 /*---------------------------------------------------------------------
6719 The data sent with the message has the following structure:
6720 | 00 | ucBcastSignature | ucUcastSignature | ucSTAID |
6721 each field above is one byte
6722 ---------------------------------------------------------------------*/
6723 uData = message->bodyval;
6724 ucSTAId = ( uData & 0x000000FF);
6725 ucUcastSig = ( uData & 0x0000FF00)>>8;
6726 ucBcastSig = (v_U8_t)(( uData & 0x00FF0000)>>16);
6727 vosStatus = WLANTL_ForwardSTAFrames( pvosGCtx, ucSTAId,
6728 ucUcastSig, ucBcastSig);
6729 break;
6730
6731 default:
6732 /*no processing for now*/
6733 break;
6734 }
6735
6736 return VOS_STATUS_SUCCESS;
6737}
6738
6739
6740/*==========================================================================
Jeff Johnson295189b2012-06-20 16:38:30 -07006741 FUNCTION WLANTL_ResourceCB
6742
6743 DESCRIPTION
6744 Called by the TL when it has packets available for transmission.
6745
6746 DEPENDENCIES
6747 The TL must be registered with BAL before this function can be called.
6748
6749 PARAMETERS
6750
6751 IN
6752 pvosGCtx: pointer to the global vos context; a handle to TL's
6753 or BAL's control block can be extracted from its context
6754
6755 RETURN VALUE
6756 The result code associated with performing the operation
6757
6758 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
6759 page fault
6760 VOS_STATUS_SUCCESS: Everything is good :)
6761
6762 SIDE EFFECTS
6763
6764============================================================================*/
6765VOS_STATUS
6766WLANTL_ResourceCB
6767(
6768 v_PVOID_t pvosGCtx,
6769 v_U32_t uCount
6770)
6771{
6772 WLANTL_CbType* pTLCb = NULL;
6773 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
6774
6775 /*------------------------------------------------------------------------
6776 Sanity check
6777 Extract TL control block
6778 ------------------------------------------------------------------------*/
6779 pTLCb = VOS_GET_TL_CB(pvosGCtx);
6780 if ( NULL == pTLCb )
6781 {
6782 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6783 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_ChangeSTAState"));
6784 return VOS_STATUS_E_FAULT;
6785 }
6786
6787 pTLCb->uResCount = uCount;
6788
6789
6790 /*-----------------------------------------------------------------------
6791 Resume Tx if enough res and not suspended
6792 -----------------------------------------------------------------------*/
6793 if (( pTLCb->uResCount >= WDA_TLI_MIN_RES_MF ) &&
6794 ( 0 == pTLCb->ucTxSuspended ))
6795 {
6796 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
6797 "WLAN TL:Issuing Xmit start request to BAL for avail res ASYNC"));
6798 return WDA_DS_StartXmit(pvosGCtx);
6799 }
6800
6801 return VOS_STATUS_SUCCESS;
6802}/* WLANTL_ResourceCB */
6803
6804
Gopichand Nakkala11acd112012-12-31 16:04:04 -08006805/*==========================================================================
6806 FUNCTION WLANTL_IsTxXmitPending
6807
6808 DESCRIPTION
6809 Called by the WDA when it wants to know whether WDA_DS_TX_START_XMIT msg
6810 is pending in TL msg queue
6811
6812 DEPENDENCIES
6813 The TL must be registered with WDA before this function can be called.
6814
6815 PARAMETERS
6816
6817 IN
6818 pvosGCtx: pointer to the global vos context; a handle to TL's
6819 or WDA's control block can be extracted from its context
6820
6821 RETURN VALUE
6822 The result code associated with performing the operation
6823
6824 0: No WDA_DS_TX_START_XMIT msg pending
6825 1: Msg WDA_DS_TX_START_XMIT already pending in TL msg queue
6826
6827 SIDE EFFECTS
6828
6829============================================================================*/
6830v_BOOL_t
6831WLANTL_IsTxXmitPending
6832(
6833 v_PVOID_t pvosGCtx
6834)
6835{
6836
6837 WLANTL_CbType* pTLCb = NULL;
6838 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
6839
6840 /*------------------------------------------------------------------------
6841 Sanity check
6842 Extract TL control block
6843 ------------------------------------------------------------------------*/
6844 pTLCb = VOS_GET_TL_CB(pvosGCtx);
6845 if ( NULL == pTLCb )
6846 {
6847 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_FATAL,
6848 "WLAN TL:Invalid TL pointer from pvosGCtx in WLANTL_IsTxXmitPending "));
6849 return FALSE;
6850 }
6851
6852 return pTLCb->isTxTranmitMsgPending;
6853
6854}/*WLANTL_IsTxXmitPending */
6855
6856/*==========================================================================
6857 FUNCTION WLANTL_SetTxXmitPending
6858
6859 DESCRIPTION
6860 Called by the WDA when it wants to indicate that WDA_DS_TX_START_XMIT msg
6861 is pending in TL msg queue
6862
6863 DEPENDENCIES
6864 The TL must be registered with WDA before this function can be called.
6865
6866 PARAMETERS
6867
6868 IN
6869 pvosGCtx: pointer to the global vos context; a handle to TL's
6870 or WDA's control block can be extracted from its context
6871
6872 RETURN VALUE None
6873
6874 SIDE EFFECTS
6875
6876============================================================================*/
6877
6878v_VOID_t
6879WLANTL_SetTxXmitPending
6880(
6881 v_PVOID_t pvosGCtx
6882)
6883{
6884
6885 WLANTL_CbType* pTLCb = NULL;
6886 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
6887
6888 /*------------------------------------------------------------------------
6889 Sanity check
6890 Extract TL control block
6891 ------------------------------------------------------------------------*/
6892 pTLCb = VOS_GET_TL_CB(pvosGCtx);
6893 if ( NULL == pTLCb )
6894 {
6895 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_FATAL,
6896 "WLAN TL:Invalid TL pointer from pvosGCtx in WLANTL_SetTxXmitPending"));
6897 return;
6898 }
6899
6900 pTLCb->isTxTranmitMsgPending = 1;
6901 return;
6902
6903}/*WLANTL_SetTxXmitPending */
6904
6905/*==========================================================================
6906 FUNCTION WLANTL_ClearTxXmitPending
6907
6908 DESCRIPTION
6909 Called by the WDA when it wants to indicate that no WDA_DS_TX_START_XMIT msg
6910 is pending in TL msg queue
6911
6912 DEPENDENCIES
6913 The TL must be registered with WDA before this function can be called.
6914
6915 PARAMETERS
6916
6917 IN
6918 pvosGCtx: pointer to the global vos context; a handle to TL's
6919 or WDA's control block can be extracted from its context
6920
6921 RETURN VALUE None
6922
6923 SIDE EFFECTS
6924
6925============================================================================*/
6926
6927v_VOID_t
6928WLANTL_ClearTxXmitPending
6929(
6930 v_PVOID_t pvosGCtx
6931)
6932{
6933
6934 WLANTL_CbType* pTLCb = NULL;
6935 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
6936
6937 /*------------------------------------------------------------------------
6938 Sanity check
6939 Extract TL control block
6940 ------------------------------------------------------------------------*/
6941 pTLCb = VOS_GET_TL_CB(pvosGCtx);
6942 if ( NULL == pTLCb )
6943 {
6944 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_FATAL,
6945 "WLAN TL:Invalid TL pointer from pvosGCtx in WLANTL_ClearTxXmitPending "));
6946 return;
6947 }
6948
6949 pTLCb->isTxTranmitMsgPending = 0;
6950 return;
6951}/*WLANTL_ClearTxXmitPending */
6952
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05306953/*==========================================================================
6954 FUNCTION WLANTL_TxThreadDebugHandler
6955
6956 DESCRIPTION
6957 Printing TL Snapshot dump, processed under TxThread context, currently
6958 information regarding the global TlCb struture. Dumps information related
6959 to per active STA connection currently in use by TL.
6960
6961 DEPENDENCIES
6962 The TL must be initialized before this gets called.
6963
6964 PARAMETERS
6965
6966 IN
6967 pvosGCtx: pointer to the global vos context; a handle to TL's
6968 or WDA's control block can be extracted from its context
6969
6970 RETURN VALUE None
6971
6972 SIDE EFFECTS
6973
6974============================================================================*/
6975
6976v_VOID_t
6977WLANTL_TxThreadDebugHandler
6978(
6979 v_PVOID_t *pVosContext
6980)
6981{
6982 WLANTL_CbType* pTLCb = NULL;
6983 WLANTL_STAClientType* pClientSTA = NULL;
6984 int i = 0;
Mihir Shete5d148f12014-12-16 17:54:49 +05306985 v_U8_t uFlowMask; // TX FlowMask from WDA
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05306986
6987 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_FATAL,
6988 "WLAN TL: %s Enter ", __func__));
6989
6990 pTLCb = VOS_GET_TL_CB(pVosContext);
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05306991
6992 if ( NULL == pVosContext || NULL == pTLCb )
6993 {
6994 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6995 "Global VoS Context or TL Context are NULL"));
6996 return;
6997 }
6998
Mihir Shete5d148f12014-12-16 17:54:49 +05306999 if (VOS_STATUS_SUCCESS == WDA_DS_GetTxFlowMask(pVosContext, &uFlowMask))
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307000 {
7001 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Mihir Shete5d148f12014-12-16 17:54:49 +05307002 "WDA uTxFlowMask: 0x%x", uFlowMask));
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307003 }
Mihir Shete5d148f12014-12-16 17:54:49 +05307004
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307005 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7006 "************************TL DUMP INFORMATION**************"));
7007
7008 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7009 "uDelayedTriggerFrmInt:%d\tuMinFramesProcThres:%d",
7010 pTLCb->tlConfigInfo.uDelayedTriggerFrmInt,
7011 pTLCb->tlConfigInfo.uMinFramesProcThres));
7012
7013 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7014 "Management Frame Client exists: %d",
7015 pTLCb->tlMgmtFrmClient.ucExists));
7016 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7017 "usPendingTxCompleteCount: %d\tucTxSuspended: %d",
7018 pTLCb->usPendingTxCompleteCount,
7019 pTLCb->ucTxSuspended));
7020
7021 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7022 "uResCount: %d", pTLCb->uResCount));
7023
7024 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7025 "ucRegisteredStaId: %d\tucCurrentSTA: %d",
7026 pTLCb->ucRegisteredStaId, pTLCb->ucCurrentSTA));
7027
7028 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7029 "UrgentFrameProcessing: %s\tuFramesProcThres: %d",
7030 (pTLCb->bUrgent?"True":"False"), pTLCb->uFramesProcThres));
7031
7032 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7033 "isTxTranmitMsgPending: %d\t isBMPS: %s",
7034 pTLCb->isTxTranmitMsgPending, pTLCb->isBMPS?"True":"False"));
7035
7036#ifdef FEATURE_WLAN_TDLS
7037 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7038 "TDLS Peer Count: %d", pTLCb->ucTdlsPeerCount));
7039#endif
7040
7041 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7042 "++++++++++++++++++++Registerd Client Information++++++++++"));
7043
7044 for ( i =0; i<WLAN_MAX_STA_COUNT; i++ )
7045 {
7046 pClientSTA = pTLCb->atlSTAClients[i];
7047 if( NULL == pClientSTA || 0 == pClientSTA->ucExists)
7048 {
7049 continue;
7050 }
7051
7052 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7053 "######################STA Index: %d ############################",i));
7054 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR, "WLAN_STADescType:"));
7055 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7056 "STAId: %d\t STA MAC Address: %pM", pClientSTA->wSTADesc.ucSTAId,
7057 pClientSTA->wSTADesc.vSTAMACAddress.bytes));
7058 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7059 "STA Type: %d\tProtectedFrame: %d",
7060 pClientSTA->wSTADesc.wSTAType, pClientSTA->wSTADesc.ucProtectedFrame));
7061 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7062 "QoS: %d\tRxFrameTrans: %d\tTxFrameTrans: %d",
7063 pClientSTA->wSTADesc.ucQosEnabled, pClientSTA->wSTADesc.ucSwFrameRXXlation,
7064 pClientSTA->wSTADesc.ucSwFrameTXXlation));
7065 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7066 "ucUcastSig: %d\tucBcastSig: %d", pClientSTA->wSTADesc.ucUcastSig,
7067 pClientSTA->wSTADesc.ucBcastSig));
7068
7069 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7070 "ClientIndex: %d\t Exists: %d", i, pClientSTA->ucExists));
7071 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7072 "TL State: %d\t TL Priority: %d", pClientSTA->tlState,
7073 pClientSTA->tlPri));
7074 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7075 "ucTxSuspended: %d\tucPktPending: %d", pClientSTA->ucTxSuspended,
7076 pClientSTA->ucPktPending));
7077 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7078 "ucEAPOLPktPending: %d\tucNoMoreData: %d",
7079 pClientSTA->ucEapolPktPending, pClientSTA->ucNoMoreData));
7080 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Katya Nigam63902932014-06-26 19:04:23 +05307081 "enableCaching: %d\t fcStaTxDisabled: %d", pClientSTA->enableCaching,
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307082 pClientSTA->fcStaTxDisabled));
7083 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7084 "ucCurrentAC: %d\tucServicedAC: %d", pClientSTA->ucCurrentAC,
7085 pClientSTA->ucServicedAC));
7086 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7087 "TID: %d\tautTxCount[0]: %d\tauRxCount[0]: %d",0, pClientSTA->auTxCount[0],
7088 pClientSTA->auRxCount[0]));
7089 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7090 "aucAcMask[0]: %d\taucAcMask[1]: %d\taucAcMask[2]: %d\taucAcMask[3]: %d\t",
7091 pClientSTA->aucACMask[0], pClientSTA->aucACMask[1],
7092 pClientSTA->aucACMask[2], pClientSTA->aucACMask[3]));
7093 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7094 "ucCurrentWeight: %d", pClientSTA->ucCurrentWeight));
7095
7096 if( WLAN_STA_SOFTAP == pClientSTA->wSTADesc.wSTAType)
7097 {
7098 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7099 "TrafficStatistics for SOFTAP Station:"));
7100 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7101 "RUF=%d\tRMF=%d\tRBF=%d", pClientSTA->trafficStatistics.rxUCFcnt,
7102 pClientSTA->trafficStatistics.rxMCFcnt,
7103 pClientSTA->trafficStatistics.rxBCFcnt));
7104 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7105 "RUB=%d\tRMB=%d\tRBB=%d", pClientSTA->trafficStatistics.rxUCBcnt,
7106 pClientSTA->trafficStatistics.rxMCBcnt,
7107 pClientSTA->trafficStatistics.rxBCBcnt));
7108 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7109 "TUF=%d\tTMF=%d\tTBF=%d", pClientSTA->trafficStatistics.txUCFcnt,
7110 pClientSTA->trafficStatistics.txMCFcnt,
7111 pClientSTA->trafficStatistics.txBCFcnt));
7112 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7113 "TUB=%d\tTMB=%d\tTBB=%d", pClientSTA->trafficStatistics.txUCBcnt,
7114 pClientSTA->trafficStatistics.txMCBcnt,
7115 pClientSTA->trafficStatistics.txBCBcnt));
7116 }
7117 }
7118 return;
7119}
7120
7121/*==========================================================================
Mihir Shetefd62d9d2014-08-06 15:08:21 +05307122 FUNCTION WLANTL_FatalErrorHandler
7123
7124 DESCRIPTION
7125 Handle Fatal errors detected on the TX path.
7126 Currently issues SSR to recover from the error.
7127
7128 DEPENDENCIES
7129 The TL must be initialized before this gets called.
7130
7131 PARAMETERS
7132
7133 IN
7134 pvosGCtx: pointer to the global vos context; a handle to TL's
7135 or WDA's control block can be extracted from its context
7136
7137 RETURN VALUE None
7138
7139 SIDE EFFECTS
7140
7141============================================================================*/
7142v_VOID_t
7143WLANTL_FatalErrorHandler
7144(
7145 v_PVOID_t *pVosContext
7146)
7147{
7148
7149 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_FATAL,
7150 "WLAN TL: %s Enter ", __func__));
7151
7152 if ( NULL == pVosContext )
7153 {
7154 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7155 "%s: Global VoS Context or TL Context are NULL",
7156 __func__));
7157 return;
7158 }
7159
7160 /*
7161 * Issue SSR. vos_wlanRestart has tight checks to make sure that
7162 * we do not send an FIQ if previous FIQ is not processed
7163 */
7164 vos_wlanRestart();
7165}
7166
7167/*==========================================================================
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307168 FUNCTION WLANTL_TLDebugMessage
7169
7170 DESCRIPTION
7171 Post a TL Snapshot request, posts message in TxThread.
7172
7173 DEPENDENCIES
7174 The TL must be initialized before this gets called.
7175
7176 PARAMETERS
7177
7178 IN
7179 displaySnapshot Boolean showing whether to dump the snapshot or not.
7180
7181 RETURN VALUE None
7182
7183 SIDE EFFECTS
7184
7185============================================================================*/
7186
7187v_VOID_t
7188WLANTL_TLDebugMessage
7189(
Mihir Shete327c2ab2014-11-13 15:17:02 +05307190 v_U32_t debugFlags
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307191)
7192{
7193 vos_msg_t vosMsg;
7194 VOS_STATUS status;
7195
Mihir Shete327c2ab2014-11-13 15:17:02 +05307196 if(debugFlags & WLANTL_DEBUG_TX_SNAPSHOT)
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307197 {
7198 vosMsg.reserved = 0;
7199 vosMsg.bodyptr = NULL;
7200 vosMsg.type = WLANTL_TX_SNAPSHOT;
7201
7202 status = vos_tx_mq_serialize( VOS_MODULE_ID_TL, &vosMsg);
7203 if(status != VOS_STATUS_SUCCESS)
7204 {
7205 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR, "TX Msg Posting Failed with status: %d",status));
7206 return;
7207 }
7208 }
Mihir Shete327c2ab2014-11-13 15:17:02 +05307209 if (debugFlags & WLANTL_DEBUG_FW_CLEANUP)
7210 {
7211 vosMsg.reserved = 0;
7212 vosMsg.bodyptr = NULL;
7213 vosMsg.type = WLANTL_TX_FW_DEBUG;
7214
7215 status = vos_tx_mq_serialize( VOS_MODULE_ID_TL, &vosMsg);
7216 if(status != VOS_STATUS_SUCCESS)
7217 {
7218 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR, "TX Msg Posting Failed with status: %d",status));
7219 return;
7220 }
7221 }
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307222 return;
7223}
Jeff Johnson295189b2012-06-20 16:38:30 -07007224
Mihir Shetefd62d9d2014-08-06 15:08:21 +05307225/*==========================================================================
7226 FUNCTION WLANTL_FatalError
7227
7228 DESCRIPTION
7229 Fatal error reported in TX path, post an event to TX Thread for further
7230 handling
7231
7232 DEPENDENCIES
7233 The TL must be initialized before this gets called.
7234
7235 PARAMETERS
7236
7237 VOID
7238
7239 RETURN VALUE None
7240
7241 SIDE EFFECTS
7242
7243============================================================================*/
7244
7245v_VOID_t
7246WLANTL_FatalError
7247(
7248 v_VOID_t
7249)
7250{
7251 vos_msg_t vosMsg;
7252 VOS_STATUS status;
7253
7254 vosMsg.reserved = 0;
7255 vosMsg.bodyptr = NULL;
7256 vosMsg.type = WLANTL_TX_FATAL_ERROR;
7257
7258 status = vos_tx_mq_serialize( VOS_MODULE_ID_TL, &vosMsg);
7259 if(status != VOS_STATUS_SUCCESS)
7260 {
7261 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7262 "%s: TX Msg Posting Failed with status: %d",
7263 __func__,status));
7264 }
7265 return;
7266}
Jeff Johnson295189b2012-06-20 16:38:30 -07007267/*============================================================================
7268 TL STATE MACHINE
7269============================================================================*/
7270
7271/*==========================================================================
7272 FUNCTION WLANTL_STATxConn
7273
7274 DESCRIPTION
7275 Transmit in connected state - only EAPOL and WAI packets allowed
7276
7277 DEPENDENCIES
7278 The STA must be registered with TL before this function can be called.
7279
7280 PARAMETERS
7281
7282 IN
7283 pvosGCtx: pointer to the global vos context; a handle to TL's
7284 control block can be extracted from its context
7285 ucSTAId: identifier of the station being processed
7286 vosDataBuff: pointer to the tx vos buffer
7287
7288 RETURN VALUE
7289 The result code associated with performing the operation
7290
7291 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
7292 page fault
7293 VOS_STATUS_SUCCESS: Everything is good :)
7294
7295 Other return values are possible coming from the called functions.
7296 Please check API for additional info.
7297
7298 SIDE EFFECTS
7299
7300============================================================================*/
7301VOS_STATUS
7302WLANTL_STATxConn
7303(
7304 v_PVOID_t pvosGCtx,
7305 v_U8_t ucSTAId,
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07007306 vos_pkt_t** pvosDataBuff,
7307 v_BOOL_t bForwardIAPPwithLLC
Jeff Johnson295189b2012-06-20 16:38:30 -07007308)
7309{
7310 v_U16_t usPktLen;
7311 VOS_STATUS vosStatus;
7312 v_MACADDR_t vDestMacAddr;
7313 vos_pkt_t* vosDataBuff = NULL;
7314 WLANTL_CbType* pTLCb = NULL;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307315 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07007316 WLANTL_MetaInfoType tlMetaInfo;
7317 v_U8_t ucTypeSubtype = 0;
7318 v_U8_t ucTid;
7319 v_U8_t extraHeadSpace = 0;
7320 v_U8_t ucWDSEnabled = 0;
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07007321 v_U8_t ucAC, ucACMask, i;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05307322 v_U32_t txFlag = HAL_TX_NO_ENCRYPTION_MASK;
Jeff Johnson295189b2012-06-20 16:38:30 -07007323 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
7324
7325 /*------------------------------------------------------------------------
7326 Sanity check
7327 Extract TL control block
7328 ------------------------------------------------------------------------*/
7329 pTLCb = VOS_GET_TL_CB(pvosGCtx);
7330 if ( NULL == pTLCb )
7331 {
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07007332 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7333 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_STATxConn");
Jeff Johnson295189b2012-06-20 16:38:30 -07007334 *pvosDataBuff = NULL;
7335 return VOS_STATUS_E_FAULT;
7336 }
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307337 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
7338
7339 if ( NULL == pClientSTA )
7340 {
7341 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7342 "WLAN TL:Client Memory was not allocated on %s", __func__));
7343 return VOS_STATUS_E_FAILURE;
7344 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007345
7346 /*-------------------------------------------------------------------
7347 Disable AC temporary - if successfull retrieve re-enable
7348 The order is justified because of the possible scenario
7349 - TL tryes to fetch packet for AC and it returns NULL
7350 - TL analyzes the data it has received to see if there are
7351 any more pkts available for AC -> if not TL will disable AC
7352 - however it is possible that while analyzing results TL got
7353 preempted by a pending indication where the mask was again set
7354 TL will not check again and as a result when it resumes
7355 execution it will disable AC
7356 To prevent this the AC will be disabled here and if retrieve
7357 is successfull it will be re-enabled
7358 -------------------------------------------------------------------*/
7359
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07007360
7361 //LTI:pTLCb->atlSTAClients[ucSTAId].
7362 //LTI: aucACMask[pTLCb->atlSTAClients[ucSTAId].ucCurrentAC] = 0;
7363
7364 /*------------------------------------------------------------------------
7365 Fetch packet from HDD
7366 ------------------------------------------------------------------------*/
Sunil Ravid5406f22013-01-22 00:18:31 -08007367#ifdef FEATURE_WLAN_TDLS
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307368 if ((WLAN_STA_SOFTAP != pClientSTA->wSTADesc.wSTAType) &&
Agarwal Ashishcd86f7b2014-06-16 17:11:58 +05307369 !(vos_concurrent_open_sessions_running()) &&
Sunil Ravid5406f22013-01-22 00:18:31 -08007370 !pTLCb->ucTdlsPeerCount)
7371 {
7372#else
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307373 if ((WLAN_STA_SOFTAP != pClientSTA->wSTADesc.wSTAType) &&
Agarwal Ashishcd86f7b2014-06-16 17:11:58 +05307374 !(vos_concurrent_open_sessions_running()))
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07007375 {
Sunil Ravid5406f22013-01-22 00:18:31 -08007376#endif
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307377 ucAC = pClientSTA->ucCurrentAC;
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07007378
7379 /*-------------------------------------------------------------------
7380 Disable AC temporary - if successfull retrieve re-enable
7381 The order is justified because of the possible scenario
7382 - TL tryes to fetch packet for AC and it returns NULL
7383 - TL analyzes the data it has received to see if there are
7384 any more pkts available for AC -> if not TL will disable AC
7385 - however it is possible that while analyzing results TL got
7386 preempted by a pending indication where the mask was again set
7387 TL will not check again and as a result when it resumes
7388 execution it will disable AC
7389 To prevent this the AC will be disabled here and if retrieve
7390 is successfull it will be re-enabled
7391 -------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307392 pClientSTA->aucACMask[ucAC] = 0;
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07007393 }
7394 else
7395 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307396 //softap case
7397 ucAC = pTLCb->uCurServedAC;
7398 pClientSTA->aucACMask[ucAC] = 0;
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07007399 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007400
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307401 /*You make an initial assumption that HDD has no more data and if the
Jeff Johnson295189b2012-06-20 16:38:30 -07007402 assumption was wrong you reset the flags to their original state
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307403 This will prevent from exposing a race condition between checking with HDD
Jeff Johnson295189b2012-06-20 16:38:30 -07007404 for packets and setting the flags to false*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307405 //LTI: vos_atomic_set_U8( &pTLCb->atlSTAClients[ucSTAId].ucPktPending, 0);
7406 //LTI: pTLCb->atlSTAClients[ucSTAId].ucNoMoreData = 1;
7407 vos_atomic_set_U8( &pClientSTA->ucPktPending, 0);
7408 WLAN_TL_AC_ARRAY_2_MASK( pClientSTA, ucACMask, i);
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307409 /*You make an initial assumption that HDD has no more data and if the
7410 assumption was wrong you reset the flags to their original state
7411 This will prevent from exposing a race condition between checking with HDD
7412 for packets and setting the flags to false*/
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07007413 if ( 0 == ucACMask )
7414 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307415 pClientSTA->ucNoMoreData = 1;
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07007416 }
7417 else
7418 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307419 vos_atomic_set_U8( &pClientSTA->ucPktPending, 1);
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07007420 }
7421
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07007422
Madan Mohan Koyyalamudid93f4942012-10-05 15:05:40 -07007423 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07007424 "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 +05307425 ucAC, ucACMask, pClientSTA->ucPktPending);
Jeff Johnson295189b2012-06-20 16:38:30 -07007426
7427 /*------------------------------------------------------------------------
7428 Fetch tx packet from HDD
7429 ------------------------------------------------------------------------*/
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07007430
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307431 vosStatus = pClientSTA->pfnSTAFetchPkt( pvosGCtx,
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07007432 &ucSTAId,
7433 ucAC,
7434 &vosDataBuff, &tlMetaInfo );
Jeff Johnson295189b2012-06-20 16:38:30 -07007435
7436 if (( VOS_STATUS_SUCCESS != vosStatus ) || ( NULL == vosDataBuff ))
7437 {
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07007438 TLLOG1(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -07007439 "WLAN TL:No more data at HDD status %d", vosStatus));
7440 *pvosDataBuff = NULL;
7441
7442 /*--------------------------------------------------------------------
7443 Reset AC for the serviced station to the highest priority AC
7444 -> due to no more data at the station
7445 Even if this AC is not supported by the station, correction will be
7446 made in the main TL loop
7447 --------------------------------------------------------------------*/
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05307448 pClientSTA->ucCurrentAC = WLANTL_AC_HIGH_PRIO;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307449 pClientSTA->ucCurrentWeight = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07007450
Madan Mohan Koyyalamudid8000342012-11-08 14:55:26 -08007451 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07007452 "WLAN TL: WLANTL_STATxConn no more packets in HDD for AC: %d AC Mask: %d",
7453 ucAC, ucACMask);
7454
Jeff Johnson295189b2012-06-20 16:38:30 -07007455 return vosStatus;
7456 }
7457
7458 /*There are still packets in HDD - set back the pending packets and
7459 the no more data assumption*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307460 vos_atomic_set_U8( &pClientSTA->ucPktPending, 1);
7461 pClientSTA->ucNoMoreData = 0;
7462 pClientSTA->aucACMask[ucAC] = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07007463
Jeff Johnson295189b2012-06-20 16:38:30 -07007464#ifdef WLAN_PERF
7465 vos_pkt_set_user_data_ptr( vosDataBuff, VOS_PKT_USER_DATA_ID_BAL,
7466 (v_PVOID_t)0);
7467
7468#endif /*WLAN_PERF*/
7469
7470
7471#ifdef FEATURE_WLAN_WAPI
7472 /*------------------------------------------------------------------------
7473 If the packet is neither an Eapol packet nor a WAI packet then drop it
7474 ------------------------------------------------------------------------*/
7475 if ( 0 == tlMetaInfo.ucIsEapol && 0 == tlMetaInfo.ucIsWai )
7476 {
Madan Mohan Koyyalamudid93f4942012-10-05 15:05:40 -07007477 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -07007478 "WLAN TL:Only EAPOL or WAI packets allowed before authentication"));
7479
7480 /* Fail tx for packet */
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307481 pClientSTA->pfnSTATxComp( pvosGCtx, vosDataBuff,
Jeff Johnson295189b2012-06-20 16:38:30 -07007482 VOS_STATUS_E_BADMSG);
7483 vosDataBuff = NULL;
7484 *pvosDataBuff = NULL;
7485 return VOS_STATUS_SUCCESS;
7486 }
7487#else
7488 if ( 0 == tlMetaInfo.ucIsEapol )
7489 {
7490 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
7491 "WLAN TL:Received non EAPOL packet before authentication"));
7492
7493 /* Fail tx for packet */
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307494 pClientSTA->pfnSTATxComp( pvosGCtx, vosDataBuff,
Jeff Johnson295189b2012-06-20 16:38:30 -07007495 VOS_STATUS_E_BADMSG);
7496 vosDataBuff = NULL;
7497 *pvosDataBuff = NULL;
7498 return VOS_STATUS_SUCCESS;
7499 }
7500#endif /* FEATURE_WLAN_WAPI */
7501
7502 /*-------------------------------------------------------------------------
7503 Check TID
7504 -------------------------------------------------------------------------*/
7505 ucTid = tlMetaInfo.ucTID;
7506
7507 /*Make sure TID is valid*/
7508 if ( WLANTL_TID_INVALID(ucTid))
7509 {
Rajesh Chauhan2df40bf2013-08-22 11:26:12 -07007510 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
Jeff Johnson295189b2012-06-20 16:38:30 -07007511 "WLAN TL:Invalid TID sent in meta info %d - defaulting to 0 (BE)",
7512 ucTid));
7513 ucTid = 0;
7514 }
7515
7516 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
7517 "WLAN TL:Attaching BD header to pkt on WLANTL_STATxConn"));
7518
7519#ifdef FEATURE_WLAN_WAPI
7520 /*------------------------------------------------------------------------
7521 Translate 802.3 frame to 802.11 if Frame translation is enabled or if
7522 frame is a WAI frame.
7523 ------------------------------------------------------------------------*/
7524 if ( ( 1 == tlMetaInfo.ucIsWai ) ||
7525 ( 0 == tlMetaInfo.ucDisableFrmXtl ) )
7526#else
7527 /*------------------------------------------------------------------------
7528 Translate 802.3 frame to 802.11 if Frame translation is enabled
7529 ------------------------------------------------------------------------*/
7530 if ( ( 0 == tlMetaInfo.ucDisableFrmXtl ) &&
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307531 ( 0 != pClientSTA->wSTADesc.ucSwFrameTXXlation) )
Jeff Johnson295189b2012-06-20 16:38:30 -07007532#endif //#ifdef FEATURE_WLAN_WAPI
7533 {
Kiran Venkatappacab0d352012-12-17 13:09:22 -08007534 vosStatus = WLANTL_Translate8023To80211Header( vosDataBuff, &vosStatus,
7535 pTLCb, &ucSTAId,
Ravi Joshid0699502013-07-08 15:48:47 -07007536 &tlMetaInfo, &ucWDSEnabled,
7537 &extraHeadSpace);
Jeff Johnson295189b2012-06-20 16:38:30 -07007538 if ( VOS_STATUS_SUCCESS != vosStatus )
7539 {
7540 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7541 "WLAN TL:Error when translating header WLANTL_STATxConn"));
7542
7543 return vosStatus;
7544 }
7545
7546 tlMetaInfo.ucDisableFrmXtl = 1;
7547 }
7548
7549 /*-------------------------------------------------------------------------
7550 Call HAL to fill BD header
7551 -------------------------------------------------------------------------*/
7552 ucTypeSubtype |= (WLANTL_80211_DATA_TYPE << 4);
7553
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307554 if ( pClientSTA->wSTADesc.ucQosEnabled )
Jeff Johnson295189b2012-06-20 16:38:30 -07007555 {
7556 ucTypeSubtype |= (WLANTL_80211_DATA_QOS_SUBTYPE);
7557 }
7558
Gopichand Nakkala8b54e912013-03-11 10:44:21 +05307559#ifdef FEATURE_WLAN_WAPI
7560 /* TL State does not transition to AUTHENTICATED till GTK is installed, So in
7561 * case of WPA where GTK handshake is done after the 4 way handshake, the
7562 * unicast 2/2 EAPOL packet from the STA->AP has to be encrypted even before
7563 * the TL is in authenticated state. Since the PTK has been installed
7564 * already (after the 4 way handshake) we make sure that all traffic
7565 * is encrypted henceforth.(Note: TL is still not in AUTHENTICATED state so
7566 * we will only allow EAPOL data or WAI in case of WAPI)
7567 */
7568 if (tlMetaInfo.ucIsEapol && pClientSTA->ptkInstalled)
7569 {
7570 txFlag = 0;
7571 }
7572#else
7573 if (pClientSTA->ptkInstalled)
7574 {
7575 txFlag = 0;
7576 }
7577#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007578
7579 vosStatus = (VOS_STATUS)WDA_DS_BuildTxPacketInfo( pvosGCtx, vosDataBuff , &vDestMacAddr,
7580 tlMetaInfo.ucDisableFrmXtl, &usPktLen,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307581 pClientSTA->wSTADesc.ucQosEnabled, ucWDSEnabled,
Jeff Johnson295189b2012-06-20 16:38:30 -07007582 extraHeadSpace,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307583 ucTypeSubtype, &pClientSTA->wSTADesc.vSelfMACAddress,
Gopichand Nakkala8b54e912013-03-11 10:44:21 +05307584 ucTid, txFlag,
Ganesh Kondabattini10e67352015-03-16 17:41:57 +05307585 tlMetaInfo.usTimeStamp, tlMetaInfo.ucIsEapol || tlMetaInfo.ucIsWai, tlMetaInfo.ucUP,
7586 tlMetaInfo.ucTxBdToken);
Jeff Johnson295189b2012-06-20 16:38:30 -07007587
7588 if ( VOS_STATUS_SUCCESS != vosStatus )
7589 {
7590 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7591 "WLAN TL:Failed while attempting to fill BD %d", vosStatus));
7592 *pvosDataBuff = NULL;
7593 return vosStatus;
7594 }
7595
7596 /*-----------------------------------------------------------------------
7597 Update tx counter for BA session query for tx side
7598 !1 - should this be done for EAPOL frames?
7599 -----------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307600 pClientSTA->auTxCount[ucTid]++;
Jeff Johnson295189b2012-06-20 16:38:30 -07007601
7602 vos_pkt_set_user_data_ptr( vosDataBuff, VOS_PKT_USER_DATA_ID_TL,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307603 (v_PVOID_t)pClientSTA->pfnSTATxComp );
Jeff Johnson295189b2012-06-20 16:38:30 -07007604
7605 /*------------------------------------------------------------------------
7606 Save data to input pointer for TL core
7607 ------------------------------------------------------------------------*/
7608 *pvosDataBuff = vosDataBuff;
7609 /*security frames cannot be delayed*/
7610 pTLCb->bUrgent = TRUE;
7611
Jeff Johnson295189b2012-06-20 16:38:30 -07007612 /* TX Statistics */
7613 if (!(tlMetaInfo.ucBcast || tlMetaInfo.ucMcast))
7614 {
7615 /* This is TX UC frame */
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307616 pClientSTA->trafficStatistics.txUCFcnt++;
7617 pClientSTA->trafficStatistics.txUCBcnt += usPktLen;
Jeff Johnson295189b2012-06-20 16:38:30 -07007618 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007619
7620 return VOS_STATUS_SUCCESS;
7621}/* WLANTL_STATxConn */
7622
7623
7624/*==========================================================================
7625 FUNCTION WLANTL_STATxAuth
7626
7627 DESCRIPTION
7628 Transmit in authenticated state - all data allowed
7629
7630 DEPENDENCIES
7631 The STA must be registered with TL before this function can be called.
7632
7633 PARAMETERS
7634
7635 IN
7636 pvosGCtx: pointer to the global vos context; a handle to TL's
7637 control block can be extracted from its context
7638 ucSTAId: identifier of the station being processed
7639 vosDataBuff: pointer to the tx vos buffer
7640
7641 RETURN VALUE
7642 The result code associated with performing the operation
7643
7644 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
7645 page fault
7646 VOS_STATUS_SUCCESS: Everything is good :)
7647
7648 Other return values are possible coming from the called functions.
7649 Please check API for additional info.
7650
7651 SIDE EFFECTS
7652
7653============================================================================*/
7654VOS_STATUS
7655WLANTL_STATxAuth
7656(
7657 v_PVOID_t pvosGCtx,
7658 v_U8_t ucSTAId,
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07007659 vos_pkt_t** pvosDataBuff,
7660 v_BOOL_t bForwardIAPPwithLLC
Jeff Johnson295189b2012-06-20 16:38:30 -07007661)
7662{
7663 v_U16_t usPktLen;
7664 VOS_STATUS vosStatus;
7665 v_MACADDR_t vDestMacAddr;
7666 vos_pkt_t* vosDataBuff = NULL;
7667 WLANTL_CbType* pTLCb = NULL;
7668 WLANTL_MetaInfoType tlMetaInfo;
7669 v_U8_t ucTypeSubtype = 0;
7670 WLANTL_ACEnumType ucAC;
7671 WLANTL_ACEnumType ucNextAC;
7672 v_U8_t ucTid;
7673 v_U8_t ucSwFrmXtl = 0;
7674 v_U8_t extraHeadSpace = 0;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307675 WLANTL_STAClientType *pStaClient = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07007676 v_U8_t ucWDSEnabled = 0;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05307677 v_U32_t ucTxFlag = 0;
Abhishek Singh45e68fe2014-12-11 12:55:59 +05307678 v_U8_t ucACMask, i;
Jeff Johnson295189b2012-06-20 16:38:30 -07007679 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
7680
7681 /*------------------------------------------------------------------------
7682 Sanity check
7683 Extract TL control block
7684 ------------------------------------------------------------------------*/
7685 pTLCb = VOS_GET_TL_CB(pvosGCtx);
7686 if (( NULL == pTLCb ) || ( NULL == pvosDataBuff ))
7687 {
7688 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson0298bd02013-11-14 19:58:38 -08007689 "WLAN TL:Invalid input params on WLANTL_STATxAuth TL %p DB %p",
Jeff Johnson295189b2012-06-20 16:38:30 -07007690 pTLCb, pvosDataBuff));
7691 if (NULL != pvosDataBuff)
7692 {
7693 *pvosDataBuff = NULL;
7694 }
7695 if(NULL != pTLCb)
7696 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307697 if ( NULL == pTLCb->atlSTAClients[ucSTAId] )
7698 {
7699 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7700 "WLAN TL:Client Memory was not allocated on %s", __func__));
7701 return VOS_STATUS_E_FAILURE;
7702 }
7703 pTLCb->atlSTAClients[ucSTAId]->ucNoMoreData = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07007704 }
7705 return VOS_STATUS_E_FAULT;
7706 }
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307707 pStaClient = pTLCb->atlSTAClients[ucSTAId];
Jeff Johnson295189b2012-06-20 16:38:30 -07007708
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307709 if ( NULL == pStaClient )
7710 {
7711 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7712 "WLAN TL:Client Memory was not allocated on %s", __func__));
7713 return VOS_STATUS_E_FAILURE;
7714 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007715
7716 vos_mem_zero(&tlMetaInfo, sizeof(tlMetaInfo));
7717 /*------------------------------------------------------------------------
7718 Fetch packet from HDD
7719 ------------------------------------------------------------------------*/
Sunil Ravid5406f22013-01-22 00:18:31 -08007720#ifdef FEATURE_WLAN_TDLS
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307721 if ((WLAN_STA_SOFTAP != pStaClient->wSTADesc.wSTAType) &&
Agarwal Ashishcd86f7b2014-06-16 17:11:58 +05307722 (!vos_concurrent_open_sessions_running()) &&
Sunil Ravid5406f22013-01-22 00:18:31 -08007723 !pTLCb->ucTdlsPeerCount)
7724 {
7725#else
Jeff Johnson295189b2012-06-20 16:38:30 -07007726 if ((WLAN_STA_SOFTAP != pStaClient->wSTADesc.wSTAType) &&
Agarwal Ashishcd86f7b2014-06-16 17:11:58 +05307727 (!vos_concurrent_open_sessions_running()))
Jeff Johnson295189b2012-06-20 16:38:30 -07007728 {
7729#endif
7730 ucAC = pStaClient->ucCurrentAC;
7731
7732 /*-------------------------------------------------------------------
7733 Disable AC temporary - if successfull retrieve re-enable
7734 The order is justified because of the possible scenario
7735 - TL tryes to fetch packet for AC and it returns NULL
7736 - TL analyzes the data it has received to see if there are
7737 any more pkts available for AC -> if not TL will disable AC
7738 - however it is possible that while analyzing results TL got
7739 preempted by a pending indication where the mask was again set
7740 TL will not check again and as a result when it resumes
7741 execution it will disable AC
7742 To prevent this the AC will be disabled here and if retrieve
7743 is successfull it will be re-enabled
7744 -------------------------------------------------------------------*/
7745 pStaClient->aucACMask[pStaClient->ucCurrentAC] = 0;
7746
7747 // don't reset it, as other AC queues in HDD may have packets
7748 //vos_atomic_set_U8( &pStaClient->ucPktPending, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07007749 }
7750 else
7751 {
7752 //softap case
7753 ucAC = pTLCb->uCurServedAC;
7754 pStaClient->aucACMask[ucAC] = 0;
7755
7756 //vos_atomic_set_U8( &pStaClient->ucPktPending, 0);
7757 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007758
7759 WLAN_TL_AC_ARRAY_2_MASK( pStaClient, ucACMask, i);
Jeff Johnson295189b2012-06-20 16:38:30 -07007760 /*You make an initial assumption that HDD has no more data and if the
7761 assumption was wrong you reset the flags to their original state
7762 This will prevent from exposing a race condition between checking with HDD
7763 for packets and setting the flags to false*/
7764 if ( 0 == ucACMask )
7765 {
7766 vos_atomic_set_U8( &pStaClient->ucPktPending, 0);
7767 pStaClient->ucNoMoreData = 1;
7768 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007769
7770 vosStatus = pStaClient->pfnSTAFetchPkt( pvosGCtx,
7771 &ucSTAId,
7772 ucAC,
7773 &vosDataBuff, &tlMetaInfo );
7774
7775
7776 if (( VOS_STATUS_SUCCESS != vosStatus ) || ( NULL == vosDataBuff ))
7777 {
7778
7779 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05307780 "WLAN TL:Failed while attempting to fetch pkt from HDD QId:%d status:%d",
7781 ucAC, vosStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07007782 *pvosDataBuff = NULL;
7783 /*--------------------------------------------------------------------
7784 Reset AC for the serviced station to the highest priority AC
7785 -> due to no more data at the station
7786 Even if this AC is not supported by the station, correction will be
7787 made in the main TL loop
7788 --------------------------------------------------------------------*/
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05307789 pStaClient->ucCurrentAC = WLANTL_AC_HIGH_PRIO;
Jeff Johnson295189b2012-06-20 16:38:30 -07007790 pStaClient->ucCurrentWeight = 0;
7791
7792 return vosStatus;
7793 }
7794
Jeff Johnsone7245742012-09-05 17:12:55 -07007795 WLANTL_StatHandleTXFrame(pvosGCtx, ucSTAId, vosDataBuff, NULL, &tlMetaInfo);
Jeff Johnsone7245742012-09-05 17:12:55 -07007796
Jeff Johnson295189b2012-06-20 16:38:30 -07007797 /*There are still packets in HDD - set back the pending packets and
7798 the no more data assumption*/
7799 vos_atomic_set_U8( &pStaClient->ucPktPending, 1);
7800 pStaClient->ucNoMoreData = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07007801
Jeff Johnson295189b2012-06-20 16:38:30 -07007802 if (WLAN_STA_SOFTAP != pStaClient->wSTADesc.wSTAType)
7803 {
Jeff Johnson295189b2012-06-20 16:38:30 -07007804 // don't need to set it, as we don't reset it in this function.
7805 //vos_atomic_set_U8( &pTLCb->atlSTAClients[ucSTAId].ucPktPending, 1);
Jeff Johnson295189b2012-06-20 16:38:30 -07007806 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007807
7808#ifdef WLAN_PERF
7809 vos_pkt_set_user_data_ptr( vosDataBuff, VOS_PKT_USER_DATA_ID_BAL,
7810 (v_PVOID_t)0);
7811#endif /*WLAN_PERF*/
7812
7813 /*-------------------------------------------------------------------------
7814 Check TID
7815 -------------------------------------------------------------------------*/
7816 ucTid = tlMetaInfo.ucTID;
7817
7818 /*Make sure TID is valid*/
7819 if ( WLANTL_TID_INVALID(ucTid))
7820 {
Rajesh Chauhan2df40bf2013-08-22 11:26:12 -07007821 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
Jeff Johnson295189b2012-06-20 16:38:30 -07007822 "WLAN TL:Invalid TID sent in meta info %d - defaulting to 0 (BE)",
7823 ucTid));
7824 ucTid = 0;
7825 }
7826
7827 /*Save for UAPSD timer consideration*/
7828 pStaClient->ucServicedAC = ucAC;
7829
7830 if ( ucAC == pStaClient->ucCurrentAC )
7831 {
7832 pStaClient->aucACMask[pStaClient->ucCurrentAC] = 1;
7833 pStaClient->ucCurrentWeight--;
7834 }
7835 else
7836 {
7837 pStaClient->ucCurrentAC = ucAC;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307838 pStaClient->ucCurrentWeight = pTLCb->tlConfigInfo.ucAcWeights[ucAC] - 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07007839
7840 pStaClient->aucACMask[pStaClient->ucCurrentAC] = 1;
7841
7842 }
7843
Jeff Johnson295189b2012-06-20 16:38:30 -07007844 if (WLAN_STA_SOFTAP != pStaClient->wSTADesc.wSTAType)
7845 {
Jeff Johnson295189b2012-06-20 16:38:30 -07007846 if ( 0 == pStaClient->ucCurrentWeight )
7847 {
7848 WLANTL_ACEnumType tempAC = ucAC;
7849 /*-----------------------------------------------------------------------
7850 Choose next AC - !!! optimize me
7851 -----------------------------------------------------------------------*/
7852 while ( 0 != ucACMask )
7853 {
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05307854 if(tempAC == WLANTL_AC_BK)
7855 ucNextAC = WLANTL_AC_HIGH_PRIO;
7856 else
7857 ucNextAC = (tempAC - 1);
7858
Jeff Johnson295189b2012-06-20 16:38:30 -07007859 if ( 0 != pStaClient->aucACMask[ucNextAC] )
7860 {
7861 pStaClient->ucCurrentAC = ucNextAC;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307862 pStaClient->ucCurrentWeight = pTLCb->tlConfigInfo.ucAcWeights[ucNextAC];
Jeff Johnson295189b2012-06-20 16:38:30 -07007863
7864 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
7865 "WLAN TL: Changing serviced AC to: %d with Weight: %d",
7866 pStaClient->ucCurrentAC ,
7867 pStaClient->ucCurrentWeight));
7868 break;
7869 }
7870 tempAC = ucNextAC;
7871 }
7872 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007873 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007874
7875 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
7876 "WLAN TL:Attaching BD header to pkt on WLANTL_STATxAuth"));
7877
7878 /*------------------------------------------------------------------------
7879 Translate 802.3 frame to 802.11
7880 ------------------------------------------------------------------------*/
7881 if ( 0 == tlMetaInfo.ucDisableFrmXtl )
7882 {
7883 /* Needs frame translation */
7884 // if the client has not enabled SW-only frame translation
7885 // and if the frame is a unicast frame
7886 // (HW frame translation does not support multiple broadcast domains
7887 // so we use SW frame translation for broadcast/multicast frames)
7888#ifdef FEATURE_WLAN_WAPI
7889 // and if the frame is not a WAPI frame
7890#endif
7891 // then use HW_based frame translation
7892
7893 if ( ( 0 == pStaClient->wSTADesc.ucSwFrameTXXlation ) &&
7894 ( 0 == tlMetaInfo.ucBcast ) &&
7895 ( 0 == tlMetaInfo.ucMcast )
7896#ifdef FEATURE_WLAN_WAPI
7897 && ( tlMetaInfo.ucIsWai != 1 )
7898#endif
7899 )
7900 {
7901#ifdef WLAN_PERF
7902 v_U32_t uFastFwdOK = 0;
7903
7904 /* HW based translation. See if the frame could be fast forwarded */
7905 WDA_TLI_FastHwFwdDataFrame( pvosGCtx, vosDataBuff , &vosStatus,
7906 &uFastFwdOK, &tlMetaInfo, &pStaClient->wSTADesc);
7907
7908 if( VOS_STATUS_SUCCESS == vosStatus )
7909 {
7910 if(uFastFwdOK)
7911 {
7912 /* Packet could be fast forwarded now */
7913 vos_pkt_set_user_data_ptr( vosDataBuff, VOS_PKT_USER_DATA_ID_TL,
7914 (v_PVOID_t)pStaClient->pfnSTATxComp );
7915
7916 *pvosDataBuff = vosDataBuff;
7917
7918 /* TODO: Do we really need to update WLANTL_HSHandleTXFrame()
7919 stats for every pkt? */
7920 pStaClient->auTxCount[tlMetaInfo.ucTID]++;
7921 return vosStatus;
7922 }
7923 /* can't be fast forwarded, fall through normal (slow) path. */
7924 }
7925 else
7926 {
7927
7928 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7929 "WLAN TL:Failed while attempting to fastFwd BD %d", vosStatus));
7930 *pvosDataBuff = NULL;
7931 return vosStatus;
7932 }
7933#endif /*WLAN_PERF*/
7934 }
7935 else
7936 {
7937 /* SW based translation */
7938
7939#ifdef FEATURE_WLAN_WAPI
7940 gUcIsWai = tlMetaInfo.ucIsWai,
7941#endif
7942
Kiran Venkatappacab0d352012-12-17 13:09:22 -08007943 vosStatus = WLANTL_Translate8023To80211Header( vosDataBuff, &vosStatus,
7944 pTLCb, &ucSTAId,
Ravi Joshid0699502013-07-08 15:48:47 -07007945 &tlMetaInfo, &ucWDSEnabled,
7946 &extraHeadSpace);
Jeff Johnson295189b2012-06-20 16:38:30 -07007947 if ( VOS_STATUS_SUCCESS != vosStatus )
7948 {
7949 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7950 "WLAN TL:Error when translating header WLANTL_STATxAuth"));
7951 return vosStatus;
7952 }
7953
7954 TLLOG4(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_LOW,
Arif Hussainf2b00992013-11-17 21:46:15 -08007955 "WLAN TL software translation success"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007956 ucSwFrmXtl = 1;
7957 tlMetaInfo.ucDisableFrmXtl = 1;
7958 }
7959 }
Gopichand Nakkala574f6d12013-06-27 19:38:43 +05307960#ifdef FEATURE_WLAN_TDLS
7961 /*In case of TDLS, if the packet is destined to TDLS STA ucSTAId may
7962 change. so update the pStaClient accordingly */
7963 pStaClient = pTLCb->atlSTAClients[ucSTAId];
Jeff Johnson295189b2012-06-20 16:38:30 -07007964
Gopichand Nakkala574f6d12013-06-27 19:38:43 +05307965 if ( NULL == pStaClient )
7966 {
7967 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7968 "pStaClient is NULL %s", __func__));
7969 return VOS_STATUS_E_FAILURE;
7970 }
7971#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007972 /*-------------------------------------------------------------------------
7973 Call HAL to fill BD header
7974 -------------------------------------------------------------------------*/
7975 ucTypeSubtype |= (WLANTL_80211_DATA_TYPE << 4);
7976
7977 if ( pStaClient->wSTADesc.ucQosEnabled )
7978 {
7979 ucTypeSubtype |= (WLANTL_80211_DATA_QOS_SUBTYPE);
7980 }
7981
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05307982 /* ucAC now points to TL Q ID with a new queue added in TL,
7983 * hence look for the uapsd info for the correct AC that
7984 * this packet belongs to.
7985 */
7986 ucTxFlag = (0 != pStaClient->wUAPSDInfo[tlMetaInfo.ac].ucSet)?
Jeff Johnson295189b2012-06-20 16:38:30 -07007987 HAL_TRIGGER_ENABLED_AC_MASK:0;
7988
7989#ifdef FEATURE_WLAN_WAPI
7990 if ( pStaClient->wSTADesc.ucIsWapiSta == 1 )
7991 {
7992#ifdef LIBRA_WAPI_SUPPORT
7993 ucTxFlag = ucTxFlag | HAL_WAPI_STA_MASK;
7994#endif //LIBRA_WAPI_SUPPORT
7995 if ( tlMetaInfo.ucIsWai == 1 )
7996 {
7997 ucTxFlag = ucTxFlag | HAL_TX_NO_ENCRYPTION_MASK;
7998 }
7999 }
8000#endif /* FEATURE_WLAN_WAPI */
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008001#ifdef FEATURE_WLAN_TDLS
8002 if ( pStaClient->wSTADesc.wSTAType == WLAN_STA_TDLS )
8003 {
8004 ucTxFlag = ucTxFlag | HAL_TDLS_PEER_STA_MASK;
8005 }
8006#endif /* FEATURE_WLAN_TDLS */
Abhishek Singhfa011222014-04-14 10:57:08 +05308007 if( tlMetaInfo.ucIsArp )
8008 {
8009 /*Send ARP at lowest Phy rate and through WQ5 */
8010 ucTxFlag |= HAL_USE_BD_RATE_MASK;
Abhishek Singhfa011222014-04-14 10:57:08 +05308011 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008012
8013 vosStatus = (VOS_STATUS)WDA_DS_BuildTxPacketInfo( pvosGCtx,
8014 vosDataBuff , &vDestMacAddr,
8015 tlMetaInfo.ucDisableFrmXtl, &usPktLen,
8016 pStaClient->wSTADesc.ucQosEnabled, ucWDSEnabled,
8017 extraHeadSpace,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308018 ucTypeSubtype, &pStaClient->wSTADesc.vSelfMACAddress,
Jeff Johnson295189b2012-06-20 16:38:30 -07008019 ucTid, ucTxFlag, tlMetaInfo.usTimeStamp,
Ganesh Kondabattini10e67352015-03-16 17:41:57 +05308020 tlMetaInfo.ucIsEapol, tlMetaInfo.ucUP,
8021 tlMetaInfo.ucTxBdToken);
Jeff Johnson295189b2012-06-20 16:38:30 -07008022
8023 if(!VOS_IS_STATUS_SUCCESS(vosStatus))
8024 {
8025 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8026 "Fill TX BD Error status %d", vosStatus));
8027
8028 return vosStatus;
8029 }
8030
Jeff Johnson295189b2012-06-20 16:38:30 -07008031 /* TX Statistics */
8032 if (!(tlMetaInfo.ucBcast || tlMetaInfo.ucMcast))
8033 {
8034 /* This is TX UC frame */
8035 pStaClient->trafficStatistics.txUCFcnt++;
8036 pStaClient->trafficStatistics.txUCBcnt += usPktLen;
8037 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008038
Kiran Venkatappacab0d352012-12-17 13:09:22 -08008039#ifndef FEATURE_WLAN_TDLS
Jeff Johnson295189b2012-06-20 16:38:30 -07008040 /*-----------------------------------------------------------------------
8041 Update tx counter for BA session query for tx side
8042 -----------------------------------------------------------------------*/
8043 pStaClient->auTxCount[ucTid]++;
Kiran Venkatappacab0d352012-12-17 13:09:22 -08008044#else
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308045 pTLCb->atlSTAClients[ucSTAId]->auTxCount[ucTid]++;
Kiran Venkatappacab0d352012-12-17 13:09:22 -08008046#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07008047
8048 /* This code is to send traffic with lower priority AC when we does not
8049 get admitted to send it. Today HAL does not downgrade AC so this code
8050 does not get executed.(In other words, HAL doesnÂ’t change tid. The if
8051 statement is always false.)
8052 NOTE: In the case of LA downgrade occurs in HDD (that was the change
8053 Phani made during WMM-AC plugfest). If WM & BMP also took this approach,
8054 then there will be no need for any AC downgrade logic in TL/WDI. */
8055#if 0
8056 if (( ucTid != tlMetaInfo.ucTID ) &&
8057 ( 0 != pStaClient->wSTADesc.ucQosEnabled ) &&
8058 ( 0 != ucSwFrmXtl ))
8059 {
8060 /*---------------------------------------------------------------------
8061 !! FIX me: Once downgrading is clear put in the proper change
8062 ---------------------------------------------------------------------*/
8063 ucQCOffset = WLANHAL_TX_BD_HEADER_SIZE + WLANTL_802_11_HEADER_LEN;
8064
8065 //!!!Fix this replace peek with extract
8066 vos_pkt_peek_data( vosDataBuff, ucQCOffset,(v_PVOID_t)&pucQosCtrl,
8067 sizeof(*pucQosCtrl));
8068 *pucQosCtrl = ucTid; //? proper byte order
8069 }
8070#endif
8071
8072 if ( VOS_STATUS_SUCCESS != vosStatus )
8073 {
8074 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8075 "WLAN TL:Failed while attempting to fill BD %d", vosStatus));
8076 *pvosDataBuff = NULL;
8077 return vosStatus;
8078 }
8079
8080 vos_pkt_set_user_data_ptr( vosDataBuff, VOS_PKT_USER_DATA_ID_TL,
8081 (v_PVOID_t)pStaClient->pfnSTATxComp );
8082
8083 *pvosDataBuff = vosDataBuff;
8084
8085 /*BE & BK can be delayed, VO and VI not frames cannot be delayed*/
8086 if ( pStaClient->ucServicedAC > WLANTL_AC_BE )
8087 {
8088 pTLCb->bUrgent= TRUE;
8089 }
8090
8091 return VOS_STATUS_SUCCESS;
8092}/* WLANTL_STATxAuth */
8093
8094/*==========================================================================
8095 FUNCTION WLANTL_STATxDisc
8096
8097 DESCRIPTION
8098 Transmit in disconnected state - no data allowed
8099
8100 DEPENDENCIES
8101 The STA must be registered with TL before this function can be called.
8102
8103 PARAMETERS
8104
8105 IN
8106 pvosGCtx: pointer to the global vos context; a handle to TL's
8107 control block can be extracted from its context
8108 ucSTAId: identifier of the station being processed
8109 vosDataBuff: pointer to the tx vos buffer
8110
8111 RETURN VALUE
8112 The result code associated with performing the operation
8113
8114 VOS_STATUS_SUCCESS: Everything is good :)
8115
8116 SIDE EFFECTS
8117
8118============================================================================*/
8119VOS_STATUS
8120WLANTL_STATxDisc
8121(
8122 v_PVOID_t pvosGCtx,
8123 v_U8_t ucSTAId,
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07008124 vos_pkt_t** pvosDataBuff,
8125 v_BOOL_t bForwardIAPPwithLLC
Jeff Johnson295189b2012-06-20 16:38:30 -07008126)
8127{
8128 WLANTL_CbType* pTLCb = NULL;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308129 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07008130 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
8131
Jeff Johnson295189b2012-06-20 16:38:30 -07008132 /*------------------------------------------------------------------------
8133 Sanity check
8134 Extract TL control block
8135 ------------------------------------------------------------------------*/
8136 pTLCb = VOS_GET_TL_CB(pvosGCtx);
8137 if ( NULL == pTLCb )
8138 {
8139 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8140 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_STATxAuth"));
8141 *pvosDataBuff = NULL;
8142 return VOS_STATUS_E_FAULT;
8143 }
8144
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308145 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
8146
8147 if ( NULL == pClientSTA )
8148 {
8149 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8150 "WLAN TL:Client Memory was not allocated on %s", __func__));
8151 return VOS_STATUS_E_FAILURE;
8152 }
8153
Jeff Johnson295189b2012-06-20 16:38:30 -07008154 /*------------------------------------------------------------------------
8155 Error
8156 ------------------------------------------------------------------------*/
8157 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
8158 "WLAN TL:Packet should not be transmitted in state disconnected ignoring"
8159 " request"));
8160
8161 *pvosDataBuff = NULL;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308162 pClientSTA->ucNoMoreData = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07008163
8164 //Should not be anything pending in disconnect state
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308165 vos_atomic_set_U8( &pClientSTA->ucPktPending, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07008166
8167 return VOS_STATUS_SUCCESS;
8168}/* WLANTL_STATxDisc */
8169
8170/*==========================================================================
8171 FUNCTION WLANTL_STARxConn
8172
8173 DESCRIPTION
8174 Receive in connected state - only EAPOL
8175
8176 DEPENDENCIES
8177 The STA must be registered with TL before this function can be called.
8178
8179 PARAMETERS
8180
8181 IN
8182 pvosGCtx: pointer to the global vos context; a handle to TL's
8183 control block can be extracted from its context
8184 ucSTAId: identifier of the station being processed
8185 vosDataBuff: pointer to the tx/rx vos buffer
8186
8187 RETURN VALUE
8188 The result code associated with performing the operation
8189
8190 VOS_STATUS_E_INVAL: invalid input parameters
8191 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
8192 page fault
8193 VOS_STATUS_SUCCESS: Everything is good :)
8194
8195 SIDE EFFECTS
8196
8197============================================================================*/
8198VOS_STATUS
8199WLANTL_STARxConn
8200(
8201 v_PVOID_t pvosGCtx,
8202 v_U8_t ucSTAId,
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07008203 vos_pkt_t** pvosDataBuff,
8204 v_BOOL_t bForwardIAPPwithLLC
Jeff Johnson295189b2012-06-20 16:38:30 -07008205)
8206{
8207 WLANTL_CbType* pTLCb = NULL;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308208 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07008209 v_U16_t usEtherType = 0;
8210 v_U16_t usPktLen;
8211 v_U8_t ucMPDUHOffset;
8212 v_U16_t usMPDUDOffset;
8213 v_U16_t usMPDULen;
8214 v_U8_t ucMPDUHLen;
8215 v_U16_t usActualHLen = 0;
8216 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
8217 vos_pkt_t* vosDataBuff;
8218 v_PVOID_t aucBDHeader;
8219 v_U8_t ucTid;
8220 WLANTL_RxMetaInfoType wRxMetaInfo;
8221 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
8222
8223 /*------------------------------------------------------------------------
8224 Sanity check
8225 ------------------------------------------------------------------------*/
8226 if (( NULL == pvosDataBuff ) || ( NULL == ( vosDataBuff = *pvosDataBuff )))
8227 {
8228 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8229 "WLAN TL:Invalid parameter sent on WLANTL_STARxConn"));
8230 return VOS_STATUS_E_INVAL;
8231 }
8232
8233 /*------------------------------------------------------------------------
8234 Extract TL control block
8235 ------------------------------------------------------------------------*/
8236 pTLCb = VOS_GET_TL_CB(pvosGCtx);
8237 if ( NULL == pTLCb )
8238 {
8239 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8240 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_ChangeSTAState"));
8241 return VOS_STATUS_E_FAULT;
8242 }
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308243 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
8244
8245 if ( NULL == pClientSTA )
8246 {
8247 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8248 "WLAN TL:Client Memory was not allocated on %s", __func__));
8249 return VOS_STATUS_E_FAILURE;
8250 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008251
8252 /*------------------------------------------------------------------------
8253 Extract BD header and check if valid
8254 ------------------------------------------------------------------------*/
8255 vosStatus = WDA_DS_PeekRxPacketInfo( vosDataBuff, (v_PVOID_t)&aucBDHeader, 0/*Swap BD*/ );
8256
8257 if ( NULL == aucBDHeader )
8258 {
8259 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8260 "WLAN TL:Cannot extract BD header"));
8261 VOS_ASSERT( 0 );
8262 return VOS_STATUS_E_FAULT;
8263 }
8264
8265
8266 ucMPDUHOffset = (v_U8_t)WDA_GET_RX_MPDU_HEADER_OFFSET(aucBDHeader);
8267 usMPDUDOffset = (v_U16_t)WDA_GET_RX_MPDU_DATA_OFFSET(aucBDHeader);
8268 usMPDULen = (v_U16_t)WDA_GET_RX_MPDU_LEN(aucBDHeader);
8269 ucMPDUHLen = (v_U8_t)WDA_GET_RX_MPDU_HEADER_LEN(aucBDHeader);
8270 ucTid = (v_U8_t)WDA_GET_RX_TID(aucBDHeader);
8271
8272 vos_pkt_get_packet_length( vosDataBuff, &usPktLen);
8273
8274 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
8275 "WLAN TL:BD header processing data: HO %d DO %d Len %d HLen %d",
8276 ucMPDUHOffset, usMPDUDOffset, usMPDULen, ucMPDUHLen));
8277
8278 /*It will cut out the 802.11 header if not used*/
8279 if ( VOS_STATUS_SUCCESS != WDA_DS_TrimRxPacketInfo( vosDataBuff ) )
8280 {
8281 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
8282 "WLAN TL:BD header corrupted - dropping packet"));
8283 /* Drop packet */
8284 vos_pkt_return_packet(vosDataBuff);
8285 return VOS_STATUS_SUCCESS;
8286 }
8287
8288 vosStatus = WLANTL_GetEtherType(aucBDHeader,vosDataBuff,ucMPDUHLen,&usEtherType);
8289
8290 if( VOS_IS_STATUS_SUCCESS(vosStatus) )
8291 {
8292#ifdef FEATURE_WLAN_WAPI
8293 /* If frame is neither an EAPOL frame nor a WAI frame then we drop the frame*/
8294 /* TODO: Do we need a check to see if we are in WAPI mode? If not is it possible */
8295 /* that we get an EAPOL packet in WAPI mode or vice versa? */
8296 if ( WLANTL_LLC_8021X_TYPE != usEtherType && WLANTL_LLC_WAI_TYPE != usEtherType )
8297 {
Sunil Ravid5406f22013-01-22 00:18:31 -08008298 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07008299 "WLAN TL:RX Frame not EAPOL or WAI EtherType %d - dropping", usEtherType );
Jeff Johnson295189b2012-06-20 16:38:30 -07008300 /* Drop packet */
8301 vos_pkt_return_packet(vosDataBuff);
8302 }
8303#else
8304 if ( WLANTL_LLC_8021X_TYPE != usEtherType )
8305 {
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07008306 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8307 "WLAN TL:RX Frame not EAPOL EtherType %d - dropping", usEtherType);
Jeff Johnson295189b2012-06-20 16:38:30 -07008308 /* Drop packet */
8309 vos_pkt_return_packet(vosDataBuff);
8310 }
8311#endif /* FEATURE_WLAN_WAPI */
8312 else /* Frame is an EAPOL frame or a WAI frame*/
8313 {
Katya Nigam42e16e82014-02-04 16:28:55 +05308314 MTRACE(vos_trace(VOS_MODULE_ID_TL,
8315 TRACE_CODE_TL_RX_CONN_EAPOL, ucSTAId, usEtherType ));
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07008316
Madan Mohan Koyyalamudid8000342012-11-08 14:55:26 -08008317 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07008318 "WLAN TL:RX Frame EAPOL EtherType %d - processing", usEtherType);
8319
Jeff Johnson295189b2012-06-20 16:38:30 -07008320 if (( 0 == WDA_GET_RX_FT_DONE(aucBDHeader) ) &&
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308321 ( 0 != pClientSTA->wSTADesc.ucSwFrameRXXlation))
Jeff Johnson295189b2012-06-20 16:38:30 -07008322 {
8323 if (usMPDUDOffset > ucMPDUHOffset)
8324 {
8325 usActualHLen = usMPDUDOffset - ucMPDUHOffset;
8326 }
8327
8328 vosStatus = WLANTL_Translate80211To8023Header( vosDataBuff, &vosStatus, usActualHLen,
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07008329 ucMPDUHLen, pTLCb, ucSTAId, bForwardIAPPwithLLC);
Jeff Johnson295189b2012-06-20 16:38:30 -07008330
8331 if ( VOS_STATUS_SUCCESS != vosStatus )
8332 {
Kaushik, Sushante386ee12014-05-01 15:50:52 +05308333 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
Jeff Johnson295189b2012-06-20 16:38:30 -07008334 "WLAN TL:Failed to translate from 802.11 to 802.3 - dropping"));
8335 /* Drop packet */
8336 vos_pkt_return_packet(vosDataBuff);
8337 return vosStatus;
8338 }
8339 }
8340 /*-------------------------------------------------------------------
8341 Increment receive counter
8342 -------------------------------------------------------------------*/
Madan Mohan Koyyalamudic0e5bd82012-09-18 17:12:27 -07008343 if ( !WLANTL_TID_INVALID( ucTid) )
8344 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308345 pClientSTA->auRxCount[ucTid]++;
Madan Mohan Koyyalamudic0e5bd82012-09-18 17:12:27 -07008346 }
8347 else
8348 {
8349 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8350 "WLAN TL:Invalid tid %d (Station ID %d) on %s",
8351 ucTid, ucSTAId, __func__));
8352 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008353
8354 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
8355 "WLAN TL:Sending EAPoL frame to station %d AC %d", ucSTAId, ucTid));
8356
8357 /*-------------------------------------------------------------------
8358 !!!Assuming TID = UP mapping
8359 -------------------------------------------------------------------*/
8360 wRxMetaInfo.ucUP = ucTid;
8361
Jeff Johnson295189b2012-06-20 16:38:30 -07008362 TLLOG4(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_LOW,
Arif Hussainf2b00992013-11-17 21:46:15 -08008363 "WLAN TL %s:Sending data chain to station", __func__));
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308364 if ( WLAN_STA_SOFTAP == pClientSTA->wSTADesc.wSTAType )
Jeff Johnson295189b2012-06-20 16:38:30 -07008365 {
8366 wRxMetaInfo.ucDesSTAId = WLAN_RX_SAP_SELF_STA_ID;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308367 pClientSTA->pfnSTARx( pvosGCtx, vosDataBuff, ucSTAId,
Jeff Johnson295189b2012-06-20 16:38:30 -07008368 &wRxMetaInfo );
8369 }
8370 else
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308371 pClientSTA->pfnSTARx( pvosGCtx, vosDataBuff, ucSTAId,
Jeff Johnson295189b2012-06-20 16:38:30 -07008372 &wRxMetaInfo );
8373 }/*EAPOL frame or WAI frame*/
8374 }/*vos status success*/
8375
8376 return VOS_STATUS_SUCCESS;
8377}/* WLANTL_STARxConn */
8378
Jeff Johnson295189b2012-06-20 16:38:30 -07008379/*==========================================================================
8380 FUNCTION WLANTL_FwdPktToHDD
8381
8382 DESCRIPTION
8383 Determine the Destation Station ID and route the Frame to Upper Layer
8384
8385 DEPENDENCIES
8386
8387 PARAMETERS
8388
8389 IN
8390 pvosGCtx: pointer to the global vos context; a handle to TL's
8391 control block can be extracted from its context
8392 ucSTAId: identifier of the station being processed
8393 vosDataBuff: pointer to the rx vos buffer
8394
8395 RETURN VALUE
8396 The result code associated with performing the operation
8397
8398 VOS_STATUS_E_INVAL: invalid input parameters
8399 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
8400 page fault
8401 VOS_STATUS_SUCCESS: Everything is good :)
8402
8403 SIDE EFFECTS
8404
8405============================================================================*/
8406
8407VOS_STATUS
8408WLANTL_FwdPktToHDD
8409(
8410 v_PVOID_t pvosGCtx,
8411 vos_pkt_t* pvosDataBuff,
8412 v_U8_t ucSTAId
8413)
8414{
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308415 v_MACADDR_t DestMacAddress;
8416 v_MACADDR_t *pDestMacAddress = &DestMacAddress;
8417 v_SIZE_t usMacAddSize = VOS_MAC_ADDR_SIZE;
Jeff Johnson295189b2012-06-20 16:38:30 -07008418 WLANTL_CbType* pTLCb = NULL;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308419 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07008420 vos_pkt_t* vosDataBuff ;
8421 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
Girish Gowli93e3edd2014-05-01 15:42:31 +05308422 v_U32_t* STAMetaInfoPtr;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308423 vos_pkt_t* vosNextDataBuff ;
8424 v_U8_t ucDesSTAId;
Jeff Johnson295189b2012-06-20 16:38:30 -07008425 WLANTL_RxMetaInfoType wRxMetaInfo;
8426
Jeff Johnson295189b2012-06-20 16:38:30 -07008427 /*------------------------------------------------------------------------
8428 Sanity check
8429 ------------------------------------------------------------------------*/
8430 if (( NULL == pvosDataBuff ) || ( NULL == ( vosDataBuff = pvosDataBuff )))
8431 {
8432 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8433 "WLAN TL:Invalid parameter sent on WLANTL_FwdPktToHdd"));
8434 return VOS_STATUS_E_INVAL;
8435 }
8436
8437 /*------------------------------------------------------------------------
8438 Extract TL control block
8439 ------------------------------------------------------------------------*/
8440 pTLCb = VOS_GET_TL_CB(pvosGCtx);
8441 if ( NULL == pTLCb )
8442 {
8443 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8444 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_FwdPktToHdd"));
8445 return VOS_STATUS_E_FAULT;
8446 }
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308447
Tushnim Bhattacharyya5dd94562013-03-20 20:15:03 -07008448 if(WLANTL_STA_ID_INVALID(ucSTAId))
8449 {
8450 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,"ucSTAId %d is not valid",
8451 ucSTAId));
8452 return VOS_STATUS_E_INVAL;
8453 }
8454
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308455 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
8456
8457 if ( NULL == pClientSTA )
8458 {
8459 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8460 "WLAN TL:Client Memory was not allocated on %s", __func__));
8461 return VOS_STATUS_E_FAILURE;
8462 }
8463
Jeff Johnson295189b2012-06-20 16:38:30 -07008464 /* This the change required for SoftAp to handle Reordered Buffer. Since a STA
8465 may have packets destined to multiple destinations we have to process each packet
8466 at a time and determine its Destination. So the Voschain provided by Reorder code
8467 is unchain and forwarded to Upper Layer after Determining the Destination */
8468
8469 vosDataBuff = pvosDataBuff;
8470 while (vosDataBuff != NULL)
8471 {
8472 vos_pkt_walk_packet_chain( vosDataBuff, &vosNextDataBuff, 1/*true*/ );
8473 vos_pkt_get_user_data_ptr( vosDataBuff, VOS_PKT_USER_DATA_ID_TL,
Girish Gowli93e3edd2014-05-01 15:42:31 +05308474 (v_PVOID_t *)&STAMetaInfoPtr );
8475 wRxMetaInfo.ucUP = (v_U8_t)((uintptr_t)STAMetaInfoPtr & WLANTL_AC_MASK);
8476 ucDesSTAId = (v_U8_t)(((uintptr_t)STAMetaInfoPtr) >> WLANTL_STAID_OFFSET);
Jeff Johnson295189b2012-06-20 16:38:30 -07008477
8478 vosStatus = vos_pkt_extract_data( vosDataBuff, 0, (v_VOID_t *)pDestMacAddress, &usMacAddSize);
8479 if ( VOS_STATUS_SUCCESS != vosStatus )
8480 {
8481 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Arif Hussainf2b00992013-11-17 21:46:15 -08008482 "WLAN TL: recv corrupted data packet"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008483 vos_pkt_return_packet(vosDataBuff);
8484 return vosStatus;
8485 }
8486
Arif Hussaina7c8e412013-11-20 11:06:42 -08008487 TLLOG4(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_LOW,
8488 "station mac "MAC_ADDRESS_STR,
8489 MAC_ADDR_ARRAY(pDestMacAddress->bytes)));
Jeff Johnson295189b2012-06-20 16:38:30 -07008490
8491 if (vos_is_macaddr_broadcast( pDestMacAddress ) || vos_is_macaddr_group(pDestMacAddress))
8492 {
8493 // destination is mc/bc station
8494 ucDesSTAId = WLAN_RX_BCMC_STA_ID;
8495 TLLOG4(VOS_TRACE( VOS_MODULE_ID_HDD_SOFTAP, VOS_TRACE_LEVEL_INFO_LOW,
Arif Hussainf2b00992013-11-17 21:46:15 -08008496 "%s: BC/MC packet, id %d", __func__, WLAN_RX_BCMC_STA_ID));
Jeff Johnson295189b2012-06-20 16:38:30 -07008497 }
8498 else
8499 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308500 if (vos_is_macaddr_equal(pDestMacAddress, &pClientSTA->wSTADesc.vSelfMACAddress))
Jeff Johnson295189b2012-06-20 16:38:30 -07008501 {
8502 // destination is AP itself
8503 ucDesSTAId = WLAN_RX_SAP_SELF_STA_ID;
8504 TLLOG4(VOS_TRACE( VOS_MODULE_ID_HDD_SOFTAP, VOS_TRACE_LEVEL_INFO_LOW,
Arif Hussainf2b00992013-11-17 21:46:15 -08008505 "%s: packet to AP itself, id %d", __func__, WLAN_RX_SAP_SELF_STA_ID));
Jeff Johnson295189b2012-06-20 16:38:30 -07008506 }
Madan Mohan Koyylamudi64258222013-01-30 14:35:10 +05308507 else if (( WLAN_MAX_STA_COUNT <= ucDesSTAId ) || (NULL != pTLCb->atlSTAClients[ucDesSTAId] && pTLCb->atlSTAClients[ucDesSTAId]->ucExists == 0))
Jeff Johnson295189b2012-06-20 16:38:30 -07008508 {
8509 // destination station is something else
8510 TLLOG4(VOS_TRACE( VOS_MODULE_ID_HDD_SOFTAP, VOS_TRACE_LEVEL_INFO_LOW,
Arif Hussainf2b00992013-11-17 21:46:15 -08008511 "%s: get an station index larger than WLAN_MAX_STA_COUNT %d", __func__, ucDesSTAId));
Jeff Johnson295189b2012-06-20 16:38:30 -07008512 ucDesSTAId = WLAN_RX_SAP_SELF_STA_ID;
8513 }
8514
8515
8516 //loopback unicast station comes here
8517 }
8518
Girish Gowli93e3edd2014-05-01 15:42:31 +05308519 wRxMetaInfo.ucUP = (v_U8_t)((uintptr_t)STAMetaInfoPtr & WLANTL_AC_MASK);
Jeff Johnson295189b2012-06-20 16:38:30 -07008520 wRxMetaInfo.ucDesSTAId = ucDesSTAId;
8521
Madan Mohan Koyyalamudi6c2977d2013-09-04 15:42:45 +05308522 vosStatus = pClientSTA->pfnSTARx( pvosGCtx, vosDataBuff, ucDesSTAId,
Jeff Johnson295189b2012-06-20 16:38:30 -07008523 &wRxMetaInfo );
Madan Mohan Koyyalamudi6c2977d2013-09-04 15:42:45 +05308524 if ( VOS_STATUS_SUCCESS != vosStatus )
8525 {
8526 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Arif Hussainf2b00992013-11-17 21:46:15 -08008527 "WLAN TL: failed to send pkt to HDD"));
Madan Mohan Koyyalamudi6c2977d2013-09-04 15:42:45 +05308528 vos_pkt_return_packet(vosDataBuff);
8529
8530 return vosStatus;
8531 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008532 vosDataBuff = vosNextDataBuff;
8533 }
8534 return VOS_STATUS_SUCCESS;
8535}
Jeff Johnson295189b2012-06-20 16:38:30 -07008536
8537/*==========================================================================
8538 FUNCTION WLANTL_STARxAuth
8539
8540 DESCRIPTION
8541 Receive in authenticated state - all data allowed
8542
8543 DEPENDENCIES
8544 The STA must be registered with TL before this function can be called.
8545
8546 PARAMETERS
8547
8548 IN
8549 pvosGCtx: pointer to the global vos context; a handle to TL's
8550 control block can be extracted from its context
8551 ucSTAId: identifier of the station being processed
8552 vosDataBuff: pointer to the rx vos buffer
8553
8554 RETURN VALUE
8555 The result code associated with performing the operation
8556
8557 VOS_STATUS_E_INVAL: invalid input parameters
8558 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
8559 page fault
8560 VOS_STATUS_SUCCESS: Everything is good :)
8561
8562 SIDE EFFECTS
8563
8564============================================================================*/
8565VOS_STATUS
8566WLANTL_STARxAuth
8567(
8568 v_PVOID_t pvosGCtx,
8569 v_U8_t ucSTAId,
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07008570 vos_pkt_t** pvosDataBuff,
8571 v_BOOL_t bForwardIAPPwithLLC
Jeff Johnson295189b2012-06-20 16:38:30 -07008572)
8573{
8574 WLANTL_CbType* pTLCb = NULL;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308575 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07008576 v_U8_t ucAsf; /* AMSDU sub frame */
8577 v_U16_t usMPDUDOffset;
8578 v_U8_t ucMPDUHOffset;
8579 v_U16_t usMPDULen;
8580 v_U8_t ucMPDUHLen;
8581 v_U16_t usActualHLen = 0;
8582 v_U8_t ucTid;
8583#ifdef FEATURE_WLAN_WAPI
Jeff Johnsone0343db2013-04-03 16:39:24 -07008584 v_U16_t usEtherType = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07008585#endif
8586 v_U16_t usPktLen;
8587 vos_pkt_t* vosDataBuff ;
8588 v_PVOID_t aucBDHeader;
8589 VOS_STATUS vosStatus;
8590 WLANTL_RxMetaInfoType wRxMetaInfo;
Madan Mohan Koyyalamudidfd6aa82012-10-18 20:18:43 -07008591 static v_U8_t ucPMPDUHLen;
Girish Gowli93e3edd2014-05-01 15:42:31 +05308592 v_U32_t* STAMetaInfoPtr;
Jeff Johnson295189b2012-06-20 16:38:30 -07008593 v_U8_t ucEsf=0; /* first subframe of AMSDU flag */
8594 v_U64_t ullcurrentReplayCounter=0; /*current replay counter*/
8595 v_U64_t ullpreviousReplayCounter=0; /*previous replay counter*/
8596 v_U16_t ucUnicastBroadcastType=0; /*It denotes whether received frame is UC or BC*/
Madan Mohan Koyyalamudi4fe30172012-10-18 20:13:40 -07008597 struct _BARFrmStruct *pBarFrame = NULL;
8598
Jeff Johnson295189b2012-06-20 16:38:30 -07008599 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
8600
8601 /*------------------------------------------------------------------------
8602 Sanity check
8603 ------------------------------------------------------------------------*/
8604 if (( NULL == pvosDataBuff ) || ( NULL == ( vosDataBuff = *pvosDataBuff )))
8605 {
8606 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8607 "WLAN TL:Invalid parameter sent on WLANTL_STARxAuth"));
8608 return VOS_STATUS_E_INVAL;
8609 }
8610
8611 /*------------------------------------------------------------------------
8612 Extract TL control block
8613 ------------------------------------------------------------------------*/
8614 pTLCb = VOS_GET_TL_CB(pvosGCtx);
8615 if ( NULL == pTLCb )
8616 {
8617 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8618 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_STARxAuth"));
8619 return VOS_STATUS_E_FAULT;
8620 }
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308621 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
8622
8623 if ( NULL == pClientSTA )
8624 {
8625 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8626 "WLAN TL:Client Memory was not allocated on %s", __func__));
8627 return VOS_STATUS_E_FAILURE;
8628 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008629
8630 /*------------------------------------------------------------------------
8631 Extract BD header and check if valid
8632 ------------------------------------------------------------------------*/
8633 WDA_DS_PeekRxPacketInfo( vosDataBuff, (v_PVOID_t)&aucBDHeader, 0 );
8634
8635 ucMPDUHOffset = (v_U8_t)WDA_GET_RX_MPDU_HEADER_OFFSET(aucBDHeader);
8636 usMPDUDOffset = (v_U16_t)WDA_GET_RX_MPDU_DATA_OFFSET(aucBDHeader);
8637 usMPDULen = (v_U16_t)WDA_GET_RX_MPDU_LEN(aucBDHeader);
8638 ucMPDUHLen = (v_U8_t)WDA_GET_RX_MPDU_HEADER_LEN(aucBDHeader);
8639 ucTid = (v_U8_t)WDA_GET_RX_TID(aucBDHeader);
8640
Madan Mohan Koyyalamudi4fe30172012-10-18 20:13:40 -07008641 /* Fix for a hardware bug.
8642 * H/W does not update the tid field in BD header for BAR frames.
8643 * Fix is to read the tid field from MAC header of BAR frame */
8644 if( (WDA_GET_RX_TYPE(aucBDHeader) == SIR_MAC_CTRL_FRAME) &&
8645 (WDA_GET_RX_SUBTYPE(aucBDHeader) == SIR_MAC_CTRL_BAR))
8646 {
8647 pBarFrame = (struct _BARFrmStruct *)(WDA_GET_RX_MAC_HEADER(aucBDHeader));
8648 ucTid = pBarFrame->barControl.numTID;
8649 }
8650
Jeff Johnson295189b2012-06-20 16:38:30 -07008651 /*Host based replay check is needed for unicast data frames*/
8652 ucUnicastBroadcastType = (v_U16_t)WDA_IS_RX_BCAST(aucBDHeader);
Jeff Johnson295189b2012-06-20 16:38:30 -07008653 if(0 != ucMPDUHLen)
8654 {
8655 ucPMPDUHLen = ucMPDUHLen;
8656 }
8657
8658 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
8659 "WLAN TL:BD header processing data: HO %d DO %d Len %d HLen %d"
8660 " Tid %d BD %d",
8661 ucMPDUHOffset, usMPDUDOffset, usMPDULen, ucMPDUHLen, ucTid,
8662 WLANHAL_RX_BD_HEADER_SIZE));
8663
8664 vos_pkt_get_packet_length( vosDataBuff, &usPktLen);
8665
8666 if ( VOS_STATUS_SUCCESS != WDA_DS_TrimRxPacketInfo( vosDataBuff ) )
8667 {
8668 if((WDA_GET_RX_ASF(aucBDHeader) && !WDA_GET_RX_ESF(aucBDHeader)))
8669 {
8670 /* AMSDU case, ucMPDUHOffset = 0
8671 * it should be hancdled seperatly */
8672 if(( usMPDUDOffset > ucMPDUHOffset ) &&
8673 ( usMPDULen >= ucMPDUHLen ) && ( usPktLen >= usMPDULen ) &&
8674 ( !WLANTL_TID_INVALID(ucTid) ))
8675 {
8676 ucMPDUHOffset = usMPDUDOffset - WLANTL_MPDU_HEADER_LEN;
8677 }
8678 else
8679 {
8680 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
8681 "WLAN TL:BD header corrupted - dropping packet"));
8682 /* Drop packet */
8683 vos_pkt_return_packet(vosDataBuff);
8684 return VOS_STATUS_SUCCESS;
8685 }
8686 }
8687 else
8688 {
8689 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
8690 "WLAN TL:BD header corrupted - dropping packet"));
8691 /* Drop packet */
8692 vos_pkt_return_packet(vosDataBuff);
8693 return VOS_STATUS_SUCCESS;
8694 }
8695 }
8696
8697#ifdef FEATURE_WLAN_WAPI
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308698 if ( pClientSTA->wSTADesc.ucIsWapiSta )
Jeff Johnson295189b2012-06-20 16:38:30 -07008699 {
8700 vosStatus = WLANTL_GetEtherType(aucBDHeader, vosDataBuff, ucMPDUHLen, &usEtherType);
8701 if( VOS_IS_STATUS_SUCCESS(vosStatus) )
8702 {
8703 if ( WLANTL_LLC_WAI_TYPE == usEtherType )
8704 {
8705 if ( !( WLANHAL_RX_IS_UNPROTECTED_WPI_FRAME(aucBDHeader)) )
8706 {
8707 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8708 "WLAN TL:WAI frame was received encrypted - dropping"));
8709 /* Drop packet */
8710 /*Temporary fix added to fix wapi rekey issue*/
8711 //vos_pkt_return_packet(vosDataBuff);
8712 //return vosStatus; //returning success
8713 }
8714 }
8715 else
8716 {
8717 if ( WLANHAL_RX_IS_UNPROTECTED_WPI_FRAME(aucBDHeader) )
8718 {
8719 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8720 "WLAN TL:Non-WAI frame was received unencrypted - dropping"));
8721 /* Drop packet */
8722 vos_pkt_return_packet(vosDataBuff);
8723 return vosStatus; //returning success
8724 }
8725 }
8726 }
8727 else //could not extract EtherType - this should not happen
8728 {
8729 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008730 "WLAN TL:Could not extract EtherType"));
8731 //Packet is already freed
Jeff Johnson295189b2012-06-20 16:38:30 -07008732 return vosStatus; //returning failure
Jeff Johnson295189b2012-06-20 16:38:30 -07008733 }
8734 }
8735#endif /* FEATURE_WLAN_WAPI */
8736
8737 /*----------------------------------------------------------------------
8738 Increment receive counter
8739 !! not sure this is the best place to increase this - pkt might be
8740 dropped below or delayed in TL's queues
8741 - will leave it here for now
8742 ------------------------------------------------------------------------*/
Madan Mohan Koyyalamudic0e5bd82012-09-18 17:12:27 -07008743 if ( !WLANTL_TID_INVALID( ucTid) )
8744 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308745 pClientSTA->auRxCount[ucTid]++;
Madan Mohan Koyyalamudic0e5bd82012-09-18 17:12:27 -07008746 }
8747 else
8748 {
8749 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8750 "WLAN TL:Invalid tid %d (Station ID %d) on %s",
8751 ucTid, ucSTAId, __func__));
8752 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008753
8754 /*------------------------------------------------------------------------
8755 Check if AMSDU and send for processing if so
8756 ------------------------------------------------------------------------*/
8757 ucAsf = (v_U8_t)WDA_GET_RX_ASF(aucBDHeader);
8758
8759 if ( 0 != ucAsf )
8760 {
8761 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
8762 "WLAN TL:Packet is AMSDU sub frame - sending for completion"));
8763 vosStatus = WLANTL_AMSDUProcess( pvosGCtx, &vosDataBuff, aucBDHeader, ucSTAId,
8764 ucMPDUHLen, usMPDULen );
8765 if(NULL == vosDataBuff)
8766 {
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008767 //Packet is already freed
Jeff Johnson295189b2012-06-20 16:38:30 -07008768 return VOS_STATUS_SUCCESS;
8769 }
8770 }
8771 /* After AMSDU header handled
8772 * AMSDU frame just same with normal frames */
8773 /*-------------------------------------------------------------------
8774 Translating header if necesary
8775 !! Fix me: rmv comments below
8776 ----------------------------------------------------------------------*/
8777 if (( 0 == WDA_GET_RX_FT_DONE(aucBDHeader) ) &&
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308778 ( 0 != pClientSTA->wSTADesc.ucSwFrameRXXlation) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07008779 ( WLANTL_IS_DATA_FRAME(WDA_GET_RX_TYPE_SUBTYPE(aucBDHeader)) ))
8780 {
8781 if(0 == ucMPDUHLen)
8782 {
8783 ucMPDUHLen = ucPMPDUHLen;
8784 }
8785 if (usMPDUDOffset > ucMPDUHOffset)
8786 {
8787 usActualHLen = usMPDUDOffset - ucMPDUHOffset;
8788 }
8789 vosStatus = WLANTL_Translate80211To8023Header( vosDataBuff, &vosStatus, usActualHLen,
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07008790 ucMPDUHLen, pTLCb, ucSTAId, bForwardIAPPwithLLC);
Jeff Johnson295189b2012-06-20 16:38:30 -07008791
8792 if ( VOS_STATUS_SUCCESS != vosStatus )
8793 {
Kaushik, Sushante386ee12014-05-01 15:50:52 +05308794 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
Jeff Johnson295189b2012-06-20 16:38:30 -07008795 "WLAN TL:Failed to translate from 802.11 to 802.3 - dropping"));
8796 /* Drop packet */
8797 vos_pkt_return_packet(vosDataBuff);
8798 return vosStatus;
8799 }
8800 }
8801 /* Softap requires additional Info such as Destination STAID and Access
8802 Category. Voschain or Buffer returned by BA would be unchain and this
8803 Meta Data would help in routing the packets to appropriate Destination */
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308804 if( WLAN_STA_SOFTAP == pClientSTA->wSTADesc.wSTAType)
Jeff Johnson295189b2012-06-20 16:38:30 -07008805 {
Arun Kumar Khandavalli37cfc222014-01-09 22:32:40 +05308806 STAMetaInfoPtr = (v_U32_t *)(uintptr_t)(ucTid | (WDA_GET_RX_ADDR3_IDX(aucBDHeader) << WLANTL_STAID_OFFSET));
Jeff Johnson295189b2012-06-20 16:38:30 -07008807 vos_pkt_set_user_data_ptr( vosDataBuff, VOS_PKT_USER_DATA_ID_TL,
8808 (v_PVOID_t)STAMetaInfoPtr);
8809 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008810
8811 /*------------------------------------------------------------------------
8812 Check to see if re-ordering session is in place
8813 ------------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308814 if ( 0 != pClientSTA->atlBAReorderInfo[ucTid].ucExists )
Jeff Johnson295189b2012-06-20 16:38:30 -07008815 {
8816 WLANTL_MSDUReorder( pTLCb, &vosDataBuff, aucBDHeader, ucSTAId, ucTid );
8817 }
8818
Jeff Johnson295189b2012-06-20 16:38:30 -07008819if(0 == ucUnicastBroadcastType
8820#ifdef FEATURE_ON_CHIP_REORDERING
8821 && (WLANHAL_IsOnChipReorderingEnabledForTID(pvosGCtx, ucSTAId, ucTid) != TRUE)
8822#endif
8823)
8824{
8825 /* replay check code : check whether replay check is needed or not */
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308826 if(VOS_TRUE == pClientSTA->ucIsReplayCheckValid)
Jeff Johnson295189b2012-06-20 16:38:30 -07008827 {
8828 /* replay check is needed for the station */
8829
8830 /* check whether frame is AMSDU frame */
8831 if ( 0 != ucAsf )
8832 {
8833 /* Since virgo can't send AMSDU frames this leg of the code
8834 was not tested properly, it needs to be tested properly*/
8835 /* Frame is AMSDU frame. As per 802.11n only first
8836 subframe will have replay counter */
8837 ucEsf = WDA_GET_RX_ESF( aucBDHeader );
8838 if( 0 != ucEsf )
8839 {
8840 v_BOOL_t status;
8841 /* Getting 48-bit replay counter from the RX BD */
8842 ullcurrentReplayCounter = WDA_DS_GetReplayCounter(aucBDHeader);
8843
8844 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Arif Hussainf2b00992013-11-17 21:46:15 -08008845 "WLAN TL: AMSDU currentReplayCounter [0x%llX]",ullcurrentReplayCounter);
Jeff Johnson295189b2012-06-20 16:38:30 -07008846
8847 /* Getting 48-bit previous replay counter from TL control block */
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308848 ullpreviousReplayCounter = pClientSTA->ullReplayCounter[ucTid];
Jeff Johnson295189b2012-06-20 16:38:30 -07008849
8850 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Arif Hussainf2b00992013-11-17 21:46:15 -08008851 "WLAN TL: AMSDU previousReplayCounter [0x%llX]",ullpreviousReplayCounter);
Jeff Johnson295189b2012-06-20 16:38:30 -07008852
8853 /* It is first subframe of AMSDU thus it
8854 conatains replay counter perform the
8855 replay check for this first subframe*/
8856 status = WLANTL_IsReplayPacket( ullcurrentReplayCounter, ullpreviousReplayCounter);
8857 if(VOS_FALSE == status)
8858 {
8859 /* Not a replay paket, update previous replay counter in TL CB */
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308860 pClientSTA->ullReplayCounter[ucTid] = ullcurrentReplayCounter;
Jeff Johnson295189b2012-06-20 16:38:30 -07008861 }
8862 else
8863 {
8864 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Arif Hussainf2b00992013-11-17 21:46:15 -08008865 "WLAN TL: AMSDU Drop the replay packet with PN : [0x%llX]",ullcurrentReplayCounter);
Jeff Johnson295189b2012-06-20 16:38:30 -07008866
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308867 pClientSTA->ulTotalReplayPacketsDetected++;
Jeff Johnson295189b2012-06-20 16:38:30 -07008868 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Arif Hussainf2b00992013-11-17 21:46:15 -08008869 "WLAN TL: AMSDU total dropped replay packets on STA ID %X is [0x%X]",
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308870 ucSTAId, pClientSTA->ulTotalReplayPacketsDetected);
Jeff Johnson295189b2012-06-20 16:38:30 -07008871
8872 /* Drop the packet */
8873 vos_pkt_return_packet(vosDataBuff);
8874 return VOS_STATUS_SUCCESS;
8875 }
8876 }
8877 }
8878 else
8879 {
8880 v_BOOL_t status;
8881
8882 /* Getting 48-bit replay counter from the RX BD */
8883 ullcurrentReplayCounter = WDA_DS_GetReplayCounter(aucBDHeader);
8884
8885 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Arif Hussainf2b00992013-11-17 21:46:15 -08008886 "WLAN TL: Non-AMSDU currentReplayCounter [0x%llX]",ullcurrentReplayCounter);
Jeff Johnson295189b2012-06-20 16:38:30 -07008887
8888 /* Getting 48-bit previous replay counter from TL control block */
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308889 ullpreviousReplayCounter = pClientSTA->ullReplayCounter[ucTid];
Jeff Johnson295189b2012-06-20 16:38:30 -07008890
8891 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Arif Hussainf2b00992013-11-17 21:46:15 -08008892 "WLAN TL: Non-AMSDU previousReplayCounter [0x%llX]",ullpreviousReplayCounter);
Jeff Johnson295189b2012-06-20 16:38:30 -07008893
8894 /* It is not AMSDU frame so perform
8895 reaply check for each packet, as
8896 each packet contains valid replay counter*/
8897 status = WLANTL_IsReplayPacket( ullcurrentReplayCounter, ullpreviousReplayCounter);
8898 if(VOS_FALSE == status)
8899 {
8900 /* Not a replay paket, update previous replay counter in TL CB */
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308901 pClientSTA->ullReplayCounter[ucTid] = ullcurrentReplayCounter;
Jeff Johnson295189b2012-06-20 16:38:30 -07008902 }
8903 else
8904 {
8905 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Arif Hussainf2b00992013-11-17 21:46:15 -08008906 "WLAN TL: Non-AMSDU Drop the replay packet with PN : [0x%llX]",ullcurrentReplayCounter);
Jeff Johnson295189b2012-06-20 16:38:30 -07008907
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308908 pClientSTA->ulTotalReplayPacketsDetected++;
Jeff Johnson295189b2012-06-20 16:38:30 -07008909 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Arif Hussainf2b00992013-11-17 21:46:15 -08008910 "WLAN TL: Non-AMSDU total dropped replay packets on STA ID %X is [0x%X]",
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308911 ucSTAId, pClientSTA->ulTotalReplayPacketsDetected);
Jeff Johnson295189b2012-06-20 16:38:30 -07008912
8913 /* Repaly packet, drop the packet */
8914 vos_pkt_return_packet(vosDataBuff);
8915 return VOS_STATUS_SUCCESS;
8916 }
8917 }
8918 }
8919}
8920/*It is a broadast packet DPU has already done replay check for
8921 broadcast packets no need to do replay check of these packets*/
Jeff Johnson295189b2012-06-20 16:38:30 -07008922
8923 if ( NULL != vosDataBuff )
8924 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308925 if( WLAN_STA_SOFTAP == pClientSTA->wSTADesc.wSTAType)
Jeff Johnson295189b2012-06-20 16:38:30 -07008926 {
8927 WLANTL_FwdPktToHDD( pvosGCtx, vosDataBuff, ucSTAId );
8928 }
8929 else
Jeff Johnson295189b2012-06-20 16:38:30 -07008930 {
8931 wRxMetaInfo.ucUP = ucTid;
Shailender Karmuchi13c0d082013-03-26 14:41:39 -07008932 wRxMetaInfo.rssiAvg = pClientSTA->rssiAvg;
Gopichand Nakkala4a2fc1a2013-05-17 16:59:39 +05308933#ifdef FEATURE_WLAN_TDLS
8934 if (WLAN_STA_TDLS == pClientSTA->wSTADesc.wSTAType)
8935 {
8936 wRxMetaInfo.isStaTdls = TRUE;
8937 }
8938 else
8939 {
8940 wRxMetaInfo.isStaTdls = FALSE;
8941 }
8942#endif
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308943 pClientSTA->pfnSTARx( pvosGCtx, vosDataBuff, ucSTAId,
Jeff Johnson295189b2012-06-20 16:38:30 -07008944 &wRxMetaInfo );
8945 }
8946 }/* if not NULL */
8947
8948 return VOS_STATUS_SUCCESS;
8949}/* WLANTL_STARxAuth */
8950
8951
8952/*==========================================================================
8953 FUNCTION WLANTL_STARxDisc
8954
8955 DESCRIPTION
8956 Receive in disconnected state - no data allowed
8957
8958 DEPENDENCIES
8959 The STA must be registered with TL before this function can be called.
8960
8961 PARAMETERS
8962
8963 IN
8964 pvosGCtx: pointer to the global vos context; a handle to TL's
8965 control block can be extracted from its context
8966 ucSTAId: identifier of the station being processed
8967 vosDataBuff: pointer to the rx vos buffer
8968
8969 RETURN VALUE
8970 The result code associated with performing the operation
8971
8972 VOS_STATUS_SUCCESS: Everything is good :)
8973
8974 SIDE EFFECTS
8975
8976============================================================================*/
8977VOS_STATUS
8978WLANTL_STARxDisc
8979(
8980 v_PVOID_t pvosGCtx,
8981 v_U8_t ucSTAId,
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07008982 vos_pkt_t** pvosDataBuff,
8983 v_BOOL_t bForwardIAPPwithLLC
Jeff Johnson295189b2012-06-20 16:38:30 -07008984)
8985{
8986 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
8987
8988 /*------------------------------------------------------------------------
8989 Sanity check
8990 ------------------------------------------------------------------------*/
8991 if (( NULL == pvosDataBuff ) || ( NULL == *pvosDataBuff ))
8992 {
8993 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8994 "WLAN TL:Invalid parameter sent on WLANTL_STARxDisc"));
8995 return VOS_STATUS_E_INVAL;
8996 }
8997
8998 /*------------------------------------------------------------------------
8999 Error - drop packet
9000 ------------------------------------------------------------------------*/
9001 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9002 "WLAN TL:Packet should not be received in state disconnected"
9003 " - dropping"));
9004 vos_pkt_return_packet(*pvosDataBuff);
9005 *pvosDataBuff = NULL;
9006
9007 return VOS_STATUS_SUCCESS;
9008}/* WLANTL_STARxDisc */
9009
9010/*==========================================================================
9011 Processing main loops for MAIN and TX threads
9012 ==========================================================================*/
9013
9014/*==========================================================================
9015 FUNCTION WLANTL_McProcessMsg
9016
9017 DESCRIPTION
9018 Called by VOSS when a message was serialized for TL through the
9019 main thread/task.
9020
9021 DEPENDENCIES
9022 The TL must be initialized before this function can be called.
9023
9024 PARAMETERS
9025
9026 IN
9027 pvosGCtx: pointer to the global vos context; a handle to TL's
9028 control block can be extracted from its context
9029 message: type and content of the message
9030
9031
9032 RETURN VALUE
9033 The result code associated with performing the operation
9034
9035 VOS_STATUS_E_INVAL: invalid input parameters
9036 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
9037 page fault
9038 VOS_STATUS_SUCCESS: Everything is good :)
9039
9040 SIDE EFFECTS
9041
9042============================================================================*/
9043VOS_STATUS
9044WLANTL_McProcessMsg
9045(
9046 v_PVOID_t pvosGCtx,
9047 vos_msg_t* message
9048)
9049{
9050 WLANTL_CbType* pTLCb = NULL;
9051 tAddBAInd* ptAddBaInd = NULL;
9052 tDelBAInd* ptDelBaInd = NULL;
9053 tAddBARsp* ptAddBaRsp = NULL;
9054 vos_msg_t vosMessage;
9055 VOS_STATUS vosStatus;
9056 tpFlushACRsp FlushACRspPtr;
9057 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
9058
9059 /*------------------------------------------------------------------------
9060 Sanity check
9061 ------------------------------------------------------------------------*/
9062 if ( NULL == message )
9063 {
9064 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9065 "WLAN TL:Invalid parameter sent on WLANTL_ProcessMainMessage"));
9066 return VOS_STATUS_E_INVAL;
9067 }
9068
9069 /*------------------------------------------------------------------------
9070 Extract TL control block
9071 ------------------------------------------------------------------------*/
9072 pTLCb = VOS_GET_TL_CB(pvosGCtx);
9073 if ( NULL == pTLCb )
9074 {
9075 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9076 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_ProcessMainMessage"));
9077 return VOS_STATUS_E_FAULT;
9078 }
9079
9080 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
9081 "WLAN TL:Received message: %d through main flow", message->type));
9082
9083 switch( message->type )
9084 {
9085 case WDA_TL_FLUSH_AC_RSP:
9086 // Extract the message from the message body
9087 FlushACRspPtr = (tpFlushACRsp)(message->bodyptr);
9088 // Make sure the call back function is not null.
Tushnim Bhattacharyya5dd94562013-03-20 20:15:03 -07009089 if ( NULL == pTLCb->tlBAPClient.pfnFlushOpCompleteCb )
9090 {
9091 VOS_ASSERT(0);
9092 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9093 "WLAN TL:Invalid TL pointer pfnFlushOpCompleteCb"));
9094 return VOS_STATUS_E_FAULT;
9095 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009096
9097 TLLOG2(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
9098 "Received message: Flush complete received by TL"));
9099
9100 // Since we have the response back from HAL, just call the BAP client
9101 // registered call back from TL. There is only 1 possible
9102 // BAP client. So directly reference tlBAPClient
9103 pTLCb->tlBAPClient.pfnFlushOpCompleteCb( pvosGCtx,
9104 FlushACRspPtr->ucSTAId,
9105 FlushACRspPtr->ucTid, FlushACRspPtr->status );
9106
9107 // Free the PAL memory, we are done with it.
9108 TLLOG2(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
9109 "Flush complete received by TL: Freeing %p", FlushACRspPtr));
9110 vos_mem_free((v_VOID_t *)FlushACRspPtr);
9111 break;
9112
9113 case WDA_HDD_ADDBA_REQ:
9114 ptAddBaInd = (tAddBAInd*)(message->bodyptr);
9115 vosStatus = WLANTL_BaSessionAdd( pvosGCtx,
9116 ptAddBaInd->baSession.baSessionID,
9117 ptAddBaInd->baSession.STAID,
9118 ptAddBaInd->baSession.baTID,
9119 (v_U32_t)ptAddBaInd->baSession.baBufferSize,
9120 ptAddBaInd->baSession.winSize,
9121 ptAddBaInd->baSession.SSN);
9122 ptAddBaRsp = vos_mem_malloc(sizeof(*ptAddBaRsp));
9123
9124 if ( NULL == ptAddBaRsp )
9125 {
9126 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9127 "WLAN TL: fatal failure, cannot allocate BA Rsp structure"));
9128 VOS_ASSERT(0);
9129 return VOS_STATUS_E_NOMEM;
9130 }
9131
9132 if ( VOS_STATUS_SUCCESS == vosStatus )
9133 {
9134 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
9135 "WLAN TL: Sending success indication to HAL for ADD BA"));
9136 /*Send success*/
9137 ptAddBaRsp->mesgType = WDA_HDD_ADDBA_RSP;
9138 vosMessage.type = WDA_HDD_ADDBA_RSP;
9139 }
9140 else
9141 {
9142 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
9143 "WLAN TL: Sending failure indication to HAL for ADD BA"));
9144
9145 /*Send failure*/
9146 ptAddBaRsp->mesgType = WDA_BA_FAIL_IND;
9147 vosMessage.type = WDA_BA_FAIL_IND;
9148 }
9149
9150 ptAddBaRsp->mesgLen = sizeof(tAddBARsp);
9151 ptAddBaRsp->baSessionID = ptAddBaInd->baSession.baSessionID;
9152 /* This is default, reply win size has to be handled BA module, FIX THIS */
9153 ptAddBaRsp->replyWinSize = WLANTL_MAX_WINSIZE;
9154 vosMessage.bodyptr = ptAddBaRsp;
9155
9156 vos_mq_post_message( VOS_MQ_ID_WDA, &vosMessage );
9157 WLANTL_McFreeMsg (pvosGCtx, message);
9158 break;
9159 case WDA_DELETEBA_IND:
9160 ptDelBaInd = (tDelBAInd*)(message->bodyptr);
9161 vosStatus = WLANTL_BaSessionDel(pvosGCtx,
9162 ptDelBaInd->staIdx,
9163 ptDelBaInd->baTID);
9164
9165 if ( VOS_STATUS_SUCCESS != vosStatus )
9166 {
9167 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9168 "WLAN TL: Failed to del BA session STA:%d TID:%d Status :%d",
9169 ptDelBaInd->staIdx,
9170 ptDelBaInd->baTID,
9171 vosStatus));
9172 }
9173 WLANTL_McFreeMsg (pvosGCtx, message);
9174 break;
9175 default:
9176 /*no processing for now*/
9177 break;
9178 }
9179
9180 return VOS_STATUS_SUCCESS;
9181}/* WLANTL_ProcessMainMessage */
9182
9183/*==========================================================================
9184 FUNCTION WLANTL_McFreeMsg
9185
9186 DESCRIPTION
9187 Called by VOSS to free a given TL message on the Main thread when there
9188 are messages pending in the queue when the whole system is been reset.
9189 For now, TL does not allocate any body so this function shout translate
9190 into a NOOP
9191
9192 DEPENDENCIES
9193 The TL must be initialized before this function can be called.
9194
9195 PARAMETERS
9196
9197 IN
9198 pvosGCtx: pointer to the global vos context; a handle to TL's
9199 control block can be extracted from its context
9200 message: type and content of the message
9201
9202
9203 RETURN VALUE
9204 The result code associated with performing the operation
9205
9206 VOS_STATUS_SUCCESS: Everything is good :)
9207
9208 SIDE EFFECTS
9209
9210============================================================================*/
9211VOS_STATUS
9212WLANTL_McFreeMsg
9213(
9214 v_PVOID_t pvosGCtx,
9215 vos_msg_t* message
9216)
9217{
9218 WLANTL_CbType* pTLCb = NULL;
9219 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
9220
9221 /*------------------------------------------------------------------------
9222 Sanity check
9223 ------------------------------------------------------------------------*/
9224 if ( NULL == message )
9225 {
9226 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9227 "WLAN TL:Invalid parameter sent on WLANTL_McFreeMsg"));
9228 return VOS_STATUS_E_INVAL;
9229 }
9230
9231 /*------------------------------------------------------------------------
9232 Extract TL control block
9233 ------------------------------------------------------------------------*/
9234 pTLCb = VOS_GET_TL_CB(pvosGCtx);
9235 if ( NULL == pTLCb )
9236 {
9237 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9238 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_McFreeMsg"));
9239 return VOS_STATUS_E_FAULT;
9240 }
9241
9242 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
9243 "WLAN TL:Received message: %d through main free", message->type));
9244
9245 switch( message->type )
9246 {
9247 case WDA_HDD_ADDBA_REQ:
9248 case WDA_DELETEBA_IND:
9249 /*vos free body pointer*/
9250 vos_mem_free(message->bodyptr);
9251 message->bodyptr = NULL;
9252 break;
9253 default:
9254 /*no processing for now*/
9255 break;
9256 }
9257
9258 return VOS_STATUS_SUCCESS;
9259}/*WLANTL_McFreeMsg*/
9260
9261/*==========================================================================
9262 FUNCTION WLANTL_TxProcessMsg
9263
9264 DESCRIPTION
9265 Called by VOSS when a message was serialized for TL through the
9266 tx thread/task.
9267
9268 DEPENDENCIES
9269 The TL must be initialized before this function can be called.
9270
9271 PARAMETERS
9272
9273 IN
9274 pvosGCtx: pointer to the global vos context; a handle to TL's
9275 control block can be extracted from its context
9276 message: type and content of the message
9277
9278
9279 RETURN VALUE
9280 The result code associated with performing the operation
9281
9282 VOS_STATUS_E_INVAL: invalid input parameters
9283 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
9284 page fault
9285 VOS_STATUS_SUCCESS: Everything is good :)
9286
9287 Other values can be returned as a result of a function call, please check
9288 corresponding API for more info.
9289 SIDE EFFECTS
9290
9291============================================================================*/
9292VOS_STATUS
9293WLANTL_TxProcessMsg
9294(
9295 v_PVOID_t pvosGCtx,
9296 vos_msg_t* message
9297)
9298{
9299 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07009300 void (*callbackRoutine) (void *callbackContext);
9301 void *callbackContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07009302 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
9303
9304 /*------------------------------------------------------------------------
9305 Sanity check
9306 ------------------------------------------------------------------------*/
9307 if ( NULL == message )
9308 {
9309 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9310 "WLAN TL:Invalid parameter sent on WLANTL_ProcessTxMessage"));
9311 return VOS_STATUS_E_INVAL;
9312 }
9313
9314 /*------------------------------------------------------------------------
9315 Process message
9316 ------------------------------------------------------------------------*/
9317 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
9318 "WLAN TL:Received message: %d through tx flow", message->type));
9319
9320 switch( message->type )
9321 {
9322 case WLANTL_TX_SIG_SUSPEND:
9323 vosStatus = WLANTL_SuspendCB( pvosGCtx,
9324 (WLANTL_SuspendCBType)message->bodyptr,
9325 message->reserved);
9326 break;
9327 case WLANTL_TX_RES_NEEDED:
9328 vosStatus = WLANTL_GetTxResourcesCB( pvosGCtx );
9329 break;
Katya Nigam664f5032014-05-05 12:24:32 +05309330
Jeff Johnson295189b2012-06-20 16:38:30 -07009331 case WDA_DS_TX_START_XMIT:
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05309332 WLANTL_ClearTxXmitPending(pvosGCtx);
9333 vosStatus = WDA_DS_TxFrames( pvosGCtx );
Jeff Johnson295189b2012-06-20 16:38:30 -07009334 break;
9335
9336 case WDA_DS_FINISH_ULA:
Arun Kumar Khandavalli8d1979d2014-01-09 21:12:25 +05309337 callbackContext = message->bodyptr;
9338 callbackRoutine = message->callback;
9339 if ( NULL != callbackRoutine )
9340 {
9341 callbackRoutine(callbackContext);
9342 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009343 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009344
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05309345 case WLANTL_TX_SNAPSHOT:
9346 /*Dumping TL State and then continuing to print
9347 the DXE Dump*/
9348 WLANTL_TxThreadDebugHandler(pvosGCtx);
9349 WDA_TransportChannelDebug(NULL, VOS_TRUE, VOS_FALSE);
9350 break;
9351
Mihir Shetefd62d9d2014-08-06 15:08:21 +05309352 case WLANTL_TX_FATAL_ERROR:
9353 WLANTL_FatalErrorHandler(pvosGCtx);
9354 break;
9355
Mihir Shete327c2ab2014-11-13 15:17:02 +05309356 case WLANTL_TX_FW_DEBUG:
Siddharth Bhal68115602015-01-18 20:44:55 +05309357 vos_fwDumpReq(274, 0, 0, 0, 0, 1); //Async event
Mihir Shete327c2ab2014-11-13 15:17:02 +05309358 break;
9359
Jeff Johnson295189b2012-06-20 16:38:30 -07009360 default:
9361 /*no processing for now*/
9362 break;
9363 }
9364
9365 return vosStatus;
9366}/* WLANTL_TxProcessMsg */
9367
9368/*==========================================================================
9369 FUNCTION WLANTL_McFreeMsg
9370
9371 DESCRIPTION
9372 Called by VOSS to free a given TL message on the Main thread when there
9373 are messages pending in the queue when the whole system is been reset.
9374 For now, TL does not allocate any body so this function shout translate
9375 into a NOOP
9376
9377 DEPENDENCIES
9378 The TL must be initialized before this function can be called.
9379
9380 PARAMETERS
9381
9382 IN
9383 pvosGCtx: pointer to the global vos context; a handle to TL's
9384 control block can be extracted from its context
9385 message: type and content of the message
9386
9387
9388 RETURN VALUE
9389 The result code associated with performing the operation
9390
9391 VOS_STATUS_SUCCESS: Everything is good :)
9392
9393 SIDE EFFECTS
9394
9395============================================================================*/
9396VOS_STATUS
9397WLANTL_TxFreeMsg
9398(
9399 v_PVOID_t pvosGCtx,
9400 vos_msg_t* message
9401)
9402{
9403 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
9404
9405 /*Nothing to do for now!!!*/
9406 return VOS_STATUS_SUCCESS;
9407}/*WLANTL_TxFreeMsg*/
9408
Jeff Johnson295189b2012-06-20 16:38:30 -07009409/*==========================================================================
9410
9411 FUNCTION WLANTL_TxFCFrame
9412
9413 DESCRIPTION
9414 Internal utility function to send FC frame. Enable
9415 or disable LWM mode based on the information.
9416
9417 DEPENDENCIES
9418 TL must be initiailized before this function gets called.
9419 FW sends up special flow control frame.
9420
9421 PARAMETERS
9422
9423 IN
9424 pvosGCtx: pointer to the global vos context; a handle to TL's
9425 control block can be extracted from its context
9426
9427 RETURN VALUE
9428 The result code associated with performing the operation
9429
9430 VOS_STATUS_E_INVAL: Input pointers are NULL.
9431 VOS_STATUS_E_FAULT: Something is wrong.
9432 VOS_STATUS_SUCCESS: Everything is good.
9433
9434 SIDE EFFECTS
9435 Newly formed FC frame is generated and waits to be transmitted. Previously unsent frame will
9436 be released.
9437
9438============================================================================*/
9439VOS_STATUS
9440WLANTL_TxFCFrame
9441(
9442 v_PVOID_t pvosGCtx
9443)
9444{
9445#if 0
9446 WLANTL_CbType* pTLCb = NULL;
9447 VOS_STATUS vosStatus;
9448 tpHalFcTxBd pvFcTxBd = NULL;
9449 vos_pkt_t * pPacket = NULL;
9450 v_U8_t ucSTAId = 0;
9451 v_U8_t ucBitCheck = 1;
9452
9453 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009454 "WLAN TL: Send FC frame %s", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07009455
9456 /*------------------------------------------------------------------------
9457 Sanity check
9458 ------------------------------------------------------------------------*/
9459 if ( NULL == pvosGCtx )
9460 {
9461 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009462 "WLAN TL:Invalid parameter %s", __func__));
Jeff Johnson295189b2012-06-20 16:38:30 -07009463 return VOS_STATUS_E_INVAL;
9464 }
9465 /*------------------------------------------------------------------------
9466 Extract TL control block
9467 ------------------------------------------------------------------------*/
9468 pTLCb = VOS_GET_TL_CB(pvosGCtx);
9469
9470 if (NULL == pTLCb)
9471 {
9472 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009473 "WLAN TL:Invalid pointer in %s \n", __func__));
Jeff Johnson295189b2012-06-20 16:38:30 -07009474 return VOS_STATUS_E_INVAL;
9475 }
9476
9477 //Get one voss packet
9478 vosStatus = vos_pkt_get_packet( &pPacket, VOS_PKT_TYPE_TX_802_11_MGMT, sizeof(tHalFcTxBd), 1,
9479 VOS_FALSE, NULL, NULL );
9480
9481 if ( VOS_STATUS_SUCCESS != vosStatus )
9482 {
9483 return VOS_STATUS_E_INVAL;
9484 }
9485
9486 vosStatus = vos_pkt_reserve_head( pPacket, (void *)&pvFcTxBd, sizeof(tHalFcTxBd));
9487
9488 if( VOS_STATUS_SUCCESS != vosStatus )
9489 {
9490 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009491 "%s: failed to reserve FC TX BD %d\n",__func__, sizeof(tHalFcTxBd)));
Jeff Johnson295189b2012-06-20 16:38:30 -07009492 vos_pkt_return_packet( pPacket );
9493 return VOS_STATUS_E_FAULT;
9494 }
9495
9496 //Generate most recent tlFCInfo. Most fields are correct.
9497 pTLCb->tlFCInfo.fcSTAThreshEnabledMask = 0;
9498 pTLCb->tlFCInfo.fcSTATxMoreDataMask = 0;
9499 for( ucSTAId = 0, ucBitCheck = 1 ; ucSTAId < WLAN_MAX_STA_COUNT; ucBitCheck <<= 1, ucSTAId ++)
9500 {
9501 if (0 == pTLCb->atlSTAClients[ucSTAId].ucExists)
9502 {
9503 continue;
9504 }
9505
9506 if (pTLCb->atlSTAClients[ucSTAId].ucPktPending)
9507 {
9508 pTLCb->tlFCInfo.fcSTATxMoreDataMask |= ucBitCheck;
9509 }
9510
9511 if ( (pTLCb->atlSTAClients[ucSTAId].ucLwmModeEnabled) &&
9512 (pTLCb->atlSTAClients[ucSTAId].bmuMemConsumed > pTLCb->atlSTAClients[ucSTAId].uLwmThreshold))
9513 {
9514 pTLCb->tlFCInfo.fcSTAThreshEnabledMask |= ucBitCheck;
9515
9516 pTLCb->tlFCInfo.fcSTAThresh[ucSTAId] = (tANI_U8)pTLCb->atlSTAClients[ucSTAId].uLwmThreshold;
9517
9518 pTLCb->atlSTAClients[ucSTAId].ucLwmEventReported = FALSE;
9519 }
9520
9521 }
9522
9523 //request immediate feedback
9524 pTLCb->tlFCInfo.fcConfig |= 0x4;
9525
9526 //fill in BD to sent
9527 vosStatus = WLANHAL_FillFcTxBd(pvosGCtx, &pTLCb->tlFCInfo, (void *)pvFcTxBd);
9528
9529 if( VOS_STATUS_SUCCESS != vosStatus )
9530 {
9531 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009532 "%s: Fill FC TX BD unsuccessful\n", __func__));
Jeff Johnson295189b2012-06-20 16:38:30 -07009533 vos_pkt_return_packet( pPacket );
9534 return VOS_STATUS_E_FAULT;
9535 }
9536
9537 if (NULL != pTLCb->vosTxFCBuf)
9538 {
9539 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009540 "%s: Previous FC TX BD not sent\n", __func__));
Jeff Johnson295189b2012-06-20 16:38:30 -07009541 vos_pkt_return_packet(pTLCb->vosTxFCBuf);
9542 }
9543
9544 pTLCb->vosTxFCBuf = pPacket;
9545
9546 vos_pkt_set_user_data_ptr( pPacket, VOS_PKT_USER_DATA_ID_TL,
9547 (v_PVOID_t)WLANTL_TxCompDefaultCb);
9548 vosStatus = WDA_DS_StartXmit(pvosGCtx);
9549
9550 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009551 "WLAN TL: send FC frame leave %s", __func__));
Jeff Johnson295189b2012-06-20 16:38:30 -07009552#endif
9553 return VOS_STATUS_SUCCESS;
9554}
9555
Jeff Johnson295189b2012-06-20 16:38:30 -07009556
9557/*==========================================================================
9558 FUNCTION WLANTL_GetTxResourcesCB
9559
9560 DESCRIPTION
9561 Processing function for Resource needed signal. A request will be issued
9562 to BAL to get more tx resources.
9563
9564 DEPENDENCIES
9565 The TL must be initialized before this function can be called.
9566
9567 PARAMETERS
9568
9569 IN
9570 pvosGCtx: pointer to the global vos context; a handle to TL's
9571 control block can be extracted from its context
9572
9573
9574 RETURN VALUE
9575 The result code associated with performing the operation
9576
9577 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
9578 page fault
9579 VOS_STATUS_SUCCESS: Everything is good :)
9580
9581 Other values can be returned as a result of a function call, please check
9582 corresponding API for more info.
9583 SIDE EFFECTS
9584
9585============================================================================*/
9586VOS_STATUS
9587WLANTL_GetTxResourcesCB
9588(
9589 v_PVOID_t pvosGCtx
9590)
9591{
9592 WLANTL_CbType* pTLCb = NULL;
9593 v_U32_t uResCount = WDA_TLI_MIN_RES_DATA;
9594 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
9595 v_U8_t ucMgmt = 0;
9596 v_U8_t ucBAP = 0;
9597 v_U8_t ucData = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07009598#ifdef WLAN_SOFTAP_FLOWCTRL_EN
9599 tBssSystemRole systemRole;
9600 tpAniSirGlobal pMac;
9601#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009602 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
9603 /*------------------------------------------------------------------------
9604 Extract TL control block
9605 ------------------------------------------------------------------------*/
9606 pTLCb = VOS_GET_TL_CB(pvosGCtx);
9607 if ( NULL == pTLCb )
9608 {
9609 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9610 "WLAN TL:Invalid TL pointer from pvosGCtx on"
9611 " WLANTL_ProcessTxMessage"));
9612 return VOS_STATUS_E_FAULT;
9613 }
9614
9615 /*------------------------------------------------------------------------
9616 Get tx resources from BAL
9617 ------------------------------------------------------------------------*/
9618 vosStatus = WDA_DS_GetTxResources( pvosGCtx, &uResCount );
9619
9620 if ( (VOS_STATUS_SUCCESS != vosStatus) && (VOS_STATUS_E_RESOURCES != vosStatus))
9621 {
9622 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9623 "WLAN TL:TL failed to get resources from BAL, Err: %d",
9624 vosStatus));
9625 return vosStatus;
9626 }
9627
9628 /* Currently only Linux BAL returns the E_RESOURCES error code when it is running
9629 out of BD/PDUs. To make use of this interrupt for throughput enhancement, similar
9630 changes should be done in BAL code of AMSS and WM */
9631 if (VOS_STATUS_E_RESOURCES == vosStatus)
9632 {
9633#ifdef VOLANS_PERF
9634 WLANHAL_EnableIdleBdPduInterrupt(pvosGCtx, (tANI_U8)bdPduInterruptGetThreshold);
9635 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
9636 "WLAN TL: Enabling Idle BD/PDU interrupt, Current resources = %d", uResCount);
9637#else
9638 return VOS_STATUS_E_FAILURE;
9639#endif
9640 }
9641
9642 pTLCb->uResCount = uResCount;
9643
9644
Jeff Johnson295189b2012-06-20 16:38:30 -07009645#ifdef WLAN_SOFTAP_FLOWCTRL_EN
9646 /* FIXME: disabled since creating issues in power-save, needs to be addressed */
9647 pTLCb->sendFCFrame ++;
9648 pMac = vos_get_context(VOS_MODULE_ID_WDA, pvosGCtx);
9649 systemRole = wdaGetGlobalSystemRole(pMac);
9650 if (eSYSTEM_AP_ROLE == systemRole)
9651 {
9652 if (pTLCb->sendFCFrame % 16 == 0)
9653 {
9654 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
9655 "Transmit FC"));
9656 WLANTL_TxFCFrame (pvosGCtx);
9657 }
9658 }
9659#endif //WLAN_SOFTAP_FLOWCTRL_EN
Jeff Johnson295189b2012-06-20 16:38:30 -07009660
9661 ucData = ( pTLCb->uResCount >= WDA_TLI_MIN_RES_DATA );
9662 ucBAP = ( pTLCb->uResCount >= WDA_TLI_MIN_RES_BAP ) &&
9663 ( NULL != pTLCb->tlBAPClient.vosPendingDataBuff );
9664 ucMgmt = ( pTLCb->uResCount >= WDA_TLI_MIN_RES_MF ) &&
9665 ( NULL != pTLCb->tlMgmtFrmClient.vosPendingDataBuff );
9666
9667 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
9668 "WLAN TL: Eval Resume tx Res: %d DATA: %d BAP: %d MGMT: %d",
9669 pTLCb->uResCount, ucData, ucBAP, ucMgmt));
9670
9671 if (( 0 == pTLCb->ucTxSuspended ) &&
9672 (( 0 != ucData ) || ( 0 != ucMgmt ) || ( 0 != ucBAP ) ) )
9673 {
9674 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
9675 "Issuing Xmit start request to BAL for avail res SYNC"));
9676 vosStatus =WDA_DS_StartXmit(pvosGCtx);
9677 }
9678 return vosStatus;
9679}/*WLANTL_GetTxResourcesCB*/
9680
9681/*==========================================================================
9682 Utility functions
9683 ==========================================================================*/
9684
9685/*==========================================================================
9686 FUNCTION WLANTL_Translate8023To80211Header
9687
9688 DESCRIPTION
9689 Inline function for translating and 802.11 header into an 802.3 header.
9690
9691 DEPENDENCIES
9692
9693
9694 PARAMETERS
9695
9696 IN
9697 pTLCb: TL control block
Kiran Venkatappaa044eb92012-12-17 15:48:49 -08009698 IN/OUT
9699 ucStaId: station ID. Incase of TDLS, this returns actual TDLS
9700 station ID used
Jeff Johnson295189b2012-06-20 16:38:30 -07009701
9702 IN/OUT
9703 vosDataBuff: vos data buffer, will contain the new header on output
9704
9705 OUT
9706 pvosStatus: status of the operation
9707
9708 RETURN VALUE
9709
9710 VOS_STATUS_SUCCESS: Everything is good :)
9711
9712 Other error codes might be returned from the vos api used in the function
9713 please check those return values.
9714
9715 SIDE EFFECTS
9716
9717============================================================================*/
Kiran Venkatappacab0d352012-12-17 13:09:22 -08009718VOS_STATUS
9719WLANTL_Translate8023To80211Header
9720(
9721 vos_pkt_t* vosDataBuff,
9722 VOS_STATUS* pvosStatus,
9723 WLANTL_CbType* pTLCb,
9724 v_U8_t *pucStaId,
Ravi Joshid0699502013-07-08 15:48:47 -07009725 WLANTL_MetaInfoType *tlMetaInfo,
Kiran Venkatappacab0d352012-12-17 13:09:22 -08009726 v_U8_t *ucWDSEnabled,
9727 v_U8_t *extraHeadSpace
9728)
Jeff Johnson295189b2012-06-20 16:38:30 -07009729{
9730 WLANTL_8023HeaderType w8023Header;
9731 WLANTL_80211HeaderType *pw80211Header; // Allocate an aligned BD and then fill it.
9732 VOS_STATUS vosStatus;
9733 v_U8_t MandatoryucHeaderSize = WLAN80211_MANDATORY_HEADER_SIZE;
9734 v_U8_t ucHeaderSize = 0;
9735 v_VOID_t *ppvBDHeader = NULL;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309736 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07009737 v_U8_t ucQoSOffset = WLAN80211_MANDATORY_HEADER_SIZE;
Kiran Venkatappacab0d352012-12-17 13:09:22 -08009738 v_U8_t ucStaId;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009739#ifdef FEATURE_WLAN_ESE_UPLOAD
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009740 v_BOOL_t bIAPPTxwithLLC = VOS_FALSE;
9741 v_SIZE_t wIAPPSnapSize = WLANTL_LLC_HEADER_LEN;
9742 v_U8_t wIAPPSnap[WLANTL_LLC_HEADER_LEN] = {0};
9743#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009744 *ucWDSEnabled = 0; // default WDS off.
9745 vosStatus = vos_pkt_pop_head( vosDataBuff, &w8023Header,
9746 sizeof(w8023Header));
9747
9748 if ( VOS_STATUS_SUCCESS != vosStatus )
9749 {
9750 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9751 "WLAN TL: Packet pop header fails on WLANTL_Translate8023To80211Header"));
9752 return vosStatus;
9753 }
9754
Kiran Venkatappacab0d352012-12-17 13:09:22 -08009755 if( NULL == pucStaId )
9756 {
9757 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9758 "WLAN TL: Invalid pointer for StaId"));
9759 return VOS_STATUS_E_INVAL;
9760 }
9761 ucStaId = *pucStaId;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309762 pClientSTA = pTLCb->atlSTAClients[ucStaId];
9763
9764 if ( NULL == pClientSTA )
9765 {
9766 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9767 "WLAN TL:Client Memory was not allocated on %s", __func__));
9768 return VOS_STATUS_E_FAILURE;
9769 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -08009770
Kiran Venkatappaa044eb92012-12-17 15:48:49 -08009771#ifdef FEATURE_WLAN_TDLS
9772
Madan Mohan Koyylamudi64258222013-01-30 14:35:10 +05309773 if ( WLAN_STA_INFRA == pTLCb->atlSTAClients[ucStaId]->wSTADesc.wSTAType
9774 && pTLCb->ucTdlsPeerCount )
Kiran Venkatappacab0d352012-12-17 13:09:22 -08009775 {
9776 v_U8_t ucIndex = 0;
9777 for ( ucIndex = 0; ucIndex < WLAN_MAX_STA_COUNT ; ucIndex++)
9778 {
Madan Mohan Koyylamudi64258222013-01-30 14:35:10 +05309779 if ( ucIndex != ucStaId && pTLCb->atlSTAClients[ucIndex] && pTLCb->atlSTAClients[ucIndex]->ucExists &&
Gopichand Nakkala471708b2013-06-04 20:03:01 +05309780 (pTLCb->atlSTAClients[ucIndex]->tlState == WLANTL_STA_AUTHENTICATED) &&
9781 (!pTLCb->atlSTAClients[ucIndex]->ucTxSuspended) &&
Madan Mohan Koyylamudi64258222013-01-30 14:35:10 +05309782 vos_mem_compare( (void*)pTLCb->atlSTAClients[ucIndex]->wSTADesc.vSTAMACAddress.bytes,
Kiran Venkatappacab0d352012-12-17 13:09:22 -08009783 (void*)w8023Header.vDA, 6) )
9784 {
9785 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_LOW,
9786 "WLAN TL: Got a TDLS station. Using that index"));
9787 ucStaId = ucIndex;
9788 *pucStaId = ucStaId;
Madan Mohan Koyylamudi64258222013-01-30 14:35:10 +05309789 pClientSTA = pTLCb->atlSTAClients[ucStaId];
9790 if ( NULL == pClientSTA )
9791 {
9792 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9793 "WLAN TL:Client Memory was not allocated on %s", __func__));
9794 return VOS_STATUS_E_FAILURE;
9795 }
Kiran Venkatappacab0d352012-12-17 13:09:22 -08009796 break;
9797 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -08009798 }
Kiran Venkatappacab0d352012-12-17 13:09:22 -08009799 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -08009800#endif
9801
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009802#ifdef FEATURE_WLAN_ESE_UPLOAD
9803if ((0 == w8023Header.usLenType) && (pClientSTA->wSTADesc.ucIsEseSta))
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009804{
9805 vos_pkt_extract_data(vosDataBuff,0,&wIAPPSnap[0],&wIAPPSnapSize);
9806 if (vos_mem_compare(wIAPPSnap,WLANTL_AIRONET_SNAP_HEADER,WLANTL_LLC_HEADER_LEN))
9807 {
9808 /*The SNAP and the protocol type are already in the data buffer.
9809 They are filled by the application (wpa_supplicant). So, Skip Adding LLC below.*/
9810 bIAPPTxwithLLC = VOS_TRUE;
9811 }
9812 else
9813 {
9814 bIAPPTxwithLLC = VOS_FALSE;
9815 }
9816}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009817#endif /* FEATURE_WLAN_ESE_UPLOAD */
Jeff Johnson295189b2012-06-20 16:38:30 -07009818
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009819 if ((0 != pClientSTA->wSTADesc.ucAddRmvLLC)
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009820#ifdef FEATURE_WLAN_ESE_UPLOAD
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009821 && (!bIAPPTxwithLLC)
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009822#endif /* FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009823 )
Jeff Johnson295189b2012-06-20 16:38:30 -07009824 {
9825 /* Push the length */
9826 vosStatus = vos_pkt_push_head(vosDataBuff,
9827 &w8023Header.usLenType, sizeof(w8023Header.usLenType));
9828
9829 if ( VOS_STATUS_SUCCESS != vosStatus )
9830 {
9831 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9832 "WLAN TL: Packet push ether type fails on"
9833 " WLANTL_Translate8023To80211Header"));
9834 return vosStatus;
9835 }
9836
9837#ifdef BTAMP_TEST
9838 // The STA side will execute this, a hack to test BTAMP by using the
9839 // infra setup. On real BTAMP this will come from BAP itself.
9840 {
9841 static v_U8_t WLANTL_BT_AMP_LLC_HEADER[] = {0xAA, 0xAA, 0x03, 0x00, 0x19, 0x58 };
9842 vosStatus = vos_pkt_push_head(vosDataBuff, WLANTL_BT_AMP_LLC_HEADER,
9843 sizeof(WLANTL_BT_AMP_LLC_HEADER));
9844
9845 if ( VOS_STATUS_SUCCESS != vosStatus )
9846 {
9847 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9848 "WLAN TL: Packet push LLC header fails on"
9849 " WLANTL_Translate8023To80211Header"));
9850 return vosStatus;
9851 }
9852 }
9853#else
9854 vosStatus = vos_pkt_push_head(vosDataBuff, WLANTL_LLC_HEADER,
9855 sizeof(WLANTL_LLC_HEADER));
9856
9857 if ( VOS_STATUS_SUCCESS != vosStatus )
9858 {
9859 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9860 "WLAN TL: Packet push LLC header fails on"
9861 " WLANTL_Translate8023To80211Header"));
9862 return vosStatus;
9863 }
9864#endif
9865 }/*If add LLC is enabled*/
9866 else
9867 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009868#ifdef FEATURE_WLAN_ESE_UPLOAD
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009869 bIAPPTxwithLLC = VOS_FALSE; /*Reset the Flag here to start afresh with the next TX pkt*/
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009870#endif /* FEATURE_WLAN_ESE_UPLOAD */
Jeff Johnson295189b2012-06-20 16:38:30 -07009871 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
9872 "WLAN TL: STA Client registered to not remove LLC"
9873 " WLANTL_Translate8023To80211Header"));
9874 }
9875
9876#ifdef BTAMP_TEST
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309877 pClientSTA->wSTADesc.wSTAType = WLAN_STA_BT_AMP;
Jeff Johnson295189b2012-06-20 16:38:30 -07009878#endif
9879
9880 // Find the space required for the 802.11 header format
9881 // based on the frame control fields.
9882 ucHeaderSize = MandatoryucHeaderSize;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309883 if (pClientSTA->wSTADesc.ucQosEnabled)
Jeff Johnson295189b2012-06-20 16:38:30 -07009884 {
9885 ucHeaderSize += sizeof(pw80211Header->usQosCtrl);
9886 }
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309887 if (pClientSTA->wSTADesc.wSTAType == WLAN_STA_BT_AMP)
Jeff Johnson295189b2012-06-20 16:38:30 -07009888 {
9889 ucHeaderSize += sizeof(pw80211Header->optvA4);
Jeff Johnson295189b2012-06-20 16:38:30 -07009890 ucQoSOffset += sizeof(pw80211Header->optvA4);
Jeff Johnson295189b2012-06-20 16:38:30 -07009891 }
9892
9893 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
9894 " WLANTL_Translate8023To80211Header : Header size = %d ", ucHeaderSize));
9895
9896 vos_pkt_reserve_head( vosDataBuff, &ppvBDHeader, ucHeaderSize );
9897 if ( NULL == ppvBDHeader )
9898 {
9899 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9900 "WLAN TL:VOSS packet corrupted "));
9901 *pvosStatus = VOS_STATUS_E_INVAL;
9902 return *pvosStatus;
9903 }
9904
Jeff Johnson295189b2012-06-20 16:38:30 -07009905
9906 // OK now we have the space. Fill the 80211 header
9907 /* Fill A2 */
9908 pw80211Header = (WLANTL_80211HeaderType *)(ppvBDHeader);
9909 // only clear the required space.
9910 vos_mem_set( pw80211Header, ucHeaderSize, 0 );
9911 vos_mem_copy( pw80211Header->vA2, w8023Header.vSA, VOS_MAC_ADDR_SIZE);
9912
9913
9914#ifdef FEATURE_WLAN_WAPI
Gopichand Nakkala8b54e912013-03-11 10:44:21 +05309915 if (( WLANTL_STA_AUTHENTICATED == pClientSTA->tlState ||
9916 pClientSTA->ptkInstalled ) && gUcIsWai != 1)
Jeff Johnson295189b2012-06-20 16:38:30 -07009917#else
Gopichand Nakkala8b54e912013-03-11 10:44:21 +05309918 if ( WLANTL_STA_AUTHENTICATED == pClientSTA->tlState ||
9919 pClientSTA->ptkInstalled )
Jeff Johnson295189b2012-06-20 16:38:30 -07009920#endif
9921 {
9922 pw80211Header->wFrmCtrl.wep =
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309923 pClientSTA->wSTADesc.ucProtectedFrame;
Jeff Johnson295189b2012-06-20 16:38:30 -07009924 }
9925
9926 pw80211Header->usDurationId = 0;
9927 pw80211Header->usSeqCtrl = 0;
9928
9929 pw80211Header->wFrmCtrl.type = WLANTL_80211_DATA_TYPE;
9930
9931
9932
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309933 if(pClientSTA->wSTADesc.ucQosEnabled)
Jeff Johnson295189b2012-06-20 16:38:30 -07009934 {
9935 pw80211Header->wFrmCtrl.subType = WLANTL_80211_DATA_QOS_SUBTYPE;
9936
Ravi Joshid0699502013-07-08 15:48:47 -07009937 *((v_U16_t *)((v_U8_t *)ppvBDHeader + ucQoSOffset)) = tlMetaInfo->ucUP;
Jeff Johnson295189b2012-06-20 16:38:30 -07009938
9939 }
9940 else
9941 {
9942 pw80211Header->wFrmCtrl.subType = 0;
Agarwal Ashish8b343f12015-01-08 20:06:44 +05309943 tlMetaInfo->ucUP = 0;
9944 tlMetaInfo->ucTID = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07009945
9946 // NO NO NO - there is not enough memory allocated to write the QOS ctrl
9947 // field, it will overwrite the first 2 bytes of the data packet(LLC header)
9948 // pw80211Header->usQosCtrl = 0;
9949 }
9950
9951
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309952 switch( pClientSTA->wSTADesc.wSTAType )
Jeff Johnson295189b2012-06-20 16:38:30 -07009953 {
Ravi Joshid0699502013-07-08 15:48:47 -07009954 case WLAN_STA_IBSS:
Jeff Johnson295189b2012-06-20 16:38:30 -07009955 pw80211Header->wFrmCtrl.toDS = 0;
9956 pw80211Header->wFrmCtrl.fromDS = 0;
Ravi Joshid0699502013-07-08 15:48:47 -07009957
Abhishek Singh45e68fe2014-12-11 12:55:59 +05309958 vos_copy_macaddr( (v_MACADDR_t*)&pw80211Header->vA1,
Ravi Joshid0699502013-07-08 15:48:47 -07009959 (v_MACADDR_t*)&w8023Header.vDA);
Jeff Johnson295189b2012-06-20 16:38:30 -07009960 vos_mem_copy( pw80211Header->vA3,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309961 &pClientSTA->wSTADesc.vBSSIDforIBSS ,
Jeff Johnson295189b2012-06-20 16:38:30 -07009962 VOS_MAC_ADDR_SIZE);
9963 break;
9964
Ravi Joshid0699502013-07-08 15:48:47 -07009965 case WLAN_STA_BT_AMP:
Jeff Johnson295189b2012-06-20 16:38:30 -07009966 *ucWDSEnabled = 1; // WDS on.
9967 pw80211Header->wFrmCtrl.toDS = 1;
9968 pw80211Header->wFrmCtrl.fromDS = 1;
9969 vos_copy_macaddr( (v_MACADDR_t*)&pw80211Header->vA1,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309970 &pClientSTA->wSTADesc.vSTAMACAddress);
Jeff Johnson295189b2012-06-20 16:38:30 -07009971 vos_mem_copy( pw80211Header->vA2,
Ravi Joshid0699502013-07-08 15:48:47 -07009972 w8023Header.vSA, VOS_MAC_ADDR_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -07009973 vos_copy_macaddr( (v_MACADDR_t*)&pw80211Header->vA3,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309974 &pClientSTA->wSTADesc.vSTAMACAddress);
Jeff Johnson295189b2012-06-20 16:38:30 -07009975 /* fill the optional A4 header */
9976 vos_mem_copy( pw80211Header->optvA4,
Ravi Joshid0699502013-07-08 15:48:47 -07009977 w8023Header.vSA, VOS_MAC_ADDR_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -07009978 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
Arif Hussainf2b00992013-11-17 21:46:15 -08009979 "BTAMP CASE NOW ---------staid=%d",
Ravi Joshid0699502013-07-08 15:48:47 -07009980 ucStaId));
Jeff Johnson295189b2012-06-20 16:38:30 -07009981 break;
9982
Ravi Joshid0699502013-07-08 15:48:47 -07009983 case WLAN_STA_SOFTAP:
Jeff Johnson295189b2012-06-20 16:38:30 -07009984 *ucWDSEnabled = 0; // WDS off.
9985 pw80211Header->wFrmCtrl.toDS = 0;
9986 pw80211Header->wFrmCtrl.fromDS = 1;
9987 /*Copy the DA to A1*/
9988 vos_mem_copy( pw80211Header->vA1, w8023Header.vDA , VOS_MAC_ADDR_SIZE);
9989 vos_copy_macaddr( (v_MACADDR_t*)&pw80211Header->vA2,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309990 &pClientSTA->wSTADesc.vSelfMACAddress);
Jeff Johnson295189b2012-06-20 16:38:30 -07009991 vos_mem_copy( pw80211Header->vA3,
Ravi Joshid0699502013-07-08 15:48:47 -07009992 w8023Header.vSA, VOS_MAC_ADDR_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -07009993 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
Arif Hussainf2b00992013-11-17 21:46:15 -08009994 "sw 802 to 80211 softap case ---------staid=%d",
Ravi Joshid0699502013-07-08 15:48:47 -07009995 ucStaId));
Jeff Johnson295189b2012-06-20 16:38:30 -07009996 break;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08009997#ifdef FEATURE_WLAN_TDLS
Ravi Joshid0699502013-07-08 15:48:47 -07009998 case WLAN_STA_TDLS:
Mohit Khanna698ba2a2012-12-04 15:08:18 -08009999 pw80211Header->wFrmCtrl.toDS = 0;
10000 pw80211Header->wFrmCtrl.fromDS = 0;
10001 /*Fix me*/
10002 vos_copy_macaddr( (v_MACADDR_t*)&pw80211Header->vA1,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053010003 &pClientSTA->wSTADesc.vSTAMACAddress);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080010004 vos_mem_copy( pw80211Header->vA3,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053010005 &pClientSTA->wSTADesc.vBSSIDforIBSS ,
Mohit Khanna698ba2a2012-12-04 15:08:18 -080010006 VOS_MAC_ADDR_SIZE);
10007 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
Arif Hussainf2b00992013-11-17 21:46:15 -080010008 ("TL:TDLS CASE NOW ---------staid=%d"), ucStaId);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080010009 break;
10010#endif
Ravi Joshid0699502013-07-08 15:48:47 -070010011 case WLAN_STA_INFRA:
10012 default:
Jeff Johnson295189b2012-06-20 16:38:30 -070010013 pw80211Header->wFrmCtrl.toDS = 1;
10014 pw80211Header->wFrmCtrl.fromDS = 0;
10015 vos_copy_macaddr( (v_MACADDR_t*)&pw80211Header->vA1,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053010016 &pClientSTA->wSTADesc.vSTAMACAddress);
Jeff Johnson295189b2012-06-20 16:38:30 -070010017 vos_mem_copy( pw80211Header->vA3, w8023Header.vDA , VOS_MAC_ADDR_SIZE);
10018 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
Arif Hussainf2b00992013-11-17 21:46:15 -080010019 "REGULAR INFRA LINK CASE---------staid=%d",
Ravi Joshid0699502013-07-08 15:48:47 -070010020 ucStaId));
Jeff Johnson295189b2012-06-20 16:38:30 -070010021 break;
10022 }
10023 // OK now we have the space. Fill the 80211 header
10024 /* Fill A2 */
10025 pw80211Header = (WLANTL_80211HeaderType *)(ppvBDHeader);
10026 return VOS_STATUS_SUCCESS;
10027}/*WLANTL_Translate8023To80211Header*/
10028
10029
10030/*=============================================================================
10031 BEGIN LOG FUNCTION !!! Remove me or clean me
10032=============================================================================*/
Ravi Kumar Vaishnavb7652402013-01-18 19:05:15 -080010033#if 0 //def WLANTL_DEBUG
Jeff Johnson295189b2012-06-20 16:38:30 -070010034
10035#define WLANTL_DEBUG_FRAME_BYTE_PER_LINE 16
10036#define WLANTL_DEBUG_FRAME_BYTE_PER_BYTE 4
10037
10038static v_VOID_t WLANTL_DebugFrame
10039(
10040 v_PVOID_t dataPointer,
10041 v_U32_t dataSize
10042)
10043{
10044 v_U8_t lineBuffer[WLANTL_DEBUG_FRAME_BYTE_PER_LINE];
10045 v_U32_t numLines;
10046 v_U32_t numBytes;
10047 v_U32_t idx;
10048 v_U8_t *linePointer;
10049
10050 numLines = dataSize / WLANTL_DEBUG_FRAME_BYTE_PER_LINE;
10051 numBytes = dataSize % WLANTL_DEBUG_FRAME_BYTE_PER_LINE;
10052 linePointer = (v_U8_t *)dataPointer;
10053
10054 TLLOGE(VOS_TRACE(VOS_MODULE_ID_SAL, VOS_TRACE_LEVEL_ERROR, "WLAN TL:Frame Debug Frame Size %d, Pointer 0x%p", dataSize, dataPointer));
10055 for(idx = 0; idx < numLines; idx++)
10056 {
10057 memset(lineBuffer, 0, WLANTL_DEBUG_FRAME_BYTE_PER_LINE);
10058 memcpy(lineBuffer, linePointer, WLANTL_DEBUG_FRAME_BYTE_PER_LINE);
10059 TLLOGE(VOS_TRACE(VOS_MODULE_ID_SAL, VOS_TRACE_LEVEL_ERROR,
10060 "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",
10061 lineBuffer[0], lineBuffer[1], lineBuffer[2], lineBuffer[3], lineBuffer[4], lineBuffer[5], lineBuffer[6], lineBuffer[7],
10062 lineBuffer[8], lineBuffer[9], lineBuffer[10], lineBuffer[11], lineBuffer[12], lineBuffer[13], lineBuffer[14], lineBuffer[15]));
10063 linePointer += WLANTL_DEBUG_FRAME_BYTE_PER_LINE;
10064 }
10065
10066 if(0 == numBytes)
10067 return;
10068
10069 memset(lineBuffer, 0, WLANTL_DEBUG_FRAME_BYTE_PER_LINE);
10070 memcpy(lineBuffer, linePointer, numBytes);
10071 for(idx = 0; idx < WLANTL_DEBUG_FRAME_BYTE_PER_LINE / WLANTL_DEBUG_FRAME_BYTE_PER_BYTE; idx++)
10072 {
10073 TLLOGE(VOS_TRACE(VOS_MODULE_ID_SAL, VOS_TRACE_LEVEL_ERROR, "WLAN TL:0x%2x 0x%2x 0x%2x 0x%2x",
10074 lineBuffer[idx * WLANTL_DEBUG_FRAME_BYTE_PER_BYTE], lineBuffer[1 + idx * WLANTL_DEBUG_FRAME_BYTE_PER_BYTE],
10075 lineBuffer[2 + idx * WLANTL_DEBUG_FRAME_BYTE_PER_BYTE], lineBuffer[3 + idx * WLANTL_DEBUG_FRAME_BYTE_PER_BYTE]));
10076 if(((idx + 1) * WLANTL_DEBUG_FRAME_BYTE_PER_BYTE) >= numBytes)
10077 break;
10078 }
10079
10080 return;
10081}
10082#endif
10083
10084/*=============================================================================
10085 END LOG FUNCTION
10086=============================================================================*/
10087
10088/*==========================================================================
10089 FUNCTION WLANTL_Translate80211To8023Header
10090
10091 DESCRIPTION
10092 Inline function for translating and 802.11 header into an 802.3 header.
10093
10094 DEPENDENCIES
10095
10096
10097 PARAMETERS
10098
10099 IN
10100 pTLCb: TL control block
10101 ucStaId: station ID
10102 ucHeaderLen: Length of the header from BD
10103 ucActualHLen: Length of header including padding or any other trailers
10104
10105 IN/OUT
10106 vosDataBuff: vos data buffer, will contain the new header on output
10107
10108 OUT
10109 pvosStatus: status of the operation
10110
10111 RETURN VALUE
10112
10113 The result code associated with performing the operation
10114 VOS_STATUS_SUCCESS: Everything is good :)
10115
10116 SIDE EFFECTS
10117
10118============================================================================*/
10119VOS_STATUS
10120WLANTL_Translate80211To8023Header
10121(
10122 vos_pkt_t* vosDataBuff,
10123 VOS_STATUS* pvosStatus,
10124 v_U16_t usActualHLen,
10125 v_U8_t ucHeaderLen,
10126 WLANTL_CbType* pTLCb,
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070010127 v_U8_t ucSTAId,
10128 v_BOOL_t bForwardIAPPwithLLC
Jeff Johnson295189b2012-06-20 16:38:30 -070010129)
10130{
10131 WLANTL_8023HeaderType w8023Header;
10132 WLANTL_80211HeaderType w80211Header;
10133 v_U8_t aucLLCHeader[WLANTL_LLC_HEADER_LEN];
10134 VOS_STATUS vosStatus;
10135 v_U16_t usDataStartOffset = 0;
10136 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
10137
10138 if ( sizeof(w80211Header) < ucHeaderLen )
10139 {
10140 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
10141 "Warning !: Check the header size for the Rx frame structure=%d received=%dn",
10142 sizeof(w80211Header), ucHeaderLen));
10143 ucHeaderLen = sizeof(w80211Header);
10144 }
10145
10146 // This will take care of headers of all sizes, 3 address, 3 addr QOS,
10147 // WDS non-QOS and WDS QoS etc. We have space for all in the 802.11 header structure.
10148 vosStatus = vos_pkt_pop_head( vosDataBuff, &w80211Header, ucHeaderLen);
10149
10150 if ( VOS_STATUS_SUCCESS != vosStatus )
10151 {
10152 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
10153 "WLAN TL: Failed to pop 80211 header from packet %d",
10154 vosStatus));
10155
10156 return vosStatus;
10157 }
10158
10159 switch ( w80211Header.wFrmCtrl.fromDS )
10160 {
10161 case 0:
Jeff Johnson295189b2012-06-20 16:38:30 -070010162 if ( w80211Header.wFrmCtrl.toDS )
10163 {
10164 //SoftAP AP mode
10165 vos_mem_copy( w8023Header.vDA, w80211Header.vA3, VOS_MAC_ADDR_SIZE);
10166 vos_mem_copy( w8023Header.vSA, w80211Header.vA2, VOS_MAC_ADDR_SIZE);
10167 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
Arif Hussainf2b00992013-11-17 21:46:15 -080010168 "WLAN TL SoftAP: 802 3 DA %08x SA %08x",
Jeff Johnson295189b2012-06-20 16:38:30 -070010169 w8023Header.vDA, w8023Header.vSA));
10170 }
10171 else
10172 {
10173 /* IBSS */
10174 vos_mem_copy( w8023Header.vDA, w80211Header.vA1, VOS_MAC_ADDR_SIZE);
10175 vos_mem_copy( w8023Header.vSA, w80211Header.vA2, VOS_MAC_ADDR_SIZE);
10176 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010177 break;
10178 case 1:
10179 if ( w80211Header.wFrmCtrl.toDS )
10180 {
10181 /* BT-AMP case */
10182 vos_mem_copy( w8023Header.vDA, w80211Header.vA1, VOS_MAC_ADDR_SIZE);
10183 vos_mem_copy( w8023Header.vSA, w80211Header.vA2, VOS_MAC_ADDR_SIZE);
10184 }
10185 else
10186 { /* Infra */
10187 vos_mem_copy( w8023Header.vDA, w80211Header.vA1, VOS_MAC_ADDR_SIZE);
10188 vos_mem_copy( w8023Header.vSA, w80211Header.vA3, VOS_MAC_ADDR_SIZE);
10189 }
10190 break;
10191 }
10192
10193 if( usActualHLen > ucHeaderLen )
10194 {
10195 usDataStartOffset = usActualHLen - ucHeaderLen;
10196 }
10197
10198 if ( 0 < usDataStartOffset )
10199 {
10200 vosStatus = vos_pkt_trim_head( vosDataBuff, usDataStartOffset );
10201
10202 if ( VOS_STATUS_SUCCESS != vosStatus )
10203 {
10204 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
10205 "WLAN TL: Failed to trim header from packet %d",
10206 vosStatus));
10207 return vosStatus;
10208 }
10209 }
10210
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053010211 if ( NULL == pTLCb->atlSTAClients[ucSTAId] )
10212 {
10213 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
10214 "WLAN TL:Client Memory was not allocated on %s", __func__));
10215 return VOS_STATUS_E_FAILURE;
10216 }
10217
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070010218 if ( 0 != pTLCb->atlSTAClients[ucSTAId]->wSTADesc.ucAddRmvLLC
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010219#ifdef FEATURE_WLAN_ESE_UPLOAD
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070010220 && (!bForwardIAPPwithLLC)
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010221#endif /* FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070010222 )
Jeff Johnson295189b2012-06-20 16:38:30 -070010223 {
10224 // Extract the LLC header
10225 vosStatus = vos_pkt_pop_head( vosDataBuff, aucLLCHeader,
10226 WLANTL_LLC_HEADER_LEN);
10227
10228 if ( VOS_STATUS_SUCCESS != vosStatus )
10229 {
Kaushik, Sushante386ee12014-05-01 15:50:52 +053010230 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
Jeff Johnson295189b2012-06-20 16:38:30 -070010231 "WLAN TL: Failed to pop LLC header from packet %d",
10232 vosStatus));
10233
10234 return vosStatus;
10235 }
10236
10237 //Extract the length
10238 vos_mem_copy(&w8023Header.usLenType,
10239 &aucLLCHeader[WLANTL_LLC_HEADER_LEN - sizeof(w8023Header.usLenType)],
10240 sizeof(w8023Header.usLenType) );
10241 }
10242 else
10243 {
10244 vosStatus = vos_pkt_get_packet_length(vosDataBuff,
10245 &w8023Header.usLenType);
10246
10247 if ( VOS_STATUS_SUCCESS != vosStatus )
10248 {
10249 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
10250 "WLAN TL: Failed to get packet length %d",
10251 vosStatus));
10252
10253 return vosStatus;
10254 }
10255
10256 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
10257 "WLAN TL: BTAMP len (ethertype) fld = %d",
10258 w8023Header.usLenType));
10259 w8023Header.usLenType = vos_cpu_to_be16(w8023Header.usLenType);
10260 }
10261
10262 vos_pkt_push_head(vosDataBuff, &w8023Header, sizeof(w8023Header));
10263
10264#ifdef BTAMP_TEST
10265 {
10266 // AP side will execute this.
10267 v_U8_t *temp_w8023Header = NULL;
10268 vosStatus = vos_pkt_peek_data( vosDataBuff, 0,
10269 &temp_w8023Header, sizeof(w8023Header) );
10270 }
10271#endif
10272#if 0 /*TL_DEBUG*/
10273 vos_pkt_get_packet_length(vosDataBuff, &usLen);
10274 vos_pkt_pop_head( vosDataBuff, aucData, usLen);
10275
10276 WLANTL_DebugFrame(aucData, usLen);
10277
10278 vos_pkt_push_head(vosDataBuff, aucData, usLen);
10279
10280#endif
10281
10282 *pvosStatus = VOS_STATUS_SUCCESS;
10283
10284 return VOS_STATUS_SUCCESS;
10285}/*WLANTL_Translate80211To8023Header*/
10286
Katya Nigame7b69a82015-04-28 15:24:06 +053010287VOS_STATUS
10288WLANTL_MonTranslate80211To8023Header
10289(
10290 vos_pkt_t* vosDataBuff,
10291 WLANTL_CbType* pTLCb
10292)
10293{
10294 v_U16_t usMPDUDOffset;
10295 v_U8_t ucMPDUHOffset;
10296 v_U8_t ucMPDUHLen;
10297 v_U16_t usActualHLen = 0;
10298 v_U16_t usDataStartOffset = 0;
10299 v_PVOID_t aucBDHeader;
10300 WLANTL_8023HeaderType w8023Header;
10301 WLANTL_80211HeaderType w80211Header;
10302 VOS_STATUS vosStatus;
10303 v_U8_t aucLLCHeader[WLANTL_LLC_HEADER_LEN];
10304
10305 WDA_DS_PeekRxPacketInfo( vosDataBuff, (v_PVOID_t)&aucBDHeader, 0 );
10306 ucMPDUHOffset = (v_U8_t)WDA_GET_RX_MPDU_HEADER_OFFSET(aucBDHeader);
10307 usMPDUDOffset = (v_U16_t)WDA_GET_RX_MPDU_DATA_OFFSET(aucBDHeader);
10308 ucMPDUHLen = (v_U8_t)WDA_GET_RX_MPDU_HEADER_LEN(aucBDHeader);
10309 if (usMPDUDOffset > ucMPDUHOffset)
10310 {
10311 usActualHLen = usMPDUDOffset - ucMPDUHOffset;
10312 }
10313
10314 if ( sizeof(w80211Header) < ucMPDUHLen )
10315 {
10316 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
10317 "Warning !: Check the header size for the Rx frame structure=%d received=%dn",
10318 sizeof(w80211Header), ucMPDUHLen));
10319 ucMPDUHLen = sizeof(w80211Header);
10320 }
10321
10322 vosStatus = vos_pkt_pop_head( vosDataBuff, &w80211Header, ucMPDUHLen);
10323 if ( VOS_STATUS_SUCCESS != vosStatus )
10324 {
10325 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
10326 "WLAN TL: Failed to pop 80211 header from packet %d",
10327 vosStatus));
10328
10329 return vosStatus;
10330 }
10331 switch ( w80211Header.wFrmCtrl.fromDS )
10332 {
10333 case 0:
10334 if ( w80211Header.wFrmCtrl.toDS )
10335 {
10336 vos_mem_copy( w8023Header.vDA, w80211Header.vA3, VOS_MAC_ADDR_SIZE);
10337 vos_mem_copy( w8023Header.vSA, w80211Header.vA2, VOS_MAC_ADDR_SIZE);
10338 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
10339 "WLAN TL SoftAP: 802 3 DA %08x SA %08x",
10340 w8023Header.vDA, w8023Header.vSA));
10341 }
10342 else
10343 {
10344 vos_mem_copy( w8023Header.vDA, w80211Header.vA1, VOS_MAC_ADDR_SIZE);
10345 vos_mem_copy( w8023Header.vSA, w80211Header.vA2, VOS_MAC_ADDR_SIZE);
10346 }
10347 break;
10348 case 1:
10349 if ( w80211Header.wFrmCtrl.toDS )
10350 {
10351 vos_mem_copy( w8023Header.vDA, w80211Header.vA1, VOS_MAC_ADDR_SIZE);
10352 vos_mem_copy( w8023Header.vSA, w80211Header.vA2, VOS_MAC_ADDR_SIZE);
10353 }
10354 else
10355 {
10356 vos_mem_copy( w8023Header.vDA, w80211Header.vA1, VOS_MAC_ADDR_SIZE);
10357 vos_mem_copy( w8023Header.vSA, w80211Header.vA3, VOS_MAC_ADDR_SIZE);
10358 }
10359 break;
10360 }
10361 if( usActualHLen > ucMPDUHLen )
10362 {
10363 usDataStartOffset = usActualHLen - ucMPDUHLen;
10364 }
10365
10366 if ( 0 < usDataStartOffset )
10367 {
10368 vosStatus = vos_pkt_trim_head( vosDataBuff, usDataStartOffset );
10369
10370 if ( VOS_STATUS_SUCCESS != vosStatus )
10371 {
10372 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
10373 "WLAN TL: Failed to trim header from packet %d",
10374 vosStatus));
10375 return vosStatus;
10376 }
10377 }
10378 // Extract the LLC header
10379 vosStatus = vos_pkt_pop_head( vosDataBuff, aucLLCHeader,
10380 WLANTL_LLC_HEADER_LEN);
10381
10382 if ( VOS_STATUS_SUCCESS != vosStatus )
10383 {
10384 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
10385 "WLAN TL: Failed to pop LLC header from packet %d",
10386 vosStatus));
10387
10388 return vosStatus;
10389 }
10390
10391 //Extract the length
10392 vos_mem_copy(&w8023Header.usLenType,
10393 &aucLLCHeader[WLANTL_LLC_HEADER_LEN - sizeof(w8023Header.usLenType)],
10394 sizeof(w8023Header.usLenType) );
10395
10396 vos_pkt_push_head(vosDataBuff, &w8023Header, sizeof(w8023Header));
10397 return VOS_STATUS_SUCCESS;
10398}
10399
Madan Mohan Koyyalamudia148e1e2012-11-30 14:52:59 -080010400/*==========================================================================
10401 FUNCTION WLANTL_FindFrameTypeBcMcUc
10402
10403 DESCRIPTION
10404 Utility function to find whether received frame is broadcast, multicast
10405 or unicast.
10406
10407 DEPENDENCIES
10408 The STA must be registered with TL before this function can be called.
10409
10410 PARAMETERS
10411
10412 IN
10413 pTLCb: pointer to the TL's control block
10414 ucSTAId: identifier of the station being processed
10415 vosDataBuff: pointer to the vos buffer
10416
10417 IN/OUT
10418 pucBcMcUc: pointer to buffer, will contain frame type on return
10419
10420 RETURN VALUE
10421 The result code associated with performing the operation
10422
10423 VOS_STATUS_E_INVAL: invalid input parameters
10424 VOS_STATUS_E_BADMSG: failed to extract info from data buffer
10425 VOS_STATUS_SUCCESS: success
10426
10427 SIDE EFFECTS
10428 None.
10429============================================================================*/
10430VOS_STATUS
10431WLANTL_FindFrameTypeBcMcUc
10432(
10433 WLANTL_CbType *pTLCb,
10434 v_U8_t ucSTAId,
10435 vos_pkt_t *vosDataBuff,
10436 v_U8_t *pucBcMcUc
10437)
10438{
10439 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
10440 v_PVOID_t aucBDHeader;
10441 v_PVOID_t pvPeekData;
10442 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
10443
10444 /*------------------------------------------------------------------------
10445 Sanity check
10446 ------------------------------------------------------------------------*/
10447 if ((NULL == pTLCb) ||
10448 (NULL == vosDataBuff) ||
10449 (NULL == pucBcMcUc))
10450 {
10451 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
10452 "WLAN TL:Invalid parameter in WLANTL_FindFrameTypeBcMcUc"));
10453 return VOS_STATUS_E_INVAL;
10454 }
10455
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053010456 if ( NULL == pTLCb->atlSTAClients[ucSTAId] )
10457 {
10458 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
10459 "WLAN TL:Client Memory was not allocated on %s", __func__));
10460 return VOS_STATUS_E_FAILURE;
10461 }
10462
Madan Mohan Koyyalamudia148e1e2012-11-30 14:52:59 -080010463 /*------------------------------------------------------------------------
10464 Extract BD header and check if valid
10465 ------------------------------------------------------------------------*/
10466 vosStatus = WDA_DS_PeekRxPacketInfo(vosDataBuff, (v_PVOID_t)&aucBDHeader, 0/*Swap BD*/ );
10467
10468 if (NULL == aucBDHeader)
10469 {
10470 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
10471 "WLAN TL:WLANTL_FindFrameTypeBcMcUc - Cannot extract BD header"));
10472 VOS_ASSERT(0);
10473 return VOS_STATUS_E_BADMSG;
10474 }
10475
10476 if ((0 == WDA_GET_RX_FT_DONE(aucBDHeader)) &&
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053010477 (0 != pTLCb->atlSTAClients[ucSTAId]->wSTADesc.ucSwFrameRXXlation))
Madan Mohan Koyyalamudia148e1e2012-11-30 14:52:59 -080010478 {
10479 /* Its an 802.11 frame, extract MAC address 1 */
10480 TLLOG2(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
10481 "WLAN TL:WLANTL_FindFrameTypeBcMcUc - 802.11 frame, peeking Addr1"));
10482 vosStatus = vos_pkt_peek_data(vosDataBuff, WLANTL_MAC_ADDR_ALIGN(1),
10483 (v_PVOID_t)&pvPeekData, VOS_MAC_ADDR_SIZE);
10484 }
10485 else
10486 {
10487 /* Its an 802.3 frame, extract Destination MAC address */
10488 TLLOG2(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
10489 "WLAN TL:WLANTL_FindFrameTypeBcMcUc - 802.3 frame, peeking DA"));
10490 vosStatus = vos_pkt_peek_data(vosDataBuff, WLANTL_MAC_ADDR_ALIGN(0),
10491 (v_PVOID_t)&pvPeekData, VOS_MAC_ADDR_SIZE);
10492 }
10493
10494 if (VOS_STATUS_SUCCESS != vosStatus)
10495 {
10496 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
10497 "WLAN TL:WLANTL_FindFrameTypeBcMcUc - Failed to peek MAC address"));
10498 return vosStatus;
10499 }
10500
10501 if (((tANI_U8 *)pvPeekData)[0] == 0xff)
10502 {
10503 *pucBcMcUc = WLANTL_FRAME_TYPE_BCAST;
10504 }
10505 else
10506 {
10507 if ((((tANI_U8 *)pvPeekData)[0] & 0x01) == 0x01)
10508 *pucBcMcUc = WLANTL_FRAME_TYPE_MCAST;
10509 else
10510 *pucBcMcUc = WLANTL_FRAME_TYPE_UCAST;
10511 }
10512
10513 TLLOG2(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
10514 "WLAN TL:WLANTL_FindFrameTypeBcMcUc - Addr1Byte1 is: %x",
10515 ((tANI_U8 *)pvPeekData)[0]));
10516
10517 return VOS_STATUS_SUCCESS;
10518}
10519
Jeff Johnson295189b2012-06-20 16:38:30 -070010520#if 0
10521#ifdef WLAN_PERF
10522/*==========================================================================
10523 FUNCTION WLANTL_FastHwFwdDataFrame
10524
10525 DESCRIPTION
10526 Fast path function to quickly forward a data frame if HAL determines BD
10527 signature computed here matches the signature inside current VOSS packet.
10528 If there is a match, HAL and TL fills in the swapped packet length into
10529 BD header and DxE header, respectively. Otherwise, packet goes back to
10530 normal (slow) path and a new BD signature would be tagged into BD in this
10531 VOSS packet later by the WLANHAL_FillTxBd() function.
10532
10533 DEPENDENCIES
10534
10535 PARAMETERS
10536
10537 IN
10538 pvosGCtx VOS context
10539 vosDataBuff Ptr to VOSS packet
10540 pMetaInfo For getting frame's TID
10541 pStaInfo For checking STA type
10542
10543 OUT
10544 pvosStatus returned status
10545 puFastFwdOK Flag to indicate whether frame could be fast forwarded
10546
10547 RETURN VALUE
10548 No return.
10549
10550 SIDE EFFECTS
10551
10552============================================================================*/
10553static void
10554WLANTL_FastHwFwdDataFrame
10555(
10556 v_PVOID_t pvosGCtx,
10557 vos_pkt_t* vosDataBuff,
10558 VOS_STATUS* pvosStatus,
10559 v_U32_t* puFastFwdOK,
10560 WLANTL_MetaInfoType* pMetaInfo,
10561 WLAN_STADescType* pStaInfo
10562
10563)
10564{
10565 v_PVOID_t pvPeekData;
10566 v_U8_t ucDxEBDWLANHeaderLen = WLANTL_BD_HEADER_LEN(0) + sizeof(WLANBAL_sDXEHeaderType);
10567 v_U8_t ucIsUnicast;
10568 WLANBAL_sDXEHeaderType *pDxEHeader;
10569 v_PVOID_t pvBDHeader;
10570 v_PVOID_t pucBuffPtr;
10571 v_U16_t usPktLen;
10572
10573 /*-----------------------------------------------------------------------
10574 Extract packet length
10575 -----------------------------------------------------------------------*/
10576
10577 vos_pkt_get_packet_length( vosDataBuff, &usPktLen);
10578
10579 /*-----------------------------------------------------------------------
10580 Extract MAC address
10581 -----------------------------------------------------------------------*/
10582 *pvosStatus = vos_pkt_peek_data( vosDataBuff,
10583 WLANTL_MAC_ADDR_ALIGN(0),
10584 (v_PVOID_t)&pvPeekData,
10585 VOS_MAC_ADDR_SIZE );
10586
10587 if ( VOS_STATUS_SUCCESS != *pvosStatus )
10588 {
10589 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
10590 "WLAN TL:Failed while attempting to extract MAC Addr %d",
10591 *pvosStatus));
10592 *pvosStatus = VOS_STATUS_E_INVAL;
10593 return;
10594 }
10595
10596 /*-----------------------------------------------------------------------
10597 Reserve head room for DxE header, BD, and WLAN header
10598 -----------------------------------------------------------------------*/
10599
10600 vos_pkt_reserve_head( vosDataBuff, &pucBuffPtr,
10601 ucDxEBDWLANHeaderLen );
10602 if ( NULL == pucBuffPtr )
10603 {
10604 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
10605 "WLAN TL:No enough space in VOSS packet %p for DxE/BD/WLAN header", vosDataBuff));
10606 *pvosStatus = VOS_STATUS_E_INVAL;
10607 return;
10608 }
10609 pDxEHeader = (WLANBAL_sDXEHeaderType *)pucBuffPtr;
10610 pvBDHeader = (v_PVOID_t) &pDxEHeader[1];
10611
10612 /* UMA Tx acceleration is enabled.
10613 * UMA would help convert frames to 802.11, fill partial BD fields and
10614 * construct LLC header. To further accelerate this kind of frames,
10615 * HAL would attempt to reuse the BD descriptor if the BD signature
10616 * matches to the saved BD descriptor.
10617 */
10618 if(pStaInfo->wSTAType == WLAN_STA_IBSS)
10619 ucIsUnicast = !(((tANI_U8 *)pvPeekData)[0] & 0x01);
10620 else
10621 ucIsUnicast = 1;
10622
10623 *puFastFwdOK = (v_U32_t) WLANHAL_TxBdFastFwd(pvosGCtx, pvPeekData, pMetaInfo->ucTID, ucIsUnicast, pvBDHeader, usPktLen );
10624
10625 /* Can't be fast forwarded. Trim the VOS head back to original location. */
10626 if(! *puFastFwdOK){
10627 vos_pkt_trim_head(vosDataBuff, ucDxEBDWLANHeaderLen);
10628 }else{
10629 /* could be fast forwarded. Now notify BAL DxE header filling could be completely skipped
10630 */
10631 v_U32_t uPacketSize = WLANTL_BD_HEADER_LEN(0) + usPktLen;
10632 vos_pkt_set_user_data_ptr( vosDataBuff, VOS_PKT_USER_DATA_ID_BAL,
10633 (v_PVOID_t)uPacketSize);
10634 pDxEHeader->size = SWAP_ENDIAN_UINT32(uPacketSize);
10635 }
10636 *pvosStatus = VOS_STATUS_SUCCESS;
10637 return;
10638}
10639#endif /*WLAN_PERF*/
10640#endif
10641
10642#if 0
10643/*==========================================================================
10644 FUNCTION WLANTL_PrepareBDHeader
10645
10646 DESCRIPTION
10647 Inline function for preparing BD header before HAL processing.
10648
10649 DEPENDENCIES
10650 Just notify HAL that suspend in TL is complete.
10651
10652 PARAMETERS
10653
10654 IN
10655 vosDataBuff: vos data buffer
10656 ucDisableFrmXtl: is frame xtl disabled
10657
10658 OUT
10659 ppvBDHeader: it will contain the BD header
10660 pvDestMacAdddr: it will contain the destination MAC address
10661 pvosStatus: status of the combined processing
10662 pusPktLen: packet len.
10663
10664 RETURN VALUE
10665 No return.
10666
10667 SIDE EFFECTS
10668
10669============================================================================*/
10670void
10671WLANTL_PrepareBDHeader
10672(
10673 vos_pkt_t* vosDataBuff,
10674 v_PVOID_t* ppvBDHeader,
10675 v_MACADDR_t* pvDestMacAdddr,
10676 v_U8_t ucDisableFrmXtl,
10677 VOS_STATUS* pvosStatus,
10678 v_U16_t* pusPktLen,
10679 v_U8_t ucQosEnabled,
10680 v_U8_t ucWDSEnabled,
10681 v_U8_t extraHeadSpace
10682)
10683{
10684 v_U8_t ucHeaderOffset;
10685 v_U8_t ucHeaderLen;
Jeff Johnson295189b2012-06-20 16:38:30 -070010686 v_U8_t ucBDHeaderLen = WLANTL_BD_HEADER_LEN(ucDisableFrmXtl);
10687
10688 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
10689 /*-------------------------------------------------------------------------
10690 Get header pointer from VOSS
10691 !!! make sure reserve head zeros out the memory
10692 -------------------------------------------------------------------------*/
10693 vos_pkt_get_packet_length( vosDataBuff, pusPktLen);
10694
10695 if ( WLANTL_MAC_HEADER_LEN(ucDisableFrmXtl) > *pusPktLen )
10696 {
10697 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
10698 "WLAN TL: Length of the packet smaller than expected network"
10699 " header %d", *pusPktLen ));
10700
10701 *pvosStatus = VOS_STATUS_E_INVAL;
10702 return;
10703 }
10704
10705 vos_pkt_reserve_head( vosDataBuff, ppvBDHeader,
10706 ucBDHeaderLen );
10707 if ( NULL == *ppvBDHeader )
10708 {
10709 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
10710 "WLAN TL:VOSS packet corrupted on Attach BD header"));
10711 *pvosStatus = VOS_STATUS_E_INVAL;
10712 return;
10713 }
10714
10715 /*-----------------------------------------------------------------------
10716 Extract MAC address
10717 -----------------------------------------------------------------------*/
Jeff Johnson295189b2012-06-20 16:38:30 -070010718 {
10719 v_SIZE_t usMacAddrSize = VOS_MAC_ADDR_SIZE;
10720 *pvosStatus = vos_pkt_extract_data( vosDataBuff,
10721 ucBDHeaderLen +
10722 WLANTL_MAC_ADDR_ALIGN(ucDisableFrmXtl),
10723 (v_PVOID_t)pvDestMacAdddr,
10724 &usMacAddrSize );
10725 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010726 if ( VOS_STATUS_SUCCESS != *pvosStatus )
10727 {
10728 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
10729 "WLAN TL:Failed while attempting to extract MAC Addr %d",
10730 *pvosStatus));
10731 }
10732 else
10733 {
10734 /*---------------------------------------------------------------------
10735 Fill MPDU info fields:
10736 - MPDU data start offset
10737 - MPDU header start offset
10738 - MPDU header length
10739 - MPDU length - this is a 16b field - needs swapping
10740 --------------------------------------------------------------------*/
10741 ucHeaderOffset = ucBDHeaderLen;
10742 ucHeaderLen = WLANTL_MAC_HEADER_LEN(ucDisableFrmXtl);
10743
10744 if ( 0 != ucDisableFrmXtl )
10745 {
10746 if ( 0 != ucQosEnabled )
10747 {
10748 ucHeaderLen += WLANTL_802_11_HEADER_QOS_CTL;
10749 }
10750
10751 // Similar to Qos we need something for WDS format !
10752 if ( ucWDSEnabled != 0 )
10753 {
10754 // If we have frame translation enabled
10755 ucHeaderLen += WLANTL_802_11_HEADER_ADDR4_LEN;
10756 }
10757 if ( extraHeadSpace != 0 )
10758 {
10759 // Decrease the packet length with the extra padding after the header
10760 *pusPktLen = *pusPktLen - extraHeadSpace;
10761 }
10762 }
10763
10764 WLANHAL_TX_BD_SET_MPDU_HEADER_LEN( *ppvBDHeader, ucHeaderLen);
10765 WLANHAL_TX_BD_SET_MPDU_HEADER_OFFSET( *ppvBDHeader, ucHeaderOffset);
10766 WLANHAL_TX_BD_SET_MPDU_DATA_OFFSET( *ppvBDHeader,
10767 ucHeaderOffset + ucHeaderLen + extraHeadSpace);
10768 WLANHAL_TX_BD_SET_MPDU_LEN( *ppvBDHeader, *pusPktLen);
10769
10770 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
10771 "WLAN TL: VALUES ARE HLen=%x Hoff=%x doff=%x len=%x ex=%d",
10772 ucHeaderLen, ucHeaderOffset,
10773 (ucHeaderOffset + ucHeaderLen + extraHeadSpace),
10774 *pusPktLen, extraHeadSpace));
10775 }/* if peek MAC success*/
10776
10777}/* WLANTL_PrepareBDHeader */
10778#endif
10779
Jeff Johnson295189b2012-06-20 16:38:30 -070010780//THIS IS A HACK AND NEEDS TO BE FIXED FOR CONCURRENCY
10781/*==========================================================================
10782 FUNCTION WLAN_TLGetNextTxIds
10783
10784 DESCRIPTION
10785 Gets the next station and next AC in the list that should be served by the TL.
10786
10787 Multiple Station Scheduling and TL queue management.
10788
10789 4 HDD BC/MC data packet queue status is specified as Station 0's status. Weights used
10790 in WFQ algorith are initialized in WLANTL_OPEN and contained in tlConfigInfo field.
10791 Each station has fields of ucPktPending and AC mask to tell whether a AC has traffic
10792 or not.
10793
10794 Stations are served in a round-robin fashion from highest priority to lowest priority.
10795 The number of round-robin times of each prioirty equals to the WFQ weights and differetiates
10796 the traffic of different prioirty. As such, stations can not provide low priority packets if
10797 high priority packets are all served.
10798
10799 DEPENDENCIES
10800
10801 PARAMETERS
10802
10803 IN
10804 pvosGCtx: pointer to the global vos context; a handle to TL's
10805 control block can be extracted from its context
10806
10807 OUT
10808 pucSTAId: Station ID
10809
10810 RETURN VALUE
10811 The result code associated with performing the operation
10812
10813 VOS_STATUS_SUCCESS: Everything is good
10814
10815 SIDE EFFECTS
10816
10817 TL context contains currently served station ID in ucCurrentSTA field, currently served AC
10818 in uCurServedAC field, and unserved weights of current AC in uCurLeftWeight.
10819 When existing from the function, these three fields are changed accordingly.
10820
10821============================================================================*/
10822VOS_STATUS
10823WLAN_TLAPGetNextTxIds
10824(
10825 v_PVOID_t pvosGCtx,
10826 v_U8_t* pucSTAId
10827)
10828{
10829 WLANTL_CbType* pTLCb;
10830 v_U8_t ucACFilter = 1;
10831 v_U8_t ucNextSTA ;
10832 v_BOOL_t isServed = TRUE; //current round has find a packet or not
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +053010833 v_U8_t ucACLoopNum = WLANTL_AC_HIGH_PRIO + 1; //number of loop to go
Jeff Johnson295189b2012-06-20 16:38:30 -070010834 v_U8_t uFlowMask; // TX FlowMask from WDA
10835 uint8 ucACMask;
Gopichand Nakkala96237bc2013-01-04 12:20:29 -080010836 uint8 i = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070010837 /*------------------------------------------------------------------------
10838 Extract TL control block
10839 ------------------------------------------------------------------------*/
10840 //ENTER();
10841
10842 pTLCb = VOS_GET_TL_CB(pvosGCtx);
10843 if ( NULL == pTLCb )
10844 {
10845 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
10846 "WLAN TL:Invalid TL pointer from pvosGCtx on WLAN_TLAPGetNextTxIds"));
10847 return VOS_STATUS_E_FAULT;
10848 }
10849
10850 if ( VOS_STATUS_SUCCESS != WDA_DS_GetTxFlowMask( pvosGCtx, &uFlowMask ) )
10851 {
10852 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
10853 "WLAN TL:Failed to retrieve Flow control mask from WDA"));
10854 return VOS_STATUS_E_FAULT;
10855 }
10856
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +053010857 /* The flow mask does not differentiate between different ACs/Qs
10858 * since we use a single dxe channel for all ACs/Qs, hence it is
10859 * enough to check that there are dxe resources on data channel
10860 */
10861 uFlowMask &= WLANTL_DATA_FLOW_MASK;
10862
10863 if (0 == uFlowMask)
10864 {
10865 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
10866 "WLAN TL: No resources to send packets"));
10867
10868 // Setting STA Id to invalid if mask is 0
10869 *pucSTAId = WLAN_MAX_STA_COUNT;
10870 return VOS_STATUS_E_FAULT;
10871 }
10872
Jeff Johnson295189b2012-06-20 16:38:30 -070010873 ucNextSTA = pTLCb->ucCurrentSTA;
10874
10875 ++ucNextSTA;
10876
10877 if ( WLAN_MAX_STA_COUNT <= ucNextSTA )
10878 {
10879 //one round is done.
10880 ucNextSTA = 0;
10881 pTLCb->ucCurLeftWeight--;
10882 isServed = FALSE;
10883 if ( 0 == pTLCb->ucCurLeftWeight )
10884 {
10885 //current prioirty is done
10886 if ( WLANTL_AC_BK == (WLANTL_ACEnumType)pTLCb->uCurServedAC )
10887 {
10888 //end of current VO, VI, BE, BK loop. Reset priority.
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +053010889 pTLCb->uCurServedAC = WLANTL_AC_HIGH_PRIO;
Jeff Johnson295189b2012-06-20 16:38:30 -070010890 }
10891 else
10892 {
10893 pTLCb->uCurServedAC --;
10894 }
10895
10896 pTLCb->ucCurLeftWeight = pTLCb->tlConfigInfo.ucAcWeights[pTLCb->uCurServedAC];
10897
10898 } // (0 == pTLCb->ucCurLeftWeight)
10899 } //( WLAN_MAX_STA_COUNT == ucNextSTA )
10900
10901 //decide how many loops to go. if current loop is partial, do one extra to make sure
10902 //we cover every station
10903 if ((1 == pTLCb->ucCurLeftWeight) && (ucNextSTA != 0))
10904 {
10905 ucACLoopNum ++; // now is 5 loops
10906 }
10907
10908 /* Start with highest priority. ucNextSTA, pTLCb->uCurServedAC, pTLCb->ucCurLeftWeight
10909 all have previous values.*/
10910 for (; ucACLoopNum > 0; ucACLoopNum--)
10911 {
10912
10913 ucACFilter = 1 << pTLCb->uCurServedAC;
10914
10915 // pTLCb->ucCurLeftWeight keeps previous results.
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +053010916 for (; (pTLCb->ucCurLeftWeight > 0) ; pTLCb->ucCurLeftWeight-- )
Jeff Johnson295189b2012-06-20 16:38:30 -070010917 {
10918
10919 for ( ; ucNextSTA < WLAN_MAX_STA_COUNT; ucNextSTA ++ )
10920 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053010921 if(NULL == pTLCb->atlSTAClients[ucNextSTA])
10922 {
10923 continue;
10924 }
10925 WLAN_TL_AC_ARRAY_2_MASK (pTLCb->atlSTAClients[ucNextSTA], ucACMask, i);
Jeff Johnson295189b2012-06-20 16:38:30 -070010926
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053010927 if ( (0 == pTLCb->atlSTAClients[ucNextSTA]->ucExists) ||
10928 ((0 == pTLCb->atlSTAClients[ucNextSTA]->ucPktPending) && !(ucACMask)) ||
Jeff Johnson295189b2012-06-20 16:38:30 -070010929 (0 == (ucACMask & ucACFilter)) )
10930
10931 {
Tushnim Bhattacharyya39a8f182013-02-20 18:10:30 -080010932 //current station does not exist or have any packet to serve.
10933 continue;
10934 }
10935
10936 if (WLANTL_STA_AUTHENTICATED != pTLCb->atlSTAClients[ucNextSTA]->tlState)
10937 {
10938 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
10939 "%s Sta %d not in auth state so skipping it.",
10940 __func__, ucNextSTA));
Jeff Johnson295189b2012-06-20 16:38:30 -070010941 continue;
10942 }
10943
10944 //go to next station if current station can't send due to flow control
10945 //Station is allowed to send when it is not in LWM mode. When station is in LWM mode,
10946 //station is allowed to send only after FW reports FW memory is below threshold and on-fly
10947 //packets are less then allowed value
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053010948 if ( (TRUE == pTLCb->atlSTAClients[ucNextSTA]->ucLwmModeEnabled) &&
10949 ((FALSE == pTLCb->atlSTAClients[ucNextSTA]->ucLwmEventReported) ||
10950 (0 < pTLCb->atlSTAClients[ucNextSTA]->uBuffThresholdMax))
Jeff Johnson295189b2012-06-20 16:38:30 -070010951 )
10952 {
10953 continue;
10954 }
10955
10956
10957 // Find a station. Weight is updated already.
10958 *pucSTAId = ucNextSTA;
10959 pTLCb->ucCurrentSTA = ucNextSTA;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053010960 pTLCb->atlSTAClients[*pucSTAId]->ucCurrentAC = pTLCb->uCurServedAC;
Jeff Johnson295189b2012-06-20 16:38:30 -070010961
10962 TLLOG4(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_LOW,
10963 " TL serve one station AC: %d W: %d StaId: %d",
10964 pTLCb->uCurServedAC, pTLCb->ucCurLeftWeight, pTLCb->ucCurrentSTA ));
10965
10966 return VOS_STATUS_SUCCESS;
10967 } //STA loop
10968
10969 ucNextSTA = 0;
10970 if ( FALSE == isServed )
10971 {
10972 //current loop finds no packet.no need to repeat for the same priority
10973 break;
10974 }
10975 //current loop is partial loop. go for one more loop.
10976 isServed = FALSE;
10977
10978 } //Weight loop
10979
10980 if (WLANTL_AC_BK == pTLCb->uCurServedAC)
10981 {
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +053010982 pTLCb->uCurServedAC = WLANTL_AC_HIGH_PRIO;
Jeff Johnson295189b2012-06-20 16:38:30 -070010983 }
10984 else
10985 {
10986 pTLCb->uCurServedAC--;
10987 }
10988 pTLCb->ucCurLeftWeight = pTLCb->tlConfigInfo.ucAcWeights[pTLCb->uCurServedAC];
10989
10990 }// AC loop
10991
10992 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
Arif Hussainf2b00992013-11-17 21:46:15 -080010993 " TL can't find one station to serve" ));
Jeff Johnson295189b2012-06-20 16:38:30 -070010994
10995 pTLCb->uCurServedAC = WLANTL_AC_BK;
10996 pTLCb->ucCurLeftWeight = 1;
10997 //invalid number will be captured by caller
10998 pTLCb->ucCurrentSTA = WLAN_MAX_STA_COUNT;
10999
11000 *pucSTAId = pTLCb->ucCurrentSTA;
Jeff Johnson295189b2012-06-20 16:38:30 -070011001 return VOS_STATUS_E_FAULT;
11002}
11003
11004
11005/*==========================================================================
11006 FUNCTION WLAN_TLGetNextTxIds
11007
11008 DESCRIPTION
11009 Gets the next station and next AC in the list
11010
11011 DEPENDENCIES
11012
11013 PARAMETERS
11014
11015 IN
11016 pvosGCtx: pointer to the global vos context; a handle to TL's
11017 control block can be extracted from its context
11018
11019 OUT
11020 pucSTAId: Station ID
11021
11022
11023 RETURN VALUE
11024 The result code associated with performing the operation
11025
11026 VOS_STATUS_SUCCESS: Everything is good :)
11027
11028 SIDE EFFECTS
11029
11030============================================================================*/
11031VOS_STATUS
11032WLAN_TLGetNextTxIds
11033(
11034 v_PVOID_t pvosGCtx,
11035 v_U8_t* pucSTAId
11036)
11037{
11038 WLANTL_CbType* pTLCb;
11039 v_U8_t ucNextAC;
11040 v_U8_t ucNextSTA;
11041 v_U8_t ucCount;
11042 v_U8_t uFlowMask; // TX FlowMask from WDA
11043 v_U8_t ucACMask = 0;
11044 v_U8_t i = 0;
11045
11046 tBssSystemRole systemRole; //RG HACK to be removed
11047 tpAniSirGlobal pMac;
11048
11049 pMac = vos_get_context(VOS_MODULE_ID_PE, pvosGCtx);
11050 if ( NULL == pMac )
11051 {
11052 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070011053 "%s: Invalid pMac", __func__));
Jeff Johnson295189b2012-06-20 16:38:30 -070011054 return VOS_STATUS_E_FAULT;
11055 }
11056
11057 systemRole = wdaGetGlobalSystemRole(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -070011058
Jeff Johnson295189b2012-06-20 16:38:30 -070011059 /*------------------------------------------------------------------------
11060 Extract TL control block
11061 ------------------------------------------------------------------------*/
11062 pTLCb = VOS_GET_TL_CB(pvosGCtx);
11063 if ( NULL == pTLCb )
11064 {
11065 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11066 "WLAN TL:Invalid TL pointer from pvosGCtx on WLAN_TLGetNextTxIds"));
11067 return VOS_STATUS_E_FAULT;
11068 }
11069
Sunil Ravid5406f22013-01-22 00:18:31 -080011070#ifdef FEATURE_WLAN_TDLS
Agarwal Ashishcd86f7b2014-06-16 17:11:58 +053011071 if ((eSYSTEM_AP_ROLE == systemRole) ||
Katya Nigam1fd24402015-02-16 14:52:19 +053011072 (eSYSTEM_STA_IN_IBSS_ROLE == systemRole) ||
Agarwal Ashishcd86f7b2014-06-16 17:11:58 +053011073 (vos_concurrent_open_sessions_running()) || pTLCb->ucTdlsPeerCount)
Sunil Ravid5406f22013-01-22 00:18:31 -080011074#else
Agarwal Ashishcd86f7b2014-06-16 17:11:58 +053011075 if ((eSYSTEM_AP_ROLE == systemRole) ||
Katya Nigam1fd24402015-02-16 14:52:19 +053011076 (eSYSTEM_STA_IN_IBSS_ROLE == systemRole) ||
Agarwal Ashishcd86f7b2014-06-16 17:11:58 +053011077 (vos_concurrent_open_sessions_running()))
Sunil Ravid5406f22013-01-22 00:18:31 -080011078#endif
11079 {
11080 return WLAN_TLAPGetNextTxIds(pvosGCtx,pucSTAId);
11081 }
11082
11083
Jeff Johnson295189b2012-06-20 16:38:30 -070011084 if ( VOS_STATUS_SUCCESS != WDA_DS_GetTxFlowMask( pvosGCtx, &uFlowMask ) )
11085 {
11086 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11087 "WLAN TL:Failed to retrieve Flow control mask from WDA"));
11088 return VOS_STATUS_E_FAULT;
11089 }
11090
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +053011091 /* The flow mask does not differentiate between different ACs/Qs
11092 * since we use a single dxe channel for all ACs/Qs, hence it is
11093 * enough to check that there are dxe resources on data channel
11094 */
11095 uFlowMask &= WLANTL_DATA_FLOW_MASK;
11096
11097 if (0 == uFlowMask)
11098 {
11099 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11100 "WLAN TL: No resources to send packets"));
11101
11102 // Setting STA id to invalid if mask is 0
11103 *pucSTAId = WLAN_MAX_STA_COUNT;
11104 return VOS_STATUS_E_FAULT;
11105 }
11106
Jeff Johnson295189b2012-06-20 16:38:30 -070011107 /*STA id - no priority yet implemented */
11108 /*-----------------------------------------------------------------------
11109 Choose the next STA for tx - for now go in a round robin fashion
11110 through all the stations that have pending packets
11111 -------------------------------------------------------------------------*/
11112 ucNextSTA = pTLCb->ucCurrentSTA;
11113
11114 pTLCb->ucCurrentSTA = WLAN_MAX_STA_COUNT;
11115 for ( ucCount = 0;
11116 ucCount < WLAN_MAX_STA_COUNT;
11117 ucCount++ )
11118 {
11119 ucNextSTA = ( (ucNextSTA+1) >= WLAN_MAX_STA_COUNT )?0:(ucNextSTA+1);
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053011120 if(NULL == pTLCb->atlSTAClients[ucNextSTA])
11121 {
11122 continue;
11123 }
11124 if (( pTLCb->atlSTAClients[ucNextSTA]->ucExists ) &&
11125 ( pTLCb->atlSTAClients[ucNextSTA]->ucPktPending ))
Jeff Johnson295189b2012-06-20 16:38:30 -070011126 {
Tushnim Bhattacharyya39a8f182013-02-20 18:10:30 -080011127 if (WLANTL_STA_AUTHENTICATED == pTLCb->atlSTAClients[ucNextSTA]->tlState)
11128 {
11129 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
11130 "STA ID: %d on WLAN_TLGetNextTxIds", *pucSTAId));
11131 pTLCb->ucCurrentSTA = ucNextSTA;
11132 break;
Tushnim Bhattacharyya5dd94562013-03-20 20:15:03 -070011133 }
11134 else
11135 {
Tushnim Bhattacharyya39a8f182013-02-20 18:10:30 -080011136 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
11137 "%s Sta %d is not in auth state, skipping this sta.",
11138 __func__, ucNextSTA));
Tushnim Bhattacharyya5dd94562013-03-20 20:15:03 -070011139 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011140 }
11141 }
11142
11143 *pucSTAId = pTLCb->ucCurrentSTA;
11144
11145 if ( WLANTL_STA_ID_INVALID( *pucSTAId ) )
11146 {
11147 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
11148 "WLAN TL:No station registered with TL at this point"));
11149
11150 return VOS_STATUS_E_FAULT;
11151
11152 }
11153
11154 /*Convert the array to a mask for easier operation*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053011155 WLAN_TL_AC_ARRAY_2_MASK( pTLCb->atlSTAClients[*pucSTAId], ucACMask, i);
Jeff Johnson295189b2012-06-20 16:38:30 -070011156
11157 if ( 0 == ucACMask )
11158 {
11159 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11160 "WLAN TL: Mask 0 "
11161 "STA ID: %d on WLAN_TLGetNextTxIds", *pucSTAId));
11162
11163 /*setting STA id to invalid if mask is 0*/
11164 *pucSTAId = WLAN_MAX_STA_COUNT;
11165
11166 return VOS_STATUS_E_FAULT;
11167 }
11168
11169 /*-----------------------------------------------------------------------
11170 AC is updated whenever a packet is fetched from HDD -> the current
11171 weight of such an AC cannot be 0 -> in this case TL is expected to
11172 exit this function at this point during the main Tx loop
11173 -----------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053011174 if ( 0 < pTLCb->atlSTAClients[*pucSTAId]->ucCurrentWeight )
Jeff Johnson295189b2012-06-20 16:38:30 -070011175 {
11176 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
11177 "WLAN TL: Maintaining serviced AC to: %d for Weight: %d",
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053011178 pTLCb->atlSTAClients[*pucSTAId]->ucCurrentAC ,
11179 pTLCb->atlSTAClients[*pucSTAId]->ucCurrentWeight));
Jeff Johnson295189b2012-06-20 16:38:30 -070011180 return VOS_STATUS_SUCCESS;
11181 }
11182
11183 /*-----------------------------------------------------------------------
11184 Choose highest priority AC - !!! optimize me
11185 -----------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053011186 ucNextAC = pTLCb->atlSTAClients[*pucSTAId]->ucCurrentAC;
Jeff Johnson295189b2012-06-20 16:38:30 -070011187 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
11188 "Next AC: %d", ucNextAC));
11189
11190 while ( 0 != ucACMask )
11191 {
11192 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
11193 " AC Mask: %d Next: %d Res : %d",
11194 ucACMask, ( 1 << ucNextAC ), ( ucACMask & ( 1 << ucNextAC ))));
11195
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +053011196 if ( 0 != ( ucACMask & ( 1 << ucNextAC )))
Jeff Johnson295189b2012-06-20 16:38:30 -070011197 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053011198 pTLCb->atlSTAClients[*pucSTAId]->ucCurrentAC =
Jeff Johnson295189b2012-06-20 16:38:30 -070011199 (WLANTL_ACEnumType)ucNextAC;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053011200 pTLCb->atlSTAClients[*pucSTAId]->ucCurrentWeight =
Jeff Johnson295189b2012-06-20 16:38:30 -070011201 pTLCb->tlConfigInfo.ucAcWeights[ucNextAC];
11202
11203 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
11204 "WLAN TL: Switching serviced AC to: %d with Weight: %d",
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053011205 pTLCb->atlSTAClients[*pucSTAId]->ucCurrentAC ,
11206 pTLCb->atlSTAClients[*pucSTAId]->ucCurrentWeight));
Jeff Johnson295189b2012-06-20 16:38:30 -070011207 break;
11208 }
11209
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +053011210 if (ucNextAC == WLANTL_AC_BK)
11211 ucNextAC = WLANTL_AC_HIGH_PRIO;
11212 else
11213 ucNextAC--;
Jeff Johnson295189b2012-06-20 16:38:30 -070011214
11215 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
11216 "Next AC %d", ucNextAC));
Jeff Johnson295189b2012-06-20 16:38:30 -070011217 }
11218
11219 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
11220 " C AC: %d C W: %d",
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053011221 pTLCb->atlSTAClients[*pucSTAId]->ucCurrentAC,
11222 pTLCb->atlSTAClients[*pucSTAId]->ucCurrentWeight));
Jeff Johnson295189b2012-06-20 16:38:30 -070011223
11224 return VOS_STATUS_SUCCESS;
11225}/* WLAN_TLGetNextTxIds */
11226
Jeff Johnson295189b2012-06-20 16:38:30 -070011227
11228
11229/*==========================================================================
11230 DEFAULT HANDLERS: Registered at initialization with TL
11231 ==========================================================================*/
11232
11233/*==========================================================================
11234
11235 FUNCTION WLANTL_MgmtFrmRxDefaultCb
11236
11237 DESCRIPTION
11238 Default Mgmt Frm rx callback: asserts all the time. If this function gets
11239 called it means there is no registered rx cb pointer for Mgmt Frm.
11240
11241 DEPENDENCIES
11242
11243 PARAMETERS
11244 Not used.
11245
11246 RETURN VALUE
11247
11248 VOS_STATUS_E_FAILURE: Always FAILURE.
11249
11250============================================================================*/
11251VOS_STATUS
11252WLANTL_MgmtFrmRxDefaultCb
11253(
11254 v_PVOID_t pvosGCtx,
11255 v_PVOID_t vosBuff
11256)
11257{
11258 if ( NULL != vosBuff )
11259 {
11260 TLLOGP(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_FATAL,
11261 "WLAN TL:Fatal failure: No registered Mgmt Frm client on pkt RX"));
11262 /* Drop packet */
11263 vos_pkt_return_packet((vos_pkt_t *)vosBuff);
11264 }
11265
Jeff Johnson295189b2012-06-20 16:38:30 -070011266 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
11267 "WLAN TL: No registered Mgmt Frm client on pkt RX. Load/Unload in progress, Ignore"));
Jeff Johnson295189b2012-06-20 16:38:30 -070011268
11269 return VOS_STATUS_E_FAILURE;
11270}/*WLANTL_MgmtFrmRxDefaultCb*/
11271
11272/*==========================================================================
11273
Madan Mohan Koyyalamudi6c2977d2013-09-04 15:42:45 +053011274 FUNCTION WLANTL_BAPRxDefaultCb
Jeff Johnson295189b2012-06-20 16:38:30 -070011275
11276 DESCRIPTION
11277 Default BAP rx callback: asserts all the time. If this function gets
11278 called it means there is no registered rx cb pointer for BAP.
11279
11280 DEPENDENCIES
11281
11282 PARAMETERS
11283 Not used.
11284
11285 RETURN VALUE
11286
11287 VOS_STATUS_E_FAILURE: Always FAILURE.
11288
11289============================================================================*/
11290VOS_STATUS
11291WLANTL_BAPRxDefaultCb
11292(
11293 v_PVOID_t pvosGCtx,
11294 vos_pkt_t* vosDataBuff,
11295 WLANTL_BAPFrameEnumType frameType
11296)
11297{
11298 TLLOGP(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_FATAL,
11299 "WLAN TL:Fatal failure: No registered BAP client on BAP pkt RX"));
11300#ifndef BTAMP_TEST
11301 VOS_ASSERT(0);
11302#endif
11303 return VOS_STATUS_E_FAILURE;
11304}/*WLANTL_MgmtFrmRxDefaultCb*/
11305
11306/*==========================================================================
11307
11308 FUNCTION WLANTL_STARxDefaultCb
11309
11310 DESCRIPTION
11311 Default STA rx callback: asserts all the time. If this function gets
11312 called it means there is no registered rx cb pointer for station.
11313 (Mem corruption most likely, it should never happen)
11314
11315 DEPENDENCIES
11316
11317 PARAMETERS
11318 Not used.
11319
11320 RETURN VALUE
11321
11322 VOS_STATUS_E_FAILURE: Always FAILURE.
11323
11324============================================================================*/
11325VOS_STATUS
11326WLANTL_STARxDefaultCb
11327(
11328 v_PVOID_t pvosGCtx,
11329 vos_pkt_t* vosDataBuff,
11330 v_U8_t ucSTAId,
11331 WLANTL_RxMetaInfoType* pRxMetaInfo
11332)
11333{
11334 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11335 "WLAN TL: No registered STA client rx cb for STAID: %d dropping pkt",
11336 ucSTAId));
11337 vos_pkt_return_packet(vosDataBuff);
Madan Mohan Koyyalamudi6c2977d2013-09-04 15:42:45 +053011338 return VOS_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070011339}/*WLANTL_MgmtFrmRxDefaultCb*/
11340
11341
11342/*==========================================================================
11343
11344 FUNCTION WLANTL_STAFetchPktDefaultCb
11345
11346 DESCRIPTION
11347 Default fetch callback: asserts all the time. If this function gets
11348 called it means there is no registered fetch cb pointer for station.
11349 (Mem corruption most likely, it should never happen)
11350
11351 DEPENDENCIES
11352
11353 PARAMETERS
11354 Not used.
11355
11356 RETURN VALUE
11357
11358 VOS_STATUS_E_FAILURE: Always FAILURE.
11359
11360============================================================================*/
11361VOS_STATUS
11362WLANTL_STAFetchPktDefaultCb
11363(
11364 v_PVOID_t pvosGCtx,
11365 v_U8_t* pucSTAId,
11366 WLANTL_ACEnumType ucAC,
11367 vos_pkt_t** vosDataBuff,
11368 WLANTL_MetaInfoType* tlMetaInfo
11369)
11370{
11371 TLLOGP(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_FATAL,
11372 "WLAN TL:Fatal failure: No registered STA client on data pkt RX"));
11373 VOS_ASSERT(0);
11374 return VOS_STATUS_E_FAILURE;
11375}/*WLANTL_MgmtFrmRxDefaultCb*/
11376
11377/*==========================================================================
11378
11379 FUNCTION WLANTL_TxCompDefaultCb
11380
11381 DESCRIPTION
11382 Default tx complete handler. It will release the completed pkt to
11383 prevent memory leaks.
11384
11385 PARAMETERS
11386
11387 IN
11388 pvosGCtx: pointer to the global vos context; a handle to
11389 TL/HAL/PE/BAP/HDD control block can be extracted from
11390 its context
11391 vosDataBuff: pointer to the VOSS data buffer that was transmitted
11392 wTxSTAtus: status of the transmission
11393
11394
11395 RETURN VALUE
11396 The result code associated with performing the operation; please
11397 check vos_pkt_return_packet for possible error codes.
11398
11399 Please check vos_pkt_return_packet API for possible return values.
11400
11401============================================================================*/
11402VOS_STATUS
11403WLANTL_TxCompDefaultCb
11404(
11405 v_PVOID_t pvosGCtx,
11406 vos_pkt_t* vosDataBuff,
11407 VOS_STATUS wTxSTAtus
11408)
11409{
11410 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
11411 "WLAN TL:TXComp not registered, releasing pkt to prevent mem leak"));
11412 return vos_pkt_return_packet(vosDataBuff);
11413}/*WLANTL_TxCompDefaultCb*/
11414
11415
11416/*==========================================================================
11417 Cleanup functions
11418 ==========================================================================*/
11419
11420/*==========================================================================
11421
11422 FUNCTION WLANTL_CleanCB
11423
11424 DESCRIPTION
11425 Cleans TL control block
11426
11427 DEPENDENCIES
11428
11429 PARAMETERS
11430
11431 IN
11432 pTLCb: pointer to TL's control block
11433 ucEmpty: set if TL has to clean up the queues and release pedning pkts
11434
11435 RETURN VALUE
11436 The result code associated with performing the operation
11437
11438 VOS_STATUS_E_INVAL: invalid input parameters
11439 VOS_STATUS_SUCCESS: Everything is good :)
11440
11441 SIDE EFFECTS
11442
11443============================================================================*/
11444VOS_STATUS
11445WLANTL_CleanCB
11446(
11447 WLANTL_CbType* pTLCb,
11448 v_U8_t ucEmpty
11449)
11450{
11451 v_U8_t ucIndex;
11452 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
11453
11454 /*-------------------------------------------------------------------------
11455 Sanity check
11456 -------------------------------------------------------------------------*/
11457 if ( NULL == pTLCb )
11458 {
11459 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11460 "WLAN TL:Invalid parameter sent on WLANTL_CleanCB"));
11461 return VOS_STATUS_E_INVAL;
11462 }
11463
11464 /* number of packets sent to BAL waiting for tx complete confirmation */
11465 pTLCb->usPendingTxCompleteCount = 0;
11466
11467 /* global suspend flag */
11468 vos_atomic_set_U8( &pTLCb->ucTxSuspended, 1);
11469
11470 /* resource flag */
11471 pTLCb->uResCount = 0;
11472
11473
11474 /*-------------------------------------------------------------------------
11475 Client stations
11476 -------------------------------------------------------------------------*/
11477 for ( ucIndex = 0; ucIndex < WLAN_MAX_STA_COUNT ; ucIndex++)
11478 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053011479 if(NULL != pTLCb->atlSTAClients[ucIndex])
11480 {
11481 WLANTL_CleanSTA( pTLCb->atlSTAClients[ucIndex], ucEmpty);
11482 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011483 }
11484
11485 /*-------------------------------------------------------------------------
11486 Management Frame client
11487 -------------------------------------------------------------------------*/
11488 pTLCb->tlMgmtFrmClient.ucExists = 0;
11489
11490 if ( ( 0 != ucEmpty) &&
11491 ( NULL != pTLCb->tlMgmtFrmClient.vosPendingDataBuff ))
11492 {
11493 vos_pkt_return_packet(pTLCb->tlMgmtFrmClient.vosPendingDataBuff);
11494 }
11495
11496 pTLCb->tlMgmtFrmClient.vosPendingDataBuff = NULL;
11497
11498 /* set to a default cb in order to prevent constant checking for NULL */
11499 pTLCb->tlMgmtFrmClient.pfnTlMgmtFrmRx = WLANTL_MgmtFrmRxDefaultCb;
11500
11501 /*-------------------------------------------------------------------------
11502 BT AMP client
11503 -------------------------------------------------------------------------*/
11504 pTLCb->tlBAPClient.ucExists = 0;
11505
11506 if (( 0 != ucEmpty) &&
11507 ( NULL != pTLCb->tlBAPClient.vosPendingDataBuff ))
11508 {
11509 vos_pkt_return_packet(pTLCb->tlBAPClient.vosPendingDataBuff);
11510 }
11511
11512 if (( 0 != ucEmpty) &&
11513 ( NULL != pTLCb->vosDummyBuf ))
11514 {
11515 vos_pkt_return_packet(pTLCb->vosDummyBuf);
11516 }
11517
11518 pTLCb->tlBAPClient.vosPendingDataBuff = NULL;
11519
11520 pTLCb->vosDummyBuf = NULL;
11521 pTLCb->vosTempBuf = NULL;
11522 pTLCb->ucCachedSTAId = WLAN_MAX_STA_COUNT;
11523
11524 /* set to a default cb in order to prevent constant checking for NULL */
11525 pTLCb->tlBAPClient.pfnTlBAPRx = WLANTL_BAPRxDefaultCb;
11526
11527 pTLCb->ucRegisteredStaId = WLAN_MAX_STA_COUNT;
11528
11529 return VOS_STATUS_SUCCESS;
11530
11531}/* WLANTL_CleanCB*/
11532
11533/*==========================================================================
11534
11535 FUNCTION WLANTL_CleanSTA
11536
11537 DESCRIPTION
11538 Cleans a station control block.
11539
11540 DEPENDENCIES
11541
11542 PARAMETERS
11543
11544 IN
11545 pvosGCtx: pointer to the global vos context; a handle to TL's
11546 control block can be extracted from its context
11547 ucEmpty: if set the queues and pending pkts will be emptyed
11548
11549 RETURN VALUE
11550 The result code associated with performing the operation
11551
11552 VOS_STATUS_E_INVAL: invalid input parameters
11553 VOS_STATUS_SUCCESS: Everything is good :)
11554
11555 SIDE EFFECTS
11556
11557============================================================================*/
11558VOS_STATUS
11559WLANTL_CleanSTA
11560(
11561 WLANTL_STAClientType* ptlSTAClient,
11562 v_U8_t ucEmpty
11563)
11564{
11565 v_U8_t ucIndex;
11566 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
11567
11568 /*-------------------------------------------------------------------------
11569 Sanity check
11570 -------------------------------------------------------------------------*/
11571 if ( NULL == ptlSTAClient )
11572 {
11573 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11574 "WLAN TL:Invalid parameter sent on WLANTL_CleanSTA"));
11575 return VOS_STATUS_E_INVAL;
11576 }
11577
11578 /*------------------------------------------------------------------------
11579 Clear station from TL
11580 ------------------------------------------------------------------------*/
11581 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
11582 "WLAN TL: Clearing STA Client ID: %d, Empty flag: %d",
11583 ptlSTAClient->wSTADesc.ucSTAId, ucEmpty ));
11584
11585 ptlSTAClient->pfnSTARx = WLANTL_STARxDefaultCb;
11586 ptlSTAClient->pfnSTATxComp = WLANTL_TxCompDefaultCb;
11587 ptlSTAClient->pfnSTAFetchPkt = WLANTL_STAFetchPktDefaultCb;
11588
11589 ptlSTAClient->tlState = WLANTL_STA_INIT;
11590 ptlSTAClient->tlPri = WLANTL_STA_PRI_NORMAL;
11591
11592 vos_zero_macaddr( &ptlSTAClient->wSTADesc.vSTAMACAddress );
11593 vos_zero_macaddr( &ptlSTAClient->wSTADesc.vBSSIDforIBSS );
11594 vos_zero_macaddr( &ptlSTAClient->wSTADesc.vSelfMACAddress );
11595
11596 ptlSTAClient->wSTADesc.ucSTAId = 0;
11597 ptlSTAClient->wSTADesc.wSTAType = WLAN_STA_MAX;
11598
11599 ptlSTAClient->wSTADesc.ucQosEnabled = 0;
11600 ptlSTAClient->wSTADesc.ucAddRmvLLC = 0;
11601 ptlSTAClient->wSTADesc.ucSwFrameTXXlation = 0;
11602 ptlSTAClient->wSTADesc.ucSwFrameRXXlation = 0;
11603 ptlSTAClient->wSTADesc.ucProtectedFrame = 0;
11604
11605 /*-------------------------------------------------------------------------
11606 AMSDU information for the STA
11607 -------------------------------------------------------------------------*/
11608 if ( ( 0 != ucEmpty ) &&
11609 ( NULL != ptlSTAClient->vosAMSDUChainRoot ))
11610 {
Madan Mohan Koyyalamudic0e5bd82012-09-18 17:12:27 -070011611 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_FATAL,
Jeff Johnson0298bd02013-11-14 19:58:38 -080011612 "WLAN TL:Non NULL vosAMSDUChainRoot on WLANTL_CleanSTA, "
Madan Mohan Koyyalamudic0e5bd82012-09-18 17:12:27 -070011613 "suspecting a memory corruption"));
11614
Jeff Johnson295189b2012-06-20 16:38:30 -070011615 }
11616
11617 ptlSTAClient->vosAMSDUChain = NULL;
11618 ptlSTAClient->vosAMSDUChainRoot = NULL;
11619
11620 vos_mem_zero( (v_PVOID_t)ptlSTAClient->aucMPDUHeader,
11621 WLANTL_MPDU_HEADER_LEN);
11622 ptlSTAClient->ucMPDUHeaderLen = 0;
11623
11624 /*-------------------------------------------------------------------------
11625 Reordering information for the STA
11626 -------------------------------------------------------------------------*/
11627 for ( ucIndex = 0; ucIndex < WLAN_MAX_TID ; ucIndex++)
11628 {
11629 if(0 == ptlSTAClient->atlBAReorderInfo[ucIndex].ucExists)
11630 {
11631 continue;
11632 }
11633 if(NULL != ptlSTAClient->atlBAReorderInfo[ucIndex].reorderBuffer)
11634 {
11635 ptlSTAClient->atlBAReorderInfo[ucIndex].reorderBuffer->isAvailable = VOS_TRUE;
11636 memset(&ptlSTAClient->atlBAReorderInfo[ucIndex].reorderBuffer->arrayBuffer[0], 0, WLANTL_MAX_WINSIZE * sizeof(v_PVOID_t));
11637 }
11638 vos_timer_destroy(&ptlSTAClient->atlBAReorderInfo[ucIndex].agingTimer);
11639 memset(&ptlSTAClient->atlBAReorderInfo[ucIndex], 0, sizeof(WLANTL_BAReorderType));
11640 }
11641
11642 /*-------------------------------------------------------------------------
11643 QOS information for the STA
11644 -------------------------------------------------------------------------*/
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +053011645 ptlSTAClient->ucCurrentAC = WLANTL_AC_HIGH_PRIO;
Jeff Johnson295189b2012-06-20 16:38:30 -070011646 ptlSTAClient->ucCurrentWeight = 0;
11647 ptlSTAClient->ucServicedAC = WLANTL_AC_BK;
11648
11649 vos_mem_zero( ptlSTAClient->aucACMask, sizeof(ptlSTAClient->aucACMask));
11650 vos_mem_zero( &ptlSTAClient->wUAPSDInfo, sizeof(ptlSTAClient->wUAPSDInfo));
11651
11652
11653 /*--------------------------------------------------------------------
11654 Stats info
11655 --------------------------------------------------------------------*/
11656 vos_mem_zero( ptlSTAClient->auRxCount,
11657 sizeof(ptlSTAClient->auRxCount[0])* WLAN_MAX_TID);
11658 vos_mem_zero( ptlSTAClient->auTxCount,
11659 sizeof(ptlSTAClient->auTxCount[0])* WLAN_MAX_TID);
11660 ptlSTAClient->rssiAvg = 0;
11661
11662 /*Tx not suspended and station fully registered*/
11663 vos_atomic_set_U8( &ptlSTAClient->ucTxSuspended, 0);
11664 vos_atomic_set_U8( &ptlSTAClient->ucNoMoreData, 1);
11665
11666 if ( 0 == ucEmpty )
11667 {
11668 ptlSTAClient->wSTADesc.ucUcastSig = WLAN_TL_INVALID_U_SIG;
11669 ptlSTAClient->wSTADesc.ucBcastSig = WLAN_TL_INVALID_B_SIG;
11670 }
11671
11672 ptlSTAClient->ucExists = 0;
11673
11674 /*--------------------------------------------------------------------
11675 Statistics info
11676 --------------------------------------------------------------------*/
11677 memset(&ptlSTAClient->trafficStatistics,
11678 0,
11679 sizeof(WLANTL_TRANSFER_STA_TYPE));
11680
11681 /*fix me!!: add new values from the TL Cb for cleanup */
11682 return VOS_STATUS_SUCCESS;
11683}/* WLANTL_CleanSTA */
11684
11685
11686/*==========================================================================
11687 FUNCTION WLANTL_EnableUAPSDForAC
11688
11689 DESCRIPTION
11690 Called by HDD to enable UAPSD. TL in turn calls WDA API to enable the
11691 logic in FW/SLM to start sending trigger frames. Previously TL had the
11692 trigger frame logic which later moved down to FW. Hence
11693 HDD -> TL -> WDA -> FW call flow.
11694
11695 DEPENDENCIES
11696 The TL must be initialized before this function can be called.
11697
11698 PARAMETERS
11699
11700 IN
11701 pvosGCtx: pointer to the global vos context; a handle to TL's
11702 control block can be extracted from its context
11703 ucSTAId: station Id
11704 ucAC: AC for which U-APSD is being enabled
11705 ucTid: TID for which U-APSD is setup
11706 ucUP: used to place in the trigger frame generation
11707 ucServiceInt: service interval used by TL to send trigger frames
11708 ucSuspendInt: suspend interval used by TL to determine that an
11709 app is idle and should start sending trigg frms less often
11710 wTSDir: direction of TSpec
11711
11712 RETURN VALUE
11713 The result code associated with performing the operation
11714
11715 VOS_STATUS_SUCCESS: Everything is good :)
11716
11717 SIDE EFFECTS
11718
11719============================================================================*/
11720VOS_STATUS
11721WLANTL_EnableUAPSDForAC
11722(
11723 v_PVOID_t pvosGCtx,
11724 v_U8_t ucSTAId,
11725 WLANTL_ACEnumType ucAC,
11726 v_U8_t ucTid,
11727 v_U8_t ucUP,
11728 v_U32_t uServiceInt,
11729 v_U32_t uSuspendInt,
11730 WLANTL_TSDirType wTSDir
11731)
11732{
11733
11734 WLANTL_CbType* pTLCb = NULL;
11735 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
11736 tUapsdInfo halUAPSDInfo;
11737 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
11738
11739 /*------------------------------------------------------------------------
11740 Sanity check
11741 Extract TL control block
11742 ------------------------------------------------------------------------*/
11743 pTLCb = VOS_GET_TL_CB(pvosGCtx);
11744 if (( NULL == pTLCb ) || WLANTL_STA_ID_INVALID( ucSTAId )
Gopichand Nakkala574f6d12013-06-27 19:38:43 +053011745 || WLANTL_AC_INVALID(ucAC))
Jeff Johnson295189b2012-06-20 16:38:30 -070011746 {
11747 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11748 "WLAN TL:Invalid input params on WLANTL_EnableUAPSDForAC"
Gopichand Nakkala574f6d12013-06-27 19:38:43 +053011749 " TL: %p STA: %d AC: %d",
11750 pTLCb, ucSTAId, ucAC));
Jeff Johnson295189b2012-06-20 16:38:30 -070011751 return VOS_STATUS_E_FAULT;
11752 }
11753
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053011754 if ( NULL == pTLCb->atlSTAClients[ucSTAId] )
11755 {
11756 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11757 "WLAN TL:Client Memory was not allocated on %s", __func__));
11758 return VOS_STATUS_E_FAILURE;
11759 }
11760
Jeff Johnson295189b2012-06-20 16:38:30 -070011761 /*Set this flag in order to remember that this is a trigger enabled AC*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053011762 pTLCb->atlSTAClients[ucSTAId]->wUAPSDInfo[ucAC].ucSet = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -070011763
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053011764#ifdef FEATURE_WLAN_TDLS
11765 if(pTLCb->atlSTAClients[ucSTAId]->wSTADesc.wSTAType != WLAN_STA_TDLS)
11766#endif
11767 {
11768 if( 0 == uServiceInt )
11769 {
11770 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi198ade32013-09-29 03:52:25 +053011771 "WLAN TL:Input params on WLANTL_EnableUAPSDForAC"
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053011772 " SI: %d", uServiceInt ));
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053011773 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011774
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053011775 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
11776 "WLAN TL:Enabling U-APSD in FW for STA: %d AC: %d SI: %d SPI: %d "
11777 "DI: %d",
11778 ucSTAId, ucAC, uServiceInt, uSuspendInt,
11779 pTLCb->tlConfigInfo.uDelayedTriggerFrmInt));
Jeff Johnson295189b2012-06-20 16:38:30 -070011780
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053011781 /*Save all info for HAL*/
11782 halUAPSDInfo.staidx = ucSTAId;
11783 halUAPSDInfo.ac = ucAC;
11784 halUAPSDInfo.up = ucUP;
11785 halUAPSDInfo.srvInterval = uServiceInt;
11786 halUAPSDInfo.susInterval = uSuspendInt;
11787 halUAPSDInfo.delayInterval = pTLCb->tlConfigInfo.uDelayedTriggerFrmInt;
11788
11789 /*Notify HAL*/
11790 vosStatus = WDA_EnableUapsdAcParams(pvosGCtx, ucSTAId, &halUAPSDInfo);
11791 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011792 return vosStatus;
11793
11794}/*WLANTL_EnableUAPSDForAC*/
11795
11796
11797/*==========================================================================
11798 FUNCTION WLANTL_DisableUAPSDForAC
11799
11800 DESCRIPTION
11801 Called by HDD to disable UAPSD. TL in turn calls WDA API to disable the
11802 logic in FW/SLM to stop sending trigger frames. Previously TL had the
11803 trigger frame logic which later moved down to FW. Hence
11804 HDD -> TL -> WDA -> FW call flow.
11805
11806 DEPENDENCIES
11807 The TL must be initialized before this function can be called.
11808
11809 PARAMETERS
11810
11811 IN
11812 pvosGCtx: pointer to the global vos context; a handle to TL's
11813 control block can be extracted from its context
11814 ucSTAId: station Id
11815 ucAC: AC for which U-APSD is being enabled
11816
11817
11818 RETURN VALUE
11819 The result code associated with performing the operation
11820
11821 VOS_STATUS_SUCCESS: Everything is good :)
11822
11823 SIDE EFFECTS
11824
11825============================================================================*/
11826VOS_STATUS
11827WLANTL_DisableUAPSDForAC
11828(
11829 v_PVOID_t pvosGCtx,
11830 v_U8_t ucSTAId,
11831 WLANTL_ACEnumType ucAC
11832)
11833{
11834 WLANTL_CbType* pTLCb;
11835 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
11836
11837 /*------------------------------------------------------------------------
11838 Sanity check
11839 Extract TL control block
11840 ------------------------------------------------------------------------*/
11841 pTLCb = VOS_GET_TL_CB(pvosGCtx);
11842 if (( NULL == pTLCb ) || WLANTL_STA_ID_INVALID( ucSTAId )
11843 || WLANTL_AC_INVALID(ucAC) )
11844 {
11845 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11846 "WLAN TL:Invalid input params on WLANTL_DisableUAPSDForAC"
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +053011847 " TL: %p STA: %d AC: %d", pTLCb, ucSTAId, ucAC ));
Jeff Johnson295189b2012-06-20 16:38:30 -070011848 return VOS_STATUS_E_FAULT;
11849 }
11850
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053011851 if ( NULL == pTLCb->atlSTAClients[ucSTAId] )
11852 {
11853 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11854 "WLAN TL:Client Memory was not allocated on %s", __func__));
11855 return VOS_STATUS_E_FAILURE;
11856 }
11857
Jeff Johnson295189b2012-06-20 16:38:30 -070011858 /*Reset this flag as this is no longer a trigger enabled AC*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053011859 pTLCb->atlSTAClients[ucSTAId]->wUAPSDInfo[ucAC].ucSet = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -070011860
11861 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
11862 "WLAN TL:Disabling U-APSD in FW for STA: %d AC: %d ",
11863 ucSTAId, ucAC));
11864
11865 /*Notify HAL*/
11866 WDA_DisableUapsdAcParams(pvosGCtx, ucSTAId, ucAC);
11867
11868 return VOS_STATUS_SUCCESS;
11869}/* WLANTL_DisableUAPSDForAC */
11870
11871#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
11872/*==========================================================================
11873 FUNCTION WLANTL_RegRSSIIndicationCB
11874
11875 DESCRIPTION Registration function to get notification if RSSI cross
11876 threshold.
11877 Client should register threshold, direction, and notification
11878 callback function pointer
11879
11880 DEPENDENCIES NONE
11881
11882 PARAMETERS in pAdapter - Global handle
11883 in rssiValue - RSSI threshold value
11884 in triggerEvent - Cross direction should be notified
11885 UP, DOWN, and CROSS
11886 in crossCBFunction - Notification CB Function
11887 in usrCtxt - user context
11888
11889 RETURN VALUE VOS_STATUS
11890
11891 SIDE EFFECTS NONE
11892
11893============================================================================*/
11894VOS_STATUS WLANTL_RegRSSIIndicationCB
11895(
11896 v_PVOID_t pAdapter,
11897 v_S7_t rssiValue,
11898 v_U8_t triggerEvent,
11899 WLANTL_RSSICrossThresholdCBType crossCBFunction,
11900 VOS_MODULE_ID moduleID,
11901 v_PVOID_t usrCtxt
11902)
11903{
11904 VOS_STATUS status = VOS_STATUS_SUCCESS;
11905
11906 status = WLANTL_HSRegRSSIIndicationCB(pAdapter,
11907 rssiValue,
11908 triggerEvent,
11909 crossCBFunction,
11910 moduleID,
11911 usrCtxt);
11912
11913 return status;
11914}
11915
11916/*==========================================================================
11917 FUNCTION WLANTL_DeregRSSIIndicationCB
11918
11919 DESCRIPTION Remove specific threshold from list
11920
11921 DEPENDENCIES NONE
11922
11923 PARAMETERS in pAdapter - Global handle
11924 in rssiValue - RSSI threshold value
11925 in triggerEvent - Cross direction should be notified
11926 UP, DOWN, and CROSS
11927
11928 RETURN VALUE VOS_STATUS
11929
11930 SIDE EFFECTS NONE
11931
11932============================================================================*/
11933VOS_STATUS WLANTL_DeregRSSIIndicationCB
11934(
11935 v_PVOID_t pAdapter,
11936 v_S7_t rssiValue,
11937 v_U8_t triggerEvent,
11938 WLANTL_RSSICrossThresholdCBType crossCBFunction,
11939 VOS_MODULE_ID moduleID
11940)
11941{
11942 VOS_STATUS status = VOS_STATUS_SUCCESS;
11943
11944 status = WLANTL_HSDeregRSSIIndicationCB(pAdapter,
11945 rssiValue,
11946 triggerEvent,
11947 crossCBFunction,
11948 moduleID);
11949 return status;
11950}
11951
11952/*==========================================================================
11953 FUNCTION WLANTL_SetAlpha
11954
11955 DESCRIPTION ALPLA is weight value to calculate AVG RSSI
11956 avgRSSI = (ALPHA * historyRSSI) + ((10 - ALPHA) * newRSSI)
11957 avgRSSI has (ALPHA * 10)% of history RSSI weight and
11958 (10 - ALPHA)% of newRSSI weight
11959 This portion is dynamically configurable.
11960 Default is ?
11961
11962 DEPENDENCIES NONE
11963
11964 PARAMETERS in pAdapter - Global handle
11965 in valueAlpah - ALPHA
11966
11967 RETURN VALUE VOS_STATUS
11968
11969 SIDE EFFECTS NONE
11970
11971============================================================================*/
11972VOS_STATUS WLANTL_SetAlpha
11973(
11974 v_PVOID_t pAdapter,
11975 v_U8_t valueAlpha
11976)
11977{
11978 VOS_STATUS status = VOS_STATUS_SUCCESS;
11979
11980 status = WLANTL_HSSetAlpha(pAdapter, valueAlpha);
11981 return status;
11982}
11983
11984/*==========================================================================
11985
11986 FUNCTION
11987
11988 DESCRIPTION
11989
11990 PARAMETERS
11991
11992 RETURN VALUE
11993
11994============================================================================*/
11995VOS_STATUS WLANTL_BMPSRSSIRegionChangedNotification
11996(
11997 v_PVOID_t pAdapter,
11998 tpSirRSSINotification pRSSINotification
11999)
12000{
12001 VOS_STATUS status = VOS_STATUS_SUCCESS;
12002
12003 status = WLANTL_HSBMPSRSSIRegionChangedNotification(pAdapter, pRSSINotification);
12004 return status;
12005}
12006
12007/*==========================================================================
12008 FUNCTION WLANTL_RegGetTrafficStatus
12009
12010 DESCRIPTION Registration function for traffic status monitoring
12011 During measure period count data frames.
12012 If frame count is larger then IDLE threshold set as traffic ON
12013 or OFF.
12014 And traffic status is changed send report to client with
12015 registered callback function
12016
12017 DEPENDENCIES NONE
12018
12019 PARAMETERS in pAdapter - Global handle
12020 in idleThreshold - Traffic on or off threshold
12021 in measurePeriod - Traffic state check period
12022 in trfficStatusCB - traffic status changed notification
12023 CB function
12024 in usrCtxt - user context
12025
12026 RETURN VALUE VOS_STATUS
12027
12028 SIDE EFFECTS NONE
12029
12030============================================================================*/
12031VOS_STATUS WLANTL_RegGetTrafficStatus
12032(
12033 v_PVOID_t pAdapter,
12034 v_U32_t idleThreshold,
12035 v_U32_t measurePeriod,
12036 WLANTL_TrafficStatusChangedCBType trfficStatusCB,
12037 v_PVOID_t usrCtxt
12038)
12039{
12040 VOS_STATUS status = VOS_STATUS_SUCCESS;
12041
12042 status = WLANTL_HSRegGetTrafficStatus(pAdapter,
12043 idleThreshold,
12044 measurePeriod,
12045 trfficStatusCB,
12046 usrCtxt);
12047 return status;
12048}
12049#endif
12050/*==========================================================================
12051 FUNCTION WLANTL_GetStatistics
12052
12053 DESCRIPTION Get traffic statistics for identified station
12054
12055 DEPENDENCIES NONE
12056
12057 PARAMETERS in pAdapter - Global handle
12058 in statType - specific statistics field to reset
12059 out statBuffer - traffic statistics buffer
12060
12061 RETURN VALUE VOS_STATUS
12062
12063 SIDE EFFECTS NONE
12064
12065============================================================================*/
12066VOS_STATUS WLANTL_GetStatistics
12067(
12068 v_PVOID_t pAdapter,
12069 WLANTL_TRANSFER_STA_TYPE *statBuffer,
12070 v_U8_t STAid
12071)
12072{
12073 WLANTL_CbType *pTLCb = VOS_GET_TL_CB(pAdapter);
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053012074 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070012075 VOS_STATUS status = VOS_STATUS_SUCCESS;
12076 WLANTL_TRANSFER_STA_TYPE *statistics = NULL;
12077
12078 /*------------------------------------------------------------------------
12079 Sanity check
12080 Extract TL control block
12081 ------------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053012082 if ( NULL == pTLCb )
Jeff Johnson295189b2012-06-20 16:38:30 -070012083 {
12084 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
12085 "WLAN TL:Invalid TL pointer on WLANTL_GetStatistics"));
12086 return VOS_STATUS_E_FAULT;
12087 }
12088
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053012089 pClientSTA = pTLCb->atlSTAClients[STAid];
12090
12091 if ( NULL == pClientSTA )
12092 {
12093 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
12094 "WLAN TL:Client Memory was not allocated on %s", __func__));
12095 return VOS_STATUS_E_FAILURE;
12096 }
12097
12098 if(0 == pClientSTA->ucExists)
Jeff Johnson295189b2012-06-20 16:38:30 -070012099 {
12100 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
12101 "WLAN TL: %d STA ID does not exist", STAid));
12102 return VOS_STATUS_E_INVAL;
12103 }
12104
12105 if(NULL == statBuffer)
12106 {
12107 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
12108 "WLAN TL:Invalid TL statistics buffer pointer on WLANTL_GetStatistics"));
12109 return VOS_STATUS_E_INVAL;
12110 }
12111
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053012112 statistics = &pClientSTA->trafficStatistics;
Katya Nigam493ff652014-02-11 14:31:04 +053012113 vos_mem_copy(statBuffer, statistics, sizeof(WLANTL_TRANSFER_STA_TYPE));
Jeff Johnson295189b2012-06-20 16:38:30 -070012114
12115 return status;
12116}
12117
12118/*==========================================================================
12119 FUNCTION WLANTL_ResetStatistics
12120
12121 DESCRIPTION Reset statistics structure for identified station ID
12122 Reset means set values as 0
12123
12124 DEPENDENCIES NONE
12125
12126 PARAMETERS in pAdapter - Global handle
12127 in statType - specific statistics field to reset
12128
12129 RETURN VALUE VOS_STATUS
12130
12131 SIDE EFFECTS NONE
12132
12133============================================================================*/
12134VOS_STATUS WLANTL_ResetStatistics
12135(
12136 v_PVOID_t pAdapter,
12137 v_U8_t STAid
12138)
12139{
12140 WLANTL_CbType *pTLCb = VOS_GET_TL_CB(pAdapter);
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053012141 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070012142 VOS_STATUS status = VOS_STATUS_SUCCESS;
12143 WLANTL_TRANSFER_STA_TYPE *statistics = NULL;
12144
12145 /*------------------------------------------------------------------------
12146 Sanity check
12147 Extract TL control block
12148 ------------------------------------------------------------------------*/
12149 if (NULL == pTLCb)
12150 {
12151 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
12152 "WLAN TL:Invalid TL pointer on WLANTL_GetStatistics"));
12153 return VOS_STATUS_E_FAULT;
12154 }
12155
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053012156 pClientSTA = pTLCb->atlSTAClients[STAid];
12157
12158 if ( NULL == pClientSTA )
12159 {
12160 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
12161 "WLAN TL:Client Memory was not allocated on %s", __func__));
12162 return VOS_STATUS_E_FAILURE;
12163 }
12164
12165 if(0 == pClientSTA->ucExists)
Jeff Johnson295189b2012-06-20 16:38:30 -070012166 {
12167 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
12168 "WLAN TL: %d STA ID does not exist", STAid));
12169 return VOS_STATUS_E_INVAL;
12170 }
12171
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053012172 statistics = &pClientSTA->trafficStatistics;
Jeff Johnson295189b2012-06-20 16:38:30 -070012173 vos_mem_zero((v_VOID_t *)statistics, sizeof(WLANTL_TRANSFER_STA_TYPE));
12174
12175 return status;
12176}
12177
12178/*==========================================================================
12179 FUNCTION WLANTL_GetSpecStatistic
12180
12181 DESCRIPTION Get specific field within statistics structure for
12182 identified station ID
12183
12184 DEPENDENCIES NONE
12185
12186 PARAMETERS in pAdapter - Global handle
12187 in statType - specific statistics field to reset
12188 in STAid - Station ID
12189 out buffer - Statistic value
12190
12191 RETURN VALUE VOS_STATUS
12192
12193 SIDE EFFECTS NONE
12194
12195============================================================================*/
12196VOS_STATUS WLANTL_GetSpecStatistic
12197(
12198 v_PVOID_t pAdapter,
12199 WLANTL_TRANSFER_STATIC_TYPE statType,
12200 v_U32_t *buffer,
12201 v_U8_t STAid
12202)
12203{
12204 WLANTL_CbType *pTLCb = VOS_GET_TL_CB(pAdapter);
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053012205 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070012206 VOS_STATUS status = VOS_STATUS_SUCCESS;
12207 WLANTL_TRANSFER_STA_TYPE *statistics = NULL;
12208
12209 /*------------------------------------------------------------------------
12210 Sanity check
12211 Extract TL control block
12212 ------------------------------------------------------------------------*/
12213 if (NULL == pTLCb)
12214 {
12215 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
12216 "WLAN TL:Invalid TL pointer on WLANTL_GetStatistics"));
12217 return VOS_STATUS_E_FAULT;
12218 }
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053012219 pClientSTA = pTLCb->atlSTAClients[STAid];
Jeff Johnson295189b2012-06-20 16:38:30 -070012220
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053012221 if ( NULL == pClientSTA )
12222 {
12223 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
12224 "WLAN TL:Client Memory was not allocated on %s", __func__));
12225 return VOS_STATUS_E_FAILURE;
12226 }
12227
12228 if(0 == pClientSTA->ucExists)
Jeff Johnson295189b2012-06-20 16:38:30 -070012229 {
12230 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
12231 "WLAN TL: %d STA ID does not exist", STAid));
12232 return VOS_STATUS_E_INVAL;
12233 }
12234
12235 if(NULL == buffer)
12236 {
12237 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
12238 "WLAN TL:Invalid TL statistic buffer pointer on WLANTL_GetStatistics"));
12239 return VOS_STATUS_E_INVAL;
12240 }
12241
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053012242 statistics = &pClientSTA->trafficStatistics;
Jeff Johnson295189b2012-06-20 16:38:30 -070012243 switch(statType)
12244 {
12245 case WLANTL_STATIC_TX_UC_FCNT:
12246 *buffer = statistics->txUCFcnt;
12247 break;
12248
12249 case WLANTL_STATIC_TX_MC_FCNT:
12250 *buffer = statistics->txMCFcnt;
12251 break;
12252
12253 case WLANTL_STATIC_TX_BC_FCNT:
12254 *buffer = statistics->txBCFcnt;
12255 break;
12256
12257 case WLANTL_STATIC_TX_UC_BCNT:
12258 *buffer = statistics->txUCBcnt;
12259 break;
12260
12261 case WLANTL_STATIC_TX_MC_BCNT:
12262 *buffer = statistics->txMCBcnt;
12263 break;
12264
12265 case WLANTL_STATIC_TX_BC_BCNT:
12266 *buffer = statistics->txBCBcnt;
12267 break;
12268
12269 case WLANTL_STATIC_RX_UC_FCNT:
12270 *buffer = statistics->rxUCFcnt;
12271 break;
12272
12273 case WLANTL_STATIC_RX_MC_FCNT:
12274 *buffer = statistics->rxMCFcnt;
12275 break;
12276
12277 case WLANTL_STATIC_RX_BC_FCNT:
12278 *buffer = statistics->rxBCFcnt;
12279 break;
12280
12281 case WLANTL_STATIC_RX_UC_BCNT:
12282 *buffer = statistics->rxUCBcnt;
12283 break;
12284
12285 case WLANTL_STATIC_RX_MC_BCNT:
12286 *buffer = statistics->rxMCBcnt;
12287 break;
12288
12289 case WLANTL_STATIC_RX_BC_BCNT:
12290 *buffer = statistics->rxBCBcnt;
12291 break;
12292
12293 case WLANTL_STATIC_RX_BCNT:
12294 *buffer = statistics->rxBcnt;
12295 break;
12296
12297 case WLANTL_STATIC_RX_BCNT_CRC_OK:
12298 *buffer = statistics->rxBcntCRCok;
12299 break;
12300
12301 case WLANTL_STATIC_RX_RATE:
12302 *buffer = statistics->rxRate;
12303 break;
12304
12305 default:
12306 *buffer = 0;
12307 status = VOS_STATUS_E_INVAL;
12308 break;
12309 }
12310
12311
12312 return status;
12313}
12314
12315/*==========================================================================
12316 FUNCTION WLANTL_ResetSpecStatistic
12317
12318 DESCRIPTION Reset specific field within statistics structure for
12319 identified station ID
12320 Reset means set as 0
12321
12322 DEPENDENCIES NONE
12323
12324 PARAMETERS in pAdapter - Global handle
12325 in statType - specific statistics field to reset
12326 in STAid - Station ID
12327
12328 RETURN VALUE VOS_STATUS
12329
12330 SIDE EFFECTS NONE
12331
12332============================================================================*/
12333VOS_STATUS WLANTL_ResetSpecStatistic
12334(
12335 v_PVOID_t pAdapter,
12336 WLANTL_TRANSFER_STATIC_TYPE statType,
12337 v_U8_t STAid
12338)
12339{
12340 WLANTL_CbType *pTLCb = VOS_GET_TL_CB(pAdapter);
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053012341 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070012342 VOS_STATUS status = VOS_STATUS_SUCCESS;
12343 WLANTL_TRANSFER_STA_TYPE *statistics = NULL;
12344
12345 /*------------------------------------------------------------------------
12346 Sanity check
12347 Extract TL control block
12348 ------------------------------------------------------------------------*/
12349 if (NULL == pTLCb)
12350 {
12351 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
12352 "WLAN TL:Invalid TL pointer on WLANTL_GetStatistics"));
12353 return VOS_STATUS_E_FAULT;
12354 }
12355
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053012356 pClientSTA = pTLCb->atlSTAClients[STAid];
12357
12358 if ( NULL == pClientSTA )
12359 {
12360 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
12361 "WLAN TL:Client Memory was not allocated on %s", __func__));
12362 return VOS_STATUS_E_FAILURE;
12363 }
12364
12365 if(0 == pClientSTA->ucExists)
Jeff Johnson295189b2012-06-20 16:38:30 -070012366 {
12367 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
12368 "WLAN TL: %d STA ID does not exist", STAid));
12369 return VOS_STATUS_E_INVAL;
12370 }
12371
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053012372 statistics = &pClientSTA->trafficStatistics;
Jeff Johnson295189b2012-06-20 16:38:30 -070012373 switch(statType)
12374 {
12375 case WLANTL_STATIC_TX_UC_FCNT:
12376 statistics->txUCFcnt = 0;
12377 break;
12378
12379 case WLANTL_STATIC_TX_MC_FCNT:
12380 statistics->txMCFcnt = 0;
12381 break;
12382
12383 case WLANTL_STATIC_TX_BC_FCNT:
12384 statistics->txBCFcnt = 0;
12385 break;
12386
12387 case WLANTL_STATIC_TX_UC_BCNT:
12388 statistics->txUCBcnt = 0;
12389 break;
12390
12391 case WLANTL_STATIC_TX_MC_BCNT:
12392 statistics->txMCBcnt = 0;
12393 break;
12394
12395 case WLANTL_STATIC_TX_BC_BCNT:
12396 statistics->txBCBcnt = 0;
12397 break;
12398
12399 case WLANTL_STATIC_RX_UC_FCNT:
12400 statistics->rxUCFcnt = 0;
12401 break;
12402
12403 case WLANTL_STATIC_RX_MC_FCNT:
12404 statistics->rxMCFcnt = 0;
12405 break;
12406
12407 case WLANTL_STATIC_RX_BC_FCNT:
12408 statistics->rxBCFcnt = 0;
12409 break;
12410
12411 case WLANTL_STATIC_RX_UC_BCNT:
12412 statistics->rxUCBcnt = 0;
12413 break;
12414
12415 case WLANTL_STATIC_RX_MC_BCNT:
12416 statistics->rxMCBcnt = 0;
12417 break;
12418
12419 case WLANTL_STATIC_RX_BC_BCNT:
12420 statistics->rxBCBcnt = 0;
12421 break;
12422
12423 case WLANTL_STATIC_RX_BCNT:
12424 statistics->rxBcnt = 0;
12425 break;
12426
12427 case WLANTL_STATIC_RX_BCNT_CRC_OK:
12428 statistics->rxBcntCRCok = 0;
12429 break;
12430
12431 case WLANTL_STATIC_RX_RATE:
12432 statistics->rxRate = 0;
12433 break;
12434
12435 default:
12436 status = VOS_STATUS_E_INVAL;
12437 break;
12438 }
12439
12440 return status;
12441}
12442
12443
12444/*==========================================================================
12445
12446 FUNCTION
12447
12448 DESCRIPTION Read RSSI value out of a RX BD
12449
12450 PARAMETERS: Caller must validate all parameters
12451
12452 RETURN VALUE
12453
12454============================================================================*/
12455VOS_STATUS WLANTL_ReadRSSI
12456(
12457 v_PVOID_t pAdapter,
12458 v_PVOID_t pBDHeader,
12459 v_U8_t STAid
12460)
12461{
12462 WLANTL_CbType *tlCtxt = VOS_GET_TL_CB(pAdapter);
12463 v_S7_t currentRSSI, currentRSSI0, currentRSSI1;
12464
12465
12466 if(NULL == tlCtxt)
12467 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070012468 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR, "%s Invalid TL handle", __func__));
Jeff Johnson295189b2012-06-20 16:38:30 -070012469 return VOS_STATUS_E_INVAL;
12470 }
12471
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053012472 if ( NULL == tlCtxt->atlSTAClients[STAid] )
12473 {
12474 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
12475 "WLAN TL:Client Memory was not allocated on %s", __func__));
12476 return VOS_STATUS_E_FAILURE;
12477 }
12478
Jeff Johnson295189b2012-06-20 16:38:30 -070012479 currentRSSI0 = WLANTL_GETRSSI0(pBDHeader);
12480 currentRSSI1 = WLANTL_GETRSSI1(pBDHeader);
12481 currentRSSI = (currentRSSI0 > currentRSSI1) ? currentRSSI0 : currentRSSI1;
12482
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053012483 tlCtxt->atlSTAClients[STAid]->rssiAvg = currentRSSI;
Jeff Johnson295189b2012-06-20 16:38:30 -070012484
12485 return VOS_STATUS_SUCCESS;
12486}
12487
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053012488/*==========================================================================
12489
12490 FUNCTION
12491
12492 DESCRIPTION Read SNR value out of a RX BD
12493
12494 PARAMETERS: Caller must validate all parameters
12495
12496 RETURN VALUE
12497
12498============================================================================*/
12499VOS_STATUS WLANTL_ReadSNR
12500(
12501 v_PVOID_t pAdapter,
12502 v_PVOID_t pBDHeader,
12503 v_U8_t STAid
12504)
12505{
12506 WLANTL_CbType *tlCtxt = VOS_GET_TL_CB(pAdapter);
12507 v_S7_t currentSNR;
12508
12509
12510 if (NULL == tlCtxt)
12511 {
12512 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
12513 "%s Invalid TL handle", __func__));
12514 return VOS_STATUS_E_INVAL;
12515 }
12516
12517 if (NULL == tlCtxt->atlSTAClients[STAid])
12518 {
12519 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
12520 "WLAN TL:Client Memory was not allocated on %s", __func__));
12521 return VOS_STATUS_E_FAILURE;
12522 }
12523
12524 currentSNR = WLANTL_GETSNR(pBDHeader);
12525
Madan Mohan Koyyalamudi43acf032013-09-27 04:33:28 +053012526 /* SNR reported in the Buffer Descriptor is scaled up by 2(SNR*2),
12527 * Get the correct SNR value
12528 */
12529 currentSNR = currentSNR >> 1;
12530
12531 /* SNR reported by HW cannot be more than 35dB due to HW limitations */
12532 currentSNR = (WLANTL_MAX_HW_SNR > currentSNR ? currentSNR :
12533 WLANTL_MAX_HW_SNR);
12534
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053012535 TLLOG2(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
12536 "%s: snrsum: %d snridx: %d prevsnravg: %d",
12537 __func__,
12538 tlCtxt->atlSTAClients[STAid]->snrSum,
12539 tlCtxt->atlSTAClients[STAid]->snrIdx,
12540 tlCtxt->atlSTAClients[STAid]->prevSnrAvg));
12541
12542 /* The SNR returned for all purposes is the average SNR over
12543 * WLANTL_MAX_SNR_DATA_SMAPLES.When data samples
12544 * > WLANTL_MAX_SNR_DATA_SAMPLES are obtained,
12545 * store the average of the samples in prevSnrAvg
12546 * and start a new averaging window. The prevSnrAvg is used when
12547 * enough data samples are not available when applications
12548 * actually query for SNR.
12549 *
12550 * SEE: WLANTL_GetSnr()
12551 */
12552 if (tlCtxt->atlSTAClients[STAid]->snrIdx >= WLANTL_MAX_SNR_DATA_SAMPLES)
12553 {
12554 tlCtxt->atlSTAClients[STAid]->prevSnrAvg =
12555 tlCtxt->atlSTAClients[STAid]->snrSum /
12556 tlCtxt->atlSTAClients[STAid]->snrIdx;
12557 tlCtxt->atlSTAClients[STAid]->snrSum = 0;
12558 tlCtxt->atlSTAClients[STAid]->snrIdx = 0;
12559 }
12560 tlCtxt->atlSTAClients[STAid]->snrSum += currentSNR;
12561 tlCtxt->atlSTAClients[STAid]->snrIdx += 1;
12562
12563 return VOS_STATUS_SUCCESS;
12564}
Jeff Johnson295189b2012-06-20 16:38:30 -070012565
12566/*
12567 DESCRIPTION
12568 TL returns the weight currently maintained in TL.
12569 IN
12570 pvosGCtx: pointer to the global vos context; a handle to TL's
12571 or SME's control block can be extracted from its context
12572
12573 OUT
12574 pACWeights: Caller allocated memory for filling in weights
12575
12576 RETURN VALUE VOS_STATUS
12577*/
12578VOS_STATUS
12579WLANTL_GetACWeights
12580(
12581 v_PVOID_t pvosGCtx,
12582 v_U8_t* pACWeights
12583)
12584{
12585 WLANTL_CbType* pTLCb = NULL;
12586 v_U8_t ucIndex;
12587 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
12588
12589 /*------------------------------------------------------------------------
12590 Sanity check
12591 ------------------------------------------------------------------------*/
12592 if ( NULL == pACWeights )
12593 {
12594 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
12595 "WLAN TL:Invalid parameter sent on WLANTL_GetACWeights"));
12596 return VOS_STATUS_E_INVAL;
12597 }
12598
12599 /*------------------------------------------------------------------------
12600 Extract TL control block and check existance
12601 ------------------------------------------------------------------------*/
12602 pTLCb = VOS_GET_TL_CB(pvosGCtx);
12603 if ( NULL == pTLCb )
12604 {
12605 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
12606 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_GetACWeights"));
12607 return VOS_STATUS_E_FAULT;
12608 }
12609 for ( ucIndex = 0; ucIndex < WLANTL_MAX_AC ; ucIndex++)
12610 {
12611 pACWeights[ucIndex] = pTLCb->tlConfigInfo.ucAcWeights[ucIndex];
12612 }
12613
12614 return VOS_STATUS_SUCCESS;
12615}
12616
12617
12618
12619/*
12620 DESCRIPTION
12621 Change the weight currently maintained by TL.
12622 IN
12623 pvosGCtx: pointer to the global vos context; a handle to TL's
12624 or SME's control block can be extracted from its context
12625 pACWeights: Caller allocated memory contain the weights to use
12626
12627
12628 RETURN VALUE VOS_STATUS
12629*/
12630VOS_STATUS
12631WLANTL_SetACWeights
12632(
12633 v_PVOID_t pvosGCtx,
12634 v_U8_t* pACWeights
12635)
12636{
12637 WLANTL_CbType* pTLCb = NULL;
12638 v_U8_t ucIndex;
12639 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
12640
12641 /*------------------------------------------------------------------------
12642 Sanity check
12643 ------------------------------------------------------------------------*/
12644 if ( NULL == pACWeights )
12645 {
12646 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
12647 "WLAN TL:Invalid parameter sent on WLANTL_GetACWeights"));
12648 return VOS_STATUS_E_INVAL;
12649 }
12650
12651 /*------------------------------------------------------------------------
12652 Extract TL control block and check existance
12653 ------------------------------------------------------------------------*/
12654 pTLCb = VOS_GET_TL_CB(pvosGCtx);
12655 if ( NULL == pTLCb )
12656 {
12657 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
12658 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_GetACWeights"));
12659 return VOS_STATUS_E_FAULT;
12660 }
12661 for ( ucIndex = 0; ucIndex < WLANTL_MAX_AC ; ucIndex++)
12662 {
12663 pTLCb->tlConfigInfo.ucAcWeights[ucIndex] = pACWeights[ucIndex];
12664 }
12665
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +053012666 pTLCb->tlConfigInfo.ucAcWeights[WLANTL_AC_HIGH_PRIO] = pACWeights[WLANTL_AC_VO];
Jeff Johnson295189b2012-06-20 16:38:30 -070012667 return VOS_STATUS_SUCCESS;
12668}
12669
12670
12671/*==========================================================================
12672
12673 FUNCTION
12674
12675 DESCRIPTION
12676
12677 PARAMETERS
12678
12679 RETURN VALUE
12680
12681============================================================================*/
12682void WLANTL_PowerStateChangedCB
12683(
12684 v_PVOID_t pAdapter,
12685 tPmcState newState
12686)
12687{
12688 WLANTL_CbType *tlCtxt = VOS_GET_TL_CB(pAdapter);
12689
12690 if (NULL == tlCtxt)
12691 {
12692 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +053012693 "%s: Invalid TL Control Block", __func__ );
Jeff Johnson295189b2012-06-20 16:38:30 -070012694 return;
12695 }
12696
12697 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO, "Power state changed, new state is %d", newState );
12698 switch(newState)
12699 {
12700 case FULL_POWER:
12701 tlCtxt->isBMPS = VOS_FALSE;
12702 break;
12703
12704 case BMPS:
12705#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
12706 WLANTL_SetFWRSSIThresholds(pAdapter);
12707#endif
12708
12709 tlCtxt->isBMPS = VOS_TRUE;
12710 break;
12711
12712 case IMPS:
12713 case LOW_POWER:
12714 case REQUEST_BMPS:
12715 case REQUEST_FULL_POWER:
12716 case REQUEST_IMPS:
12717 case STOPPED:
12718 case REQUEST_START_UAPSD:
12719 case REQUEST_STOP_UAPSD:
12720 case UAPSD:
12721 case REQUEST_STANDBY:
12722 case STANDBY:
12723 case REQUEST_ENTER_WOWL:
12724 case REQUEST_EXIT_WOWL:
12725 case WOWL:
12726 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN, "Not handle this events %d", newState ));
12727 break;
12728
12729 default:
12730 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR, "Not a valid event %d", newState ));
12731 break;
12732 }
12733
12734 return;
12735}
12736/*==========================================================================
12737 FUNCTION WLANTL_GetEtherType
12738
12739 DESCRIPTION Extract Ether type information from the BD
12740
12741 DEPENDENCIES NONE
12742
12743 PARAMETERS in aucBDHeader - BD header
12744 in vosDataBuff - data buffer
12745 in ucMPDUHLen - MPDU header length
12746 out pUsEtherType - pointer to Ethertype
12747
12748 RETURN VALUE VOS_STATUS_SUCCESS : if the EtherType is successfully extracted
12749 VOS_STATUS_FAILURE : if the EtherType extraction failed and
12750 the packet was dropped
12751
12752 SIDE EFFECTS NONE
12753
12754============================================================================*/
12755static VOS_STATUS WLANTL_GetEtherType
12756(
12757 v_U8_t * aucBDHeader,
12758 vos_pkt_t * vosDataBuff,
12759 v_U8_t ucMPDUHLen,
12760 v_U16_t * pUsEtherType
12761)
12762{
12763 v_U8_t ucOffset;
12764 v_U16_t usEtherType = *pUsEtherType;
12765 v_SIZE_t usLLCSize = sizeof(usEtherType);
12766 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
12767
12768 /*------------------------------------------------------------------------
12769 Check if LLC is present - if not, TL is unable to determine type
12770 ------------------------------------------------------------------------*/
12771 if ( VOS_FALSE == WDA_IS_RX_LLC_PRESENT( aucBDHeader ) )
12772 {
12773 ucOffset = WLANTL_802_3_HEADER_LEN - sizeof(usEtherType);
12774 }
12775 else
12776 {
12777 ucOffset = ucMPDUHLen + WLANTL_LLC_PROTO_TYPE_OFFSET;
12778 }
12779
12780 /*------------------------------------------------------------------------
12781 Extract LLC type
12782 ------------------------------------------------------------------------*/
12783 vosStatus = vos_pkt_extract_data( vosDataBuff, ucOffset,
12784 (v_PVOID_t)&usEtherType, &usLLCSize);
12785
12786 if (( VOS_STATUS_SUCCESS != vosStatus ) ||
12787 ( sizeof(usEtherType) != usLLCSize ))
12788
12789 {
12790 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
12791 "WLAN TL:Error extracting Ether type from data packet"));
12792 /* Drop packet */
12793 vos_pkt_return_packet(vosDataBuff);
12794 vosStatus = VOS_STATUS_E_FAILURE;
12795 }
12796 else
12797 {
12798 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
12799 "WLAN TL:Ether type retrieved before endianess conv: %d",
12800 usEtherType));
12801
12802 usEtherType = vos_be16_to_cpu(usEtherType);
12803 *pUsEtherType = usEtherType;
12804
12805 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
12806 "WLAN TL:Ether type retrieved: %d", usEtherType));
12807 }
12808
12809 return vosStatus;
12810}
12811
Jeff Johnson295189b2012-06-20 16:38:30 -070012812/*==========================================================================
12813 FUNCTION WLANTL_GetSoftAPStatistics
12814
12815 DESCRIPTION Collect the cumulative statistics for all Softap stations
12816
12817 DEPENDENCIES NONE
12818
12819 PARAMETERS in pvosGCtx - Pointer to the global vos context
12820 bReset - If set TL statistics will be cleared after reading
12821 out statsSum - pointer to collected statistics
12822
12823 RETURN VALUE VOS_STATUS_SUCCESS : if the Statistics are successfully extracted
12824
12825 SIDE EFFECTS NONE
12826
12827============================================================================*/
12828VOS_STATUS WLANTL_GetSoftAPStatistics(v_PVOID_t pAdapter, WLANTL_TRANSFER_STA_TYPE *statsSum, v_BOOL_t bReset)
12829{
12830 v_U8_t i = 0;
12831 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
12832 WLANTL_CbType *pTLCb = VOS_GET_TL_CB(pAdapter);
12833 WLANTL_TRANSFER_STA_TYPE statBufferTemp;
12834 vos_mem_zero((v_VOID_t *)&statBufferTemp, sizeof(WLANTL_TRANSFER_STA_TYPE));
12835 vos_mem_zero((v_VOID_t *)statsSum, sizeof(WLANTL_TRANSFER_STA_TYPE));
12836
12837
12838 if ( NULL == pTLCb )
12839 {
12840 return VOS_STATUS_E_FAULT;
12841 }
12842
12843 // Sum up all the statistics for stations of Soft AP from TL
12844 for (i = 0; i < WLAN_MAX_STA_COUNT; i++)
12845 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053012846 if ( NULL == pTLCb->atlSTAClients[i])
12847 {
12848 continue;
12849 }
12850 if (pTLCb->atlSTAClients[i]->wSTADesc.wSTAType == WLAN_STA_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -070012851 {
12852 vosStatus = WLANTL_GetStatistics(pAdapter, &statBufferTemp, i);// Can include staId 1 because statistics not collected for it
12853
12854 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
12855 return VOS_STATUS_E_FAULT;
12856
12857 // Add to the counters
12858 statsSum->txUCFcnt += statBufferTemp.txUCFcnt;
12859 statsSum->txMCFcnt += statBufferTemp.txMCFcnt;
12860 statsSum->txBCFcnt += statBufferTemp.txBCFcnt;
12861 statsSum->txUCBcnt += statBufferTemp.txUCBcnt;
12862 statsSum->txMCBcnt += statBufferTemp.txMCBcnt;
12863 statsSum->txBCBcnt += statBufferTemp.txBCBcnt;
12864 statsSum->rxUCFcnt += statBufferTemp.rxUCFcnt;
12865 statsSum->rxMCFcnt += statBufferTemp.rxMCFcnt;
12866 statsSum->rxBCFcnt += statBufferTemp.rxBCFcnt;
12867 statsSum->rxUCBcnt += statBufferTemp.rxUCBcnt;
12868 statsSum->rxMCBcnt += statBufferTemp.rxMCBcnt;
12869 statsSum->rxBCBcnt += statBufferTemp.rxBCBcnt;
12870
12871 if (bReset)
12872 {
12873 vosStatus = WLANTL_ResetStatistics(pAdapter, i);
12874 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
12875 return VOS_STATUS_E_FAULT;
12876 }
12877 }
12878 }
12879
12880 return vosStatus;
12881}
Mohit Khanna698ba2a2012-12-04 15:08:18 -080012882
Jeff Johnson295189b2012-06-20 16:38:30 -070012883/*===============================================================================
12884 FUNCTION WLANTL_IsReplayPacket
12885
12886 DESCRIPTION This function does replay check for valid stations
12887
12888 DEPENDENCIES Validity of replay check must be done before the function
12889 is called
12890
12891 PARAMETERS currentReplayCounter current replay counter taken from RX BD
12892 previousReplayCounter previous replay counter taken from TL CB
12893
12894 RETRUN VOS_TRUE packet is a replay packet
12895 VOS_FALSE packet is not a replay packet
12896
12897 SIDE EFFECTS none
12898 ===============================================================================*/
12899v_BOOL_t
12900WLANTL_IsReplayPacket
12901(
12902 v_U64_t ullcurrentReplayCounter,
12903 v_U64_t ullpreviousReplayCounter
12904)
12905{
12906 /* Do the replay check by comparing previous received replay counter with
12907 current received replay counter*/
12908 if(ullpreviousReplayCounter < ullcurrentReplayCounter)
12909 {
12910 /* Valid packet not replay */
12911 return VOS_FALSE;
12912 }
12913 else
12914 {
12915
12916 /* Current packet number is less than or equal to previuos received
12917 packet no, this means current packet is replay packet */
12918 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
12919 "WLAN TL: Replay packet found with replay counter :[0x%llX]",ullcurrentReplayCounter);
12920
12921 return VOS_TRUE;
12922 }
12923}
12924
12925#if 0
12926/*===============================================================================
12927 FUNCTION WLANTL_GetReplayCounterFromRxBD
12928
12929 DESCRIPTION This function extracts 48-bit replay packet number from RX BD
12930
12931 DEPENDENCIES Validity of replay check must be done before the function
12932 is called
12933
12934 PARAMETERS pucRxHeader pointer to RX BD header
12935
12936 RETRUN v_U64_t Packet number extarcted from RX BD
12937
12938 SIDE EFFECTS none
12939 ===============================================================================*/
12940v_U64_t
12941WLANTL_GetReplayCounterFromRxBD
12942(
12943 v_U8_t *pucRxBDHeader
12944)
12945{
12946/* 48-bit replay counter is created as follows
12947 from RX BD 6 byte PMI command:
12948 Addr : AES/TKIP
12949 0x38 : pn3/tsc3
12950 0x39 : pn2/tsc2
12951 0x3a : pn1/tsc1
12952 0x3b : pn0/tsc0
12953
12954 0x3c : pn5/tsc5
12955 0x3d : pn4/tsc4 */
12956
12957#ifdef ANI_BIG_BYTE_ENDIAN
12958 v_U64_t ullcurrentReplayCounter = 0;
12959 /* Getting 48-bit replay counter from the RX BD */
12960 ullcurrentReplayCounter = WLANHAL_RX_BD_GET_PMICMD_20TO23(pucRxBDHeader);
12961 ullcurrentReplayCounter <<= 16;
12962 ullcurrentReplayCounter |= (( WLANHAL_RX_BD_GET_PMICMD_24TO25(pucRxBDHeader) & 0xFFFF0000) >> 16);
12963 return ullcurrentReplayCounter;
12964#else
12965 v_U64_t ullcurrentReplayCounter = 0;
12966 /* Getting 48-bit replay counter from the RX BD */
12967 ullcurrentReplayCounter = (WLANHAL_RX_BD_GET_PMICMD_24TO25(pucRxBDHeader) & 0x0000FFFF);
12968 ullcurrentReplayCounter <<= 32;
12969 ullcurrentReplayCounter |= WLANHAL_RX_BD_GET_PMICMD_20TO23(pucRxBDHeader);
12970 return ullcurrentReplayCounter;
12971#endif
12972}
12973#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070012974
12975/*===============================================================================
12976 FUNCTION WLANTL_PostResNeeded
12977
12978 DESCRIPTION This function posts message to TL to reserve BD/PDU memory
12979
12980 DEPENDENCIES None
12981
12982 PARAMETERS pvosGCtx
12983
12984 RETURN None
12985
12986 SIDE EFFECTS none
12987 ===============================================================================*/
12988
12989void WLANTL_PostResNeeded(v_PVOID_t pvosGCtx)
12990{
12991 vos_msg_t vosMsg;
12992
12993 vosMsg.reserved = 0;
12994 vosMsg.bodyptr = NULL;
12995 vosMsg.type = WLANTL_TX_RES_NEEDED;
12996 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
12997 "WLAN TL: BD/PDU available interrupt received, Posting message to TL");
12998 if(!VOS_IS_STATUS_SUCCESS(vos_tx_mq_serialize( VOS_MQ_ID_TL, &vosMsg)))
12999 {
13000 VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070013001 " %s fails to post message", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070013002 }
13003}
13004
13005/*===============================================================================
13006 FUNCTION WLANTL_UpdateRssiBmps
13007
13008 DESCRIPTION This function updates the TL's RSSI (in BMPS mode)
13009
13010 DEPENDENCIES None
13011
13012 PARAMETERS
13013
13014 pvosGCtx VOS context VOS Global context
13015 staId Station ID Station ID
13016 rssi RSSI (BMPS mode) RSSI in BMPS mode
13017
13018 RETURN None
13019
13020 SIDE EFFECTS none
13021 ===============================================================================*/
13022
13023void WLANTL_UpdateRssiBmps(v_PVOID_t pvosGCtx, v_U8_t staId, v_S7_t rssi)
13024{
13025 WLANTL_CbType* pTLCb = VOS_GET_TL_CB(pvosGCtx);
13026
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053013027 if (NULL != pTLCb && NULL != pTLCb->atlSTAClients[staId])
Jeff Johnson295189b2012-06-20 16:38:30 -070013028 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053013029 pTLCb->atlSTAClients[staId]->rssiAvgBmps = rssi;
Jeff Johnson295189b2012-06-20 16:38:30 -070013030 }
13031}
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053013032
13033/*===============================================================================
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053013034 FUNCTION WLANTL_UpdateSnrBmps
13035
13036 DESCRIPTION This function updates the TL's SNR (in BMPS mode)
13037
13038 DEPENDENCIES None
13039
13040 PARAMETERS
13041
13042 pvosGCtx VOS context VOS Global context
13043 staId Station ID Station ID
13044 snr SNR (BMPS mode) SNR in BMPS mode
13045
13046 RETURN None
13047
13048 SIDE EFFECTS none
13049 ===============================================================================*/
13050
13051void WLANTL_UpdateSnrBmps(v_PVOID_t pvosGCtx, v_U8_t staId, v_S7_t snr)
13052{
13053 WLANTL_CbType* pTLCb = VOS_GET_TL_CB(pvosGCtx);
13054
13055 if (NULL != pTLCb && NULL != pTLCb->atlSTAClients[staId])
13056 {
13057 pTLCb->atlSTAClients[staId]->snrAvgBmps = snr;
13058 }
13059}
13060
13061/*===============================================================================
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053013062 FUNCTION WLANTL_UpdateLinkCapacity
13063
13064 DESCRIPTION This function updates the STA's Link Capacity in TL
13065
13066 DEPENDENCIES None
13067
13068 PARAMETERS
13069
13070 pvosGCtx VOS context VOS Global context
13071 staId Station ID Station ID
13072 linkCapacity linkCapacity Link Capacity
13073
13074 RETURN None
13075
13076 SIDE EFFECTS none
13077 ===============================================================================*/
13078
13079void WLANTL_UpdateLinkCapacity(v_PVOID_t pvosGCtx, v_U8_t staId, v_U32_t linkCapacity)
13080{
13081 WLANTL_CbType* pTLCb = VOS_GET_TL_CB(pvosGCtx);
13082
13083 if (NULL != pTLCb && NULL != pTLCb->atlSTAClients[staId])
13084 {
13085 pTLCb->atlSTAClients[staId]->linkCapacity = linkCapacity;
13086 }
13087}
13088
13089
13090/*===========================================================================
13091
13092 FUNCTION WLANTL_GetSTALinkCapacity
13093
13094 DESCRIPTION
13095
13096 Returns Link Capacity of a particular STA.
13097
13098 DEPENDENCIES
13099
13100 A station must have been registered before its state can be retrieved.
13101
13102
13103 PARAMETERS
13104
13105 IN
13106 pvosGCtx: pointer to the global vos context; a handle to TL's
13107 control block can be extracted from its context
13108 ucSTAId: identifier of the station
13109
13110 OUT
13111 plinkCapacity: the current link capacity the connection to
13112 the given station
13113
13114
13115 RETURN VALUE
13116
13117 The result code associated with performing the operation
13118
13119 VOS_STATUS_E_INVAL: Input parameters are invalid
13120 VOS_STATUS_E_FAULT: Station ID is outside array boundaries or pointer to
13121 TL cb is NULL ; access would cause a page fault
13122 VOS_STATUS_E_EXISTS: Station was not registered
13123 VOS_STATUS_SUCCESS: Everything is good :)
13124
13125 SIDE EFFECTS
13126
13127============================================================================*/
13128VOS_STATUS
13129WLANTL_GetSTALinkCapacity
13130(
13131 v_PVOID_t pvosGCtx,
13132 v_U8_t ucSTAId,
13133 v_U32_t *plinkCapacity
13134)
13135{
13136 WLANTL_CbType* pTLCb = NULL;
13137 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
13138
13139 /*------------------------------------------------------------------------
13140 Sanity check
13141 ------------------------------------------------------------------------*/
13142 if ( NULL == plinkCapacity )
13143 {
13144 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
13145 FL("WLAN TL:Invalid parameter")));
13146 return VOS_STATUS_E_INVAL;
13147 }
13148
13149 if ( WLANTL_STA_ID_INVALID( ucSTAId ) )
13150 {
13151 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
13152 FL("WLAN TL:Invalid station id")));
13153 return VOS_STATUS_E_FAULT;
13154 }
13155
13156 /*------------------------------------------------------------------------
13157 Extract TL control block and check existance
13158 ------------------------------------------------------------------------*/
13159 pTLCb = VOS_GET_TL_CB(pvosGCtx);
13160 if ( NULL == pTLCb )
13161 {
13162 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
13163 FL("WLAN TL:Invalid TL pointer from pvosGCtx")));
13164 return VOS_STATUS_E_FAULT;
13165 }
13166
13167 if ( NULL == pTLCb->atlSTAClients[ucSTAId] )
13168 {
13169 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
13170 FL("WLAN TL:Client Memory was not allocated")));
13171 return VOS_STATUS_E_FAILURE;
13172 }
13173
13174 if ( 0 == pTLCb->atlSTAClients[ucSTAId]->ucExists )
13175 {
13176 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
13177 FL("WLAN TL:Station was not previously registered")));
13178 return VOS_STATUS_E_EXISTS;
13179 }
13180
13181 /*------------------------------------------------------------------------
13182 Get STA state
13183 ------------------------------------------------------------------------*/
13184 *plinkCapacity = pTLCb->atlSTAClients[ucSTAId]->linkCapacity;
13185
13186 return VOS_STATUS_SUCCESS;
13187}/* WLANTL_GetSTALinkCapacity */