blob: e6847b8dcc0c8e60703a5ddc31103c90613cb910 [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
Mohit Khanna698ba2a2012-12-04 15:08:18 -0800349#ifdef FEATURE_WLAN_TDLS_INTERNAL
350/* FIXME_MUST: during TDLS integration to main/latest, WLANTL_GetEtherType() conflicts.
351But there is difference. existing WLANTL_GetEtherType() expects vosDataBuff->offset points to MPDU Header,
352wherease TDLS expect vosDataBuff->offset should still points to RxBd.
353So far, data frmae stripped RxBD and passed to data frame handler.
354(RxBd should not be stripped in case TDLS, because it will be eventually routed to mgmt packet
355handler, where RX BD should be preserved)
356To avoid breaking existing functionality, for now, I temporarily rename to
357WLANTL_GetEtherType_2(). Eventually this function should be removed and merged to WLANTL_GetEtherType()
358*/
359static VOS_STATUS
360WLANTL_GetEtherType_2
361(
362 v_U8_t * aucBDHeader,
363 vos_pkt_t * vosDataBuff,
364 v_U8_t ucMPDUHLen,
365 v_U16_t * usEtherType
366);
367#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700368#ifdef FEATURE_WLAN_WAPI
369/*---------------------------------------------------------------------------
370 * Adding a global variable to be used when doing frame translation in TxAuth
371 * state so as to not set the protected bit to 1 in the case of WAI frames
372 *---------------------------------------------------------------------------*/
Madan Mohan Koyyalamudidfd6aa82012-10-18 20:18:43 -0700373v_U8_t gUcIsWai;
Jeff Johnson295189b2012-06-20 16:38:30 -0700374#endif
375
376/*----------------------------------------------------------------------------
377 * Externalized Function Definitions
378* -------------------------------------------------------------------------*/
379
380/*----------------------------------------------------------------------------
381 * Function Declarations and Documentation
382 * -------------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +0530383/*==========================================================================
384
385 FUNCTION WLANTL_FreeClientMemory
386
387 DESCRIPTION
388 It frees up the memory allocated to all the STA clients in TLCB block
389 Can be called inside Close, Stop or when some FAULT occurs
390
391 DEPENDENCIES
392
393 PARAMETERS
394
395 IN
396 pClientSTA: Pointer to the global client pointer array
397
398 RETURN VALUE
399
400 SIDE EFFECTS
401
402============================================================================*/
403void WLANTL_FreeClientMemory
404(WLANTL_STAClientType* pClientSTA[WLAN_MAX_STA_COUNT])
405{
406 v_U32_t i = 0;
407 for(i =0; i < WLAN_MAX_STA_COUNT; i++)
408 {
409 if( NULL != pClientSTA[i] )
410 {
411 vos_mem_free(pClientSTA[i]);
412 }
413 pClientSTA[i] = NULL;
414 }
415 return;
416}
Jeff Johnson295189b2012-06-20 16:38:30 -0700417
418/*==========================================================================
419
420 FUNCTION WLANTL_Open
421
422 DESCRIPTION
423 Called by HDD at driver initialization. TL will initialize all its
424 internal resources and will wait for the call to start to register
425 with the other modules.
426
427 DEPENDENCIES
428
429 PARAMETERS
430
431 IN
432 pvosGCtx: pointer to the global vos context; a handle to TL's
433 control block can be extracted from its context
434 pTLConfig: TL Configuration
435
436 RETURN VALUE
437 The result code associated with performing the operation
438
439 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a page
440 fault
441 VOS_STATUS_SUCCESS: Everything is good :)
442
443 SIDE EFFECTS
444
445============================================================================*/
446VOS_STATUS
447WLANTL_Open
448(
449 v_PVOID_t pvosGCtx,
450 WLANTL_ConfigInfoType* pTLConfig
451)
452{
453 WLANTL_CbType* pTLCb = NULL;
454 v_U8_t ucIndex;
455 tHalHandle smeContext;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +0530456 v_U32_t i = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700457#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
458 VOS_STATUS status = VOS_STATUS_SUCCESS;
459#endif
460 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
461
462 /*------------------------------------------------------------------------
463 Sanity check
464 Extract TL control block
465 ------------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +0530466 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -0700467 vos_alloc_context( pvosGCtx, VOS_MODULE_ID_TL,
468 (void*)&pTLCb, sizeof(WLANTL_CbType));
469
470 pTLCb = VOS_GET_TL_CB(pvosGCtx);
471 if (( NULL == pTLCb ) || ( NULL == pTLConfig ) )
472 {
Madan Mohan Koyyalamudic0e5bd82012-09-18 17:12:27 -0700473 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_FATAL,
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +0530474 "WLAN TL: Invalid input pointer on WLANTL_Open TL %p Config %p", pTLCb, pTLConfig ));
Jeff Johnson295189b2012-06-20 16:38:30 -0700475 return VOS_STATUS_E_FAULT;
476 }
477
Madan Mohan Koyyalamudic0e5bd82012-09-18 17:12:27 -0700478 /* Set the default log level to VOS_TRACE_LEVEL_ERROR */
479 vos_trace_setLevel(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR);
480
Jeff Johnson295189b2012-06-20 16:38:30 -0700481 smeContext = vos_get_context(VOS_MODULE_ID_SME, pvosGCtx);
482 if ( NULL == smeContext )
483 {
484 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700485 "%s: Invalid smeContext", __func__));
Jeff Johnson295189b2012-06-20 16:38:30 -0700486 return VOS_STATUS_E_FAULT;
487 }
488
489 /* Zero out the memory so we are OK, when CleanCB is called.*/
490 vos_mem_zero((v_VOID_t *)pTLCb, sizeof(WLANTL_CbType));
491
492 /*------------------------------------------------------------------------
493 Clean up TL control block, initialize all values
494 ------------------------------------------------------------------------*/
495 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
496 "WLAN TL:WLANTL_Open"));
497
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +0530498 for ( i =0; i<WLAN_MAX_STA_COUNT; i++ )
Jeff Johnson295189b2012-06-20 16:38:30 -0700499 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +0530500 if ( i < WLAN_NON32_STA_COUNT )
501 {
502 pTLCb->atlSTAClients[i] = vos_mem_malloc(sizeof(WLANTL_STAClientType));
503 /* Allocating memory for LEGACY STA COUNT so as to avoid regression issues. */
504 if ( NULL == pTLCb->atlSTAClients[i] )
505 {
506 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR, "WLAN TL: StaClient allocation failed"));
507 WLANTL_FreeClientMemory(pTLCb->atlSTAClients);
508 vos_free_context(pvosGCtx, VOS_MODULE_ID_TL, pTLCb);
509 return VOS_STATUS_E_FAULT;
510 }
511 vos_mem_zero((v_VOID_t *) pTLCb->atlSTAClients[i], sizeof(WLANTL_STAClientType));
512 }
513 else
514 {
515 pTLCb->atlSTAClients[i] = NULL;
516 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700517 }
518
Jeff Johnson295189b2012-06-20 16:38:30 -0700519 pTLCb->reorderBufferPool = vos_mem_malloc(sizeof(WLANTL_REORDER_BUFFER_T) * WLANTL_MAX_BA_SESSION);
520 if (NULL == pTLCb->reorderBufferPool)
521 {
Arif Hussainf2b00992013-11-17 21:46:15 -0800522 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 +0530523 WLANTL_FreeClientMemory(pTLCb->atlSTAClients);
Jeff Johnson295189b2012-06-20 16:38:30 -0700524 vos_free_context(pvosGCtx, VOS_MODULE_ID_TL, pTLCb);
525 return VOS_STATUS_E_FAULT;
Jeff Johnson295189b2012-06-20 16:38:30 -0700526 }
527
528 vos_mem_zero((v_VOID_t *)pTLCb->reorderBufferPool, sizeof(WLANTL_REORDER_BUFFER_T) * WLANTL_MAX_BA_SESSION);
529
530 WLANTL_CleanCB(pTLCb, 0 /*do not empty*/);
531
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +0530532 for ( ucIndex = 0; ucIndex < WLANTL_NUM_TX_QUEUES ; ucIndex++)
Jeff Johnson295189b2012-06-20 16:38:30 -0700533 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +0530534 pTLCb->tlConfigInfo.ucAcWeights[ucIndex] = pTLConfig->ucAcWeights[ucIndex];
Jeff Johnson295189b2012-06-20 16:38:30 -0700535 }
536
Dhanashri Atred8c20a32014-01-03 17:20:55 -0800537 for ( ucIndex = 0; ucIndex < WLANTL_MAX_AC ; ucIndex++)
538 {
539 pTLCb->tlConfigInfo.ucReorderAgingTime[ucIndex] = pTLConfig->ucReorderAgingTime[ucIndex];
540 }
541
Jeff Johnson295189b2012-06-20 16:38:30 -0700542 // scheduling init to be the last one of previous round
543 pTLCb->uCurServedAC = WLANTL_AC_BK;
544 pTLCb->ucCurLeftWeight = 1;
545 pTLCb->ucCurrentSTA = WLAN_MAX_STA_COUNT-1;
546
547#if 0
548 //flow control field init
549 vos_mem_zero(&pTLCb->tlFCInfo, sizeof(tFcTxParams_type));
550 //bit 0: set (Bd/pdu count) bit 1: set (request station PS change notification)
551 pTLCb->tlFCInfo.fcConfig = 0x1;
552#endif
553
554 pTLCb->vosTxFCBuf = NULL;
555 pTLCb->tlConfigInfo.uMinFramesProcThres =
556 pTLConfig->uMinFramesProcThres;
Jeff Johnson295189b2012-06-20 16:38:30 -0700557
Sunil Ravid5406f22013-01-22 00:18:31 -0800558#ifdef FEATURE_WLAN_TDLS
559 pTLCb->ucTdlsPeerCount = 0;
560#endif
561
Jeff Johnson295189b2012-06-20 16:38:30 -0700562 pTLCb->tlConfigInfo.uDelayedTriggerFrmInt =
563 pTLConfig->uDelayedTriggerFrmInt;
564
565 /*------------------------------------------------------------------------
566 Allocate internal resources
567 ------------------------------------------------------------------------*/
568 vos_pkt_get_packet(&pTLCb->vosDummyBuf, VOS_PKT_TYPE_RX_RAW, 1, 1,
569 1/*true*/,NULL, NULL);
570
571 WLANTL_InitBAReorderBuffer(pvosGCtx);
572#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
573 /* Initialize Handoff support modue
574 * RSSI measure and Traffic state monitoring */
575 status = WLANTL_HSInit(pvosGCtx);
576 if(!VOS_IS_STATUS_SUCCESS(status))
577 {
578 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
579 "Handoff support module init fail"));
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +0530580 WLANTL_FreeClientMemory(pTLCb->atlSTAClients);
Jeff Johnson295189b2012-06-20 16:38:30 -0700581 vos_mem_free(pTLCb->reorderBufferPool);
582 vos_free_context(pvosGCtx, VOS_MODULE_ID_TL, pTLCb);
583 return status;
584 }
585#endif
586
587 pTLCb->isBMPS = VOS_FALSE;
588 pmcRegisterDeviceStateUpdateInd( smeContext,
589 WLANTL_PowerStateChangedCB, pvosGCtx );
590
591 return VOS_STATUS_SUCCESS;
592}/* WLANTL_Open */
593
594/*==========================================================================
595
596 FUNCTION WLANTL_Start
597
598 DESCRIPTION
599 Called by HDD as part of the overall start procedure. TL will use this
600 call to register with BAL as a transport layer entity.
601
602 DEPENDENCIES
603
604 PARAMETERS
605
606 IN
607 pvosGCtx: pointer to the global vos context; a handle to TL's
608 control block can be extracted from its context
609
610 RETURN VALUE
611 The result code associated with performing the operation
612
613 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a page
614 fault
615 VOS_STATUS_SUCCESS: Everything is good :)
616
617 Other codes can be returned as a result of a BAL failure; see BAL API
618 for more info
619
620 SIDE EFFECTS
621
622============================================================================*/
623VOS_STATUS
624WLANTL_Start
625(
626 v_PVOID_t pvosGCtx
627)
628{
629 WLANTL_CbType* pTLCb = NULL;
630 v_U32_t uResCount = WDA_TLI_MIN_RES_DATA;
631 VOS_STATUS vosStatus;
632 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
633
634 /*------------------------------------------------------------------------
635 Sanity check
636 Extract TL control block
637 ------------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +0530638 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -0700639 pTLCb = VOS_GET_TL_CB(pvosGCtx);
640 if ( NULL == pTLCb )
641 {
642 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
643 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_Start"));
644 return VOS_STATUS_E_FAULT;
645 }
646
647 /*------------------------------------------------------------------------
648 Register with WDA as transport layer client
649 Request resources for tx from bus
650 ------------------------------------------------------------------------*/
651 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
652 "WLAN TL:WLAN TL:WLANTL_Start"));
653
Katya Nigam42e16e82014-02-04 16:28:55 +0530654 tlTraceInit();
Jeff Johnson295189b2012-06-20 16:38:30 -0700655 vosStatus = WDA_DS_Register( pvosGCtx,
656 WLANTL_TxComp,
657 WLANTL_RxFrames,
658 WLANTL_GetFrames,
659 WLANTL_ResourceCB,
660 WDA_TLI_MIN_RES_DATA,
661 pvosGCtx,
662 &uResCount );
663
664 if ( VOS_STATUS_SUCCESS != vosStatus )
665 {
666 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
667 "WLAN TL:TL failed to register with BAL/WDA, Err: %d",
668 vosStatus));
669 return vosStatus;
670 }
671
672 /* Enable transmission */
673 vos_atomic_set_U8( &pTLCb->ucTxSuspended, 0);
674
675 pTLCb->uResCount = uResCount;
Jeff Johnson295189b2012-06-20 16:38:30 -0700676 return VOS_STATUS_SUCCESS;
677}/* WLANTL_Start */
678
679/*==========================================================================
680
681 FUNCTION WLANTL_Stop
682
683 DESCRIPTION
684 Called by HDD to stop operation in TL, before close. TL will suspend all
685 frame transfer operation and will wait for the close request to clean up
686 its resources.
687
688 DEPENDENCIES
689
690 PARAMETERS
691
692 IN
693 pvosGCtx: pointer to the global vos context; a handle to TL's
694 control block can be extracted from its context
695
696 RETURN VALUE
697 The result code associated with performing the operation
698
699 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a page
700 fault
701 VOS_STATUS_SUCCESS: Everything is good :)
702
703 SIDE EFFECTS
704
705============================================================================*/
706VOS_STATUS
707WLANTL_Stop
708(
709 v_PVOID_t pvosGCtx
710)
711{
712 WLANTL_CbType* pTLCb = NULL;
713 v_U8_t ucIndex;
714 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
715
716 /*------------------------------------------------------------------------
717 Sanity check
718 Extract TL control block
719 ------------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +0530720 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -0700721 pTLCb = VOS_GET_TL_CB(pvosGCtx);
722 if ( NULL == pTLCb )
723 {
724 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
725 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_ChangeSTAState"));
726 return VOS_STATUS_E_FAULT;
727 }
728
729 /*------------------------------------------------------------------------
730 Stop TL and empty Station list
731 ------------------------------------------------------------------------*/
732 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
733 "WLAN TL:WLANTL_Stop"));
734
735 /* Disable transmission */
736 vos_atomic_set_U8( &pTLCb->ucTxSuspended, 1);
737
738 if ( NULL != pTLCb->tlMgmtFrmClient.vosPendingDataBuff )
739 {
740 vos_pkt_return_packet(pTLCb->tlMgmtFrmClient.vosPendingDataBuff);
741 pTLCb->tlMgmtFrmClient.vosPendingDataBuff = NULL;
742 }
743
744 if ( NULL != pTLCb->tlBAPClient.vosPendingDataBuff )
745 {
746 vos_pkt_return_packet(pTLCb->tlBAPClient.vosPendingDataBuff);
747 pTLCb->tlBAPClient.vosPendingDataBuff = NULL;
748 }
749
750#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
751 if(VOS_STATUS_SUCCESS != WLANTL_HSStop(pvosGCtx))
752 {
753 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
754 "Handoff Support module stop fail"));
755 }
756#endif
757
758 /*-------------------------------------------------------------------------
759 Clean client stations
760 -------------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +0530761 for ( ucIndex = 0; ucIndex < WLAN_MAX_STA_COUNT; ucIndex++)
Jeff Johnson295189b2012-06-20 16:38:30 -0700762 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +0530763 if ( NULL != pTLCb->atlSTAClients[ucIndex] )
764 {
765 WLANTL_CleanSTA(pTLCb->atlSTAClients[ucIndex], 1 /*empty all queues*/);
766 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700767 }
768
769
770 return VOS_STATUS_SUCCESS;
771}/* WLANTL_Stop */
772
773/*==========================================================================
774
775 FUNCTION WLANTL_Close
776
777 DESCRIPTION
778 Called by HDD during general driver close procedure. TL will clean up
779 all the internal resources.
780
781 DEPENDENCIES
782
783 PARAMETERS
784
785 IN
786 pvosGCtx: pointer to the global vos context; a handle to TL's
787 control block can be extracted from its context
788
789 RETURN VALUE
790 The result code associated with performing the operation
791
792 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a page
793 fault
794 VOS_STATUS_SUCCESS: Everything is good :)
795
796 SIDE EFFECTS
797
798============================================================================*/
799VOS_STATUS
800WLANTL_Close
801(
802 v_PVOID_t pvosGCtx
803)
804{
805 WLANTL_CbType* pTLCb = NULL;
806 tHalHandle smeContext;
807 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
808
809 /*------------------------------------------------------------------------
810 Sanity check
811 Extract TL control block
812 ------------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +0530813 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -0700814 pTLCb = VOS_GET_TL_CB(pvosGCtx);
815 if ( NULL == pTLCb )
816 {
817 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
818 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_ChangeSTAState"));
819 return VOS_STATUS_E_FAULT;
820 }
821 /*------------------------------------------------------------------------
822 Deregister from PMC
823 ------------------------------------------------------------------------*/
824 smeContext = vos_get_context(VOS_MODULE_ID_SME, pvosGCtx);
825 if ( NULL == smeContext )
826 {
827 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700828 "%s: Invalid smeContext", __func__));
Jeff Johnson295189b2012-06-20 16:38:30 -0700829 // continue so that we can cleanup as much as possible
830 }
831 else
832 {
833 pmcDeregisterDeviceStateUpdateInd( smeContext, WLANTL_PowerStateChangedCB );
834 }
835
836#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
837 if(VOS_STATUS_SUCCESS != WLANTL_HSDeInit(pvosGCtx))
838 {
839 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
840 "Handoff Support module DeInit fail"));
841 }
842#endif
843
844 /*------------------------------------------------------------------------
845 Cleanup TL control block.
846 ------------------------------------------------------------------------*/
847 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
848 "WLAN TL: WLANTL_Close"));
849 WLANTL_CleanCB(pTLCb, 1 /* empty queues/lists/pkts if any*/);
850
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +0530851 WLANTL_FreeClientMemory(pTLCb->atlSTAClients);
852
Jeff Johnson295189b2012-06-20 16:38:30 -0700853 vos_mem_free(pTLCb->reorderBufferPool);
854
855 /*------------------------------------------------------------------------
856 Free TL context from VOSS global
857 ------------------------------------------------------------------------*/
858 vos_free_context(pvosGCtx, VOS_MODULE_ID_TL, pTLCb);
859 return VOS_STATUS_SUCCESS;
860}/* WLANTL_Close */
861
862/*----------------------------------------------------------------------------
863 INTERACTION WITH HDD
864 ---------------------------------------------------------------------------*/
865/*==========================================================================
866
867 FUNCTION WLANTL_ConfigureSwFrameTXXlationForAll
868
869 DESCRIPTION
870 Function to disable/enable frame translation for all association stations.
871
872 DEPENDENCIES
873
874 PARAMETERS
875 IN
876 pvosGCtx: VOS context
877 EnableFrameXlation TRUE means enable SW translation for all stations.
878 .
879
880 RETURN VALUE
881
882 void.
883
884============================================================================*/
885void
886WLANTL_ConfigureSwFrameTXXlationForAll
887(
888 v_PVOID_t pvosGCtx,
889 v_BOOL_t enableFrameXlation
890)
891{
892 v_U8_t ucIndex;
893 /*------------------------------------------------------------------------
894 Extract TL control block
895 ------------------------------------------------------------------------*/
896 WLANTL_CbType* pTLCb = VOS_GET_TL_CB(pvosGCtx);
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +0530897 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -0700898 if ( NULL == pTLCb )
899 {
900 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
901 "WLAN TL:Invalid TL pointer from pvosGCtx on "
902 "WLANTL_ConfigureSwFrameTXXlationForAll"));
903 return;
904 }
905
906 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
907 "WLANTL_ConfigureSwFrameTXXlationForAll: Configure SW frameXlation %d",
908 enableFrameXlation));
909
910 for ( ucIndex = 0; ucIndex < WLAN_MAX_TID; ucIndex++)
911 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +0530912 pClientSTA = pTLCb->atlSTAClients[ucIndex];
913 if ( NULL != pClientSTA && 0 != pClientSTA->ucExists )
Jeff Johnson295189b2012-06-20 16:38:30 -0700914 {
915#ifdef WLAN_SOFTAP_VSTA_FEATURE
916 // if this station was not allocated resources to perform HW-based
917 // TX frame translation then force SW-based TX frame translation
918 // otherwise use the frame translation supplied by the client
919 if (!WDA_IsHwFrameTxTranslationCapable(pvosGCtx, ucIndex))
920 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +0530921 pClientSTA->wSTADesc.ucSwFrameTXXlation = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -0700922 }
923 else
924#endif
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +0530925 pClientSTA->wSTADesc.ucSwFrameTXXlation = enableFrameXlation;
Jeff Johnson295189b2012-06-20 16:38:30 -0700926 }
927 }
928}
929
930/*===========================================================================
931
932 FUNCTION WLANTL_StartForwarding
933
934 DESCRIPTION
935
936 This function is used to ask serialization through TX thread of the
937 cached frame forwarding (if statation has been registered in the mean while)
938 or flushing (if station has not been registered by the time)
939
940 In case of forwarding, upper layer is only required to call WLANTL_RegisterSTAClient()
941 and doesn't need to call this function explicitly. TL will handle this inside
942 WLANTL_RegisterSTAClient().
943
944 In case of flushing, upper layer is required to call this function explicitly
945
946 DEPENDENCIES
947
948 TL must have been initialized before this gets called.
949
950
951 PARAMETERS
952
953 ucSTAId: station id
954
955 RETURN VALUE
956
957 The result code associated with performing the operation
958 Please check return values of vos_tx_mq_serialize.
959
960 SIDE EFFECTS
961 If TL was asked to perform WLANTL_CacheSTAFrame() in WLANTL_RxFrames(),
962 either WLANTL_RegisterSTAClient() or this function must be called
963 within reasonable time. Otherwise, TL will keep cached vos buffer until
964 one of this function is called, and may end up with system buffer exhasution.
965
966 It's an upper layer's responsibility to call this function in case of
967 flushing
968
969============================================================================*/
970
971VOS_STATUS
972WLANTL_StartForwarding
973(
974 v_U8_t ucSTAId,
975 v_U8_t ucUcastSig,
976 v_U8_t ucBcastSig
977)
978{
979 vos_msg_t sMessage;
980 v_U32_t uData;
981 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
982
983 /* Signal the OS to serialize our event */
984 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
985 "Serializing TL Start Forwarding Cached for control STA %d",
986 ucSTAId );
987
988 vos_mem_zero( &sMessage, sizeof(vos_msg_t) );
989
990 uData = ucSTAId | (ucUcastSig << 8 ) | (ucBcastSig << 16);
Jeff Johnsond86c05a2013-11-10 18:50:34 -0800991 sMessage.bodyval = uData;
Katya Nigam664f5032014-05-05 12:24:32 +0530992 sMessage.type = WLANTL_RX_FWD_CACHED;
Jeff Johnson295189b2012-06-20 16:38:30 -0700993
Katya Nigam664f5032014-05-05 12:24:32 +0530994 return vos_rx_mq_serialize(VOS_MQ_ID_TL, &sMessage);
Jeff Johnson295189b2012-06-20 16:38:30 -0700995
996} /* WLANTL_StartForwarding() */
997
998/*===========================================================================
999
Katya Nigam63902932014-06-26 19:04:23 +05301000 FUNCTION WLANTL_EnableCaching
1001
1002 DESCRIPTION
1003
1004 This function is used to enable caching only when assoc/reassoc req is send.
1005 that is cache packets only for such STA ID.
1006
1007
1008 DEPENDENCIES
1009
1010 TL must have been initialized before this gets called.
1011
1012
1013 PARAMETERS
1014
1015 staId: station id
1016
1017 RETURN VALUE
1018
1019 none
1020
1021============================================================================*/
1022void WLANTL_EnableCaching(v_U8_t staId)
1023{
1024 v_PVOID_t pvosGCtx= vos_get_global_context(VOS_MODULE_ID_TL,NULL);
1025 WLANTL_CbType* pTLCb = VOS_GET_TL_CB(pvosGCtx);
1026 if ( NULL == pTLCb )
1027 {
1028 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1029 "WLAN TL:Invalid TL pointer from pvosGCtx on "
1030 "WLANTL_EnableCaching"));
1031 return;
1032 }
1033 pTLCb->atlSTAClients[staId]->enableCaching = 1;
1034}
1035
1036/*===========================================================================
1037
Jeff Johnson295189b2012-06-20 16:38:30 -07001038 FUNCTION WLANTL_AssocFailed
1039
1040 DESCRIPTION
1041
1042 This function is used by PE to notify TL that cache needs to flushed'
1043 when association is not successfully completed
1044
1045 Internally, TL post a message to TX_Thread to serialize the request to
1046 keep lock-free mechanism.
1047
1048
1049 DEPENDENCIES
1050
1051 TL must have been initialized before this gets called.
1052
1053
1054 PARAMETERS
1055
1056 ucSTAId: station id
1057
1058 RETURN VALUE
1059
1060 none
1061
1062 SIDE EFFECTS
1063 There may be race condition that PE call this API and send another association
1064 request immediately with same staId before TX_thread can process the message.
1065
1066 To avoid this, we might need PE to wait for TX_thread process the message,
1067 but this is not currently implemented.
1068
1069============================================================================*/
1070void WLANTL_AssocFailed(v_U8_t staId)
1071{
1072 // flushing frames and forwarding frames uses the same message
1073 // the only difference is what happens when the message is processed
1074 // if the STA exist, the frames will be forwarded
1075 // and if it doesn't exist, the frames will be flushed
1076 // 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 +05301077 MTRACE(vos_trace(VOS_MODULE_ID_TL, TRACE_CODE_TL_ASSOC_FAILED,
1078 staId, 0));
1079
Jeff Johnson295189b2012-06-20 16:38:30 -07001080 if(!VOS_IS_STATUS_SUCCESS(WLANTL_StartForwarding(staId,0,0)))
1081 {
1082 VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Mihir Sheteb7337272014-04-11 15:53:08 +05301083 " %s fails to start forwarding (staId %d)", __func__, staId);
Jeff Johnson295189b2012-06-20 16:38:30 -07001084 }
1085}
Nirav Shah4f765af2015-01-21 19:51:30 +05301086
1087/*===========================================================================
Jeff Johnson295189b2012-06-20 16:38:30 -07001088
1089 FUNCTION WLANTL_Finish_ULA
1090
1091 DESCRIPTION
1092 This function is used by HDD to notify TL to finish Upper layer authentication
1093 incase the last EAPOL packet is pending in the TL queue.
1094 To avoid the race condition between sme set key and the last EAPOL packet
1095 the HDD module calls this function just before calling the sme_RoamSetKey.
1096
1097 DEPENDENCIES
1098
1099 TL must have been initialized before this gets called.
Nirav Shah4f765af2015-01-21 19:51:30 +05301100
Jeff Johnson295189b2012-06-20 16:38:30 -07001101 PARAMETERS
1102
Nirav Shah4f765af2015-01-21 19:51:30 +05301103 callbackRoutine: HDD Callback function.
1104 callbackContext: HDD userdata context.
1105 pvosGCtx : VOS Context
1106 ucSTAId : STA ID
1107
Jeff Johnson295189b2012-06-20 16:38:30 -07001108 RETURN VALUE
1109
1110 VOS_STATUS_SUCCESS/VOS_STATUS_FAILURE
Nirav Shah4f765af2015-01-21 19:51:30 +05301111
Jeff Johnson295189b2012-06-20 16:38:30 -07001112 SIDE EFFECTS
Nirav Shah4f765af2015-01-21 19:51:30 +05301113
Jeff Johnson295189b2012-06-20 16:38:30 -07001114============================================================================*/
1115
1116VOS_STATUS WLANTL_Finish_ULA( void (*callbackRoutine) (void *callbackContext),
Nirav Shah4f765af2015-01-21 19:51:30 +05301117 void *callbackContext,
1118 v_PVOID_t pvosGCtx,
1119 v_U8_t ucSTAId)
Jeff Johnson295189b2012-06-20 16:38:30 -07001120{
Nirav Shah4f765af2015-01-21 19:51:30 +05301121 WLANTL_CbType* pTLCb = NULL;
1122 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07001123
Nirav Shah4f765af2015-01-21 19:51:30 +05301124 /*------------------------------------------------------------------------
1125 Sanity check
1126 ------------------------------------------------------------------------*/
1127 if ( WLANTL_STA_ID_INVALID( ucSTAId ) )
1128 {
1129 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1130 "WLAN TL:Invalid station id requested on WLANTL_Finish_ULA"));
1131 return VOS_STATUS_E_FAULT;
1132 }
1133
1134 /*------------------------------------------------------------------------
1135 Extract TL control block and check existance
1136 ------------------------------------------------------------------------*/
1137 pTLCb = VOS_GET_TL_CB(pvosGCtx);
1138 if ( NULL == pTLCb )
1139 {
1140 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1141 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_Finish_ULA"));
1142 return VOS_STATUS_E_FAULT;
1143 }
1144
1145 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
1146 if ( NULL == pClientSTA )
1147 {
1148 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1149 "WLAN TL:Client Memory was not allocated on %s", __func__));
1150 return VOS_STATUS_E_FAILURE;
1151 }
1152
Nirav Shahf6bd2672015-03-11 12:53:15 +05301153 if (!VOS_IS_STATUS_SUCCESS(vos_lock_acquire(&(pClientSTA->ulaLock))))
1154 {
1155 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1156 "%s Get ULA Lock Fail", __func__));
1157 return VOS_STATUS_E_FAILURE;
1158 }
1159
Nirav Shah4f765af2015-01-21 19:51:30 +05301160 if (pClientSTA->isEapolM4Transmitted ||
1161 pClientSTA->tlState == WLANTL_STA_AUTHENTICATED)
1162 {
1163 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
1164 "WLAN TL: M4 is already received on %s", __func__));
Nirav Shahf6bd2672015-03-11 12:53:15 +05301165 if (!VOS_IS_STATUS_SUCCESS(vos_lock_release(&(pClientSTA->ulaLock))))
1166 {
1167 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1168 "%s Release ULA Lock Fail", __func__));
1169 return VOS_STATUS_E_FAILURE;
1170 }
Nirav Shah4f765af2015-01-21 19:51:30 +05301171 return VOS_STATUS_E_ALREADY;
1172 }
1173
1174 pClientSTA->pfnSTAUlaComplete = (WLANTL_STAUlaCompleteCBType) callbackRoutine;
1175 pClientSTA->pUlaCBCtx = callbackContext;
1176
Nirav Shahf6bd2672015-03-11 12:53:15 +05301177 if (!VOS_IS_STATUS_SUCCESS(vos_lock_release(&(pClientSTA->ulaLock))))
1178 {
1179 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1180 "%s Release ULA Lock Fail", __func__));
1181 return VOS_STATUS_E_FAILURE;
1182 }
1183
Nirav Shah4f765af2015-01-21 19:51:30 +05301184 return VOS_STATUS_SUCCESS;
1185}
Jeff Johnson295189b2012-06-20 16:38:30 -07001186
1187/*===========================================================================
1188
1189 FUNCTION WLANTL_RegisterSTAClient
1190
1191 DESCRIPTION
1192
1193 This function is used by HDD to register as a client for data services
1194 with TL. HDD will call this API for each new station that it adds,
1195 thus having the flexibility of registering different callback for each
1196 STA it services.
1197
1198 DEPENDENCIES
1199
1200 TL must have been initialized before this gets called.
1201
1202 Restriction:
1203 Main thread will have higher priority that Tx and Rx threads thus
1204 guaranteeing that a station will be added before any data can be
1205 received for it. (This enables TL to be lock free)
1206
1207 PARAMETERS
1208
1209 pvosGCtx: pointer to the global vos context; a handle to TL's
1210 control block can be extracted from its context
1211 pfnStARx: function pointer to the receive packet handler from HDD
1212 pfnSTATxComp: function pointer to the transmit complete confirmation
1213 handler from HDD
1214 pfnSTAFetchPkt: function pointer to the packet retrieval routine in HDD
1215 wSTADescType: STA Descriptor, contains information related to the
1216 new added STA
1217
1218 RETURN VALUE
1219
1220 The result code associated with performing the operation
1221
1222 VOS_STATUS_E_INVAL: Input parameters are invalid
1223 VOS_STATUS_E_FAULT: Station ID is outside array boundaries or pointer to
1224 TL cb is NULL ; access would cause a page fault
1225 VOS_STATUS_E_EXISTS: Station was already registered
1226 VOS_STATUS_SUCCESS: Everything is good :)
1227
1228 SIDE EFFECTS
1229
1230============================================================================*/
1231VOS_STATUS
1232WLANTL_RegisterSTAClient
1233(
1234 v_PVOID_t pvosGCtx,
1235 WLANTL_STARxCBType pfnSTARx,
1236 WLANTL_TxCompCBType pfnSTATxComp,
1237 WLANTL_STAFetchPktCBType pfnSTAFetchPkt,
1238 WLAN_STADescType* pwSTADescType,
1239 v_S7_t rssi
1240)
1241{
1242 WLANTL_CbType* pTLCb = NULL;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301243 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07001244 v_U8_t ucTid = 0;/*Local variable to clear previous replay counters of STA on all TIDs*/
Jeff Johnson295189b2012-06-20 16:38:30 -07001245 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
1246
1247 /*------------------------------------------------------------------------
1248 Sanity check
1249 ------------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301250 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -07001251 if (( NULL == pwSTADescType ) || ( NULL == pfnSTARx ) ||
1252 ( NULL == pfnSTAFetchPkt ))
1253 {
1254 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1255 "WLAN TL:Invalid parameter sent on WLANTL_RegisterSTAClient"));
1256 return VOS_STATUS_E_INVAL;
1257 }
1258
1259 if ( WLANTL_STA_ID_INVALID( pwSTADescType->ucSTAId ) )
1260 {
1261 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1262 "WLAN TL:Invalid station id requested on WLANTL_RegisterSTAClient"));
1263 return VOS_STATUS_E_FAULT;
1264 }
1265
1266 /*------------------------------------------------------------------------
1267 Extract TL control block
1268 ------------------------------------------------------------------------*/
1269 pTLCb = VOS_GET_TL_CB(pvosGCtx);
1270 if ( NULL == pTLCb )
1271 {
1272 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1273 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_RegisterSTAClient"));
1274 return VOS_STATUS_E_FAULT;
1275 }
1276
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301277 //Code for checking and allocating memory for new STA
1278 if ( NULL == pTLCb->atlSTAClients[pwSTADescType->ucSTAId] ){
1279 pTLCb->atlSTAClients[pwSTADescType->ucSTAId] = vos_mem_malloc(sizeof(WLANTL_STAClientType));
1280 if ( NULL == pTLCb->atlSTAClients[pwSTADescType->ucSTAId] ){
1281 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1282 "WLAN TL: STA Client memory allocation failed in WLANTL_RegisterSTAClient"));
1283 return VOS_STATUS_E_FAILURE;
1284 }
1285 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
1286 "WLAN TL: STA Client memory allocation in WLANTL_RegisterSTAClient"));
1287 vos_mem_zero((v_VOID_t *) pTLCb->atlSTAClients[pwSTADescType->ucSTAId],sizeof(WLANTL_STAClientType));
1288 }
1289
1290 //Assigning the pointer to local variable for easy access in future
1291 pClientSTA = pTLCb->atlSTAClients[pwSTADescType->ucSTAId];
1292 if ( 0 != pClientSTA->ucExists )
Jeff Johnson295189b2012-06-20 16:38:30 -07001293 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301294 pClientSTA->ucExists++;
Jeff Johnson295189b2012-06-20 16:38:30 -07001295 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1296 "WLAN TL:Station was already registered on WLANTL_RegisterSTAClient"));
1297 return VOS_STATUS_E_EXISTS;
1298 }
1299
1300 /*------------------------------------------------------------------------
1301 Register station with TL
1302 ------------------------------------------------------------------------*/
Katya Nigam42e16e82014-02-04 16:28:55 +05301303 MTRACE(vos_trace(VOS_MODULE_ID_TL, TRACE_CODE_TL_REGISTER_STA_CLIENT,
1304 pwSTADescType->ucSTAId, (unsigned )
1305 (*(pwSTADescType->vSTAMACAddress.bytes+2)<<24 |
1306 *(pwSTADescType->vSTAMACAddress.bytes+3)<<16 |
1307 *(pwSTADescType->vSTAMACAddress.bytes+4)<<8 |
1308 *(pwSTADescType->vSTAMACAddress.bytes+5))));
1309
Jeff Johnson295189b2012-06-20 16:38:30 -07001310 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
1311 "WLAN TL:Registering STA Client ID: %d", pwSTADescType->ucSTAId ));
1312
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301313 pClientSTA->pfnSTARx = pfnSTARx;
1314 pClientSTA->pfnSTAFetchPkt = pfnSTAFetchPkt;
Jeff Johnson295189b2012-06-20 16:38:30 -07001315
Nirav Shah4f765af2015-01-21 19:51:30 +05301316 pClientSTA->pfnSTAUlaComplete = NULL;
1317 pClientSTA->pUlaCBCtx = NULL;
1318
Jeff Johnson295189b2012-06-20 16:38:30 -07001319 /* Only register if different from NULL - TL default Tx Comp Cb will
1320 release the vos packet */
1321 if ( NULL != pfnSTATxComp )
1322 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301323 pClientSTA->pfnSTATxComp = pfnSTATxComp;
Jeff Johnson295189b2012-06-20 16:38:30 -07001324 }
1325
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301326 pClientSTA->tlState = WLANTL_STA_INIT;
1327 pClientSTA->tlPri = WLANTL_STA_PRI_NORMAL;
1328 pClientSTA->wSTADesc.ucSTAId = pwSTADescType->ucSTAId;
Gopichand Nakkala8b54e912013-03-11 10:44:21 +05301329 pClientSTA->ptkInstalled = 0;
Nirav Shah4f765af2015-01-21 19:51:30 +05301330 pClientSTA->isEapolM4Transmitted = 0;
Nirav Shahf6bd2672015-03-11 12:53:15 +05301331 vos_lock_init(&pClientSTA->ulaLock);
Jeff Johnson295189b2012-06-20 16:38:30 -07001332
1333 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
1334 "WLAN TL:Registering STA Client ID: %d with UC %d and BC %d",
1335 pwSTADescType->ucSTAId,
1336 pwSTADescType->ucUcastSig, pwSTADescType->ucBcastSig));
1337
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301338 pClientSTA->wSTADesc.wSTAType = pwSTADescType->wSTAType;
Jeff Johnson295189b2012-06-20 16:38:30 -07001339
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301340 pClientSTA->wSTADesc.ucQosEnabled = pwSTADescType->ucQosEnabled;
Jeff Johnson295189b2012-06-20 16:38:30 -07001341
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301342 pClientSTA->wSTADesc.ucAddRmvLLC = pwSTADescType->ucAddRmvLLC;
Jeff Johnson295189b2012-06-20 16:38:30 -07001343
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301344 pClientSTA->wSTADesc.ucProtectedFrame = pwSTADescType->ucProtectedFrame;
Jeff Johnson295189b2012-06-20 16:38:30 -07001345
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001346#ifdef FEATURE_WLAN_ESE
1347 pClientSTA->wSTADesc.ucIsEseSta = pwSTADescType->ucIsEseSta;
Jeff Johnson295189b2012-06-20 16:38:30 -07001348
1349 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001350 "WLAN TL:Registering STA Client ID: %d QoS %d Add LLC %d ProtFrame %d EseSta %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07001351 pwSTADescType->ucSTAId,
1352 pwSTADescType->ucQosEnabled,
1353 pwSTADescType->ucAddRmvLLC,
1354 pwSTADescType->ucProtectedFrame,
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001355 pwSTADescType->ucIsEseSta));
Jeff Johnson295189b2012-06-20 16:38:30 -07001356#else
1357
1358 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
1359 "WLAN TL:Registering STA Client ID: %d QoS %d Add LLC %d ProtFrame %d",
1360 pwSTADescType->ucSTAId,
1361 pwSTADescType->ucQosEnabled,
1362 pwSTADescType->ucAddRmvLLC,
1363 pwSTADescType->ucProtectedFrame));
1364
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001365#endif //FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07001366#ifdef WLAN_SOFTAP_VSTA_FEATURE
1367 // if this station was not allocated resources to perform HW-based
1368 // TX frame translation then force SW-based TX frame translation
1369 // otherwise use the frame translation supplied by the client
1370
1371 if (!WDA_IsHwFrameTxTranslationCapable(pvosGCtx, pwSTADescType->ucSTAId)
1372 || ( WLAN_STA_BT_AMP == pwSTADescType->wSTAType))
1373 {
1374 pwSTADescType->ucSwFrameTXXlation = 1;
1375 }
1376#endif
1377
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301378 pClientSTA->wSTADesc.ucSwFrameTXXlation = pwSTADescType->ucSwFrameTXXlation;
1379 pClientSTA->wSTADesc.ucSwFrameRXXlation = pwSTADescType->ucSwFrameRXXlation;
Jeff Johnson295189b2012-06-20 16:38:30 -07001380
1381#ifdef FEATURE_WLAN_WAPI
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301382 pClientSTA->wSTADesc.ucIsWapiSta = pwSTADescType->ucIsWapiSta;
Jeff Johnson295189b2012-06-20 16:38:30 -07001383#endif /* FEATURE_WLAN_WAPI */
1384
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301385 vos_copy_macaddr( &pClientSTA->wSTADesc.vSTAMACAddress, &pwSTADescType->vSTAMACAddress);
Jeff Johnson295189b2012-06-20 16:38:30 -07001386
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301387 vos_copy_macaddr( &pClientSTA->wSTADesc.vBSSIDforIBSS, &pwSTADescType->vBSSIDforIBSS);
Jeff Johnson295189b2012-06-20 16:38:30 -07001388
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301389 vos_copy_macaddr( &pClientSTA->wSTADesc.vSelfMACAddress, &pwSTADescType->vSelfMACAddress);
Jeff Johnson295189b2012-06-20 16:38:30 -07001390
Jeff Johnson295189b2012-06-20 16:38:30 -07001391 /* In volans release L replay check is done at TL */
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301392 pClientSTA->ucIsReplayCheckValid = pwSTADescType->ucIsReplayCheckValid;
1393 pClientSTA->ulTotalReplayPacketsDetected = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001394/*Clear replay counters of the STA on all TIDs*/
1395 for(ucTid = 0; ucTid < WLANTL_MAX_TID ; ucTid++)
1396 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301397 pClientSTA->ullReplayCounter[ucTid] = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001398 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001399
1400 /*--------------------------------------------------------------------
1401 Set the AC for the registered station to the highest priority AC
1402 Even if this AC is not supported by the station, correction will be
1403 made in the main TL loop after the supported mask is properly
1404 updated in the pending packets call
1405 --------------------------------------------------------------------*/
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05301406 pClientSTA->ucCurrentAC = WLANTL_AC_HIGH_PRIO;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301407 pClientSTA->ucCurrentWeight = 0;
1408 pClientSTA->ucServicedAC = WLANTL_AC_BK;
1409 pClientSTA->ucEapolPktPending = 0;
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -07001410
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301411 vos_mem_zero( pClientSTA->aucACMask, sizeof(pClientSTA->aucACMask));
Jeff Johnson295189b2012-06-20 16:38:30 -07001412
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301413 vos_mem_zero( &pClientSTA->wUAPSDInfo, sizeof(pClientSTA->wUAPSDInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -07001414
1415 /*--------------------------------------------------------------------
1416 Reordering info and AMSDU de-aggregation
1417 --------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301418 vos_mem_zero( pClientSTA->atlBAReorderInfo,
1419 sizeof(pClientSTA->atlBAReorderInfo[0])*
Jeff Johnson295189b2012-06-20 16:38:30 -07001420 WLAN_MAX_TID);
1421
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301422 vos_mem_zero( pClientSTA->aucMPDUHeader,
Jeff Johnson295189b2012-06-20 16:38:30 -07001423 WLANTL_MPDU_HEADER_LEN);
1424
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301425 pClientSTA->ucMPDUHeaderLen = 0;
1426 pClientSTA->vosAMSDUChain = NULL;
1427 pClientSTA->vosAMSDUChainRoot = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07001428
1429
Leo Chang6b6faaf2014-01-24 21:21:26 -08001430 /* Reorder LOCK
1431 * During handle normal RX frame within RX thread,
1432 * if MC thread try to preempt, ADDBA, DELBA, TIMER
1433 * Context should be protected from race */
1434 for (ucTid = 0; ucTid < WLAN_MAX_TID ; ucTid++)
1435 {
1436 if (!VOS_IS_STATUS_SUCCESS(
1437 vos_lock_init(&pClientSTA->atlBAReorderInfo[ucTid].reorderLock)))
1438 {
1439 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1440 "Lock Init Fail"));
1441 return VOS_STATUS_E_FAILURE;
1442 }
1443 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001444 /*--------------------------------------------------------------------
1445 Stats info
1446 --------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301447 vos_mem_zero( pClientSTA->auRxCount,
1448 sizeof(pClientSTA->auRxCount[0])*
Jeff Johnson295189b2012-06-20 16:38:30 -07001449 WLAN_MAX_TID);
1450
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301451 vos_mem_zero( pClientSTA->auTxCount,
1452 sizeof(pClientSTA->auRxCount[0])*
Jeff Johnson295189b2012-06-20 16:38:30 -07001453 WLAN_MAX_TID);
1454 /* Initial RSSI is always reported as zero because TL doesnt have enough
1455 data to calculate RSSI. So to avoid reporting zero, we are initializing
1456 RSSI with RSSI saved in BssDescription during scanning. */
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301457 pClientSTA->rssiAvg = rssi;
Shailender Karmuchi13c0d082013-03-26 14:41:39 -07001458#ifdef FEATURE_WLAN_TDLS
1459 if(WLAN_STA_TDLS == pClientSTA->wSTADesc.wSTAType)
1460 {
1461 /* If client is TDLS, use TDLS specific alpha */
1462 pClientSTA->rssiAlpha = WLANTL_HO_TDLS_ALPHA;
1463 }
1464 else
1465 {
1466 pClientSTA->rssiAlpha = WLANTL_HO_DEFAULT_ALPHA;
1467 }
1468#else
1469 pClientSTA->rssiAlpha = WLANTL_HO_DEFAULT_ALPHA;
1470#endif /* FEATURE_WLAN_TDLS */
Dino Mycle3b9536d2014-07-09 22:05:24 +05301471#ifdef WLAN_FEATURE_LINK_LAYER_STATS
1472 pClientSTA->rssiDataAlpha = WLANTL_HO_DEFAULT_ALPHA;
1473 pClientSTA->interfaceStats.accessCategoryStats[0].ac = WLANTL_AC_BK;
1474 pClientSTA->interfaceStats.accessCategoryStats[1].ac = WLANTL_AC_BE;
1475 pClientSTA->interfaceStats.accessCategoryStats[2].ac = WLANTL_AC_VI;
1476 pClientSTA->interfaceStats.accessCategoryStats[3].ac = WLANTL_AC_VO;
1477#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001478
1479 /*Tx not suspended and station fully registered*/
1480 vos_atomic_set_U8(
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301481 &pClientSTA->ucTxSuspended, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07001482
1483 /* Used until multiple station support will be added*/
1484 pTLCb->ucRegisteredStaId = pwSTADescType->ucSTAId;
1485
1486 /* Save the BAP station ID for future usage */
1487 if ( WLAN_STA_BT_AMP == pwSTADescType->wSTAType )
1488 {
1489 pTLCb->tlBAPClient.ucBAPSTAId = pwSTADescType->ucSTAId;
1490 }
1491
1492 /*------------------------------------------------------------------------
1493 Statistics info
1494 -----------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301495 memset(&pClientSTA->trafficStatistics,
Jeff Johnson295189b2012-06-20 16:38:30 -07001496 0, sizeof(WLANTL_TRANSFER_STA_TYPE));
1497
1498
1499 /*------------------------------------------------------------------------
1500 Start with the state suggested by client caller
1501 -----------------------------------------------------------------------*/
Madan Mohan Koyylamudi64258222013-01-30 14:35:10 +05301502 pClientSTA->tlState = pwSTADescType->ucInitState;
Jeff Johnson295189b2012-06-20 16:38:30 -07001503 /*-----------------------------------------------------------------------
1504 After all the init is complete we can mark the existance flag
1505 ----------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301506 pClientSTA->ucExists++;
Jeff Johnson295189b2012-06-20 16:38:30 -07001507
Jeff Johnson295189b2012-06-20 16:38:30 -07001508 //flow control fields init
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301509 pClientSTA->ucLwmModeEnabled = FALSE;
1510 pClientSTA->ucLwmEventReported = FALSE;
1511 pClientSTA->bmuMemConsumed = 0;
1512 pClientSTA->uIngress_length = 0;
1513 pClientSTA->uBuffThresholdMax = WLANTL_STA_BMU_THRESHOLD_MAX;
Jeff Johnson295189b2012-06-20 16:38:30 -07001514
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301515 pClientSTA->uLwmThreshold = WLANTL_STA_BMU_THRESHOLD_MAX / 3;
Jeff Johnson295189b2012-06-20 16:38:30 -07001516
1517 //@@@ HDDSOFTAP does not queue unregistered packet for now
1518 if ( WLAN_STA_SOFTAP != pwSTADescType->wSTAType )
1519 {
Jeff Johnson295189b2012-06-20 16:38:30 -07001520 /*------------------------------------------------------------------------
1521 Forward received frames while STA was not yet registered
1522 - ----------------------------------------------------------------------*/
1523 if(!VOS_IS_STATUS_SUCCESS(WLANTL_StartForwarding( pwSTADescType->ucSTAId,
1524 pwSTADescType->ucUcastSig,
1525 pwSTADescType->ucBcastSig)))
1526 {
1527 VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001528 " %s fails to start forwarding", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001529 }
Sunil Ravid5406f22013-01-22 00:18:31 -08001530#ifdef FEATURE_WLAN_TDLS
1531 if( WLAN_STA_TDLS == pwSTADescType->wSTAType )
1532 pTLCb->ucTdlsPeerCount++;
1533#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001534 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001535 return VOS_STATUS_SUCCESS;
1536}/* WLANTL_RegisterSTAClient */
1537
1538/*===========================================================================
1539
1540 FUNCTION WLANTL_ClearSTAClient
1541
1542 DESCRIPTION
1543
1544 HDD will call this API when it no longer needs data services for the
1545 particular station.
1546
1547 DEPENDENCIES
1548
1549 A station must have been registered before the clear registration is
1550 called.
1551
1552 PARAMETERS
1553
1554 pvosGCtx: pointer to the global vos context; a handle to TL's
1555 control block can be extracted from its context
1556 ucSTAId: identifier for the STA to be cleared
1557
1558 RETURN VALUE
1559
1560 The result code associated with performing the operation
1561
1562 VOS_STATUS_E_FAULT: Station ID is outside array boundaries or pointer to
1563 TL cb is NULL ; access would cause a page fault
1564 VOS_STATUS_E_EXISTS: Station was not registered
1565 VOS_STATUS_SUCCESS: Everything is good :)
1566
1567 SIDE EFFECTS
1568
1569============================================================================*/
1570VOS_STATUS
1571WLANTL_ClearSTAClient
1572(
1573 v_PVOID_t pvosGCtx,
1574 v_U8_t ucSTAId
1575)
1576{
1577 WLANTL_CbType* pTLCb = NULL;
1578 v_U8_t ucIndex;
1579 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
1580
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301581 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -07001582 /*------------------------------------------------------------------------
1583 Sanity check
1584 ------------------------------------------------------------------------*/
1585 if ( WLANTL_STA_ID_INVALID( ucSTAId ) )
1586 {
1587 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1588 "WLAN TL:Invalid station id requested on WLANTL_ClearSTAClient"));
1589 return VOS_STATUS_E_FAULT;
1590 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001591 /*------------------------------------------------------------------------
1592 Extract TL control block
1593 ------------------------------------------------------------------------*/
1594 pTLCb = VOS_GET_TL_CB(pvosGCtx);
1595 if ( NULL == pTLCb )
1596 {
1597 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1598 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_ClearSTAClient"));
1599 return VOS_STATUS_E_FAULT;
1600 }
1601
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301602 if ( NULL == pTLCb->atlSTAClients[ucSTAId] )
1603 {
1604 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1605 "WLAN TL:Client Memory was not allocated on %s", __func__));
1606 return VOS_STATUS_E_FAILURE;
1607 }
1608
1609 if ( 0 == pTLCb->atlSTAClients[ucSTAId]->ucExists )
Jeff Johnson295189b2012-06-20 16:38:30 -07001610 {
1611 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1612 "WLAN TL:Station was not previously registered on WLANTL_ClearSTAClient"));
Siddharth Bhalaef8ee12014-04-02 00:09:45 +05301613 /* Clean packets cached for the STA */
1614 WLANTL_StartForwarding(ucSTAId,0,0);
Jeff Johnson295189b2012-06-20 16:38:30 -07001615 return VOS_STATUS_E_EXISTS;
1616 }
1617
1618 /* Delete BA sessions on all TID's */
Leo Chang6b6faaf2014-01-24 21:21:26 -08001619 for (ucIndex = 0; ucIndex < WLAN_MAX_TID ; ucIndex++)
Jeff Johnson295189b2012-06-20 16:38:30 -07001620 {
Leo Chang6b6faaf2014-01-24 21:21:26 -08001621 WLANTL_BaSessionDel(pvosGCtx, ucSTAId, ucIndex);
1622 vos_lock_destroy(&pTLCb->atlSTAClients[ucSTAId]->atlBAReorderInfo[ucIndex].reorderLock);
Jeff Johnson295189b2012-06-20 16:38:30 -07001623 }
1624
Nirav Shahf6bd2672015-03-11 12:53:15 +05301625 /* delete ulaLock*/
1626 vos_lock_destroy(&pTLCb->atlSTAClients[ucSTAId]->ulaLock);
Sunil Ravid5406f22013-01-22 00:18:31 -08001627#ifdef FEATURE_WLAN_TDLS
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301628 /* decrement ucTdlsPeerCount only if it is non-zero */
1629 if(WLAN_STA_TDLS == pTLCb->atlSTAClients[ucSTAId]->wSTADesc.wSTAType
Sunil Ravid5406f22013-01-22 00:18:31 -08001630 && pTLCb->ucTdlsPeerCount)
1631 pTLCb->ucTdlsPeerCount--;
1632#endif
1633
Jeff Johnson295189b2012-06-20 16:38:30 -07001634 /*------------------------------------------------------------------------
1635 Clear station
1636 ------------------------------------------------------------------------*/
1637 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
1638 "WLAN TL:Clearing STA Client ID: %d", ucSTAId ));
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301639 WLANTL_CleanSTA(pTLCb->atlSTAClients[ucSTAId], 1 /*empty packets*/);
Jeff Johnson295189b2012-06-20 16:38:30 -07001640
1641 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
1642 "WLAN TL:Clearing STA Reset History RSSI and Region number"));
1643 pTLCb->hoSupport.currentHOState.historyRSSI = 0;
1644 pTLCb->hoSupport.currentHOState.regionNumber = 0;
1645
1646 return VOS_STATUS_SUCCESS;
1647}/* WLANTL_ClearSTAClient */
1648
1649/*===========================================================================
1650
1651 FUNCTION WLANTL_ChangeSTAState
1652
1653 DESCRIPTION
1654
1655 HDD will make this notification whenever a change occurs in the
1656 connectivity state of a particular STA.
1657
1658 DEPENDENCIES
1659
1660 A station must have been registered before the change state can be
1661 called.
1662
1663 RESTRICTION: A station is being notified as authenticated before the
1664 keys are installed in HW. This way if a frame is received
1665 before the keys are installed DPU will drop that frame.
1666
1667 Main thread has higher priority that Tx and Rx threads thus guaranteeing
1668 the following:
1669 - a station will be in assoc state in TL before TL receives any data
1670 for it
1671
1672 PARAMETERS
1673
1674 pvosGCtx: pointer to the global vos context; a handle to TL's
1675 control block can be extracted from its context
1676 ucSTAId: identifier for the STA that is pending transmission
1677 tlSTAState: the new state of the connection to the given station
1678
1679
1680 RETURN VALUE
1681
1682 The result code associated with performing the operation
1683
1684 VOS_STATUS_E_INVAL: Input parameters are invalid
1685 VOS_STATUS_E_FAULT: Station ID is outside array boundaries or pointer to
1686 TL cb is NULL ; access would cause a page fault
1687 VOS_STATUS_E_EXISTS: Station was not registered
1688 VOS_STATUS_SUCCESS: Everything is good :)
1689
1690 SIDE EFFECTS
1691
1692============================================================================*/
1693VOS_STATUS
1694WLANTL_ChangeSTAState
1695(
1696 v_PVOID_t pvosGCtx,
1697 v_U8_t ucSTAId,
1698 WLANTL_STAStateType tlSTAState
1699)
1700{
1701 WLANTL_CbType* pTLCb = NULL;
1702 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
1703
1704 /*------------------------------------------------------------------------
1705 Sanity check
1706 ------------------------------------------------------------------------*/
1707 if ( tlSTAState >= WLANTL_STA_MAX_STATE )
1708 {
1709 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1710 "WLAN TL:Invalid parameter sent on WLANTL_ChangeSTAState"));
1711 return VOS_STATUS_E_INVAL;
1712 }
1713
1714 if ( WLANTL_STA_ID_INVALID( ucSTAId ) )
1715 {
1716 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1717 "WLAN TL:Invalid station id requested on WLANTL_ChangeSTAState"));
1718 return VOS_STATUS_E_FAULT;
1719 }
1720
1721 /*------------------------------------------------------------------------
1722 Extract TL control block and check existance
1723 ------------------------------------------------------------------------*/
1724 pTLCb = VOS_GET_TL_CB(pvosGCtx);
1725 if ( NULL == pTLCb )
1726 {
1727 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1728 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_ChangeSTAState"));
1729 return VOS_STATUS_E_FAULT;
1730 }
1731
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301732 if ( NULL == pTLCb->atlSTAClients[ucSTAId] )
1733 {
1734 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1735 "WLAN TL:Client Memory was not allocated on %s", __func__));
1736 return VOS_STATUS_E_FAILURE;
1737 }
1738
1739 if ( 0 == pTLCb->atlSTAClients[ucSTAId]->ucExists )
Jeff Johnson295189b2012-06-20 16:38:30 -07001740 {
1741 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1742 "WLAN TL:Station was not previously registered on WLANTL_ChangeSTAState"));
1743 return VOS_STATUS_E_EXISTS;
1744 }
1745
1746 /*------------------------------------------------------------------------
1747 Change STA state
1748 No need to lock this operation, see restrictions above
1749 ------------------------------------------------------------------------*/
1750 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
1751 "WLAN TL:Changing state for STA Client ID: %d from %d to %d",
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301752 ucSTAId, pTLCb->atlSTAClients[ucSTAId]->tlState, tlSTAState));
Jeff Johnson295189b2012-06-20 16:38:30 -07001753
Katya Nigam42e16e82014-02-04 16:28:55 +05301754 MTRACE(vos_trace(VOS_MODULE_ID_TL,
1755 TRACE_CODE_TL_STA_STATE, ucSTAId,tlSTAState ));
1756
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301757 pTLCb->atlSTAClients[ucSTAId]->tlState = tlSTAState;
Jeff Johnson295189b2012-06-20 16:38:30 -07001758
1759 return VOS_STATUS_SUCCESS;
1760}/* WLANTL_ChangeSTAState */
1761
1762/*===========================================================================
1763
Agarwal Ashish16020c42014-12-29 22:01:11 +05301764 FUNCTION WLANTL_UpdateTdlsSTAClient
1765
1766 DESCRIPTION
1767
1768 HDD will call this API when ENABLE_LINK happens and HDD want to
1769 register QoS or other params for TDLS peers.
1770
1771 DEPENDENCIES
1772
1773 A station must have been registered before the WMM/QOS registration is
1774 called.
1775
1776 PARAMETERS
1777
1778 pvosGCtx: pointer to the global vos context; a handle to TL's
1779 control block can be extracted from its context
1780 wSTADescType: STA Descriptor, contains information related to the
1781 new added STA
1782
1783 RETURN VALUE
1784
1785 The result code associated with performing the operation
1786
1787 VOS_STATUS_E_FAULT: Station ID is outside array boundaries or pointer to
1788 TL cb is NULL ; access would cause a page fault
1789 VOS_STATUS_E_EXISTS: Station was not registered
1790 VOS_STATUS_SUCCESS: Everything is good :)
1791
1792 SIDE EFFECTS
1793
1794============================================================================*/
1795
1796VOS_STATUS
1797WLANTL_UpdateTdlsSTAClient
1798(
1799 v_PVOID_t pvosGCtx,
1800 WLAN_STADescType* pwSTADescType
1801)
1802{
1803 WLANTL_CbType* pTLCb = NULL;
1804 WLANTL_STAClientType* pClientSTA = NULL;
1805 /*------------------------------------------------------------------------
1806 Extract TL control block
1807 ------------------------------------------------------------------------*/
1808 pTLCb = VOS_GET_TL_CB(pvosGCtx);
1809 if ( NULL == pTLCb || ( WLAN_MAX_STA_COUNT <= pwSTADescType->ucSTAId))
1810 {
1811 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1812 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_UpdateTdlsSTAClient"));
1813 return VOS_STATUS_E_FAULT;
1814 }
1815
1816 pClientSTA = pTLCb->atlSTAClients[pwSTADescType->ucSTAId];
1817 if ((NULL == pClientSTA) || 0 == pClientSTA->ucExists)
1818 {
1819 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1820 "WLAN TL:Station not exists"));
1821 return VOS_STATUS_E_FAILURE;
1822 }
1823
1824 pClientSTA->wSTADesc.ucQosEnabled = pwSTADescType->ucQosEnabled;
1825
1826 return VOS_STATUS_SUCCESS;
1827
1828}
1829
1830
1831/*===========================================================================
1832
Gopichand Nakkala8b54e912013-03-11 10:44:21 +05301833 FUNCTION WLANTL_STAPtkInstalled
1834
1835 DESCRIPTION
1836
1837 HDD will make this notification whenever PTK is installed for the STA
1838
1839 DEPENDENCIES
1840
1841 A station must have been registered before the change state can be
1842 called.
1843
1844 PARAMETERS
1845
1846 pvosGCtx: pointer to the global vos context; a handle to TL's
1847 control block can be extracted from its context
1848 ucSTAId: identifier for the STA for which Pairwise key is
1849 installed
1850
1851 RETURN VALUE
1852
1853 The result code associated with performing the operation
1854
1855 VOS_STATUS_E_FAULT: Station ID is outside array boundaries or pointer to
1856 TL cb is NULL ; access would cause a page fault
1857 VOS_STATUS_E_EXISTS: Station was not registered
1858 VOS_STATUS_SUCCESS: Everything is good :)
1859
1860 SIDE EFFECTS
1861
1862============================================================================*/
1863VOS_STATUS
1864WLANTL_STAPtkInstalled
1865(
1866 v_PVOID_t pvosGCtx,
1867 v_U8_t ucSTAId
1868)
1869{
1870 WLANTL_CbType* pTLCb = NULL;
1871 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
1872
1873 /*------------------------------------------------------------------------
1874 Sanity check
1875 ------------------------------------------------------------------------*/
1876
1877 if ( WLANTL_STA_ID_INVALID( ucSTAId ) )
1878 {
1879 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1880 "WLAN TL:Invalid station id requested on WLANTL_ChangeSTAState"));
1881 return VOS_STATUS_E_FAULT;
1882 }
1883
1884 /*------------------------------------------------------------------------
1885 Extract TL control block and check existance
1886 ------------------------------------------------------------------------*/
1887 pTLCb = VOS_GET_TL_CB(pvosGCtx);
1888 if ( NULL == pTLCb )
1889 {
1890 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1891 FL("WLAN TL:Invalid TL pointer from pvosGCtx")));
1892 return VOS_STATUS_E_FAULT;
1893 }
1894
1895 if ( NULL == pTLCb->atlSTAClients[ucSTAId] )
1896 {
1897 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1898 FL("WLAN TL:Client Memory was not allocated")));
1899 return VOS_STATUS_E_FAILURE;
1900 }
1901
1902 if ( 0 == pTLCb->atlSTAClients[ucSTAId]->ucExists )
1903 {
1904 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1905 FL("WLAN TL:Station was not previously registered")));
1906 return VOS_STATUS_E_EXISTS;
1907 }
1908
1909 pTLCb->atlSTAClients[ucSTAId]->ptkInstalled = 1;
1910
1911 return VOS_STATUS_SUCCESS;
1912}/* WLANTL_STAPtkInstalled */
1913
1914/*===========================================================================
1915
Madan Mohan Koyyalamudifc1d1fe2012-10-18 15:07:12 -07001916 FUNCTION WLANTL_GetSTAState
1917
1918 DESCRIPTION
1919
1920 Returns connectivity state of a particular STA.
1921
1922 DEPENDENCIES
1923
1924 A station must have been registered before its state can be retrieved.
1925
1926
1927 PARAMETERS
1928
1929 IN
1930 pvosGCtx: pointer to the global vos context; a handle to TL's
1931 control block can be extracted from its context
1932 ucSTAId: identifier of the station
1933
1934 OUT
1935 ptlSTAState: the current state of the connection to the given station
1936
1937
1938 RETURN VALUE
1939
1940 The result code associated with performing the operation
1941
1942 VOS_STATUS_E_INVAL: Input parameters are invalid
1943 VOS_STATUS_E_FAULT: Station ID is outside array boundaries or pointer to
1944 TL cb is NULL ; access would cause a page fault
1945 VOS_STATUS_E_EXISTS: Station was not registered
1946 VOS_STATUS_SUCCESS: Everything is good :)
1947
1948 SIDE EFFECTS
1949
1950============================================================================*/
1951VOS_STATUS
1952WLANTL_GetSTAState
1953(
1954 v_PVOID_t pvosGCtx,
1955 v_U8_t ucSTAId,
1956 WLANTL_STAStateType *ptlSTAState
1957)
1958{
1959 WLANTL_CbType* pTLCb = NULL;
1960 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
1961
1962 /*------------------------------------------------------------------------
1963 Sanity check
1964 ------------------------------------------------------------------------*/
1965 if ( NULL == ptlSTAState )
1966 {
1967 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1968 "WLAN TL:Invalid parameter sent on WLANTL_GetSTAState"));
1969 return VOS_STATUS_E_INVAL;
1970 }
1971
1972 if ( WLANTL_STA_ID_INVALID( ucSTAId ) )
1973 {
1974 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1975 "WLAN TL:Invalid station id requested on WLANTL_GetSTAState"));
1976 return VOS_STATUS_E_FAULT;
1977 }
1978
1979 /*------------------------------------------------------------------------
1980 Extract TL control block and check existance
1981 ------------------------------------------------------------------------*/
1982 pTLCb = VOS_GET_TL_CB(pvosGCtx);
1983 if ( NULL == pTLCb )
1984 {
1985 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1986 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_GetSTAState"));
1987 return VOS_STATUS_E_FAULT;
1988 }
1989
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301990 if ( NULL == pTLCb->atlSTAClients[ucSTAId] )
1991 {
1992 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1993 "WLAN TL:Client Memory was not allocated on %s", __func__));
1994 return VOS_STATUS_E_FAILURE;
1995 }
1996
1997 if ( 0 == pTLCb->atlSTAClients[ucSTAId]->ucExists )
Madan Mohan Koyyalamudifc1d1fe2012-10-18 15:07:12 -07001998 {
Sunil Ravid5406f22013-01-22 00:18:31 -08001999 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
Madan Mohan Koyyalamudifc1d1fe2012-10-18 15:07:12 -07002000 "WLAN TL:Station was not previously registered on WLANTL_GetSTAState"));
2001 return VOS_STATUS_E_EXISTS;
2002 }
2003
2004 /*------------------------------------------------------------------------
2005 Get STA state
2006 ------------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302007 *ptlSTAState = pTLCb->atlSTAClients[ucSTAId]->tlState;
Madan Mohan Koyyalamudifc1d1fe2012-10-18 15:07:12 -07002008
2009 return VOS_STATUS_SUCCESS;
2010}/* WLANTL_GetSTAState */
2011
Shailender Karmuchia734f332013-04-19 14:02:48 -07002012/*==========================================================================
2013 FUNCTION WLANTL_UpdateSTABssIdforIBSS
2014
2015 DESCRIPTION
2016 HDD will call this API to update the BSSID for this Station.
2017
2018 DEPENDENCIES
2019 The HDD Should registered the staID with TL before calling this function.
2020
2021 PARAMETERS
2022
2023 IN
2024 pvosGCtx: Pointer to the global vos context; a handle to TL's
2025 or WDA's control block can be extracted from its context
2026 IN
2027 ucSTAId The Station ID for Bssid to be updated
2028 IN
2029 pBssid BSSID to be updated
2030
2031 RETURN VALUE
2032 The result code associated with performing the operation
2033
2034 VOS_STATUS_E_INVAL: Input parameters are invalid
2035 VOS_STATUS_E_FAULT: Station ID is outside array boundaries or pointer to
2036 TL cb is NULL ; access would cause a page fault
2037 VOS_STATUS_E_EXISTS: Station was not registered
2038 VOS_STATUS_SUCCESS: Everything is good :)
2039
2040 SIDE EFFECTS
2041============================================================================*/
2042
2043
2044VOS_STATUS
2045WLANTL_UpdateSTABssIdforIBSS
2046(
2047 v_PVOID_t pvosGCtx,
2048 v_U8_t ucSTAId,
2049 v_U8_t *pBssid
2050)
2051{
2052 WLANTL_CbType* pTLCb = NULL;
2053 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
2054
2055 /*------------------------------------------------------------------------
2056 Sanity check
2057 ------------------------------------------------------------------------*/
2058 if ( WLANTL_STA_ID_INVALID( ucSTAId ) )
2059 {
2060 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2061 "WLAN TL:Invalid station id requested %s", __func__));
2062 return VOS_STATUS_E_FAULT;
2063 }
2064
2065 /*------------------------------------------------------------------------
2066 Extract TL control block and check existance
2067 ------------------------------------------------------------------------*/
2068 pTLCb = VOS_GET_TL_CB(pvosGCtx);
2069 if ( NULL == pTLCb )
2070 {
2071 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2072 "WLAN TL:Invalid TL pointer from pvosGCtx %s", __func__));
2073 return VOS_STATUS_E_FAULT;
2074 }
2075
2076 if ( NULL == pTLCb->atlSTAClients[ucSTAId] )
2077 {
2078 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2079 "WLAN TL:Client Memory was not allocated on %s", __func__));
2080 return VOS_STATUS_E_FAILURE;
2081 }
2082
2083 if ( 0 == pTLCb->atlSTAClients[ucSTAId]->ucExists )
2084 {
2085 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
2086 "WLAN TL:Station was not previously registered %s", __func__));
2087 return VOS_STATUS_E_EXISTS;
2088 }
2089
2090 /*------------------------------------------------------------------------
2091 Update the IBSS BSSID
2092 ------------------------------------------------------------------------*/
2093 vos_mem_copy( &pTLCb->atlSTAClients[ucSTAId]->wSTADesc.vBSSIDforIBSS,
2094 pBssid, sizeof(v_MACADDR_t));
2095
2096 return VOS_STATUS_SUCCESS;
2097}
2098
Madan Mohan Koyyalamudifc1d1fe2012-10-18 15:07:12 -07002099/*===========================================================================
2100
Jeff Johnson295189b2012-06-20 16:38:30 -07002101 FUNCTION WLANTL_STAPktPending
2102
2103 DESCRIPTION
2104
2105 HDD will call this API when a packet is pending transmission in its
2106 queues.
2107
2108 DEPENDENCIES
2109
2110 A station must have been registered before the packet pending
2111 notification can be sent.
2112
2113 RESTRICTION: TL will not count packets for pending notification.
2114 HDD is expected to send the notification only when
2115 non-empty event gets triggered. Worst case scenario
2116 is that TL might end up making a call when Hdds
2117 queues are actually empty.
2118
2119 PARAMETERS
2120
2121 pvosGCtx: pointer to the global vos context; a handle to TL's
2122 control block can be extracted from its context
2123 ucSTAId: identifier for the STA that is pending transmission
2124
2125 RETURN VALUE
2126
2127 The result code associated with performing the operation
2128
2129 VOS_STATUS_E_INVAL: Input parameters are invalid
2130 VOS_STATUS_E_FAULT: Station ID is outside array boundaries or pointer
2131 to TL cb is NULL ; access would cause a page fault
2132 VOS_STATUS_E_EXISTS: Station was not registered
2133 VOS_STATUS_SUCCESS: Everything is good :)
2134
2135 SIDE EFFECTS
2136
2137============================================================================*/
2138VOS_STATUS
2139WLANTL_STAPktPending
2140(
2141 v_PVOID_t pvosGCtx,
2142 v_U8_t ucSTAId,
2143 WLANTL_ACEnumType ucAc
2144)
2145{
2146 WLANTL_CbType* pTLCb = NULL;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302147 WLANTL_STAClientType* pClientSTA = NULL;
Nirav Shah4f765af2015-01-21 19:51:30 +05302148 v_U32_t uMgmtAvailRes = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002149 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
2150
2151 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
2152 "WLAN TL:Packet pending indication for STA: %d AC: %d", ucSTAId, ucAc);
2153
2154 /*------------------------------------------------------------------------
2155 Sanity check
2156 ------------------------------------------------------------------------*/
2157 if ( WLANTL_STA_ID_INVALID( ucSTAId ) )
2158 {
2159 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2160 "WLAN TL:Invalid station id requested on WLANTL_STAPktPending"));
2161 return VOS_STATUS_E_FAULT;
2162 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002163 /*------------------------------------------------------------------------
2164 Extract TL control block and check existance
2165 ------------------------------------------------------------------------*/
2166 pTLCb = VOS_GET_TL_CB(pvosGCtx);
2167 if ( NULL == pTLCb )
2168 {
2169 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2170 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_STAPktPending"));
2171 return VOS_STATUS_E_FAULT;
2172 }
2173
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302174 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
2175
2176 if ( NULL == pClientSTA )
2177 {
2178 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2179 "WLAN TL:Client Memory was not allocated on %s", __func__));
2180 return VOS_STATUS_E_FAILURE;
2181 }
2182
2183 if ( 0 == pClientSTA->ucExists )
Jeff Johnson295189b2012-06-20 16:38:30 -07002184 {
Katya Nigamb130d572014-11-24 16:38:16 +05302185 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07002186 "WLAN TL:Station was not previously registered on WLANTL_STAPktPending"));
2187 return VOS_STATUS_E_EXISTS;
2188 }
2189
2190 /*---------------------------------------------------------------------
2191 Temporary fix to enable TL to fetch packets when multiple peers join
2192 an IBSS. To fix CR177301. Needs to go away when the actual fix of
2193 going through all STA's in round robin fashion gets merged in from
2194 BT AMP branch.
2195 --------------------------------------------------------------------*/
2196 pTLCb->ucRegisteredStaId = ucSTAId;
2197
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302198 if( WLANTL_STA_CONNECTED == pClientSTA->tlState )
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -07002199 { /* EAPOL_HI_PRIORITY : need to find out whether EAPOL is pending before
2200 WLANTL_FetchPacket()/WLANTL_TxConn() is called.
2201 change STA_AUTHENTICATED != tlState to CONNECTED == tlState
2202 to make sure TL is indeed waiting for EAPOL.
2203 Just in the case when STA got disconnected shortly after connectection */
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302204 pClientSTA->ucEapolPktPending = 1;
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -07002205
Katya Nigam42e16e82014-02-04 16:28:55 +05302206 MTRACE(vos_trace(VOS_MODULE_ID_TL,
2207 TRACE_CODE_TL_EAPOL_PKT_PENDING, ucSTAId, ucAc));
2208
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -07002209 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07002210 "WLAN TL:Packet pending indication for STA: %d AC: %d State: %d",
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302211 ucSTAId, ucAc, pClientSTA->tlState);
Nirav Shah4f765af2015-01-21 19:51:30 +05302212
2213 uMgmtAvailRes = WDA_DS_GetAvailableResCount(pvosGCtx,
2214 WDI_MGMT_POOL_ID);
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07002215 }
2216
Jeff Johnson295189b2012-06-20 16:38:30 -07002217 /*-----------------------------------------------------------------------
2218 Enable this AC in the AC mask in order for TL to start servicing it
2219 Set packet pending flag
2220 To avoid race condition, serialize the updation of AC and AC mask
2221 through WLANTL_TX_STAID_AC_IND message.
2222 -----------------------------------------------------------------------*/
Jeff Johnson295189b2012-06-20 16:38:30 -07002223
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302224 pClientSTA->aucACMask[ucAc] = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07002225
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302226 vos_atomic_set_U8( &pClientSTA->ucPktPending, 1);
Jeff Johnson295189b2012-06-20 16:38:30 -07002227
Mihir Shete5d148f12014-12-16 17:54:49 +05302228 MTRACE(vos_trace(VOS_MODULE_ID_TL, TRACE_CODE_TL_STA_PKT_PENDING, ucSTAId,
2229 (pTLCb->ucTxSuspended << 31) |
2230 ((pTLCb->uResCount >= WDA_TLI_MIN_RES_DATA) << 30) |
2231 pClientSTA->tlState));
2232
Jeff Johnson295189b2012-06-20 16:38:30 -07002233 /*------------------------------------------------------------------------
2234 Check if there are enough resources for transmission and tx is not
2235 suspended.
2236 ------------------------------------------------------------------------*/
Nirav Shah4f765af2015-01-21 19:51:30 +05302237 if ((( pTLCb->uResCount >= WDA_TLI_MIN_RES_DATA ) &&
2238 ( 0 == pTLCb->ucTxSuspended )) ||
2239 (pClientSTA->ucEapolPktPending &&
2240 uMgmtAvailRes >= WDA_TLI_MIN_RES_MF))
Jeff Johnson295189b2012-06-20 16:38:30 -07002241 {
Katya Nigam42e16e82014-02-04 16:28:55 +05302242
Jeff Johnson295189b2012-06-20 16:38:30 -07002243 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
2244 "Issuing Xmit start request to BAL"));
2245 WDA_DS_StartXmit(pvosGCtx);
2246 }
2247 else
2248 {
2249 /*---------------------------------------------------------------------
2250 No error code is sent because TL will resume tx autonomously if
2251 resources become available or tx gets resumed
2252 ---------------------------------------------------------------------*/
Madan Mohan Koyyalamudi179e6fe2012-10-15 15:31:08 -07002253 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
Jeff Johnson295189b2012-06-20 16:38:30 -07002254 "WLAN TL:Request to send but condition not met. Res: %d,Suspend: %d",
Madan Mohan Koyyalamudi48139e32012-10-11 14:43:56 -07002255 pTLCb->uResCount, pTLCb->ucTxSuspended );
Jeff Johnson295189b2012-06-20 16:38:30 -07002256 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002257 return VOS_STATUS_SUCCESS;
2258}/* WLANTL_STAPktPending */
2259
2260/*==========================================================================
2261
2262 FUNCTION WLANTL_SetSTAPriority
2263
2264 DESCRIPTION
2265
2266 TL exposes this API to allow upper layers a rough control over the
2267 priority of transmission for a given station when supporting multiple
2268 connections.
2269
2270 DEPENDENCIES
2271
2272 A station must have been registered before the change in priority can be
2273 called.
2274
2275 PARAMETERS
2276
2277 pvosGCtx: pointer to the global vos context; a handle to TL's
2278 control block can be extracted from its context
2279 ucSTAId: identifier for the STA that has to change priority
2280
2281 RETURN VALUE
2282
2283 The result code associated with performing the operation
2284
2285 VOS_STATUS_E_INVAL: Input parameters are invalid
2286 VOS_STATUS_E_FAULT: Station ID is outside array boundaries or pointer
2287 to TL cb is NULL ; access would cause a page fault
2288 VOS_STATUS_E_EXISTS: Station was not registered
2289 VOS_STATUS_SUCCESS: Everything is good :)
2290
2291 SIDE EFFECTS
2292
2293============================================================================*/
2294VOS_STATUS
2295WLANTL_SetSTAPriority
2296(
2297 v_PVOID_t pvosGCtx,
2298 v_U8_t ucSTAId,
2299 WLANTL_STAPriorityType tlSTAPri
2300)
2301{
2302 WLANTL_CbType* pTLCb = NULL;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302303 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002304 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
2305
2306 /*------------------------------------------------------------------------
2307 Sanity check
2308 ------------------------------------------------------------------------*/
2309 if ( WLANTL_STA_ID_INVALID( ucSTAId ) )
2310 {
2311 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2312 "WLAN TL:Invalid station id requested on WLANTL_SetSTAPriority"));
2313 return VOS_STATUS_E_FAULT;
2314 }
2315
2316 /*------------------------------------------------------------------------
2317 Extract TL control block
2318 ------------------------------------------------------------------------*/
2319 pTLCb = VOS_GET_TL_CB(pvosGCtx);
2320 if ( NULL == pTLCb )
2321 {
2322 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2323 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_SetSTAPriority"));
2324 return VOS_STATUS_E_FAULT;
2325 }
2326
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302327 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
2328
2329 if ( NULL == pClientSTA )
2330 {
2331 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2332 "WLAN TL:Client Memory was not allocated on %s", __func__));
2333 return VOS_STATUS_E_FAILURE;
2334 }
2335
2336 if ( 0 == pClientSTA->ucExists )
Jeff Johnson295189b2012-06-20 16:38:30 -07002337 {
2338 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2339 "WLAN TL:Station was not previously registered on WLANTL_SetSTAPriority"));
2340 return VOS_STATUS_E_EXISTS;
2341 }
2342
2343 /*------------------------------------------------------------------------
2344 Re-analize if lock is needed when adding multiple stations
2345 ------------------------------------------------------------------------*/
2346 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
2347 "WLAN TL:Changing state for STA Pri ID: %d from %d to %d",
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302348 ucSTAId, pClientSTA->tlPri, tlSTAPri));
2349 pClientSTA->tlPri = tlSTAPri;
Jeff Johnson295189b2012-06-20 16:38:30 -07002350
2351 return VOS_STATUS_SUCCESS;
2352}/* WLANTL_SetSTAPriority */
2353
2354
2355/*----------------------------------------------------------------------------
2356 INTERACTION WITH BAP
2357 ---------------------------------------------------------------------------*/
2358
2359/*==========================================================================
2360
2361 FUNCTION WLANTL_RegisterBAPClient
2362
2363 DESCRIPTION
2364 Called by SME to register itself as client for non-data BT-AMP packets.
2365
2366 DEPENDENCIES
2367 TL must be initialized before this function can be called.
2368
2369 PARAMETERS
2370
2371 IN
2372 pvosGCtx: pointer to the global vos context; a handle to TL's
2373 or SME's control block can be extracted from its context
2374 pfnTlBAPRxFrm: pointer to the receive processing routine for non-data
2375 BT-AMP packets
2376 pfnFlushOpCompleteCb:
2377 pointer to the call back function, for the Flush operation
2378 completion.
2379
2380
2381 RETURN VALUE
2382
2383 The result code associated with performing the operation
2384
2385 VOS_STATUS_E_INVAL: Input parameters are invalid
2386 VOS_STATUS_E_FAULT: Station ID is outside array boundaries or pointer
2387 to TL cb is NULL ; access would cause a page fault
2388 VOS_STATUS_E_EXISTS: BAL client was already registered
2389 VOS_STATUS_SUCCESS: Everything is good :)
2390
2391 SIDE EFFECTS
2392
2393============================================================================*/
2394VOS_STATUS
2395WLANTL_RegisterBAPClient
2396(
2397 v_PVOID_t pvosGCtx,
2398 WLANTL_BAPRxCBType pfnTlBAPRxFrm,
2399 WLANTL_FlushOpCompCBType pfnFlushOpCompleteCb
2400)
2401{
2402 WLANTL_CbType* pTLCb = NULL;
2403 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
2404
2405 /*------------------------------------------------------------------------
2406 Sanity check
2407 ------------------------------------------------------------------------*/
2408 if ( NULL == pfnTlBAPRxFrm )
2409 {
2410 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2411 "WLAN TL:Invalid parameter sent on WLANTL_RegisterBAPClient"));
2412 return VOS_STATUS_E_INVAL;
2413 }
2414
2415 if ( NULL == pfnFlushOpCompleteCb )
2416 {
2417 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2418 "Invalid Flush Complete Cb parameter sent on WLANTL_RegisterBAPClient"));
2419 return VOS_STATUS_E_INVAL;
2420 }
2421
2422 /*------------------------------------------------------------------------
2423 Extract TL control block
2424 ------------------------------------------------------------------------*/
2425 pTLCb = VOS_GET_TL_CB(pvosGCtx);
2426 if ( NULL == pTLCb )
2427 {
2428 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2429 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_RegisterBAPClient"));
2430 return VOS_STATUS_E_FAULT;
2431 }
2432
2433 /*------------------------------------------------------------------------
2434 Make sure this is the first registration attempt
2435 ------------------------------------------------------------------------*/
2436 if ( 0 != pTLCb->tlBAPClient.ucExists )
2437 {
2438 pTLCb->tlBAPClient.ucExists++;
2439 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2440 "WLAN TL:BAP client was already registered"));
2441 return VOS_STATUS_E_EXISTS;
2442 }
2443
2444 /*------------------------------------------------------------------------
2445 Register station with TL
2446 ------------------------------------------------------------------------*/
2447 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
2448 "WLAN TL:Registering BAP Client" ));
2449
2450 pTLCb->tlBAPClient.ucExists++;
2451
2452 if ( NULL != pfnTlBAPRxFrm )
2453 {
2454 pTLCb->tlBAPClient.pfnTlBAPRx = pfnTlBAPRxFrm;
2455 }
2456
2457 pTLCb->tlBAPClient.pfnFlushOpCompleteCb = pfnFlushOpCompleteCb;
2458
2459 pTLCb->tlBAPClient.vosPendingDataBuff = NULL;
2460
2461 return VOS_STATUS_SUCCESS;
2462}/* WLANTL_RegisterBAPClient */
2463
2464
2465/*==========================================================================
2466
2467 FUNCTION WLANTL_TxBAPFrm
2468
2469 DESCRIPTION
2470 BAP calls this when it wants to send a frame to the module
2471
2472 DEPENDENCIES
2473 BAP must be registered with TL before this function can be called.
2474
2475 RESTRICTION: BAP CANNOT push any packets to TL until it did not receive
2476 a tx complete from the previous packet, that means BAP
2477 sends one packet, wait for tx complete and then
2478 sends another one
2479
2480 If BAP sends another packet before TL manages to process the
2481 previously sent packet call will end in failure
2482
2483 PARAMETERS
2484
2485 IN
2486 pvosGCtx: pointer to the global vos context; a handle to TL's
2487 or BAP's control block can be extracted from its context
2488 vosDataBuff: pointer to the vOSS buffer containing the packet to be
2489 transmitted
2490 pMetaInfo: meta information about the packet
2491 pfnTlBAPTxComp: pointer to a transmit complete routine for notifying
2492 the result of the operation over the bus
2493
2494 RETURN VALUE
2495 The result code associated with performing the operation
2496
2497 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
2498 page fault
2499 VOS_STATUS_E_EXISTS: BAL client was not yet registered
2500 VOS_STATUS_E_BUSY: The previous BT-AMP packet was not yet transmitted
2501 VOS_STATUS_SUCCESS: Everything is good :)
2502
2503 Other failure messages may be returned from the BD header handling
2504 routines, please check apropriate API for more info.
2505
2506 SIDE EFFECTS
2507
2508============================================================================*/
2509VOS_STATUS
2510WLANTL_TxBAPFrm
2511(
2512 v_PVOID_t pvosGCtx,
2513 vos_pkt_t* vosDataBuff,
2514 WLANTL_MetaInfoType* pMetaInfo,
2515 WLANTL_TxCompCBType pfnTlBAPTxComp
2516)
2517{
2518 WLANTL_CbType* pTLCb = NULL;
2519 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
2520 v_MACADDR_t vDestMacAddr;
2521 v_U16_t usPktLen;
2522 v_U8_t ucStaId = 0;
2523 v_U8_t extraHeadSpace = 0;
2524 v_U8_t ucWDSEnabled = 0;
2525 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
2526
2527 /*------------------------------------------------------------------------
2528 Sanity check
2529 Extract TL control block
2530 ------------------------------------------------------------------------*/
2531 pTLCb = VOS_GET_TL_CB(pvosGCtx);
2532 if ( NULL == pTLCb )
2533 {
2534 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2535 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_TxBAPFrm"));
2536 return VOS_STATUS_E_FAULT;
2537 }
2538
2539 /*------------------------------------------------------------------------
2540 Ensure that BAP client was registered previously
2541 ------------------------------------------------------------------------*/
2542 if (( 0 == pTLCb->tlBAPClient.ucExists ) ||
2543 ( WLANTL_STA_ID_INVALID(pTLCb->tlBAPClient.ucBAPSTAId) ))
2544 {
2545 pTLCb->tlBAPClient.ucExists++;
2546 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2547 "WLAN TL:BAP client not register on WLANTL_TxBAPFrm"));
2548 return VOS_STATUS_E_EXISTS;
2549 }
2550
2551 /*------------------------------------------------------------------------
2552 Check if any BT-AMP Frm is pending
2553 ------------------------------------------------------------------------*/
2554 if ( NULL != pTLCb->tlBAPClient.vosPendingDataBuff )
2555 {
2556 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2557 "WLAN TL:BT-AMP Frame already pending tx in TL on WLANTL_TxBAPFrm"));
2558 return VOS_STATUS_E_BUSY;
2559 }
2560
2561 /*------------------------------------------------------------------------
2562 Save buffer and notify BAL; no lock is needed if the above restriction
2563 is met
2564 Save the tx complete fnct pointer as tl specific data in the vos buffer
2565 ------------------------------------------------------------------------*/
2566
2567 /*------------------------------------------------------------------------
2568 Translate 802.3 frame to 802.11
2569 ------------------------------------------------------------------------*/
2570 ucStaId = pTLCb->tlBAPClient.ucBAPSTAId;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302571 if ( NULL == pTLCb->atlSTAClients[ucStaId] )
2572 {
2573 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2574 "WLAN TL:Client Memory was not allocated on %s", __func__));
2575 return VOS_STATUS_E_FAILURE;
2576 }
2577 if (( 0 == pMetaInfo->ucDisableFrmXtl ) &&
2578 ( 0 != pTLCb->atlSTAClients[ucStaId]->wSTADesc.ucSwFrameTXXlation ))
Jeff Johnson295189b2012-06-20 16:38:30 -07002579 {
Kiran Venkatappacab0d352012-12-17 13:09:22 -08002580 vosStatus = WLANTL_Translate8023To80211Header( vosDataBuff, &vosStatus,
2581 pTLCb, &ucStaId,
Ravi Joshid0699502013-07-08 15:48:47 -07002582 pMetaInfo, &ucWDSEnabled,
2583 &extraHeadSpace);
Jeff Johnson295189b2012-06-20 16:38:30 -07002584
2585 if ( VOS_STATUS_SUCCESS != vosStatus )
2586 {
2587 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2588 "WLAN TL:Error when translating header WLANTL_TxBAPFrm"));
2589
2590 return vosStatus;
2591 }
2592
2593 pMetaInfo->ucDisableFrmXtl = 1;
2594 }
2595
2596 /*-------------------------------------------------------------------------
2597 Call HAL to fill BD header
2598 -------------------------------------------------------------------------*/
2599
2600 /* Adding Type, SubType which was missing for EAPOL from BAP */
2601 pMetaInfo->ucType |= (WLANTL_80211_DATA_TYPE << 4);
2602 pMetaInfo->ucType |= (WLANTL_80211_DATA_QOS_SUBTYPE);
2603
2604 vosStatus = WDA_DS_BuildTxPacketInfo( pvosGCtx, vosDataBuff ,
2605 &vDestMacAddr, pMetaInfo->ucDisableFrmXtl,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302606 &usPktLen, pTLCb->atlSTAClients[ucStaId]->wSTADesc.ucQosEnabled,
Jeff Johnson295189b2012-06-20 16:38:30 -07002607 ucWDSEnabled, extraHeadSpace, pMetaInfo->ucType,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302608 &pTLCb->atlSTAClients[ucStaId]->wSTADesc.vSelfMACAddress,
Jeff Johnson295189b2012-06-20 16:38:30 -07002609 pMetaInfo->ucTID, 0 /* No ACK */, pMetaInfo->usTimeStamp,
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -07002610 pMetaInfo->ucIsEapol || pMetaInfo->ucIsWai, pMetaInfo->ucUP );
Jeff Johnson295189b2012-06-20 16:38:30 -07002611
2612 if ( VOS_STATUS_SUCCESS != vosStatus )
2613 {
2614 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2615 "WLAN TL:Failed while building TX header %d", vosStatus));
2616 return vosStatus;
2617 }
2618
2619 if ( NULL != pfnTlBAPTxComp )
2620 {
2621 vos_pkt_set_user_data_ptr( vosDataBuff, VOS_PKT_USER_DATA_ID_TL,
2622 (v_PVOID_t)pfnTlBAPTxComp);
2623 }
2624 else
2625 {
2626 vos_pkt_set_user_data_ptr( vosDataBuff, VOS_PKT_USER_DATA_ID_TL,
2627 (v_PVOID_t)WLANTL_TxCompDefaultCb);
2628
2629 }
2630
Arun Kumar Khandavalli0af8d3c2014-02-07 18:05:11 +05302631 vos_atomic_set( (uintptr_t*)&pTLCb->tlBAPClient.vosPendingDataBuff,
2632 (uintptr_t)vosDataBuff);
Jeff Johnson295189b2012-06-20 16:38:30 -07002633
2634 /*------------------------------------------------------------------------
2635 Check if thre are enough resources for transmission and tx is not
2636 suspended.
2637 ------------------------------------------------------------------------*/
2638 if (( pTLCb->uResCount >= WDA_TLI_MIN_RES_BAP ) &&
2639 ( 0 == pTLCb->ucTxSuspended ))
2640 {
2641 WDA_DS_StartXmit(pvosGCtx);
2642 }
2643 else
2644 {
2645 /*---------------------------------------------------------------------
2646 No error code is sent because TL will resume tx autonomously if
2647 resources become available or tx gets resumed
2648 ---------------------------------------------------------------------*/
2649 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
2650 "WLAN TL:Request to send from BAP but condition not met.Res: %d,"
2651 "Suspend: %d", pTLCb->uResCount, pTLCb->ucTxSuspended ));
2652 }
2653
2654 return VOS_STATUS_SUCCESS;
2655}/* WLANTL_TxBAPFrm */
2656
2657
2658/*----------------------------------------------------------------------------
2659 INTERACTION WITH SME
2660 ---------------------------------------------------------------------------*/
2661
2662/*==========================================================================
2663
2664 FUNCTION WLANTL_GetRssi
2665
2666 DESCRIPTION
2667 TL will extract the RSSI information from every data packet from the
2668 ongoing traffic and will store it. It will provide the result to SME
2669 upon request.
2670
2671 DEPENDENCIES
2672
2673 WARNING: the read and write of this value will not be protected
2674 by locks, therefore the information obtained after a read
2675 might not always be consistent.
2676
2677 PARAMETERS
2678
2679 IN
2680 pvosGCtx: pointer to the global vos context; a handle to TL's
2681 or SME's control block can be extracted from its context
2682 ucSTAId: station identifier for the requested value
2683
2684 OUT
2685 puRssi: the average value of the RSSI
2686
2687
2688 RETURN VALUE
2689 The result code associated with performing the operation
2690
2691 VOS_STATUS_E_INVAL: Input parameters are invalid
2692 VOS_STATUS_E_FAULT: Station ID is outside array boundaries or pointer
2693 to TL cb is NULL ; access would cause a page fault
2694 VOS_STATUS_E_EXISTS: STA was not yet registered
2695 VOS_STATUS_SUCCESS: Everything is good :)
2696
2697 SIDE EFFECTS
2698
2699============================================================================*/
2700VOS_STATUS
2701WLANTL_GetRssi
2702(
2703 v_PVOID_t pvosGCtx,
2704 v_U8_t ucSTAId,
2705 v_S7_t* pRssi
2706)
2707{
2708 WLANTL_CbType* pTLCb = NULL;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302709 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002710 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
2711
2712 /*------------------------------------------------------------------------
2713 Sanity check
2714 ------------------------------------------------------------------------*/
2715 if ( NULL == pRssi )
2716 {
2717 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2718 "WLAN TL:Invalid parameter sent on WLANTL_GetRssi"));
2719 return VOS_STATUS_E_INVAL;
2720 }
2721
2722 if ( WLANTL_STA_ID_INVALID( ucSTAId ) )
2723 {
2724 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2725 "WLAN TL:Invalid station id requested on WLANTL_GetRssi"));
2726 return VOS_STATUS_E_FAULT;
2727 }
2728
2729 /*------------------------------------------------------------------------
2730 Extract TL control block and check existance
2731 ------------------------------------------------------------------------*/
2732 pTLCb = VOS_GET_TL_CB(pvosGCtx);
2733 if ( NULL == pTLCb )
2734 {
2735 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2736 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_GetRssi"));
2737 return VOS_STATUS_E_FAULT;
2738 }
2739
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302740 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
2741
2742 if ( NULL == pClientSTA )
2743 {
2744 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2745 "WLAN TL:Client Memory was not allocated on %s", __func__));
2746 return VOS_STATUS_E_FAILURE;
2747 }
2748
2749 if ( 0 == pClientSTA->ucExists )
Jeff Johnson295189b2012-06-20 16:38:30 -07002750 {
2751 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2752 "WLAN TL:Station was not previously registered on WLANTL_GetRssi"));
2753 return VOS_STATUS_E_EXISTS;
2754 }
2755
2756 /*------------------------------------------------------------------------
2757 Copy will not be locked; please read restriction
2758 ------------------------------------------------------------------------*/
Katya Nigam5c2e5f62013-11-15 19:19:11 +05302759 if(pTLCb->isBMPS || IS_ACTIVEMODE_OFFLOAD_FEATURE_ENABLE)
Jeff Johnson295189b2012-06-20 16:38:30 -07002760 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302761 *pRssi = pClientSTA->rssiAvgBmps;
Jeff Johnson295189b2012-06-20 16:38:30 -07002762 /* Check If RSSI is zero because we are reading rssAvgBmps updated by HAL in
2763 previous GetStatsRequest. It may be updated as zero by Hal because EnterBmps
2764 might not have happend by that time. Hence reading the most recent Rssi
2765 calcluated by TL*/
2766 if(0 == *pRssi)
2767 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302768 *pRssi = pClientSTA->rssiAvg;
Jeff Johnson295189b2012-06-20 16:38:30 -07002769 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002770 }
2771 else
2772 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302773 *pRssi = pClientSTA->rssiAvg;
Jeff Johnson295189b2012-06-20 16:38:30 -07002774 }
2775
2776 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
Jeff Johnson32d95a32012-09-10 13:15:23 -07002777 "WLAN TL:WLANTL_GetRssi for STA: %d RSSI: %d%s",
2778 ucSTAId, *pRssi,
2779 pTLCb->isBMPS ? " in BMPS" : ""));
Jeff Johnson295189b2012-06-20 16:38:30 -07002780
2781 return VOS_STATUS_SUCCESS;
2782}/* WLANTL_GetRssi */
2783
2784/*==========================================================================
2785
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05302786 FUNCTION WLANTL_GetSnr
2787
2788 DESCRIPTION
2789 TL will extract the SNR information from every data packet from the
2790 ongoing traffic and will store it. It will provide the result to SME
2791 upon request.
2792
2793 DEPENDENCIES
2794
2795 WARNING: the read and write of this value will not be protected
2796 by locks, therefore the information obtained after a read
2797 might not always be consistent.
2798
2799 PARAMETERS
2800
2801 IN
2802 pvosGCtx: pointer to the global vos context; a handle to TL's
2803 or SME's control block can be extracted from its context
2804 ucSTAId: station identifier for the requested value
2805
2806 OUT
2807 pSnr: the average value of the SNR
2808
2809
2810 RETURN VALUE
2811 The result code associated with performing the operation
2812
2813 VOS_STATUS_E_INVAL: Input parameters are invalid
2814 VOS_STATUS_E_FAULT: Station ID is outside array boundaries or pointer
2815 to TL cb is NULL ; access would cause a page fault
2816 VOS_STATUS_E_EXISTS: STA was not yet registered
2817 VOS_STATUS_SUCCESS: Everything is good :)
2818
2819 SIDE EFFECTS
2820
2821============================================================================*/
2822VOS_STATUS
2823WLANTL_GetSnr
2824(
2825 tANI_U8 ucSTAId,
2826 tANI_S8* pSnr
2827)
2828{
2829 WLANTL_CbType* pTLCb = NULL;
2830 WLANTL_STAClientType* pClientSTA = NULL;
2831 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
2832
2833 /*------------------------------------------------------------------------
2834 Sanity check
2835 ------------------------------------------------------------------------*/
2836 if (NULL == pSnr)
2837 {
2838 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2839 "WLAN TL:Invalid parameter sent on %s", __func__));
2840 return VOS_STATUS_E_INVAL;
2841 }
2842
2843 if (WLANTL_STA_ID_INVALID(ucSTAId))
2844 {
2845 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2846 "WLAN TL:Invalid station id requested on %s", __func__));
2847 return VOS_STATUS_E_FAULT;
2848 }
2849
2850 /*------------------------------------------------------------------------
2851 Extract TL control block and check existance
2852 ------------------------------------------------------------------------*/
2853 pTLCb = VOS_GET_TL_CB(vos_get_global_context(VOS_MODULE_ID_TL, NULL));
2854 if (NULL == pTLCb)
2855 {
2856 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2857 "WLAN TL:Invalid TL pointer from pvosGCtx on %s", __func__));
2858 return VOS_STATUS_E_FAULT;
2859 }
2860
2861 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
2862
2863 if (NULL == pClientSTA)
2864 {
2865 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2866 "WLAN TL:Client Memory was not allocated on %s", __func__));
2867 return VOS_STATUS_E_FAILURE;
2868 }
2869
2870 if (0 == pClientSTA->ucExists)
2871 {
2872 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2873 "WLAN TL:Station was not previously registered on %s", __func__));
2874 return VOS_STATUS_E_EXISTS;
2875 }
2876
2877 /*------------------------------------------------------------------------
2878 Copy will not be locked; please read restriction
2879 ------------------------------------------------------------------------*/
2880 if (pTLCb->isBMPS)
2881 {
2882 *pSnr = pClientSTA->snrAvgBmps;
2883 }
2884 else
2885 {
2886 /* SNR is averaged over WLANTL_MAX_SNR_DATA_SAMPLES, if there are not enough
2887 * data samples (snridx) to calculate the average then return the
2888 * average for the window of prevoius 20 packets. And if there aren't
2889 * enough samples and the average for previous window of 20 packets is
2890 * not available then return a predefined value
2891 *
2892 * NOTE: the SNR_HACK_BMPS value is defined to 127, documents from HW
2893 * team reveal that the SNR value has a ceiling well below 127 dBm,
2894 * so if SNR has value of 127 the userspace applications can know that
2895 * the SNR has not been computed yet because enough data was not
2896 * available for SNR calculation
2897 */
2898 if (pClientSTA->snrIdx > (WLANTL_MAX_SNR_DATA_SAMPLES/2)
2899 || !(pClientSTA->prevSnrAvg))
2900 {
2901 *pSnr = pClientSTA->snrSum / pClientSTA->snrIdx;
2902 }
2903 else if (pClientSTA->prevSnrAvg)
2904 {
2905 *pSnr = pClientSTA->prevSnrAvg;
2906 }
2907 else
2908 {
2909 *pSnr = SNR_HACK_BMPS;
2910 }
2911 }
2912
2913 VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
2914 "WLAN TL:WLANTL_GetSnr for STA: %d SNR: %d%s",
2915 ucSTAId, *pSnr,
2916 pTLCb->isBMPS ? " in BMPS" : "");
2917
2918 return VOS_STATUS_SUCCESS;
2919}/* WLANTL_GetSnr */
2920/*==========================================================================
2921
Jeff Johnson295189b2012-06-20 16:38:30 -07002922 FUNCTION WLANTL_GetLinkQuality
2923
2924 DESCRIPTION
2925 TL will extract the SNR information from every data packet from the
2926 ongoing traffic and will store it. It will provide the result to SME
2927 upon request.
2928
2929 DEPENDENCIES
2930
2931 WARNING: the read and write of this value will not be protected
2932 by locks, therefore the information obtained after a read
2933 might not always be consistent.
2934
2935 PARAMETERS
2936
2937 IN
2938 pvosGCtx: pointer to the global vos context; a handle to TL's
2939 or SME's control block can be extracted from its context
2940 ucSTAId: station identifier for the requested value
2941
2942 OUT
2943 puLinkQuality: the average value of the SNR
2944
2945
2946 RETURN VALUE
2947 The result code associated with performing the operation
2948
2949 VOS_STATUS_E_INVAL: Input parameters are invalid
2950 VOS_STATUS_E_FAULT: Station ID is outside array boundaries or pointer
2951 to TL cb is NULL ; access would cause a page fault
2952 VOS_STATUS_E_EXISTS: STA was not yet registered
2953 VOS_STATUS_SUCCESS: Everything is good :)
2954
2955 SIDE EFFECTS
2956
2957============================================================================*/
2958VOS_STATUS
2959WLANTL_GetLinkQuality
2960(
2961 v_PVOID_t pvosGCtx,
2962 v_U8_t ucSTAId,
2963 v_U32_t* puLinkQuality
2964)
2965{
2966 WLANTL_CbType* pTLCb = NULL;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302967 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002968
2969 /*------------------------------------------------------------------------
2970 Sanity check
2971 ------------------------------------------------------------------------*/
2972 if ( NULL == puLinkQuality )
2973 {
2974 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2975 "Invalid parameter sent on WLANTL_GetLinkQuality"));
2976 return VOS_STATUS_E_INVAL;
2977 }
2978
2979 if ( WLANTL_STA_ID_INVALID( ucSTAId ) )
2980 {
2981 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2982 "Invalid station id requested on WLANTL_GetLinkQuality"));
2983 return VOS_STATUS_E_FAULT;
2984 }
2985
2986 /*------------------------------------------------------------------------
2987 Extract TL control block and check existance
2988 ------------------------------------------------------------------------*/
2989 pTLCb = VOS_GET_TL_CB(pvosGCtx);
2990 if ( NULL == pTLCb )
2991 {
2992 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2993 "Invalid TL pointer from pvosGCtx on WLANTL_GetLinkQuality"));
2994 return VOS_STATUS_E_FAULT;
2995 }
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302996 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
Jeff Johnson295189b2012-06-20 16:38:30 -07002997
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302998 if ( NULL == pClientSTA )
2999 {
3000 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3001 "WLAN TL:Client Memory was not allocated on %s", __func__));
3002 return VOS_STATUS_E_FAILURE;
3003 }
3004
3005 if ( 0 == pClientSTA->ucExists )
Jeff Johnson295189b2012-06-20 16:38:30 -07003006 {
3007 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3008 "Station was not previously registered on WLANTL_GetLinkQuality"));
3009 return VOS_STATUS_E_EXISTS;
3010 }
3011
3012 /*------------------------------------------------------------------------
3013 Copy will not be locked; please read restriction
3014 ------------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05303015 *puLinkQuality = pClientSTA->uLinkQualityAvg;
Jeff Johnson295189b2012-06-20 16:38:30 -07003016
3017 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
3018 "WLANTL_GetLinkQuality for STA: %d LinkQuality: %d", ucSTAId, *puLinkQuality));
3019
3020 return VOS_STATUS_SUCCESS;
3021}/* WLANTL_GetLinkQuality */
3022
3023/*==========================================================================
3024
3025 FUNCTION WLANTL_FlushStaTID
3026
3027 DESCRIPTION
3028 TL provides this API as an interface to SME (BAP) layer. TL inturn posts a
3029 message to HAL. This API is called by the SME inorder to perform a flush
3030 operation.
3031
3032 DEPENDENCIES
3033
3034 PARAMETERS
3035
3036 IN
3037 pvosGCtx: pointer to the global vos context; a handle to TL's
3038 or SME's control block can be extracted from its context
3039 ucSTAId: station identifier for the requested value
3040 ucTid: Tspec ID for the new BA session
3041
3042 OUT
3043 The response for this post is received in the main thread, via a response
3044 message from HAL to TL.
3045
3046 RETURN VALUE
3047 VOS_STATUS_SUCCESS: Everything is good :)
3048
3049 SIDE EFFECTS
3050============================================================================*/
3051VOS_STATUS
3052WLANTL_FlushStaTID
3053(
3054 v_PVOID_t pvosGCtx,
3055 v_U8_t ucSTAId,
3056 v_U8_t ucTid
3057)
3058{
3059 WLANTL_CbType* pTLCb = NULL;
3060 tpFlushACReq FlushACReqPtr = NULL;
3061 vos_msg_t vosMessage;
3062
3063
3064 if ( WLANTL_STA_ID_INVALID( ucSTAId ) )
3065 {
3066 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3067 "Invalid station id requested on WLANTL_FlushStaTID"));
3068 return VOS_STATUS_E_FAULT;
3069 }
3070
3071 /*------------------------------------------------------------------------
3072 Extract TL control block and check existance
3073 ------------------------------------------------------------------------*/
3074 pTLCb = VOS_GET_TL_CB(pvosGCtx);
3075 if ( NULL == pTLCb )
3076 {
3077 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3078 "Invalid TL pointer from pvosGCtx on WLANTL_FlushStaTID"));
3079 return VOS_STATUS_E_FAULT;
3080 }
3081
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05303082 if ( NULL == pTLCb->atlSTAClients[ucSTAId] )
3083 {
3084 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3085 "WLAN TL:Client Memory was not allocated on %s", __func__));
3086 return VOS_STATUS_E_FAILURE;
3087 }
3088
3089 if ( 0 == pTLCb->atlSTAClients[ucSTAId]->ucExists )
Jeff Johnson295189b2012-06-20 16:38:30 -07003090 {
3091 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3092 "Station was not previously registered on WLANTL_FlushStaTID"));
3093 return VOS_STATUS_E_EXISTS;
3094 }
3095
3096 /*------------------------------------------------------------------------
3097 We need to post a message with the STA, TID value to HAL. HAL performs the flush
3098 ------------------------------------------------------------------------*/
3099 FlushACReqPtr = vos_mem_malloc(sizeof(tFlushACReq));
3100
3101 if ( NULL == FlushACReqPtr )
3102 {
3103 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3104 "WLAN TL: fatal failure, cannot allocate Flush Req structure"));
3105 VOS_ASSERT(0);
3106 return VOS_STATUS_E_NOMEM;
3107 }
3108
3109 // Start constructing the message for HAL
3110 FlushACReqPtr->mesgType = SIR_TL_HAL_FLUSH_AC_REQ;
3111 FlushACReqPtr->mesgLen = sizeof(tFlushACReq);
3112 FlushACReqPtr->mesgLen = sizeof(tFlushACReq);
3113 FlushACReqPtr->ucSTAId = ucSTAId;
3114 FlushACReqPtr->ucTid = ucTid;
3115
3116 vosMessage.type = WDA_TL_FLUSH_AC_REQ;
3117 vosMessage.bodyptr = (void *)FlushACReqPtr;
3118
3119 vos_mq_post_message(VOS_MQ_ID_WDA, &vosMessage);
3120 return VOS_STATUS_SUCCESS;
3121}
3122
3123
3124/*----------------------------------------------------------------------------
3125 INTERACTION WITH PE
3126 ---------------------------------------------------------------------------*/
Siddharth Bhal4551b102014-10-09 21:36:36 +05303127/*==========================================================================
Jeff Johnson295189b2012-06-20 16:38:30 -07003128
Siddharth Bhal4551b102014-10-09 21:36:36 +05303129 FUNCTION WLANTL_updateSpoofMacAddr
3130
3131 DESCRIPTION
3132 Called by HDD to update macaddr
3133
3134 DEPENDENCIES
3135 TL must be initialized before this API can be called.
3136
3137 PARAMETERS
3138
3139 IN
3140 pvosGCtx: pointer to the global vos context; a handle to
3141 TL's control block can be extracted from its context
3142 spoofMacAddr: spoofed mac adderess
3143 selfMacAddr: self Mac Address
3144
3145 RETURN VALUE
3146 The result code associated with performing the operation
3147
3148 VOS_STATUS_E_INVAL: Input parameters are invalid
3149 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
3150 page fault
3151 VOS_STATUS_SUCCESS: Everything is good :)
3152
3153 SIDE EFFECTS
3154
3155============================================================================*/
3156VOS_STATUS
3157WLANTL_updateSpoofMacAddr
3158(
3159 v_PVOID_t pvosGCtx,
3160 v_MACADDR_t* spoofMacAddr,
3161 v_MACADDR_t* selfMacAddr
3162)
3163{
3164 WLANTL_CbType* pTLCb = NULL;
3165 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
3166
3167 /*------------------------------------------------------------------------
3168 Sanity check
3169 ------------------------------------------------------------------------*/
3170 if ( NULL == spoofMacAddr || NULL == selfMacAddr)
3171 {
3172 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3173 "WLAN TL:Invalid parameter sent on WLANTL_updateSpoofMacAddr");
3174 return VOS_STATUS_E_INVAL;
3175 }
3176
3177 /*------------------------------------------------------------------------
3178 Extract TL control block
3179 ------------------------------------------------------------------------*/
3180 pTLCb = VOS_GET_TL_CB(pvosGCtx);
3181 if ( NULL == pTLCb )
3182 {
3183 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3184 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_ChangeSTAState");
3185 return VOS_STATUS_E_FAULT;
3186 }
3187
3188 vos_mem_copy(pTLCb->spoofMacAddr.selfMac.bytes, selfMacAddr,
3189 VOS_MAC_ADDRESS_LEN);
3190 vos_mem_copy(pTLCb->spoofMacAddr.spoofMac.bytes, spoofMacAddr,
3191 VOS_MAC_ADDRESS_LEN);
3192
3193 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_LOW,
3194 "TL: SelfSTA mac Addr for current Scan "MAC_ADDRESS_STR,
3195 MAC_ADDR_ARRAY(pTLCb->spoofMacAddr.selfMac.bytes));
3196
3197 return VOS_STATUS_SUCCESS;
3198}/* WLANTL_updateSpoofMacAddr */
Jeff Johnson295189b2012-06-20 16:38:30 -07003199/*==========================================================================
3200
3201 FUNCTION WLANTL_RegisterMgmtFrmClient
3202
3203 DESCRIPTION
3204 Called by PE to register as a client for management frames delivery.
3205
3206 DEPENDENCIES
3207 TL must be initialized before this API can be called.
3208
3209 PARAMETERS
3210
3211 IN
3212 pvosGCtx: pointer to the global vos context; a handle to
3213 TL's control block can be extracted from its context
3214 pfnTlMgmtFrmRx: pointer to the receive processing routine for
3215 management frames
3216
3217 RETURN VALUE
3218 The result code associated with performing the operation
3219
3220 VOS_STATUS_E_INVAL: Input parameters are invalid
3221 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
3222 page fault
3223 VOS_STATUS_E_EXISTS: Mgmt Frame client was already registered
3224 VOS_STATUS_SUCCESS: Everything is good :)
3225
3226 SIDE EFFECTS
3227
3228============================================================================*/
3229VOS_STATUS
3230WLANTL_RegisterMgmtFrmClient
3231(
3232 v_PVOID_t pvosGCtx,
3233 WLANTL_MgmtFrmRxCBType pfnTlMgmtFrmRx
3234)
3235{
3236 WLANTL_CbType* pTLCb = NULL;
3237 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
3238
3239 /*------------------------------------------------------------------------
3240 Sanity check
3241 ------------------------------------------------------------------------*/
3242 if ( NULL == pfnTlMgmtFrmRx )
3243 {
3244 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3245 "WLAN TL:Invalid parameter sent on WLANTL_RegisterMgmtFrmClient"));
3246 return VOS_STATUS_E_INVAL;
3247 }
3248
3249 /*------------------------------------------------------------------------
3250 Extract TL control block
3251 ------------------------------------------------------------------------*/
3252 pTLCb = VOS_GET_TL_CB(pvosGCtx);
3253 if ( NULL == pTLCb )
3254 {
3255 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3256 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_ChangeSTAState"));
3257 return VOS_STATUS_E_FAULT;
3258 }
3259
3260 /*------------------------------------------------------------------------
3261 Make sure this is the first registration attempt
3262 ------------------------------------------------------------------------*/
3263 if ( 0 != pTLCb->tlMgmtFrmClient.ucExists )
3264 {
3265 pTLCb->tlMgmtFrmClient.ucExists++;
3266 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3267 "WLAN TL:Management frame client was already registered"));
3268 return VOS_STATUS_E_EXISTS;
3269 }
3270
3271 /*------------------------------------------------------------------------
3272 Register station with TL
3273 ------------------------------------------------------------------------*/
3274 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
3275 "WLAN TL:Registering Management Frame Client" ));
3276
3277 pTLCb->tlMgmtFrmClient.ucExists++;
3278
3279 if ( NULL != pfnTlMgmtFrmRx )
3280 {
3281 pTLCb->tlMgmtFrmClient.pfnTlMgmtFrmRx = pfnTlMgmtFrmRx;
3282 }
3283
3284 pTLCb->tlMgmtFrmClient.vosPendingDataBuff = NULL;
3285
3286 return VOS_STATUS_SUCCESS;
3287}/* WLANTL_RegisterMgmtFrmClient */
3288
3289/*==========================================================================
3290
3291 FUNCTION WLANTL_DeRegisterMgmtFrmClient
3292
3293 DESCRIPTION
3294 Called by PE to deregister as a client for management frames delivery.
3295
3296 DEPENDENCIES
3297 TL must be initialized before this API can be called.
3298
3299 PARAMETERS
3300
3301 IN
3302 pvosGCtx: pointer to the global vos context; a handle to
3303 TL's control block can be extracted from its context
3304 RETURN VALUE
3305 The result code associated with performing the operation
3306
3307 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
3308 page fault
3309 VOS_STATUS_E_EXISTS: Mgmt Frame client was never registered
3310 VOS_STATUS_SUCCESS: Everything is good :)
3311
3312 SIDE EFFECTS
3313
3314============================================================================*/
3315VOS_STATUS
3316WLANTL_DeRegisterMgmtFrmClient
3317(
3318 v_PVOID_t pvosGCtx
3319)
3320{
3321 WLANTL_CbType* pTLCb = NULL;
3322 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
3323
3324 /*------------------------------------------------------------------------
3325 Extract TL control block
3326 ------------------------------------------------------------------------*/
3327 pTLCb = VOS_GET_TL_CB(pvosGCtx);
3328 if ( NULL == pTLCb )
3329 {
3330 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3331 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_ChangeSTAState"));
3332 return VOS_STATUS_E_FAULT;
3333 }
3334
3335 /*------------------------------------------------------------------------
3336 Make sure this is the first registration attempt
3337 ------------------------------------------------------------------------*/
3338 if ( 0 == pTLCb->tlMgmtFrmClient.ucExists )
3339 {
3340 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3341 "WLAN TL:Management frame client was never registered"));
3342 return VOS_STATUS_E_EXISTS;
3343 }
3344
3345 /*------------------------------------------------------------------------
3346 Clear registration with TL
3347 ------------------------------------------------------------------------*/
3348 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
3349 "WLAN TL:Deregistering Management Frame Client" ));
3350
3351 pTLCb->tlMgmtFrmClient.pfnTlMgmtFrmRx = WLANTL_MgmtFrmRxDefaultCb;
3352 if ( NULL != pTLCb->tlMgmtFrmClient.vosPendingDataBuff)
3353 {
3354 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
3355 "WLAN TL:Management cache buffer not empty on deregistering"
3356 " - dropping packet" ));
3357 vos_pkt_return_packet(pTLCb->tlMgmtFrmClient.vosPendingDataBuff);
3358
3359 pTLCb->tlMgmtFrmClient.vosPendingDataBuff = NULL;
3360 }
3361
3362 pTLCb->tlMgmtFrmClient.ucExists = 0;
3363
3364 return VOS_STATUS_SUCCESS;
3365}/* WLANTL_RegisterMgmtFrmClient */
3366
3367/*==========================================================================
3368
3369 FUNCTION WLANTL_TxMgmtFrm
3370
3371 DESCRIPTION
3372 Called by PE when it want to send out a management frame.
3373 HAL will also use this API for the few frames it sends out, they are not
3374 management frames howevere it is accepted that an exception will be
3375 allowed ONLY for the usage of HAL.
3376 Generic data frames SHOULD NOT travel through this function.
3377
3378 DEPENDENCIES
3379 TL must be initialized before this API can be called.
3380
3381 RESTRICTION: If PE sends another packet before TL manages to process the
3382 previously sent packet call will end in failure
3383
3384 Frames comming through here must be 802.11 frames, frame
3385 translation in UMA will be automatically disabled.
3386
3387 PARAMETERS
3388
3389 IN
3390 pvosGCtx: pointer to the global vos context;a handle to TL's
3391 control block can be extracted from its context
3392 vosFrmBuf: pointer to a vOSS buffer containing the management
3393 frame to be transmitted
3394 usFrmLen: the length of the frame to be transmitted; information
3395 is already included in the vOSS buffer
3396 wFrmType: the type of the frame being transmitted
3397 tid: tid used to transmit this frame
3398 pfnCompTxFunc: function pointer to the transmit complete routine
3399 pvBDHeader: pointer to the BD header, if NULL it means it was not
3400 yet constructed and it lies within TL's responsibility
3401 to do so; if not NULL it is expected that it was
3402 already packed inside the vos packet
3403 ucAckResponse: flag notifying it an interrupt is needed for the
3404 acknowledgement received when the frame is sent out
3405 the air and ; the interrupt will be processed by HAL,
3406 only one such frame can be pending in the system at
3407 one time.
3408
3409
3410 RETURN VALUE
3411 The result code associated with performing the operation
3412
3413 VOS_STATUS_E_INVAL: Input parameters are invalid
3414 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
3415 page fault
3416 VOS_STATUS_E_EXISTS: Mgmt Frame client was not yet registered
3417 VOS_STATUS_E_BUSY: The previous Mgmt packet was not yet transmitted
3418 VOS_STATUS_SUCCESS: Everything is good :)
3419
3420 Other failure messages may be returned from the BD header handling
3421 routines, please check apropriate API for more info.
3422
3423 SIDE EFFECTS
3424
3425============================================================================*/
3426VOS_STATUS
3427WLANTL_TxMgmtFrm
3428(
3429 v_PVOID_t pvosGCtx,
3430 vos_pkt_t* vosFrmBuf,
3431 v_U16_t usFrmLen,
3432 v_U8_t wFrmType,
3433 v_U8_t ucTid,
3434 WLANTL_TxCompCBType pfnCompTxFunc,
3435 v_PVOID_t pvBDHeader,
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05303436 v_U32_t ucAckResponse
Jeff Johnson295189b2012-06-20 16:38:30 -07003437)
3438{
3439 WLANTL_CbType* pTLCb = NULL;
3440 v_MACADDR_t vDestMacAddr;
3441 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
3442 v_U16_t usPktLen;
3443 v_U32_t usTimeStamp = 0;
3444 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
3445
3446 /*------------------------------------------------------------------------
3447 Sanity check
3448 ------------------------------------------------------------------------*/
3449 if ( NULL == vosFrmBuf )
3450 {
3451 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3452 "WLAN TL:Invalid parameter sent on WLANTL_TxMgmtFrm"));
3453 return VOS_STATUS_E_INVAL;
3454 }
3455
3456 /*------------------------------------------------------------------------
3457 Extract TL control block
3458 ------------------------------------------------------------------------*/
3459 pTLCb = VOS_GET_TL_CB(pvosGCtx);
3460 if ( NULL == pTLCb )
3461 {
3462 TLLOGP(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_FATAL,
3463 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_TxMgmtFrm"));
3464 return VOS_STATUS_E_FAULT;
3465 }
3466
3467 /*------------------------------------------------------------------------
3468 Ensure that management frame client was previously registered
3469 ------------------------------------------------------------------------*/
3470 if ( 0 == pTLCb->tlMgmtFrmClient.ucExists )
3471 {
3472 pTLCb->tlMgmtFrmClient.ucExists++;
3473 TLLOGP(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_FATAL,
3474 "WLAN TL:Management Frame client not register on WLANTL_TxMgmtFrm"));
3475 return VOS_STATUS_E_EXISTS;
3476 }
3477
3478 /*------------------------------------------------------------------------
3479 Check if any Mgmt Frm is pending
3480 ------------------------------------------------------------------------*/
3481 //vosTempBuff = pTLCb->tlMgmtFrmClient.vosPendingDataBuff;
3482 if ( NULL != pTLCb->tlMgmtFrmClient.vosPendingDataBuff )
3483 {
3484
3485 TLLOGP(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_FATAL,
3486 "WLAN TL:Management Frame already pending tx in TL: failing old one"));
3487
3488
3489 /*Failing the tx for the previous packet enqued by PE*/
Arun Kumar Khandavalli0af8d3c2014-02-07 18:05:11 +05303490 //vos_atomic_set( (uintptr_t*)&pTLCb->tlMgmtFrmClient.vosPendingDataBuff,
3491 // (uintptr_t)NULL);
Jeff Johnson295189b2012-06-20 16:38:30 -07003492
3493 //vos_pkt_get_user_data_ptr( vosTempBuff, VOS_PKT_USER_DATA_ID_TL,
3494 // (v_PVOID_t)&pfnTxComp);
3495
3496 /*it should never be NULL - default handler should be registered if none*/
3497 //if ( NULL == pfnTxComp )
3498 //{
3499 // VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3500 // "NULL pointer to Tx Complete on WLANTL_TxMgmtFrm");
3501 // VOS_ASSERT(0);
3502 // return VOS_STATUS_E_FAULT;
3503 //}
3504
3505 //pfnTxComp( pvosGCtx, vosTempBuff, VOS_STATUS_E_RESOURCES );
3506 //return VOS_STATUS_E_BUSY;
3507
3508
3509 //pfnCompTxFunc( pvosGCtx, vosFrmBuf, VOS_STATUS_E_RESOURCES);
3510 return VOS_STATUS_E_RESOURCES;
3511 }
3512
3513
3514 /*------------------------------------------------------------------------
3515 Check if BD header was build, if not construct
3516 ------------------------------------------------------------------------*/
3517 if ( NULL == pvBDHeader )
3518 {
3519 v_MACADDR_t* pvAddr2MacAddr;
3520 v_U8_t uQosHdr = VOS_FALSE;
3521
3522 /* Get address 2 of Mangement Frame to give to WLANHAL_FillTxBd */
3523 vosStatus = vos_pkt_peek_data( vosFrmBuf,
3524 WLANTL_MAC_ADDR_ALIGN(1) + VOS_MAC_ADDR_SIZE,
3525 (v_PVOID_t)&pvAddr2MacAddr, VOS_MAC_ADDR_SIZE);
3526
3527 if ( VOS_STATUS_SUCCESS != vosStatus )
3528 {
3529 TLLOGP(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_FATAL,
3530 "WLAN TL:Failed while attempting to get addr2 %d", vosStatus));
3531 return vosStatus;
3532 }
Gopichand Nakkala0f3eb5c2013-05-07 16:48:38 +05303533
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003534 /* ESE IAPP/TDLS Frame which are data frames but technically used
Jeff Johnson295189b2012-06-20 16:38:30 -07003535 * for management functionality comes through route.
3536 */
3537 if (WLANTL_IS_QOS_DATA_FRAME(wFrmType)) \
3538 {
3539 uQosHdr = VOS_TRUE;
3540 }
Siddharth Bhal4551b102014-10-09 21:36:36 +05303541
3542 if (WLANTL_IS_PROBE_REQ(wFrmType))
3543 {
3544 if (VOS_TRUE == vos_mem_compare((v_VOID_t*) pvAddr2MacAddr,
3545 (v_VOID_t*) &pTLCb->spoofMacAddr.spoofMac, VOS_MAC_ADDRESS_LEN))
3546 {
3547 pvAddr2MacAddr = (v_PVOID_t)pTLCb->spoofMacAddr.selfMac.bytes;
3548 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
3549 "TL: using self sta addr to get staidx for spoofed probe req "
3550 MAC_ADDRESS_STR, MAC_ADDR_ARRAY(pvAddr2MacAddr->bytes));
3551 }
3552 }
3553
Jeff Johnson295189b2012-06-20 16:38:30 -07003554 /*----------------------------------------------------------------------
3555 Call WDA to build TX header
3556 ----------------------------------------------------------------------*/
3557 vosStatus = WDA_DS_BuildTxPacketInfo( pvosGCtx, vosFrmBuf , &vDestMacAddr,
3558 1 /* always 802.11 frames*/, &usPktLen, uQosHdr /*qos not enabled !!!*/,
Siddharth Bhal4551b102014-10-09 21:36:36 +05303559 0 /* WDS off */, 0, wFrmType, pvAddr2MacAddr, ucTid,
Jeff Johnson295189b2012-06-20 16:38:30 -07003560 ucAckResponse, usTimeStamp, 0, 0 );
3561
3562
3563 if ( !VOS_IS_STATUS_SUCCESS(vosStatus) )
3564 {
3565 TLLOGP(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_FATAL,
3566 "WLAN TL:Failed while attempting to build TX header %d", vosStatus));
3567 return vosStatus;
3568 }
3569 }/* if BD header not present */
3570
3571 /*------------------------------------------------------------------------
3572 Save buffer and notify BAL; no lock is needed if the above restriction
3573 is met
3574 Save the tx complete fnct pointer as tl specific data in the vos buffer
3575 ------------------------------------------------------------------------*/
3576 if ( NULL != pfnCompTxFunc )
3577 {
3578 vos_pkt_set_user_data_ptr( vosFrmBuf, VOS_PKT_USER_DATA_ID_TL,
3579 (v_PVOID_t)pfnCompTxFunc);
3580 }
3581 else
3582 {
3583 vos_pkt_set_user_data_ptr( vosFrmBuf, VOS_PKT_USER_DATA_ID_TL,
3584 (v_PVOID_t)WLANTL_TxCompDefaultCb);
3585
3586 }
Arun Kumar Khandavalli0af8d3c2014-02-07 18:05:11 +05303587 vos_atomic_set( (uintptr_t*)&pTLCb->tlMgmtFrmClient.vosPendingDataBuff,
3588 (uintptr_t)vosFrmBuf);
Jeff Johnson295189b2012-06-20 16:38:30 -07003589
3590 /*------------------------------------------------------------------------
3591 Check if thre are enough resources for transmission and tx is not
3592 suspended.
3593 ------------------------------------------------------------------------*/
3594 if ( pTLCb->uResCount >= WDA_TLI_MIN_RES_MF )
3595 {
3596 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
3597 "WLAN TL:Issuing Xmit start request to BAL for MGMT"));
3598 vosStatus = WDA_DS_StartXmit(pvosGCtx);
3599 if(VOS_STATUS_SUCCESS != vosStatus)
3600 {
3601 TLLOGP(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_FATAL,
3602 "WLAN TL:WDA_DS_StartXmit fails. vosStatus %d", vosStatus));
Arun Kumar Khandavalli0af8d3c2014-02-07 18:05:11 +05303603 vos_atomic_set( (uintptr_t*)&pTLCb->tlMgmtFrmClient.vosPendingDataBuff,0);
Jeff Johnson295189b2012-06-20 16:38:30 -07003604 }
3605 return vosStatus;
3606
3607 }
3608 else
3609 {
3610 /*---------------------------------------------------------------------
3611 No error code is sent because TL will resume tx autonomously if
3612 resources become available or tx gets resumed
3613 ---------------------------------------------------------------------*/
3614 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
3615 "WLAN TL:Request to send for Mgmt Frm but condition not met. Res: %d",
3616 pTLCb->uResCount));
3617 }
3618
3619 return VOS_STATUS_SUCCESS;
3620}/* WLANTL_TxMgmtFrm */
3621
3622/*----------------------------------------------------------------------------
3623 INTERACTION WITH HAL
3624 ---------------------------------------------------------------------------*/
3625
3626/*==========================================================================
3627
3628 FUNCTION WLANTL_ResetNotification
3629
3630 DESCRIPTION
3631 HAL notifies TL when the module is being reset.
3632 Currently not used.
3633
3634 DEPENDENCIES
3635
3636 PARAMETERS
3637
3638 IN
3639 pvosGCtx: pointer to the global vos context; a handle to TL's
3640 control block can be extracted from its context
3641
3642
3643 RETURN VALUE
3644 The result code associated with performing the operation
3645
3646 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
3647 page fault
3648 VOS_STATUS_SUCCESS: Everything is good :)
3649
3650 SIDE EFFECTS
3651
3652============================================================================*/
3653VOS_STATUS
3654WLANTL_ResetNotification
3655(
3656 v_PVOID_t pvosGCtx
3657)
3658{
3659 WLANTL_CbType* pTLCb = NULL;
3660 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
3661
3662 /*------------------------------------------------------------------------
3663 Sanity check
3664 Extract TL control block
3665 ------------------------------------------------------------------------*/
3666 pTLCb = VOS_GET_TL_CB(pvosGCtx);
3667 if ( NULL == pTLCb )
3668 {
3669 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3670 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_ResetNotification"));
3671 return VOS_STATUS_E_FAULT;
3672 }
3673
3674 WLANTL_CleanCB(pTLCb, 1 /*empty all queues and pending packets*/);
3675 return VOS_STATUS_SUCCESS;
3676}/* WLANTL_ResetNotification */
3677
3678/*==========================================================================
3679
3680 FUNCTION WLANTL_SuspendDataTx
3681
3682 DESCRIPTION
3683 HAL calls this API when it wishes to suspend transmission for a
3684 particular STA.
3685
3686 DEPENDENCIES
3687 The STA for which the request is made must be first registered with
3688 TL by HDD.
3689
3690 RESTRICTION: In case of a suspend, the flag write and read will not be
3691 locked: worst case scenario one more packet can get
3692 through before the flag gets updated (we can make this
3693 write atomic as well to guarantee consistency)
3694
3695 PARAMETERS
3696
3697 IN
3698 pvosGCtx: pointer to the global vos context; a handle to TL's
3699 control block can be extracted from its context
3700 pucSTAId: identifier of the station for which the request is made;
3701 a value of NULL assumes suspend on all active station
3702 pfnSuspendTxCB: pointer to the suspend result notification in case the
3703 call is asynchronous
3704
3705
3706 RETURN VALUE
3707 The result code associated with performing the operation
3708
3709 VOS_STATUS_E_FAULT: Station ID is outside array boundaries or pointer
3710 to TL cb is NULL ; access would cause a page fault
3711 VOS_STATUS_E_EXISTS: Station was not registered
3712 VOS_STATUS_SUCCESS: Everything is good :)
3713
3714 SIDE EFFECTS
3715
3716============================================================================*/
3717
3718VOS_STATUS
3719WLANTL_SuspendDataTx
3720(
3721 v_PVOID_t pvosGCtx,
3722 v_U8_t* pucSTAId,
3723 WLANTL_SuspendCBType pfnSuspendTx
3724)
3725{
3726 WLANTL_CbType* pTLCb = NULL;
3727 vos_msg_t vosMsg;
Jeff Johnson295189b2012-06-20 16:38:30 -07003728
3729 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
3730
3731 /*------------------------------------------------------------------------
3732 Sanity check
3733 Extract TL control block
3734 ------------------------------------------------------------------------*/
3735 pTLCb = VOS_GET_TL_CB(pvosGCtx);
Hoonki Lee14621352013-04-16 17:51:19 -07003736 if ( NULL == pTLCb )
Jeff Johnson295189b2012-06-20 16:38:30 -07003737 {
3738 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3739 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_SuspendDataTx"));
3740 return VOS_STATUS_E_FAULT;
3741 }
3742
3743 /*------------------------------------------------------------------------
3744 Check the type of request: generic suspend, or per station suspend
3745 ------------------------------------------------------------------------*/
Hoonki Lee14621352013-04-16 17:51:19 -07003746 if (NULL == pucSTAId)
Jeff Johnson295189b2012-06-20 16:38:30 -07003747 {
3748 /* General Suspend Request received */
3749 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
3750 "WLAN TL:General suspend requested"));
Hoonki Lee14621352013-04-16 17:51:19 -07003751 vos_atomic_set_U8( &pTLCb->ucTxSuspended, 1);
Jeff Johnson295189b2012-06-20 16:38:30 -07003752 vosMsg.reserved = WLAN_MAX_STA_COUNT;
3753 }
3754 else
3755 {
Hoonki Lee14621352013-04-16 17:51:19 -07003756 if ( WLANTL_STA_ID_INVALID( *pucSTAId ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07003757 {
Hoonki Lee14621352013-04-16 17:51:19 -07003758 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3759 "WLAN TL:Invalid station id %d requested on WLANTL_SuspendDataTx", *pucSTAId));
3760 return VOS_STATUS_E_FAULT;
3761 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003762
Gopichand Nakkalae5fef6c2013-06-19 18:04:23 +05303763 if ( NULL == pTLCb->atlSTAClients[*pucSTAId] )
3764 {
3765 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3766 "WLAN TL:Invalid pTLCb->atlSTAClients pointer for STA Id :%d on "
3767 "WLANTL_SuspendDataTx", *pucSTAId));
3768 return VOS_STATUS_E_FAULT;
3769 }
3770
3771 if ( 0 == pTLCb->atlSTAClients[*pucSTAId]->ucExists )
Hoonki Lee14621352013-04-16 17:51:19 -07003772 {
3773 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3774 "WLAN TL:Station %d was not previously registered on WLANTL_SuspendDataTx", *pucSTAId));
3775 return VOS_STATUS_E_EXISTS;
3776 }
3777
3778 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
3779 "WLAN TL:Suspend request for station: %d", *pucSTAId));
3780 vos_atomic_set_U8( &pTLCb->atlSTAClients[*pucSTAId]->ucTxSuspended, 1);
Jeff Johnson295189b2012-06-20 16:38:30 -07003781 vosMsg.reserved = *pucSTAId;
3782 }
3783
3784 /*------------------------------------------------------------------------
3785 Serialize request through TX thread
3786 ------------------------------------------------------------------------*/
3787 vosMsg.type = WLANTL_TX_SIG_SUSPEND;
3788 vosMsg.bodyptr = (v_PVOID_t)pfnSuspendTx;
3789
Katya Nigam42e16e82014-02-04 16:28:55 +05303790 MTRACE(vos_trace(VOS_MODULE_ID_TL, TRACE_CODE_TL_SUSPEND_DATA_TX,
3791 vosMsg.reserved , 0 ));
3792
Jeff Johnson295189b2012-06-20 16:38:30 -07003793 if(!VOS_IS_STATUS_SUCCESS(vos_tx_mq_serialize( VOS_MQ_ID_TL, &vosMsg)))
3794 {
3795 VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003796 " %s fails to post message", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003797 }
3798
3799 return VOS_STATUS_SUCCESS;
3800}/* WLANTL_SuspendDataTx */
3801
3802/*==========================================================================
3803
3804 FUNCTION WLANTL_ResumeDataTx
3805
3806 DESCRIPTION
3807 Called by HAL to resume data transmission for a given STA.
3808
3809 WARNING: If a station was individually suspended a global resume will
3810 not resume that station
3811
3812 DEPENDENCIES
3813
3814 PARAMETERS
3815
3816 IN
3817 pvosGCtx: pointer to the global vos context; a handle to TL's
3818 control block can be extracted from its context
3819 pucSTAId: identifier of the station which is being resumed; NULL
3820 translates into global resume
3821
3822 RETURN VALUE
3823 The result code associated with performing the operation
3824
3825 VOS_STATUS_E_FAULT: Station ID is outside array boundaries or pointer
3826 to TL cb is NULL ; access would cause a page fault
3827 VOS_STATUS_E_EXISTS: Station was not registered
3828 VOS_STATUS_SUCCESS: Everything is good :)
3829
3830 SIDE EFFECTS
3831
3832============================================================================*/
3833
3834VOS_STATUS
3835WLANTL_ResumeDataTx
3836(
3837 v_PVOID_t pvosGCtx,
3838 v_U8_t* pucSTAId
3839)
3840{
3841 WLANTL_CbType* pTLCb = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07003842 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
3843
3844 /*------------------------------------------------------------------------
3845 Sanity check
3846 Extract TL control block
3847 ------------------------------------------------------------------------*/
3848 pTLCb = VOS_GET_TL_CB(pvosGCtx);
Hoonki Lee14621352013-04-16 17:51:19 -07003849 if ( NULL == pTLCb )
Jeff Johnson295189b2012-06-20 16:38:30 -07003850 {
3851 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3852 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_ResumeDataTx"));
3853 return VOS_STATUS_E_FAULT;
3854 }
3855
Jeff Johnson295189b2012-06-20 16:38:30 -07003856 /*------------------------------------------------------------------------
3857 Check to see the type of resume
3858 ------------------------------------------------------------------------*/
Hoonki Lee14621352013-04-16 17:51:19 -07003859 if ( NULL == pucSTAId )
Jeff Johnson295189b2012-06-20 16:38:30 -07003860 {
Katya Nigam42e16e82014-02-04 16:28:55 +05303861 MTRACE(vos_trace(VOS_MODULE_ID_TL, TRACE_CODE_TL_RESUME_DATA_TX,
3862 41 , 0 ));
3863
Jeff Johnson295189b2012-06-20 16:38:30 -07003864 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
3865 "WLAN TL:General resume requested"));
3866 vos_atomic_set_U8( &pTLCb->ucTxSuspended, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07003867 }
3868 else
3869 {
Katya Nigam42e16e82014-02-04 16:28:55 +05303870 MTRACE(vos_trace(VOS_MODULE_ID_TL, TRACE_CODE_TL_RESUME_DATA_TX,
3871 *pucSTAId , 0 ));
3872
Hoonki Lee14621352013-04-16 17:51:19 -07003873 if ( WLANTL_STA_ID_INVALID( *pucSTAId ))
Jeff Johnson295189b2012-06-20 16:38:30 -07003874 {
Hoonki Lee14621352013-04-16 17:51:19 -07003875 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3876 "WLAN TL:Invalid station id %d requested on WLANTL_ResumeDataTx", *pucSTAId));
3877 return VOS_STATUS_E_FAULT;
3878 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003879
Gopichand Nakkalae5fef6c2013-06-19 18:04:23 +05303880 if ( NULL == pTLCb->atlSTAClients[*pucSTAId] )
3881 {
3882 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3883 "WLAN TL:Invalid pTLCb->atlSTAClients pointer for STA Id :%d on "
3884 "WLANTL_ResumeDataTx", *pucSTAId));
3885 return VOS_STATUS_E_FAULT;
3886 }
3887
3888 if ( 0 == pTLCb->atlSTAClients[*pucSTAId]->ucExists )
Hoonki Lee14621352013-04-16 17:51:19 -07003889 {
3890 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3891 "WLAN TL:Station %d was not previously registered on WLANTL_ResumeDataTx", *pucSTAId));
3892 return VOS_STATUS_E_EXISTS;
3893 }
3894
3895 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
3896 "WLAN TL:Resume request for station: %d", *pucSTAId));
3897 vos_atomic_set_U8( &pTLCb->atlSTAClients[*pucSTAId]->ucTxSuspended, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07003898 }
3899
3900 /*------------------------------------------------------------------------
3901 Resuming transmission
3902 ------------------------------------------------------------------------*/
Hoonki Lee14621352013-04-16 17:51:19 -07003903 if (( pTLCb->uResCount >= WDA_TLI_MIN_RES_MF ) &&
3904 ( 0 == pTLCb->ucTxSuspended ))
Jeff Johnson295189b2012-06-20 16:38:30 -07003905 {
3906 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
3907 "WLAN TL:Resuming transmission"));
3908 return WDA_DS_StartXmit(pvosGCtx);
3909 }
3910
3911 return VOS_STATUS_SUCCESS;
3912}/* WLANTL_ResumeDataTx */
3913
3914/*==========================================================================
3915 FUNCTION WLANTL_SuspendCB
3916
3917 DESCRIPTION
3918 Callback function for serializing Suspend signal through Tx thread
3919
3920 DEPENDENCIES
3921 Just notify HAL that suspend in TL is complete.
3922
3923 PARAMETERS
3924
3925 IN
3926 pvosGCtx: pointer to the global vos context; a handle to TL's
3927 control block can be extracted from its context
3928 pUserData: user data sent with the callback
3929
3930 RETURN VALUE
3931 The result code associated with performing the operation
3932
3933 VOS_STATUS_E_INVAL: invalid input parameters
3934 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
3935 page fault
3936 VOS_STATUS_SUCCESS: Everything is good :)
3937
3938
3939 SIDE EFFECTS
3940
3941============================================================================*/
3942VOS_STATUS
3943WLANTL_SuspendCB
3944(
3945 v_PVOID_t pvosGCtx,
3946 WLANTL_SuspendCBType pfnSuspendCB,
3947 v_U16_t usReserved
3948)
3949{
3950 WLANTL_CbType* pTLCb = NULL;
3951 v_U8_t ucSTAId = (v_U8_t)usReserved;
3952 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
3953
3954 /*------------------------------------------------------------------------
3955 Sanity check
3956 ------------------------------------------------------------------------*/
3957 if ( NULL == pfnSuspendCB )
3958 {
3959 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
3960 "WLAN TL: No Call back processing requested WLANTL_SuspendCB"));
3961 return VOS_STATUS_SUCCESS;
3962 }
3963
3964 /*------------------------------------------------------------------------
3965 Extract TL control block
3966 ------------------------------------------------------------------------*/
3967 pTLCb = VOS_GET_TL_CB(pvosGCtx);
3968 if ( NULL == pTLCb )
3969 {
3970 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3971 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_SuspendCB"));
3972 return VOS_STATUS_E_FAULT;
3973 }
3974
3975 if ( WLANTL_STA_ID_INVALID( ucSTAId ) )
3976 {
3977 pfnSuspendCB(pvosGCtx, NULL, VOS_STATUS_SUCCESS);
3978 }
3979 else
3980 {
3981 pfnSuspendCB(pvosGCtx, &ucSTAId, VOS_STATUS_SUCCESS);
3982 }
3983
3984 return VOS_STATUS_SUCCESS;
3985}/*WLANTL_SuspendCB*/
3986
3987
3988/*----------------------------------------------------------------------------
3989 CLIENT INDEPENDENT INTERFACE
3990 ---------------------------------------------------------------------------*/
3991
3992/*==========================================================================
3993
3994 FUNCTION WLANTL_GetTxPktCount
3995
3996 DESCRIPTION
3997 TL will provide the number of transmitted packets counted per
3998 STA per TID.
3999
4000 DEPENDENCIES
4001
4002 PARAMETERS
4003
4004 IN
4005 pvosGCtx: pointer to the global vos context; a handle to TL's
4006 control block can be extracted from its context
4007 ucSTAId: identifier of the station
4008 ucTid: identifier of the tspec
4009
4010 OUT
4011 puTxPktCount: the number of packets tx packet for this STA and TID
4012
4013 RETURN VALUE
4014 The result code associated with performing the operation
4015
4016 VOS_STATUS_E_INVAL: Input parameters are invalid
4017 VOS_STATUS_E_FAULT: Station ID is outside array boundaries or pointer
4018 to TL cb is NULL ; access would cause a page fault
4019 VOS_STATUS_E_EXISTS: Station was not registered
4020 VOS_STATUS_SUCCESS: Everything is good :)
4021
4022 SIDE EFFECTS
4023
4024============================================================================*/
4025VOS_STATUS
4026WLANTL_GetTxPktCount
4027(
4028 v_PVOID_t pvosGCtx,
4029 v_U8_t ucSTAId,
4030 v_U8_t ucTid,
4031 v_U32_t* puTxPktCount
4032)
4033{
4034 WLANTL_CbType* pTLCb = NULL;
4035 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
4036
4037 /*------------------------------------------------------------------------
4038 Sanity check
4039 ------------------------------------------------------------------------*/
4040 if ( NULL == puTxPktCount )
4041 {
4042 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
4043 "WLAN TL:Invalid parameter sent on WLANTL_GetTxPktCount"));
4044 return VOS_STATUS_E_INVAL;
4045 }
4046
4047 if ( WLANTL_STA_ID_INVALID( ucSTAId ) || WLANTL_TID_INVALID( ucTid) )
4048 {
4049 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
4050 "WLAN TL:Invalid station id %d/tid %d requested on WLANTL_GetTxPktCount",
4051 ucSTAId, ucTid));
4052 return VOS_STATUS_E_FAULT;
4053 }
4054
4055 /*------------------------------------------------------------------------
4056 Extract TL control block and check if station exists
4057 ------------------------------------------------------------------------*/
4058 pTLCb = VOS_GET_TL_CB(pvosGCtx);
4059 if ( NULL == pTLCb )
4060 {
4061 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
4062 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_GetTxPktCount"));
4063 return VOS_STATUS_E_FAULT;
4064 }
4065
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304066 if ( NULL == pTLCb->atlSTAClients[ucSTAId] )
4067 {
4068 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
4069 "WLAN TL:Client Memory was not allocated on %s", __func__));
4070 return VOS_STATUS_E_FAILURE;
4071 }
4072
4073 if ( 0 == pTLCb->atlSTAClients[ucSTAId]->ucExists )
Jeff Johnson295189b2012-06-20 16:38:30 -07004074 {
4075 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
4076 "WLAN TL:Station was not previously registered on WLANTL_GetTxPktCount %d",
4077 ucSTAId));
4078 return VOS_STATUS_E_EXISTS;
4079 }
4080
4081 /*------------------------------------------------------------------------
4082 Return data
4083 ------------------------------------------------------------------------*/
4084 //VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_MED,
4085 // "WLAN TL:Requested tx packet count for STA: %d, TID: %d",
4086 // ucSTAId, ucTid);
4087
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304088 *puTxPktCount = pTLCb->atlSTAClients[ucSTAId]->auTxCount[ucTid];
Jeff Johnson295189b2012-06-20 16:38:30 -07004089
4090 return VOS_STATUS_SUCCESS;
4091}/* WLANTL_GetTxPktCount */
4092
4093/*==========================================================================
4094
4095 FUNCTION WLANTL_GetRxPktCount
4096
4097 DESCRIPTION
4098 TL will provide the number of received packets counted per
4099 STA per TID.
4100
4101 DEPENDENCIES
4102
4103 PARAMETERS
4104
4105 IN
4106 pvosGCtx: pointer to the global vos context; a handle to TL's
4107 control block can be extracted from its context
4108 ucSTAId: identifier of the station
4109 ucTid: identifier of the tspec
4110
4111 OUT
4112 puTxPktCount: the number of packets rx packet for this STA and TID
4113
4114 RETURN VALUE
4115 The result code associated with performing the operation
4116
4117 VOS_STATUS_E_INVAL: Input parameters are invalid
4118 VOS_STATUS_E_FAULT: Station ID is outside array boundaries or pointer
4119 to TL cb is NULL ; access would cause a page fault
4120 VOS_STATUS_E_EXISTS: Station was not registered
4121 VOS_STATUS_SUCCESS: Everything is good :)
4122
4123 SIDE EFFECTS
4124
4125============================================================================*/
4126VOS_STATUS
4127WLANTL_GetRxPktCount
4128(
4129 v_PVOID_t pvosGCtx,
4130 v_U8_t ucSTAId,
4131 v_U8_t ucTid,
4132 v_U32_t* puRxPktCount
4133)
4134{
4135 WLANTL_CbType* pTLCb = NULL;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304136 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004137 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
4138
4139 /*------------------------------------------------------------------------
4140 Sanity check
4141 ------------------------------------------------------------------------*/
4142 if ( NULL == puRxPktCount )
4143 {
4144 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
4145 "WLAN TL:Invalid parameter sent on WLANTL_GetRxPktCount"));
4146 return VOS_STATUS_E_INVAL;
4147 }
4148
4149 if ( WLANTL_STA_ID_INVALID( ucSTAId ) || WLANTL_TID_INVALID( ucTid) )
4150 {
4151 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
4152 "WLAN TL:Invalid station id %d/tid %d requested on WLANTL_GetRxPktCount",
4153 ucSTAId, ucTid));
4154 return VOS_STATUS_E_FAULT;
4155 }
4156
4157 /*------------------------------------------------------------------------
4158 Extract TL control block and existance
4159 ------------------------------------------------------------------------*/
4160 pTLCb = VOS_GET_TL_CB(pvosGCtx);
4161 if ( NULL == pTLCb )
4162 {
4163 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
4164 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_GetRxPktCount"));
4165 return VOS_STATUS_E_FAULT;
4166 }
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304167 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
Jeff Johnson295189b2012-06-20 16:38:30 -07004168
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304169 if ( NULL == pClientSTA )
4170 {
4171 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
4172 "WLAN TL:Client Memory was not allocated on %s", __func__));
4173 return VOS_STATUS_E_FAILURE;
4174 }
4175
4176 if ( 0 == pClientSTA->ucExists )
Jeff Johnson295189b2012-06-20 16:38:30 -07004177 {
4178 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
4179 "WLAN TL:Station was not previously registered on WLANTL_GetRxPktCount"));
4180 return VOS_STATUS_E_EXISTS;
4181 }
4182
4183 /*------------------------------------------------------------------------
4184 Return data
4185 ------------------------------------------------------------------------*/
4186 TLLOG3(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_MED,
4187 "WLAN TL:Requested rx packet count for STA: %d, TID: %d",
4188 ucSTAId, ucTid));
4189
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304190 *puRxPktCount = pClientSTA->auRxCount[ucTid];
Jeff Johnson295189b2012-06-20 16:38:30 -07004191
4192 return VOS_STATUS_SUCCESS;
4193}/* WLANTL_GetRxPktCount */
4194
Jeff Johnson295189b2012-06-20 16:38:30 -07004195VOS_STATUS
4196WLANTL_TxFCFrame
4197(
4198 v_PVOID_t pvosGCtx
4199);
Jeff Johnson295189b2012-06-20 16:38:30 -07004200/*============================================================================
4201 TL INTERNAL API DEFINITION
4202============================================================================*/
4203
4204/*==========================================================================
4205
4206 FUNCTION WLANTL_GetFrames
4207
4208 DESCRIPTION
4209
4210 BAL calls this function at the request of the lower bus interface.
4211 When this request is being received TL will retrieve packets from HDD
4212 in accordance with the priority rules and the count supplied by BAL.
4213
4214 DEPENDENCIES
4215
4216 HDD must have registered with TL at least one STA before this function
4217 can be called.
4218
4219 PARAMETERS
4220
4221 IN
4222 pvosGCtx: pointer to the global vos context; a handle to TL's
4223 or BAL's control block can be extracted from its context
4224 uSize: maximum size accepted by the lower layer
4225 uFlowMask TX flow control mask for Prima. Each bit is defined as
4226 WDA_TXFlowEnumType
4227
4228 OUT
4229 vosDataBuff: it will contain a pointer to the first buffer supplied
4230 by TL, if there is more than one packet supplied, TL
4231 will chain them through vOSS buffers
4232
4233 RETURN VALUE
4234
4235 The result code associated with performing the operation
4236
4237 1 or more: number of required resources if there are still frames to fetch
4238 0 : error or HDD queues are drained
4239
4240 SIDE EFFECTS
4241
4242 NOTE
4243
4244 Featurized uFlowMask. If we want to remove featurization, we need to change
4245 BAL on Volans.
4246
4247============================================================================*/
4248v_U32_t
4249WLANTL_GetFrames
4250(
4251 v_PVOID_t pvosGCtx,
4252 vos_pkt_t **ppFrameDataBuff,
4253 v_U32_t uSize,
Jeff Johnson295189b2012-06-20 16:38:30 -07004254 v_U8_t uFlowMask,
Jeff Johnson295189b2012-06-20 16:38:30 -07004255 v_BOOL_t* pbUrgent
4256)
4257{
4258 vos_pkt_t** pvosDataBuff = (vos_pkt_t**)ppFrameDataBuff;
4259 WLANTL_CbType* pTLCb = NULL;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304260 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004261 v_U32_t uRemaining = uSize;
4262 vos_pkt_t* vosRoot;
4263 vos_pkt_t* vosTempBuf;
4264 WLANTL_STAFuncType pfnSTAFsm;
4265 v_U16_t usPktLen;
4266 v_U32_t uResLen;
4267 v_U8_t ucSTAId;
4268 v_U8_t ucAC;
4269 vos_pkt_t* vosDataBuff;
4270 v_U32_t uTotalPktLen;
4271 v_U32_t i=0;
Tushnim Bhattacharyya39a8f182013-02-20 18:10:30 -08004272 v_U32_t j=0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004273 v_U32_t ucResult = 0;
4274 VOS_STATUS vosStatus;
4275 WLANTL_STAEventType wSTAEvent;
4276 tBssSystemRole systemRole;
4277 tpAniSirGlobal pMac;
4278 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
4279
4280 /*------------------------------------------------------------------------
4281 Sanity check
4282 Extract TL control block
4283 ------------------------------------------------------------------------*/
4284 pTLCb = VOS_GET_TL_CB(pvosGCtx);
4285 if (( NULL == pTLCb ) || ( NULL == pvosDataBuff ))
4286 {
4287 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
4288 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_ChangeSTAState"));
4289 return ucResult;
4290 }
4291
4292 pMac = vos_get_context(VOS_MODULE_ID_PE, pvosGCtx);
4293 if ( NULL == pMac )
4294 {
4295 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004296 "%s: Invalid pMac", __func__));
Jeff Johnson295189b2012-06-20 16:38:30 -07004297 return ucResult;
4298 }
4299
4300 vosDataBuff = pTLCb->vosDummyBuf; /* Just to avoid checking for NULL at
4301 each iteration */
4302
Jeff Johnson295189b2012-06-20 16:38:30 -07004303 pTLCb->uResCount = uSize;
Jeff Johnson295189b2012-06-20 16:38:30 -07004304
4305 /*-----------------------------------------------------------------------
4306 Save the root as we will walk this chain as we fill it
4307 -----------------------------------------------------------------------*/
4308 vosRoot = vosDataBuff;
4309
4310 /*-----------------------------------------------------------------------
4311 There is still data - until FSM function says otherwise
4312 -----------------------------------------------------------------------*/
4313 pTLCb->bUrgent = FALSE;
4314
Jeff Johnson295189b2012-06-20 16:38:30 -07004315 while (( pTLCb->tlConfigInfo.uMinFramesProcThres < pTLCb->uResCount ) &&
4316 ( 0 < uRemaining ))
Jeff Johnson295189b2012-06-20 16:38:30 -07004317 {
4318 systemRole = wdaGetGlobalSystemRole(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -07004319#ifdef WLAN_SOFTAP_FLOWCTRL_EN
4320/* FIXME: The code has been disabled since it is creating issues in power save */
4321 if (eSYSTEM_AP_ROLE == systemRole)
4322 {
4323 if (pTLCb->done_once == 0 && NULL == pTLCb->vosTxFCBuf)
4324 {
4325 WLANTL_TxFCFrame (pvosGCtx);
4326 pTLCb->done_once ++;
4327 }
4328 }
4329 if ( NULL != pTLCb->vosTxFCBuf )
4330 {
4331 //there is flow control packet waiting to be sent
4332 WDA_TLI_PROCESS_FRAME_LEN( pTLCb->vosTxFCBuf, usPktLen, uResLen, uTotalPktLen);
4333
4334 if ( ( pTLCb->uResCount > uResLen ) &&
Jeff Johnson9b5dc4d2013-02-22 21:28:47 -08004335 ( uRemaining > uTotalPktLen ) &&
4336 ( uFlowMask & ( 1 << WDA_TXFLOW_FC ) ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07004337 {
4338 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
4339 "WLAN TL:Chaining FC frame first on GetFrame"));
4340
4341 vos_pkt_chain_packet( vosDataBuff, pTLCb->vosTxFCBuf, 1 /*true*/ );
4342
Arun Kumar Khandavalli0af8d3c2014-02-07 18:05:11 +05304343 vos_atomic_set( (uintptr_t*)&pTLCb->vosTxFCBuf, (uintptr_t) NULL);
Jeff Johnson295189b2012-06-20 16:38:30 -07004344
4345 /*FC frames cannot be delayed*/
4346 pTLCb->bUrgent = TRUE;
4347
4348 /*Update remaining len from SSC */
4349 uRemaining -= (usPktLen + WDA_DXE_HEADER_SIZE);
4350
4351 /*Update resource count */
4352 pTLCb->uResCount -= uResLen;
4353 }
4354 else
4355 {
4356 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004357 "WLAN TL:send fc out of source %s", __func__));
Jeff Johnson295189b2012-06-20 16:38:30 -07004358 ucResult = ( pTLCb->uResCount > uResLen )?VOS_TRUE:VOS_FALSE;
4359 break; /* Out of resources or reached max len */
4360 }
4361 }
4362 else
4363#endif //WLAN_SOFTAP_FLOWCTRL_EN
Jeff Johnson295189b2012-06-20 16:38:30 -07004364
Jeff Johnson9b5dc4d2013-02-22 21:28:47 -08004365 if (( NULL != pTLCb->tlMgmtFrmClient.vosPendingDataBuff ) &&
4366 ( uFlowMask & ( 1 << WDA_TXFLOW_MGMT ) ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07004367 {
4368 WDA_TLI_PROCESS_FRAME_LEN( pTLCb->tlMgmtFrmClient.vosPendingDataBuff,
4369 usPktLen, uResLen, uTotalPktLen);
4370
Manjunathappa Prakashfb585462013-12-23 19:07:07 -08004371 if (usPktLen > WLANTL_MAX_ALLOWED_LEN)
4372 {
4373 usPktLen = WLANTL_MAX_ALLOWED_LEN;
4374 VOS_ASSERT(0);
4375 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004376
4377 if ( ( pTLCb->uResCount > uResLen ) &&
Jeff Johnson9b5dc4d2013-02-22 21:28:47 -08004378 ( uRemaining > uTotalPktLen ) &&
4379 ( uFlowMask & ( 1 << WDA_TXFLOW_MGMT ) ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07004380 {
4381 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
4382 "WLAN TL:Chaining management frame on GetFrame"));
4383
4384 vos_pkt_chain_packet( vosDataBuff,
4385 pTLCb->tlMgmtFrmClient.vosPendingDataBuff,
4386 1 /*true*/ );
4387
Arun Kumar Khandavalli0af8d3c2014-02-07 18:05:11 +05304388 vos_atomic_set( (uintptr_t*)&pTLCb->tlMgmtFrmClient.
4389 vosPendingDataBuff, (uintptr_t)NULL);
Jeff Johnson295189b2012-06-20 16:38:30 -07004390
4391 /*management frames cannot be delayed*/
4392 pTLCb->bUrgent = TRUE;
4393
4394 /*Update remaining len from SSC */
4395 uRemaining -= (usPktLen + WDA_DXE_HEADER_SIZE);
4396
4397 /*Update resource count */
4398 pTLCb->uResCount -= uResLen;
4399 }
4400 else
4401 {
4402 ucResult = ( pTLCb->uResCount > uResLen )?VOS_TRUE:VOS_FALSE;
4403 break; /* Out of resources or reached max len */
4404 }
4405 }
4406 else if (( pTLCb->tlBAPClient.vosPendingDataBuff ) &&
4407 ( WDA_TLI_MIN_RES_BAP <= pTLCb->uResCount ) &&
Gopichand Nakkala7e48ca72012-12-31 14:15:07 -08004408 ( 0 == pTLCb->ucTxSuspended ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07004409 {
4410 WDA_TLI_PROCESS_FRAME_LEN( pTLCb->tlBAPClient.vosPendingDataBuff,
4411 usPktLen, uResLen, uTotalPktLen);
4412
Manjunathappa Prakashfb585462013-12-23 19:07:07 -08004413 if (usPktLen > WLANTL_MAX_ALLOWED_LEN)
4414 {
4415 usPktLen = WLANTL_MAX_ALLOWED_LEN;
4416 VOS_ASSERT(0);
4417 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004418
4419 if ( ( pTLCb->uResCount > (uResLen + WDA_TLI_MIN_RES_MF ) ) &&
4420 ( uRemaining > uTotalPktLen ))
4421 {
4422 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
4423 "WLAN TL:Chaining BT-AMP frame on GetFrame"));
4424
4425 vos_pkt_chain_packet( vosDataBuff,
4426 pTLCb->tlBAPClient.vosPendingDataBuff,
4427 1 /*true*/ );
4428
4429 /*BAP frames cannot be delayed*/
4430 pTLCb->bUrgent = TRUE;
4431
Arun Kumar Khandavalli0af8d3c2014-02-07 18:05:11 +05304432 vos_atomic_set( (uintptr_t*)&pTLCb->tlBAPClient.vosPendingDataBuff,
4433 (uintptr_t) NULL);
Jeff Johnson295189b2012-06-20 16:38:30 -07004434
4435 /*Update remaining len from SSC */
4436 uRemaining -= (usPktLen + WDA_DXE_HEADER_SIZE);
4437
4438 /*Update resource count */
4439 pTLCb->uResCount -= uResLen;
4440 }
4441 else
4442 {
Jeff Johnson295189b2012-06-20 16:38:30 -07004443 ucResult = uResLen + WDA_TLI_MIN_RES_MF;
Jeff Johnson295189b2012-06-20 16:38:30 -07004444 break; /* Out of resources or reached max len */
4445 }
4446 }
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -07004447 /* note: this feature implemented only after WLAN_INGETRATED_SOC */
4448 /* search 'EAPOL_HI_PRIORITY' will show EAPOL HI_PRIORITY change in TL and WDI
4449 by default, EAPOL will be treated as higher priority, which means
4450 use mgmt_pool and DXE_TX_HI prority channel.
4451 this is introduced to address EAPOL failure under high background traffic
4452 with multi-channel concurrent mode. But this change works in SCC or standalone, too.
4453 see CR#387009 and WCNSOS-8
4454 */
4455 else if (( WDA_TLI_MIN_RES_MF <= pTLCb->uResCount )&&
4456 ( 0 == pTLCb->ucTxSuspended ) &&
4457 ( uFlowMask & ( 1 << WDA_TXFLOW_MGMT ) )
4458 )
4459 {
4460 vosTempBuf = NULL;
4461 /*---------------------------------------------------------------------
4462 Check to see if there was any EAPOL packet is pending
4463 *--------------------------------------------------------------------*/
4464 for ( i = 0; i < WLAN_MAX_STA_COUNT; i++)
4465 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304466 if ((NULL != pTLCb->atlSTAClients[i]) &&
4467 (pTLCb->atlSTAClients[i]->ucExists) &&
4468 (0 == pTLCb->atlSTAClients[i]->ucTxSuspended) &&
Tushnim Bhattacharyya39a8f182013-02-20 18:10:30 -08004469 (WLANTL_STA_CONNECTED == pTLCb->atlSTAClients[i]->tlState) &&
4470 (pTLCb->atlSTAClients[i]->ucPktPending)
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -07004471 )
4472 break;
4473 }
4474
4475 if (i >= WLAN_MAX_STA_COUNT)
4476 {
4477 /* No More to Serve Exit Get Frames */
4478 break;
4479 }
4480 /* Serve EAPOL frame with HI_FLOW_MASK */
4481 ucSTAId = i;
4482
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304483 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
4484
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05304485 MTRACE(vos_trace(VOS_MODULE_ID_TL,
4486 TRACE_CODE_TL_GET_FRAMES_EAPOL, ucSTAId, pClientSTA->tlState));
4487
4488 if (pClientSTA->wSTADesc.wSTAType == WLAN_STA_INFRA)
4489 {
4490 if(0 != pClientSTA->aucACMask[WLANTL_AC_HIGH_PRIO])
4491 {
4492 pClientSTA->ucCurrentAC = WLANTL_AC_HIGH_PRIO;
4493 pTLCb->uCurServedAC = WLANTL_AC_HIGH_PRIO;
4494 }
4495 else
4496 break;
4497 }
4498 else
4499 {
4500 for (j = WLANTL_MAX_AC ; j > 0; j--)
4501 {
4502 if (0 != pClientSTA->aucACMask[j-1])
4503 {
4504 pClientSTA->ucCurrentAC = j-1;
4505 pTLCb->uCurServedAC = j-1;
4506 break;
4507 }
4508 }
4509 }
4510
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -07004511 wSTAEvent = WLANTL_TX_EVENT;
4512
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304513 pfnSTAFsm = tlSTAFsm[pClientSTA->tlState].
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -07004514 pfnSTATbl[wSTAEvent];
4515
4516 if ( NULL != pfnSTAFsm )
4517 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304518 pClientSTA->ucNoMoreData = 0;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004519 vosStatus = pfnSTAFsm( pvosGCtx, ucSTAId, &vosTempBuf, VOS_FALSE);
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -07004520
4521 if (( VOS_STATUS_SUCCESS != vosStatus ) &&
4522 ( NULL != vosTempBuf ))
4523 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304524 pClientSTA->pfnSTATxComp( pvosGCtx, vosTempBuf, vosStatus );
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -07004525 vosTempBuf = NULL;
4526 break;
4527 }/* status success*/
4528 }
4529
4530 if (NULL != vosTempBuf)
4531 {
4532 WDA_TLI_PROCESS_FRAME_LEN( vosTempBuf, usPktLen, uResLen, uTotalPktLen);
4533
Manjunathappa Prakashfb585462013-12-23 19:07:07 -08004534 if (usPktLen > WLANTL_MAX_ALLOWED_LEN)
4535 {
4536 usPktLen = WLANTL_MAX_ALLOWED_LEN;
4537 VOS_ASSERT(0);
4538 }
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -07004539
4540 TLLOG4(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_LOW,
4541 "WLAN TL:Resources needed by frame: %d", uResLen));
4542
4543 if ( ( pTLCb->uResCount >= (uResLen + WDA_TLI_MIN_RES_MF ) ) &&
4544 ( uRemaining > uTotalPktLen )
4545 )
4546 {
4547 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
4548 "WLAN TL:Chaining data frame on GetFrame"));
4549
4550 vos_pkt_chain_packet( vosDataBuff, vosTempBuf, 1 /*true*/ );
4551
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -07004552 /*EAPOL frame cannot be delayed*/
4553 pTLCb->bUrgent = TRUE;
4554
4555 vosTempBuf = NULL;
4556
4557 /*Update remaining len from SSC */
4558 uRemaining -= (usPktLen + WDA_DXE_HEADER_SIZE);
4559
4560 /*Update resource count */
4561 pTLCb->uResCount -= uResLen;
4562
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -07004563 //fow control update
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304564 pClientSTA->uIngress_length += uResLen;
4565 pClientSTA->uBuffThresholdMax = (pClientSTA->uBuffThresholdMax >= uResLen) ?
4566 (pClientSTA->uBuffThresholdMax - uResLen) : 0;
Tushnim Bhattacharyya39a8f182013-02-20 18:10:30 -08004567 pClientSTA->ucEapolPktPending = 0;
4568 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
4569 "WLAN TL:GetFrames STA: %d EAPOLPktPending %d",
4570 ucSTAId, pClientSTA->ucEapolPktPending);
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -07004571 }
4572 }
4573 else
4574 { // no EAPOL frames exit Get frames
Tushnim Bhattacharyya39a8f182013-02-20 18:10:30 -08004575 TLLOG2(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
4576 "WLAN TL:GetFrames STA: %d, no EAPOL frame, continue.",
4577 ucSTAId));
4578 continue;
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -07004579 }
4580 }
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -07004581
Jeff Johnson9b5dc4d2013-02-22 21:28:47 -08004582 else if (( WDA_TLI_MIN_RES_DATA <= pTLCb->uResCount ) &&
4583 ( 0 == pTLCb->ucTxSuspended ) &&
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05304584 ( uFlowMask & WLANTL_DATA_FLOW_MASK))
Jeff Johnson295189b2012-06-20 16:38:30 -07004585 {
4586 /*---------------------------------------------------------------------
4587 Check to see if there was any packet left behind previously due to
4588 size constraints
4589 ---------------------------------------------------------------------*/
4590 vosTempBuf = NULL;
4591
4592 if ( NULL != pTLCb->vosTempBuf )
4593 {
4594 vosTempBuf = pTLCb->vosTempBuf;
4595 pTLCb->vosTempBuf = NULL;
4596 ucSTAId = pTLCb->ucCachedSTAId;
4597 ucAC = pTLCb->ucCachedAC;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304598
4599 if ( NULL == pTLCb->atlSTAClients[ucSTAId] )
4600 {
4601 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
4602 "WLAN TL:Client Memory was not allocated on %s", __func__));
Madan Mohan Koyylamudi64258222013-01-30 14:35:10 +05304603 continue;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304604 }
4605
4606 pTLCb->atlSTAClients[ucSTAId]->ucNoMoreData = 0;
Madan Mohan Koyylamudi64258222013-01-30 14:35:10 +05304607 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
Jeff Johnson295189b2012-06-20 16:38:30 -07004608
4609 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
4610 "WLAN TL:Chaining cached data frame on GetFrame"));
4611 }
4612 else
4613 {
4614 WLAN_TLGetNextTxIds( pvosGCtx, &ucSTAId);
4615 if (ucSTAId >= WLAN_MAX_STA_COUNT)
4616 {
4617 /* Packets start coming in even after insmod Without *
4618 starting Hostapd or Interface being up *
4619 During which cases STAID is invaled and hence
4620 the check. HalMsg_ScnaComplete Triggers */
4621
4622 break;
4623 }
4624 /* ucCurrentAC should have correct AC to be served by calling
4625 WLAN_TLGetNextTxIds */
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304626 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304627 if ( NULL == pClientSTA )
4628 {
4629 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
4630 "WLAN TL:Client Memory was not allocated on %s", __func__));
Madan Mohan Koyylamudi64258222013-01-30 14:35:10 +05304631 continue;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304632 }
4633
4634 ucAC = pClientSTA->ucCurrentAC;
4635
4636 pClientSTA->ucNoMoreData = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07004637 TLLOG4(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_LOW,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004638 "WLAN TL: %s get one data frame, station ID %d ", __func__, ucSTAId));
Jeff Johnson295189b2012-06-20 16:38:30 -07004639 /*-------------------------------------------------------------------
4640 Check to see that STA is valid and tx is not suspended
4641 -------------------------------------------------------------------*/
4642 if ( ( ! WLANTL_STA_ID_INVALID( ucSTAId ) ) &&
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304643 ( 0 == pClientSTA->ucTxSuspended ) &&
4644 ( 0 == pClientSTA->fcStaTxDisabled) )
Jeff Johnson295189b2012-06-20 16:38:30 -07004645 {
4646 TLLOG4(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_LOW,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004647 "WLAN TL: %s sta id valid and not suspended ",__func__));
Jeff Johnson295189b2012-06-20 16:38:30 -07004648 wSTAEvent = WLANTL_TX_EVENT;
4649
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304650 pfnSTAFsm = tlSTAFsm[pClientSTA->tlState].
Jeff Johnson295189b2012-06-20 16:38:30 -07004651 pfnSTATbl[wSTAEvent];
4652
4653 if ( NULL != pfnSTAFsm )
4654 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304655 pClientSTA->ucNoMoreData = 0;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004656 vosStatus = pfnSTAFsm( pvosGCtx, ucSTAId, &vosTempBuf, VOS_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07004657
4658 if (( VOS_STATUS_SUCCESS != vosStatus ) &&
4659 ( NULL != vosTempBuf ))
4660 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304661 pClientSTA->pfnSTATxComp( pvosGCtx,
Jeff Johnson295189b2012-06-20 16:38:30 -07004662 vosTempBuf,
4663 vosStatus );
4664 vosTempBuf = NULL;
4665 }/* status success*/
4666 }/*NULL function state*/
4667 }/* valid STA id and ! suspended*/
4668 else
4669 {
4670 if ( ! WLANTL_STA_ID_INVALID( ucSTAId ) )
4671 {
4672 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
4673 "WLAN TL:Not fetching frame because suspended for sta ID %d",
4674 ucSTAId));
4675 }
4676 }
4677 }/* data */
4678
4679 if ( NULL != vosTempBuf )
4680 {
4681 WDA_TLI_PROCESS_FRAME_LEN( vosTempBuf, usPktLen, uResLen, uTotalPktLen);
4682
Manjunathappa Prakashfb585462013-12-23 19:07:07 -08004683 if (usPktLen > WLANTL_MAX_ALLOWED_LEN)
4684 {
4685 usPktLen = WLANTL_MAX_ALLOWED_LEN;
4686 VOS_ASSERT(0);
4687 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004688
4689 TLLOG4(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_LOW,
4690 "WLAN TL:Resources needed by frame: %d", uResLen));
4691
4692 if ( ( pTLCb->uResCount >= (uResLen + WDA_TLI_MIN_RES_BAP ) ) &&
Jeff Johnson9b5dc4d2013-02-22 21:28:47 -08004693 ( uRemaining > uTotalPktLen ) &&
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05304694 ( uFlowMask & WLANTL_DATA_FLOW_MASK ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07004695 {
4696 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
4697 "WLAN TL:Chaining data frame on GetFrame"));
4698
4699 vos_pkt_chain_packet( vosDataBuff, vosTempBuf, 1 /*true*/ );
4700 vosTempBuf = NULL;
4701
4702 /*Update remaining len from SSC */
4703 uRemaining -= (usPktLen + WDA_DXE_HEADER_SIZE);
4704
4705 /*Update resource count */
4706 pTLCb->uResCount -= uResLen;
4707
Jeff Johnson295189b2012-06-20 16:38:30 -07004708 //fow control update
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304709 pClientSTA->uIngress_length += uResLen;
4710 pClientSTA->uBuffThresholdMax = (pClientSTA->uBuffThresholdMax >= uResLen) ?
4711 (pClientSTA->uBuffThresholdMax - uResLen) : 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004712
4713 }
4714 else
4715 {
4716 /* Store this for later tx - already fetched from HDD */
4717 pTLCb->vosTempBuf = vosTempBuf;
4718 pTLCb->ucCachedSTAId = ucSTAId;
4719 pTLCb->ucCachedAC = ucAC;
Jeff Johnson295189b2012-06-20 16:38:30 -07004720 ucResult = uResLen + WDA_TLI_MIN_RES_BAP;
4721 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
4722 "min %d res required by TL.", ucResult ));
Jeff Johnson295189b2012-06-20 16:38:30 -07004723 break; /* Out of resources or reached max len */
4724 }
4725 }
4726 else
4727 {
4728 for ( i = 0; i < WLAN_MAX_STA_COUNT; i++)
4729 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304730 if (NULL != pTLCb->atlSTAClients[i] && (pTLCb->atlSTAClients[i]->ucExists) &&
4731 (pTLCb->atlSTAClients[i]->ucPktPending))
Jeff Johnson295189b2012-06-20 16:38:30 -07004732 {
4733 /* There is station to be Served */
4734 break;
4735 }
4736 }
4737 if (i >= WLAN_MAX_STA_COUNT)
4738 {
4739 /* No More to Serve Exit Get Frames */
4740 break;
4741 }
4742 else
4743 {
4744 /* More to be Served */
4745 continue;
4746 }
4747 }
4748 }
4749 else
4750 {
4751 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
4752 "WLAN TL:Returning from GetFrame: resources = %d suspended = %d",
4753 pTLCb->uResCount, pTLCb->ucTxSuspended));
Jeff Johnson295189b2012-06-20 16:38:30 -07004754 /* TL is starving even when DXE is not in low resource condition
4755 Return min resource number required and Let DXE deceide what to do */
4756 if(( 0 == pTLCb->ucTxSuspended ) &&
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05304757 ( uFlowMask & WLANTL_DATA_FLOW_MASK ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07004758 {
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07004759 TLLOG1(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -07004760 "WLAN TL:Returning from GetFrame: resources = %d",
4761 pTLCb->uResCount));
4762 ucResult = WDA_TLI_MIN_RES_DATA;
4763 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004764 break; /*out of min data resources*/
4765 }
4766
4767 pTLCb->usPendingTxCompleteCount++;
4768 /* Move data buffer up one packet */
4769 vos_pkt_walk_packet_chain( vosDataBuff, &vosDataBuff, 0/*false*/ );
4770 }
4771
4772 /*----------------------------------------------------------------------
4773 Packet chain starts at root + 1
4774 ----------------------------------------------------------------------*/
4775 vos_pkt_walk_packet_chain( vosRoot, &vosDataBuff, 1/*true*/ );
4776
4777 *pvosDataBuff = vosDataBuff;
Manjunathappa Prakashfb585462013-12-23 19:07:07 -08004778 if (pbUrgent)
4779 {
4780 *pbUrgent = pTLCb->bUrgent;
4781 }
4782 else
4783 {
4784 VOS_ASSERT( pbUrgent );
4785 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004786 return ucResult;
4787}/* WLANTL_GetFrames */
4788
4789
4790/*==========================================================================
4791
4792 FUNCTION WLANTL_TxComp
4793
4794 DESCRIPTION
4795 It is being called by BAL upon asynchronous notification of the packet
4796 or packets being sent over the bus.
4797
4798 DEPENDENCIES
4799 Tx complete cannot be called without a previous transmit.
4800
4801 PARAMETERS
4802
4803 IN
4804 pvosGCtx: pointer to the global vos context; a handle to TL's
4805 or BAL's control block can be extracted from its context
4806 vosDataBuff: it will contain a pointer to the first buffer for which
4807 the BAL report is being made, if there is more then one
4808 packet they will be chained using vOSS buffers.
4809 wTxStatus: the status of the transmitted packet, see above chapter
4810 on HDD interaction for a list of possible values
4811
4812 RETURN VALUE
4813 The result code associated with performing the operation
4814
4815 VOS_STATUS_E_INVAL: Input parameters are invalid
4816 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
4817 page fault
4818 VOS_STATUS_E_EXISTS: Station was not registered
4819 VOS_STATUS_SUCCESS: Everything is good :)
4820
4821 SIDE EFFECTS
4822
4823============================================================================*/
4824VOS_STATUS
4825WLANTL_TxComp
4826(
4827 v_PVOID_t pvosGCtx,
4828 vos_pkt_t *pFrameDataBuff,
4829 VOS_STATUS wTxStatus
4830)
4831{
4832 vos_pkt_t* vosDataBuff = (vos_pkt_t*)pFrameDataBuff;
4833 WLANTL_CbType* pTLCb = NULL;
4834 WLANTL_TxCompCBType pfnTxComp = NULL;
4835 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07004836 vos_pkt_t* vosTempTx = NULL;
4837
4838 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
4839
4840 /*------------------------------------------------------------------------
4841 Sanity check
4842 ------------------------------------------------------------------------*/
4843 if ( NULL == vosDataBuff )
4844 {
4845 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
4846 "WLAN TL:Extraneous NULL data pointer on WLANTL_TxComp"));
4847 return VOS_STATUS_E_INVAL;
4848 }
4849
4850 /*------------------------------------------------------------------------
4851 Extract TL control block
4852 ------------------------------------------------------------------------*/
4853 pTLCb = VOS_GET_TL_CB(pvosGCtx);
4854 if ( NULL == pTLCb )
4855 {
4856 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
4857 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_TxComp"));
4858 return VOS_STATUS_E_FAULT;
4859 }
4860
4861 while ((0 < pTLCb->usPendingTxCompleteCount) &&
4862 ( VOS_STATUS_SUCCESS == vosStatus ) &&
4863 ( NULL != vosDataBuff))
4864 {
4865 vos_pkt_get_user_data_ptr( vosDataBuff, VOS_PKT_USER_DATA_ID_TL,
4866 (v_PVOID_t)&pfnTxComp);
4867
4868 /*it should never be NULL - default handler should be registered if none*/
4869 if ( NULL == pfnTxComp )
4870 {
4871 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
4872 "WLAN TL:NULL pointer to Tx Complete on WLANTL_TxComp"));
4873 VOS_ASSERT(0);
4874 return VOS_STATUS_E_FAULT;
4875 }
4876
4877 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05304878 "WLAN TL:Calling Tx complete for pkt %p in function %p",
Jeff Johnson295189b2012-06-20 16:38:30 -07004879 vosDataBuff, pfnTxComp));
4880
4881 vosTempTx = vosDataBuff;
4882 vosStatus = vos_pkt_walk_packet_chain( vosDataBuff,
4883 &vosDataBuff, 1/*true*/);
4884
4885 pfnTxComp( pvosGCtx, vosTempTx, wTxStatus );
4886
4887 pTLCb->usPendingTxCompleteCount--;
4888 }
4889
Jeff Johnson295189b2012-06-20 16:38:30 -07004890
4891 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
4892 "WLAN TL: current TL values are: resources = %d "
4893 "pTLCb->usPendingTxCompleteCount = %d",
4894 pTLCb->uResCount, pTLCb->usPendingTxCompleteCount));
4895
4896 return VOS_STATUS_SUCCESS;
4897}/* WLANTL_TxComp */
4898
4899/*==========================================================================
4900
4901 FUNCTION WLANTL_CacheSTAFrame
4902
4903 DESCRIPTION
4904 Internal utility function for for caching incoming data frames that do
4905 not have a registered station yet.
4906
4907 DEPENDENCIES
4908 TL must be initiailized before this function gets called.
4909 In order to benefit from thsi caching, the components must ensure that
4910 they will only register with TL at the moment when they are fully setup
4911 and ready to receive incoming data
4912
4913 PARAMETERS
4914
4915 IN
4916
4917 pTLCb: TL control block
4918 ucSTAId: station id
4919 vosTempBuff: the data packet
4920 uDPUSig: DPU signature of the incoming packet
4921 bBcast: true if packet had the MC/BC bit set
4922
4923 RETURN VALUE
4924 The result code associated with performing the operation
4925
4926 VOS_STATUS_E_FAULT: pointer to TL cb is NULL or STA Id invalid ; access
4927 would cause a page fault
4928 VOS_STATUS_SUCCESS: Everything is good :)
4929
4930 SIDE EFFECTS
4931
4932============================================================================*/
4933static VOS_STATUS
4934WLANTL_CacheSTAFrame
4935(
4936 WLANTL_CbType* pTLCb,
4937 v_U8_t ucSTAId,
4938 vos_pkt_t* vosTempBuff,
4939 v_U32_t uDPUSig,
4940 v_U8_t bBcast,
4941 v_U8_t ucFrmType
4942)
4943{
4944 v_U8_t ucUcastSig;
4945 v_U8_t ucBcastSig;
4946 v_BOOL_t bOldSTAPkt;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304947 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004948 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
4949
4950 /*-------------------------------------------------------------------------
4951 Sanity check
4952 -------------------------------------------------------------------------*/
4953 if (( NULL == pTLCb ) || ( NULL == vosTempBuff ) )
4954 {
4955 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05304956 "WLAN TL: Invalid input pointer on WLANTL_CacheSTAFrame TL %p"
4957 " Packet %p", pTLCb, vosTempBuff ));
Jeff Johnson295189b2012-06-20 16:38:30 -07004958 return VOS_STATUS_E_FAULT;
4959 }
4960
4961 if ( WLANTL_STA_ID_INVALID( ucSTAId ) )
4962 {
4963 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
4964 "WLAN TL:Invalid station id requested on WLANTL_CacheSTAFrame"));
4965 return VOS_STATUS_E_FAULT;
4966 }
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304967 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
4968
4969 if ( NULL == pClientSTA )
4970 {
4971 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
4972 "WLAN TL:Client Memory was not allocated on %s", __func__));
4973 return VOS_STATUS_E_FAILURE;
4974 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004975
4976 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
4977 "WLAN TL:Attempting to cache pkt for STA %d, BD DPU Sig: %d with sig UC: %d, BC: %d",
4978 ucSTAId, uDPUSig,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304979 pClientSTA->wSTADesc.ucUcastSig,
4980 pClientSTA->wSTADesc.ucBcastSig));
Jeff Johnson295189b2012-06-20 16:38:30 -07004981
4982 if(WLANTL_IS_CTRL_FRAME(ucFrmType))
4983 {
4984 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
4985 "WLAN TL: No need to cache CTRL frame. Dropping"));
4986 vos_pkt_return_packet(vosTempBuff);
4987 return VOS_STATUS_SUCCESS;
4988 }
4989
4990 /*-------------------------------------------------------------------------
4991 Check if the packet that we are trying to cache belongs to the old
4992 registered station (if any) or the new (potentially)upcoming station
4993
4994 - If the STA with this Id was never registered with TL - the signature
4995 will be invalid;
4996 - If the STA was previously registered TL will have cached the former
4997 set of DPU signatures
4998 -------------------------------------------------------------------------*/
4999 if ( bBcast )
5000 {
5001 ucBcastSig = (v_U8_t)uDPUSig;
5002 bOldSTAPkt = (( WLAN_TL_INVALID_B_SIG !=
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05305003 pClientSTA->wSTADesc.ucBcastSig ) &&
5004 ( ucBcastSig == pClientSTA->wSTADesc.ucBcastSig ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005005 }
5006 else
5007 {
5008 ucUcastSig = (v_U8_t)uDPUSig;
5009 bOldSTAPkt = (( WLAN_TL_INVALID_U_SIG !=
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05305010 pClientSTA->wSTADesc.ucUcastSig ) &&
5011 ( ucUcastSig == pClientSTA->wSTADesc.ucUcastSig ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005012 }
5013
5014 /*------------------------------------------------------------------------
5015 If the value of the DPU SIG matches the old, this packet will not
5016 be cached as it belonged to the former association
5017 In case the SIG does not match - this is a packet for a potentially new
5018 associated station
5019 -------------------------------------------------------------------------*/
Varun Reddy Yeturua39b9902013-01-18 15:48:32 -08005020 if ( bOldSTAPkt || bBcast )
Jeff Johnson295189b2012-06-20 16:38:30 -07005021 {
5022 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
5023 "WLAN TL:Data packet matches old sig for sig DPU: %d UC: %d, "
5024 "BC: %d - dropping",
5025 uDPUSig,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05305026 pClientSTA->wSTADesc.ucUcastSig,
5027 pClientSTA->wSTADesc.ucBcastSig));
Jeff Johnson295189b2012-06-20 16:38:30 -07005028 vos_pkt_return_packet(vosTempBuff);
5029 }
5030 else
5031 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05305032 if ( NULL == pClientSTA->vosBegCachedFrame )
Jeff Johnson295189b2012-06-20 16:38:30 -07005033 {
5034 /*this is the first frame that we are caching */
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05305035 pClientSTA->vosBegCachedFrame = vosTempBuff;
Mihir Sheteb7337272014-04-11 15:53:08 +05305036
5037 pClientSTA->tlCacheInfo.cacheInitTime = vos_timer_get_system_time();
5038 pClientSTA->tlCacheInfo.cacheDoneTime =
5039 pClientSTA->tlCacheInfo.cacheInitTime;
5040 pClientSTA->tlCacheInfo.cacheSize = 1;
5041
Mihir Sheteae6f02b2014-04-11 19:49:21 +05305042 MTRACE(vos_trace(VOS_MODULE_ID_TL, TRACE_CODE_TL_CACHE_FRAME,
5043 ucSTAId, pClientSTA->tlCacheInfo.cacheSize));
5044
Jeff Johnson295189b2012-06-20 16:38:30 -07005045 }
5046 else
5047 {
5048 /*this is a subsequent frame that we are caching: chain to the end */
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05305049 vos_pkt_chain_packet(pClientSTA->vosEndCachedFrame,
Jeff Johnson295189b2012-06-20 16:38:30 -07005050 vosTempBuff, VOS_TRUE);
Mihir Sheteb7337272014-04-11 15:53:08 +05305051
5052 pClientSTA->tlCacheInfo.cacheDoneTime = vos_timer_get_system_time();
5053 pClientSTA->tlCacheInfo.cacheSize ++;
5054
5055 if (pClientSTA->tlCacheInfo.cacheSize % WLANTL_CACHE_TRACE_WATERMARK == 0)
5056 {
5057 VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
5058 "%s: Cache High watermark for staid:%d (%d)",
5059 __func__,ucSTAId, pClientSTA->tlCacheInfo.cacheSize);
Mihir Sheteae6f02b2014-04-11 19:49:21 +05305060 MTRACE(vos_trace(VOS_MODULE_ID_TL, TRACE_CODE_TL_CACHE_FRAME,
5061 ucSTAId, pClientSTA->tlCacheInfo.cacheSize));
Mihir Sheteb7337272014-04-11 15:53:08 +05305062 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005063 }
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05305064 pClientSTA->vosEndCachedFrame = vosTempBuff;
Jeff Johnson295189b2012-06-20 16:38:30 -07005065 }/*else new packet*/
5066
5067 return VOS_STATUS_SUCCESS;
5068}/*WLANTL_CacheSTAFrame*/
5069
5070/*==========================================================================
5071
5072 FUNCTION WLANTL_FlushCachedFrames
5073
5074 DESCRIPTION
5075 Internal utility function used by TL to flush the station cache
5076
5077 DEPENDENCIES
5078 TL must be initiailized before this function gets called.
5079
5080 PARAMETERS
5081
5082 IN
5083
5084 vosDataBuff: it will contain a pointer to the first cached buffer
5085 received,
5086
5087 RETURN VALUE
5088 The result code associated with performing the operation
5089
5090 VOS_STATUS_SUCCESS: Everything is good :)
5091
5092 SIDE EFFECTS
5093
5094 NOTE
5095 This function doesn't re-initialize vosDataBuff to NULL. It's caller's
5096 responsibility to do so, if required, after this function call.
5097 Because of this restriction, we decide to make this function to static
5098 so that upper layer doesn't need to be aware of this restriction.
5099
5100============================================================================*/
5101static VOS_STATUS
5102WLANTL_FlushCachedFrames
5103(
5104 vos_pkt_t* vosDataBuff
5105)
5106{
5107 /*----------------------------------------------------------------------
5108 Return the entire chain to vos if there are indeed cache frames
5109 ----------------------------------------------------------------------*/
5110 if ( NULL != vosDataBuff )
5111 {
5112 vos_pkt_return_packet(vosDataBuff);
5113 }
5114
5115 return VOS_STATUS_SUCCESS;
5116}/*WLANTL_FlushCachedFrames*/
5117
5118/*==========================================================================
5119
5120 FUNCTION WLANTL_ForwardSTAFrames
5121
5122 DESCRIPTION
5123 Internal utility function for either forwarding cached data to the station after
5124 the station has been registered, or flushing cached data if the station has not
5125 been registered.
5126
5127
5128 DEPENDENCIES
5129 TL must be initiailized before this function gets called.
5130
5131 PARAMETERS
5132
5133 IN
5134
5135 pTLCb: TL control block
5136 ucSTAId: station id
5137
5138 RETURN VALUE
5139 The result code associated with performing the operation
5140
5141 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
5142 page fault
5143 VOS_STATUS_SUCCESS: Everything is good :)
5144
5145 SIDE EFFECTS
5146 This function doesn't re-initialize vosDataBuff to NULL. It's caller's
5147 responsibility to do so, if required, after this function call.
5148 Because of this restriction, we decide to make this function to static
5149 so that upper layer doesn't need to be aware of this restriction.
5150
5151============================================================================*/
5152static VOS_STATUS
5153WLANTL_ForwardSTAFrames
5154(
5155 void* pvosGCtx,
5156 v_U8_t ucSTAId,
5157 v_U8_t ucUcastSig,
5158 v_U8_t ucBcastSig
5159)
5160{
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05305161 WLANTL_CbType* pTLCb = NULL;
5162 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005163 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
5164
5165 /*-------------------------------------------------------------------------
5166 Sanity check
5167 -------------------------------------------------------------------------*/
5168 pTLCb = VOS_GET_TL_CB(pvosGCtx);
5169 if ( NULL == pTLCb )
5170 {
5171 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05305172 "WLAN TL: Invalid input pointer on WLANTL_ForwardSTAFrames TL %p",
Jeff Johnson295189b2012-06-20 16:38:30 -07005173 pTLCb ));
5174 return VOS_STATUS_E_FAULT;
5175 }
5176
5177 if ( WLANTL_STA_ID_INVALID( ucSTAId ) )
5178 {
5179 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
5180 "WLAN TL:Invalid station id requested on WLANTL_ForwardSTAFrames"));
5181 return VOS_STATUS_E_FAULT;
5182 }
5183
5184 //WLAN_TL_LOCK_STA_CACHE(pTLCb->atlSTAClients[ucSTAId]);
5185
5186 /*------------------------------------------------------------------------
5187 Check if station has not been registered in the mean while
5188 if not registered, flush cached frames.
5189 ------------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05305190 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
5191
5192 if ( NULL == pClientSTA )
5193 {
5194 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
5195 "WLAN TL:Client Memory was not allocated on %s", __func__));
5196 return VOS_STATUS_E_FAILURE;
5197 }
5198
5199 if ( 0 == pClientSTA->ucExists )
Jeff Johnson295189b2012-06-20 16:38:30 -07005200 {
5201 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
5202 "WLAN TL:Station has been deleted for STA %d - flushing cache", ucSTAId));
Mihir Sheteae6f02b2014-04-11 19:49:21 +05305203 MTRACE(vos_trace(VOS_MODULE_ID_TL, TRACE_CODE_TL_FLUSH_CACHED_FRAMES,
5204 ucSTAId, pClientSTA->tlCacheInfo.cacheSize));
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05305205 WLANTL_FlushCachedFrames(pClientSTA->vosBegCachedFrame);
Jeff Johnson295189b2012-06-20 16:38:30 -07005206 goto done;
5207 }
5208
5209 /*------------------------------------------------------------------------
5210 Forwarding cache frames received while the station was in the process
5211 of being registered with the rest of the SW components
5212
5213 Access to the cache must be locked; similarly updating the signature and
5214 the existence flag must be synchronized because these values are checked
5215 during cached
5216 ------------------------------------------------------------------------*/
5217 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
5218 "WLAN TL:Preparing to fwd packets for STA %d", ucSTAId));
5219
5220 /*-----------------------------------------------------------------------
5221 Save the new signature values
5222 ------------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05305223 pClientSTA->wSTADesc.ucUcastSig = ucUcastSig;
5224 pClientSTA->wSTADesc.ucBcastSig = ucBcastSig;
Jeff Johnson295189b2012-06-20 16:38:30 -07005225
5226 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
5227 "WLAN TL:Fwd-ing packets for STA %d UC %d BC %d",
5228 ucSTAId, ucUcastSig, ucBcastSig));
5229
5230 /*-------------------------------------------------------------------------
5231 Check to see if we have any cached data to forward
5232 -------------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05305233 if ( NULL != pClientSTA->vosBegCachedFrame )
Jeff Johnson295189b2012-06-20 16:38:30 -07005234 {
5235 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
5236 "WLAN TL: Fwd-ing Cached packets for station %d", ucSTAId ));
5237
5238 WLANTL_RxCachedFrames( pTLCb,
5239 ucSTAId,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05305240 pClientSTA->vosBegCachedFrame);
Jeff Johnson295189b2012-06-20 16:38:30 -07005241 }
5242 else
5243 {
5244 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
5245 "WLAN TL: NO cached packets for station %d", ucSTAId ));
5246 }
5247
5248done:
5249 /*-------------------------------------------------------------------------
5250 Clear the station cache
5251 -------------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05305252 pClientSTA->vosBegCachedFrame = NULL;
5253 pClientSTA->vosEndCachedFrame = NULL;
Mihir Sheteb7337272014-04-11 15:53:08 +05305254 pClientSTA->tlCacheInfo.cacheSize = 0;
5255 pClientSTA->tlCacheInfo.cacheClearTime = vos_timer_get_system_time();
Jeff Johnson295189b2012-06-20 16:38:30 -07005256
5257 /*-----------------------------------------------------------------------
5258 After all the init is complete we can mark the existance flag
5259 ----------------------------------------------------------------------*/
Katya Nigam63902932014-06-26 19:04:23 +05305260 pClientSTA->enableCaching = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005261
5262 //WLAN_TL_UNLOCK_STA_CACHE(pTLCb->atlSTAClients[ucSTAId]);
5263 return VOS_STATUS_SUCCESS;
5264
5265}/*WLANTL_ForwardSTAFrames*/
5266
5267
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005268#if defined(FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_ESE_UPLOAD)
Jeff Johnson295189b2012-06-20 16:38:30 -07005269/*==========================================================================
5270
5271 FUNCTION WLANTL_IsIAPPFrame
5272
5273 DESCRIPTION
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005274 Internal utility function for detecting incoming ESE IAPP frames
Jeff Johnson295189b2012-06-20 16:38:30 -07005275
5276 DEPENDENCIES
5277
5278 PARAMETERS
5279
5280 IN
5281
5282 pvBDHeader: pointer to the BD header
5283 vosTempBuff: the data packet
5284
5285 IN/OUT
5286 pFirstDataPktArrived: static from caller function; used for rssi
5287 computation
5288 RETURN VALUE
5289 The result code associated with performing the operation
5290
5291 VOS_TRUE: It is a IAPP frame
5292 VOS_FALSE: It is NOT IAPP frame
5293
5294 SIDE EFFECTS
5295
5296============================================================================*/
5297v_BOOL_t
5298WLANTL_IsIAPPFrame
5299(
5300 v_PVOID_t pvBDHeader,
5301 vos_pkt_t* vosTempBuff
5302)
5303{
5304 v_U16_t usMPDUDOffset;
5305 v_U8_t ucOffset;
5306 v_U8_t ucSnapHdr[WLANTL_LLC_SNAP_SIZE];
5307 v_SIZE_t usSnapHdrSize = WLANTL_LLC_SNAP_SIZE;
5308 VOS_STATUS vosStatus;
5309
5310 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
5311
5312 /*------------------------------------------------------------------------
5313 Check if OUI field is present.
5314 -------------------------------------------------------------------------*/
5315 if ( VOS_FALSE == WDA_IS_RX_LLC_PRESENT(pvBDHeader) )
5316 {
5317 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
5318 "WLAN TL:LLC header removed, cannot determine BT-AMP type -"
5319 "dropping pkt"));
5320 /* Drop packet */
5321 vos_pkt_return_packet(vosTempBuff);
5322 return VOS_TRUE;
5323 }
5324 usMPDUDOffset = (v_U8_t)WDA_GET_RX_MPDU_DATA_OFFSET(pvBDHeader);
5325 ucOffset = (v_U8_t)usMPDUDOffset + WLANTL_LLC_SNAP_OFFSET;
5326
5327 vosStatus = vos_pkt_extract_data( vosTempBuff, ucOffset,
5328 (v_PVOID_t)ucSnapHdr, &usSnapHdrSize);
5329
5330 if (( VOS_STATUS_SUCCESS != vosStatus))
5331 {
5332 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
5333 "Unable to extract Snap Hdr of data packet -"
5334 "dropping pkt"));
5335 return VOS_FALSE;
5336 }
5337
5338 /*------------------------------------------------------------------------
5339 Check if this is IAPP frame by matching Aironet Snap hdr.
5340 -------------------------------------------------------------------------*/
5341 // Compare returns 1 if values are same and 0
5342 // if not the same.
5343 if (( WLANTL_LLC_SNAP_SIZE != usSnapHdrSize ) ||
5344 ( 0 == vos_mem_compare(ucSnapHdr, (v_PVOID_t)WLANTL_AIRONET_SNAP_HEADER,
5345 WLANTL_LLC_SNAP_SIZE ) ))
5346 {
5347 return VOS_FALSE;
5348 }
5349
5350 return VOS_TRUE;
5351
5352}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005353#endif //FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07005354
5355/*==========================================================================
5356
5357 FUNCTION WLANTL_ProcessBAPFrame
5358
5359 DESCRIPTION
5360 Internal utility function for processing incoming BT-AMP frames
5361
5362 DEPENDENCIES
5363 TL must be initiailized before this function gets called.
5364 Bothe the BT-AMP station and the BAP Ctrl path must have been previously
5365 registered with TL.
5366
5367 PARAMETERS
5368
5369 IN
5370
5371 pvBDHeader: pointer to the BD header
5372 vosTempBuff: the data packet
5373 pTLCb: TL control block
5374 ucSTAId: station id
5375
5376 IN/OUT
5377 pFirstDataPktArrived: static from caller function; used for rssi
5378 computation
5379 RETURN VALUE
5380 The result code associated with performing the operation
5381
5382 VOS_STATUS_E_INVAL: Input parameters are invalid
5383 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
5384 page fault
5385 VOS_STATUS_SUCCESS: Everything is good :)
5386
5387 SIDE EFFECTS
5388
5389============================================================================*/
5390v_BOOL_t
5391WLANTL_ProcessBAPFrame
5392(
5393 v_PVOID_t pvBDHeader,
5394 vos_pkt_t* vosTempBuff,
5395 WLANTL_CbType* pTLCb,
5396 v_U8_t* pFirstDataPktArrived,
5397 v_U8_t ucSTAId
5398)
5399{
5400 v_U16_t usMPDUDOffset;
5401 v_U8_t ucOffset;
5402 v_U8_t ucOUI[WLANTL_LLC_OUI_SIZE];
5403 v_SIZE_t usOUISize = WLANTL_LLC_OUI_SIZE;
5404 VOS_STATUS vosStatus;
5405 v_U16_t usType;
5406 v_SIZE_t usTypeLen = sizeof(usType);
5407 v_U8_t ucMPDUHOffset;
5408 v_U8_t ucMPDUHLen = 0;
5409 v_U16_t usActualHLen = 0;
5410
5411 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
5412
5413 /*------------------------------------------------------------------------
5414 Extract OUI and type from LLC and validate; if non-data send to BAP
5415 -------------------------------------------------------------------------*/
5416 if ( VOS_FALSE == WDA_IS_RX_LLC_PRESENT(pvBDHeader) )
5417 {
5418 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
5419 "WLAN TL:LLC header removed, cannot determine BT-AMP type -"
5420 "dropping pkt"));
5421 /* Drop packet */
5422 vos_pkt_return_packet(vosTempBuff);
5423 return VOS_TRUE;
5424 }
5425
5426 usMPDUDOffset = (v_U8_t)WDA_GET_RX_MPDU_DATA_OFFSET(pvBDHeader);
5427 ucMPDUHOffset = (v_U8_t)WDA_GET_RX_MPDU_HEADER_OFFSET(pvBDHeader);
5428 ucMPDUHLen = (v_U8_t)WDA_GET_RX_MPDU_HEADER_LEN(pvBDHeader);
5429 ucOffset = (v_U8_t)usMPDUDOffset + WLANTL_LLC_OUI_OFFSET;
5430
5431 vosStatus = vos_pkt_extract_data( vosTempBuff, ucOffset,
5432 (v_PVOID_t)ucOUI, &usOUISize);
5433
5434#if 0
5435 // Compare returns 1 if values are same and 0
5436 // if not the same.
5437 if (( WLANTL_LLC_OUI_SIZE != usOUISize ) ||
5438 ( 0 == vos_mem_compare(ucOUI, (v_PVOID_t)WLANTL_BT_AMP_OUI,
5439 WLANTL_LLC_OUI_SIZE ) ))
5440 {
5441 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
5442 "LLC header points to diff OUI in BT-AMP station -"
5443 "dropping pkt"));
5444 /* Drop packet */
5445 vos_pkt_return_packet(vosTempBuff);
5446 return VOS_TRUE;
5447 }
5448#endif
5449 /*------------------------------------------------------------------------
5450 Extract LLC OUI and ensure that this is indeed a BT-AMP frame
5451 ------------------------------------------------------------------------*/
5452 vosStatus = vos_pkt_extract_data( vosTempBuff,
5453 ucOffset + WLANTL_LLC_OUI_SIZE,
5454 (v_PVOID_t)&usType, &usTypeLen);
5455
5456 if (( VOS_STATUS_SUCCESS != vosStatus) ||
5457 ( sizeof(usType) != usTypeLen ))
5458 {
5459 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
5460 "Unable to extract type on incoming BAP packet -"
5461 "dropping pkt"));
5462 /* Drop packet */
5463 vos_pkt_return_packet(vosTempBuff);
5464 return VOS_TRUE;
5465 }
5466
5467 /*------------------------------------------------------------------------
5468 Check if this is BT-AMP data or ctrl packet(RSN, LinkSvision, ActivityR)
5469 ------------------------------------------------------------------------*/
5470 usType = vos_be16_to_cpu(usType);
5471
5472 if (WLANTL_BAP_IS_NON_DATA_PKT_TYPE(usType))
5473 {
5474 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
5475 "WLAN TL:Non-data packet received over BT-AMP link: %d, => BAP",
5476 usType));
5477
5478 /*Flatten packet as BAP expects to be able to peek*/
5479 if ( VOS_STATUS_SUCCESS != vos_pkt_flatten_rx_pkt(&vosTempBuff))
5480 {
5481 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
5482 "WLAN TL:Cannot flatten BT-AMP packet - dropping"));
5483 /* Drop packet */
5484 vos_pkt_return_packet(vosTempBuff);
5485 return VOS_TRUE;
5486 }
5487
5488 /* Send packet to BAP client*/
Jeff Johnson295189b2012-06-20 16:38:30 -07005489 if ( VOS_STATUS_SUCCESS != WDA_DS_TrimRxPacketInfo( vosTempBuff ) )
5490 {
5491 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
5492 "WLAN TL:BD header corrupted - dropping packet"));
5493 /* Drop packet */
5494 vos_pkt_return_packet(vosTempBuff);
5495 return VOS_TRUE;
5496 }
5497
5498 if ( 0 == WDA_GET_RX_FT_DONE(pvBDHeader) )
5499 {
5500 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
5501 "Non-data packet received over BT-AMP link: Sending it for "
5502 "frame Translation"));
5503
5504 if (usMPDUDOffset > ucMPDUHOffset)
5505 {
5506 usActualHLen = usMPDUDOffset - ucMPDUHOffset;
5507 }
5508
5509 /* software frame translation for BTAMP WDS.*/
5510 WLANTL_Translate80211To8023Header( vosTempBuff, &vosStatus, usActualHLen,
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005511 ucMPDUHLen, pTLCb,ucSTAId, VOS_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07005512
5513 }
5514 if (pTLCb->tlBAPClient.pfnTlBAPRx)
5515 pTLCb->tlBAPClient.pfnTlBAPRx( vos_get_global_context(VOS_MODULE_ID_TL,pTLCb),
5516 vosTempBuff,
5517 (WLANTL_BAPFrameEnumType)usType );
Manjunathappa Prakashfb585462013-12-23 19:07:07 -08005518 else
5519 {
5520 VOS_ASSERT(0);
5521 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005522
5523 return VOS_TRUE;
5524 }
5525 else
5526 {
5527 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
5528 "WLAN TL: BAP DATA packet received over BT-AMP link: %d, => BAP",
5529 usType));
5530 /*!!!FIX ME!!*/
5531 #if 0
5532 /*--------------------------------------------------------------------
5533 For data packet collect phy stats RSSI and Link Quality
5534 Calculate the RSSI average and save it. Continuous average is done.
5535 --------------------------------------------------------------------*/
5536 if ( *pFirstDataPktArrived == 0)
5537 {
5538 pTLCb->atlSTAClients[ucSTAId].rssiAvg =
5539 WLANHAL_GET_RSSI_AVERAGE( pvBDHeader );
5540 pTLCb->atlSTAClients[ucSTAId].uLinkQualityAvg =
5541 WLANHAL_RX_BD_GET_SNR( pvBDHeader );
5542
5543 // Rcvd 1st pkt, start average from next time
5544 *pFirstDataPktArrived = 1;
5545 }
5546 else
5547 {
5548 pTLCb->atlSTAClients[ucSTAId].rssiAvg =
5549 (WLANHAL_GET_RSSI_AVERAGE( pvBDHeader ) +
5550 pTLCb->atlSTAClients[ucSTAId].rssiAvg)/2;
5551 pTLCb->atlSTAClients[ucSTAId].uLinkQualityAvg =
5552 (WLANHAL_RX_BD_GET_SNR( pvBDHeader ) +
5553 pTLCb->atlSTAClients[ucSTAId].uLinkQualityAvg)/2;
5554 }/*Else, first data packet*/
5555 #endif
5556 }/*BT-AMP data packet*/
5557
5558 return VOS_FALSE;
5559}/*WLANTL_ProcessBAPFrame*/
5560
Jeff Johnson295189b2012-06-20 16:38:30 -07005561
5562/*==========================================================================
5563
5564 FUNCTION WLANTL_ProcessFCFrame
5565
5566 DESCRIPTION
5567 Internal utility function for processing incoming Flow Control frames. Enable
5568 or disable LWM mode based on the information.
5569
5570 DEPENDENCIES
5571 TL must be initiailized before this function gets called.
5572 FW sends up special flow control frame.
5573
5574 PARAMETERS
5575
5576 IN
5577 pvosGCtx pointer to vos global context
5578 pvBDHeader: pointer to the BD header
5579 pTLCb: TL control block
5580 pvBDHeader pointer to BD header.
5581
5582 IN/OUT
5583 pFirstDataPktArrived: static from caller function; used for rssi
5584 computation
5585 RETURN VALUE
5586 The result code associated with performing the operation
5587
5588 VOS_STATUS_E_INVAL: Input frame are invalid
5589 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
5590 page fault
5591 VOS_STATUS_SUCCESS: Everything is good :)
5592
5593 SIDE EFFECTS
5594 The ingress and egress of each station will be updated. If needed, LWM mode will
5595 be enabled or disabled based on the flow control algorithm.
5596
5597============================================================================*/
5598v_BOOL_t
5599WLANTL_ProcessFCFrame
5600(
5601 v_PVOID_t pvosGCtx,
5602 vos_pkt_t* pvosDataBuff,
5603 v_PVOID_t pvBDHeader
5604)
5605{
5606#if 1 //enable processing of only fcStaTxDisabled bitmap for now. the else part is old better qos code.
5607 // need to revisit the old code for full implementation.
Hoonki Lee14621352013-04-16 17:51:19 -07005608 v_U8_t ucSTAId;
5609 v_U16_t ucStaValidBitmap;
5610 v_U16_t ucStaTxDisabledBitmap;
5611 WLANTL_CbType* pTLCb = NULL;
5612 #ifdef TL_DEBUG_FC
5613 v_U32_t rxTimeStamp;
5614 v_U32_t curTick;
5615 #endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005616 /*------------------------------------------------------------------------
Hoonki Lee14621352013-04-16 17:51:19 -07005617 Extract TL control block
Jeff Johnson295189b2012-06-20 16:38:30 -07005618 ------------------------------------------------------------------------*/
5619 pTLCb = VOS_GET_TL_CB(pvosGCtx);
5620 if ( NULL == pTLCb )
5621 {
5622 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
5623 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_SuspendDataTx"));
5624 return VOS_STATUS_E_FAULT;
5625 }
Hoonki Lee14621352013-04-16 17:51:19 -07005626 ucStaValidBitmap = WDA_GET_RX_FC_VALID_STA_MASK(pvBDHeader);
5627 ucStaTxDisabledBitmap = WDA_GET_RX_FC_STA_TX_DISABLED_BITMAP(pvBDHeader);
5628#ifdef TL_DEBUG_FC
5629 rxTimeStamp = WDA_GET_RX_TIMESTAMP(pvBDHeader);
5630 /* hard code of MTU_GLOBAL_TIMER_ADDR to calculate the time between generated and processed */
5631 wpalReadRegister(0x03081400+0x1D4, &curTick);
Jeff Johnson295189b2012-06-20 16:38:30 -07005632
Jeff Johnson295189b2012-06-20 16:38:30 -07005633 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Arif Hussainf2b00992013-11-17 21:46:15 -08005634 "%ld (%ld-%ld): Disabled %x Valid %x", curTick > rxTimeStamp ? curTick - rxTimeStamp : rxTimeStamp - (0xFFFFFFFF - curTick),
Hoonki Lee14621352013-04-16 17:51:19 -07005635 curTick, rxTimeStamp, ucStaTxDisabledBitmap, ucStaValidBitmap));
5636#endif
5637 for(ucSTAId = 0; ucStaValidBitmap != 0; ucStaValidBitmap >>=1, ucStaTxDisabledBitmap >>= 1, ucSTAId ++)
Jeff Johnson295189b2012-06-20 16:38:30 -07005638 {
Hoonki Lee14621352013-04-16 17:51:19 -07005639 if ( (0 == (ucStaValidBitmap & 0x1)) || (pTLCb->atlSTAClients[ucSTAId] && (0 == pTLCb->atlSTAClients[ucSTAId]->ucExists)) )
5640 continue;
5641
5642 if (ucStaTxDisabledBitmap & 0x1)
5643 {
5644 WLANTL_SuspendDataTx(pvosGCtx, &ucSTAId, NULL);
5645 }
5646 else
5647 {
5648 WLANTL_ResumeDataTx(pvosGCtx, &ucSTAId);
5649 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005650 }
5651
5652#else
5653 VOS_STATUS vosStatus;
5654 tpHalFcRxBd pvFcRxBd = NULL;
5655 v_U8_t ucBitCheck = 0x1;
5656 v_U8_t ucStaValid = 0;
5657 v_U8_t ucSTAId = 0;
5658
5659 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
5660 "Received FC Response");
5661 if ( (NULL == pTLCb) || (NULL == pvosDataBuff))
5662 {
5663 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Arif Hussainf2b00992013-11-17 21:46:15 -08005664 "WLAN TL:Invalid pointer in %s", __func__));
Jeff Johnson295189b2012-06-20 16:38:30 -07005665 return VOS_STATUS_E_FAULT;
5666 }
5667 vosStatus = vos_pkt_peek_data( pvosDataBuff, 0, (v_PVOID_t)&pvFcRxBd,
5668 sizeof(tHalFcRxBd));
5669
5670 if ( (VOS_STATUS_SUCCESS != vosStatus) || (NULL == pvFcRxBd) )
5671 {
5672 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
5673 "WLAN TL:wrong FC Rx packet"));
5674 return VOS_STATUS_E_INVAL;
5675 }
5676
5677 // need to swap bytes in the FC contents.
5678 WLANHAL_SwapFcRxBd(&pvFcRxBd->fcSTATxQLen[0]);
5679
5680 //logic to enable/disable LWM mode for each station
5681 for( ucStaValid = (v_U8_t)pvFcRxBd->fcSTAValidMask; ucStaValid; ucStaValid >>= 1, ucBitCheck <<= 1, ucSTAId ++)
5682 {
5683 if ( (0 == (ucStaValid & 0x1)) || (0 == pTLCb->atlSTAClients[ucSTAId].ucExists) )
5684 {
5685 continue;
5686 }
5687
5688 if ( pvFcRxBd->fcSTAThreshIndMask & ucBitCheck )
5689 {
5690 //LWM event is reported by FW. Able to fetch more packet
5691 if( pTLCb->atlSTAClients[ucSTAId].ucLwmModeEnabled )
5692 {
5693 //Now memory usage is below LWM. Station can send more packets.
5694 pTLCb->atlSTAClients[ucSTAId].ucLwmEventReported = TRUE;
5695 }
5696 else
5697 {
5698 TLLOG4(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_LOW,
Arif Hussainf2b00992013-11-17 21:46:15 -08005699 "WLAN TL: FW report LWM event but the station %d is not in LWM mode", ucSTAId));
Jeff Johnson295189b2012-06-20 16:38:30 -07005700 }
5701 }
5702
5703 //calculate uEgress_length/uIngress_length only after receiving enough packets
5704 if (WLANTL_LWM_INGRESS_SAMPLE_THRESHOLD <= pTLCb->atlSTAClients[ucSTAId].uIngress_length)
5705 {
5706 //check memory usage info to see whether LWM mode should be enabled for the station
5707 v_U32_t uEgress_length = pTLCb->atlSTAClients[ucSTAId].uIngress_length +
5708 pTLCb->atlSTAClients[ucSTAId].bmuMemConsumed - pvFcRxBd->fcSTATxQLen[ucSTAId];
5709
5710 //if ((float)uEgress_length/(float)pTLCb->atlSTAClients[ucSTAId].uIngress_length
5711 // <= WLANTL_LWM_EGRESS_INGRESS_THRESHOLD)
5712 if ( (pTLCb->atlSTAClients[ucSTAId].uIngress_length > uEgress_length) &&
5713 ((pTLCb->atlSTAClients[ucSTAId].uIngress_length - uEgress_length ) >=
5714 (pTLCb->atlSTAClients[ucSTAId].uIngress_length >> 2))
5715 )
5716 {
5717 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
Arif Hussainf2b00992013-11-17 21:46:15 -08005718 "WLAN TL:Enable LWM mode for station %d", ucSTAId));
Jeff Johnson295189b2012-06-20 16:38:30 -07005719 pTLCb->atlSTAClients[ucSTAId].ucLwmModeEnabled = TRUE;
5720 }
5721 else
5722 {
5723 if( pTLCb->atlSTAClients[ucSTAId].ucLwmModeEnabled )
5724 {
5725 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
Arif Hussainf2b00992013-11-17 21:46:15 -08005726 "WLAN TL:Disable LWM mode for station %d", ucSTAId));
Jeff Johnson295189b2012-06-20 16:38:30 -07005727 pTLCb->atlSTAClients[ucSTAId].ucLwmModeEnabled = FALSE;
5728 }
5729
5730 }
5731
5732 //remember memory usage in FW starting from this round
5733 pTLCb->atlSTAClients[ucSTAId].bmuMemConsumed = pvFcRxBd->fcSTATxQLen[ucSTAId];
5734 pTLCb->atlSTAClients[ucSTAId].uIngress_length = 0;
5735 } //(WLANTL_LWM_INGRESS_SAMPLE_THRESHOLD <= pTLCb->atlSTAClients[ucSTAId].uIngress_length)
5736
5737 if( pTLCb->atlSTAClients[ucSTAId].ucLwmModeEnabled )
5738 {
5739 //always update current maximum allowed memeory usage
5740 pTLCb->atlSTAClients[ucSTAId].uBuffThresholdMax = WLANTL_STA_BMU_THRESHOLD_MAX -
5741 pvFcRxBd->fcSTATxQLen[ucSTAId];
5742 }
5743
5744 }
5745#endif
5746
5747 return VOS_STATUS_SUCCESS;
5748}
Jeff Johnson295189b2012-06-20 16:38:30 -07005749
5750
5751/*==========================================================================
5752
5753 FUNCTION WLANTL_RxFrames
5754
5755 DESCRIPTION
5756 Callback registered by TL and called by BAL when a packet is received
5757 over the bus. Upon the call of this function TL will make the necessary
5758 decision with regards to the forwarding or queuing of this packet and
5759 the layer it needs to be delivered to.
5760
5761 DEPENDENCIES
5762 TL must be initiailized before this function gets called.
5763 If the frame carried is a data frame then the station for which it is
5764 destined to must have been previously registered with TL.
5765
5766 PARAMETERS
5767
5768 IN
5769 pvosGCtx: pointer to the global vos context; a handle to TL's
5770 or BAL's control block can be extracted from its context
5771
5772 vosDataBuff: it will contain a pointer to the first buffer received,
5773 if there is more then one packet they will be chained
5774 using vOSS buffers.
5775
5776 RETURN VALUE
5777 The result code associated with performing the operation
5778
5779 VOS_STATUS_E_INVAL: Input parameters are invalid
5780 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
5781 page fault
5782 VOS_STATUS_SUCCESS: Everything is good :)
5783
5784 SIDE EFFECTS
5785
5786============================================================================*/
5787VOS_STATUS
5788WLANTL_RxFrames
5789(
5790 v_PVOID_t pvosGCtx,
5791 vos_pkt_t *pFrameDataBuff
5792)
5793{
5794 vos_pkt_t* vosDataBuff = (vos_pkt_t*)pFrameDataBuff;
5795 WLANTL_CbType* pTLCb = NULL;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05305796 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005797 WLANTL_STAFuncType pfnSTAFsm;
5798 vos_pkt_t* vosTempBuff;
5799 v_U8_t ucSTAId;
5800 VOS_STATUS vosStatus;
5801 v_U8_t ucFrmType;
5802 v_PVOID_t pvBDHeader = NULL;
5803 WLANTL_STAEventType wSTAEvent = WLANTL_RX_EVENT;
5804 v_U8_t ucTid = 0;
5805 v_BOOL_t broadcast = VOS_FALSE;
5806 v_BOOL_t selfBcastLoopback = VOS_FALSE;
Madan Mohan Koyyalamudidfd6aa82012-10-18 20:18:43 -07005807 static v_U8_t first_data_pkt_arrived;
Jeff Johnson295189b2012-06-20 16:38:30 -07005808 v_U32_t uDPUSig;
Jeff Johnson295189b2012-06-20 16:38:30 -07005809 v_U16_t usPktLen;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08005810#ifdef FEATURE_WLAN_TDLS_INTERNAL
5811 v_U8_t ucMPDUHLen = 0 ;
5812 v_U16_t usEtherType = 0;
5813#endif
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005814 v_BOOL_t bForwardIAPPwithLLC = VOS_FALSE;
Dino Mycle3b9536d2014-07-09 22:05:24 +05305815#ifdef WLAN_FEATURE_LINK_LAYER_STATS
5816 v_S7_t currentAvgRSSI = 0;
5817 v_U8_t ac;
5818
5819#endif
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005820
Jeff Johnson295189b2012-06-20 16:38:30 -07005821 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
5822
5823 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
5824 "WLAN TL:TL Receive Frames called"));
5825
5826 /*------------------------------------------------------------------------
5827 Sanity check
5828 ------------------------------------------------------------------------*/
5829 if ( NULL == vosDataBuff )
5830 {
5831 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
5832 "WLAN TL:Invalid parameter sent on WLANTL_RxFrames"));
5833 return VOS_STATUS_E_INVAL;
5834 }
5835
Katya Nigam3802f202013-12-16 19:27:14 +05305836 /*------------------------------------------------------------------------
5837 Popolaute timestamp as the time when packet arrives
5838 ---------------------------------------------------------------------- */
5839 vosDataBuff->timestamp = vos_timer_get_system_ticks();
5840
Jeff Johnson295189b2012-06-20 16:38:30 -07005841 /*------------------------------------------------------------------------
5842 Extract TL control block
5843 ------------------------------------------------------------------------*/
5844 pTLCb = VOS_GET_TL_CB(pvosGCtx);
5845 if ( NULL == pTLCb )
5846 {
5847 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
5848 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_ChangeSTAState"));
5849 return VOS_STATUS_E_FAULT;
5850 }
5851
5852 /*---------------------------------------------------------------------
5853 Save the initial buffer - this is the first received buffer
5854 ---------------------------------------------------------------------*/
5855 vosTempBuff = vosDataBuff;
5856
5857 while ( NULL != vosTempBuff )
5858 {
Madan Mohan Koyyalamudia148e1e2012-11-30 14:52:59 -08005859 broadcast = VOS_FALSE;
5860 selfBcastLoopback = VOS_FALSE;
5861
Jeff Johnson295189b2012-06-20 16:38:30 -07005862 vos_pkt_walk_packet_chain( vosDataBuff, &vosDataBuff, 1/*true*/ );
5863
5864 /*---------------------------------------------------------------------
5865 Peek at BD header - do not remove
5866 !!! Optimize me: only part of header is needed; not entire one
5867 ---------------------------------------------------------------------*/
5868 vosStatus = WDA_DS_PeekRxPacketInfo( vosTempBuff, (v_PVOID_t)&pvBDHeader, 1/*Swap BD*/ );
5869
5870 if ( NULL == pvBDHeader )
5871 {
5872 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
5873 "WLAN TL:Cannot extract BD header"));
5874 /* Drop packet */
5875 vos_pkt_return_packet(vosTempBuff);
5876 vosTempBuff = vosDataBuff;
5877 continue;
5878 }
5879
Jeff Johnson295189b2012-06-20 16:38:30 -07005880 /*---------------------------------------------------------------------
5881 Check if FC frame reported from FW
5882 ---------------------------------------------------------------------*/
5883 if(WDA_IS_RX_FC(pvBDHeader))
5884 {
5885 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
5886 "WLAN TL:receive one FC frame"));
5887
5888 WLANTL_ProcessFCFrame(pvosGCtx, vosTempBuff, pvBDHeader);
5889 /* Drop packet */
5890 vos_pkt_return_packet(vosTempBuff);
5891 vosTempBuff = vosDataBuff;
5892 continue;
5893 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005894
5895 /* AMSDU HW bug fix
5896 * After 2nd AMSDU subframe HW could not handle BD correctly
5897 * HAL workaround is needed */
5898 if(WDA_GET_RX_ASF(pvBDHeader))
5899 {
5900 WDA_DS_RxAmsduBdFix(pvosGCtx, pvBDHeader);
5901 }
5902
5903 /*---------------------------------------------------------------------
5904 Extract frame control field from 802.11 header if present
5905 (frame translation not done)
5906 ---------------------------------------------------------------------*/
5907
5908 vosStatus = WDA_DS_GetFrameTypeSubType( pvosGCtx, vosTempBuff,
5909 pvBDHeader, &ucFrmType );
5910 if ( VOS_STATUS_SUCCESS != vosStatus )
5911 {
5912 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
5913 "WLAN TL:Cannot extract Frame Control Field"));
5914 /* Drop packet */
5915 vos_pkt_return_packet(vosTempBuff);
5916 vosTempBuff = vosDataBuff;
5917 continue;
5918 }
5919
Mohit Khanna698ba2a2012-12-04 15:08:18 -08005920#ifdef FEATURE_WLAN_TDLS_INTERNAL
5921 if ( WLANTL_IS_DATA_FRAME(ucFrmType))
5922 {
5923 ucMPDUHLen = (v_U8_t)WDA_GET_RX_MPDU_HEADER_LEN(pvBDHeader);
5924 WLANTL_GetEtherType_2(pvBDHeader, vosTempBuff, ucMPDUHLen, &usEtherType) ;
5925 }
5926#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005927 vos_pkt_get_packet_length(vosTempBuff, &usPktLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07005928
5929 /*---------------------------------------------------------------------
5930 Check if management and send to PE
5931 ---------------------------------------------------------------------*/
5932
Mohit Khanna698ba2a2012-12-04 15:08:18 -08005933 if ( WLANTL_IS_MGMT_FRAME(ucFrmType)
5934#ifdef FEATURE_WLAN_TDLS_INTERNAL
5935 || (WLANTL_IS_TDLS_FRAME(usEtherType))
5936#endif
5937 )
Jeff Johnson295189b2012-06-20 16:38:30 -07005938 {
5939 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
5940 "WLAN TL:Sending packet to management client"));
5941 if ( VOS_STATUS_SUCCESS != vos_pkt_flatten_rx_pkt(&vosTempBuff))
5942 {
5943 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
5944 "WLAN TL:Cannot flatten packet - dropping"));
5945 /* Drop packet */
5946 vos_pkt_return_packet(vosTempBuff);
5947 vosTempBuff = vosDataBuff;
5948 continue;
5949 }
5950 ucSTAId = (v_U8_t)WDA_GET_RX_STAID( pvBDHeader );
5951 /* Read RSSI and update */
5952 if(!WLANTL_STA_ID_INVALID(ucSTAId))
5953 {
5954#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
5955 /* Read RSSI and update */
5956 vosStatus = WLANTL_HSHandleRXFrame(pvosGCtx,
5957 WLANTL_MGMT_FRAME_TYPE,
5958 pvBDHeader,
5959 ucSTAId,
5960 VOS_FALSE,
5961 NULL);
5962#else
5963 vosStatus = WLANTL_ReadRSSI(pvosGCtx, pvBDHeader, ucSTAId);
5964#endif
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05305965 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
5966 {
5967 TLLOGW(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
5968 "Handle RX Management Frame fail within Handoff "
5969 "support module"));
5970 /* Do Not Drop packet at here
5971 * Revisit why HO module return fail
5972 * vos_pkt_return_packet(vosTempBuff);
5973 * vosTempBuff = vosDataBuff;
5974 * continue;
5975 */
5976 }
5977 vosStatus = WLANTL_ReadSNR(pvosGCtx, pvBDHeader, ucSTAId);
5978
5979 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
5980 {
5981 TLLOGW(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
5982 FL("Failed to Read SNR")));
5983 }
Dino Mycle3b9536d2014-07-09 22:05:24 +05305984#ifdef WLAN_FEATURE_LINK_LAYER_STATS
5985 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
5986 if ( NULL != pClientSTA)
5987 {
5988 pClientSTA->interfaceStats.mgmtRx++;
Dino Mycle3b9536d2014-07-09 22:05:24 +05305989 }
5990#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005991 }
5992
Jeff Johnson295189b2012-06-20 16:38:30 -07005993 pTLCb->tlMgmtFrmClient.pfnTlMgmtFrmRx( pvosGCtx, vosTempBuff);
5994 }
5995 else /* Data Frame */
5996 {
5997 ucSTAId = (v_U8_t)WDA_GET_RX_STAID( pvBDHeader );
5998 ucTid = (v_U8_t)WDA_GET_RX_TID( pvBDHeader );
Dino Mycle3b9536d2014-07-09 22:05:24 +05305999#ifdef WLAN_FEATURE_LINK_LAYER_STATS
6000 ac = WLANTL_TID_2_AC[ucTid];
6001#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006002
6003 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
6004 "WLAN TL:Data packet received for STA %d", ucSTAId));
6005
6006 /*------------------------------------------------------------------
6007 This should be corrected when multipe sta support is added !!!
6008 for now bcast frames will be sent to the last registered STA
6009 ------------------------------------------------------------------*/
6010 if ( WDA_IS_RX_BCAST(pvBDHeader))
6011 {
6012 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
6013 "WLAN TL:TL rx Bcast frame - sending to last registered station"));
6014 broadcast = VOS_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006015 /*-------------------------------------------------------------------
6016 If Addr1 is b/mcast, but Addr3 is our own self MAC, it is a b/mcast
6017 pkt we sent looping back to us. To be dropped if we are non BTAMP
6018 -------------------------------------------------------------------*/
6019 if( WLANHAL_RX_BD_ADDR3_SELF_IDX ==
6020 (v_U8_t)WDA_GET_RX_ADDR3_IDX( pvBDHeader ))
6021 {
6022 selfBcastLoopback = VOS_TRUE;
6023 }
6024 }/*if bcast*/
6025
6026 if ( WLANTL_STA_ID_INVALID(ucSTAId) )
6027 {
6028 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
6029 "WLAN TL:STA ID invalid - dropping pkt"));
6030 /* Drop packet */
6031 vos_pkt_return_packet(vosTempBuff);
6032 vosTempBuff = vosDataBuff;
6033 continue;
6034 }
6035
6036 /*----------------------------------------------------------------------
6037 No need to lock cache access because cache manipulation only happens
6038 in the transport thread/task context
6039 - These frames are to be forwarded to the station upon registration
6040 which happens in the main thread context
6041 The caching here can happen in either Tx or Rx thread depending
6042 on the current SSC scheduling
6043 - also we need to make sure that the frames in the cache are fwd-ed to
6044 the station before the new incoming ones
6045 -----------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306046 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
6047 if (NULL == pClientSTA)
6048 {
6049 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
6050 "WLAN TL:STA not allocated memory. Dropping packet"));
6051 vos_pkt_return_packet(vosTempBuff);
6052 vosTempBuff = vosDataBuff;
6053 continue;
6054 }
6055
Hoonki Lee5305c3a2013-04-29 23:28:59 -07006056#ifdef FEATURE_WLAN_TDLS
6057 if (( pClientSTA->ucExists ) &&
6058 (WLAN_STA_TDLS == pClientSTA->wSTADesc.wSTAType) &&
6059 (pClientSTA->ucTxSuspended))
6060 vos_atomic_set_U8( &pClientSTA->ucTxSuspended, 0 );
6061 else if ( !broadcast && (pClientSTA->ucExists == 0 ) )
6062 {
6063 tpSirMacMgmtHdr pMacHeader = WDA_GET_RX_MAC_HEADER( pvBDHeader );
6064
6065 /* from the direct peer while it is not registered to TL yet */
6066 if ( (pMacHeader->fc.fromDS == 0) &&
6067 (pMacHeader->fc.toDS == 0) )
6068 {
6069 v_U8_t ucAddr3STAId;
6070
6071 ucAddr3STAId = WDA_GET_RX_ADDR3_IDX(pvBDHeader);
6072
6073 if ( WLANTL_STA_ID_INVALID(ucAddr3STAId) )
6074 {
6075 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
6076 "WLAN TL:STA ID %d invalid - dropping pkt", ucAddr3STAId));
6077 /* Drop packet */
6078 vos_pkt_return_packet(vosTempBuff);
6079 vosTempBuff = vosDataBuff;
6080 continue;
6081 }
6082
6083 if (!(pTLCb->atlSTAClients[ucAddr3STAId] && pTLCb->atlSTAClients[ucAddr3STAId]->ucExists &&
6084 (WLAN_STA_INFRA == pTLCb->atlSTAClients[ucAddr3STAId]->wSTADesc.wSTAType) &&
6085 (WLANTL_STA_AUTHENTICATED == pTLCb->atlSTAClients[ucAddr3STAId]->tlState)))
6086 {
6087 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
Arif Hussainf2b00992013-11-17 21:46:15 -08006088 "%s: staId %d addr3Id %d tlState %d. Unkown Receiver/Transmitter Dropping packet", __func__,
Hoonki Lee5305c3a2013-04-29 23:28:59 -07006089 ucSTAId, ucAddr3STAId, pTLCb->atlSTAClients[ucAddr3STAId]->tlState));
6090 vos_pkt_return_packet(vosTempBuff);
6091 vosTempBuff = vosDataBuff;
6092 continue;
6093 }
6094 else
6095 {
6096 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
Arif Hussainf2b00992013-11-17 21:46:15 -08006097 "%s: staId %d doesn't exist, but mapped to AP staId %d", __func__,
Hoonki Lee5305c3a2013-04-29 23:28:59 -07006098 ucSTAId, ucAddr3STAId));
6099 ucSTAId = ucAddr3STAId;
6100 pClientSTA = pTLCb->atlSTAClients[ucAddr3STAId];
6101 }
6102 }
6103 }
6104#endif
6105
Katya Nigam63902932014-06-26 19:04:23 +05306106 if (( pClientSTA->enableCaching == 1 ) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07006107 /*Dont buffer Broadcast/Multicast frames. If AP transmits bursts of Broadcast/Multicast data frames,
6108 * libra buffers all Broadcast/Multicast packets after authentication with AP,
6109 * So it will lead to low resource condition in Rx Data Path.*/
Katya Nigam63902932014-06-26 19:04:23 +05306110 ( WDA_IS_RX_BCAST(pvBDHeader) == 0 ))
Jeff Johnson295189b2012-06-20 16:38:30 -07006111 {
Katya Nigam6201c3e2014-05-27 17:51:42 +05306112 if( WDA_IsSelfSTA(pvosGCtx,ucSTAId))
6113 {
6114 //drop packet for Self STA index
6115 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
6116 "%s: Packet dropped for Self STA with staId %d ", __func__, ucSTAId ));
6117
6118 vos_pkt_return_packet(vosTempBuff);
6119 vosTempBuff = vosDataBuff;
6120 continue;
6121 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006122 uDPUSig = WDA_GET_RX_DPUSIG( pvBDHeader );
6123 //Station has not yet been registered with TL - cache the frame
Hoonki Lee5305c3a2013-04-29 23:28:59 -07006124 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
Arif Hussainf2b00992013-11-17 21:46:15 -08006125 "%s: staId %d exist %d tlState %d cache rx frame", __func__, ucSTAId,
Hoonki Lee5305c3a2013-04-29 23:28:59 -07006126 pClientSTA->ucExists, pClientSTA->tlState));
Jeff Johnson295189b2012-06-20 16:38:30 -07006127 WLANTL_CacheSTAFrame( pTLCb, ucSTAId, vosTempBuff, uDPUSig, broadcast, ucFrmType);
6128 vosTempBuff = vosDataBuff;
6129 continue;
6130 }
6131
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08006132#ifdef FEATURE_WLAN_ESE_UPLOAD
6133 if ((pClientSTA->wSTADesc.ucIsEseSta)|| broadcast)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07006134 {
6135 /*--------------------------------------------------------------------
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08006136 Filter the IAPP frames for ESE connection;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07006137 if data it will return false and it
6138 will be routed through the regular data path
6139 --------------------------------------------------------------------*/
6140 if ( WLANTL_IsIAPPFrame(pvBDHeader,
6141 vosTempBuff))
6142 {
6143 bForwardIAPPwithLLC = VOS_TRUE;
6144 }
6145 }
6146#endif
6147
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08006148#if defined(FEATURE_WLAN_ESE) && !defined(FEATURE_WLAN_ESE_UPLOAD)
6149 if ((pClientSTA->wSTADesc.ucIsEseSta)|| broadcast)
Jeff Johnson295189b2012-06-20 16:38:30 -07006150 {
6151 /*--------------------------------------------------------------------
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08006152 Filter the IAPP frames for ESE connection;
Jeff Johnson295189b2012-06-20 16:38:30 -07006153 if data it will return false and it
6154 will be routed through the regular data path
6155 --------------------------------------------------------------------*/
6156 if ( WLANTL_IsIAPPFrame(pvBDHeader,
6157 vosTempBuff))
6158 {
6159 if ( VOS_STATUS_SUCCESS != vos_pkt_flatten_rx_pkt(&vosTempBuff))
6160 {
6161 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6162 "WLAN TL:Cannot flatten packet - dropping"));
6163 /* Drop packet */
6164 vos_pkt_return_packet(vosTempBuff);
6165 } else {
6166
6167 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08006168 "WLAN TL: Received ESE IAPP Frame"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006169
6170 pTLCb->tlMgmtFrmClient.pfnTlMgmtFrmRx( pvosGCtx, vosTempBuff);
6171 }
6172 vosTempBuff = vosDataBuff;
6173 continue;
6174 }
6175 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08006176#endif /* defined(FEATURE_WLAN_ESE) && !defined(FEATURE_WLAN_ESE_UPLOAD) */
Jeff Johnson295189b2012-06-20 16:38:30 -07006177
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306178 if ( WLAN_STA_BT_AMP == pClientSTA->wSTADesc.wSTAType )
Jeff Johnson295189b2012-06-20 16:38:30 -07006179 {
6180 /*--------------------------------------------------------------------
6181 Process the ctrl BAP frame; if data it will return false and it
6182 will be routed through the regular data path
6183 --------------------------------------------------------------------*/
6184 if ( WLANTL_ProcessBAPFrame( pvBDHeader,
6185 vosTempBuff,
6186 pTLCb,
6187 &first_data_pkt_arrived,
6188 ucSTAId))
6189 {
6190 vosTempBuff = vosDataBuff;
6191 continue;
6192 }
6193 }/*if BT-AMP station*/
6194 else if(selfBcastLoopback == VOS_TRUE)
6195 {
6196 /* Drop packet */
6197 vos_pkt_return_packet(vosTempBuff);
6198 vosTempBuff = vosDataBuff;
6199 continue;
6200 }
6201
6202 /*---------------------------------------------------------------------
6203 Data packet received, send to state machine
6204 ---------------------------------------------------------------------*/
6205 wSTAEvent = WLANTL_RX_EVENT;
6206
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306207 pfnSTAFsm = tlSTAFsm[pClientSTA->tlState].
Jeff Johnson295189b2012-06-20 16:38:30 -07006208 pfnSTATbl[wSTAEvent];
6209
6210 if ( NULL != pfnSTAFsm )
6211 {
6212#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
6213 /* Read RSSI and update */
6214 vosStatus = WLANTL_HSHandleRXFrame(pvosGCtx,
6215 WLANTL_DATA_FRAME_TYPE,
6216 pvBDHeader,
6217 ucSTAId,
6218 broadcast,
6219 vosTempBuff);
6220 broadcast = VOS_FALSE;
6221#else
6222 vosStatus = WLANTL_ReadRSSI(pvosGCtx, pvBDHeader, ucSTAId);
Kiet Lam47325522014-03-10 11:50:46 -07006223#endif
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05306224 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
Jeff Johnson295189b2012-06-20 16:38:30 -07006225 {
6226 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
6227 "Handle RX Data Frame fail within Handoff support module"));
6228 /* Do Not Drop packet at here
6229 * Revisit why HO module return fail
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05306230 * vos_pkt_return_packet(vosTempBuff);
6231 * vosTempBuff = vosDataBuff;
6232 * continue;
Jeff Johnson295189b2012-06-20 16:38:30 -07006233 */
6234 }
Dino Mycle3b9536d2014-07-09 22:05:24 +05306235#ifdef WLAN_FEATURE_LINK_LAYER_STATS
6236 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
6237 if ( NULL != pClientSTA)
6238 {
6239 tpSirMacMgmtHdr pMacHeader = WDA_GET_RX_MAC_HEADER( pvBDHeader );
Mahesh A Saptasagarbbdcf122014-10-28 20:57:11 +05306240 if (!IS_BROADCAST_ADD(pMacHeader->da) && IS_MULTICAST_ADD(pMacHeader->da))
Dino Mycle3b9536d2014-07-09 22:05:24 +05306241 {
6242 pClientSTA->interfaceStats.accessCategoryStats[ac].rxMcast++;
6243 }
6244
6245 WLANTL_HSGetDataRSSI(pvosGCtx, pvBDHeader, ucSTAId,
6246 &currentAvgRSSI);
6247 pClientSTA->interfaceStats.rssiData = currentAvgRSSI;
6248
6249 pClientSTA->interfaceStats.accessCategoryStats[ac].rxMpdu++;
6250 if (WDA_IS_RX_AN_AMPDU (pvBDHeader))
6251 {
6252 pClientSTA->interfaceStats.accessCategoryStats[ac].rxAmpdu++;
6253 }
6254 }
6255
6256
6257#endif
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05306258 vosStatus = WLANTL_ReadSNR(pvosGCtx, pvBDHeader, ucSTAId);
6259
6260 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
6261 {
6262 TLLOGW(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
6263 FL("Failed to Read SNR")));
6264 }
6265
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07006266 pfnSTAFsm( pvosGCtx, ucSTAId, &vosTempBuff, bForwardIAPPwithLLC);
Jeff Johnson295189b2012-06-20 16:38:30 -07006267 }
6268 else
6269 {
6270 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
6271 "WLAN TL:NULL state function, STA:%d, State: %d- dropping packet",
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306272 ucSTAId, pClientSTA->tlState));
Jeff Johnson295189b2012-06-20 16:38:30 -07006273 /* Drop packet */
6274 vos_pkt_return_packet(vosTempBuff);
6275 vosTempBuff = vosDataBuff;
6276 continue;
6277 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006278 }/* else data frame*/
6279
6280 vosTempBuff = vosDataBuff;
6281 }/*while chain*/
6282
6283 return VOS_STATUS_SUCCESS;
6284}/* WLANTL_RxFrames */
6285
Dino Mycle3b9536d2014-07-09 22:05:24 +05306286#ifdef WLAN_FEATURE_LINK_LAYER_STATS
6287/*==========================================================================
6288
6289 FUNCTION WLANTL_CollectInterfaceStats
6290
6291 DESCRIPTION
6292 Utility function used by TL to send the statitics
6293
6294 DEPENDENCIES
6295
6296
6297 PARAMETERS
6298
6299 IN
6300
6301 ucSTAId: station for which the statistics need to collected
6302
6303 vosDataBuff: it will contain the pointer to the corresponding
6304 structure
6305
6306 RETURN VALUE
6307 The result code associated with performing the operation
6308
6309 VOS_STATUS_E_INVAL: Input parameters are invalid
6310 VOS_STATUS_SUCCESS: Everything is good :)
6311
6312 SIDE EFFECTS
6313
6314============================================================================*/
6315VOS_STATUS
6316WLANTL_CollectInterfaceStats
6317(
6318 v_PVOID_t pvosGCtx,
6319 v_U8_t ucSTAId,
6320 WLANTL_InterfaceStatsType *vosDataBuff
6321)
6322{
6323 WLANTL_CbType* pTLCb = NULL;
6324 /*------------------------------------------------------------------------
6325 Sanity check
6326 ------------------------------------------------------------------------*/
6327 if ( WLANTL_STA_ID_INVALID( ucSTAId ) )
6328 {
6329 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6330 "WLAN TL:Invalid station id requested on WLANTL_CollectStats"));
6331 return VOS_STATUS_E_FAULT;
6332 }
6333 /*------------------------------------------------------------------------
6334 Extract TL control block
6335 ------------------------------------------------------------------------*/
6336 pTLCb = VOS_GET_TL_CB(pvosGCtx);
6337 if ( NULL == pTLCb )
6338 {
6339 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6340 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_CollectStats"));
6341 return VOS_STATUS_E_FAULT;
6342 }
6343
6344 if ( NULL == pTLCb->atlSTAClients[ucSTAId] )
6345 {
6346 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6347 "WLAN TL:Client Memory was not allocated on %s", __func__));
6348 return VOS_STATUS_E_FAILURE;
6349 }
Srinivas Dasari98947432014-11-07 19:41:24 +05306350 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
6351 "WLAN TL: collect WIFI_STATS_IFACE results"));
6352
Dino Mycle3b9536d2014-07-09 22:05:24 +05306353 vos_mem_copy(vosDataBuff, &pTLCb->atlSTAClients[ucSTAId]->interfaceStats,
6354 sizeof(WLANTL_InterfaceStatsType));
6355 return VOS_STATUS_SUCCESS;
6356}
6357
Srinivas Dasari98947432014-11-07 19:41:24 +05306358/*==========================================================================
6359
6360 FUNCTION WLANTL_ClearInterfaceStats
6361
6362 DESCRIPTION
6363 Utility function used by TL to clear the statitics
6364
6365 DEPENDENCIES
6366
6367
6368 PARAMETERS
6369
6370 IN
6371
6372 ucSTAId: station for which the statistics need to collected
6373
6374 RETURN VALUE
6375 The result code associated with performing the operation
6376
6377 VOS_STATUS_E_INVAL: Input parameters are invalid
6378 VOS_STATUS_SUCCESS: Everything is good :)
6379
6380 SIDE EFFECTS
6381
6382============================================================================*/
6383VOS_STATUS
6384WLANTL_ClearInterfaceStats
6385(
6386 v_PVOID_t pvosGCtx,
6387 v_U8_t ucSTAId,
6388 v_U8_t statsClearReqMask
6389)
6390{
6391 WLANTL_CbType* pTLCb = NULL;
6392 WLANTL_STAClientType* pClientSTA = NULL;
6393 /*------------------------------------------------------------------------
6394 Sanity check
6395 ------------------------------------------------------------------------*/
6396 if ( WLANTL_STA_ID_INVALID( ucSTAId ) )
6397 {
6398 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6399 "WLAN TL:Invalid station id requested on WLANTL_CollectStats"));
6400 return VOS_STATUS_E_FAULT;
6401 }
6402 /*------------------------------------------------------------------------
6403 Extract TL control block
6404 ------------------------------------------------------------------------*/
6405 pTLCb = VOS_GET_TL_CB(pvosGCtx);
6406 if ( NULL == pTLCb )
6407 {
6408 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
6409 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_CollectStats"));
6410 return VOS_STATUS_E_FAULT;
6411 }
6412
6413 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
6414 if ( NULL == pClientSTA )
6415 {
6416 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
6417 "WLAN TL:Client Memory was not allocated on %s", __func__));
6418 return VOS_STATUS_E_FAILURE;
6419 }
6420
6421 if ((statsClearReqMask & WIFI_STATS_IFACE_AC) ||
6422 (statsClearReqMask & WIFI_STATS_IFACE)) {
6423 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
6424 "WLAN TL:cleared WIFI_STATS_IFACE_AC results"));
6425 pClientSTA->interfaceStats.accessCategoryStats[0].rxMcast = 0;
6426 pClientSTA->interfaceStats.accessCategoryStats[1].rxMcast = 0;
6427 pClientSTA->interfaceStats.accessCategoryStats[2].rxMcast = 0;
6428 pClientSTA->interfaceStats.accessCategoryStats[3].rxMcast = 0;
6429
6430 pClientSTA->interfaceStats.accessCategoryStats[0].rxMpdu = 0;
6431 pClientSTA->interfaceStats.accessCategoryStats[1].rxMpdu = 0;
6432 pClientSTA->interfaceStats.accessCategoryStats[2].rxMpdu = 0;
6433 pClientSTA->interfaceStats.accessCategoryStats[3].rxMpdu = 0;
6434
6435 pClientSTA->interfaceStats.accessCategoryStats[0].rxAmpdu = 0;
6436 pClientSTA->interfaceStats.accessCategoryStats[1].rxAmpdu = 0;
6437 pClientSTA->interfaceStats.accessCategoryStats[2].rxAmpdu = 0;
6438 pClientSTA->interfaceStats.accessCategoryStats[3].rxAmpdu = 0;
6439 }
6440
6441 if (statsClearReqMask & WIFI_STATS_IFACE) {
6442 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
6443 "WLAN TL:cleared WIFI_STATS_IFACE results"));
6444 pClientSTA->interfaceStats.mgmtRx = 0;
6445 pClientSTA->interfaceStats.rssiData = 0;
6446 return VOS_STATUS_SUCCESS;
6447 }
6448
6449 return VOS_STATUS_SUCCESS;
6450}
6451
Dino Mycle3b9536d2014-07-09 22:05:24 +05306452#endif /* WLAN_FEATURE_LINK_LAYER_STATS */
Jeff Johnson295189b2012-06-20 16:38:30 -07006453
6454/*==========================================================================
6455
6456 FUNCTION WLANTL_RxCachedFrames
6457
6458 DESCRIPTION
6459 Utility function used by TL to forward the cached frames to a particular
6460 station;
6461
6462 DEPENDENCIES
6463 TL must be initiailized before this function gets called.
6464 If the frame carried is a data frame then the station for which it is
6465 destined to must have been previously registered with TL.
6466
6467 PARAMETERS
6468
6469 IN
6470 pTLCb: pointer to TL handle
6471
6472 ucSTAId: station for which we need to forward the packets
6473
6474 vosDataBuff: it will contain a pointer to the first cached buffer
6475 received, if there is more then one packet they will be
6476 chained using vOSS buffers.
6477
6478 RETURN VALUE
6479 The result code associated with performing the operation
6480
6481 VOS_STATUS_E_INVAL: Input parameters are invalid
6482 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
6483 page fault
6484 VOS_STATUS_SUCCESS: Everything is good :)
6485
6486 SIDE EFFECTS
6487
6488============================================================================*/
6489VOS_STATUS
6490WLANTL_RxCachedFrames
6491(
6492 WLANTL_CbType* pTLCb,
6493 v_U8_t ucSTAId,
6494 vos_pkt_t* vosDataBuff
6495)
6496{
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306497 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07006498 WLANTL_STAFuncType pfnSTAFsm;
6499 vos_pkt_t* vosTempBuff;
6500 VOS_STATUS vosStatus;
6501 v_PVOID_t pvBDHeader = NULL;
6502 WLANTL_STAEventType wSTAEvent = WLANTL_RX_EVENT;
6503 v_U8_t ucTid = 0;
6504 v_BOOL_t broadcast = VOS_FALSE;
6505 v_BOOL_t bSigMatch = VOS_FALSE;
6506 v_BOOL_t selfBcastLoopback = VOS_FALSE;
Madan Mohan Koyyalamudidfd6aa82012-10-18 20:18:43 -07006507 static v_U8_t first_data_pkt_arrived;
Jeff Johnson295189b2012-06-20 16:38:30 -07006508 v_U32_t uDPUSig;
6509 v_U8_t ucUcastSig;
6510 v_U8_t ucBcastSig;
6511 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
6512
6513 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
6514 "WLAN TL:TL Receive Cached Frames called"));
6515
6516 /*------------------------------------------------------------------------
6517 Sanity check
6518 ------------------------------------------------------------------------*/
6519 if ( NULL == vosDataBuff )
6520 {
6521 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6522 "WLAN TL:Invalid parameter sent on WLANTL_RxFrames"));
6523 return VOS_STATUS_E_INVAL;
6524 }
6525
Mihir Sheteae6f02b2014-04-11 19:49:21 +05306526 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
6527
6528 if ( NULL == pClientSTA )
6529 {
6530 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6531 "WLAN TL:Client Memory was not allocated on %s", __func__));
6532 return VOS_STATUS_E_FAILURE;
6533 }
6534
6535 MTRACE(vos_trace(VOS_MODULE_ID_TL, TRACE_CODE_TL_FORWARD_CACHED_FRAMES,
6536 ucSTAId, 1<<16 | pClientSTA->tlCacheInfo.cacheSize));
6537
Jeff Johnson295189b2012-06-20 16:38:30 -07006538 /*---------------------------------------------------------------------
6539 Save the initial buffer - this is the first received buffer
6540 ---------------------------------------------------------------------*/
6541 vosTempBuff = vosDataBuff;
6542
6543 while ( NULL != vosTempBuff )
6544 {
Madan Mohan Koyyalamudia148e1e2012-11-30 14:52:59 -08006545 broadcast = VOS_FALSE;
6546 selfBcastLoopback = VOS_FALSE;
6547
Jeff Johnson295189b2012-06-20 16:38:30 -07006548 vos_pkt_walk_packet_chain( vosDataBuff, &vosDataBuff, 1/*true*/ );
6549
6550 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
6551 "WLAN TL:Sending new cached packet to station %d", ucSTAId));
6552 /*---------------------------------------------------------------------
6553 Peek at BD header - do not remove
6554 !!! Optimize me: only part of header is needed; not entire one
6555 ---------------------------------------------------------------------*/
6556 vosStatus = WDA_DS_PeekRxPacketInfo( vosTempBuff, (v_PVOID_t)&pvBDHeader, 0 );
6557
6558 if ( NULL == pvBDHeader )
6559 {
6560 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6561 "WLAN TL:Cannot extract BD header"));
6562 /* Drop packet */
6563 vos_pkt_return_packet(vosTempBuff);
6564 vosTempBuff = vosDataBuff;
6565 continue;
6566 }
6567
6568 uDPUSig = WDA_GET_RX_DPUSIG( pvBDHeader );
6569
6570 /* AMSDU HW bug fix
6571 * After 2nd AMSDU subframe HW could not handle BD correctly
6572 * HAL workaround is needed */
6573 if(WDA_GET_RX_ASF(pvBDHeader))
6574 {
6575 WDA_DS_RxAmsduBdFix(vos_get_global_context(VOS_MODULE_ID_TL,pTLCb),
6576 pvBDHeader);
6577 }
6578
6579 ucTid = (v_U8_t)WDA_GET_RX_TID( pvBDHeader );
6580
6581 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
6582 "WLAN TL:Data packet cached for STA %d", ucSTAId);
6583
6584 /*------------------------------------------------------------------
6585 This should be corrected when multipe sta support is added !!!
6586 for now bcast frames will be sent to the last registered STA
6587 ------------------------------------------------------------------*/
6588 if ( WDA_IS_RX_BCAST(pvBDHeader))
6589 {
6590 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
6591 "WLAN TL:TL rx Bcast frame "));
6592 broadcast = VOS_TRUE;
6593
6594 /* If Addr1 is b/mcast, but Addr3 is our own self MAC, it is a b/mcast
6595 * pkt we sent looping back to us. To be dropped if we are non BTAMP
6596 */
6597 if( WLANHAL_RX_BD_ADDR3_SELF_IDX ==
6598 (v_U8_t)WDA_GET_RX_ADDR3_IDX( pvBDHeader ))
6599 {
6600 selfBcastLoopback = VOS_TRUE;
6601 }
6602 }/*if bcast*/
6603
6604 /*-------------------------------------------------------------------------
6605 Check if the packet that we cached matches the DPU signature of the
6606 newly added station
6607 -------------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306608 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
6609
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306610 if ( NULL == pClientSTA )
6611 {
6612 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6613 "WLAN TL:Client Memory was not allocated on %s", __func__));
6614 return VOS_STATUS_E_FAILURE;
6615 }
6616
Jeff Johnson295189b2012-06-20 16:38:30 -07006617 if ( broadcast )
6618 {
6619 ucBcastSig = (v_U8_t)uDPUSig;
6620 bSigMatch = (( WLAN_TL_INVALID_B_SIG !=
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306621 pClientSTA->wSTADesc.ucBcastSig ) &&
6622 ( ucBcastSig == pClientSTA->wSTADesc.ucBcastSig ));
Jeff Johnson295189b2012-06-20 16:38:30 -07006623 }
6624 else
6625 {
6626 ucUcastSig = (v_U8_t)uDPUSig;
6627 bSigMatch = (( WLAN_TL_INVALID_U_SIG !=
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306628 pClientSTA->wSTADesc.ucUcastSig ) &&
6629 ( ucUcastSig == pClientSTA->wSTADesc.ucUcastSig ));
Jeff Johnson295189b2012-06-20 16:38:30 -07006630 }
6631
6632 /*-------------------------------------------------------------------------
6633 If the packet doesn't match - drop it
6634 -------------------------------------------------------------------------*/
6635 if ( !bSigMatch )
6636 {
Rajesh Chauhana6b08f42013-06-18 19:01:26 -07006637 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_MED,
Jeff Johnson295189b2012-06-20 16:38:30 -07006638 "WLAN TL: Cached packet does not match DPU Sig of the new STA - drop "
6639 " DPU Sig %d UC %d BC %d B %d",
6640 uDPUSig,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306641 pClientSTA->wSTADesc.ucUcastSig,
Rajesh Chauhana6b08f42013-06-18 19:01:26 -07006642 pClientSTA->wSTADesc.ucBcastSig,
Jeff Johnson295189b2012-06-20 16:38:30 -07006643 broadcast));
6644
6645 /* Drop packet */
6646 vos_pkt_return_packet(vosTempBuff);
6647 vosTempBuff = vosDataBuff;
6648 continue;
6649
6650 }/*if signature mismatch*/
6651
6652 /*------------------------------------------------------------------------
6653 Check if BT-AMP frame:
6654 - additional processing needed in this case to separate BT-AMP date
6655 from BT-AMP Ctrl path
6656 ------------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306657 if ( WLAN_STA_BT_AMP == pClientSTA->wSTADesc.wSTAType )
Jeff Johnson295189b2012-06-20 16:38:30 -07006658 {
6659 /*--------------------------------------------------------------------
6660 Process the ctrl BAP frame; if data it will return false and it
6661 will be routed through the regular data path
6662 --------------------------------------------------------------------*/
6663 if ( WLANTL_ProcessBAPFrame( pvBDHeader,
6664 vosTempBuff,
6665 pTLCb,
6666 &first_data_pkt_arrived,
6667 ucSTAId))
6668 {
6669 vosTempBuff = vosDataBuff;
6670 continue;
6671 }
6672 }/*if BT-AMP station*/
6673 else if(selfBcastLoopback == VOS_TRUE)
6674 {
6675 /* Drop packet */
6676 vos_pkt_return_packet(vosTempBuff);
6677 vosTempBuff = vosDataBuff;
6678 continue;
6679 }
6680
6681 /*---------------------------------------------------------------------
6682 Data packet received, send to state machine
6683 ---------------------------------------------------------------------*/
6684 wSTAEvent = WLANTL_RX_EVENT;
6685
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306686 pfnSTAFsm = tlSTAFsm[pClientSTA->tlState].
Jeff Johnson295189b2012-06-20 16:38:30 -07006687 pfnSTATbl[wSTAEvent];
6688
6689 if ( NULL != pfnSTAFsm )
6690 {
6691#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
6692 /* Read RSSI and update */
6693 vosStatus = WLANTL_HSHandleRXFrame(vos_get_global_context(
6694 VOS_MODULE_ID_TL,pTLCb),
6695 WLANTL_DATA_FRAME_TYPE,
6696 pvBDHeader,
6697 ucSTAId,
6698 broadcast,
6699 vosTempBuff);
6700 broadcast = VOS_FALSE;
6701#else
6702 vosStatus = WLANTL_ReadRSSI(vos_get_global_context(VOS_MODULE_ID_TL,pTLCb), pvBDHeader, ucSTAId);
Kiet Lam47325522014-03-10 11:50:46 -07006703#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006704 if(!VOS_IS_STATUS_SUCCESS(vosStatus))
6705 {
6706 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6707 "Handle RX Data Frame fail within Handoff support module"));
6708 /* Do Not Drop packet at here
6709 * Revisit why HO module return fail
6710 vos_pkt_return_packet(vosTempBuff);
6711 vosTempBuff = vosDataBuff;
6712 continue;
6713 */
6714 }
6715 pfnSTAFsm( vos_get_global_context(VOS_MODULE_ID_TL,pTLCb), ucSTAId,
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07006716 &vosTempBuff, VOS_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07006717 }
6718 else
6719 {
6720 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6721 "WLAN TL:NULL state function, STA:%d, State: %d- dropping packet",
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306722 ucSTAId, pClientSTA->tlState));
Jeff Johnson295189b2012-06-20 16:38:30 -07006723 /* Drop packet */
6724 vos_pkt_return_packet(vosTempBuff);
6725 vosTempBuff = vosDataBuff;
6726 continue;
6727 }
6728
6729 vosTempBuff = vosDataBuff;
6730 }/*while chain*/
6731
6732 return VOS_STATUS_SUCCESS;
6733}/* WLANTL_RxCachedFrames */
6734
6735/*==========================================================================
Katya Nigam664f5032014-05-05 12:24:32 +05306736 FUNCTION WLANTL_RxProcessMsg
6737
6738 DESCRIPTION
6739 Called by VOSS when a message was serialized for TL through the
6740 rx thread/task.
6741
6742 DEPENDENCIES
6743 The TL must be initialized before this function can be called.
6744
6745 PARAMETERS
6746
6747 IN
6748 pvosGCtx: pointer to the global vos context; a handle to TL's
6749 control block can be extracted from its context
6750 message: type and content of the message
6751
6752
6753 RETURN VALUE
6754 The result code associated with performing the operation
6755
6756 VOS_STATUS_E_INVAL: invalid input parameters
6757 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
6758 page fault
6759 VOS_STATUS_SUCCESS: Everything is good :)
6760
6761 Other values can be returned as a result of a function call, please check
6762 corresponding API for more info.
6763 SIDE EFFECTS
6764
6765============================================================================*/
6766VOS_STATUS
6767WLANTL_RxProcessMsg
6768(
6769 v_PVOID_t pvosGCtx,
6770 vos_msg_t* message
6771)
6772{
6773 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
6774 v_U32_t uData;
6775 v_U8_t ucSTAId;
6776 v_U8_t ucUcastSig;
6777 v_U8_t ucBcastSig;
6778
6779 /*------------------------------------------------------------------------
6780 Sanity check
6781 ------------------------------------------------------------------------*/
6782 if ( NULL == message )
6783 {
6784 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6785 "WLAN TL:Invalid parameter sent on WLANTL_RxProcessMessage"));
6786 return VOS_STATUS_E_INVAL;
6787 }
6788
6789 /*------------------------------------------------------------------------
6790 Process message
6791 ------------------------------------------------------------------------*/
6792 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
6793 "WLAN TL:Received message: %d through rx flow", message->type));
6794
6795 switch( message->type )
6796 {
6797
6798 case WLANTL_RX_FWD_CACHED:
6799 /*---------------------------------------------------------------------
6800 The data sent with the message has the following structure:
6801 | 00 | ucBcastSignature | ucUcastSignature | ucSTAID |
6802 each field above is one byte
6803 ---------------------------------------------------------------------*/
6804 uData = message->bodyval;
6805 ucSTAId = ( uData & 0x000000FF);
6806 ucUcastSig = ( uData & 0x0000FF00)>>8;
6807 ucBcastSig = (v_U8_t)(( uData & 0x00FF0000)>>16);
6808 vosStatus = WLANTL_ForwardSTAFrames( pvosGCtx, ucSTAId,
6809 ucUcastSig, ucBcastSig);
6810 break;
6811
6812 default:
6813 /*no processing for now*/
6814 break;
6815 }
6816
6817 return VOS_STATUS_SUCCESS;
6818}
6819
6820
6821/*==========================================================================
Jeff Johnson295189b2012-06-20 16:38:30 -07006822 FUNCTION WLANTL_ResourceCB
6823
6824 DESCRIPTION
6825 Called by the TL when it has packets available for transmission.
6826
6827 DEPENDENCIES
6828 The TL must be registered with BAL before this function can be called.
6829
6830 PARAMETERS
6831
6832 IN
6833 pvosGCtx: pointer to the global vos context; a handle to TL's
6834 or BAL's control block can be extracted from its context
6835
6836 RETURN VALUE
6837 The result code associated with performing the operation
6838
6839 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
6840 page fault
6841 VOS_STATUS_SUCCESS: Everything is good :)
6842
6843 SIDE EFFECTS
6844
6845============================================================================*/
6846VOS_STATUS
6847WLANTL_ResourceCB
6848(
6849 v_PVOID_t pvosGCtx,
6850 v_U32_t uCount
6851)
6852{
6853 WLANTL_CbType* pTLCb = NULL;
6854 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
6855
6856 /*------------------------------------------------------------------------
6857 Sanity check
6858 Extract TL control block
6859 ------------------------------------------------------------------------*/
6860 pTLCb = VOS_GET_TL_CB(pvosGCtx);
6861 if ( NULL == pTLCb )
6862 {
6863 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6864 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_ChangeSTAState"));
6865 return VOS_STATUS_E_FAULT;
6866 }
6867
6868 pTLCb->uResCount = uCount;
6869
6870
6871 /*-----------------------------------------------------------------------
6872 Resume Tx if enough res and not suspended
6873 -----------------------------------------------------------------------*/
6874 if (( pTLCb->uResCount >= WDA_TLI_MIN_RES_MF ) &&
6875 ( 0 == pTLCb->ucTxSuspended ))
6876 {
6877 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
6878 "WLAN TL:Issuing Xmit start request to BAL for avail res ASYNC"));
6879 return WDA_DS_StartXmit(pvosGCtx);
6880 }
6881
6882 return VOS_STATUS_SUCCESS;
6883}/* WLANTL_ResourceCB */
6884
6885
Gopichand Nakkala11acd112012-12-31 16:04:04 -08006886/*==========================================================================
6887 FUNCTION WLANTL_IsTxXmitPending
6888
6889 DESCRIPTION
6890 Called by the WDA when it wants to know whether WDA_DS_TX_START_XMIT msg
6891 is pending in TL msg queue
6892
6893 DEPENDENCIES
6894 The TL must be registered with WDA before this function can be called.
6895
6896 PARAMETERS
6897
6898 IN
6899 pvosGCtx: pointer to the global vos context; a handle to TL's
6900 or WDA's control block can be extracted from its context
6901
6902 RETURN VALUE
6903 The result code associated with performing the operation
6904
6905 0: No WDA_DS_TX_START_XMIT msg pending
6906 1: Msg WDA_DS_TX_START_XMIT already pending in TL msg queue
6907
6908 SIDE EFFECTS
6909
6910============================================================================*/
6911v_BOOL_t
6912WLANTL_IsTxXmitPending
6913(
6914 v_PVOID_t pvosGCtx
6915)
6916{
6917
6918 WLANTL_CbType* pTLCb = NULL;
6919 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
6920
6921 /*------------------------------------------------------------------------
6922 Sanity check
6923 Extract TL control block
6924 ------------------------------------------------------------------------*/
6925 pTLCb = VOS_GET_TL_CB(pvosGCtx);
6926 if ( NULL == pTLCb )
6927 {
6928 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_FATAL,
6929 "WLAN TL:Invalid TL pointer from pvosGCtx in WLANTL_IsTxXmitPending "));
6930 return FALSE;
6931 }
6932
6933 return pTLCb->isTxTranmitMsgPending;
6934
6935}/*WLANTL_IsTxXmitPending */
6936
6937/*==========================================================================
6938 FUNCTION WLANTL_SetTxXmitPending
6939
6940 DESCRIPTION
6941 Called by the WDA when it wants to indicate that WDA_DS_TX_START_XMIT msg
6942 is pending in TL msg queue
6943
6944 DEPENDENCIES
6945 The TL must be registered with WDA before this function can be called.
6946
6947 PARAMETERS
6948
6949 IN
6950 pvosGCtx: pointer to the global vos context; a handle to TL's
6951 or WDA's control block can be extracted from its context
6952
6953 RETURN VALUE None
6954
6955 SIDE EFFECTS
6956
6957============================================================================*/
6958
6959v_VOID_t
6960WLANTL_SetTxXmitPending
6961(
6962 v_PVOID_t pvosGCtx
6963)
6964{
6965
6966 WLANTL_CbType* pTLCb = NULL;
6967 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
6968
6969 /*------------------------------------------------------------------------
6970 Sanity check
6971 Extract TL control block
6972 ------------------------------------------------------------------------*/
6973 pTLCb = VOS_GET_TL_CB(pvosGCtx);
6974 if ( NULL == pTLCb )
6975 {
6976 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_FATAL,
6977 "WLAN TL:Invalid TL pointer from pvosGCtx in WLANTL_SetTxXmitPending"));
6978 return;
6979 }
6980
6981 pTLCb->isTxTranmitMsgPending = 1;
6982 return;
6983
6984}/*WLANTL_SetTxXmitPending */
6985
6986/*==========================================================================
6987 FUNCTION WLANTL_ClearTxXmitPending
6988
6989 DESCRIPTION
6990 Called by the WDA when it wants to indicate that no WDA_DS_TX_START_XMIT msg
6991 is pending in TL msg queue
6992
6993 DEPENDENCIES
6994 The TL must be registered with WDA before this function can be called.
6995
6996 PARAMETERS
6997
6998 IN
6999 pvosGCtx: pointer to the global vos context; a handle to TL's
7000 or WDA's control block can be extracted from its context
7001
7002 RETURN VALUE None
7003
7004 SIDE EFFECTS
7005
7006============================================================================*/
7007
7008v_VOID_t
7009WLANTL_ClearTxXmitPending
7010(
7011 v_PVOID_t pvosGCtx
7012)
7013{
7014
7015 WLANTL_CbType* pTLCb = NULL;
7016 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
7017
7018 /*------------------------------------------------------------------------
7019 Sanity check
7020 Extract TL control block
7021 ------------------------------------------------------------------------*/
7022 pTLCb = VOS_GET_TL_CB(pvosGCtx);
7023 if ( NULL == pTLCb )
7024 {
7025 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_FATAL,
7026 "WLAN TL:Invalid TL pointer from pvosGCtx in WLANTL_ClearTxXmitPending "));
7027 return;
7028 }
7029
7030 pTLCb->isTxTranmitMsgPending = 0;
7031 return;
7032}/*WLANTL_ClearTxXmitPending */
7033
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307034/*==========================================================================
7035 FUNCTION WLANTL_TxThreadDebugHandler
7036
7037 DESCRIPTION
7038 Printing TL Snapshot dump, processed under TxThread context, currently
7039 information regarding the global TlCb struture. Dumps information related
7040 to per active STA connection currently in use by TL.
7041
7042 DEPENDENCIES
7043 The TL must be initialized before this gets called.
7044
7045 PARAMETERS
7046
7047 IN
7048 pvosGCtx: pointer to the global vos context; a handle to TL's
7049 or WDA's control block can be extracted from its context
7050
7051 RETURN VALUE None
7052
7053 SIDE EFFECTS
7054
7055============================================================================*/
7056
7057v_VOID_t
7058WLANTL_TxThreadDebugHandler
7059(
7060 v_PVOID_t *pVosContext
7061)
7062{
7063 WLANTL_CbType* pTLCb = NULL;
7064 WLANTL_STAClientType* pClientSTA = NULL;
7065 int i = 0;
Mihir Shete5d148f12014-12-16 17:54:49 +05307066 v_U8_t uFlowMask; // TX FlowMask from WDA
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307067
7068 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_FATAL,
7069 "WLAN TL: %s Enter ", __func__));
7070
7071 pTLCb = VOS_GET_TL_CB(pVosContext);
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307072
7073 if ( NULL == pVosContext || NULL == pTLCb )
7074 {
7075 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7076 "Global VoS Context or TL Context are NULL"));
7077 return;
7078 }
7079
Mihir Shete5d148f12014-12-16 17:54:49 +05307080 if (VOS_STATUS_SUCCESS == WDA_DS_GetTxFlowMask(pVosContext, &uFlowMask))
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307081 {
7082 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Mihir Shete5d148f12014-12-16 17:54:49 +05307083 "WDA uTxFlowMask: 0x%x", uFlowMask));
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307084 }
Mihir Shete5d148f12014-12-16 17:54:49 +05307085
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307086 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7087 "************************TL DUMP INFORMATION**************"));
7088
7089 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7090 "uDelayedTriggerFrmInt:%d\tuMinFramesProcThres:%d",
7091 pTLCb->tlConfigInfo.uDelayedTriggerFrmInt,
7092 pTLCb->tlConfigInfo.uMinFramesProcThres));
7093
7094 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7095 "Management Frame Client exists: %d",
7096 pTLCb->tlMgmtFrmClient.ucExists));
7097 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7098 "usPendingTxCompleteCount: %d\tucTxSuspended: %d",
7099 pTLCb->usPendingTxCompleteCount,
7100 pTLCb->ucTxSuspended));
7101
7102 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7103 "uResCount: %d", pTLCb->uResCount));
7104
7105 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7106 "ucRegisteredStaId: %d\tucCurrentSTA: %d",
7107 pTLCb->ucRegisteredStaId, pTLCb->ucCurrentSTA));
7108
7109 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7110 "UrgentFrameProcessing: %s\tuFramesProcThres: %d",
7111 (pTLCb->bUrgent?"True":"False"), pTLCb->uFramesProcThres));
7112
7113 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7114 "isTxTranmitMsgPending: %d\t isBMPS: %s",
7115 pTLCb->isTxTranmitMsgPending, pTLCb->isBMPS?"True":"False"));
7116
7117#ifdef FEATURE_WLAN_TDLS
7118 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7119 "TDLS Peer Count: %d", pTLCb->ucTdlsPeerCount));
7120#endif
7121
7122 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7123 "++++++++++++++++++++Registerd Client Information++++++++++"));
7124
7125 for ( i =0; i<WLAN_MAX_STA_COUNT; i++ )
7126 {
7127 pClientSTA = pTLCb->atlSTAClients[i];
7128 if( NULL == pClientSTA || 0 == pClientSTA->ucExists)
7129 {
7130 continue;
7131 }
7132
7133 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7134 "######################STA Index: %d ############################",i));
7135 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR, "WLAN_STADescType:"));
7136 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7137 "STAId: %d\t STA MAC Address: %pM", pClientSTA->wSTADesc.ucSTAId,
7138 pClientSTA->wSTADesc.vSTAMACAddress.bytes));
7139 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7140 "STA Type: %d\tProtectedFrame: %d",
7141 pClientSTA->wSTADesc.wSTAType, pClientSTA->wSTADesc.ucProtectedFrame));
7142 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7143 "QoS: %d\tRxFrameTrans: %d\tTxFrameTrans: %d",
7144 pClientSTA->wSTADesc.ucQosEnabled, pClientSTA->wSTADesc.ucSwFrameRXXlation,
7145 pClientSTA->wSTADesc.ucSwFrameTXXlation));
7146 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7147 "ucUcastSig: %d\tucBcastSig: %d", pClientSTA->wSTADesc.ucUcastSig,
7148 pClientSTA->wSTADesc.ucBcastSig));
7149
7150 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7151 "ClientIndex: %d\t Exists: %d", i, pClientSTA->ucExists));
7152 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7153 "TL State: %d\t TL Priority: %d", pClientSTA->tlState,
7154 pClientSTA->tlPri));
7155 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7156 "ucTxSuspended: %d\tucPktPending: %d", pClientSTA->ucTxSuspended,
7157 pClientSTA->ucPktPending));
7158 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7159 "ucEAPOLPktPending: %d\tucNoMoreData: %d",
7160 pClientSTA->ucEapolPktPending, pClientSTA->ucNoMoreData));
7161 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Katya Nigam63902932014-06-26 19:04:23 +05307162 "enableCaching: %d\t fcStaTxDisabled: %d", pClientSTA->enableCaching,
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307163 pClientSTA->fcStaTxDisabled));
7164 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7165 "ucCurrentAC: %d\tucServicedAC: %d", pClientSTA->ucCurrentAC,
7166 pClientSTA->ucServicedAC));
7167 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7168 "TID: %d\tautTxCount[0]: %d\tauRxCount[0]: %d",0, pClientSTA->auTxCount[0],
7169 pClientSTA->auRxCount[0]));
7170 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7171 "aucAcMask[0]: %d\taucAcMask[1]: %d\taucAcMask[2]: %d\taucAcMask[3]: %d\t",
7172 pClientSTA->aucACMask[0], pClientSTA->aucACMask[1],
7173 pClientSTA->aucACMask[2], pClientSTA->aucACMask[3]));
7174 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7175 "ucCurrentWeight: %d", pClientSTA->ucCurrentWeight));
7176
7177 if( WLAN_STA_SOFTAP == pClientSTA->wSTADesc.wSTAType)
7178 {
7179 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7180 "TrafficStatistics for SOFTAP Station:"));
7181 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7182 "RUF=%d\tRMF=%d\tRBF=%d", pClientSTA->trafficStatistics.rxUCFcnt,
7183 pClientSTA->trafficStatistics.rxMCFcnt,
7184 pClientSTA->trafficStatistics.rxBCFcnt));
7185 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7186 "RUB=%d\tRMB=%d\tRBB=%d", pClientSTA->trafficStatistics.rxUCBcnt,
7187 pClientSTA->trafficStatistics.rxMCBcnt,
7188 pClientSTA->trafficStatistics.rxBCBcnt));
7189 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7190 "TUF=%d\tTMF=%d\tTBF=%d", pClientSTA->trafficStatistics.txUCFcnt,
7191 pClientSTA->trafficStatistics.txMCFcnt,
7192 pClientSTA->trafficStatistics.txBCFcnt));
7193 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7194 "TUB=%d\tTMB=%d\tTBB=%d", pClientSTA->trafficStatistics.txUCBcnt,
7195 pClientSTA->trafficStatistics.txMCBcnt,
7196 pClientSTA->trafficStatistics.txBCBcnt));
7197 }
7198 }
7199 return;
7200}
7201
7202/*==========================================================================
Mihir Shetefd62d9d2014-08-06 15:08:21 +05307203 FUNCTION WLANTL_FatalErrorHandler
7204
7205 DESCRIPTION
7206 Handle Fatal errors detected on the TX path.
7207 Currently issues SSR to recover from the error.
7208
7209 DEPENDENCIES
7210 The TL must be initialized before this gets called.
7211
7212 PARAMETERS
7213
7214 IN
7215 pvosGCtx: pointer to the global vos context; a handle to TL's
7216 or WDA's control block can be extracted from its context
7217
7218 RETURN VALUE None
7219
7220 SIDE EFFECTS
7221
7222============================================================================*/
7223v_VOID_t
7224WLANTL_FatalErrorHandler
7225(
7226 v_PVOID_t *pVosContext
7227)
7228{
7229
7230 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_FATAL,
7231 "WLAN TL: %s Enter ", __func__));
7232
7233 if ( NULL == pVosContext )
7234 {
7235 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7236 "%s: Global VoS Context or TL Context are NULL",
7237 __func__));
7238 return;
7239 }
7240
7241 /*
7242 * Issue SSR. vos_wlanRestart has tight checks to make sure that
7243 * we do not send an FIQ if previous FIQ is not processed
7244 */
7245 vos_wlanRestart();
7246}
7247
7248/*==========================================================================
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307249 FUNCTION WLANTL_TLDebugMessage
7250
7251 DESCRIPTION
7252 Post a TL Snapshot request, posts message in TxThread.
7253
7254 DEPENDENCIES
7255 The TL must be initialized before this gets called.
7256
7257 PARAMETERS
7258
7259 IN
7260 displaySnapshot Boolean showing whether to dump the snapshot or not.
7261
7262 RETURN VALUE None
7263
7264 SIDE EFFECTS
7265
7266============================================================================*/
7267
7268v_VOID_t
7269WLANTL_TLDebugMessage
7270(
Mihir Shete327c2ab2014-11-13 15:17:02 +05307271 v_U32_t debugFlags
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307272)
7273{
7274 vos_msg_t vosMsg;
7275 VOS_STATUS status;
7276
Mihir Shete327c2ab2014-11-13 15:17:02 +05307277 if(debugFlags & WLANTL_DEBUG_TX_SNAPSHOT)
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307278 {
7279 vosMsg.reserved = 0;
7280 vosMsg.bodyptr = NULL;
7281 vosMsg.type = WLANTL_TX_SNAPSHOT;
7282
7283 status = vos_tx_mq_serialize( VOS_MODULE_ID_TL, &vosMsg);
7284 if(status != VOS_STATUS_SUCCESS)
7285 {
7286 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR, "TX Msg Posting Failed with status: %d",status));
7287 return;
7288 }
7289 }
Mihir Shete327c2ab2014-11-13 15:17:02 +05307290 if (debugFlags & WLANTL_DEBUG_FW_CLEANUP)
7291 {
7292 vosMsg.reserved = 0;
7293 vosMsg.bodyptr = NULL;
7294 vosMsg.type = WLANTL_TX_FW_DEBUG;
7295
7296 status = vos_tx_mq_serialize( VOS_MODULE_ID_TL, &vosMsg);
7297 if(status != VOS_STATUS_SUCCESS)
7298 {
7299 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR, "TX Msg Posting Failed with status: %d",status));
7300 return;
7301 }
7302 }
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307303 return;
7304}
Jeff Johnson295189b2012-06-20 16:38:30 -07007305
Mihir Shetefd62d9d2014-08-06 15:08:21 +05307306/*==========================================================================
7307 FUNCTION WLANTL_FatalError
7308
7309 DESCRIPTION
7310 Fatal error reported in TX path, post an event to TX Thread for further
7311 handling
7312
7313 DEPENDENCIES
7314 The TL must be initialized before this gets called.
7315
7316 PARAMETERS
7317
7318 VOID
7319
7320 RETURN VALUE None
7321
7322 SIDE EFFECTS
7323
7324============================================================================*/
7325
7326v_VOID_t
7327WLANTL_FatalError
7328(
7329 v_VOID_t
7330)
7331{
7332 vos_msg_t vosMsg;
7333 VOS_STATUS status;
7334
7335 vosMsg.reserved = 0;
7336 vosMsg.bodyptr = NULL;
7337 vosMsg.type = WLANTL_TX_FATAL_ERROR;
7338
7339 status = vos_tx_mq_serialize( VOS_MODULE_ID_TL, &vosMsg);
7340 if(status != VOS_STATUS_SUCCESS)
7341 {
7342 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7343 "%s: TX Msg Posting Failed with status: %d",
7344 __func__,status));
7345 }
7346 return;
7347}
Jeff Johnson295189b2012-06-20 16:38:30 -07007348/*============================================================================
7349 TL STATE MACHINE
7350============================================================================*/
7351
7352/*==========================================================================
7353 FUNCTION WLANTL_STATxConn
7354
7355 DESCRIPTION
7356 Transmit in connected state - only EAPOL and WAI packets allowed
7357
7358 DEPENDENCIES
7359 The STA must be registered with TL before this function can be called.
7360
7361 PARAMETERS
7362
7363 IN
7364 pvosGCtx: pointer to the global vos context; a handle to TL's
7365 control block can be extracted from its context
7366 ucSTAId: identifier of the station being processed
7367 vosDataBuff: pointer to the tx vos buffer
7368
7369 RETURN VALUE
7370 The result code associated with performing the operation
7371
7372 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
7373 page fault
7374 VOS_STATUS_SUCCESS: Everything is good :)
7375
7376 Other return values are possible coming from the called functions.
7377 Please check API for additional info.
7378
7379 SIDE EFFECTS
7380
7381============================================================================*/
7382VOS_STATUS
7383WLANTL_STATxConn
7384(
7385 v_PVOID_t pvosGCtx,
7386 v_U8_t ucSTAId,
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07007387 vos_pkt_t** pvosDataBuff,
7388 v_BOOL_t bForwardIAPPwithLLC
Jeff Johnson295189b2012-06-20 16:38:30 -07007389)
7390{
7391 v_U16_t usPktLen;
7392 VOS_STATUS vosStatus;
7393 v_MACADDR_t vDestMacAddr;
7394 vos_pkt_t* vosDataBuff = NULL;
7395 WLANTL_CbType* pTLCb = NULL;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307396 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07007397 WLANTL_MetaInfoType tlMetaInfo;
7398 v_U8_t ucTypeSubtype = 0;
7399 v_U8_t ucTid;
7400 v_U8_t extraHeadSpace = 0;
7401 v_U8_t ucWDSEnabled = 0;
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07007402 v_U8_t ucAC, ucACMask, i;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05307403 v_U32_t txFlag = HAL_TX_NO_ENCRYPTION_MASK;
Jeff Johnson295189b2012-06-20 16:38:30 -07007404 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
7405
7406 /*------------------------------------------------------------------------
7407 Sanity check
7408 Extract TL control block
7409 ------------------------------------------------------------------------*/
7410 pTLCb = VOS_GET_TL_CB(pvosGCtx);
7411 if ( NULL == pTLCb )
7412 {
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07007413 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7414 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_STATxConn");
Jeff Johnson295189b2012-06-20 16:38:30 -07007415 *pvosDataBuff = NULL;
7416 return VOS_STATUS_E_FAULT;
7417 }
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307418 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
7419
7420 if ( NULL == pClientSTA )
7421 {
7422 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7423 "WLAN TL:Client Memory was not allocated on %s", __func__));
7424 return VOS_STATUS_E_FAILURE;
7425 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007426
7427 /*-------------------------------------------------------------------
7428 Disable AC temporary - if successfull retrieve re-enable
7429 The order is justified because of the possible scenario
7430 - TL tryes to fetch packet for AC and it returns NULL
7431 - TL analyzes the data it has received to see if there are
7432 any more pkts available for AC -> if not TL will disable AC
7433 - however it is possible that while analyzing results TL got
7434 preempted by a pending indication where the mask was again set
7435 TL will not check again and as a result when it resumes
7436 execution it will disable AC
7437 To prevent this the AC will be disabled here and if retrieve
7438 is successfull it will be re-enabled
7439 -------------------------------------------------------------------*/
7440
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07007441
7442 //LTI:pTLCb->atlSTAClients[ucSTAId].
7443 //LTI: aucACMask[pTLCb->atlSTAClients[ucSTAId].ucCurrentAC] = 0;
7444
7445 /*------------------------------------------------------------------------
7446 Fetch packet from HDD
7447 ------------------------------------------------------------------------*/
Sunil Ravid5406f22013-01-22 00:18:31 -08007448#ifdef FEATURE_WLAN_TDLS
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307449 if ((WLAN_STA_SOFTAP != pClientSTA->wSTADesc.wSTAType) &&
Agarwal Ashishcd86f7b2014-06-16 17:11:58 +05307450 !(vos_concurrent_open_sessions_running()) &&
Sunil Ravid5406f22013-01-22 00:18:31 -08007451 !pTLCb->ucTdlsPeerCount)
7452 {
7453#else
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307454 if ((WLAN_STA_SOFTAP != pClientSTA->wSTADesc.wSTAType) &&
Agarwal Ashishcd86f7b2014-06-16 17:11:58 +05307455 !(vos_concurrent_open_sessions_running()))
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07007456 {
Sunil Ravid5406f22013-01-22 00:18:31 -08007457#endif
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307458 ucAC = pClientSTA->ucCurrentAC;
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07007459
7460 /*-------------------------------------------------------------------
7461 Disable AC temporary - if successfull retrieve re-enable
7462 The order is justified because of the possible scenario
7463 - TL tryes to fetch packet for AC and it returns NULL
7464 - TL analyzes the data it has received to see if there are
7465 any more pkts available for AC -> if not TL will disable AC
7466 - however it is possible that while analyzing results TL got
7467 preempted by a pending indication where the mask was again set
7468 TL will not check again and as a result when it resumes
7469 execution it will disable AC
7470 To prevent this the AC will be disabled here and if retrieve
7471 is successfull it will be re-enabled
7472 -------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307473 pClientSTA->aucACMask[ucAC] = 0;
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07007474 }
7475 else
7476 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307477 //softap case
7478 ucAC = pTLCb->uCurServedAC;
7479 pClientSTA->aucACMask[ucAC] = 0;
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07007480 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007481
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307482 /*You make an initial assumption that HDD has no more data and if the
Jeff Johnson295189b2012-06-20 16:38:30 -07007483 assumption was wrong you reset the flags to their original state
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307484 This will prevent from exposing a race condition between checking with HDD
Jeff Johnson295189b2012-06-20 16:38:30 -07007485 for packets and setting the flags to false*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307486 //LTI: vos_atomic_set_U8( &pTLCb->atlSTAClients[ucSTAId].ucPktPending, 0);
7487 //LTI: pTLCb->atlSTAClients[ucSTAId].ucNoMoreData = 1;
7488 vos_atomic_set_U8( &pClientSTA->ucPktPending, 0);
7489 WLAN_TL_AC_ARRAY_2_MASK( pClientSTA, ucACMask, i);
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307490 /*You make an initial assumption that HDD has no more data and if the
7491 assumption was wrong you reset the flags to their original state
7492 This will prevent from exposing a race condition between checking with HDD
7493 for packets and setting the flags to false*/
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07007494 if ( 0 == ucACMask )
7495 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307496 pClientSTA->ucNoMoreData = 1;
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07007497 }
7498 else
7499 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307500 vos_atomic_set_U8( &pClientSTA->ucPktPending, 1);
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07007501 }
7502
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07007503
Madan Mohan Koyyalamudid93f4942012-10-05 15:05:40 -07007504 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07007505 "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 +05307506 ucAC, ucACMask, pClientSTA->ucPktPending);
Jeff Johnson295189b2012-06-20 16:38:30 -07007507
7508 /*------------------------------------------------------------------------
7509 Fetch tx packet from HDD
7510 ------------------------------------------------------------------------*/
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07007511
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307512 vosStatus = pClientSTA->pfnSTAFetchPkt( pvosGCtx,
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07007513 &ucSTAId,
7514 ucAC,
7515 &vosDataBuff, &tlMetaInfo );
Jeff Johnson295189b2012-06-20 16:38:30 -07007516
7517 if (( VOS_STATUS_SUCCESS != vosStatus ) || ( NULL == vosDataBuff ))
7518 {
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07007519 TLLOG1(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -07007520 "WLAN TL:No more data at HDD status %d", vosStatus));
7521 *pvosDataBuff = NULL;
7522
7523 /*--------------------------------------------------------------------
7524 Reset AC for the serviced station to the highest priority AC
7525 -> due to no more data at the station
7526 Even if this AC is not supported by the station, correction will be
7527 made in the main TL loop
7528 --------------------------------------------------------------------*/
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05307529 pClientSTA->ucCurrentAC = WLANTL_AC_HIGH_PRIO;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307530 pClientSTA->ucCurrentWeight = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07007531
Madan Mohan Koyyalamudid8000342012-11-08 14:55:26 -08007532 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07007533 "WLAN TL: WLANTL_STATxConn no more packets in HDD for AC: %d AC Mask: %d",
7534 ucAC, ucACMask);
7535
Jeff Johnson295189b2012-06-20 16:38:30 -07007536 return vosStatus;
7537 }
7538
7539 /*There are still packets in HDD - set back the pending packets and
7540 the no more data assumption*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307541 vos_atomic_set_U8( &pClientSTA->ucPktPending, 1);
7542 pClientSTA->ucNoMoreData = 0;
7543 pClientSTA->aucACMask[ucAC] = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07007544
Jeff Johnson295189b2012-06-20 16:38:30 -07007545#ifdef WLAN_PERF
7546 vos_pkt_set_user_data_ptr( vosDataBuff, VOS_PKT_USER_DATA_ID_BAL,
7547 (v_PVOID_t)0);
7548
7549#endif /*WLAN_PERF*/
7550
7551
7552#ifdef FEATURE_WLAN_WAPI
7553 /*------------------------------------------------------------------------
7554 If the packet is neither an Eapol packet nor a WAI packet then drop it
7555 ------------------------------------------------------------------------*/
7556 if ( 0 == tlMetaInfo.ucIsEapol && 0 == tlMetaInfo.ucIsWai )
7557 {
Madan Mohan Koyyalamudid93f4942012-10-05 15:05:40 -07007558 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -07007559 "WLAN TL:Only EAPOL or WAI packets allowed before authentication"));
7560
7561 /* Fail tx for packet */
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307562 pClientSTA->pfnSTATxComp( pvosGCtx, vosDataBuff,
Jeff Johnson295189b2012-06-20 16:38:30 -07007563 VOS_STATUS_E_BADMSG);
7564 vosDataBuff = NULL;
7565 *pvosDataBuff = NULL;
7566 return VOS_STATUS_SUCCESS;
7567 }
7568#else
7569 if ( 0 == tlMetaInfo.ucIsEapol )
7570 {
7571 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
7572 "WLAN TL:Received non EAPOL packet before authentication"));
7573
7574 /* Fail tx for packet */
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307575 pClientSTA->pfnSTATxComp( pvosGCtx, vosDataBuff,
Jeff Johnson295189b2012-06-20 16:38:30 -07007576 VOS_STATUS_E_BADMSG);
7577 vosDataBuff = NULL;
7578 *pvosDataBuff = NULL;
7579 return VOS_STATUS_SUCCESS;
7580 }
7581#endif /* FEATURE_WLAN_WAPI */
7582
7583 /*-------------------------------------------------------------------------
7584 Check TID
7585 -------------------------------------------------------------------------*/
7586 ucTid = tlMetaInfo.ucTID;
7587
7588 /*Make sure TID is valid*/
7589 if ( WLANTL_TID_INVALID(ucTid))
7590 {
Rajesh Chauhan2df40bf2013-08-22 11:26:12 -07007591 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
Jeff Johnson295189b2012-06-20 16:38:30 -07007592 "WLAN TL:Invalid TID sent in meta info %d - defaulting to 0 (BE)",
7593 ucTid));
7594 ucTid = 0;
7595 }
7596
7597 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
7598 "WLAN TL:Attaching BD header to pkt on WLANTL_STATxConn"));
7599
7600#ifdef FEATURE_WLAN_WAPI
7601 /*------------------------------------------------------------------------
7602 Translate 802.3 frame to 802.11 if Frame translation is enabled or if
7603 frame is a WAI frame.
7604 ------------------------------------------------------------------------*/
7605 if ( ( 1 == tlMetaInfo.ucIsWai ) ||
7606 ( 0 == tlMetaInfo.ucDisableFrmXtl ) )
7607#else
7608 /*------------------------------------------------------------------------
7609 Translate 802.3 frame to 802.11 if Frame translation is enabled
7610 ------------------------------------------------------------------------*/
7611 if ( ( 0 == tlMetaInfo.ucDisableFrmXtl ) &&
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307612 ( 0 != pClientSTA->wSTADesc.ucSwFrameTXXlation) )
Jeff Johnson295189b2012-06-20 16:38:30 -07007613#endif //#ifdef FEATURE_WLAN_WAPI
7614 {
Kiran Venkatappacab0d352012-12-17 13:09:22 -08007615 vosStatus = WLANTL_Translate8023To80211Header( vosDataBuff, &vosStatus,
7616 pTLCb, &ucSTAId,
Ravi Joshid0699502013-07-08 15:48:47 -07007617 &tlMetaInfo, &ucWDSEnabled,
7618 &extraHeadSpace);
Jeff Johnson295189b2012-06-20 16:38:30 -07007619 if ( VOS_STATUS_SUCCESS != vosStatus )
7620 {
7621 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7622 "WLAN TL:Error when translating header WLANTL_STATxConn"));
7623
7624 return vosStatus;
7625 }
7626
7627 tlMetaInfo.ucDisableFrmXtl = 1;
7628 }
7629
7630 /*-------------------------------------------------------------------------
7631 Call HAL to fill BD header
7632 -------------------------------------------------------------------------*/
7633 ucTypeSubtype |= (WLANTL_80211_DATA_TYPE << 4);
7634
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307635 if ( pClientSTA->wSTADesc.ucQosEnabled )
Jeff Johnson295189b2012-06-20 16:38:30 -07007636 {
7637 ucTypeSubtype |= (WLANTL_80211_DATA_QOS_SUBTYPE);
7638 }
7639
Gopichand Nakkala8b54e912013-03-11 10:44:21 +05307640#ifdef FEATURE_WLAN_WAPI
7641 /* TL State does not transition to AUTHENTICATED till GTK is installed, So in
7642 * case of WPA where GTK handshake is done after the 4 way handshake, the
7643 * unicast 2/2 EAPOL packet from the STA->AP has to be encrypted even before
7644 * the TL is in authenticated state. Since the PTK has been installed
7645 * already (after the 4 way handshake) we make sure that all traffic
7646 * is encrypted henceforth.(Note: TL is still not in AUTHENTICATED state so
7647 * we will only allow EAPOL data or WAI in case of WAPI)
7648 */
7649 if (tlMetaInfo.ucIsEapol && pClientSTA->ptkInstalled)
7650 {
7651 txFlag = 0;
7652 }
7653#else
7654 if (pClientSTA->ptkInstalled)
7655 {
7656 txFlag = 0;
7657 }
7658#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007659
7660 vosStatus = (VOS_STATUS)WDA_DS_BuildTxPacketInfo( pvosGCtx, vosDataBuff , &vDestMacAddr,
7661 tlMetaInfo.ucDisableFrmXtl, &usPktLen,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307662 pClientSTA->wSTADesc.ucQosEnabled, ucWDSEnabled,
Jeff Johnson295189b2012-06-20 16:38:30 -07007663 extraHeadSpace,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307664 ucTypeSubtype, &pClientSTA->wSTADesc.vSelfMACAddress,
Gopichand Nakkala8b54e912013-03-11 10:44:21 +05307665 ucTid, txFlag,
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -07007666 tlMetaInfo.usTimeStamp, tlMetaInfo.ucIsEapol || tlMetaInfo.ucIsWai, tlMetaInfo.ucUP );
Jeff Johnson295189b2012-06-20 16:38:30 -07007667
7668 if ( VOS_STATUS_SUCCESS != vosStatus )
7669 {
7670 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7671 "WLAN TL:Failed while attempting to fill BD %d", vosStatus));
7672 *pvosDataBuff = NULL;
7673 return vosStatus;
7674 }
7675
Nirav Shah4f765af2015-01-21 19:51:30 +05307676
7677
7678 // call ULA complete once M4 BD is filled.
7679 if (tlMetaInfo.ucEapolSubType == EAPOL_M4)
7680 {
Nirav Shahf6bd2672015-03-11 12:53:15 +05307681 if (!VOS_IS_STATUS_SUCCESS(vos_lock_acquire(&(pClientSTA->ulaLock))))
7682 {
7683 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7684 "%s Get ULA Lock Fail", __func__));
7685 return VOS_STATUS_E_FAILURE;
7686 }
7687
Nirav Shah4f765af2015-01-21 19:51:30 +05307688 pClientSTA->isEapolM4Transmitted = 1;
7689 if (pClientSTA->pfnSTAUlaComplete)
7690 pClientSTA->pfnSTAUlaComplete(pClientSTA->pUlaCBCtx);
7691 pClientSTA->pfnSTAUlaComplete = NULL;
7692 pClientSTA->pUlaCBCtx = NULL;
Nirav Shahf6bd2672015-03-11 12:53:15 +05307693
7694 if (!VOS_IS_STATUS_SUCCESS(vos_lock_release(&(pClientSTA->ulaLock))))
7695 {
7696 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7697 "%s Release ULA Lock Fail", __func__));
7698 return VOS_STATUS_E_FAILURE;
7699 }
Nirav Shah4f765af2015-01-21 19:51:30 +05307700 }
7701
Jeff Johnson295189b2012-06-20 16:38:30 -07007702 /*-----------------------------------------------------------------------
7703 Update tx counter for BA session query for tx side
7704 !1 - should this be done for EAPOL frames?
7705 -----------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307706 pClientSTA->auTxCount[ucTid]++;
Jeff Johnson295189b2012-06-20 16:38:30 -07007707
7708 vos_pkt_set_user_data_ptr( vosDataBuff, VOS_PKT_USER_DATA_ID_TL,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307709 (v_PVOID_t)pClientSTA->pfnSTATxComp );
Jeff Johnson295189b2012-06-20 16:38:30 -07007710
7711 /*------------------------------------------------------------------------
7712 Save data to input pointer for TL core
7713 ------------------------------------------------------------------------*/
7714 *pvosDataBuff = vosDataBuff;
7715 /*security frames cannot be delayed*/
7716 pTLCb->bUrgent = TRUE;
7717
Jeff Johnson295189b2012-06-20 16:38:30 -07007718 /* TX Statistics */
7719 if (!(tlMetaInfo.ucBcast || tlMetaInfo.ucMcast))
7720 {
7721 /* This is TX UC frame */
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307722 pClientSTA->trafficStatistics.txUCFcnt++;
7723 pClientSTA->trafficStatistics.txUCBcnt += usPktLen;
Jeff Johnson295189b2012-06-20 16:38:30 -07007724 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007725
7726 return VOS_STATUS_SUCCESS;
7727}/* WLANTL_STATxConn */
7728
7729
7730/*==========================================================================
7731 FUNCTION WLANTL_STATxAuth
7732
7733 DESCRIPTION
7734 Transmit in authenticated state - all data allowed
7735
7736 DEPENDENCIES
7737 The STA must be registered with TL before this function can be called.
7738
7739 PARAMETERS
7740
7741 IN
7742 pvosGCtx: pointer to the global vos context; a handle to TL's
7743 control block can be extracted from its context
7744 ucSTAId: identifier of the station being processed
7745 vosDataBuff: pointer to the tx vos buffer
7746
7747 RETURN VALUE
7748 The result code associated with performing the operation
7749
7750 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
7751 page fault
7752 VOS_STATUS_SUCCESS: Everything is good :)
7753
7754 Other return values are possible coming from the called functions.
7755 Please check API for additional info.
7756
7757 SIDE EFFECTS
7758
7759============================================================================*/
7760VOS_STATUS
7761WLANTL_STATxAuth
7762(
7763 v_PVOID_t pvosGCtx,
7764 v_U8_t ucSTAId,
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07007765 vos_pkt_t** pvosDataBuff,
7766 v_BOOL_t bForwardIAPPwithLLC
Jeff Johnson295189b2012-06-20 16:38:30 -07007767)
7768{
7769 v_U16_t usPktLen;
7770 VOS_STATUS vosStatus;
7771 v_MACADDR_t vDestMacAddr;
7772 vos_pkt_t* vosDataBuff = NULL;
7773 WLANTL_CbType* pTLCb = NULL;
7774 WLANTL_MetaInfoType tlMetaInfo;
7775 v_U8_t ucTypeSubtype = 0;
7776 WLANTL_ACEnumType ucAC;
7777 WLANTL_ACEnumType ucNextAC;
7778 v_U8_t ucTid;
7779 v_U8_t ucSwFrmXtl = 0;
7780 v_U8_t extraHeadSpace = 0;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307781 WLANTL_STAClientType *pStaClient = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07007782 v_U8_t ucWDSEnabled = 0;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05307783 v_U32_t ucTxFlag = 0;
Abhishek Singh45e68fe2014-12-11 12:55:59 +05307784 v_U8_t ucACMask, i;
Jeff Johnson295189b2012-06-20 16:38:30 -07007785 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
7786
7787 /*------------------------------------------------------------------------
7788 Sanity check
7789 Extract TL control block
7790 ------------------------------------------------------------------------*/
7791 pTLCb = VOS_GET_TL_CB(pvosGCtx);
7792 if (( NULL == pTLCb ) || ( NULL == pvosDataBuff ))
7793 {
7794 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson0298bd02013-11-14 19:58:38 -08007795 "WLAN TL:Invalid input params on WLANTL_STATxAuth TL %p DB %p",
Jeff Johnson295189b2012-06-20 16:38:30 -07007796 pTLCb, pvosDataBuff));
7797 if (NULL != pvosDataBuff)
7798 {
7799 *pvosDataBuff = NULL;
7800 }
7801 if(NULL != pTLCb)
7802 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307803 if ( NULL == pTLCb->atlSTAClients[ucSTAId] )
7804 {
7805 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7806 "WLAN TL:Client Memory was not allocated on %s", __func__));
7807 return VOS_STATUS_E_FAILURE;
7808 }
7809 pTLCb->atlSTAClients[ucSTAId]->ucNoMoreData = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07007810 }
7811 return VOS_STATUS_E_FAULT;
7812 }
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307813 pStaClient = pTLCb->atlSTAClients[ucSTAId];
Jeff Johnson295189b2012-06-20 16:38:30 -07007814
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307815 if ( NULL == pStaClient )
7816 {
7817 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7818 "WLAN TL:Client Memory was not allocated on %s", __func__));
7819 return VOS_STATUS_E_FAILURE;
7820 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007821
7822 vos_mem_zero(&tlMetaInfo, sizeof(tlMetaInfo));
7823 /*------------------------------------------------------------------------
7824 Fetch packet from HDD
7825 ------------------------------------------------------------------------*/
Sunil Ravid5406f22013-01-22 00:18:31 -08007826#ifdef FEATURE_WLAN_TDLS
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307827 if ((WLAN_STA_SOFTAP != pStaClient->wSTADesc.wSTAType) &&
Agarwal Ashishcd86f7b2014-06-16 17:11:58 +05307828 (!vos_concurrent_open_sessions_running()) &&
Sunil Ravid5406f22013-01-22 00:18:31 -08007829 !pTLCb->ucTdlsPeerCount)
7830 {
7831#else
Jeff Johnson295189b2012-06-20 16:38:30 -07007832 if ((WLAN_STA_SOFTAP != pStaClient->wSTADesc.wSTAType) &&
Agarwal Ashishcd86f7b2014-06-16 17:11:58 +05307833 (!vos_concurrent_open_sessions_running()))
Jeff Johnson295189b2012-06-20 16:38:30 -07007834 {
7835#endif
7836 ucAC = pStaClient->ucCurrentAC;
7837
7838 /*-------------------------------------------------------------------
7839 Disable AC temporary - if successfull retrieve re-enable
7840 The order is justified because of the possible scenario
7841 - TL tryes to fetch packet for AC and it returns NULL
7842 - TL analyzes the data it has received to see if there are
7843 any more pkts available for AC -> if not TL will disable AC
7844 - however it is possible that while analyzing results TL got
7845 preempted by a pending indication where the mask was again set
7846 TL will not check again and as a result when it resumes
7847 execution it will disable AC
7848 To prevent this the AC will be disabled here and if retrieve
7849 is successfull it will be re-enabled
7850 -------------------------------------------------------------------*/
7851 pStaClient->aucACMask[pStaClient->ucCurrentAC] = 0;
7852
7853 // don't reset it, as other AC queues in HDD may have packets
7854 //vos_atomic_set_U8( &pStaClient->ucPktPending, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07007855 }
7856 else
7857 {
7858 //softap case
7859 ucAC = pTLCb->uCurServedAC;
7860 pStaClient->aucACMask[ucAC] = 0;
7861
7862 //vos_atomic_set_U8( &pStaClient->ucPktPending, 0);
7863 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007864
7865 WLAN_TL_AC_ARRAY_2_MASK( pStaClient, ucACMask, i);
Jeff Johnson295189b2012-06-20 16:38:30 -07007866 /*You make an initial assumption that HDD has no more data and if the
7867 assumption was wrong you reset the flags to their original state
7868 This will prevent from exposing a race condition between checking with HDD
7869 for packets and setting the flags to false*/
7870 if ( 0 == ucACMask )
7871 {
7872 vos_atomic_set_U8( &pStaClient->ucPktPending, 0);
7873 pStaClient->ucNoMoreData = 1;
7874 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007875
7876 vosStatus = pStaClient->pfnSTAFetchPkt( pvosGCtx,
7877 &ucSTAId,
7878 ucAC,
7879 &vosDataBuff, &tlMetaInfo );
7880
7881
7882 if (( VOS_STATUS_SUCCESS != vosStatus ) || ( NULL == vosDataBuff ))
7883 {
7884
7885 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05307886 "WLAN TL:Failed while attempting to fetch pkt from HDD QId:%d status:%d",
7887 ucAC, vosStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07007888 *pvosDataBuff = NULL;
7889 /*--------------------------------------------------------------------
7890 Reset AC for the serviced station to the highest priority AC
7891 -> due to no more data at the station
7892 Even if this AC is not supported by the station, correction will be
7893 made in the main TL loop
7894 --------------------------------------------------------------------*/
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05307895 pStaClient->ucCurrentAC = WLANTL_AC_HIGH_PRIO;
Jeff Johnson295189b2012-06-20 16:38:30 -07007896 pStaClient->ucCurrentWeight = 0;
7897
7898 return vosStatus;
7899 }
7900
Jeff Johnsone7245742012-09-05 17:12:55 -07007901 WLANTL_StatHandleTXFrame(pvosGCtx, ucSTAId, vosDataBuff, NULL, &tlMetaInfo);
Jeff Johnsone7245742012-09-05 17:12:55 -07007902
Jeff Johnson295189b2012-06-20 16:38:30 -07007903 /*There are still packets in HDD - set back the pending packets and
7904 the no more data assumption*/
7905 vos_atomic_set_U8( &pStaClient->ucPktPending, 1);
7906 pStaClient->ucNoMoreData = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07007907
Jeff Johnson295189b2012-06-20 16:38:30 -07007908 if (WLAN_STA_SOFTAP != pStaClient->wSTADesc.wSTAType)
7909 {
Jeff Johnson295189b2012-06-20 16:38:30 -07007910 // don't need to set it, as we don't reset it in this function.
7911 //vos_atomic_set_U8( &pTLCb->atlSTAClients[ucSTAId].ucPktPending, 1);
Jeff Johnson295189b2012-06-20 16:38:30 -07007912 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007913
7914#ifdef WLAN_PERF
7915 vos_pkt_set_user_data_ptr( vosDataBuff, VOS_PKT_USER_DATA_ID_BAL,
7916 (v_PVOID_t)0);
7917#endif /*WLAN_PERF*/
7918
7919 /*-------------------------------------------------------------------------
7920 Check TID
7921 -------------------------------------------------------------------------*/
7922 ucTid = tlMetaInfo.ucTID;
7923
7924 /*Make sure TID is valid*/
7925 if ( WLANTL_TID_INVALID(ucTid))
7926 {
Rajesh Chauhan2df40bf2013-08-22 11:26:12 -07007927 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
Jeff Johnson295189b2012-06-20 16:38:30 -07007928 "WLAN TL:Invalid TID sent in meta info %d - defaulting to 0 (BE)",
7929 ucTid));
7930 ucTid = 0;
7931 }
7932
7933 /*Save for UAPSD timer consideration*/
7934 pStaClient->ucServicedAC = ucAC;
7935
7936 if ( ucAC == pStaClient->ucCurrentAC )
7937 {
7938 pStaClient->aucACMask[pStaClient->ucCurrentAC] = 1;
7939 pStaClient->ucCurrentWeight--;
7940 }
7941 else
7942 {
7943 pStaClient->ucCurrentAC = ucAC;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307944 pStaClient->ucCurrentWeight = pTLCb->tlConfigInfo.ucAcWeights[ucAC] - 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07007945
7946 pStaClient->aucACMask[pStaClient->ucCurrentAC] = 1;
7947
7948 }
7949
Jeff Johnson295189b2012-06-20 16:38:30 -07007950 if (WLAN_STA_SOFTAP != pStaClient->wSTADesc.wSTAType)
7951 {
Jeff Johnson295189b2012-06-20 16:38:30 -07007952 if ( 0 == pStaClient->ucCurrentWeight )
7953 {
7954 WLANTL_ACEnumType tempAC = ucAC;
7955 /*-----------------------------------------------------------------------
7956 Choose next AC - !!! optimize me
7957 -----------------------------------------------------------------------*/
7958 while ( 0 != ucACMask )
7959 {
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05307960 if(tempAC == WLANTL_AC_BK)
7961 ucNextAC = WLANTL_AC_HIGH_PRIO;
7962 else
7963 ucNextAC = (tempAC - 1);
7964
Jeff Johnson295189b2012-06-20 16:38:30 -07007965 if ( 0 != pStaClient->aucACMask[ucNextAC] )
7966 {
7967 pStaClient->ucCurrentAC = ucNextAC;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307968 pStaClient->ucCurrentWeight = pTLCb->tlConfigInfo.ucAcWeights[ucNextAC];
Jeff Johnson295189b2012-06-20 16:38:30 -07007969
7970 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
7971 "WLAN TL: Changing serviced AC to: %d with Weight: %d",
7972 pStaClient->ucCurrentAC ,
7973 pStaClient->ucCurrentWeight));
7974 break;
7975 }
7976 tempAC = ucNextAC;
7977 }
7978 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007979 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007980
7981 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
7982 "WLAN TL:Attaching BD header to pkt on WLANTL_STATxAuth"));
7983
7984 /*------------------------------------------------------------------------
7985 Translate 802.3 frame to 802.11
7986 ------------------------------------------------------------------------*/
7987 if ( 0 == tlMetaInfo.ucDisableFrmXtl )
7988 {
7989 /* Needs frame translation */
7990 // if the client has not enabled SW-only frame translation
7991 // and if the frame is a unicast frame
7992 // (HW frame translation does not support multiple broadcast domains
7993 // so we use SW frame translation for broadcast/multicast frames)
7994#ifdef FEATURE_WLAN_WAPI
7995 // and if the frame is not a WAPI frame
7996#endif
7997 // then use HW_based frame translation
7998
7999 if ( ( 0 == pStaClient->wSTADesc.ucSwFrameTXXlation ) &&
8000 ( 0 == tlMetaInfo.ucBcast ) &&
8001 ( 0 == tlMetaInfo.ucMcast )
8002#ifdef FEATURE_WLAN_WAPI
8003 && ( tlMetaInfo.ucIsWai != 1 )
8004#endif
8005 )
8006 {
8007#ifdef WLAN_PERF
8008 v_U32_t uFastFwdOK = 0;
8009
8010 /* HW based translation. See if the frame could be fast forwarded */
8011 WDA_TLI_FastHwFwdDataFrame( pvosGCtx, vosDataBuff , &vosStatus,
8012 &uFastFwdOK, &tlMetaInfo, &pStaClient->wSTADesc);
8013
8014 if( VOS_STATUS_SUCCESS == vosStatus )
8015 {
8016 if(uFastFwdOK)
8017 {
8018 /* Packet could be fast forwarded now */
8019 vos_pkt_set_user_data_ptr( vosDataBuff, VOS_PKT_USER_DATA_ID_TL,
8020 (v_PVOID_t)pStaClient->pfnSTATxComp );
8021
8022 *pvosDataBuff = vosDataBuff;
8023
8024 /* TODO: Do we really need to update WLANTL_HSHandleTXFrame()
8025 stats for every pkt? */
8026 pStaClient->auTxCount[tlMetaInfo.ucTID]++;
8027 return vosStatus;
8028 }
8029 /* can't be fast forwarded, fall through normal (slow) path. */
8030 }
8031 else
8032 {
8033
8034 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8035 "WLAN TL:Failed while attempting to fastFwd BD %d", vosStatus));
8036 *pvosDataBuff = NULL;
8037 return vosStatus;
8038 }
8039#endif /*WLAN_PERF*/
8040 }
8041 else
8042 {
8043 /* SW based translation */
8044
8045#ifdef FEATURE_WLAN_WAPI
8046 gUcIsWai = tlMetaInfo.ucIsWai,
8047#endif
8048
Kiran Venkatappacab0d352012-12-17 13:09:22 -08008049 vosStatus = WLANTL_Translate8023To80211Header( vosDataBuff, &vosStatus,
8050 pTLCb, &ucSTAId,
Ravi Joshid0699502013-07-08 15:48:47 -07008051 &tlMetaInfo, &ucWDSEnabled,
8052 &extraHeadSpace);
Jeff Johnson295189b2012-06-20 16:38:30 -07008053 if ( VOS_STATUS_SUCCESS != vosStatus )
8054 {
8055 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8056 "WLAN TL:Error when translating header WLANTL_STATxAuth"));
8057 return vosStatus;
8058 }
8059
8060 TLLOG4(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_LOW,
Arif Hussainf2b00992013-11-17 21:46:15 -08008061 "WLAN TL software translation success"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008062 ucSwFrmXtl = 1;
8063 tlMetaInfo.ucDisableFrmXtl = 1;
8064 }
8065 }
Gopichand Nakkala574f6d12013-06-27 19:38:43 +05308066#ifdef FEATURE_WLAN_TDLS
8067 /*In case of TDLS, if the packet is destined to TDLS STA ucSTAId may
8068 change. so update the pStaClient accordingly */
8069 pStaClient = pTLCb->atlSTAClients[ucSTAId];
Jeff Johnson295189b2012-06-20 16:38:30 -07008070
Gopichand Nakkala574f6d12013-06-27 19:38:43 +05308071 if ( NULL == pStaClient )
8072 {
8073 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8074 "pStaClient is NULL %s", __func__));
8075 return VOS_STATUS_E_FAILURE;
8076 }
8077#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07008078 /*-------------------------------------------------------------------------
8079 Call HAL to fill BD header
8080 -------------------------------------------------------------------------*/
8081 ucTypeSubtype |= (WLANTL_80211_DATA_TYPE << 4);
8082
8083 if ( pStaClient->wSTADesc.ucQosEnabled )
8084 {
8085 ucTypeSubtype |= (WLANTL_80211_DATA_QOS_SUBTYPE);
8086 }
8087
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05308088 /* ucAC now points to TL Q ID with a new queue added in TL,
8089 * hence look for the uapsd info for the correct AC that
8090 * this packet belongs to.
8091 */
8092 ucTxFlag = (0 != pStaClient->wUAPSDInfo[tlMetaInfo.ac].ucSet)?
Jeff Johnson295189b2012-06-20 16:38:30 -07008093 HAL_TRIGGER_ENABLED_AC_MASK:0;
8094
8095#ifdef FEATURE_WLAN_WAPI
8096 if ( pStaClient->wSTADesc.ucIsWapiSta == 1 )
8097 {
8098#ifdef LIBRA_WAPI_SUPPORT
8099 ucTxFlag = ucTxFlag | HAL_WAPI_STA_MASK;
8100#endif //LIBRA_WAPI_SUPPORT
8101 if ( tlMetaInfo.ucIsWai == 1 )
8102 {
8103 ucTxFlag = ucTxFlag | HAL_TX_NO_ENCRYPTION_MASK;
8104 }
8105 }
8106#endif /* FEATURE_WLAN_WAPI */
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008107#ifdef FEATURE_WLAN_TDLS
8108 if ( pStaClient->wSTADesc.wSTAType == WLAN_STA_TDLS )
8109 {
8110 ucTxFlag = ucTxFlag | HAL_TDLS_PEER_STA_MASK;
8111 }
8112#endif /* FEATURE_WLAN_TDLS */
Abhishek Singhfa011222014-04-14 10:57:08 +05308113 if( tlMetaInfo.ucIsArp )
8114 {
8115 /*Send ARP at lowest Phy rate and through WQ5 */
8116 ucTxFlag |= HAL_USE_BD_RATE_MASK;
Abhishek Singhfa011222014-04-14 10:57:08 +05308117 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008118
8119 vosStatus = (VOS_STATUS)WDA_DS_BuildTxPacketInfo( pvosGCtx,
8120 vosDataBuff , &vDestMacAddr,
8121 tlMetaInfo.ucDisableFrmXtl, &usPktLen,
8122 pStaClient->wSTADesc.ucQosEnabled, ucWDSEnabled,
8123 extraHeadSpace,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308124 ucTypeSubtype, &pStaClient->wSTADesc.vSelfMACAddress,
Jeff Johnson295189b2012-06-20 16:38:30 -07008125 ucTid, ucTxFlag, tlMetaInfo.usTimeStamp,
8126 tlMetaInfo.ucIsEapol, tlMetaInfo.ucUP );
8127
8128 if(!VOS_IS_STATUS_SUCCESS(vosStatus))
8129 {
8130 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8131 "Fill TX BD Error status %d", vosStatus));
8132
8133 return vosStatus;
8134 }
8135
Jeff Johnson295189b2012-06-20 16:38:30 -07008136 /* TX Statistics */
8137 if (!(tlMetaInfo.ucBcast || tlMetaInfo.ucMcast))
8138 {
8139 /* This is TX UC frame */
8140 pStaClient->trafficStatistics.txUCFcnt++;
8141 pStaClient->trafficStatistics.txUCBcnt += usPktLen;
8142 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008143
Kiran Venkatappacab0d352012-12-17 13:09:22 -08008144#ifndef FEATURE_WLAN_TDLS
Jeff Johnson295189b2012-06-20 16:38:30 -07008145 /*-----------------------------------------------------------------------
8146 Update tx counter for BA session query for tx side
8147 -----------------------------------------------------------------------*/
8148 pStaClient->auTxCount[ucTid]++;
Kiran Venkatappacab0d352012-12-17 13:09:22 -08008149#else
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308150 pTLCb->atlSTAClients[ucSTAId]->auTxCount[ucTid]++;
Kiran Venkatappacab0d352012-12-17 13:09:22 -08008151#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07008152
8153 /* This code is to send traffic with lower priority AC when we does not
8154 get admitted to send it. Today HAL does not downgrade AC so this code
8155 does not get executed.(In other words, HAL doesnÂ’t change tid. The if
8156 statement is always false.)
8157 NOTE: In the case of LA downgrade occurs in HDD (that was the change
8158 Phani made during WMM-AC plugfest). If WM & BMP also took this approach,
8159 then there will be no need for any AC downgrade logic in TL/WDI. */
8160#if 0
8161 if (( ucTid != tlMetaInfo.ucTID ) &&
8162 ( 0 != pStaClient->wSTADesc.ucQosEnabled ) &&
8163 ( 0 != ucSwFrmXtl ))
8164 {
8165 /*---------------------------------------------------------------------
8166 !! FIX me: Once downgrading is clear put in the proper change
8167 ---------------------------------------------------------------------*/
8168 ucQCOffset = WLANHAL_TX_BD_HEADER_SIZE + WLANTL_802_11_HEADER_LEN;
8169
8170 //!!!Fix this replace peek with extract
8171 vos_pkt_peek_data( vosDataBuff, ucQCOffset,(v_PVOID_t)&pucQosCtrl,
8172 sizeof(*pucQosCtrl));
8173 *pucQosCtrl = ucTid; //? proper byte order
8174 }
8175#endif
8176
8177 if ( VOS_STATUS_SUCCESS != vosStatus )
8178 {
8179 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8180 "WLAN TL:Failed while attempting to fill BD %d", vosStatus));
8181 *pvosDataBuff = NULL;
8182 return vosStatus;
8183 }
8184
8185 vos_pkt_set_user_data_ptr( vosDataBuff, VOS_PKT_USER_DATA_ID_TL,
8186 (v_PVOID_t)pStaClient->pfnSTATxComp );
8187
8188 *pvosDataBuff = vosDataBuff;
8189
8190 /*BE & BK can be delayed, VO and VI not frames cannot be delayed*/
8191 if ( pStaClient->ucServicedAC > WLANTL_AC_BE )
8192 {
8193 pTLCb->bUrgent= TRUE;
8194 }
8195
8196 return VOS_STATUS_SUCCESS;
8197}/* WLANTL_STATxAuth */
8198
8199/*==========================================================================
8200 FUNCTION WLANTL_STATxDisc
8201
8202 DESCRIPTION
8203 Transmit in disconnected state - no data allowed
8204
8205 DEPENDENCIES
8206 The STA must be registered with TL before this function can be called.
8207
8208 PARAMETERS
8209
8210 IN
8211 pvosGCtx: pointer to the global vos context; a handle to TL's
8212 control block can be extracted from its context
8213 ucSTAId: identifier of the station being processed
8214 vosDataBuff: pointer to the tx vos buffer
8215
8216 RETURN VALUE
8217 The result code associated with performing the operation
8218
8219 VOS_STATUS_SUCCESS: Everything is good :)
8220
8221 SIDE EFFECTS
8222
8223============================================================================*/
8224VOS_STATUS
8225WLANTL_STATxDisc
8226(
8227 v_PVOID_t pvosGCtx,
8228 v_U8_t ucSTAId,
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07008229 vos_pkt_t** pvosDataBuff,
8230 v_BOOL_t bForwardIAPPwithLLC
Jeff Johnson295189b2012-06-20 16:38:30 -07008231)
8232{
8233 WLANTL_CbType* pTLCb = NULL;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308234 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07008235 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
8236
Jeff Johnson295189b2012-06-20 16:38:30 -07008237 /*------------------------------------------------------------------------
8238 Sanity check
8239 Extract TL control block
8240 ------------------------------------------------------------------------*/
8241 pTLCb = VOS_GET_TL_CB(pvosGCtx);
8242 if ( NULL == pTLCb )
8243 {
8244 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8245 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_STATxAuth"));
8246 *pvosDataBuff = NULL;
8247 return VOS_STATUS_E_FAULT;
8248 }
8249
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308250 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
8251
8252 if ( NULL == pClientSTA )
8253 {
8254 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8255 "WLAN TL:Client Memory was not allocated on %s", __func__));
8256 return VOS_STATUS_E_FAILURE;
8257 }
8258
Jeff Johnson295189b2012-06-20 16:38:30 -07008259 /*------------------------------------------------------------------------
8260 Error
8261 ------------------------------------------------------------------------*/
8262 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
8263 "WLAN TL:Packet should not be transmitted in state disconnected ignoring"
8264 " request"));
8265
8266 *pvosDataBuff = NULL;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308267 pClientSTA->ucNoMoreData = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07008268
8269 //Should not be anything pending in disconnect state
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308270 vos_atomic_set_U8( &pClientSTA->ucPktPending, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07008271
8272 return VOS_STATUS_SUCCESS;
8273}/* WLANTL_STATxDisc */
8274
8275/*==========================================================================
8276 FUNCTION WLANTL_STARxConn
8277
8278 DESCRIPTION
8279 Receive in connected state - only EAPOL
8280
8281 DEPENDENCIES
8282 The STA must be registered with TL before this function can be called.
8283
8284 PARAMETERS
8285
8286 IN
8287 pvosGCtx: pointer to the global vos context; a handle to TL's
8288 control block can be extracted from its context
8289 ucSTAId: identifier of the station being processed
8290 vosDataBuff: pointer to the tx/rx vos buffer
8291
8292 RETURN VALUE
8293 The result code associated with performing the operation
8294
8295 VOS_STATUS_E_INVAL: invalid input parameters
8296 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
8297 page fault
8298 VOS_STATUS_SUCCESS: Everything is good :)
8299
8300 SIDE EFFECTS
8301
8302============================================================================*/
8303VOS_STATUS
8304WLANTL_STARxConn
8305(
8306 v_PVOID_t pvosGCtx,
8307 v_U8_t ucSTAId,
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07008308 vos_pkt_t** pvosDataBuff,
8309 v_BOOL_t bForwardIAPPwithLLC
Jeff Johnson295189b2012-06-20 16:38:30 -07008310)
8311{
8312 WLANTL_CbType* pTLCb = NULL;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308313 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07008314 v_U16_t usEtherType = 0;
8315 v_U16_t usPktLen;
8316 v_U8_t ucMPDUHOffset;
8317 v_U16_t usMPDUDOffset;
8318 v_U16_t usMPDULen;
8319 v_U8_t ucMPDUHLen;
8320 v_U16_t usActualHLen = 0;
8321 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
8322 vos_pkt_t* vosDataBuff;
8323 v_PVOID_t aucBDHeader;
8324 v_U8_t ucTid;
8325 WLANTL_RxMetaInfoType wRxMetaInfo;
8326 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
8327
8328 /*------------------------------------------------------------------------
8329 Sanity check
8330 ------------------------------------------------------------------------*/
8331 if (( NULL == pvosDataBuff ) || ( NULL == ( vosDataBuff = *pvosDataBuff )))
8332 {
8333 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8334 "WLAN TL:Invalid parameter sent on WLANTL_STARxConn"));
8335 return VOS_STATUS_E_INVAL;
8336 }
8337
8338 /*------------------------------------------------------------------------
8339 Extract TL control block
8340 ------------------------------------------------------------------------*/
8341 pTLCb = VOS_GET_TL_CB(pvosGCtx);
8342 if ( NULL == pTLCb )
8343 {
8344 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8345 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_ChangeSTAState"));
8346 return VOS_STATUS_E_FAULT;
8347 }
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308348 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
8349
8350 if ( NULL == pClientSTA )
8351 {
8352 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8353 "WLAN TL:Client Memory was not allocated on %s", __func__));
8354 return VOS_STATUS_E_FAILURE;
8355 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008356
8357 /*------------------------------------------------------------------------
8358 Extract BD header and check if valid
8359 ------------------------------------------------------------------------*/
8360 vosStatus = WDA_DS_PeekRxPacketInfo( vosDataBuff, (v_PVOID_t)&aucBDHeader, 0/*Swap BD*/ );
8361
8362 if ( NULL == aucBDHeader )
8363 {
8364 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8365 "WLAN TL:Cannot extract BD header"));
8366 VOS_ASSERT( 0 );
8367 return VOS_STATUS_E_FAULT;
8368 }
8369
8370
8371 ucMPDUHOffset = (v_U8_t)WDA_GET_RX_MPDU_HEADER_OFFSET(aucBDHeader);
8372 usMPDUDOffset = (v_U16_t)WDA_GET_RX_MPDU_DATA_OFFSET(aucBDHeader);
8373 usMPDULen = (v_U16_t)WDA_GET_RX_MPDU_LEN(aucBDHeader);
8374 ucMPDUHLen = (v_U8_t)WDA_GET_RX_MPDU_HEADER_LEN(aucBDHeader);
8375 ucTid = (v_U8_t)WDA_GET_RX_TID(aucBDHeader);
8376
8377 vos_pkt_get_packet_length( vosDataBuff, &usPktLen);
8378
8379 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
8380 "WLAN TL:BD header processing data: HO %d DO %d Len %d HLen %d",
8381 ucMPDUHOffset, usMPDUDOffset, usMPDULen, ucMPDUHLen));
8382
8383 /*It will cut out the 802.11 header if not used*/
8384 if ( VOS_STATUS_SUCCESS != WDA_DS_TrimRxPacketInfo( vosDataBuff ) )
8385 {
8386 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
8387 "WLAN TL:BD header corrupted - dropping packet"));
8388 /* Drop packet */
8389 vos_pkt_return_packet(vosDataBuff);
8390 return VOS_STATUS_SUCCESS;
8391 }
8392
8393 vosStatus = WLANTL_GetEtherType(aucBDHeader,vosDataBuff,ucMPDUHLen,&usEtherType);
8394
8395 if( VOS_IS_STATUS_SUCCESS(vosStatus) )
8396 {
8397#ifdef FEATURE_WLAN_WAPI
8398 /* If frame is neither an EAPOL frame nor a WAI frame then we drop the frame*/
8399 /* TODO: Do we need a check to see if we are in WAPI mode? If not is it possible */
8400 /* that we get an EAPOL packet in WAPI mode or vice versa? */
8401 if ( WLANTL_LLC_8021X_TYPE != usEtherType && WLANTL_LLC_WAI_TYPE != usEtherType )
8402 {
Sunil Ravid5406f22013-01-22 00:18:31 -08008403 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07008404 "WLAN TL:RX Frame not EAPOL or WAI EtherType %d - dropping", usEtherType );
Jeff Johnson295189b2012-06-20 16:38:30 -07008405 /* Drop packet */
8406 vos_pkt_return_packet(vosDataBuff);
8407 }
8408#else
8409 if ( WLANTL_LLC_8021X_TYPE != usEtherType )
8410 {
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07008411 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8412 "WLAN TL:RX Frame not EAPOL EtherType %d - dropping", usEtherType);
Jeff Johnson295189b2012-06-20 16:38:30 -07008413 /* Drop packet */
8414 vos_pkt_return_packet(vosDataBuff);
8415 }
8416#endif /* FEATURE_WLAN_WAPI */
8417 else /* Frame is an EAPOL frame or a WAI frame*/
8418 {
Katya Nigam42e16e82014-02-04 16:28:55 +05308419 MTRACE(vos_trace(VOS_MODULE_ID_TL,
8420 TRACE_CODE_TL_RX_CONN_EAPOL, ucSTAId, usEtherType ));
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07008421
Madan Mohan Koyyalamudid8000342012-11-08 14:55:26 -08008422 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07008423 "WLAN TL:RX Frame EAPOL EtherType %d - processing", usEtherType);
8424
Jeff Johnson295189b2012-06-20 16:38:30 -07008425 if (( 0 == WDA_GET_RX_FT_DONE(aucBDHeader) ) &&
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308426 ( 0 != pClientSTA->wSTADesc.ucSwFrameRXXlation))
Jeff Johnson295189b2012-06-20 16:38:30 -07008427 {
8428 if (usMPDUDOffset > ucMPDUHOffset)
8429 {
8430 usActualHLen = usMPDUDOffset - ucMPDUHOffset;
8431 }
8432
8433 vosStatus = WLANTL_Translate80211To8023Header( vosDataBuff, &vosStatus, usActualHLen,
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07008434 ucMPDUHLen, pTLCb, ucSTAId, bForwardIAPPwithLLC);
Jeff Johnson295189b2012-06-20 16:38:30 -07008435
8436 if ( VOS_STATUS_SUCCESS != vosStatus )
8437 {
Kaushik, Sushante386ee12014-05-01 15:50:52 +05308438 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
Jeff Johnson295189b2012-06-20 16:38:30 -07008439 "WLAN TL:Failed to translate from 802.11 to 802.3 - dropping"));
8440 /* Drop packet */
8441 vos_pkt_return_packet(vosDataBuff);
8442 return vosStatus;
8443 }
8444 }
8445 /*-------------------------------------------------------------------
8446 Increment receive counter
8447 -------------------------------------------------------------------*/
Madan Mohan Koyyalamudic0e5bd82012-09-18 17:12:27 -07008448 if ( !WLANTL_TID_INVALID( ucTid) )
8449 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308450 pClientSTA->auRxCount[ucTid]++;
Madan Mohan Koyyalamudic0e5bd82012-09-18 17:12:27 -07008451 }
8452 else
8453 {
8454 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8455 "WLAN TL:Invalid tid %d (Station ID %d) on %s",
8456 ucTid, ucSTAId, __func__));
8457 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008458
8459 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
8460 "WLAN TL:Sending EAPoL frame to station %d AC %d", ucSTAId, ucTid));
8461
8462 /*-------------------------------------------------------------------
8463 !!!Assuming TID = UP mapping
8464 -------------------------------------------------------------------*/
8465 wRxMetaInfo.ucUP = ucTid;
8466
Jeff Johnson295189b2012-06-20 16:38:30 -07008467 TLLOG4(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_LOW,
Arif Hussainf2b00992013-11-17 21:46:15 -08008468 "WLAN TL %s:Sending data chain to station", __func__));
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308469 if ( WLAN_STA_SOFTAP == pClientSTA->wSTADesc.wSTAType )
Jeff Johnson295189b2012-06-20 16:38:30 -07008470 {
8471 wRxMetaInfo.ucDesSTAId = WLAN_RX_SAP_SELF_STA_ID;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308472 pClientSTA->pfnSTARx( pvosGCtx, vosDataBuff, ucSTAId,
Jeff Johnson295189b2012-06-20 16:38:30 -07008473 &wRxMetaInfo );
8474 }
8475 else
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308476 pClientSTA->pfnSTARx( pvosGCtx, vosDataBuff, ucSTAId,
Jeff Johnson295189b2012-06-20 16:38:30 -07008477 &wRxMetaInfo );
8478 }/*EAPOL frame or WAI frame*/
8479 }/*vos status success*/
8480
8481 return VOS_STATUS_SUCCESS;
8482}/* WLANTL_STARxConn */
8483
Jeff Johnson295189b2012-06-20 16:38:30 -07008484/*==========================================================================
8485 FUNCTION WLANTL_FwdPktToHDD
8486
8487 DESCRIPTION
8488 Determine the Destation Station ID and route the Frame to Upper Layer
8489
8490 DEPENDENCIES
8491
8492 PARAMETERS
8493
8494 IN
8495 pvosGCtx: pointer to the global vos context; a handle to TL's
8496 control block can be extracted from its context
8497 ucSTAId: identifier of the station being processed
8498 vosDataBuff: pointer to the rx vos buffer
8499
8500 RETURN VALUE
8501 The result code associated with performing the operation
8502
8503 VOS_STATUS_E_INVAL: invalid input parameters
8504 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
8505 page fault
8506 VOS_STATUS_SUCCESS: Everything is good :)
8507
8508 SIDE EFFECTS
8509
8510============================================================================*/
8511
8512VOS_STATUS
8513WLANTL_FwdPktToHDD
8514(
8515 v_PVOID_t pvosGCtx,
8516 vos_pkt_t* pvosDataBuff,
8517 v_U8_t ucSTAId
8518)
8519{
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308520 v_MACADDR_t DestMacAddress;
8521 v_MACADDR_t *pDestMacAddress = &DestMacAddress;
8522 v_SIZE_t usMacAddSize = VOS_MAC_ADDR_SIZE;
Jeff Johnson295189b2012-06-20 16:38:30 -07008523 WLANTL_CbType* pTLCb = NULL;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308524 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07008525 vos_pkt_t* vosDataBuff ;
8526 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
Girish Gowli93e3edd2014-05-01 15:42:31 +05308527 v_U32_t* STAMetaInfoPtr;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308528 vos_pkt_t* vosNextDataBuff ;
8529 v_U8_t ucDesSTAId;
Jeff Johnson295189b2012-06-20 16:38:30 -07008530 WLANTL_RxMetaInfoType wRxMetaInfo;
8531
Jeff Johnson295189b2012-06-20 16:38:30 -07008532 /*------------------------------------------------------------------------
8533 Sanity check
8534 ------------------------------------------------------------------------*/
8535 if (( NULL == pvosDataBuff ) || ( NULL == ( vosDataBuff = pvosDataBuff )))
8536 {
8537 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8538 "WLAN TL:Invalid parameter sent on WLANTL_FwdPktToHdd"));
8539 return VOS_STATUS_E_INVAL;
8540 }
8541
8542 /*------------------------------------------------------------------------
8543 Extract TL control block
8544 ------------------------------------------------------------------------*/
8545 pTLCb = VOS_GET_TL_CB(pvosGCtx);
8546 if ( NULL == pTLCb )
8547 {
8548 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8549 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_FwdPktToHdd"));
8550 return VOS_STATUS_E_FAULT;
8551 }
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308552
Tushnim Bhattacharyya5dd94562013-03-20 20:15:03 -07008553 if(WLANTL_STA_ID_INVALID(ucSTAId))
8554 {
8555 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,"ucSTAId %d is not valid",
8556 ucSTAId));
8557 return VOS_STATUS_E_INVAL;
8558 }
8559
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308560 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
8561
8562 if ( NULL == pClientSTA )
8563 {
8564 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8565 "WLAN TL:Client Memory was not allocated on %s", __func__));
8566 return VOS_STATUS_E_FAILURE;
8567 }
8568
Jeff Johnson295189b2012-06-20 16:38:30 -07008569 /* This the change required for SoftAp to handle Reordered Buffer. Since a STA
8570 may have packets destined to multiple destinations we have to process each packet
8571 at a time and determine its Destination. So the Voschain provided by Reorder code
8572 is unchain and forwarded to Upper Layer after Determining the Destination */
8573
8574 vosDataBuff = pvosDataBuff;
8575 while (vosDataBuff != NULL)
8576 {
8577 vos_pkt_walk_packet_chain( vosDataBuff, &vosNextDataBuff, 1/*true*/ );
8578 vos_pkt_get_user_data_ptr( vosDataBuff, VOS_PKT_USER_DATA_ID_TL,
Girish Gowli93e3edd2014-05-01 15:42:31 +05308579 (v_PVOID_t *)&STAMetaInfoPtr );
8580 wRxMetaInfo.ucUP = (v_U8_t)((uintptr_t)STAMetaInfoPtr & WLANTL_AC_MASK);
8581 ucDesSTAId = (v_U8_t)(((uintptr_t)STAMetaInfoPtr) >> WLANTL_STAID_OFFSET);
Jeff Johnson295189b2012-06-20 16:38:30 -07008582
8583 vosStatus = vos_pkt_extract_data( vosDataBuff, 0, (v_VOID_t *)pDestMacAddress, &usMacAddSize);
8584 if ( VOS_STATUS_SUCCESS != vosStatus )
8585 {
8586 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Arif Hussainf2b00992013-11-17 21:46:15 -08008587 "WLAN TL: recv corrupted data packet"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008588 vos_pkt_return_packet(vosDataBuff);
8589 return vosStatus;
8590 }
8591
Arif Hussaina7c8e412013-11-20 11:06:42 -08008592 TLLOG4(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_LOW,
8593 "station mac "MAC_ADDRESS_STR,
8594 MAC_ADDR_ARRAY(pDestMacAddress->bytes)));
Jeff Johnson295189b2012-06-20 16:38:30 -07008595
8596 if (vos_is_macaddr_broadcast( pDestMacAddress ) || vos_is_macaddr_group(pDestMacAddress))
8597 {
8598 // destination is mc/bc station
8599 ucDesSTAId = WLAN_RX_BCMC_STA_ID;
8600 TLLOG4(VOS_TRACE( VOS_MODULE_ID_HDD_SOFTAP, VOS_TRACE_LEVEL_INFO_LOW,
Arif Hussainf2b00992013-11-17 21:46:15 -08008601 "%s: BC/MC packet, id %d", __func__, WLAN_RX_BCMC_STA_ID));
Jeff Johnson295189b2012-06-20 16:38:30 -07008602 }
8603 else
8604 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308605 if (vos_is_macaddr_equal(pDestMacAddress, &pClientSTA->wSTADesc.vSelfMACAddress))
Jeff Johnson295189b2012-06-20 16:38:30 -07008606 {
8607 // destination is AP itself
8608 ucDesSTAId = WLAN_RX_SAP_SELF_STA_ID;
8609 TLLOG4(VOS_TRACE( VOS_MODULE_ID_HDD_SOFTAP, VOS_TRACE_LEVEL_INFO_LOW,
Arif Hussainf2b00992013-11-17 21:46:15 -08008610 "%s: packet to AP itself, id %d", __func__, WLAN_RX_SAP_SELF_STA_ID));
Jeff Johnson295189b2012-06-20 16:38:30 -07008611 }
Madan Mohan Koyylamudi64258222013-01-30 14:35:10 +05308612 else if (( WLAN_MAX_STA_COUNT <= ucDesSTAId ) || (NULL != pTLCb->atlSTAClients[ucDesSTAId] && pTLCb->atlSTAClients[ucDesSTAId]->ucExists == 0))
Jeff Johnson295189b2012-06-20 16:38:30 -07008613 {
8614 // destination station is something else
8615 TLLOG4(VOS_TRACE( VOS_MODULE_ID_HDD_SOFTAP, VOS_TRACE_LEVEL_INFO_LOW,
Arif Hussainf2b00992013-11-17 21:46:15 -08008616 "%s: get an station index larger than WLAN_MAX_STA_COUNT %d", __func__, ucDesSTAId));
Jeff Johnson295189b2012-06-20 16:38:30 -07008617 ucDesSTAId = WLAN_RX_SAP_SELF_STA_ID;
8618 }
8619
8620
8621 //loopback unicast station comes here
8622 }
8623
Girish Gowli93e3edd2014-05-01 15:42:31 +05308624 wRxMetaInfo.ucUP = (v_U8_t)((uintptr_t)STAMetaInfoPtr & WLANTL_AC_MASK);
Jeff Johnson295189b2012-06-20 16:38:30 -07008625 wRxMetaInfo.ucDesSTAId = ucDesSTAId;
8626
Madan Mohan Koyyalamudi6c2977d2013-09-04 15:42:45 +05308627 vosStatus = pClientSTA->pfnSTARx( pvosGCtx, vosDataBuff, ucDesSTAId,
Jeff Johnson295189b2012-06-20 16:38:30 -07008628 &wRxMetaInfo );
Madan Mohan Koyyalamudi6c2977d2013-09-04 15:42:45 +05308629 if ( VOS_STATUS_SUCCESS != vosStatus )
8630 {
8631 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Arif Hussainf2b00992013-11-17 21:46:15 -08008632 "WLAN TL: failed to send pkt to HDD"));
Madan Mohan Koyyalamudi6c2977d2013-09-04 15:42:45 +05308633 vos_pkt_return_packet(vosDataBuff);
8634
8635 return vosStatus;
8636 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008637 vosDataBuff = vosNextDataBuff;
8638 }
8639 return VOS_STATUS_SUCCESS;
8640}
Jeff Johnson295189b2012-06-20 16:38:30 -07008641
8642/*==========================================================================
8643 FUNCTION WLANTL_STARxAuth
8644
8645 DESCRIPTION
8646 Receive in authenticated state - all data allowed
8647
8648 DEPENDENCIES
8649 The STA must be registered with TL before this function can be called.
8650
8651 PARAMETERS
8652
8653 IN
8654 pvosGCtx: pointer to the global vos context; a handle to TL's
8655 control block can be extracted from its context
8656 ucSTAId: identifier of the station being processed
8657 vosDataBuff: pointer to the rx vos buffer
8658
8659 RETURN VALUE
8660 The result code associated with performing the operation
8661
8662 VOS_STATUS_E_INVAL: invalid input parameters
8663 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
8664 page fault
8665 VOS_STATUS_SUCCESS: Everything is good :)
8666
8667 SIDE EFFECTS
8668
8669============================================================================*/
8670VOS_STATUS
8671WLANTL_STARxAuth
8672(
8673 v_PVOID_t pvosGCtx,
8674 v_U8_t ucSTAId,
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07008675 vos_pkt_t** pvosDataBuff,
8676 v_BOOL_t bForwardIAPPwithLLC
Jeff Johnson295189b2012-06-20 16:38:30 -07008677)
8678{
8679 WLANTL_CbType* pTLCb = NULL;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308680 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07008681 v_U8_t ucAsf; /* AMSDU sub frame */
8682 v_U16_t usMPDUDOffset;
8683 v_U8_t ucMPDUHOffset;
8684 v_U16_t usMPDULen;
8685 v_U8_t ucMPDUHLen;
8686 v_U16_t usActualHLen = 0;
8687 v_U8_t ucTid;
8688#ifdef FEATURE_WLAN_WAPI
Jeff Johnsone0343db2013-04-03 16:39:24 -07008689 v_U16_t usEtherType = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07008690#endif
8691 v_U16_t usPktLen;
8692 vos_pkt_t* vosDataBuff ;
8693 v_PVOID_t aucBDHeader;
8694 VOS_STATUS vosStatus;
8695 WLANTL_RxMetaInfoType wRxMetaInfo;
Madan Mohan Koyyalamudidfd6aa82012-10-18 20:18:43 -07008696 static v_U8_t ucPMPDUHLen;
Girish Gowli93e3edd2014-05-01 15:42:31 +05308697 v_U32_t* STAMetaInfoPtr;
Jeff Johnson295189b2012-06-20 16:38:30 -07008698 v_U8_t ucEsf=0; /* first subframe of AMSDU flag */
8699 v_U64_t ullcurrentReplayCounter=0; /*current replay counter*/
8700 v_U64_t ullpreviousReplayCounter=0; /*previous replay counter*/
8701 v_U16_t ucUnicastBroadcastType=0; /*It denotes whether received frame is UC or BC*/
Madan Mohan Koyyalamudi4fe30172012-10-18 20:13:40 -07008702 struct _BARFrmStruct *pBarFrame = NULL;
8703
Jeff Johnson295189b2012-06-20 16:38:30 -07008704 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
8705
8706 /*------------------------------------------------------------------------
8707 Sanity check
8708 ------------------------------------------------------------------------*/
8709 if (( NULL == pvosDataBuff ) || ( NULL == ( vosDataBuff = *pvosDataBuff )))
8710 {
8711 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8712 "WLAN TL:Invalid parameter sent on WLANTL_STARxAuth"));
8713 return VOS_STATUS_E_INVAL;
8714 }
8715
8716 /*------------------------------------------------------------------------
8717 Extract TL control block
8718 ------------------------------------------------------------------------*/
8719 pTLCb = VOS_GET_TL_CB(pvosGCtx);
8720 if ( NULL == pTLCb )
8721 {
8722 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8723 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_STARxAuth"));
8724 return VOS_STATUS_E_FAULT;
8725 }
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308726 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
8727
8728 if ( NULL == pClientSTA )
8729 {
8730 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8731 "WLAN TL:Client Memory was not allocated on %s", __func__));
8732 return VOS_STATUS_E_FAILURE;
8733 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008734
8735 /*------------------------------------------------------------------------
8736 Extract BD header and check if valid
8737 ------------------------------------------------------------------------*/
8738 WDA_DS_PeekRxPacketInfo( vosDataBuff, (v_PVOID_t)&aucBDHeader, 0 );
8739
8740 ucMPDUHOffset = (v_U8_t)WDA_GET_RX_MPDU_HEADER_OFFSET(aucBDHeader);
8741 usMPDUDOffset = (v_U16_t)WDA_GET_RX_MPDU_DATA_OFFSET(aucBDHeader);
8742 usMPDULen = (v_U16_t)WDA_GET_RX_MPDU_LEN(aucBDHeader);
8743 ucMPDUHLen = (v_U8_t)WDA_GET_RX_MPDU_HEADER_LEN(aucBDHeader);
8744 ucTid = (v_U8_t)WDA_GET_RX_TID(aucBDHeader);
8745
Madan Mohan Koyyalamudi4fe30172012-10-18 20:13:40 -07008746 /* Fix for a hardware bug.
8747 * H/W does not update the tid field in BD header for BAR frames.
8748 * Fix is to read the tid field from MAC header of BAR frame */
8749 if( (WDA_GET_RX_TYPE(aucBDHeader) == SIR_MAC_CTRL_FRAME) &&
8750 (WDA_GET_RX_SUBTYPE(aucBDHeader) == SIR_MAC_CTRL_BAR))
8751 {
8752 pBarFrame = (struct _BARFrmStruct *)(WDA_GET_RX_MAC_HEADER(aucBDHeader));
8753 ucTid = pBarFrame->barControl.numTID;
8754 }
8755
Jeff Johnson295189b2012-06-20 16:38:30 -07008756 /*Host based replay check is needed for unicast data frames*/
8757 ucUnicastBroadcastType = (v_U16_t)WDA_IS_RX_BCAST(aucBDHeader);
Jeff Johnson295189b2012-06-20 16:38:30 -07008758 if(0 != ucMPDUHLen)
8759 {
8760 ucPMPDUHLen = ucMPDUHLen;
8761 }
8762
8763 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
8764 "WLAN TL:BD header processing data: HO %d DO %d Len %d HLen %d"
8765 " Tid %d BD %d",
8766 ucMPDUHOffset, usMPDUDOffset, usMPDULen, ucMPDUHLen, ucTid,
8767 WLANHAL_RX_BD_HEADER_SIZE));
8768
8769 vos_pkt_get_packet_length( vosDataBuff, &usPktLen);
8770
8771 if ( VOS_STATUS_SUCCESS != WDA_DS_TrimRxPacketInfo( vosDataBuff ) )
8772 {
8773 if((WDA_GET_RX_ASF(aucBDHeader) && !WDA_GET_RX_ESF(aucBDHeader)))
8774 {
8775 /* AMSDU case, ucMPDUHOffset = 0
8776 * it should be hancdled seperatly */
8777 if(( usMPDUDOffset > ucMPDUHOffset ) &&
8778 ( usMPDULen >= ucMPDUHLen ) && ( usPktLen >= usMPDULen ) &&
8779 ( !WLANTL_TID_INVALID(ucTid) ))
8780 {
8781 ucMPDUHOffset = usMPDUDOffset - WLANTL_MPDU_HEADER_LEN;
8782 }
8783 else
8784 {
8785 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
8786 "WLAN TL:BD header corrupted - dropping packet"));
8787 /* Drop packet */
8788 vos_pkt_return_packet(vosDataBuff);
8789 return VOS_STATUS_SUCCESS;
8790 }
8791 }
8792 else
8793 {
8794 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
8795 "WLAN TL:BD header corrupted - dropping packet"));
8796 /* Drop packet */
8797 vos_pkt_return_packet(vosDataBuff);
8798 return VOS_STATUS_SUCCESS;
8799 }
8800 }
8801
8802#ifdef FEATURE_WLAN_WAPI
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308803 if ( pClientSTA->wSTADesc.ucIsWapiSta )
Jeff Johnson295189b2012-06-20 16:38:30 -07008804 {
8805 vosStatus = WLANTL_GetEtherType(aucBDHeader, vosDataBuff, ucMPDUHLen, &usEtherType);
8806 if( VOS_IS_STATUS_SUCCESS(vosStatus) )
8807 {
8808 if ( WLANTL_LLC_WAI_TYPE == usEtherType )
8809 {
8810 if ( !( WLANHAL_RX_IS_UNPROTECTED_WPI_FRAME(aucBDHeader)) )
8811 {
8812 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8813 "WLAN TL:WAI frame was received encrypted - dropping"));
8814 /* Drop packet */
8815 /*Temporary fix added to fix wapi rekey issue*/
8816 //vos_pkt_return_packet(vosDataBuff);
8817 //return vosStatus; //returning success
8818 }
8819 }
8820 else
8821 {
8822 if ( WLANHAL_RX_IS_UNPROTECTED_WPI_FRAME(aucBDHeader) )
8823 {
8824 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8825 "WLAN TL:Non-WAI frame was received unencrypted - dropping"));
8826 /* Drop packet */
8827 vos_pkt_return_packet(vosDataBuff);
8828 return vosStatus; //returning success
8829 }
8830 }
8831 }
8832 else //could not extract EtherType - this should not happen
8833 {
8834 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008835 "WLAN TL:Could not extract EtherType"));
8836 //Packet is already freed
Jeff Johnson295189b2012-06-20 16:38:30 -07008837 return vosStatus; //returning failure
Jeff Johnson295189b2012-06-20 16:38:30 -07008838 }
8839 }
8840#endif /* FEATURE_WLAN_WAPI */
8841
8842 /*----------------------------------------------------------------------
8843 Increment receive counter
8844 !! not sure this is the best place to increase this - pkt might be
8845 dropped below or delayed in TL's queues
8846 - will leave it here for now
8847 ------------------------------------------------------------------------*/
Madan Mohan Koyyalamudic0e5bd82012-09-18 17:12:27 -07008848 if ( !WLANTL_TID_INVALID( ucTid) )
8849 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308850 pClientSTA->auRxCount[ucTid]++;
Madan Mohan Koyyalamudic0e5bd82012-09-18 17:12:27 -07008851 }
8852 else
8853 {
8854 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8855 "WLAN TL:Invalid tid %d (Station ID %d) on %s",
8856 ucTid, ucSTAId, __func__));
8857 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008858
8859 /*------------------------------------------------------------------------
8860 Check if AMSDU and send for processing if so
8861 ------------------------------------------------------------------------*/
8862 ucAsf = (v_U8_t)WDA_GET_RX_ASF(aucBDHeader);
8863
8864 if ( 0 != ucAsf )
8865 {
8866 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
8867 "WLAN TL:Packet is AMSDU sub frame - sending for completion"));
8868 vosStatus = WLANTL_AMSDUProcess( pvosGCtx, &vosDataBuff, aucBDHeader, ucSTAId,
8869 ucMPDUHLen, usMPDULen );
8870 if(NULL == vosDataBuff)
8871 {
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008872 //Packet is already freed
Jeff Johnson295189b2012-06-20 16:38:30 -07008873 return VOS_STATUS_SUCCESS;
8874 }
8875 }
8876 /* After AMSDU header handled
8877 * AMSDU frame just same with normal frames */
8878 /*-------------------------------------------------------------------
8879 Translating header if necesary
8880 !! Fix me: rmv comments below
8881 ----------------------------------------------------------------------*/
8882 if (( 0 == WDA_GET_RX_FT_DONE(aucBDHeader) ) &&
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308883 ( 0 != pClientSTA->wSTADesc.ucSwFrameRXXlation) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07008884 ( WLANTL_IS_DATA_FRAME(WDA_GET_RX_TYPE_SUBTYPE(aucBDHeader)) ))
8885 {
8886 if(0 == ucMPDUHLen)
8887 {
8888 ucMPDUHLen = ucPMPDUHLen;
8889 }
8890 if (usMPDUDOffset > ucMPDUHOffset)
8891 {
8892 usActualHLen = usMPDUDOffset - ucMPDUHOffset;
8893 }
8894 vosStatus = WLANTL_Translate80211To8023Header( vosDataBuff, &vosStatus, usActualHLen,
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07008895 ucMPDUHLen, pTLCb, ucSTAId, bForwardIAPPwithLLC);
Jeff Johnson295189b2012-06-20 16:38:30 -07008896
8897 if ( VOS_STATUS_SUCCESS != vosStatus )
8898 {
Kaushik, Sushante386ee12014-05-01 15:50:52 +05308899 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
Jeff Johnson295189b2012-06-20 16:38:30 -07008900 "WLAN TL:Failed to translate from 802.11 to 802.3 - dropping"));
8901 /* Drop packet */
8902 vos_pkt_return_packet(vosDataBuff);
8903 return vosStatus;
8904 }
8905 }
8906 /* Softap requires additional Info such as Destination STAID and Access
8907 Category. Voschain or Buffer returned by BA would be unchain and this
8908 Meta Data would help in routing the packets to appropriate Destination */
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308909 if( WLAN_STA_SOFTAP == pClientSTA->wSTADesc.wSTAType)
Jeff Johnson295189b2012-06-20 16:38:30 -07008910 {
Arun Kumar Khandavalli37cfc222014-01-09 22:32:40 +05308911 STAMetaInfoPtr = (v_U32_t *)(uintptr_t)(ucTid | (WDA_GET_RX_ADDR3_IDX(aucBDHeader) << WLANTL_STAID_OFFSET));
Jeff Johnson295189b2012-06-20 16:38:30 -07008912 vos_pkt_set_user_data_ptr( vosDataBuff, VOS_PKT_USER_DATA_ID_TL,
8913 (v_PVOID_t)STAMetaInfoPtr);
8914 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008915
8916 /*------------------------------------------------------------------------
8917 Check to see if re-ordering session is in place
8918 ------------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308919 if ( 0 != pClientSTA->atlBAReorderInfo[ucTid].ucExists )
Jeff Johnson295189b2012-06-20 16:38:30 -07008920 {
8921 WLANTL_MSDUReorder( pTLCb, &vosDataBuff, aucBDHeader, ucSTAId, ucTid );
8922 }
8923
Jeff Johnson295189b2012-06-20 16:38:30 -07008924if(0 == ucUnicastBroadcastType
8925#ifdef FEATURE_ON_CHIP_REORDERING
8926 && (WLANHAL_IsOnChipReorderingEnabledForTID(pvosGCtx, ucSTAId, ucTid) != TRUE)
8927#endif
8928)
8929{
8930 /* replay check code : check whether replay check is needed or not */
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308931 if(VOS_TRUE == pClientSTA->ucIsReplayCheckValid)
Jeff Johnson295189b2012-06-20 16:38:30 -07008932 {
8933 /* replay check is needed for the station */
8934
8935 /* check whether frame is AMSDU frame */
8936 if ( 0 != ucAsf )
8937 {
8938 /* Since virgo can't send AMSDU frames this leg of the code
8939 was not tested properly, it needs to be tested properly*/
8940 /* Frame is AMSDU frame. As per 802.11n only first
8941 subframe will have replay counter */
8942 ucEsf = WDA_GET_RX_ESF( aucBDHeader );
8943 if( 0 != ucEsf )
8944 {
8945 v_BOOL_t status;
8946 /* Getting 48-bit replay counter from the RX BD */
8947 ullcurrentReplayCounter = WDA_DS_GetReplayCounter(aucBDHeader);
8948
8949 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Arif Hussainf2b00992013-11-17 21:46:15 -08008950 "WLAN TL: AMSDU currentReplayCounter [0x%llX]",ullcurrentReplayCounter);
Jeff Johnson295189b2012-06-20 16:38:30 -07008951
8952 /* Getting 48-bit previous replay counter from TL control block */
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308953 ullpreviousReplayCounter = pClientSTA->ullReplayCounter[ucTid];
Jeff Johnson295189b2012-06-20 16:38:30 -07008954
8955 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Arif Hussainf2b00992013-11-17 21:46:15 -08008956 "WLAN TL: AMSDU previousReplayCounter [0x%llX]",ullpreviousReplayCounter);
Jeff Johnson295189b2012-06-20 16:38:30 -07008957
8958 /* It is first subframe of AMSDU thus it
8959 conatains replay counter perform the
8960 replay check for this first subframe*/
8961 status = WLANTL_IsReplayPacket( ullcurrentReplayCounter, ullpreviousReplayCounter);
8962 if(VOS_FALSE == status)
8963 {
8964 /* Not a replay paket, update previous replay counter in TL CB */
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308965 pClientSTA->ullReplayCounter[ucTid] = ullcurrentReplayCounter;
Jeff Johnson295189b2012-06-20 16:38:30 -07008966 }
8967 else
8968 {
8969 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Arif Hussainf2b00992013-11-17 21:46:15 -08008970 "WLAN TL: AMSDU Drop the replay packet with PN : [0x%llX]",ullcurrentReplayCounter);
Jeff Johnson295189b2012-06-20 16:38:30 -07008971
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308972 pClientSTA->ulTotalReplayPacketsDetected++;
Jeff Johnson295189b2012-06-20 16:38:30 -07008973 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Arif Hussainf2b00992013-11-17 21:46:15 -08008974 "WLAN TL: AMSDU total dropped replay packets on STA ID %X is [0x%X]",
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308975 ucSTAId, pClientSTA->ulTotalReplayPacketsDetected);
Jeff Johnson295189b2012-06-20 16:38:30 -07008976
8977 /* Drop the packet */
8978 vos_pkt_return_packet(vosDataBuff);
8979 return VOS_STATUS_SUCCESS;
8980 }
8981 }
8982 }
8983 else
8984 {
8985 v_BOOL_t status;
8986
8987 /* Getting 48-bit replay counter from the RX BD */
8988 ullcurrentReplayCounter = WDA_DS_GetReplayCounter(aucBDHeader);
8989
8990 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Arif Hussainf2b00992013-11-17 21:46:15 -08008991 "WLAN TL: Non-AMSDU currentReplayCounter [0x%llX]",ullcurrentReplayCounter);
Jeff Johnson295189b2012-06-20 16:38:30 -07008992
8993 /* Getting 48-bit previous replay counter from TL control block */
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308994 ullpreviousReplayCounter = pClientSTA->ullReplayCounter[ucTid];
Jeff Johnson295189b2012-06-20 16:38:30 -07008995
8996 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Arif Hussainf2b00992013-11-17 21:46:15 -08008997 "WLAN TL: Non-AMSDU previousReplayCounter [0x%llX]",ullpreviousReplayCounter);
Jeff Johnson295189b2012-06-20 16:38:30 -07008998
8999 /* It is not AMSDU frame so perform
9000 reaply check for each packet, as
9001 each packet contains valid replay counter*/
9002 status = WLANTL_IsReplayPacket( ullcurrentReplayCounter, ullpreviousReplayCounter);
9003 if(VOS_FALSE == status)
9004 {
9005 /* Not a replay paket, update previous replay counter in TL CB */
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309006 pClientSTA->ullReplayCounter[ucTid] = ullcurrentReplayCounter;
Jeff Johnson295189b2012-06-20 16:38:30 -07009007 }
9008 else
9009 {
9010 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Arif Hussainf2b00992013-11-17 21:46:15 -08009011 "WLAN TL: Non-AMSDU Drop the replay packet with PN : [0x%llX]",ullcurrentReplayCounter);
Jeff Johnson295189b2012-06-20 16:38:30 -07009012
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309013 pClientSTA->ulTotalReplayPacketsDetected++;
Jeff Johnson295189b2012-06-20 16:38:30 -07009014 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Arif Hussainf2b00992013-11-17 21:46:15 -08009015 "WLAN TL: Non-AMSDU total dropped replay packets on STA ID %X is [0x%X]",
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309016 ucSTAId, pClientSTA->ulTotalReplayPacketsDetected);
Jeff Johnson295189b2012-06-20 16:38:30 -07009017
9018 /* Repaly packet, drop the packet */
9019 vos_pkt_return_packet(vosDataBuff);
9020 return VOS_STATUS_SUCCESS;
9021 }
9022 }
9023 }
9024}
9025/*It is a broadast packet DPU has already done replay check for
9026 broadcast packets no need to do replay check of these packets*/
Jeff Johnson295189b2012-06-20 16:38:30 -07009027
9028 if ( NULL != vosDataBuff )
9029 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309030 if( WLAN_STA_SOFTAP == pClientSTA->wSTADesc.wSTAType)
Jeff Johnson295189b2012-06-20 16:38:30 -07009031 {
9032 WLANTL_FwdPktToHDD( pvosGCtx, vosDataBuff, ucSTAId );
9033 }
9034 else
Jeff Johnson295189b2012-06-20 16:38:30 -07009035 {
9036 wRxMetaInfo.ucUP = ucTid;
Shailender Karmuchi13c0d082013-03-26 14:41:39 -07009037 wRxMetaInfo.rssiAvg = pClientSTA->rssiAvg;
Gopichand Nakkala4a2fc1a2013-05-17 16:59:39 +05309038#ifdef FEATURE_WLAN_TDLS
9039 if (WLAN_STA_TDLS == pClientSTA->wSTADesc.wSTAType)
9040 {
9041 wRxMetaInfo.isStaTdls = TRUE;
9042 }
9043 else
9044 {
9045 wRxMetaInfo.isStaTdls = FALSE;
9046 }
9047#endif
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309048 pClientSTA->pfnSTARx( pvosGCtx, vosDataBuff, ucSTAId,
Jeff Johnson295189b2012-06-20 16:38:30 -07009049 &wRxMetaInfo );
9050 }
9051 }/* if not NULL */
9052
9053 return VOS_STATUS_SUCCESS;
9054}/* WLANTL_STARxAuth */
9055
9056
9057/*==========================================================================
9058 FUNCTION WLANTL_STARxDisc
9059
9060 DESCRIPTION
9061 Receive in disconnected state - no data allowed
9062
9063 DEPENDENCIES
9064 The STA must be registered with TL before this function can be called.
9065
9066 PARAMETERS
9067
9068 IN
9069 pvosGCtx: pointer to the global vos context; a handle to TL's
9070 control block can be extracted from its context
9071 ucSTAId: identifier of the station being processed
9072 vosDataBuff: pointer to the rx vos buffer
9073
9074 RETURN VALUE
9075 The result code associated with performing the operation
9076
9077 VOS_STATUS_SUCCESS: Everything is good :)
9078
9079 SIDE EFFECTS
9080
9081============================================================================*/
9082VOS_STATUS
9083WLANTL_STARxDisc
9084(
9085 v_PVOID_t pvosGCtx,
9086 v_U8_t ucSTAId,
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009087 vos_pkt_t** pvosDataBuff,
9088 v_BOOL_t bForwardIAPPwithLLC
Jeff Johnson295189b2012-06-20 16:38:30 -07009089)
9090{
9091 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
9092
9093 /*------------------------------------------------------------------------
9094 Sanity check
9095 ------------------------------------------------------------------------*/
9096 if (( NULL == pvosDataBuff ) || ( NULL == *pvosDataBuff ))
9097 {
9098 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9099 "WLAN TL:Invalid parameter sent on WLANTL_STARxDisc"));
9100 return VOS_STATUS_E_INVAL;
9101 }
9102
9103 /*------------------------------------------------------------------------
9104 Error - drop packet
9105 ------------------------------------------------------------------------*/
9106 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9107 "WLAN TL:Packet should not be received in state disconnected"
9108 " - dropping"));
9109 vos_pkt_return_packet(*pvosDataBuff);
9110 *pvosDataBuff = NULL;
9111
9112 return VOS_STATUS_SUCCESS;
9113}/* WLANTL_STARxDisc */
9114
9115/*==========================================================================
9116 Processing main loops for MAIN and TX threads
9117 ==========================================================================*/
9118
9119/*==========================================================================
9120 FUNCTION WLANTL_McProcessMsg
9121
9122 DESCRIPTION
9123 Called by VOSS when a message was serialized for TL through the
9124 main thread/task.
9125
9126 DEPENDENCIES
9127 The TL must be initialized before this function can be called.
9128
9129 PARAMETERS
9130
9131 IN
9132 pvosGCtx: pointer to the global vos context; a handle to TL's
9133 control block can be extracted from its context
9134 message: type and content of the message
9135
9136
9137 RETURN VALUE
9138 The result code associated with performing the operation
9139
9140 VOS_STATUS_E_INVAL: invalid input parameters
9141 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
9142 page fault
9143 VOS_STATUS_SUCCESS: Everything is good :)
9144
9145 SIDE EFFECTS
9146
9147============================================================================*/
9148VOS_STATUS
9149WLANTL_McProcessMsg
9150(
9151 v_PVOID_t pvosGCtx,
9152 vos_msg_t* message
9153)
9154{
9155 WLANTL_CbType* pTLCb = NULL;
9156 tAddBAInd* ptAddBaInd = NULL;
9157 tDelBAInd* ptDelBaInd = NULL;
9158 tAddBARsp* ptAddBaRsp = NULL;
9159 vos_msg_t vosMessage;
9160 VOS_STATUS vosStatus;
9161 tpFlushACRsp FlushACRspPtr;
9162 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
9163
9164 /*------------------------------------------------------------------------
9165 Sanity check
9166 ------------------------------------------------------------------------*/
9167 if ( NULL == message )
9168 {
9169 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9170 "WLAN TL:Invalid parameter sent on WLANTL_ProcessMainMessage"));
9171 return VOS_STATUS_E_INVAL;
9172 }
9173
9174 /*------------------------------------------------------------------------
9175 Extract TL control block
9176 ------------------------------------------------------------------------*/
9177 pTLCb = VOS_GET_TL_CB(pvosGCtx);
9178 if ( NULL == pTLCb )
9179 {
9180 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9181 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_ProcessMainMessage"));
9182 return VOS_STATUS_E_FAULT;
9183 }
9184
9185 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
9186 "WLAN TL:Received message: %d through main flow", message->type));
9187
9188 switch( message->type )
9189 {
9190 case WDA_TL_FLUSH_AC_RSP:
9191 // Extract the message from the message body
9192 FlushACRspPtr = (tpFlushACRsp)(message->bodyptr);
9193 // Make sure the call back function is not null.
Tushnim Bhattacharyya5dd94562013-03-20 20:15:03 -07009194 if ( NULL == pTLCb->tlBAPClient.pfnFlushOpCompleteCb )
9195 {
9196 VOS_ASSERT(0);
9197 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9198 "WLAN TL:Invalid TL pointer pfnFlushOpCompleteCb"));
9199 return VOS_STATUS_E_FAULT;
9200 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009201
9202 TLLOG2(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
9203 "Received message: Flush complete received by TL"));
9204
9205 // Since we have the response back from HAL, just call the BAP client
9206 // registered call back from TL. There is only 1 possible
9207 // BAP client. So directly reference tlBAPClient
9208 pTLCb->tlBAPClient.pfnFlushOpCompleteCb( pvosGCtx,
9209 FlushACRspPtr->ucSTAId,
9210 FlushACRspPtr->ucTid, FlushACRspPtr->status );
9211
9212 // Free the PAL memory, we are done with it.
9213 TLLOG2(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
9214 "Flush complete received by TL: Freeing %p", FlushACRspPtr));
9215 vos_mem_free((v_VOID_t *)FlushACRspPtr);
9216 break;
9217
9218 case WDA_HDD_ADDBA_REQ:
9219 ptAddBaInd = (tAddBAInd*)(message->bodyptr);
9220 vosStatus = WLANTL_BaSessionAdd( pvosGCtx,
9221 ptAddBaInd->baSession.baSessionID,
9222 ptAddBaInd->baSession.STAID,
9223 ptAddBaInd->baSession.baTID,
9224 (v_U32_t)ptAddBaInd->baSession.baBufferSize,
9225 ptAddBaInd->baSession.winSize,
9226 ptAddBaInd->baSession.SSN);
9227 ptAddBaRsp = vos_mem_malloc(sizeof(*ptAddBaRsp));
9228
9229 if ( NULL == ptAddBaRsp )
9230 {
9231 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9232 "WLAN TL: fatal failure, cannot allocate BA Rsp structure"));
9233 VOS_ASSERT(0);
9234 return VOS_STATUS_E_NOMEM;
9235 }
9236
9237 if ( VOS_STATUS_SUCCESS == vosStatus )
9238 {
9239 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
9240 "WLAN TL: Sending success indication to HAL for ADD BA"));
9241 /*Send success*/
9242 ptAddBaRsp->mesgType = WDA_HDD_ADDBA_RSP;
9243 vosMessage.type = WDA_HDD_ADDBA_RSP;
9244 }
9245 else
9246 {
9247 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
9248 "WLAN TL: Sending failure indication to HAL for ADD BA"));
9249
9250 /*Send failure*/
9251 ptAddBaRsp->mesgType = WDA_BA_FAIL_IND;
9252 vosMessage.type = WDA_BA_FAIL_IND;
9253 }
9254
9255 ptAddBaRsp->mesgLen = sizeof(tAddBARsp);
9256 ptAddBaRsp->baSessionID = ptAddBaInd->baSession.baSessionID;
9257 /* This is default, reply win size has to be handled BA module, FIX THIS */
9258 ptAddBaRsp->replyWinSize = WLANTL_MAX_WINSIZE;
9259 vosMessage.bodyptr = ptAddBaRsp;
9260
9261 vos_mq_post_message( VOS_MQ_ID_WDA, &vosMessage );
9262 WLANTL_McFreeMsg (pvosGCtx, message);
9263 break;
9264 case WDA_DELETEBA_IND:
9265 ptDelBaInd = (tDelBAInd*)(message->bodyptr);
9266 vosStatus = WLANTL_BaSessionDel(pvosGCtx,
9267 ptDelBaInd->staIdx,
9268 ptDelBaInd->baTID);
9269
9270 if ( VOS_STATUS_SUCCESS != vosStatus )
9271 {
9272 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9273 "WLAN TL: Failed to del BA session STA:%d TID:%d Status :%d",
9274 ptDelBaInd->staIdx,
9275 ptDelBaInd->baTID,
9276 vosStatus));
9277 }
9278 WLANTL_McFreeMsg (pvosGCtx, message);
9279 break;
9280 default:
9281 /*no processing for now*/
9282 break;
9283 }
9284
9285 return VOS_STATUS_SUCCESS;
9286}/* WLANTL_ProcessMainMessage */
9287
9288/*==========================================================================
9289 FUNCTION WLANTL_McFreeMsg
9290
9291 DESCRIPTION
9292 Called by VOSS to free a given TL message on the Main thread when there
9293 are messages pending in the queue when the whole system is been reset.
9294 For now, TL does not allocate any body so this function shout translate
9295 into a NOOP
9296
9297 DEPENDENCIES
9298 The TL must be initialized before this function can be called.
9299
9300 PARAMETERS
9301
9302 IN
9303 pvosGCtx: pointer to the global vos context; a handle to TL's
9304 control block can be extracted from its context
9305 message: type and content of the message
9306
9307
9308 RETURN VALUE
9309 The result code associated with performing the operation
9310
9311 VOS_STATUS_SUCCESS: Everything is good :)
9312
9313 SIDE EFFECTS
9314
9315============================================================================*/
9316VOS_STATUS
9317WLANTL_McFreeMsg
9318(
9319 v_PVOID_t pvosGCtx,
9320 vos_msg_t* message
9321)
9322{
9323 WLANTL_CbType* pTLCb = NULL;
9324 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
9325
9326 /*------------------------------------------------------------------------
9327 Sanity check
9328 ------------------------------------------------------------------------*/
9329 if ( NULL == message )
9330 {
9331 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9332 "WLAN TL:Invalid parameter sent on WLANTL_McFreeMsg"));
9333 return VOS_STATUS_E_INVAL;
9334 }
9335
9336 /*------------------------------------------------------------------------
9337 Extract TL control block
9338 ------------------------------------------------------------------------*/
9339 pTLCb = VOS_GET_TL_CB(pvosGCtx);
9340 if ( NULL == pTLCb )
9341 {
9342 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9343 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_McFreeMsg"));
9344 return VOS_STATUS_E_FAULT;
9345 }
9346
9347 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
9348 "WLAN TL:Received message: %d through main free", message->type));
9349
9350 switch( message->type )
9351 {
9352 case WDA_HDD_ADDBA_REQ:
9353 case WDA_DELETEBA_IND:
9354 /*vos free body pointer*/
9355 vos_mem_free(message->bodyptr);
9356 message->bodyptr = NULL;
9357 break;
9358 default:
9359 /*no processing for now*/
9360 break;
9361 }
9362
9363 return VOS_STATUS_SUCCESS;
9364}/*WLANTL_McFreeMsg*/
9365
9366/*==========================================================================
9367 FUNCTION WLANTL_TxProcessMsg
9368
9369 DESCRIPTION
9370 Called by VOSS when a message was serialized for TL through the
9371 tx thread/task.
9372
9373 DEPENDENCIES
9374 The TL must be initialized before this function can be called.
9375
9376 PARAMETERS
9377
9378 IN
9379 pvosGCtx: pointer to the global vos context; a handle to TL's
9380 control block can be extracted from its context
9381 message: type and content of the message
9382
9383
9384 RETURN VALUE
9385 The result code associated with performing the operation
9386
9387 VOS_STATUS_E_INVAL: invalid input parameters
9388 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
9389 page fault
9390 VOS_STATUS_SUCCESS: Everything is good :)
9391
9392 Other values can be returned as a result of a function call, please check
9393 corresponding API for more info.
9394 SIDE EFFECTS
9395
9396============================================================================*/
9397VOS_STATUS
9398WLANTL_TxProcessMsg
9399(
9400 v_PVOID_t pvosGCtx,
9401 vos_msg_t* message
9402)
9403{
9404 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07009405 void (*callbackRoutine) (void *callbackContext);
9406 void *callbackContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07009407 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
9408
9409 /*------------------------------------------------------------------------
9410 Sanity check
9411 ------------------------------------------------------------------------*/
9412 if ( NULL == message )
9413 {
9414 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9415 "WLAN TL:Invalid parameter sent on WLANTL_ProcessTxMessage"));
9416 return VOS_STATUS_E_INVAL;
9417 }
9418
9419 /*------------------------------------------------------------------------
9420 Process message
9421 ------------------------------------------------------------------------*/
9422 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
9423 "WLAN TL:Received message: %d through tx flow", message->type));
9424
9425 switch( message->type )
9426 {
9427 case WLANTL_TX_SIG_SUSPEND:
9428 vosStatus = WLANTL_SuspendCB( pvosGCtx,
9429 (WLANTL_SuspendCBType)message->bodyptr,
9430 message->reserved);
9431 break;
9432 case WLANTL_TX_RES_NEEDED:
9433 vosStatus = WLANTL_GetTxResourcesCB( pvosGCtx );
9434 break;
Katya Nigam664f5032014-05-05 12:24:32 +05309435
Jeff Johnson295189b2012-06-20 16:38:30 -07009436 case WDA_DS_TX_START_XMIT:
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05309437 WLANTL_ClearTxXmitPending(pvosGCtx);
9438 vosStatus = WDA_DS_TxFrames( pvosGCtx );
Jeff Johnson295189b2012-06-20 16:38:30 -07009439 break;
9440
9441 case WDA_DS_FINISH_ULA:
Arun Kumar Khandavalli8d1979d2014-01-09 21:12:25 +05309442 callbackContext = message->bodyptr;
9443 callbackRoutine = message->callback;
9444 if ( NULL != callbackRoutine )
9445 {
9446 callbackRoutine(callbackContext);
9447 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009448 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009449
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05309450 case WLANTL_TX_SNAPSHOT:
9451 /*Dumping TL State and then continuing to print
9452 the DXE Dump*/
9453 WLANTL_TxThreadDebugHandler(pvosGCtx);
9454 WDA_TransportChannelDebug(NULL, VOS_TRUE, VOS_FALSE);
9455 break;
9456
Mihir Shetefd62d9d2014-08-06 15:08:21 +05309457 case WLANTL_TX_FATAL_ERROR:
9458 WLANTL_FatalErrorHandler(pvosGCtx);
9459 break;
9460
Mihir Shete327c2ab2014-11-13 15:17:02 +05309461 case WLANTL_TX_FW_DEBUG:
Siddharth Bhal68115602015-01-18 20:44:55 +05309462 vos_fwDumpReq(274, 0, 0, 0, 0, 1); //Async event
Mihir Shete327c2ab2014-11-13 15:17:02 +05309463 break;
9464
Jeff Johnson295189b2012-06-20 16:38:30 -07009465 default:
9466 /*no processing for now*/
9467 break;
9468 }
9469
9470 return vosStatus;
9471}/* WLANTL_TxProcessMsg */
9472
9473/*==========================================================================
9474 FUNCTION WLANTL_McFreeMsg
9475
9476 DESCRIPTION
9477 Called by VOSS to free a given TL message on the Main thread when there
9478 are messages pending in the queue when the whole system is been reset.
9479 For now, TL does not allocate any body so this function shout translate
9480 into a NOOP
9481
9482 DEPENDENCIES
9483 The TL must be initialized before this function can be called.
9484
9485 PARAMETERS
9486
9487 IN
9488 pvosGCtx: pointer to the global vos context; a handle to TL's
9489 control block can be extracted from its context
9490 message: type and content of the message
9491
9492
9493 RETURN VALUE
9494 The result code associated with performing the operation
9495
9496 VOS_STATUS_SUCCESS: Everything is good :)
9497
9498 SIDE EFFECTS
9499
9500============================================================================*/
9501VOS_STATUS
9502WLANTL_TxFreeMsg
9503(
9504 v_PVOID_t pvosGCtx,
9505 vos_msg_t* message
9506)
9507{
9508 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
9509
9510 /*Nothing to do for now!!!*/
9511 return VOS_STATUS_SUCCESS;
9512}/*WLANTL_TxFreeMsg*/
9513
Jeff Johnson295189b2012-06-20 16:38:30 -07009514/*==========================================================================
9515
9516 FUNCTION WLANTL_TxFCFrame
9517
9518 DESCRIPTION
9519 Internal utility function to send FC frame. Enable
9520 or disable LWM mode based on the information.
9521
9522 DEPENDENCIES
9523 TL must be initiailized before this function gets called.
9524 FW sends up special flow control frame.
9525
9526 PARAMETERS
9527
9528 IN
9529 pvosGCtx: pointer to the global vos context; a handle to TL's
9530 control block can be extracted from its context
9531
9532 RETURN VALUE
9533 The result code associated with performing the operation
9534
9535 VOS_STATUS_E_INVAL: Input pointers are NULL.
9536 VOS_STATUS_E_FAULT: Something is wrong.
9537 VOS_STATUS_SUCCESS: Everything is good.
9538
9539 SIDE EFFECTS
9540 Newly formed FC frame is generated and waits to be transmitted. Previously unsent frame will
9541 be released.
9542
9543============================================================================*/
9544VOS_STATUS
9545WLANTL_TxFCFrame
9546(
9547 v_PVOID_t pvosGCtx
9548)
9549{
9550#if 0
9551 WLANTL_CbType* pTLCb = NULL;
9552 VOS_STATUS vosStatus;
9553 tpHalFcTxBd pvFcTxBd = NULL;
9554 vos_pkt_t * pPacket = NULL;
9555 v_U8_t ucSTAId = 0;
9556 v_U8_t ucBitCheck = 1;
9557
9558 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009559 "WLAN TL: Send FC frame %s", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07009560
9561 /*------------------------------------------------------------------------
9562 Sanity check
9563 ------------------------------------------------------------------------*/
9564 if ( NULL == pvosGCtx )
9565 {
9566 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009567 "WLAN TL:Invalid parameter %s", __func__));
Jeff Johnson295189b2012-06-20 16:38:30 -07009568 return VOS_STATUS_E_INVAL;
9569 }
9570 /*------------------------------------------------------------------------
9571 Extract TL control block
9572 ------------------------------------------------------------------------*/
9573 pTLCb = VOS_GET_TL_CB(pvosGCtx);
9574
9575 if (NULL == pTLCb)
9576 {
9577 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009578 "WLAN TL:Invalid pointer in %s \n", __func__));
Jeff Johnson295189b2012-06-20 16:38:30 -07009579 return VOS_STATUS_E_INVAL;
9580 }
9581
9582 //Get one voss packet
9583 vosStatus = vos_pkt_get_packet( &pPacket, VOS_PKT_TYPE_TX_802_11_MGMT, sizeof(tHalFcTxBd), 1,
9584 VOS_FALSE, NULL, NULL );
9585
9586 if ( VOS_STATUS_SUCCESS != vosStatus )
9587 {
9588 return VOS_STATUS_E_INVAL;
9589 }
9590
9591 vosStatus = vos_pkt_reserve_head( pPacket, (void *)&pvFcTxBd, sizeof(tHalFcTxBd));
9592
9593 if( VOS_STATUS_SUCCESS != vosStatus )
9594 {
9595 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009596 "%s: failed to reserve FC TX BD %d\n",__func__, sizeof(tHalFcTxBd)));
Jeff Johnson295189b2012-06-20 16:38:30 -07009597 vos_pkt_return_packet( pPacket );
9598 return VOS_STATUS_E_FAULT;
9599 }
9600
9601 //Generate most recent tlFCInfo. Most fields are correct.
9602 pTLCb->tlFCInfo.fcSTAThreshEnabledMask = 0;
9603 pTLCb->tlFCInfo.fcSTATxMoreDataMask = 0;
9604 for( ucSTAId = 0, ucBitCheck = 1 ; ucSTAId < WLAN_MAX_STA_COUNT; ucBitCheck <<= 1, ucSTAId ++)
9605 {
9606 if (0 == pTLCb->atlSTAClients[ucSTAId].ucExists)
9607 {
9608 continue;
9609 }
9610
9611 if (pTLCb->atlSTAClients[ucSTAId].ucPktPending)
9612 {
9613 pTLCb->tlFCInfo.fcSTATxMoreDataMask |= ucBitCheck;
9614 }
9615
9616 if ( (pTLCb->atlSTAClients[ucSTAId].ucLwmModeEnabled) &&
9617 (pTLCb->atlSTAClients[ucSTAId].bmuMemConsumed > pTLCb->atlSTAClients[ucSTAId].uLwmThreshold))
9618 {
9619 pTLCb->tlFCInfo.fcSTAThreshEnabledMask |= ucBitCheck;
9620
9621 pTLCb->tlFCInfo.fcSTAThresh[ucSTAId] = (tANI_U8)pTLCb->atlSTAClients[ucSTAId].uLwmThreshold;
9622
9623 pTLCb->atlSTAClients[ucSTAId].ucLwmEventReported = FALSE;
9624 }
9625
9626 }
9627
9628 //request immediate feedback
9629 pTLCb->tlFCInfo.fcConfig |= 0x4;
9630
9631 //fill in BD to sent
9632 vosStatus = WLANHAL_FillFcTxBd(pvosGCtx, &pTLCb->tlFCInfo, (void *)pvFcTxBd);
9633
9634 if( VOS_STATUS_SUCCESS != vosStatus )
9635 {
9636 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009637 "%s: Fill FC TX BD unsuccessful\n", __func__));
Jeff Johnson295189b2012-06-20 16:38:30 -07009638 vos_pkt_return_packet( pPacket );
9639 return VOS_STATUS_E_FAULT;
9640 }
9641
9642 if (NULL != pTLCb->vosTxFCBuf)
9643 {
9644 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009645 "%s: Previous FC TX BD not sent\n", __func__));
Jeff Johnson295189b2012-06-20 16:38:30 -07009646 vos_pkt_return_packet(pTLCb->vosTxFCBuf);
9647 }
9648
9649 pTLCb->vosTxFCBuf = pPacket;
9650
9651 vos_pkt_set_user_data_ptr( pPacket, VOS_PKT_USER_DATA_ID_TL,
9652 (v_PVOID_t)WLANTL_TxCompDefaultCb);
9653 vosStatus = WDA_DS_StartXmit(pvosGCtx);
9654
9655 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009656 "WLAN TL: send FC frame leave %s", __func__));
Jeff Johnson295189b2012-06-20 16:38:30 -07009657#endif
9658 return VOS_STATUS_SUCCESS;
9659}
9660
Jeff Johnson295189b2012-06-20 16:38:30 -07009661
9662/*==========================================================================
9663 FUNCTION WLANTL_GetTxResourcesCB
9664
9665 DESCRIPTION
9666 Processing function for Resource needed signal. A request will be issued
9667 to BAL to get more tx resources.
9668
9669 DEPENDENCIES
9670 The TL must be initialized before this function can be called.
9671
9672 PARAMETERS
9673
9674 IN
9675 pvosGCtx: pointer to the global vos context; a handle to TL's
9676 control block can be extracted from its context
9677
9678
9679 RETURN VALUE
9680 The result code associated with performing the operation
9681
9682 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
9683 page fault
9684 VOS_STATUS_SUCCESS: Everything is good :)
9685
9686 Other values can be returned as a result of a function call, please check
9687 corresponding API for more info.
9688 SIDE EFFECTS
9689
9690============================================================================*/
9691VOS_STATUS
9692WLANTL_GetTxResourcesCB
9693(
9694 v_PVOID_t pvosGCtx
9695)
9696{
9697 WLANTL_CbType* pTLCb = NULL;
9698 v_U32_t uResCount = WDA_TLI_MIN_RES_DATA;
9699 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
9700 v_U8_t ucMgmt = 0;
9701 v_U8_t ucBAP = 0;
9702 v_U8_t ucData = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07009703#ifdef WLAN_SOFTAP_FLOWCTRL_EN
9704 tBssSystemRole systemRole;
9705 tpAniSirGlobal pMac;
9706#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009707 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
9708 /*------------------------------------------------------------------------
9709 Extract TL control block
9710 ------------------------------------------------------------------------*/
9711 pTLCb = VOS_GET_TL_CB(pvosGCtx);
9712 if ( NULL == pTLCb )
9713 {
9714 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9715 "WLAN TL:Invalid TL pointer from pvosGCtx on"
9716 " WLANTL_ProcessTxMessage"));
9717 return VOS_STATUS_E_FAULT;
9718 }
9719
9720 /*------------------------------------------------------------------------
9721 Get tx resources from BAL
9722 ------------------------------------------------------------------------*/
9723 vosStatus = WDA_DS_GetTxResources( pvosGCtx, &uResCount );
9724
9725 if ( (VOS_STATUS_SUCCESS != vosStatus) && (VOS_STATUS_E_RESOURCES != vosStatus))
9726 {
9727 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9728 "WLAN TL:TL failed to get resources from BAL, Err: %d",
9729 vosStatus));
9730 return vosStatus;
9731 }
9732
9733 /* Currently only Linux BAL returns the E_RESOURCES error code when it is running
9734 out of BD/PDUs. To make use of this interrupt for throughput enhancement, similar
9735 changes should be done in BAL code of AMSS and WM */
9736 if (VOS_STATUS_E_RESOURCES == vosStatus)
9737 {
9738#ifdef VOLANS_PERF
9739 WLANHAL_EnableIdleBdPduInterrupt(pvosGCtx, (tANI_U8)bdPduInterruptGetThreshold);
9740 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
9741 "WLAN TL: Enabling Idle BD/PDU interrupt, Current resources = %d", uResCount);
9742#else
9743 return VOS_STATUS_E_FAILURE;
9744#endif
9745 }
9746
9747 pTLCb->uResCount = uResCount;
9748
9749
Jeff Johnson295189b2012-06-20 16:38:30 -07009750#ifdef WLAN_SOFTAP_FLOWCTRL_EN
9751 /* FIXME: disabled since creating issues in power-save, needs to be addressed */
9752 pTLCb->sendFCFrame ++;
9753 pMac = vos_get_context(VOS_MODULE_ID_WDA, pvosGCtx);
9754 systemRole = wdaGetGlobalSystemRole(pMac);
9755 if (eSYSTEM_AP_ROLE == systemRole)
9756 {
9757 if (pTLCb->sendFCFrame % 16 == 0)
9758 {
9759 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
9760 "Transmit FC"));
9761 WLANTL_TxFCFrame (pvosGCtx);
9762 }
9763 }
9764#endif //WLAN_SOFTAP_FLOWCTRL_EN
Jeff Johnson295189b2012-06-20 16:38:30 -07009765
9766 ucData = ( pTLCb->uResCount >= WDA_TLI_MIN_RES_DATA );
9767 ucBAP = ( pTLCb->uResCount >= WDA_TLI_MIN_RES_BAP ) &&
9768 ( NULL != pTLCb->tlBAPClient.vosPendingDataBuff );
9769 ucMgmt = ( pTLCb->uResCount >= WDA_TLI_MIN_RES_MF ) &&
9770 ( NULL != pTLCb->tlMgmtFrmClient.vosPendingDataBuff );
9771
9772 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
9773 "WLAN TL: Eval Resume tx Res: %d DATA: %d BAP: %d MGMT: %d",
9774 pTLCb->uResCount, ucData, ucBAP, ucMgmt));
9775
9776 if (( 0 == pTLCb->ucTxSuspended ) &&
9777 (( 0 != ucData ) || ( 0 != ucMgmt ) || ( 0 != ucBAP ) ) )
9778 {
9779 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
9780 "Issuing Xmit start request to BAL for avail res SYNC"));
9781 vosStatus =WDA_DS_StartXmit(pvosGCtx);
9782 }
9783 return vosStatus;
9784}/*WLANTL_GetTxResourcesCB*/
9785
9786/*==========================================================================
9787 Utility functions
9788 ==========================================================================*/
9789
9790/*==========================================================================
9791 FUNCTION WLANTL_Translate8023To80211Header
9792
9793 DESCRIPTION
9794 Inline function for translating and 802.11 header into an 802.3 header.
9795
9796 DEPENDENCIES
9797
9798
9799 PARAMETERS
9800
9801 IN
9802 pTLCb: TL control block
Kiran Venkatappaa044eb92012-12-17 15:48:49 -08009803 IN/OUT
9804 ucStaId: station ID. Incase of TDLS, this returns actual TDLS
9805 station ID used
Jeff Johnson295189b2012-06-20 16:38:30 -07009806
9807 IN/OUT
9808 vosDataBuff: vos data buffer, will contain the new header on output
9809
9810 OUT
9811 pvosStatus: status of the operation
9812
9813 RETURN VALUE
9814
9815 VOS_STATUS_SUCCESS: Everything is good :)
9816
9817 Other error codes might be returned from the vos api used in the function
9818 please check those return values.
9819
9820 SIDE EFFECTS
9821
9822============================================================================*/
Kiran Venkatappacab0d352012-12-17 13:09:22 -08009823VOS_STATUS
9824WLANTL_Translate8023To80211Header
9825(
9826 vos_pkt_t* vosDataBuff,
9827 VOS_STATUS* pvosStatus,
9828 WLANTL_CbType* pTLCb,
9829 v_U8_t *pucStaId,
Ravi Joshid0699502013-07-08 15:48:47 -07009830 WLANTL_MetaInfoType *tlMetaInfo,
Kiran Venkatappacab0d352012-12-17 13:09:22 -08009831 v_U8_t *ucWDSEnabled,
9832 v_U8_t *extraHeadSpace
9833)
Jeff Johnson295189b2012-06-20 16:38:30 -07009834{
9835 WLANTL_8023HeaderType w8023Header;
9836 WLANTL_80211HeaderType *pw80211Header; // Allocate an aligned BD and then fill it.
9837 VOS_STATUS vosStatus;
9838 v_U8_t MandatoryucHeaderSize = WLAN80211_MANDATORY_HEADER_SIZE;
9839 v_U8_t ucHeaderSize = 0;
9840 v_VOID_t *ppvBDHeader = NULL;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309841 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07009842 v_U8_t ucQoSOffset = WLAN80211_MANDATORY_HEADER_SIZE;
Kiran Venkatappacab0d352012-12-17 13:09:22 -08009843 v_U8_t ucStaId;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009844#ifdef FEATURE_WLAN_ESE_UPLOAD
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009845 v_BOOL_t bIAPPTxwithLLC = VOS_FALSE;
9846 v_SIZE_t wIAPPSnapSize = WLANTL_LLC_HEADER_LEN;
9847 v_U8_t wIAPPSnap[WLANTL_LLC_HEADER_LEN] = {0};
9848#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009849 *ucWDSEnabled = 0; // default WDS off.
9850 vosStatus = vos_pkt_pop_head( vosDataBuff, &w8023Header,
9851 sizeof(w8023Header));
9852
9853 if ( VOS_STATUS_SUCCESS != vosStatus )
9854 {
9855 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9856 "WLAN TL: Packet pop header fails on WLANTL_Translate8023To80211Header"));
9857 return vosStatus;
9858 }
9859
Kiran Venkatappacab0d352012-12-17 13:09:22 -08009860 if( NULL == pucStaId )
9861 {
9862 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9863 "WLAN TL: Invalid pointer for StaId"));
9864 return VOS_STATUS_E_INVAL;
9865 }
9866 ucStaId = *pucStaId;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309867 pClientSTA = pTLCb->atlSTAClients[ucStaId];
9868
9869 if ( NULL == pClientSTA )
9870 {
9871 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9872 "WLAN TL:Client Memory was not allocated on %s", __func__));
9873 return VOS_STATUS_E_FAILURE;
9874 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -08009875
Kiran Venkatappaa044eb92012-12-17 15:48:49 -08009876#ifdef FEATURE_WLAN_TDLS
9877
Madan Mohan Koyylamudi64258222013-01-30 14:35:10 +05309878 if ( WLAN_STA_INFRA == pTLCb->atlSTAClients[ucStaId]->wSTADesc.wSTAType
9879 && pTLCb->ucTdlsPeerCount )
Kiran Venkatappacab0d352012-12-17 13:09:22 -08009880 {
9881 v_U8_t ucIndex = 0;
9882 for ( ucIndex = 0; ucIndex < WLAN_MAX_STA_COUNT ; ucIndex++)
9883 {
Madan Mohan Koyylamudi64258222013-01-30 14:35:10 +05309884 if ( ucIndex != ucStaId && pTLCb->atlSTAClients[ucIndex] && pTLCb->atlSTAClients[ucIndex]->ucExists &&
Gopichand Nakkala471708b2013-06-04 20:03:01 +05309885 (pTLCb->atlSTAClients[ucIndex]->tlState == WLANTL_STA_AUTHENTICATED) &&
9886 (!pTLCb->atlSTAClients[ucIndex]->ucTxSuspended) &&
Madan Mohan Koyylamudi64258222013-01-30 14:35:10 +05309887 vos_mem_compare( (void*)pTLCb->atlSTAClients[ucIndex]->wSTADesc.vSTAMACAddress.bytes,
Kiran Venkatappacab0d352012-12-17 13:09:22 -08009888 (void*)w8023Header.vDA, 6) )
9889 {
9890 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_LOW,
9891 "WLAN TL: Got a TDLS station. Using that index"));
9892 ucStaId = ucIndex;
9893 *pucStaId = ucStaId;
Madan Mohan Koyylamudi64258222013-01-30 14:35:10 +05309894 pClientSTA = pTLCb->atlSTAClients[ucStaId];
9895 if ( NULL == pClientSTA )
9896 {
9897 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9898 "WLAN TL:Client Memory was not allocated on %s", __func__));
9899 return VOS_STATUS_E_FAILURE;
9900 }
Kiran Venkatappacab0d352012-12-17 13:09:22 -08009901 break;
9902 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -08009903 }
Kiran Venkatappacab0d352012-12-17 13:09:22 -08009904 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -08009905#endif
9906
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009907#ifdef FEATURE_WLAN_ESE_UPLOAD
9908if ((0 == w8023Header.usLenType) && (pClientSTA->wSTADesc.ucIsEseSta))
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009909{
9910 vos_pkt_extract_data(vosDataBuff,0,&wIAPPSnap[0],&wIAPPSnapSize);
9911 if (vos_mem_compare(wIAPPSnap,WLANTL_AIRONET_SNAP_HEADER,WLANTL_LLC_HEADER_LEN))
9912 {
9913 /*The SNAP and the protocol type are already in the data buffer.
9914 They are filled by the application (wpa_supplicant). So, Skip Adding LLC below.*/
9915 bIAPPTxwithLLC = VOS_TRUE;
9916 }
9917 else
9918 {
9919 bIAPPTxwithLLC = VOS_FALSE;
9920 }
9921}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009922#endif /* FEATURE_WLAN_ESE_UPLOAD */
Jeff Johnson295189b2012-06-20 16:38:30 -07009923
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009924 if ((0 != pClientSTA->wSTADesc.ucAddRmvLLC)
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009925#ifdef FEATURE_WLAN_ESE_UPLOAD
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009926 && (!bIAPPTxwithLLC)
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009927#endif /* FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009928 )
Jeff Johnson295189b2012-06-20 16:38:30 -07009929 {
9930 /* Push the length */
9931 vosStatus = vos_pkt_push_head(vosDataBuff,
9932 &w8023Header.usLenType, sizeof(w8023Header.usLenType));
9933
9934 if ( VOS_STATUS_SUCCESS != vosStatus )
9935 {
9936 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9937 "WLAN TL: Packet push ether type fails on"
9938 " WLANTL_Translate8023To80211Header"));
9939 return vosStatus;
9940 }
9941
9942#ifdef BTAMP_TEST
9943 // The STA side will execute this, a hack to test BTAMP by using the
9944 // infra setup. On real BTAMP this will come from BAP itself.
9945 {
9946 static v_U8_t WLANTL_BT_AMP_LLC_HEADER[] = {0xAA, 0xAA, 0x03, 0x00, 0x19, 0x58 };
9947 vosStatus = vos_pkt_push_head(vosDataBuff, WLANTL_BT_AMP_LLC_HEADER,
9948 sizeof(WLANTL_BT_AMP_LLC_HEADER));
9949
9950 if ( VOS_STATUS_SUCCESS != vosStatus )
9951 {
9952 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9953 "WLAN TL: Packet push LLC header fails on"
9954 " WLANTL_Translate8023To80211Header"));
9955 return vosStatus;
9956 }
9957 }
9958#else
9959 vosStatus = vos_pkt_push_head(vosDataBuff, WLANTL_LLC_HEADER,
9960 sizeof(WLANTL_LLC_HEADER));
9961
9962 if ( VOS_STATUS_SUCCESS != vosStatus )
9963 {
9964 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9965 "WLAN TL: Packet push LLC header fails on"
9966 " WLANTL_Translate8023To80211Header"));
9967 return vosStatus;
9968 }
9969#endif
9970 }/*If add LLC is enabled*/
9971 else
9972 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009973#ifdef FEATURE_WLAN_ESE_UPLOAD
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009974 bIAPPTxwithLLC = VOS_FALSE; /*Reset the Flag here to start afresh with the next TX pkt*/
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009975#endif /* FEATURE_WLAN_ESE_UPLOAD */
Jeff Johnson295189b2012-06-20 16:38:30 -07009976 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
9977 "WLAN TL: STA Client registered to not remove LLC"
9978 " WLANTL_Translate8023To80211Header"));
9979 }
9980
9981#ifdef BTAMP_TEST
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309982 pClientSTA->wSTADesc.wSTAType = WLAN_STA_BT_AMP;
Jeff Johnson295189b2012-06-20 16:38:30 -07009983#endif
9984
9985 // Find the space required for the 802.11 header format
9986 // based on the frame control fields.
9987 ucHeaderSize = MandatoryucHeaderSize;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309988 if (pClientSTA->wSTADesc.ucQosEnabled)
Jeff Johnson295189b2012-06-20 16:38:30 -07009989 {
9990 ucHeaderSize += sizeof(pw80211Header->usQosCtrl);
9991 }
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309992 if (pClientSTA->wSTADesc.wSTAType == WLAN_STA_BT_AMP)
Jeff Johnson295189b2012-06-20 16:38:30 -07009993 {
9994 ucHeaderSize += sizeof(pw80211Header->optvA4);
Jeff Johnson295189b2012-06-20 16:38:30 -07009995 ucQoSOffset += sizeof(pw80211Header->optvA4);
Jeff Johnson295189b2012-06-20 16:38:30 -07009996 }
9997
9998 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
9999 " WLANTL_Translate8023To80211Header : Header size = %d ", ucHeaderSize));
10000
10001 vos_pkt_reserve_head( vosDataBuff, &ppvBDHeader, ucHeaderSize );
10002 if ( NULL == ppvBDHeader )
10003 {
10004 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
10005 "WLAN TL:VOSS packet corrupted "));
10006 *pvosStatus = VOS_STATUS_E_INVAL;
10007 return *pvosStatus;
10008 }
10009
Jeff Johnson295189b2012-06-20 16:38:30 -070010010
10011 // OK now we have the space. Fill the 80211 header
10012 /* Fill A2 */
10013 pw80211Header = (WLANTL_80211HeaderType *)(ppvBDHeader);
10014 // only clear the required space.
10015 vos_mem_set( pw80211Header, ucHeaderSize, 0 );
10016 vos_mem_copy( pw80211Header->vA2, w8023Header.vSA, VOS_MAC_ADDR_SIZE);
10017
10018
10019#ifdef FEATURE_WLAN_WAPI
Gopichand Nakkala8b54e912013-03-11 10:44:21 +053010020 if (( WLANTL_STA_AUTHENTICATED == pClientSTA->tlState ||
10021 pClientSTA->ptkInstalled ) && gUcIsWai != 1)
Jeff Johnson295189b2012-06-20 16:38:30 -070010022#else
Gopichand Nakkala8b54e912013-03-11 10:44:21 +053010023 if ( WLANTL_STA_AUTHENTICATED == pClientSTA->tlState ||
10024 pClientSTA->ptkInstalled )
Jeff Johnson295189b2012-06-20 16:38:30 -070010025#endif
10026 {
10027 pw80211Header->wFrmCtrl.wep =
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053010028 pClientSTA->wSTADesc.ucProtectedFrame;
Jeff Johnson295189b2012-06-20 16:38:30 -070010029 }
10030
10031 pw80211Header->usDurationId = 0;
10032 pw80211Header->usSeqCtrl = 0;
10033
10034 pw80211Header->wFrmCtrl.type = WLANTL_80211_DATA_TYPE;
10035
10036
10037
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053010038 if(pClientSTA->wSTADesc.ucQosEnabled)
Jeff Johnson295189b2012-06-20 16:38:30 -070010039 {
10040 pw80211Header->wFrmCtrl.subType = WLANTL_80211_DATA_QOS_SUBTYPE;
10041
Ravi Joshid0699502013-07-08 15:48:47 -070010042 *((v_U16_t *)((v_U8_t *)ppvBDHeader + ucQoSOffset)) = tlMetaInfo->ucUP;
Jeff Johnson295189b2012-06-20 16:38:30 -070010043
10044 }
10045 else
10046 {
10047 pw80211Header->wFrmCtrl.subType = 0;
Agarwal Ashish8b343f12015-01-08 20:06:44 +053010048 tlMetaInfo->ucUP = 0;
10049 tlMetaInfo->ucTID = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070010050
10051 // NO NO NO - there is not enough memory allocated to write the QOS ctrl
10052 // field, it will overwrite the first 2 bytes of the data packet(LLC header)
10053 // pw80211Header->usQosCtrl = 0;
10054 }
10055
10056
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053010057 switch( pClientSTA->wSTADesc.wSTAType )
Jeff Johnson295189b2012-06-20 16:38:30 -070010058 {
Ravi Joshid0699502013-07-08 15:48:47 -070010059 case WLAN_STA_IBSS:
Jeff Johnson295189b2012-06-20 16:38:30 -070010060 pw80211Header->wFrmCtrl.toDS = 0;
10061 pw80211Header->wFrmCtrl.fromDS = 0;
Ravi Joshid0699502013-07-08 15:48:47 -070010062
Abhishek Singh45e68fe2014-12-11 12:55:59 +053010063 vos_copy_macaddr( (v_MACADDR_t*)&pw80211Header->vA1,
Ravi Joshid0699502013-07-08 15:48:47 -070010064 (v_MACADDR_t*)&w8023Header.vDA);
Jeff Johnson295189b2012-06-20 16:38:30 -070010065 vos_mem_copy( pw80211Header->vA3,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053010066 &pClientSTA->wSTADesc.vBSSIDforIBSS ,
Jeff Johnson295189b2012-06-20 16:38:30 -070010067 VOS_MAC_ADDR_SIZE);
10068 break;
10069
Ravi Joshid0699502013-07-08 15:48:47 -070010070 case WLAN_STA_BT_AMP:
Jeff Johnson295189b2012-06-20 16:38:30 -070010071 *ucWDSEnabled = 1; // WDS on.
10072 pw80211Header->wFrmCtrl.toDS = 1;
10073 pw80211Header->wFrmCtrl.fromDS = 1;
10074 vos_copy_macaddr( (v_MACADDR_t*)&pw80211Header->vA1,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053010075 &pClientSTA->wSTADesc.vSTAMACAddress);
Jeff Johnson295189b2012-06-20 16:38:30 -070010076 vos_mem_copy( pw80211Header->vA2,
Ravi Joshid0699502013-07-08 15:48:47 -070010077 w8023Header.vSA, VOS_MAC_ADDR_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -070010078 vos_copy_macaddr( (v_MACADDR_t*)&pw80211Header->vA3,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053010079 &pClientSTA->wSTADesc.vSTAMACAddress);
Jeff Johnson295189b2012-06-20 16:38:30 -070010080 /* fill the optional A4 header */
10081 vos_mem_copy( pw80211Header->optvA4,
Ravi Joshid0699502013-07-08 15:48:47 -070010082 w8023Header.vSA, VOS_MAC_ADDR_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -070010083 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
Arif Hussainf2b00992013-11-17 21:46:15 -080010084 "BTAMP CASE NOW ---------staid=%d",
Ravi Joshid0699502013-07-08 15:48:47 -070010085 ucStaId));
Jeff Johnson295189b2012-06-20 16:38:30 -070010086 break;
10087
Ravi Joshid0699502013-07-08 15:48:47 -070010088 case WLAN_STA_SOFTAP:
Jeff Johnson295189b2012-06-20 16:38:30 -070010089 *ucWDSEnabled = 0; // WDS off.
10090 pw80211Header->wFrmCtrl.toDS = 0;
10091 pw80211Header->wFrmCtrl.fromDS = 1;
10092 /*Copy the DA to A1*/
10093 vos_mem_copy( pw80211Header->vA1, w8023Header.vDA , VOS_MAC_ADDR_SIZE);
10094 vos_copy_macaddr( (v_MACADDR_t*)&pw80211Header->vA2,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053010095 &pClientSTA->wSTADesc.vSelfMACAddress);
Jeff Johnson295189b2012-06-20 16:38:30 -070010096 vos_mem_copy( pw80211Header->vA3,
Ravi Joshid0699502013-07-08 15:48:47 -070010097 w8023Header.vSA, VOS_MAC_ADDR_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -070010098 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
Arif Hussainf2b00992013-11-17 21:46:15 -080010099 "sw 802 to 80211 softap case ---------staid=%d",
Ravi Joshid0699502013-07-08 15:48:47 -070010100 ucStaId));
Jeff Johnson295189b2012-06-20 16:38:30 -070010101 break;
Mohit Khanna698ba2a2012-12-04 15:08:18 -080010102#ifdef FEATURE_WLAN_TDLS
Ravi Joshid0699502013-07-08 15:48:47 -070010103 case WLAN_STA_TDLS:
Mohit Khanna698ba2a2012-12-04 15:08:18 -080010104 pw80211Header->wFrmCtrl.toDS = 0;
10105 pw80211Header->wFrmCtrl.fromDS = 0;
10106 /*Fix me*/
10107 vos_copy_macaddr( (v_MACADDR_t*)&pw80211Header->vA1,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053010108 &pClientSTA->wSTADesc.vSTAMACAddress);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080010109 vos_mem_copy( pw80211Header->vA3,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053010110 &pClientSTA->wSTADesc.vBSSIDforIBSS ,
Mohit Khanna698ba2a2012-12-04 15:08:18 -080010111 VOS_MAC_ADDR_SIZE);
10112 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
Arif Hussainf2b00992013-11-17 21:46:15 -080010113 ("TL:TDLS CASE NOW ---------staid=%d"), ucStaId);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080010114 break;
10115#endif
Ravi Joshid0699502013-07-08 15:48:47 -070010116 case WLAN_STA_INFRA:
10117 default:
Jeff Johnson295189b2012-06-20 16:38:30 -070010118 pw80211Header->wFrmCtrl.toDS = 1;
10119 pw80211Header->wFrmCtrl.fromDS = 0;
10120 vos_copy_macaddr( (v_MACADDR_t*)&pw80211Header->vA1,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053010121 &pClientSTA->wSTADesc.vSTAMACAddress);
Jeff Johnson295189b2012-06-20 16:38:30 -070010122 vos_mem_copy( pw80211Header->vA3, w8023Header.vDA , VOS_MAC_ADDR_SIZE);
10123 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
Arif Hussainf2b00992013-11-17 21:46:15 -080010124 "REGULAR INFRA LINK CASE---------staid=%d",
Ravi Joshid0699502013-07-08 15:48:47 -070010125 ucStaId));
Jeff Johnson295189b2012-06-20 16:38:30 -070010126 break;
10127 }
10128 // OK now we have the space. Fill the 80211 header
10129 /* Fill A2 */
10130 pw80211Header = (WLANTL_80211HeaderType *)(ppvBDHeader);
10131 return VOS_STATUS_SUCCESS;
10132}/*WLANTL_Translate8023To80211Header*/
10133
10134
10135/*=============================================================================
10136 BEGIN LOG FUNCTION !!! Remove me or clean me
10137=============================================================================*/
Ravi Kumar Vaishnavb7652402013-01-18 19:05:15 -080010138#if 0 //def WLANTL_DEBUG
Jeff Johnson295189b2012-06-20 16:38:30 -070010139
10140#define WLANTL_DEBUG_FRAME_BYTE_PER_LINE 16
10141#define WLANTL_DEBUG_FRAME_BYTE_PER_BYTE 4
10142
10143static v_VOID_t WLANTL_DebugFrame
10144(
10145 v_PVOID_t dataPointer,
10146 v_U32_t dataSize
10147)
10148{
10149 v_U8_t lineBuffer[WLANTL_DEBUG_FRAME_BYTE_PER_LINE];
10150 v_U32_t numLines;
10151 v_U32_t numBytes;
10152 v_U32_t idx;
10153 v_U8_t *linePointer;
10154
10155 numLines = dataSize / WLANTL_DEBUG_FRAME_BYTE_PER_LINE;
10156 numBytes = dataSize % WLANTL_DEBUG_FRAME_BYTE_PER_LINE;
10157 linePointer = (v_U8_t *)dataPointer;
10158
10159 TLLOGE(VOS_TRACE(VOS_MODULE_ID_SAL, VOS_TRACE_LEVEL_ERROR, "WLAN TL:Frame Debug Frame Size %d, Pointer 0x%p", dataSize, dataPointer));
10160 for(idx = 0; idx < numLines; idx++)
10161 {
10162 memset(lineBuffer, 0, WLANTL_DEBUG_FRAME_BYTE_PER_LINE);
10163 memcpy(lineBuffer, linePointer, WLANTL_DEBUG_FRAME_BYTE_PER_LINE);
10164 TLLOGE(VOS_TRACE(VOS_MODULE_ID_SAL, VOS_TRACE_LEVEL_ERROR,
10165 "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",
10166 lineBuffer[0], lineBuffer[1], lineBuffer[2], lineBuffer[3], lineBuffer[4], lineBuffer[5], lineBuffer[6], lineBuffer[7],
10167 lineBuffer[8], lineBuffer[9], lineBuffer[10], lineBuffer[11], lineBuffer[12], lineBuffer[13], lineBuffer[14], lineBuffer[15]));
10168 linePointer += WLANTL_DEBUG_FRAME_BYTE_PER_LINE;
10169 }
10170
10171 if(0 == numBytes)
10172 return;
10173
10174 memset(lineBuffer, 0, WLANTL_DEBUG_FRAME_BYTE_PER_LINE);
10175 memcpy(lineBuffer, linePointer, numBytes);
10176 for(idx = 0; idx < WLANTL_DEBUG_FRAME_BYTE_PER_LINE / WLANTL_DEBUG_FRAME_BYTE_PER_BYTE; idx++)
10177 {
10178 TLLOGE(VOS_TRACE(VOS_MODULE_ID_SAL, VOS_TRACE_LEVEL_ERROR, "WLAN TL:0x%2x 0x%2x 0x%2x 0x%2x",
10179 lineBuffer[idx * WLANTL_DEBUG_FRAME_BYTE_PER_BYTE], lineBuffer[1 + idx * WLANTL_DEBUG_FRAME_BYTE_PER_BYTE],
10180 lineBuffer[2 + idx * WLANTL_DEBUG_FRAME_BYTE_PER_BYTE], lineBuffer[3 + idx * WLANTL_DEBUG_FRAME_BYTE_PER_BYTE]));
10181 if(((idx + 1) * WLANTL_DEBUG_FRAME_BYTE_PER_BYTE) >= numBytes)
10182 break;
10183 }
10184
10185 return;
10186}
10187#endif
10188
10189/*=============================================================================
10190 END LOG FUNCTION
10191=============================================================================*/
10192
10193/*==========================================================================
10194 FUNCTION WLANTL_Translate80211To8023Header
10195
10196 DESCRIPTION
10197 Inline function for translating and 802.11 header into an 802.3 header.
10198
10199 DEPENDENCIES
10200
10201
10202 PARAMETERS
10203
10204 IN
10205 pTLCb: TL control block
10206 ucStaId: station ID
10207 ucHeaderLen: Length of the header from BD
10208 ucActualHLen: Length of header including padding or any other trailers
10209
10210 IN/OUT
10211 vosDataBuff: vos data buffer, will contain the new header on output
10212
10213 OUT
10214 pvosStatus: status of the operation
10215
10216 RETURN VALUE
10217
10218 The result code associated with performing the operation
10219 VOS_STATUS_SUCCESS: Everything is good :)
10220
10221 SIDE EFFECTS
10222
10223============================================================================*/
10224VOS_STATUS
10225WLANTL_Translate80211To8023Header
10226(
10227 vos_pkt_t* vosDataBuff,
10228 VOS_STATUS* pvosStatus,
10229 v_U16_t usActualHLen,
10230 v_U8_t ucHeaderLen,
10231 WLANTL_CbType* pTLCb,
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070010232 v_U8_t ucSTAId,
10233 v_BOOL_t bForwardIAPPwithLLC
Jeff Johnson295189b2012-06-20 16:38:30 -070010234)
10235{
10236 WLANTL_8023HeaderType w8023Header;
10237 WLANTL_80211HeaderType w80211Header;
10238 v_U8_t aucLLCHeader[WLANTL_LLC_HEADER_LEN];
10239 VOS_STATUS vosStatus;
10240 v_U16_t usDataStartOffset = 0;
10241 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
10242
10243 if ( sizeof(w80211Header) < ucHeaderLen )
10244 {
10245 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
10246 "Warning !: Check the header size for the Rx frame structure=%d received=%dn",
10247 sizeof(w80211Header), ucHeaderLen));
10248 ucHeaderLen = sizeof(w80211Header);
10249 }
10250
10251 // This will take care of headers of all sizes, 3 address, 3 addr QOS,
10252 // WDS non-QOS and WDS QoS etc. We have space for all in the 802.11 header structure.
10253 vosStatus = vos_pkt_pop_head( vosDataBuff, &w80211Header, ucHeaderLen);
10254
10255 if ( VOS_STATUS_SUCCESS != vosStatus )
10256 {
10257 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
10258 "WLAN TL: Failed to pop 80211 header from packet %d",
10259 vosStatus));
10260
10261 return vosStatus;
10262 }
10263
10264 switch ( w80211Header.wFrmCtrl.fromDS )
10265 {
10266 case 0:
Jeff Johnson295189b2012-06-20 16:38:30 -070010267 if ( w80211Header.wFrmCtrl.toDS )
10268 {
10269 //SoftAP AP mode
10270 vos_mem_copy( w8023Header.vDA, w80211Header.vA3, VOS_MAC_ADDR_SIZE);
10271 vos_mem_copy( w8023Header.vSA, w80211Header.vA2, VOS_MAC_ADDR_SIZE);
10272 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
Arif Hussainf2b00992013-11-17 21:46:15 -080010273 "WLAN TL SoftAP: 802 3 DA %08x SA %08x",
Jeff Johnson295189b2012-06-20 16:38:30 -070010274 w8023Header.vDA, w8023Header.vSA));
10275 }
10276 else
10277 {
10278 /* IBSS */
10279 vos_mem_copy( w8023Header.vDA, w80211Header.vA1, VOS_MAC_ADDR_SIZE);
10280 vos_mem_copy( w8023Header.vSA, w80211Header.vA2, VOS_MAC_ADDR_SIZE);
10281 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010282 break;
10283 case 1:
10284 if ( w80211Header.wFrmCtrl.toDS )
10285 {
10286 /* BT-AMP case */
10287 vos_mem_copy( w8023Header.vDA, w80211Header.vA1, VOS_MAC_ADDR_SIZE);
10288 vos_mem_copy( w8023Header.vSA, w80211Header.vA2, VOS_MAC_ADDR_SIZE);
10289 }
10290 else
10291 { /* Infra */
10292 vos_mem_copy( w8023Header.vDA, w80211Header.vA1, VOS_MAC_ADDR_SIZE);
10293 vos_mem_copy( w8023Header.vSA, w80211Header.vA3, VOS_MAC_ADDR_SIZE);
10294 }
10295 break;
10296 }
10297
10298 if( usActualHLen > ucHeaderLen )
10299 {
10300 usDataStartOffset = usActualHLen - ucHeaderLen;
10301 }
10302
10303 if ( 0 < usDataStartOffset )
10304 {
10305 vosStatus = vos_pkt_trim_head( vosDataBuff, usDataStartOffset );
10306
10307 if ( VOS_STATUS_SUCCESS != vosStatus )
10308 {
10309 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
10310 "WLAN TL: Failed to trim header from packet %d",
10311 vosStatus));
10312 return vosStatus;
10313 }
10314 }
10315
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053010316 if ( NULL == pTLCb->atlSTAClients[ucSTAId] )
10317 {
10318 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
10319 "WLAN TL:Client Memory was not allocated on %s", __func__));
10320 return VOS_STATUS_E_FAILURE;
10321 }
10322
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070010323 if ( 0 != pTLCb->atlSTAClients[ucSTAId]->wSTADesc.ucAddRmvLLC
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010324#ifdef FEATURE_WLAN_ESE_UPLOAD
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070010325 && (!bForwardIAPPwithLLC)
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010326#endif /* FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070010327 )
Jeff Johnson295189b2012-06-20 16:38:30 -070010328 {
10329 // Extract the LLC header
10330 vosStatus = vos_pkt_pop_head( vosDataBuff, aucLLCHeader,
10331 WLANTL_LLC_HEADER_LEN);
10332
10333 if ( VOS_STATUS_SUCCESS != vosStatus )
10334 {
Kaushik, Sushante386ee12014-05-01 15:50:52 +053010335 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
Jeff Johnson295189b2012-06-20 16:38:30 -070010336 "WLAN TL: Failed to pop LLC header from packet %d",
10337 vosStatus));
10338
10339 return vosStatus;
10340 }
10341
10342 //Extract the length
10343 vos_mem_copy(&w8023Header.usLenType,
10344 &aucLLCHeader[WLANTL_LLC_HEADER_LEN - sizeof(w8023Header.usLenType)],
10345 sizeof(w8023Header.usLenType) );
10346 }
10347 else
10348 {
10349 vosStatus = vos_pkt_get_packet_length(vosDataBuff,
10350 &w8023Header.usLenType);
10351
10352 if ( VOS_STATUS_SUCCESS != vosStatus )
10353 {
10354 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
10355 "WLAN TL: Failed to get packet length %d",
10356 vosStatus));
10357
10358 return vosStatus;
10359 }
10360
10361 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
10362 "WLAN TL: BTAMP len (ethertype) fld = %d",
10363 w8023Header.usLenType));
10364 w8023Header.usLenType = vos_cpu_to_be16(w8023Header.usLenType);
10365 }
10366
10367 vos_pkt_push_head(vosDataBuff, &w8023Header, sizeof(w8023Header));
10368
10369#ifdef BTAMP_TEST
10370 {
10371 // AP side will execute this.
10372 v_U8_t *temp_w8023Header = NULL;
10373 vosStatus = vos_pkt_peek_data( vosDataBuff, 0,
10374 &temp_w8023Header, sizeof(w8023Header) );
10375 }
10376#endif
10377#if 0 /*TL_DEBUG*/
10378 vos_pkt_get_packet_length(vosDataBuff, &usLen);
10379 vos_pkt_pop_head( vosDataBuff, aucData, usLen);
10380
10381 WLANTL_DebugFrame(aucData, usLen);
10382
10383 vos_pkt_push_head(vosDataBuff, aucData, usLen);
10384
10385#endif
10386
10387 *pvosStatus = VOS_STATUS_SUCCESS;
10388
10389 return VOS_STATUS_SUCCESS;
10390}/*WLANTL_Translate80211To8023Header*/
10391
Madan Mohan Koyyalamudia148e1e2012-11-30 14:52:59 -080010392/*==========================================================================
10393 FUNCTION WLANTL_FindFrameTypeBcMcUc
10394
10395 DESCRIPTION
10396 Utility function to find whether received frame is broadcast, multicast
10397 or unicast.
10398
10399 DEPENDENCIES
10400 The STA must be registered with TL before this function can be called.
10401
10402 PARAMETERS
10403
10404 IN
10405 pTLCb: pointer to the TL's control block
10406 ucSTAId: identifier of the station being processed
10407 vosDataBuff: pointer to the vos buffer
10408
10409 IN/OUT
10410 pucBcMcUc: pointer to buffer, will contain frame type on return
10411
10412 RETURN VALUE
10413 The result code associated with performing the operation
10414
10415 VOS_STATUS_E_INVAL: invalid input parameters
10416 VOS_STATUS_E_BADMSG: failed to extract info from data buffer
10417 VOS_STATUS_SUCCESS: success
10418
10419 SIDE EFFECTS
10420 None.
10421============================================================================*/
10422VOS_STATUS
10423WLANTL_FindFrameTypeBcMcUc
10424(
10425 WLANTL_CbType *pTLCb,
10426 v_U8_t ucSTAId,
10427 vos_pkt_t *vosDataBuff,
10428 v_U8_t *pucBcMcUc
10429)
10430{
10431 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
10432 v_PVOID_t aucBDHeader;
10433 v_PVOID_t pvPeekData;
10434 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
10435
10436 /*------------------------------------------------------------------------
10437 Sanity check
10438 ------------------------------------------------------------------------*/
10439 if ((NULL == pTLCb) ||
10440 (NULL == vosDataBuff) ||
10441 (NULL == pucBcMcUc))
10442 {
10443 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
10444 "WLAN TL:Invalid parameter in WLANTL_FindFrameTypeBcMcUc"));
10445 return VOS_STATUS_E_INVAL;
10446 }
10447
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053010448 if ( NULL == pTLCb->atlSTAClients[ucSTAId] )
10449 {
10450 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
10451 "WLAN TL:Client Memory was not allocated on %s", __func__));
10452 return VOS_STATUS_E_FAILURE;
10453 }
10454
Madan Mohan Koyyalamudia148e1e2012-11-30 14:52:59 -080010455 /*------------------------------------------------------------------------
10456 Extract BD header and check if valid
10457 ------------------------------------------------------------------------*/
10458 vosStatus = WDA_DS_PeekRxPacketInfo(vosDataBuff, (v_PVOID_t)&aucBDHeader, 0/*Swap BD*/ );
10459
10460 if (NULL == aucBDHeader)
10461 {
10462 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
10463 "WLAN TL:WLANTL_FindFrameTypeBcMcUc - Cannot extract BD header"));
10464 VOS_ASSERT(0);
10465 return VOS_STATUS_E_BADMSG;
10466 }
10467
10468 if ((0 == WDA_GET_RX_FT_DONE(aucBDHeader)) &&
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053010469 (0 != pTLCb->atlSTAClients[ucSTAId]->wSTADesc.ucSwFrameRXXlation))
Madan Mohan Koyyalamudia148e1e2012-11-30 14:52:59 -080010470 {
10471 /* Its an 802.11 frame, extract MAC address 1 */
10472 TLLOG2(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
10473 "WLAN TL:WLANTL_FindFrameTypeBcMcUc - 802.11 frame, peeking Addr1"));
10474 vosStatus = vos_pkt_peek_data(vosDataBuff, WLANTL_MAC_ADDR_ALIGN(1),
10475 (v_PVOID_t)&pvPeekData, VOS_MAC_ADDR_SIZE);
10476 }
10477 else
10478 {
10479 /* Its an 802.3 frame, extract Destination MAC address */
10480 TLLOG2(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
10481 "WLAN TL:WLANTL_FindFrameTypeBcMcUc - 802.3 frame, peeking DA"));
10482 vosStatus = vos_pkt_peek_data(vosDataBuff, WLANTL_MAC_ADDR_ALIGN(0),
10483 (v_PVOID_t)&pvPeekData, VOS_MAC_ADDR_SIZE);
10484 }
10485
10486 if (VOS_STATUS_SUCCESS != vosStatus)
10487 {
10488 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
10489 "WLAN TL:WLANTL_FindFrameTypeBcMcUc - Failed to peek MAC address"));
10490 return vosStatus;
10491 }
10492
10493 if (((tANI_U8 *)pvPeekData)[0] == 0xff)
10494 {
10495 *pucBcMcUc = WLANTL_FRAME_TYPE_BCAST;
10496 }
10497 else
10498 {
10499 if ((((tANI_U8 *)pvPeekData)[0] & 0x01) == 0x01)
10500 *pucBcMcUc = WLANTL_FRAME_TYPE_MCAST;
10501 else
10502 *pucBcMcUc = WLANTL_FRAME_TYPE_UCAST;
10503 }
10504
10505 TLLOG2(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
10506 "WLAN TL:WLANTL_FindFrameTypeBcMcUc - Addr1Byte1 is: %x",
10507 ((tANI_U8 *)pvPeekData)[0]));
10508
10509 return VOS_STATUS_SUCCESS;
10510}
10511
Jeff Johnson295189b2012-06-20 16:38:30 -070010512#if 0
10513#ifdef WLAN_PERF
10514/*==========================================================================
10515 FUNCTION WLANTL_FastHwFwdDataFrame
10516
10517 DESCRIPTION
10518 Fast path function to quickly forward a data frame if HAL determines BD
10519 signature computed here matches the signature inside current VOSS packet.
10520 If there is a match, HAL and TL fills in the swapped packet length into
10521 BD header and DxE header, respectively. Otherwise, packet goes back to
10522 normal (slow) path and a new BD signature would be tagged into BD in this
10523 VOSS packet later by the WLANHAL_FillTxBd() function.
10524
10525 DEPENDENCIES
10526
10527 PARAMETERS
10528
10529 IN
10530 pvosGCtx VOS context
10531 vosDataBuff Ptr to VOSS packet
10532 pMetaInfo For getting frame's TID
10533 pStaInfo For checking STA type
10534
10535 OUT
10536 pvosStatus returned status
10537 puFastFwdOK Flag to indicate whether frame could be fast forwarded
10538
10539 RETURN VALUE
10540 No return.
10541
10542 SIDE EFFECTS
10543
10544============================================================================*/
10545static void
10546WLANTL_FastHwFwdDataFrame
10547(
10548 v_PVOID_t pvosGCtx,
10549 vos_pkt_t* vosDataBuff,
10550 VOS_STATUS* pvosStatus,
10551 v_U32_t* puFastFwdOK,
10552 WLANTL_MetaInfoType* pMetaInfo,
10553 WLAN_STADescType* pStaInfo
10554
10555)
10556{
10557 v_PVOID_t pvPeekData;
10558 v_U8_t ucDxEBDWLANHeaderLen = WLANTL_BD_HEADER_LEN(0) + sizeof(WLANBAL_sDXEHeaderType);
10559 v_U8_t ucIsUnicast;
10560 WLANBAL_sDXEHeaderType *pDxEHeader;
10561 v_PVOID_t pvBDHeader;
10562 v_PVOID_t pucBuffPtr;
10563 v_U16_t usPktLen;
10564
10565 /*-----------------------------------------------------------------------
10566 Extract packet length
10567 -----------------------------------------------------------------------*/
10568
10569 vos_pkt_get_packet_length( vosDataBuff, &usPktLen);
10570
10571 /*-----------------------------------------------------------------------
10572 Extract MAC address
10573 -----------------------------------------------------------------------*/
10574 *pvosStatus = vos_pkt_peek_data( vosDataBuff,
10575 WLANTL_MAC_ADDR_ALIGN(0),
10576 (v_PVOID_t)&pvPeekData,
10577 VOS_MAC_ADDR_SIZE );
10578
10579 if ( VOS_STATUS_SUCCESS != *pvosStatus )
10580 {
10581 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
10582 "WLAN TL:Failed while attempting to extract MAC Addr %d",
10583 *pvosStatus));
10584 *pvosStatus = VOS_STATUS_E_INVAL;
10585 return;
10586 }
10587
10588 /*-----------------------------------------------------------------------
10589 Reserve head room for DxE header, BD, and WLAN header
10590 -----------------------------------------------------------------------*/
10591
10592 vos_pkt_reserve_head( vosDataBuff, &pucBuffPtr,
10593 ucDxEBDWLANHeaderLen );
10594 if ( NULL == pucBuffPtr )
10595 {
10596 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
10597 "WLAN TL:No enough space in VOSS packet %p for DxE/BD/WLAN header", vosDataBuff));
10598 *pvosStatus = VOS_STATUS_E_INVAL;
10599 return;
10600 }
10601 pDxEHeader = (WLANBAL_sDXEHeaderType *)pucBuffPtr;
10602 pvBDHeader = (v_PVOID_t) &pDxEHeader[1];
10603
10604 /* UMA Tx acceleration is enabled.
10605 * UMA would help convert frames to 802.11, fill partial BD fields and
10606 * construct LLC header. To further accelerate this kind of frames,
10607 * HAL would attempt to reuse the BD descriptor if the BD signature
10608 * matches to the saved BD descriptor.
10609 */
10610 if(pStaInfo->wSTAType == WLAN_STA_IBSS)
10611 ucIsUnicast = !(((tANI_U8 *)pvPeekData)[0] & 0x01);
10612 else
10613 ucIsUnicast = 1;
10614
10615 *puFastFwdOK = (v_U32_t) WLANHAL_TxBdFastFwd(pvosGCtx, pvPeekData, pMetaInfo->ucTID, ucIsUnicast, pvBDHeader, usPktLen );
10616
10617 /* Can't be fast forwarded. Trim the VOS head back to original location. */
10618 if(! *puFastFwdOK){
10619 vos_pkt_trim_head(vosDataBuff, ucDxEBDWLANHeaderLen);
10620 }else{
10621 /* could be fast forwarded. Now notify BAL DxE header filling could be completely skipped
10622 */
10623 v_U32_t uPacketSize = WLANTL_BD_HEADER_LEN(0) + usPktLen;
10624 vos_pkt_set_user_data_ptr( vosDataBuff, VOS_PKT_USER_DATA_ID_BAL,
10625 (v_PVOID_t)uPacketSize);
10626 pDxEHeader->size = SWAP_ENDIAN_UINT32(uPacketSize);
10627 }
10628 *pvosStatus = VOS_STATUS_SUCCESS;
10629 return;
10630}
10631#endif /*WLAN_PERF*/
10632#endif
10633
10634#if 0
10635/*==========================================================================
10636 FUNCTION WLANTL_PrepareBDHeader
10637
10638 DESCRIPTION
10639 Inline function for preparing BD header before HAL processing.
10640
10641 DEPENDENCIES
10642 Just notify HAL that suspend in TL is complete.
10643
10644 PARAMETERS
10645
10646 IN
10647 vosDataBuff: vos data buffer
10648 ucDisableFrmXtl: is frame xtl disabled
10649
10650 OUT
10651 ppvBDHeader: it will contain the BD header
10652 pvDestMacAdddr: it will contain the destination MAC address
10653 pvosStatus: status of the combined processing
10654 pusPktLen: packet len.
10655
10656 RETURN VALUE
10657 No return.
10658
10659 SIDE EFFECTS
10660
10661============================================================================*/
10662void
10663WLANTL_PrepareBDHeader
10664(
10665 vos_pkt_t* vosDataBuff,
10666 v_PVOID_t* ppvBDHeader,
10667 v_MACADDR_t* pvDestMacAdddr,
10668 v_U8_t ucDisableFrmXtl,
10669 VOS_STATUS* pvosStatus,
10670 v_U16_t* pusPktLen,
10671 v_U8_t ucQosEnabled,
10672 v_U8_t ucWDSEnabled,
10673 v_U8_t extraHeadSpace
10674)
10675{
10676 v_U8_t ucHeaderOffset;
10677 v_U8_t ucHeaderLen;
Jeff Johnson295189b2012-06-20 16:38:30 -070010678 v_U8_t ucBDHeaderLen = WLANTL_BD_HEADER_LEN(ucDisableFrmXtl);
10679
10680 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
10681 /*-------------------------------------------------------------------------
10682 Get header pointer from VOSS
10683 !!! make sure reserve head zeros out the memory
10684 -------------------------------------------------------------------------*/
10685 vos_pkt_get_packet_length( vosDataBuff, pusPktLen);
10686
10687 if ( WLANTL_MAC_HEADER_LEN(ucDisableFrmXtl) > *pusPktLen )
10688 {
10689 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
10690 "WLAN TL: Length of the packet smaller than expected network"
10691 " header %d", *pusPktLen ));
10692
10693 *pvosStatus = VOS_STATUS_E_INVAL;
10694 return;
10695 }
10696
10697 vos_pkt_reserve_head( vosDataBuff, ppvBDHeader,
10698 ucBDHeaderLen );
10699 if ( NULL == *ppvBDHeader )
10700 {
10701 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
10702 "WLAN TL:VOSS packet corrupted on Attach BD header"));
10703 *pvosStatus = VOS_STATUS_E_INVAL;
10704 return;
10705 }
10706
10707 /*-----------------------------------------------------------------------
10708 Extract MAC address
10709 -----------------------------------------------------------------------*/
Jeff Johnson295189b2012-06-20 16:38:30 -070010710 {
10711 v_SIZE_t usMacAddrSize = VOS_MAC_ADDR_SIZE;
10712 *pvosStatus = vos_pkt_extract_data( vosDataBuff,
10713 ucBDHeaderLen +
10714 WLANTL_MAC_ADDR_ALIGN(ucDisableFrmXtl),
10715 (v_PVOID_t)pvDestMacAdddr,
10716 &usMacAddrSize );
10717 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010718 if ( VOS_STATUS_SUCCESS != *pvosStatus )
10719 {
10720 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
10721 "WLAN TL:Failed while attempting to extract MAC Addr %d",
10722 *pvosStatus));
10723 }
10724 else
10725 {
10726 /*---------------------------------------------------------------------
10727 Fill MPDU info fields:
10728 - MPDU data start offset
10729 - MPDU header start offset
10730 - MPDU header length
10731 - MPDU length - this is a 16b field - needs swapping
10732 --------------------------------------------------------------------*/
10733 ucHeaderOffset = ucBDHeaderLen;
10734 ucHeaderLen = WLANTL_MAC_HEADER_LEN(ucDisableFrmXtl);
10735
10736 if ( 0 != ucDisableFrmXtl )
10737 {
10738 if ( 0 != ucQosEnabled )
10739 {
10740 ucHeaderLen += WLANTL_802_11_HEADER_QOS_CTL;
10741 }
10742
10743 // Similar to Qos we need something for WDS format !
10744 if ( ucWDSEnabled != 0 )
10745 {
10746 // If we have frame translation enabled
10747 ucHeaderLen += WLANTL_802_11_HEADER_ADDR4_LEN;
10748 }
10749 if ( extraHeadSpace != 0 )
10750 {
10751 // Decrease the packet length with the extra padding after the header
10752 *pusPktLen = *pusPktLen - extraHeadSpace;
10753 }
10754 }
10755
10756 WLANHAL_TX_BD_SET_MPDU_HEADER_LEN( *ppvBDHeader, ucHeaderLen);
10757 WLANHAL_TX_BD_SET_MPDU_HEADER_OFFSET( *ppvBDHeader, ucHeaderOffset);
10758 WLANHAL_TX_BD_SET_MPDU_DATA_OFFSET( *ppvBDHeader,
10759 ucHeaderOffset + ucHeaderLen + extraHeadSpace);
10760 WLANHAL_TX_BD_SET_MPDU_LEN( *ppvBDHeader, *pusPktLen);
10761
10762 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
10763 "WLAN TL: VALUES ARE HLen=%x Hoff=%x doff=%x len=%x ex=%d",
10764 ucHeaderLen, ucHeaderOffset,
10765 (ucHeaderOffset + ucHeaderLen + extraHeadSpace),
10766 *pusPktLen, extraHeadSpace));
10767 }/* if peek MAC success*/
10768
10769}/* WLANTL_PrepareBDHeader */
10770#endif
10771
Jeff Johnson295189b2012-06-20 16:38:30 -070010772//THIS IS A HACK AND NEEDS TO BE FIXED FOR CONCURRENCY
10773/*==========================================================================
10774 FUNCTION WLAN_TLGetNextTxIds
10775
10776 DESCRIPTION
10777 Gets the next station and next AC in the list that should be served by the TL.
10778
10779 Multiple Station Scheduling and TL queue management.
10780
10781 4 HDD BC/MC data packet queue status is specified as Station 0's status. Weights used
10782 in WFQ algorith are initialized in WLANTL_OPEN and contained in tlConfigInfo field.
10783 Each station has fields of ucPktPending and AC mask to tell whether a AC has traffic
10784 or not.
10785
10786 Stations are served in a round-robin fashion from highest priority to lowest priority.
10787 The number of round-robin times of each prioirty equals to the WFQ weights and differetiates
10788 the traffic of different prioirty. As such, stations can not provide low priority packets if
10789 high priority packets are all served.
10790
10791 DEPENDENCIES
10792
10793 PARAMETERS
10794
10795 IN
10796 pvosGCtx: pointer to the global vos context; a handle to TL's
10797 control block can be extracted from its context
10798
10799 OUT
10800 pucSTAId: Station ID
10801
10802 RETURN VALUE
10803 The result code associated with performing the operation
10804
10805 VOS_STATUS_SUCCESS: Everything is good
10806
10807 SIDE EFFECTS
10808
10809 TL context contains currently served station ID in ucCurrentSTA field, currently served AC
10810 in uCurServedAC field, and unserved weights of current AC in uCurLeftWeight.
10811 When existing from the function, these three fields are changed accordingly.
10812
10813============================================================================*/
10814VOS_STATUS
10815WLAN_TLAPGetNextTxIds
10816(
10817 v_PVOID_t pvosGCtx,
10818 v_U8_t* pucSTAId
10819)
10820{
10821 WLANTL_CbType* pTLCb;
10822 v_U8_t ucACFilter = 1;
10823 v_U8_t ucNextSTA ;
10824 v_BOOL_t isServed = TRUE; //current round has find a packet or not
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +053010825 v_U8_t ucACLoopNum = WLANTL_AC_HIGH_PRIO + 1; //number of loop to go
Jeff Johnson295189b2012-06-20 16:38:30 -070010826 v_U8_t uFlowMask; // TX FlowMask from WDA
10827 uint8 ucACMask;
Gopichand Nakkala96237bc2013-01-04 12:20:29 -080010828 uint8 i = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070010829 /*------------------------------------------------------------------------
10830 Extract TL control block
10831 ------------------------------------------------------------------------*/
10832 //ENTER();
10833
10834 pTLCb = VOS_GET_TL_CB(pvosGCtx);
10835 if ( NULL == pTLCb )
10836 {
10837 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
10838 "WLAN TL:Invalid TL pointer from pvosGCtx on WLAN_TLAPGetNextTxIds"));
10839 return VOS_STATUS_E_FAULT;
10840 }
10841
10842 if ( VOS_STATUS_SUCCESS != WDA_DS_GetTxFlowMask( pvosGCtx, &uFlowMask ) )
10843 {
10844 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
10845 "WLAN TL:Failed to retrieve Flow control mask from WDA"));
10846 return VOS_STATUS_E_FAULT;
10847 }
10848
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +053010849 /* The flow mask does not differentiate between different ACs/Qs
10850 * since we use a single dxe channel for all ACs/Qs, hence it is
10851 * enough to check that there are dxe resources on data channel
10852 */
10853 uFlowMask &= WLANTL_DATA_FLOW_MASK;
10854
10855 if (0 == uFlowMask)
10856 {
10857 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
10858 "WLAN TL: No resources to send packets"));
10859
10860 // Setting STA Id to invalid if mask is 0
10861 *pucSTAId = WLAN_MAX_STA_COUNT;
10862 return VOS_STATUS_E_FAULT;
10863 }
10864
Jeff Johnson295189b2012-06-20 16:38:30 -070010865 ucNextSTA = pTLCb->ucCurrentSTA;
10866
10867 ++ucNextSTA;
10868
10869 if ( WLAN_MAX_STA_COUNT <= ucNextSTA )
10870 {
10871 //one round is done.
10872 ucNextSTA = 0;
10873 pTLCb->ucCurLeftWeight--;
10874 isServed = FALSE;
10875 if ( 0 == pTLCb->ucCurLeftWeight )
10876 {
10877 //current prioirty is done
10878 if ( WLANTL_AC_BK == (WLANTL_ACEnumType)pTLCb->uCurServedAC )
10879 {
10880 //end of current VO, VI, BE, BK loop. Reset priority.
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +053010881 pTLCb->uCurServedAC = WLANTL_AC_HIGH_PRIO;
Jeff Johnson295189b2012-06-20 16:38:30 -070010882 }
10883 else
10884 {
10885 pTLCb->uCurServedAC --;
10886 }
10887
10888 pTLCb->ucCurLeftWeight = pTLCb->tlConfigInfo.ucAcWeights[pTLCb->uCurServedAC];
10889
10890 } // (0 == pTLCb->ucCurLeftWeight)
10891 } //( WLAN_MAX_STA_COUNT == ucNextSTA )
10892
10893 //decide how many loops to go. if current loop is partial, do one extra to make sure
10894 //we cover every station
10895 if ((1 == pTLCb->ucCurLeftWeight) && (ucNextSTA != 0))
10896 {
10897 ucACLoopNum ++; // now is 5 loops
10898 }
10899
10900 /* Start with highest priority. ucNextSTA, pTLCb->uCurServedAC, pTLCb->ucCurLeftWeight
10901 all have previous values.*/
10902 for (; ucACLoopNum > 0; ucACLoopNum--)
10903 {
10904
10905 ucACFilter = 1 << pTLCb->uCurServedAC;
10906
10907 // pTLCb->ucCurLeftWeight keeps previous results.
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +053010908 for (; (pTLCb->ucCurLeftWeight > 0) ; pTLCb->ucCurLeftWeight-- )
Jeff Johnson295189b2012-06-20 16:38:30 -070010909 {
10910
10911 for ( ; ucNextSTA < WLAN_MAX_STA_COUNT; ucNextSTA ++ )
10912 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053010913 if(NULL == pTLCb->atlSTAClients[ucNextSTA])
10914 {
10915 continue;
10916 }
10917 WLAN_TL_AC_ARRAY_2_MASK (pTLCb->atlSTAClients[ucNextSTA], ucACMask, i);
Jeff Johnson295189b2012-06-20 16:38:30 -070010918
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053010919 if ( (0 == pTLCb->atlSTAClients[ucNextSTA]->ucExists) ||
10920 ((0 == pTLCb->atlSTAClients[ucNextSTA]->ucPktPending) && !(ucACMask)) ||
Jeff Johnson295189b2012-06-20 16:38:30 -070010921 (0 == (ucACMask & ucACFilter)) )
10922
10923 {
Tushnim Bhattacharyya39a8f182013-02-20 18:10:30 -080010924 //current station does not exist or have any packet to serve.
10925 continue;
10926 }
10927
10928 if (WLANTL_STA_AUTHENTICATED != pTLCb->atlSTAClients[ucNextSTA]->tlState)
10929 {
10930 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
10931 "%s Sta %d not in auth state so skipping it.",
10932 __func__, ucNextSTA));
Jeff Johnson295189b2012-06-20 16:38:30 -070010933 continue;
10934 }
10935
10936 //go to next station if current station can't send due to flow control
10937 //Station is allowed to send when it is not in LWM mode. When station is in LWM mode,
10938 //station is allowed to send only after FW reports FW memory is below threshold and on-fly
10939 //packets are less then allowed value
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053010940 if ( (TRUE == pTLCb->atlSTAClients[ucNextSTA]->ucLwmModeEnabled) &&
10941 ((FALSE == pTLCb->atlSTAClients[ucNextSTA]->ucLwmEventReported) ||
10942 (0 < pTLCb->atlSTAClients[ucNextSTA]->uBuffThresholdMax))
Jeff Johnson295189b2012-06-20 16:38:30 -070010943 )
10944 {
10945 continue;
10946 }
10947
10948
10949 // Find a station. Weight is updated already.
10950 *pucSTAId = ucNextSTA;
10951 pTLCb->ucCurrentSTA = ucNextSTA;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053010952 pTLCb->atlSTAClients[*pucSTAId]->ucCurrentAC = pTLCb->uCurServedAC;
Jeff Johnson295189b2012-06-20 16:38:30 -070010953
10954 TLLOG4(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_LOW,
10955 " TL serve one station AC: %d W: %d StaId: %d",
10956 pTLCb->uCurServedAC, pTLCb->ucCurLeftWeight, pTLCb->ucCurrentSTA ));
10957
10958 return VOS_STATUS_SUCCESS;
10959 } //STA loop
10960
10961 ucNextSTA = 0;
10962 if ( FALSE == isServed )
10963 {
10964 //current loop finds no packet.no need to repeat for the same priority
10965 break;
10966 }
10967 //current loop is partial loop. go for one more loop.
10968 isServed = FALSE;
10969
10970 } //Weight loop
10971
10972 if (WLANTL_AC_BK == pTLCb->uCurServedAC)
10973 {
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +053010974 pTLCb->uCurServedAC = WLANTL_AC_HIGH_PRIO;
Jeff Johnson295189b2012-06-20 16:38:30 -070010975 }
10976 else
10977 {
10978 pTLCb->uCurServedAC--;
10979 }
10980 pTLCb->ucCurLeftWeight = pTLCb->tlConfigInfo.ucAcWeights[pTLCb->uCurServedAC];
10981
10982 }// AC loop
10983
10984 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
Arif Hussainf2b00992013-11-17 21:46:15 -080010985 " TL can't find one station to serve" ));
Jeff Johnson295189b2012-06-20 16:38:30 -070010986
10987 pTLCb->uCurServedAC = WLANTL_AC_BK;
10988 pTLCb->ucCurLeftWeight = 1;
10989 //invalid number will be captured by caller
10990 pTLCb->ucCurrentSTA = WLAN_MAX_STA_COUNT;
10991
10992 *pucSTAId = pTLCb->ucCurrentSTA;
Jeff Johnson295189b2012-06-20 16:38:30 -070010993 return VOS_STATUS_E_FAULT;
10994}
10995
10996
10997/*==========================================================================
10998 FUNCTION WLAN_TLGetNextTxIds
10999
11000 DESCRIPTION
11001 Gets the next station and next AC in the list
11002
11003 DEPENDENCIES
11004
11005 PARAMETERS
11006
11007 IN
11008 pvosGCtx: pointer to the global vos context; a handle to TL's
11009 control block can be extracted from its context
11010
11011 OUT
11012 pucSTAId: Station ID
11013
11014
11015 RETURN VALUE
11016 The result code associated with performing the operation
11017
11018 VOS_STATUS_SUCCESS: Everything is good :)
11019
11020 SIDE EFFECTS
11021
11022============================================================================*/
11023VOS_STATUS
11024WLAN_TLGetNextTxIds
11025(
11026 v_PVOID_t pvosGCtx,
11027 v_U8_t* pucSTAId
11028)
11029{
11030 WLANTL_CbType* pTLCb;
11031 v_U8_t ucNextAC;
11032 v_U8_t ucNextSTA;
11033 v_U8_t ucCount;
11034 v_U8_t uFlowMask; // TX FlowMask from WDA
11035 v_U8_t ucACMask = 0;
11036 v_U8_t i = 0;
11037
11038 tBssSystemRole systemRole; //RG HACK to be removed
11039 tpAniSirGlobal pMac;
11040
11041 pMac = vos_get_context(VOS_MODULE_ID_PE, pvosGCtx);
11042 if ( NULL == pMac )
11043 {
11044 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070011045 "%s: Invalid pMac", __func__));
Jeff Johnson295189b2012-06-20 16:38:30 -070011046 return VOS_STATUS_E_FAULT;
11047 }
11048
11049 systemRole = wdaGetGlobalSystemRole(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -070011050
Jeff Johnson295189b2012-06-20 16:38:30 -070011051 /*------------------------------------------------------------------------
11052 Extract TL control block
11053 ------------------------------------------------------------------------*/
11054 pTLCb = VOS_GET_TL_CB(pvosGCtx);
11055 if ( NULL == pTLCb )
11056 {
11057 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11058 "WLAN TL:Invalid TL pointer from pvosGCtx on WLAN_TLGetNextTxIds"));
11059 return VOS_STATUS_E_FAULT;
11060 }
11061
Sunil Ravid5406f22013-01-22 00:18:31 -080011062#ifdef FEATURE_WLAN_TDLS
Agarwal Ashishcd86f7b2014-06-16 17:11:58 +053011063 if ((eSYSTEM_AP_ROLE == systemRole) ||
Katya Nigam1fd24402015-02-16 14:52:19 +053011064 (eSYSTEM_STA_IN_IBSS_ROLE == systemRole) ||
Agarwal Ashishcd86f7b2014-06-16 17:11:58 +053011065 (vos_concurrent_open_sessions_running()) || pTLCb->ucTdlsPeerCount)
Sunil Ravid5406f22013-01-22 00:18:31 -080011066#else
Agarwal Ashishcd86f7b2014-06-16 17:11:58 +053011067 if ((eSYSTEM_AP_ROLE == systemRole) ||
Katya Nigam1fd24402015-02-16 14:52:19 +053011068 (eSYSTEM_STA_IN_IBSS_ROLE == systemRole) ||
Agarwal Ashishcd86f7b2014-06-16 17:11:58 +053011069 (vos_concurrent_open_sessions_running()))
Sunil Ravid5406f22013-01-22 00:18:31 -080011070#endif
11071 {
11072 return WLAN_TLAPGetNextTxIds(pvosGCtx,pucSTAId);
11073 }
11074
11075
Jeff Johnson295189b2012-06-20 16:38:30 -070011076 if ( VOS_STATUS_SUCCESS != WDA_DS_GetTxFlowMask( pvosGCtx, &uFlowMask ) )
11077 {
11078 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11079 "WLAN TL:Failed to retrieve Flow control mask from WDA"));
11080 return VOS_STATUS_E_FAULT;
11081 }
11082
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +053011083 /* The flow mask does not differentiate between different ACs/Qs
11084 * since we use a single dxe channel for all ACs/Qs, hence it is
11085 * enough to check that there are dxe resources on data channel
11086 */
11087 uFlowMask &= WLANTL_DATA_FLOW_MASK;
11088
11089 if (0 == uFlowMask)
11090 {
11091 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11092 "WLAN TL: No resources to send packets"));
11093
11094 // Setting STA id to invalid if mask is 0
11095 *pucSTAId = WLAN_MAX_STA_COUNT;
11096 return VOS_STATUS_E_FAULT;
11097 }
11098
Jeff Johnson295189b2012-06-20 16:38:30 -070011099 /*STA id - no priority yet implemented */
11100 /*-----------------------------------------------------------------------
11101 Choose the next STA for tx - for now go in a round robin fashion
11102 through all the stations that have pending packets
11103 -------------------------------------------------------------------------*/
11104 ucNextSTA = pTLCb->ucCurrentSTA;
11105
11106 pTLCb->ucCurrentSTA = WLAN_MAX_STA_COUNT;
11107 for ( ucCount = 0;
11108 ucCount < WLAN_MAX_STA_COUNT;
11109 ucCount++ )
11110 {
11111 ucNextSTA = ( (ucNextSTA+1) >= WLAN_MAX_STA_COUNT )?0:(ucNextSTA+1);
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053011112 if(NULL == pTLCb->atlSTAClients[ucNextSTA])
11113 {
11114 continue;
11115 }
11116 if (( pTLCb->atlSTAClients[ucNextSTA]->ucExists ) &&
11117 ( pTLCb->atlSTAClients[ucNextSTA]->ucPktPending ))
Jeff Johnson295189b2012-06-20 16:38:30 -070011118 {
Tushnim Bhattacharyya39a8f182013-02-20 18:10:30 -080011119 if (WLANTL_STA_AUTHENTICATED == pTLCb->atlSTAClients[ucNextSTA]->tlState)
11120 {
11121 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
11122 "STA ID: %d on WLAN_TLGetNextTxIds", *pucSTAId));
11123 pTLCb->ucCurrentSTA = ucNextSTA;
11124 break;
Tushnim Bhattacharyya5dd94562013-03-20 20:15:03 -070011125 }
11126 else
11127 {
Tushnim Bhattacharyya39a8f182013-02-20 18:10:30 -080011128 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
11129 "%s Sta %d is not in auth state, skipping this sta.",
11130 __func__, ucNextSTA));
Tushnim Bhattacharyya5dd94562013-03-20 20:15:03 -070011131 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011132 }
11133 }
11134
11135 *pucSTAId = pTLCb->ucCurrentSTA;
11136
11137 if ( WLANTL_STA_ID_INVALID( *pucSTAId ) )
11138 {
11139 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
11140 "WLAN TL:No station registered with TL at this point"));
11141
11142 return VOS_STATUS_E_FAULT;
11143
11144 }
11145
11146 /*Convert the array to a mask for easier operation*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053011147 WLAN_TL_AC_ARRAY_2_MASK( pTLCb->atlSTAClients[*pucSTAId], ucACMask, i);
Jeff Johnson295189b2012-06-20 16:38:30 -070011148
11149 if ( 0 == ucACMask )
11150 {
11151 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11152 "WLAN TL: Mask 0 "
11153 "STA ID: %d on WLAN_TLGetNextTxIds", *pucSTAId));
11154
11155 /*setting STA id to invalid if mask is 0*/
11156 *pucSTAId = WLAN_MAX_STA_COUNT;
11157
11158 return VOS_STATUS_E_FAULT;
11159 }
11160
11161 /*-----------------------------------------------------------------------
11162 AC is updated whenever a packet is fetched from HDD -> the current
11163 weight of such an AC cannot be 0 -> in this case TL is expected to
11164 exit this function at this point during the main Tx loop
11165 -----------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053011166 if ( 0 < pTLCb->atlSTAClients[*pucSTAId]->ucCurrentWeight )
Jeff Johnson295189b2012-06-20 16:38:30 -070011167 {
11168 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
11169 "WLAN TL: Maintaining serviced AC to: %d for Weight: %d",
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053011170 pTLCb->atlSTAClients[*pucSTAId]->ucCurrentAC ,
11171 pTLCb->atlSTAClients[*pucSTAId]->ucCurrentWeight));
Jeff Johnson295189b2012-06-20 16:38:30 -070011172 return VOS_STATUS_SUCCESS;
11173 }
11174
11175 /*-----------------------------------------------------------------------
11176 Choose highest priority AC - !!! optimize me
11177 -----------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053011178 ucNextAC = pTLCb->atlSTAClients[*pucSTAId]->ucCurrentAC;
Jeff Johnson295189b2012-06-20 16:38:30 -070011179 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
11180 "Next AC: %d", ucNextAC));
11181
11182 while ( 0 != ucACMask )
11183 {
11184 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
11185 " AC Mask: %d Next: %d Res : %d",
11186 ucACMask, ( 1 << ucNextAC ), ( ucACMask & ( 1 << ucNextAC ))));
11187
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +053011188 if ( 0 != ( ucACMask & ( 1 << ucNextAC )))
Jeff Johnson295189b2012-06-20 16:38:30 -070011189 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053011190 pTLCb->atlSTAClients[*pucSTAId]->ucCurrentAC =
Jeff Johnson295189b2012-06-20 16:38:30 -070011191 (WLANTL_ACEnumType)ucNextAC;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053011192 pTLCb->atlSTAClients[*pucSTAId]->ucCurrentWeight =
Jeff Johnson295189b2012-06-20 16:38:30 -070011193 pTLCb->tlConfigInfo.ucAcWeights[ucNextAC];
11194
11195 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
11196 "WLAN TL: Switching serviced AC to: %d with Weight: %d",
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053011197 pTLCb->atlSTAClients[*pucSTAId]->ucCurrentAC ,
11198 pTLCb->atlSTAClients[*pucSTAId]->ucCurrentWeight));
Jeff Johnson295189b2012-06-20 16:38:30 -070011199 break;
11200 }
11201
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +053011202 if (ucNextAC == WLANTL_AC_BK)
11203 ucNextAC = WLANTL_AC_HIGH_PRIO;
11204 else
11205 ucNextAC--;
Jeff Johnson295189b2012-06-20 16:38:30 -070011206
11207 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
11208 "Next AC %d", ucNextAC));
Jeff Johnson295189b2012-06-20 16:38:30 -070011209 }
11210
11211 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
11212 " C AC: %d C W: %d",
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053011213 pTLCb->atlSTAClients[*pucSTAId]->ucCurrentAC,
11214 pTLCb->atlSTAClients[*pucSTAId]->ucCurrentWeight));
Jeff Johnson295189b2012-06-20 16:38:30 -070011215
11216 return VOS_STATUS_SUCCESS;
11217}/* WLAN_TLGetNextTxIds */
11218
Jeff Johnson295189b2012-06-20 16:38:30 -070011219
11220
11221/*==========================================================================
11222 DEFAULT HANDLERS: Registered at initialization with TL
11223 ==========================================================================*/
11224
11225/*==========================================================================
11226
11227 FUNCTION WLANTL_MgmtFrmRxDefaultCb
11228
11229 DESCRIPTION
11230 Default Mgmt Frm rx callback: asserts all the time. If this function gets
11231 called it means there is no registered rx cb pointer for Mgmt Frm.
11232
11233 DEPENDENCIES
11234
11235 PARAMETERS
11236 Not used.
11237
11238 RETURN VALUE
11239
11240 VOS_STATUS_E_FAILURE: Always FAILURE.
11241
11242============================================================================*/
11243VOS_STATUS
11244WLANTL_MgmtFrmRxDefaultCb
11245(
11246 v_PVOID_t pvosGCtx,
11247 v_PVOID_t vosBuff
11248)
11249{
11250 if ( NULL != vosBuff )
11251 {
11252 TLLOGP(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_FATAL,
11253 "WLAN TL:Fatal failure: No registered Mgmt Frm client on pkt RX"));
11254 /* Drop packet */
11255 vos_pkt_return_packet((vos_pkt_t *)vosBuff);
11256 }
11257
Jeff Johnson295189b2012-06-20 16:38:30 -070011258 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
11259 "WLAN TL: No registered Mgmt Frm client on pkt RX. Load/Unload in progress, Ignore"));
Jeff Johnson295189b2012-06-20 16:38:30 -070011260
11261 return VOS_STATUS_E_FAILURE;
11262}/*WLANTL_MgmtFrmRxDefaultCb*/
11263
11264/*==========================================================================
11265
Madan Mohan Koyyalamudi6c2977d2013-09-04 15:42:45 +053011266 FUNCTION WLANTL_BAPRxDefaultCb
Jeff Johnson295189b2012-06-20 16:38:30 -070011267
11268 DESCRIPTION
11269 Default BAP rx callback: asserts all the time. If this function gets
11270 called it means there is no registered rx cb pointer for BAP.
11271
11272 DEPENDENCIES
11273
11274 PARAMETERS
11275 Not used.
11276
11277 RETURN VALUE
11278
11279 VOS_STATUS_E_FAILURE: Always FAILURE.
11280
11281============================================================================*/
11282VOS_STATUS
11283WLANTL_BAPRxDefaultCb
11284(
11285 v_PVOID_t pvosGCtx,
11286 vos_pkt_t* vosDataBuff,
11287 WLANTL_BAPFrameEnumType frameType
11288)
11289{
11290 TLLOGP(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_FATAL,
11291 "WLAN TL:Fatal failure: No registered BAP client on BAP pkt RX"));
11292#ifndef BTAMP_TEST
11293 VOS_ASSERT(0);
11294#endif
11295 return VOS_STATUS_E_FAILURE;
11296}/*WLANTL_MgmtFrmRxDefaultCb*/
11297
11298/*==========================================================================
11299
11300 FUNCTION WLANTL_STARxDefaultCb
11301
11302 DESCRIPTION
11303 Default STA rx callback: asserts all the time. If this function gets
11304 called it means there is no registered rx cb pointer for station.
11305 (Mem corruption most likely, it should never happen)
11306
11307 DEPENDENCIES
11308
11309 PARAMETERS
11310 Not used.
11311
11312 RETURN VALUE
11313
11314 VOS_STATUS_E_FAILURE: Always FAILURE.
11315
11316============================================================================*/
11317VOS_STATUS
11318WLANTL_STARxDefaultCb
11319(
11320 v_PVOID_t pvosGCtx,
11321 vos_pkt_t* vosDataBuff,
11322 v_U8_t ucSTAId,
11323 WLANTL_RxMetaInfoType* pRxMetaInfo
11324)
11325{
11326 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11327 "WLAN TL: No registered STA client rx cb for STAID: %d dropping pkt",
11328 ucSTAId));
11329 vos_pkt_return_packet(vosDataBuff);
Madan Mohan Koyyalamudi6c2977d2013-09-04 15:42:45 +053011330 return VOS_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070011331}/*WLANTL_MgmtFrmRxDefaultCb*/
11332
11333
11334/*==========================================================================
11335
11336 FUNCTION WLANTL_STAFetchPktDefaultCb
11337
11338 DESCRIPTION
11339 Default fetch callback: asserts all the time. If this function gets
11340 called it means there is no registered fetch cb pointer for station.
11341 (Mem corruption most likely, it should never happen)
11342
11343 DEPENDENCIES
11344
11345 PARAMETERS
11346 Not used.
11347
11348 RETURN VALUE
11349
11350 VOS_STATUS_E_FAILURE: Always FAILURE.
11351
11352============================================================================*/
11353VOS_STATUS
11354WLANTL_STAFetchPktDefaultCb
11355(
11356 v_PVOID_t pvosGCtx,
11357 v_U8_t* pucSTAId,
11358 WLANTL_ACEnumType ucAC,
11359 vos_pkt_t** vosDataBuff,
11360 WLANTL_MetaInfoType* tlMetaInfo
11361)
11362{
11363 TLLOGP(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_FATAL,
11364 "WLAN TL:Fatal failure: No registered STA client on data pkt RX"));
11365 VOS_ASSERT(0);
11366 return VOS_STATUS_E_FAILURE;
11367}/*WLANTL_MgmtFrmRxDefaultCb*/
11368
11369/*==========================================================================
11370
11371 FUNCTION WLANTL_TxCompDefaultCb
11372
11373 DESCRIPTION
11374 Default tx complete handler. It will release the completed pkt to
11375 prevent memory leaks.
11376
11377 PARAMETERS
11378
11379 IN
11380 pvosGCtx: pointer to the global vos context; a handle to
11381 TL/HAL/PE/BAP/HDD control block can be extracted from
11382 its context
11383 vosDataBuff: pointer to the VOSS data buffer that was transmitted
11384 wTxSTAtus: status of the transmission
11385
11386
11387 RETURN VALUE
11388 The result code associated with performing the operation; please
11389 check vos_pkt_return_packet for possible error codes.
11390
11391 Please check vos_pkt_return_packet API for possible return values.
11392
11393============================================================================*/
11394VOS_STATUS
11395WLANTL_TxCompDefaultCb
11396(
11397 v_PVOID_t pvosGCtx,
11398 vos_pkt_t* vosDataBuff,
11399 VOS_STATUS wTxSTAtus
11400)
11401{
11402 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
11403 "WLAN TL:TXComp not registered, releasing pkt to prevent mem leak"));
11404 return vos_pkt_return_packet(vosDataBuff);
11405}/*WLANTL_TxCompDefaultCb*/
11406
11407
11408/*==========================================================================
11409 Cleanup functions
11410 ==========================================================================*/
11411
11412/*==========================================================================
11413
11414 FUNCTION WLANTL_CleanCB
11415
11416 DESCRIPTION
11417 Cleans TL control block
11418
11419 DEPENDENCIES
11420
11421 PARAMETERS
11422
11423 IN
11424 pTLCb: pointer to TL's control block
11425 ucEmpty: set if TL has to clean up the queues and release pedning pkts
11426
11427 RETURN VALUE
11428 The result code associated with performing the operation
11429
11430 VOS_STATUS_E_INVAL: invalid input parameters
11431 VOS_STATUS_SUCCESS: Everything is good :)
11432
11433 SIDE EFFECTS
11434
11435============================================================================*/
11436VOS_STATUS
11437WLANTL_CleanCB
11438(
11439 WLANTL_CbType* pTLCb,
11440 v_U8_t ucEmpty
11441)
11442{
11443 v_U8_t ucIndex;
11444 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
11445
11446 /*-------------------------------------------------------------------------
11447 Sanity check
11448 -------------------------------------------------------------------------*/
11449 if ( NULL == pTLCb )
11450 {
11451 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11452 "WLAN TL:Invalid parameter sent on WLANTL_CleanCB"));
11453 return VOS_STATUS_E_INVAL;
11454 }
11455
11456 /* number of packets sent to BAL waiting for tx complete confirmation */
11457 pTLCb->usPendingTxCompleteCount = 0;
11458
11459 /* global suspend flag */
11460 vos_atomic_set_U8( &pTLCb->ucTxSuspended, 1);
11461
11462 /* resource flag */
11463 pTLCb->uResCount = 0;
11464
11465
11466 /*-------------------------------------------------------------------------
11467 Client stations
11468 -------------------------------------------------------------------------*/
11469 for ( ucIndex = 0; ucIndex < WLAN_MAX_STA_COUNT ; ucIndex++)
11470 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053011471 if(NULL != pTLCb->atlSTAClients[ucIndex])
11472 {
11473 WLANTL_CleanSTA( pTLCb->atlSTAClients[ucIndex], ucEmpty);
11474 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011475 }
11476
11477 /*-------------------------------------------------------------------------
11478 Management Frame client
11479 -------------------------------------------------------------------------*/
11480 pTLCb->tlMgmtFrmClient.ucExists = 0;
11481
11482 if ( ( 0 != ucEmpty) &&
11483 ( NULL != pTLCb->tlMgmtFrmClient.vosPendingDataBuff ))
11484 {
11485 vos_pkt_return_packet(pTLCb->tlMgmtFrmClient.vosPendingDataBuff);
11486 }
11487
11488 pTLCb->tlMgmtFrmClient.vosPendingDataBuff = NULL;
11489
11490 /* set to a default cb in order to prevent constant checking for NULL */
11491 pTLCb->tlMgmtFrmClient.pfnTlMgmtFrmRx = WLANTL_MgmtFrmRxDefaultCb;
11492
11493 /*-------------------------------------------------------------------------
11494 BT AMP client
11495 -------------------------------------------------------------------------*/
11496 pTLCb->tlBAPClient.ucExists = 0;
11497
11498 if (( 0 != ucEmpty) &&
11499 ( NULL != pTLCb->tlBAPClient.vosPendingDataBuff ))
11500 {
11501 vos_pkt_return_packet(pTLCb->tlBAPClient.vosPendingDataBuff);
11502 }
11503
11504 if (( 0 != ucEmpty) &&
11505 ( NULL != pTLCb->vosDummyBuf ))
11506 {
11507 vos_pkt_return_packet(pTLCb->vosDummyBuf);
11508 }
11509
11510 pTLCb->tlBAPClient.vosPendingDataBuff = NULL;
11511
11512 pTLCb->vosDummyBuf = NULL;
11513 pTLCb->vosTempBuf = NULL;
11514 pTLCb->ucCachedSTAId = WLAN_MAX_STA_COUNT;
11515
11516 /* set to a default cb in order to prevent constant checking for NULL */
11517 pTLCb->tlBAPClient.pfnTlBAPRx = WLANTL_BAPRxDefaultCb;
11518
11519 pTLCb->ucRegisteredStaId = WLAN_MAX_STA_COUNT;
11520
11521 return VOS_STATUS_SUCCESS;
11522
11523}/* WLANTL_CleanCB*/
11524
11525/*==========================================================================
11526
11527 FUNCTION WLANTL_CleanSTA
11528
11529 DESCRIPTION
11530 Cleans a station control block.
11531
11532 DEPENDENCIES
11533
11534 PARAMETERS
11535
11536 IN
11537 pvosGCtx: pointer to the global vos context; a handle to TL's
11538 control block can be extracted from its context
11539 ucEmpty: if set the queues and pending pkts will be emptyed
11540
11541 RETURN VALUE
11542 The result code associated with performing the operation
11543
11544 VOS_STATUS_E_INVAL: invalid input parameters
11545 VOS_STATUS_SUCCESS: Everything is good :)
11546
11547 SIDE EFFECTS
11548
11549============================================================================*/
11550VOS_STATUS
11551WLANTL_CleanSTA
11552(
11553 WLANTL_STAClientType* ptlSTAClient,
11554 v_U8_t ucEmpty
11555)
11556{
11557 v_U8_t ucIndex;
11558 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
11559
11560 /*-------------------------------------------------------------------------
11561 Sanity check
11562 -------------------------------------------------------------------------*/
11563 if ( NULL == ptlSTAClient )
11564 {
11565 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11566 "WLAN TL:Invalid parameter sent on WLANTL_CleanSTA"));
11567 return VOS_STATUS_E_INVAL;
11568 }
11569
11570 /*------------------------------------------------------------------------
11571 Clear station from TL
11572 ------------------------------------------------------------------------*/
11573 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
11574 "WLAN TL: Clearing STA Client ID: %d, Empty flag: %d",
11575 ptlSTAClient->wSTADesc.ucSTAId, ucEmpty ));
11576
11577 ptlSTAClient->pfnSTARx = WLANTL_STARxDefaultCb;
11578 ptlSTAClient->pfnSTATxComp = WLANTL_TxCompDefaultCb;
11579 ptlSTAClient->pfnSTAFetchPkt = WLANTL_STAFetchPktDefaultCb;
11580
11581 ptlSTAClient->tlState = WLANTL_STA_INIT;
11582 ptlSTAClient->tlPri = WLANTL_STA_PRI_NORMAL;
11583
11584 vos_zero_macaddr( &ptlSTAClient->wSTADesc.vSTAMACAddress );
11585 vos_zero_macaddr( &ptlSTAClient->wSTADesc.vBSSIDforIBSS );
11586 vos_zero_macaddr( &ptlSTAClient->wSTADesc.vSelfMACAddress );
11587
11588 ptlSTAClient->wSTADesc.ucSTAId = 0;
11589 ptlSTAClient->wSTADesc.wSTAType = WLAN_STA_MAX;
11590
11591 ptlSTAClient->wSTADesc.ucQosEnabled = 0;
11592 ptlSTAClient->wSTADesc.ucAddRmvLLC = 0;
11593 ptlSTAClient->wSTADesc.ucSwFrameTXXlation = 0;
11594 ptlSTAClient->wSTADesc.ucSwFrameRXXlation = 0;
11595 ptlSTAClient->wSTADesc.ucProtectedFrame = 0;
11596
Nirav Shah4f765af2015-01-21 19:51:30 +053011597 ptlSTAClient->pfnSTAUlaComplete = NULL;
11598 ptlSTAClient->pUlaCBCtx = NULL;
11599 ptlSTAClient->isEapolM4Transmitted = 0;
11600
Jeff Johnson295189b2012-06-20 16:38:30 -070011601 /*-------------------------------------------------------------------------
11602 AMSDU information for the STA
11603 -------------------------------------------------------------------------*/
11604 if ( ( 0 != ucEmpty ) &&
11605 ( NULL != ptlSTAClient->vosAMSDUChainRoot ))
11606 {
Madan Mohan Koyyalamudic0e5bd82012-09-18 17:12:27 -070011607 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_FATAL,
Jeff Johnson0298bd02013-11-14 19:58:38 -080011608 "WLAN TL:Non NULL vosAMSDUChainRoot on WLANTL_CleanSTA, "
Madan Mohan Koyyalamudic0e5bd82012-09-18 17:12:27 -070011609 "suspecting a memory corruption"));
11610
Jeff Johnson295189b2012-06-20 16:38:30 -070011611 }
11612
11613 ptlSTAClient->vosAMSDUChain = NULL;
11614 ptlSTAClient->vosAMSDUChainRoot = NULL;
11615
11616 vos_mem_zero( (v_PVOID_t)ptlSTAClient->aucMPDUHeader,
11617 WLANTL_MPDU_HEADER_LEN);
11618 ptlSTAClient->ucMPDUHeaderLen = 0;
11619
11620 /*-------------------------------------------------------------------------
11621 Reordering information for the STA
11622 -------------------------------------------------------------------------*/
11623 for ( ucIndex = 0; ucIndex < WLAN_MAX_TID ; ucIndex++)
11624 {
11625 if(0 == ptlSTAClient->atlBAReorderInfo[ucIndex].ucExists)
11626 {
11627 continue;
11628 }
11629 if(NULL != ptlSTAClient->atlBAReorderInfo[ucIndex].reorderBuffer)
11630 {
11631 ptlSTAClient->atlBAReorderInfo[ucIndex].reorderBuffer->isAvailable = VOS_TRUE;
11632 memset(&ptlSTAClient->atlBAReorderInfo[ucIndex].reorderBuffer->arrayBuffer[0], 0, WLANTL_MAX_WINSIZE * sizeof(v_PVOID_t));
11633 }
11634 vos_timer_destroy(&ptlSTAClient->atlBAReorderInfo[ucIndex].agingTimer);
11635 memset(&ptlSTAClient->atlBAReorderInfo[ucIndex], 0, sizeof(WLANTL_BAReorderType));
11636 }
11637
11638 /*-------------------------------------------------------------------------
11639 QOS information for the STA
11640 -------------------------------------------------------------------------*/
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +053011641 ptlSTAClient->ucCurrentAC = WLANTL_AC_HIGH_PRIO;
Jeff Johnson295189b2012-06-20 16:38:30 -070011642 ptlSTAClient->ucCurrentWeight = 0;
11643 ptlSTAClient->ucServicedAC = WLANTL_AC_BK;
11644
11645 vos_mem_zero( ptlSTAClient->aucACMask, sizeof(ptlSTAClient->aucACMask));
11646 vos_mem_zero( &ptlSTAClient->wUAPSDInfo, sizeof(ptlSTAClient->wUAPSDInfo));
11647
11648
11649 /*--------------------------------------------------------------------
11650 Stats info
11651 --------------------------------------------------------------------*/
11652 vos_mem_zero( ptlSTAClient->auRxCount,
11653 sizeof(ptlSTAClient->auRxCount[0])* WLAN_MAX_TID);
11654 vos_mem_zero( ptlSTAClient->auTxCount,
11655 sizeof(ptlSTAClient->auTxCount[0])* WLAN_MAX_TID);
11656 ptlSTAClient->rssiAvg = 0;
11657
11658 /*Tx not suspended and station fully registered*/
11659 vos_atomic_set_U8( &ptlSTAClient->ucTxSuspended, 0);
11660 vos_atomic_set_U8( &ptlSTAClient->ucNoMoreData, 1);
11661
11662 if ( 0 == ucEmpty )
11663 {
11664 ptlSTAClient->wSTADesc.ucUcastSig = WLAN_TL_INVALID_U_SIG;
11665 ptlSTAClient->wSTADesc.ucBcastSig = WLAN_TL_INVALID_B_SIG;
11666 }
11667
11668 ptlSTAClient->ucExists = 0;
11669
11670 /*--------------------------------------------------------------------
11671 Statistics info
11672 --------------------------------------------------------------------*/
11673 memset(&ptlSTAClient->trafficStatistics,
11674 0,
11675 sizeof(WLANTL_TRANSFER_STA_TYPE));
11676
11677 /*fix me!!: add new values from the TL Cb for cleanup */
11678 return VOS_STATUS_SUCCESS;
11679}/* WLANTL_CleanSTA */
11680
11681
11682/*==========================================================================
11683 FUNCTION WLANTL_EnableUAPSDForAC
11684
11685 DESCRIPTION
11686 Called by HDD to enable UAPSD. TL in turn calls WDA API to enable the
11687 logic in FW/SLM to start sending trigger frames. Previously TL had the
11688 trigger frame logic which later moved down to FW. Hence
11689 HDD -> TL -> WDA -> FW call flow.
11690
11691 DEPENDENCIES
11692 The TL must be initialized before this function can be called.
11693
11694 PARAMETERS
11695
11696 IN
11697 pvosGCtx: pointer to the global vos context; a handle to TL's
11698 control block can be extracted from its context
11699 ucSTAId: station Id
11700 ucAC: AC for which U-APSD is being enabled
11701 ucTid: TID for which U-APSD is setup
11702 ucUP: used to place in the trigger frame generation
11703 ucServiceInt: service interval used by TL to send trigger frames
11704 ucSuspendInt: suspend interval used by TL to determine that an
11705 app is idle and should start sending trigg frms less often
11706 wTSDir: direction of TSpec
11707
11708 RETURN VALUE
11709 The result code associated with performing the operation
11710
11711 VOS_STATUS_SUCCESS: Everything is good :)
11712
11713 SIDE EFFECTS
11714
11715============================================================================*/
11716VOS_STATUS
11717WLANTL_EnableUAPSDForAC
11718(
11719 v_PVOID_t pvosGCtx,
11720 v_U8_t ucSTAId,
11721 WLANTL_ACEnumType ucAC,
11722 v_U8_t ucTid,
11723 v_U8_t ucUP,
11724 v_U32_t uServiceInt,
11725 v_U32_t uSuspendInt,
11726 WLANTL_TSDirType wTSDir
11727)
11728{
11729
11730 WLANTL_CbType* pTLCb = NULL;
11731 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
11732 tUapsdInfo halUAPSDInfo;
11733 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
11734
11735 /*------------------------------------------------------------------------
11736 Sanity check
11737 Extract TL control block
11738 ------------------------------------------------------------------------*/
11739 pTLCb = VOS_GET_TL_CB(pvosGCtx);
11740 if (( NULL == pTLCb ) || WLANTL_STA_ID_INVALID( ucSTAId )
Gopichand Nakkala574f6d12013-06-27 19:38:43 +053011741 || WLANTL_AC_INVALID(ucAC))
Jeff Johnson295189b2012-06-20 16:38:30 -070011742 {
11743 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11744 "WLAN TL:Invalid input params on WLANTL_EnableUAPSDForAC"
Gopichand Nakkala574f6d12013-06-27 19:38:43 +053011745 " TL: %p STA: %d AC: %d",
11746 pTLCb, ucSTAId, ucAC));
Jeff Johnson295189b2012-06-20 16:38:30 -070011747 return VOS_STATUS_E_FAULT;
11748 }
11749
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053011750 if ( NULL == pTLCb->atlSTAClients[ucSTAId] )
11751 {
11752 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11753 "WLAN TL:Client Memory was not allocated on %s", __func__));
11754 return VOS_STATUS_E_FAILURE;
11755 }
11756
Jeff Johnson295189b2012-06-20 16:38:30 -070011757 /*Set this flag in order to remember that this is a trigger enabled AC*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053011758 pTLCb->atlSTAClients[ucSTAId]->wUAPSDInfo[ucAC].ucSet = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -070011759
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053011760#ifdef FEATURE_WLAN_TDLS
11761 if(pTLCb->atlSTAClients[ucSTAId]->wSTADesc.wSTAType != WLAN_STA_TDLS)
11762#endif
11763 {
11764 if( 0 == uServiceInt )
11765 {
11766 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi198ade32013-09-29 03:52:25 +053011767 "WLAN TL:Input params on WLANTL_EnableUAPSDForAC"
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053011768 " SI: %d", uServiceInt ));
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053011769 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011770
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053011771 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
11772 "WLAN TL:Enabling U-APSD in FW for STA: %d AC: %d SI: %d SPI: %d "
11773 "DI: %d",
11774 ucSTAId, ucAC, uServiceInt, uSuspendInt,
11775 pTLCb->tlConfigInfo.uDelayedTriggerFrmInt));
Jeff Johnson295189b2012-06-20 16:38:30 -070011776
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053011777 /*Save all info for HAL*/
11778 halUAPSDInfo.staidx = ucSTAId;
11779 halUAPSDInfo.ac = ucAC;
11780 halUAPSDInfo.up = ucUP;
11781 halUAPSDInfo.srvInterval = uServiceInt;
11782 halUAPSDInfo.susInterval = uSuspendInt;
11783 halUAPSDInfo.delayInterval = pTLCb->tlConfigInfo.uDelayedTriggerFrmInt;
11784
11785 /*Notify HAL*/
11786 vosStatus = WDA_EnableUapsdAcParams(pvosGCtx, ucSTAId, &halUAPSDInfo);
11787 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011788 return vosStatus;
11789
11790}/*WLANTL_EnableUAPSDForAC*/
11791
11792
11793/*==========================================================================
11794 FUNCTION WLANTL_DisableUAPSDForAC
11795
11796 DESCRIPTION
11797 Called by HDD to disable UAPSD. TL in turn calls WDA API to disable the
11798 logic in FW/SLM to stop sending trigger frames. Previously TL had the
11799 trigger frame logic which later moved down to FW. Hence
11800 HDD -> TL -> WDA -> FW call flow.
11801
11802 DEPENDENCIES
11803 The TL must be initialized before this function can be called.
11804
11805 PARAMETERS
11806
11807 IN
11808 pvosGCtx: pointer to the global vos context; a handle to TL's
11809 control block can be extracted from its context
11810 ucSTAId: station Id
11811 ucAC: AC for which U-APSD is being enabled
11812
11813
11814 RETURN VALUE
11815 The result code associated with performing the operation
11816
11817 VOS_STATUS_SUCCESS: Everything is good :)
11818
11819 SIDE EFFECTS
11820
11821============================================================================*/
11822VOS_STATUS
11823WLANTL_DisableUAPSDForAC
11824(
11825 v_PVOID_t pvosGCtx,
11826 v_U8_t ucSTAId,
11827 WLANTL_ACEnumType ucAC
11828)
11829{
11830 WLANTL_CbType* pTLCb;
11831 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
11832
11833 /*------------------------------------------------------------------------
11834 Sanity check
11835 Extract TL control block
11836 ------------------------------------------------------------------------*/
11837 pTLCb = VOS_GET_TL_CB(pvosGCtx);
11838 if (( NULL == pTLCb ) || WLANTL_STA_ID_INVALID( ucSTAId )
11839 || WLANTL_AC_INVALID(ucAC) )
11840 {
11841 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11842 "WLAN TL:Invalid input params on WLANTL_DisableUAPSDForAC"
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +053011843 " TL: %p STA: %d AC: %d", pTLCb, ucSTAId, ucAC ));
Jeff Johnson295189b2012-06-20 16:38:30 -070011844 return VOS_STATUS_E_FAULT;
11845 }
11846
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053011847 if ( NULL == pTLCb->atlSTAClients[ucSTAId] )
11848 {
11849 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11850 "WLAN TL:Client Memory was not allocated on %s", __func__));
11851 return VOS_STATUS_E_FAILURE;
11852 }
11853
Jeff Johnson295189b2012-06-20 16:38:30 -070011854 /*Reset this flag as this is no longer a trigger enabled AC*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053011855 pTLCb->atlSTAClients[ucSTAId]->wUAPSDInfo[ucAC].ucSet = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -070011856
11857 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
11858 "WLAN TL:Disabling U-APSD in FW for STA: %d AC: %d ",
11859 ucSTAId, ucAC));
11860
11861 /*Notify HAL*/
11862 WDA_DisableUapsdAcParams(pvosGCtx, ucSTAId, ucAC);
11863
11864 return VOS_STATUS_SUCCESS;
11865}/* WLANTL_DisableUAPSDForAC */
11866
11867#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
11868/*==========================================================================
11869 FUNCTION WLANTL_RegRSSIIndicationCB
11870
11871 DESCRIPTION Registration function to get notification if RSSI cross
11872 threshold.
11873 Client should register threshold, direction, and notification
11874 callback function pointer
11875
11876 DEPENDENCIES NONE
11877
11878 PARAMETERS in pAdapter - Global handle
11879 in rssiValue - RSSI threshold value
11880 in triggerEvent - Cross direction should be notified
11881 UP, DOWN, and CROSS
11882 in crossCBFunction - Notification CB Function
11883 in usrCtxt - user context
11884
11885 RETURN VALUE VOS_STATUS
11886
11887 SIDE EFFECTS NONE
11888
11889============================================================================*/
11890VOS_STATUS WLANTL_RegRSSIIndicationCB
11891(
11892 v_PVOID_t pAdapter,
11893 v_S7_t rssiValue,
11894 v_U8_t triggerEvent,
11895 WLANTL_RSSICrossThresholdCBType crossCBFunction,
11896 VOS_MODULE_ID moduleID,
11897 v_PVOID_t usrCtxt
11898)
11899{
11900 VOS_STATUS status = VOS_STATUS_SUCCESS;
11901
11902 status = WLANTL_HSRegRSSIIndicationCB(pAdapter,
11903 rssiValue,
11904 triggerEvent,
11905 crossCBFunction,
11906 moduleID,
11907 usrCtxt);
11908
11909 return status;
11910}
11911
11912/*==========================================================================
11913 FUNCTION WLANTL_DeregRSSIIndicationCB
11914
11915 DESCRIPTION Remove specific threshold from list
11916
11917 DEPENDENCIES NONE
11918
11919 PARAMETERS in pAdapter - Global handle
11920 in rssiValue - RSSI threshold value
11921 in triggerEvent - Cross direction should be notified
11922 UP, DOWN, and CROSS
11923
11924 RETURN VALUE VOS_STATUS
11925
11926 SIDE EFFECTS NONE
11927
11928============================================================================*/
11929VOS_STATUS WLANTL_DeregRSSIIndicationCB
11930(
11931 v_PVOID_t pAdapter,
11932 v_S7_t rssiValue,
11933 v_U8_t triggerEvent,
11934 WLANTL_RSSICrossThresholdCBType crossCBFunction,
11935 VOS_MODULE_ID moduleID
11936)
11937{
11938 VOS_STATUS status = VOS_STATUS_SUCCESS;
11939
11940 status = WLANTL_HSDeregRSSIIndicationCB(pAdapter,
11941 rssiValue,
11942 triggerEvent,
11943 crossCBFunction,
11944 moduleID);
11945 return status;
11946}
11947
11948/*==========================================================================
11949 FUNCTION WLANTL_SetAlpha
11950
11951 DESCRIPTION ALPLA is weight value to calculate AVG RSSI
11952 avgRSSI = (ALPHA * historyRSSI) + ((10 - ALPHA) * newRSSI)
11953 avgRSSI has (ALPHA * 10)% of history RSSI weight and
11954 (10 - ALPHA)% of newRSSI weight
11955 This portion is dynamically configurable.
11956 Default is ?
11957
11958 DEPENDENCIES NONE
11959
11960 PARAMETERS in pAdapter - Global handle
11961 in valueAlpah - ALPHA
11962
11963 RETURN VALUE VOS_STATUS
11964
11965 SIDE EFFECTS NONE
11966
11967============================================================================*/
11968VOS_STATUS WLANTL_SetAlpha
11969(
11970 v_PVOID_t pAdapter,
11971 v_U8_t valueAlpha
11972)
11973{
11974 VOS_STATUS status = VOS_STATUS_SUCCESS;
11975
11976 status = WLANTL_HSSetAlpha(pAdapter, valueAlpha);
11977 return status;
11978}
11979
11980/*==========================================================================
11981
11982 FUNCTION
11983
11984 DESCRIPTION
11985
11986 PARAMETERS
11987
11988 RETURN VALUE
11989
11990============================================================================*/
11991VOS_STATUS WLANTL_BMPSRSSIRegionChangedNotification
11992(
11993 v_PVOID_t pAdapter,
11994 tpSirRSSINotification pRSSINotification
11995)
11996{
11997 VOS_STATUS status = VOS_STATUS_SUCCESS;
11998
11999 status = WLANTL_HSBMPSRSSIRegionChangedNotification(pAdapter, pRSSINotification);
12000 return status;
12001}
12002
12003/*==========================================================================
12004 FUNCTION WLANTL_RegGetTrafficStatus
12005
12006 DESCRIPTION Registration function for traffic status monitoring
12007 During measure period count data frames.
12008 If frame count is larger then IDLE threshold set as traffic ON
12009 or OFF.
12010 And traffic status is changed send report to client with
12011 registered callback function
12012
12013 DEPENDENCIES NONE
12014
12015 PARAMETERS in pAdapter - Global handle
12016 in idleThreshold - Traffic on or off threshold
12017 in measurePeriod - Traffic state check period
12018 in trfficStatusCB - traffic status changed notification
12019 CB function
12020 in usrCtxt - user context
12021
12022 RETURN VALUE VOS_STATUS
12023
12024 SIDE EFFECTS NONE
12025
12026============================================================================*/
12027VOS_STATUS WLANTL_RegGetTrafficStatus
12028(
12029 v_PVOID_t pAdapter,
12030 v_U32_t idleThreshold,
12031 v_U32_t measurePeriod,
12032 WLANTL_TrafficStatusChangedCBType trfficStatusCB,
12033 v_PVOID_t usrCtxt
12034)
12035{
12036 VOS_STATUS status = VOS_STATUS_SUCCESS;
12037
12038 status = WLANTL_HSRegGetTrafficStatus(pAdapter,
12039 idleThreshold,
12040 measurePeriod,
12041 trfficStatusCB,
12042 usrCtxt);
12043 return status;
12044}
12045#endif
12046/*==========================================================================
12047 FUNCTION WLANTL_GetStatistics
12048
12049 DESCRIPTION Get traffic statistics for identified station
12050
12051 DEPENDENCIES NONE
12052
12053 PARAMETERS in pAdapter - Global handle
12054 in statType - specific statistics field to reset
12055 out statBuffer - traffic statistics buffer
12056
12057 RETURN VALUE VOS_STATUS
12058
12059 SIDE EFFECTS NONE
12060
12061============================================================================*/
12062VOS_STATUS WLANTL_GetStatistics
12063(
12064 v_PVOID_t pAdapter,
12065 WLANTL_TRANSFER_STA_TYPE *statBuffer,
12066 v_U8_t STAid
12067)
12068{
12069 WLANTL_CbType *pTLCb = VOS_GET_TL_CB(pAdapter);
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053012070 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070012071 VOS_STATUS status = VOS_STATUS_SUCCESS;
12072 WLANTL_TRANSFER_STA_TYPE *statistics = NULL;
12073
12074 /*------------------------------------------------------------------------
12075 Sanity check
12076 Extract TL control block
12077 ------------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053012078 if ( NULL == pTLCb )
Jeff Johnson295189b2012-06-20 16:38:30 -070012079 {
12080 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
12081 "WLAN TL:Invalid TL pointer on WLANTL_GetStatistics"));
12082 return VOS_STATUS_E_FAULT;
12083 }
12084
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053012085 pClientSTA = pTLCb->atlSTAClients[STAid];
12086
12087 if ( NULL == pClientSTA )
12088 {
12089 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
12090 "WLAN TL:Client Memory was not allocated on %s", __func__));
12091 return VOS_STATUS_E_FAILURE;
12092 }
12093
12094 if(0 == pClientSTA->ucExists)
Jeff Johnson295189b2012-06-20 16:38:30 -070012095 {
12096 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
12097 "WLAN TL: %d STA ID does not exist", STAid));
12098 return VOS_STATUS_E_INVAL;
12099 }
12100
12101 if(NULL == statBuffer)
12102 {
12103 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
12104 "WLAN TL:Invalid TL statistics buffer pointer on WLANTL_GetStatistics"));
12105 return VOS_STATUS_E_INVAL;
12106 }
12107
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053012108 statistics = &pClientSTA->trafficStatistics;
Katya Nigam493ff652014-02-11 14:31:04 +053012109 vos_mem_copy(statBuffer, statistics, sizeof(WLANTL_TRANSFER_STA_TYPE));
Jeff Johnson295189b2012-06-20 16:38:30 -070012110
12111 return status;
12112}
12113
12114/*==========================================================================
12115 FUNCTION WLANTL_ResetStatistics
12116
12117 DESCRIPTION Reset statistics structure for identified station ID
12118 Reset means set values as 0
12119
12120 DEPENDENCIES NONE
12121
12122 PARAMETERS in pAdapter - Global handle
12123 in statType - specific statistics field to reset
12124
12125 RETURN VALUE VOS_STATUS
12126
12127 SIDE EFFECTS NONE
12128
12129============================================================================*/
12130VOS_STATUS WLANTL_ResetStatistics
12131(
12132 v_PVOID_t pAdapter,
12133 v_U8_t STAid
12134)
12135{
12136 WLANTL_CbType *pTLCb = VOS_GET_TL_CB(pAdapter);
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053012137 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070012138 VOS_STATUS status = VOS_STATUS_SUCCESS;
12139 WLANTL_TRANSFER_STA_TYPE *statistics = NULL;
12140
12141 /*------------------------------------------------------------------------
12142 Sanity check
12143 Extract TL control block
12144 ------------------------------------------------------------------------*/
12145 if (NULL == pTLCb)
12146 {
12147 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
12148 "WLAN TL:Invalid TL pointer on WLANTL_GetStatistics"));
12149 return VOS_STATUS_E_FAULT;
12150 }
12151
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053012152 pClientSTA = pTLCb->atlSTAClients[STAid];
12153
12154 if ( NULL == pClientSTA )
12155 {
12156 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
12157 "WLAN TL:Client Memory was not allocated on %s", __func__));
12158 return VOS_STATUS_E_FAILURE;
12159 }
12160
12161 if(0 == pClientSTA->ucExists)
Jeff Johnson295189b2012-06-20 16:38:30 -070012162 {
12163 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
12164 "WLAN TL: %d STA ID does not exist", STAid));
12165 return VOS_STATUS_E_INVAL;
12166 }
12167
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053012168 statistics = &pClientSTA->trafficStatistics;
Jeff Johnson295189b2012-06-20 16:38:30 -070012169 vos_mem_zero((v_VOID_t *)statistics, sizeof(WLANTL_TRANSFER_STA_TYPE));
12170
12171 return status;
12172}
12173
12174/*==========================================================================
12175 FUNCTION WLANTL_GetSpecStatistic
12176
12177 DESCRIPTION Get specific field within statistics structure for
12178 identified station ID
12179
12180 DEPENDENCIES NONE
12181
12182 PARAMETERS in pAdapter - Global handle
12183 in statType - specific statistics field to reset
12184 in STAid - Station ID
12185 out buffer - Statistic value
12186
12187 RETURN VALUE VOS_STATUS
12188
12189 SIDE EFFECTS NONE
12190
12191============================================================================*/
12192VOS_STATUS WLANTL_GetSpecStatistic
12193(
12194 v_PVOID_t pAdapter,
12195 WLANTL_TRANSFER_STATIC_TYPE statType,
12196 v_U32_t *buffer,
12197 v_U8_t STAid
12198)
12199{
12200 WLANTL_CbType *pTLCb = VOS_GET_TL_CB(pAdapter);
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053012201 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070012202 VOS_STATUS status = VOS_STATUS_SUCCESS;
12203 WLANTL_TRANSFER_STA_TYPE *statistics = NULL;
12204
12205 /*------------------------------------------------------------------------
12206 Sanity check
12207 Extract TL control block
12208 ------------------------------------------------------------------------*/
12209 if (NULL == pTLCb)
12210 {
12211 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
12212 "WLAN TL:Invalid TL pointer on WLANTL_GetStatistics"));
12213 return VOS_STATUS_E_FAULT;
12214 }
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053012215 pClientSTA = pTLCb->atlSTAClients[STAid];
Jeff Johnson295189b2012-06-20 16:38:30 -070012216
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053012217 if ( NULL == pClientSTA )
12218 {
12219 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
12220 "WLAN TL:Client Memory was not allocated on %s", __func__));
12221 return VOS_STATUS_E_FAILURE;
12222 }
12223
12224 if(0 == pClientSTA->ucExists)
Jeff Johnson295189b2012-06-20 16:38:30 -070012225 {
12226 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
12227 "WLAN TL: %d STA ID does not exist", STAid));
12228 return VOS_STATUS_E_INVAL;
12229 }
12230
12231 if(NULL == buffer)
12232 {
12233 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
12234 "WLAN TL:Invalid TL statistic buffer pointer on WLANTL_GetStatistics"));
12235 return VOS_STATUS_E_INVAL;
12236 }
12237
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053012238 statistics = &pClientSTA->trafficStatistics;
Jeff Johnson295189b2012-06-20 16:38:30 -070012239 switch(statType)
12240 {
12241 case WLANTL_STATIC_TX_UC_FCNT:
12242 *buffer = statistics->txUCFcnt;
12243 break;
12244
12245 case WLANTL_STATIC_TX_MC_FCNT:
12246 *buffer = statistics->txMCFcnt;
12247 break;
12248
12249 case WLANTL_STATIC_TX_BC_FCNT:
12250 *buffer = statistics->txBCFcnt;
12251 break;
12252
12253 case WLANTL_STATIC_TX_UC_BCNT:
12254 *buffer = statistics->txUCBcnt;
12255 break;
12256
12257 case WLANTL_STATIC_TX_MC_BCNT:
12258 *buffer = statistics->txMCBcnt;
12259 break;
12260
12261 case WLANTL_STATIC_TX_BC_BCNT:
12262 *buffer = statistics->txBCBcnt;
12263 break;
12264
12265 case WLANTL_STATIC_RX_UC_FCNT:
12266 *buffer = statistics->rxUCFcnt;
12267 break;
12268
12269 case WLANTL_STATIC_RX_MC_FCNT:
12270 *buffer = statistics->rxMCFcnt;
12271 break;
12272
12273 case WLANTL_STATIC_RX_BC_FCNT:
12274 *buffer = statistics->rxBCFcnt;
12275 break;
12276
12277 case WLANTL_STATIC_RX_UC_BCNT:
12278 *buffer = statistics->rxUCBcnt;
12279 break;
12280
12281 case WLANTL_STATIC_RX_MC_BCNT:
12282 *buffer = statistics->rxMCBcnt;
12283 break;
12284
12285 case WLANTL_STATIC_RX_BC_BCNT:
12286 *buffer = statistics->rxBCBcnt;
12287 break;
12288
12289 case WLANTL_STATIC_RX_BCNT:
12290 *buffer = statistics->rxBcnt;
12291 break;
12292
12293 case WLANTL_STATIC_RX_BCNT_CRC_OK:
12294 *buffer = statistics->rxBcntCRCok;
12295 break;
12296
12297 case WLANTL_STATIC_RX_RATE:
12298 *buffer = statistics->rxRate;
12299 break;
12300
12301 default:
12302 *buffer = 0;
12303 status = VOS_STATUS_E_INVAL;
12304 break;
12305 }
12306
12307
12308 return status;
12309}
12310
12311/*==========================================================================
12312 FUNCTION WLANTL_ResetSpecStatistic
12313
12314 DESCRIPTION Reset specific field within statistics structure for
12315 identified station ID
12316 Reset means set as 0
12317
12318 DEPENDENCIES NONE
12319
12320 PARAMETERS in pAdapter - Global handle
12321 in statType - specific statistics field to reset
12322 in STAid - Station ID
12323
12324 RETURN VALUE VOS_STATUS
12325
12326 SIDE EFFECTS NONE
12327
12328============================================================================*/
12329VOS_STATUS WLANTL_ResetSpecStatistic
12330(
12331 v_PVOID_t pAdapter,
12332 WLANTL_TRANSFER_STATIC_TYPE statType,
12333 v_U8_t STAid
12334)
12335{
12336 WLANTL_CbType *pTLCb = VOS_GET_TL_CB(pAdapter);
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053012337 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070012338 VOS_STATUS status = VOS_STATUS_SUCCESS;
12339 WLANTL_TRANSFER_STA_TYPE *statistics = NULL;
12340
12341 /*------------------------------------------------------------------------
12342 Sanity check
12343 Extract TL control block
12344 ------------------------------------------------------------------------*/
12345 if (NULL == pTLCb)
12346 {
12347 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
12348 "WLAN TL:Invalid TL pointer on WLANTL_GetStatistics"));
12349 return VOS_STATUS_E_FAULT;
12350 }
12351
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053012352 pClientSTA = pTLCb->atlSTAClients[STAid];
12353
12354 if ( NULL == pClientSTA )
12355 {
12356 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
12357 "WLAN TL:Client Memory was not allocated on %s", __func__));
12358 return VOS_STATUS_E_FAILURE;
12359 }
12360
12361 if(0 == pClientSTA->ucExists)
Jeff Johnson295189b2012-06-20 16:38:30 -070012362 {
12363 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
12364 "WLAN TL: %d STA ID does not exist", STAid));
12365 return VOS_STATUS_E_INVAL;
12366 }
12367
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053012368 statistics = &pClientSTA->trafficStatistics;
Jeff Johnson295189b2012-06-20 16:38:30 -070012369 switch(statType)
12370 {
12371 case WLANTL_STATIC_TX_UC_FCNT:
12372 statistics->txUCFcnt = 0;
12373 break;
12374
12375 case WLANTL_STATIC_TX_MC_FCNT:
12376 statistics->txMCFcnt = 0;
12377 break;
12378
12379 case WLANTL_STATIC_TX_BC_FCNT:
12380 statistics->txBCFcnt = 0;
12381 break;
12382
12383 case WLANTL_STATIC_TX_UC_BCNT:
12384 statistics->txUCBcnt = 0;
12385 break;
12386
12387 case WLANTL_STATIC_TX_MC_BCNT:
12388 statistics->txMCBcnt = 0;
12389 break;
12390
12391 case WLANTL_STATIC_TX_BC_BCNT:
12392 statistics->txBCBcnt = 0;
12393 break;
12394
12395 case WLANTL_STATIC_RX_UC_FCNT:
12396 statistics->rxUCFcnt = 0;
12397 break;
12398
12399 case WLANTL_STATIC_RX_MC_FCNT:
12400 statistics->rxMCFcnt = 0;
12401 break;
12402
12403 case WLANTL_STATIC_RX_BC_FCNT:
12404 statistics->rxBCFcnt = 0;
12405 break;
12406
12407 case WLANTL_STATIC_RX_UC_BCNT:
12408 statistics->rxUCBcnt = 0;
12409 break;
12410
12411 case WLANTL_STATIC_RX_MC_BCNT:
12412 statistics->rxMCBcnt = 0;
12413 break;
12414
12415 case WLANTL_STATIC_RX_BC_BCNT:
12416 statistics->rxBCBcnt = 0;
12417 break;
12418
12419 case WLANTL_STATIC_RX_BCNT:
12420 statistics->rxBcnt = 0;
12421 break;
12422
12423 case WLANTL_STATIC_RX_BCNT_CRC_OK:
12424 statistics->rxBcntCRCok = 0;
12425 break;
12426
12427 case WLANTL_STATIC_RX_RATE:
12428 statistics->rxRate = 0;
12429 break;
12430
12431 default:
12432 status = VOS_STATUS_E_INVAL;
12433 break;
12434 }
12435
12436 return status;
12437}
12438
12439
12440/*==========================================================================
12441
12442 FUNCTION
12443
12444 DESCRIPTION Read RSSI value out of a RX BD
12445
12446 PARAMETERS: Caller must validate all parameters
12447
12448 RETURN VALUE
12449
12450============================================================================*/
12451VOS_STATUS WLANTL_ReadRSSI
12452(
12453 v_PVOID_t pAdapter,
12454 v_PVOID_t pBDHeader,
12455 v_U8_t STAid
12456)
12457{
12458 WLANTL_CbType *tlCtxt = VOS_GET_TL_CB(pAdapter);
12459 v_S7_t currentRSSI, currentRSSI0, currentRSSI1;
12460
12461
12462 if(NULL == tlCtxt)
12463 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070012464 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR, "%s Invalid TL handle", __func__));
Jeff Johnson295189b2012-06-20 16:38:30 -070012465 return VOS_STATUS_E_INVAL;
12466 }
12467
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053012468 if ( NULL == tlCtxt->atlSTAClients[STAid] )
12469 {
12470 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
12471 "WLAN TL:Client Memory was not allocated on %s", __func__));
12472 return VOS_STATUS_E_FAILURE;
12473 }
12474
Jeff Johnson295189b2012-06-20 16:38:30 -070012475 currentRSSI0 = WLANTL_GETRSSI0(pBDHeader);
12476 currentRSSI1 = WLANTL_GETRSSI1(pBDHeader);
12477 currentRSSI = (currentRSSI0 > currentRSSI1) ? currentRSSI0 : currentRSSI1;
12478
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053012479 tlCtxt->atlSTAClients[STAid]->rssiAvg = currentRSSI;
Jeff Johnson295189b2012-06-20 16:38:30 -070012480
12481 return VOS_STATUS_SUCCESS;
12482}
12483
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053012484/*==========================================================================
12485
12486 FUNCTION
12487
12488 DESCRIPTION Read SNR value out of a RX BD
12489
12490 PARAMETERS: Caller must validate all parameters
12491
12492 RETURN VALUE
12493
12494============================================================================*/
12495VOS_STATUS WLANTL_ReadSNR
12496(
12497 v_PVOID_t pAdapter,
12498 v_PVOID_t pBDHeader,
12499 v_U8_t STAid
12500)
12501{
12502 WLANTL_CbType *tlCtxt = VOS_GET_TL_CB(pAdapter);
12503 v_S7_t currentSNR;
12504
12505
12506 if (NULL == tlCtxt)
12507 {
12508 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
12509 "%s Invalid TL handle", __func__));
12510 return VOS_STATUS_E_INVAL;
12511 }
12512
12513 if (NULL == tlCtxt->atlSTAClients[STAid])
12514 {
12515 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
12516 "WLAN TL:Client Memory was not allocated on %s", __func__));
12517 return VOS_STATUS_E_FAILURE;
12518 }
12519
12520 currentSNR = WLANTL_GETSNR(pBDHeader);
12521
Madan Mohan Koyyalamudi43acf032013-09-27 04:33:28 +053012522 /* SNR reported in the Buffer Descriptor is scaled up by 2(SNR*2),
12523 * Get the correct SNR value
12524 */
12525 currentSNR = currentSNR >> 1;
12526
12527 /* SNR reported by HW cannot be more than 35dB due to HW limitations */
12528 currentSNR = (WLANTL_MAX_HW_SNR > currentSNR ? currentSNR :
12529 WLANTL_MAX_HW_SNR);
12530
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053012531 TLLOG2(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
12532 "%s: snrsum: %d snridx: %d prevsnravg: %d",
12533 __func__,
12534 tlCtxt->atlSTAClients[STAid]->snrSum,
12535 tlCtxt->atlSTAClients[STAid]->snrIdx,
12536 tlCtxt->atlSTAClients[STAid]->prevSnrAvg));
12537
12538 /* The SNR returned for all purposes is the average SNR over
12539 * WLANTL_MAX_SNR_DATA_SMAPLES.When data samples
12540 * > WLANTL_MAX_SNR_DATA_SAMPLES are obtained,
12541 * store the average of the samples in prevSnrAvg
12542 * and start a new averaging window. The prevSnrAvg is used when
12543 * enough data samples are not available when applications
12544 * actually query for SNR.
12545 *
12546 * SEE: WLANTL_GetSnr()
12547 */
12548 if (tlCtxt->atlSTAClients[STAid]->snrIdx >= WLANTL_MAX_SNR_DATA_SAMPLES)
12549 {
12550 tlCtxt->atlSTAClients[STAid]->prevSnrAvg =
12551 tlCtxt->atlSTAClients[STAid]->snrSum /
12552 tlCtxt->atlSTAClients[STAid]->snrIdx;
12553 tlCtxt->atlSTAClients[STAid]->snrSum = 0;
12554 tlCtxt->atlSTAClients[STAid]->snrIdx = 0;
12555 }
12556 tlCtxt->atlSTAClients[STAid]->snrSum += currentSNR;
12557 tlCtxt->atlSTAClients[STAid]->snrIdx += 1;
12558
12559 return VOS_STATUS_SUCCESS;
12560}
Jeff Johnson295189b2012-06-20 16:38:30 -070012561
12562/*
12563 DESCRIPTION
12564 TL returns the weight currently maintained in TL.
12565 IN
12566 pvosGCtx: pointer to the global vos context; a handle to TL's
12567 or SME's control block can be extracted from its context
12568
12569 OUT
12570 pACWeights: Caller allocated memory for filling in weights
12571
12572 RETURN VALUE VOS_STATUS
12573*/
12574VOS_STATUS
12575WLANTL_GetACWeights
12576(
12577 v_PVOID_t pvosGCtx,
12578 v_U8_t* pACWeights
12579)
12580{
12581 WLANTL_CbType* pTLCb = NULL;
12582 v_U8_t ucIndex;
12583 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
12584
12585 /*------------------------------------------------------------------------
12586 Sanity check
12587 ------------------------------------------------------------------------*/
12588 if ( NULL == pACWeights )
12589 {
12590 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
12591 "WLAN TL:Invalid parameter sent on WLANTL_GetACWeights"));
12592 return VOS_STATUS_E_INVAL;
12593 }
12594
12595 /*------------------------------------------------------------------------
12596 Extract TL control block and check existance
12597 ------------------------------------------------------------------------*/
12598 pTLCb = VOS_GET_TL_CB(pvosGCtx);
12599 if ( NULL == pTLCb )
12600 {
12601 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
12602 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_GetACWeights"));
12603 return VOS_STATUS_E_FAULT;
12604 }
12605 for ( ucIndex = 0; ucIndex < WLANTL_MAX_AC ; ucIndex++)
12606 {
12607 pACWeights[ucIndex] = pTLCb->tlConfigInfo.ucAcWeights[ucIndex];
12608 }
12609
12610 return VOS_STATUS_SUCCESS;
12611}
12612
12613
12614
12615/*
12616 DESCRIPTION
12617 Change the weight currently maintained by TL.
12618 IN
12619 pvosGCtx: pointer to the global vos context; a handle to TL's
12620 or SME's control block can be extracted from its context
12621 pACWeights: Caller allocated memory contain the weights to use
12622
12623
12624 RETURN VALUE VOS_STATUS
12625*/
12626VOS_STATUS
12627WLANTL_SetACWeights
12628(
12629 v_PVOID_t pvosGCtx,
12630 v_U8_t* pACWeights
12631)
12632{
12633 WLANTL_CbType* pTLCb = NULL;
12634 v_U8_t ucIndex;
12635 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
12636
12637 /*------------------------------------------------------------------------
12638 Sanity check
12639 ------------------------------------------------------------------------*/
12640 if ( NULL == pACWeights )
12641 {
12642 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
12643 "WLAN TL:Invalid parameter sent on WLANTL_GetACWeights"));
12644 return VOS_STATUS_E_INVAL;
12645 }
12646
12647 /*------------------------------------------------------------------------
12648 Extract TL control block and check existance
12649 ------------------------------------------------------------------------*/
12650 pTLCb = VOS_GET_TL_CB(pvosGCtx);
12651 if ( NULL == pTLCb )
12652 {
12653 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
12654 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_GetACWeights"));
12655 return VOS_STATUS_E_FAULT;
12656 }
12657 for ( ucIndex = 0; ucIndex < WLANTL_MAX_AC ; ucIndex++)
12658 {
12659 pTLCb->tlConfigInfo.ucAcWeights[ucIndex] = pACWeights[ucIndex];
12660 }
12661
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +053012662 pTLCb->tlConfigInfo.ucAcWeights[WLANTL_AC_HIGH_PRIO] = pACWeights[WLANTL_AC_VO];
Jeff Johnson295189b2012-06-20 16:38:30 -070012663 return VOS_STATUS_SUCCESS;
12664}
12665
12666
12667/*==========================================================================
12668
12669 FUNCTION
12670
12671 DESCRIPTION
12672
12673 PARAMETERS
12674
12675 RETURN VALUE
12676
12677============================================================================*/
12678void WLANTL_PowerStateChangedCB
12679(
12680 v_PVOID_t pAdapter,
12681 tPmcState newState
12682)
12683{
12684 WLANTL_CbType *tlCtxt = VOS_GET_TL_CB(pAdapter);
12685
12686 if (NULL == tlCtxt)
12687 {
12688 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +053012689 "%s: Invalid TL Control Block", __func__ );
Jeff Johnson295189b2012-06-20 16:38:30 -070012690 return;
12691 }
12692
12693 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO, "Power state changed, new state is %d", newState );
12694 switch(newState)
12695 {
12696 case FULL_POWER:
12697 tlCtxt->isBMPS = VOS_FALSE;
12698 break;
12699
12700 case BMPS:
12701#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
12702 WLANTL_SetFWRSSIThresholds(pAdapter);
12703#endif
12704
12705 tlCtxt->isBMPS = VOS_TRUE;
12706 break;
12707
12708 case IMPS:
12709 case LOW_POWER:
12710 case REQUEST_BMPS:
12711 case REQUEST_FULL_POWER:
12712 case REQUEST_IMPS:
12713 case STOPPED:
12714 case REQUEST_START_UAPSD:
12715 case REQUEST_STOP_UAPSD:
12716 case UAPSD:
12717 case REQUEST_STANDBY:
12718 case STANDBY:
12719 case REQUEST_ENTER_WOWL:
12720 case REQUEST_EXIT_WOWL:
12721 case WOWL:
12722 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN, "Not handle this events %d", newState ));
12723 break;
12724
12725 default:
12726 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR, "Not a valid event %d", newState ));
12727 break;
12728 }
12729
12730 return;
12731}
12732/*==========================================================================
12733 FUNCTION WLANTL_GetEtherType
12734
12735 DESCRIPTION Extract Ether type information from the BD
12736
12737 DEPENDENCIES NONE
12738
12739 PARAMETERS in aucBDHeader - BD header
12740 in vosDataBuff - data buffer
12741 in ucMPDUHLen - MPDU header length
12742 out pUsEtherType - pointer to Ethertype
12743
12744 RETURN VALUE VOS_STATUS_SUCCESS : if the EtherType is successfully extracted
12745 VOS_STATUS_FAILURE : if the EtherType extraction failed and
12746 the packet was dropped
12747
12748 SIDE EFFECTS NONE
12749
12750============================================================================*/
12751static VOS_STATUS WLANTL_GetEtherType
12752(
12753 v_U8_t * aucBDHeader,
12754 vos_pkt_t * vosDataBuff,
12755 v_U8_t ucMPDUHLen,
12756 v_U16_t * pUsEtherType
12757)
12758{
12759 v_U8_t ucOffset;
12760 v_U16_t usEtherType = *pUsEtherType;
12761 v_SIZE_t usLLCSize = sizeof(usEtherType);
12762 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
12763
12764 /*------------------------------------------------------------------------
12765 Check if LLC is present - if not, TL is unable to determine type
12766 ------------------------------------------------------------------------*/
12767 if ( VOS_FALSE == WDA_IS_RX_LLC_PRESENT( aucBDHeader ) )
12768 {
12769 ucOffset = WLANTL_802_3_HEADER_LEN - sizeof(usEtherType);
12770 }
12771 else
12772 {
12773 ucOffset = ucMPDUHLen + WLANTL_LLC_PROTO_TYPE_OFFSET;
12774 }
12775
12776 /*------------------------------------------------------------------------
12777 Extract LLC type
12778 ------------------------------------------------------------------------*/
12779 vosStatus = vos_pkt_extract_data( vosDataBuff, ucOffset,
12780 (v_PVOID_t)&usEtherType, &usLLCSize);
12781
12782 if (( VOS_STATUS_SUCCESS != vosStatus ) ||
12783 ( sizeof(usEtherType) != usLLCSize ))
12784
12785 {
12786 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
12787 "WLAN TL:Error extracting Ether type from data packet"));
12788 /* Drop packet */
12789 vos_pkt_return_packet(vosDataBuff);
12790 vosStatus = VOS_STATUS_E_FAILURE;
12791 }
12792 else
12793 {
12794 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
12795 "WLAN TL:Ether type retrieved before endianess conv: %d",
12796 usEtherType));
12797
12798 usEtherType = vos_be16_to_cpu(usEtherType);
12799 *pUsEtherType = usEtherType;
12800
12801 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
12802 "WLAN TL:Ether type retrieved: %d", usEtherType));
12803 }
12804
12805 return vosStatus;
12806}
12807
Jeff Johnson295189b2012-06-20 16:38:30 -070012808/*==========================================================================
12809 FUNCTION WLANTL_GetSoftAPStatistics
12810
12811 DESCRIPTION Collect the cumulative statistics for all Softap stations
12812
12813 DEPENDENCIES NONE
12814
12815 PARAMETERS in pvosGCtx - Pointer to the global vos context
12816 bReset - If set TL statistics will be cleared after reading
12817 out statsSum - pointer to collected statistics
12818
12819 RETURN VALUE VOS_STATUS_SUCCESS : if the Statistics are successfully extracted
12820
12821 SIDE EFFECTS NONE
12822
12823============================================================================*/
12824VOS_STATUS WLANTL_GetSoftAPStatistics(v_PVOID_t pAdapter, WLANTL_TRANSFER_STA_TYPE *statsSum, v_BOOL_t bReset)
12825{
12826 v_U8_t i = 0;
12827 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
12828 WLANTL_CbType *pTLCb = VOS_GET_TL_CB(pAdapter);
12829 WLANTL_TRANSFER_STA_TYPE statBufferTemp;
12830 vos_mem_zero((v_VOID_t *)&statBufferTemp, sizeof(WLANTL_TRANSFER_STA_TYPE));
12831 vos_mem_zero((v_VOID_t *)statsSum, sizeof(WLANTL_TRANSFER_STA_TYPE));
12832
12833
12834 if ( NULL == pTLCb )
12835 {
12836 return VOS_STATUS_E_FAULT;
12837 }
12838
12839 // Sum up all the statistics for stations of Soft AP from TL
12840 for (i = 0; i < WLAN_MAX_STA_COUNT; i++)
12841 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053012842 if ( NULL == pTLCb->atlSTAClients[i])
12843 {
12844 continue;
12845 }
12846 if (pTLCb->atlSTAClients[i]->wSTADesc.wSTAType == WLAN_STA_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -070012847 {
12848 vosStatus = WLANTL_GetStatistics(pAdapter, &statBufferTemp, i);// Can include staId 1 because statistics not collected for it
12849
12850 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
12851 return VOS_STATUS_E_FAULT;
12852
12853 // Add to the counters
12854 statsSum->txUCFcnt += statBufferTemp.txUCFcnt;
12855 statsSum->txMCFcnt += statBufferTemp.txMCFcnt;
12856 statsSum->txBCFcnt += statBufferTemp.txBCFcnt;
12857 statsSum->txUCBcnt += statBufferTemp.txUCBcnt;
12858 statsSum->txMCBcnt += statBufferTemp.txMCBcnt;
12859 statsSum->txBCBcnt += statBufferTemp.txBCBcnt;
12860 statsSum->rxUCFcnt += statBufferTemp.rxUCFcnt;
12861 statsSum->rxMCFcnt += statBufferTemp.rxMCFcnt;
12862 statsSum->rxBCFcnt += statBufferTemp.rxBCFcnt;
12863 statsSum->rxUCBcnt += statBufferTemp.rxUCBcnt;
12864 statsSum->rxMCBcnt += statBufferTemp.rxMCBcnt;
12865 statsSum->rxBCBcnt += statBufferTemp.rxBCBcnt;
12866
12867 if (bReset)
12868 {
12869 vosStatus = WLANTL_ResetStatistics(pAdapter, i);
12870 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
12871 return VOS_STATUS_E_FAULT;
12872 }
12873 }
12874 }
12875
12876 return vosStatus;
12877}
Mohit Khanna698ba2a2012-12-04 15:08:18 -080012878#ifdef FEATURE_WLAN_TDLS_INTERNAL
12879/*==========================================================================
12880 FUNCTION WLANTL_GetEtherType_2
12881
12882 DESCRIPTION Extract Ether type information from the BD
12883
12884 DEPENDENCIES NONE
12885
12886 PARAMETERS in aucBDHeader - BD header
12887 in vosDataBuff - data buffer
12888 in ucMPDUHLen - MPDU header length
12889 out pUsEtherType - pointer to Ethertype
12890
12891 RETURN VALUE VOS_STATUS_SUCCESS : if the EtherType is successfully extracted
12892 VOS_STATUS_FAILURE : if the EtherType extraction failed and
12893 the packet was dropped
12894
12895 SIDE EFFECTS NONE
12896
12897============================================================================*/
12898static VOS_STATUS WLANTL_GetEtherType_2
12899(
12900 v_U8_t * aucBDHeader,
12901 vos_pkt_t * vosDataBuff,
12902 v_U8_t ucMPDUHLen,
12903 v_U16_t * pUsEtherType
12904)
12905{
12906 v_U8_t ucOffset;
12907 v_U16_t usEtherType = *pUsEtherType;
12908 v_SIZE_t usLLCSize = sizeof(usEtherType);
12909 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
12910 //v_U8_t ucLLCHeader;
12911 v_U8_t ucMPDUHOffset ;
12912 /*------------------------------------------------------------------------
12913 Check if LLC is present - if not, TL is unable to determine type
12914 ------------------------------------------------------------------------*/
12915 //ucMPDUHOffset = (v_U8_t)WLANHAL_RX_BD_GET_MPDU_H_OFFSET(aucBDHeader) ;
12916 //ucLLCHeader = (v_U8_t)WLANHAL_RX_BD_GET_LLC(aucBDHeader);
12917 ucMPDUHOffset = (v_U8_t)WDA_GET_RX_MPDU_HEADER_OFFSET(aucBDHeader);
12918
12919 if ( VOS_TRUE == WDA_IS_RX_LLC_PRESENT(aucBDHeader) )
12920 {
12921 ucOffset = ucMPDUHOffset + WLANTL_802_3_HEADER_LEN - sizeof(usEtherType);
12922 }
12923 else
12924 {
12925 ucOffset = WLANHAL_RX_BD_HEADER_SIZE + ucMPDUHLen
12926 + WLANTL_LLC_PROTO_TYPE_OFFSET;
12927 }
12928
12929 /*------------------------------------------------------------------------
12930 Extract LLC type
12931 ------------------------------------------------------------------------*/
12932 vosStatus = vos_pkt_extract_data( vosDataBuff, ucOffset,
12933 (v_PVOID_t)&usEtherType, &usLLCSize);
12934
12935 /* TODO: Do it in better way */
12936 if(vos_be16_to_cpu(usEtherType) == 0x890d)
12937 {
12938 VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Arif Hussainf2b00992013-11-17 21:46:15 -080012939 ("TDLS frame llc %x"), vos_be16_to_cpu(usEtherType)) ;
Mohit Khanna698ba2a2012-12-04 15:08:18 -080012940 }
12941
12942 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
12943 "WLAN TL:Ether type retrieved before endianess conv: %d",
12944 usEtherType);
12945
12946 usEtherType = vos_be16_to_cpu(usEtherType);
12947 *pUsEtherType = usEtherType;
12948
12949 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
12950 "WLAN TL:Ether type retrieved: %d", usEtherType);
12951
12952 return vosStatus;
12953}
12954#endif /* FEATURE_WLAN_TDLS */
12955
Jeff Johnson295189b2012-06-20 16:38:30 -070012956/*===============================================================================
12957 FUNCTION WLANTL_IsReplayPacket
12958
12959 DESCRIPTION This function does replay check for valid stations
12960
12961 DEPENDENCIES Validity of replay check must be done before the function
12962 is called
12963
12964 PARAMETERS currentReplayCounter current replay counter taken from RX BD
12965 previousReplayCounter previous replay counter taken from TL CB
12966
12967 RETRUN VOS_TRUE packet is a replay packet
12968 VOS_FALSE packet is not a replay packet
12969
12970 SIDE EFFECTS none
12971 ===============================================================================*/
12972v_BOOL_t
12973WLANTL_IsReplayPacket
12974(
12975 v_U64_t ullcurrentReplayCounter,
12976 v_U64_t ullpreviousReplayCounter
12977)
12978{
12979 /* Do the replay check by comparing previous received replay counter with
12980 current received replay counter*/
12981 if(ullpreviousReplayCounter < ullcurrentReplayCounter)
12982 {
12983 /* Valid packet not replay */
12984 return VOS_FALSE;
12985 }
12986 else
12987 {
12988
12989 /* Current packet number is less than or equal to previuos received
12990 packet no, this means current packet is replay packet */
12991 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
12992 "WLAN TL: Replay packet found with replay counter :[0x%llX]",ullcurrentReplayCounter);
12993
12994 return VOS_TRUE;
12995 }
12996}
12997
12998#if 0
12999/*===============================================================================
13000 FUNCTION WLANTL_GetReplayCounterFromRxBD
13001
13002 DESCRIPTION This function extracts 48-bit replay packet number from RX BD
13003
13004 DEPENDENCIES Validity of replay check must be done before the function
13005 is called
13006
13007 PARAMETERS pucRxHeader pointer to RX BD header
13008
13009 RETRUN v_U64_t Packet number extarcted from RX BD
13010
13011 SIDE EFFECTS none
13012 ===============================================================================*/
13013v_U64_t
13014WLANTL_GetReplayCounterFromRxBD
13015(
13016 v_U8_t *pucRxBDHeader
13017)
13018{
13019/* 48-bit replay counter is created as follows
13020 from RX BD 6 byte PMI command:
13021 Addr : AES/TKIP
13022 0x38 : pn3/tsc3
13023 0x39 : pn2/tsc2
13024 0x3a : pn1/tsc1
13025 0x3b : pn0/tsc0
13026
13027 0x3c : pn5/tsc5
13028 0x3d : pn4/tsc4 */
13029
13030#ifdef ANI_BIG_BYTE_ENDIAN
13031 v_U64_t ullcurrentReplayCounter = 0;
13032 /* Getting 48-bit replay counter from the RX BD */
13033 ullcurrentReplayCounter = WLANHAL_RX_BD_GET_PMICMD_20TO23(pucRxBDHeader);
13034 ullcurrentReplayCounter <<= 16;
13035 ullcurrentReplayCounter |= (( WLANHAL_RX_BD_GET_PMICMD_24TO25(pucRxBDHeader) & 0xFFFF0000) >> 16);
13036 return ullcurrentReplayCounter;
13037#else
13038 v_U64_t ullcurrentReplayCounter = 0;
13039 /* Getting 48-bit replay counter from the RX BD */
13040 ullcurrentReplayCounter = (WLANHAL_RX_BD_GET_PMICMD_24TO25(pucRxBDHeader) & 0x0000FFFF);
13041 ullcurrentReplayCounter <<= 32;
13042 ullcurrentReplayCounter |= WLANHAL_RX_BD_GET_PMICMD_20TO23(pucRxBDHeader);
13043 return ullcurrentReplayCounter;
13044#endif
13045}
13046#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070013047
13048/*===============================================================================
13049 FUNCTION WLANTL_PostResNeeded
13050
13051 DESCRIPTION This function posts message to TL to reserve BD/PDU memory
13052
13053 DEPENDENCIES None
13054
13055 PARAMETERS pvosGCtx
13056
13057 RETURN None
13058
13059 SIDE EFFECTS none
13060 ===============================================================================*/
13061
13062void WLANTL_PostResNeeded(v_PVOID_t pvosGCtx)
13063{
13064 vos_msg_t vosMsg;
13065
13066 vosMsg.reserved = 0;
13067 vosMsg.bodyptr = NULL;
13068 vosMsg.type = WLANTL_TX_RES_NEEDED;
13069 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
13070 "WLAN TL: BD/PDU available interrupt received, Posting message to TL");
13071 if(!VOS_IS_STATUS_SUCCESS(vos_tx_mq_serialize( VOS_MQ_ID_TL, &vosMsg)))
13072 {
13073 VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070013074 " %s fails to post message", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070013075 }
13076}
13077
13078/*===============================================================================
13079 FUNCTION WLANTL_UpdateRssiBmps
13080
13081 DESCRIPTION This function updates the TL's RSSI (in BMPS mode)
13082
13083 DEPENDENCIES None
13084
13085 PARAMETERS
13086
13087 pvosGCtx VOS context VOS Global context
13088 staId Station ID Station ID
13089 rssi RSSI (BMPS mode) RSSI in BMPS mode
13090
13091 RETURN None
13092
13093 SIDE EFFECTS none
13094 ===============================================================================*/
13095
13096void WLANTL_UpdateRssiBmps(v_PVOID_t pvosGCtx, v_U8_t staId, v_S7_t rssi)
13097{
13098 WLANTL_CbType* pTLCb = VOS_GET_TL_CB(pvosGCtx);
13099
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053013100 if (NULL != pTLCb && NULL != pTLCb->atlSTAClients[staId])
Jeff Johnson295189b2012-06-20 16:38:30 -070013101 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053013102 pTLCb->atlSTAClients[staId]->rssiAvgBmps = rssi;
Jeff Johnson295189b2012-06-20 16:38:30 -070013103 }
13104}
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053013105
13106/*===============================================================================
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053013107 FUNCTION WLANTL_UpdateSnrBmps
13108
13109 DESCRIPTION This function updates the TL's SNR (in BMPS mode)
13110
13111 DEPENDENCIES None
13112
13113 PARAMETERS
13114
13115 pvosGCtx VOS context VOS Global context
13116 staId Station ID Station ID
13117 snr SNR (BMPS mode) SNR in BMPS mode
13118
13119 RETURN None
13120
13121 SIDE EFFECTS none
13122 ===============================================================================*/
13123
13124void WLANTL_UpdateSnrBmps(v_PVOID_t pvosGCtx, v_U8_t staId, v_S7_t snr)
13125{
13126 WLANTL_CbType* pTLCb = VOS_GET_TL_CB(pvosGCtx);
13127
13128 if (NULL != pTLCb && NULL != pTLCb->atlSTAClients[staId])
13129 {
13130 pTLCb->atlSTAClients[staId]->snrAvgBmps = snr;
13131 }
13132}
13133
13134/*===============================================================================
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053013135 FUNCTION WLANTL_UpdateLinkCapacity
13136
13137 DESCRIPTION This function updates the STA's Link Capacity in TL
13138
13139 DEPENDENCIES None
13140
13141 PARAMETERS
13142
13143 pvosGCtx VOS context VOS Global context
13144 staId Station ID Station ID
13145 linkCapacity linkCapacity Link Capacity
13146
13147 RETURN None
13148
13149 SIDE EFFECTS none
13150 ===============================================================================*/
13151
13152void WLANTL_UpdateLinkCapacity(v_PVOID_t pvosGCtx, v_U8_t staId, v_U32_t linkCapacity)
13153{
13154 WLANTL_CbType* pTLCb = VOS_GET_TL_CB(pvosGCtx);
13155
13156 if (NULL != pTLCb && NULL != pTLCb->atlSTAClients[staId])
13157 {
13158 pTLCb->atlSTAClients[staId]->linkCapacity = linkCapacity;
13159 }
13160}
13161
13162
13163/*===========================================================================
13164
13165 FUNCTION WLANTL_GetSTALinkCapacity
13166
13167 DESCRIPTION
13168
13169 Returns Link Capacity of a particular STA.
13170
13171 DEPENDENCIES
13172
13173 A station must have been registered before its state can be retrieved.
13174
13175
13176 PARAMETERS
13177
13178 IN
13179 pvosGCtx: pointer to the global vos context; a handle to TL's
13180 control block can be extracted from its context
13181 ucSTAId: identifier of the station
13182
13183 OUT
13184 plinkCapacity: the current link capacity the connection to
13185 the given station
13186
13187
13188 RETURN VALUE
13189
13190 The result code associated with performing the operation
13191
13192 VOS_STATUS_E_INVAL: Input parameters are invalid
13193 VOS_STATUS_E_FAULT: Station ID is outside array boundaries or pointer to
13194 TL cb is NULL ; access would cause a page fault
13195 VOS_STATUS_E_EXISTS: Station was not registered
13196 VOS_STATUS_SUCCESS: Everything is good :)
13197
13198 SIDE EFFECTS
13199
13200============================================================================*/
13201VOS_STATUS
13202WLANTL_GetSTALinkCapacity
13203(
13204 v_PVOID_t pvosGCtx,
13205 v_U8_t ucSTAId,
13206 v_U32_t *plinkCapacity
13207)
13208{
13209 WLANTL_CbType* pTLCb = NULL;
13210 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
13211
13212 /*------------------------------------------------------------------------
13213 Sanity check
13214 ------------------------------------------------------------------------*/
13215 if ( NULL == plinkCapacity )
13216 {
13217 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
13218 FL("WLAN TL:Invalid parameter")));
13219 return VOS_STATUS_E_INVAL;
13220 }
13221
13222 if ( WLANTL_STA_ID_INVALID( ucSTAId ) )
13223 {
13224 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
13225 FL("WLAN TL:Invalid station id")));
13226 return VOS_STATUS_E_FAULT;
13227 }
13228
13229 /*------------------------------------------------------------------------
13230 Extract TL control block and check existance
13231 ------------------------------------------------------------------------*/
13232 pTLCb = VOS_GET_TL_CB(pvosGCtx);
13233 if ( NULL == pTLCb )
13234 {
13235 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
13236 FL("WLAN TL:Invalid TL pointer from pvosGCtx")));
13237 return VOS_STATUS_E_FAULT;
13238 }
13239
13240 if ( NULL == pTLCb->atlSTAClients[ucSTAId] )
13241 {
13242 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
13243 FL("WLAN TL:Client Memory was not allocated")));
13244 return VOS_STATUS_E_FAILURE;
13245 }
13246
13247 if ( 0 == pTLCb->atlSTAClients[ucSTAId]->ucExists )
13248 {
13249 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
13250 FL("WLAN TL:Station was not previously registered")));
13251 return VOS_STATUS_E_EXISTS;
13252 }
13253
13254 /*------------------------------------------------------------------------
13255 Get STA state
13256 ------------------------------------------------------------------------*/
13257 *plinkCapacity = pTLCb->atlSTAClients[ucSTAId]->linkCapacity;
13258
13259 return VOS_STATUS_SUCCESS;
13260}/* WLANTL_GetSTALinkCapacity */