blob: 3378207d39a3bc0e4ddfcda8c8e198b95e37b442 [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
1153 if (pClientSTA->isEapolM4Transmitted ||
1154 pClientSTA->tlState == WLANTL_STA_AUTHENTICATED)
1155 {
1156 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
1157 "WLAN TL: M4 is already received on %s", __func__));
1158 return VOS_STATUS_E_ALREADY;
1159 }
1160
1161 pClientSTA->pfnSTAUlaComplete = (WLANTL_STAUlaCompleteCBType) callbackRoutine;
1162 pClientSTA->pUlaCBCtx = callbackContext;
1163
1164 return VOS_STATUS_SUCCESS;
1165}
Jeff Johnson295189b2012-06-20 16:38:30 -07001166
1167/*===========================================================================
1168
1169 FUNCTION WLANTL_RegisterSTAClient
1170
1171 DESCRIPTION
1172
1173 This function is used by HDD to register as a client for data services
1174 with TL. HDD will call this API for each new station that it adds,
1175 thus having the flexibility of registering different callback for each
1176 STA it services.
1177
1178 DEPENDENCIES
1179
1180 TL must have been initialized before this gets called.
1181
1182 Restriction:
1183 Main thread will have higher priority that Tx and Rx threads thus
1184 guaranteeing that a station will be added before any data can be
1185 received for it. (This enables TL to be lock free)
1186
1187 PARAMETERS
1188
1189 pvosGCtx: pointer to the global vos context; a handle to TL's
1190 control block can be extracted from its context
1191 pfnStARx: function pointer to the receive packet handler from HDD
1192 pfnSTATxComp: function pointer to the transmit complete confirmation
1193 handler from HDD
1194 pfnSTAFetchPkt: function pointer to the packet retrieval routine in HDD
1195 wSTADescType: STA Descriptor, contains information related to the
1196 new added STA
1197
1198 RETURN VALUE
1199
1200 The result code associated with performing the operation
1201
1202 VOS_STATUS_E_INVAL: Input parameters are invalid
1203 VOS_STATUS_E_FAULT: Station ID is outside array boundaries or pointer to
1204 TL cb is NULL ; access would cause a page fault
1205 VOS_STATUS_E_EXISTS: Station was already registered
1206 VOS_STATUS_SUCCESS: Everything is good :)
1207
1208 SIDE EFFECTS
1209
1210============================================================================*/
1211VOS_STATUS
1212WLANTL_RegisterSTAClient
1213(
1214 v_PVOID_t pvosGCtx,
1215 WLANTL_STARxCBType pfnSTARx,
1216 WLANTL_TxCompCBType pfnSTATxComp,
1217 WLANTL_STAFetchPktCBType pfnSTAFetchPkt,
1218 WLAN_STADescType* pwSTADescType,
1219 v_S7_t rssi
1220)
1221{
1222 WLANTL_CbType* pTLCb = NULL;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301223 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07001224 v_U8_t ucTid = 0;/*Local variable to clear previous replay counters of STA on all TIDs*/
Jeff Johnson295189b2012-06-20 16:38:30 -07001225 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
1226
1227 /*------------------------------------------------------------------------
1228 Sanity check
1229 ------------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301230 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -07001231 if (( NULL == pwSTADescType ) || ( NULL == pfnSTARx ) ||
1232 ( NULL == pfnSTAFetchPkt ))
1233 {
1234 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1235 "WLAN TL:Invalid parameter sent on WLANTL_RegisterSTAClient"));
1236 return VOS_STATUS_E_INVAL;
1237 }
1238
1239 if ( WLANTL_STA_ID_INVALID( pwSTADescType->ucSTAId ) )
1240 {
1241 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1242 "WLAN TL:Invalid station id requested on WLANTL_RegisterSTAClient"));
1243 return VOS_STATUS_E_FAULT;
1244 }
1245
1246 /*------------------------------------------------------------------------
1247 Extract TL control block
1248 ------------------------------------------------------------------------*/
1249 pTLCb = VOS_GET_TL_CB(pvosGCtx);
1250 if ( NULL == pTLCb )
1251 {
1252 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1253 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_RegisterSTAClient"));
1254 return VOS_STATUS_E_FAULT;
1255 }
1256
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301257 //Code for checking and allocating memory for new STA
1258 if ( NULL == pTLCb->atlSTAClients[pwSTADescType->ucSTAId] ){
1259 pTLCb->atlSTAClients[pwSTADescType->ucSTAId] = vos_mem_malloc(sizeof(WLANTL_STAClientType));
1260 if ( NULL == pTLCb->atlSTAClients[pwSTADescType->ucSTAId] ){
1261 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1262 "WLAN TL: STA Client memory allocation failed in WLANTL_RegisterSTAClient"));
1263 return VOS_STATUS_E_FAILURE;
1264 }
1265 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
1266 "WLAN TL: STA Client memory allocation in WLANTL_RegisterSTAClient"));
1267 vos_mem_zero((v_VOID_t *) pTLCb->atlSTAClients[pwSTADescType->ucSTAId],sizeof(WLANTL_STAClientType));
1268 }
1269
1270 //Assigning the pointer to local variable for easy access in future
1271 pClientSTA = pTLCb->atlSTAClients[pwSTADescType->ucSTAId];
1272 if ( 0 != pClientSTA->ucExists )
Jeff Johnson295189b2012-06-20 16:38:30 -07001273 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301274 pClientSTA->ucExists++;
Jeff Johnson295189b2012-06-20 16:38:30 -07001275 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1276 "WLAN TL:Station was already registered on WLANTL_RegisterSTAClient"));
1277 return VOS_STATUS_E_EXISTS;
1278 }
1279
1280 /*------------------------------------------------------------------------
1281 Register station with TL
1282 ------------------------------------------------------------------------*/
Katya Nigam42e16e82014-02-04 16:28:55 +05301283 MTRACE(vos_trace(VOS_MODULE_ID_TL, TRACE_CODE_TL_REGISTER_STA_CLIENT,
1284 pwSTADescType->ucSTAId, (unsigned )
1285 (*(pwSTADescType->vSTAMACAddress.bytes+2)<<24 |
1286 *(pwSTADescType->vSTAMACAddress.bytes+3)<<16 |
1287 *(pwSTADescType->vSTAMACAddress.bytes+4)<<8 |
1288 *(pwSTADescType->vSTAMACAddress.bytes+5))));
1289
Jeff Johnson295189b2012-06-20 16:38:30 -07001290 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
1291 "WLAN TL:Registering STA Client ID: %d", pwSTADescType->ucSTAId ));
1292
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301293 pClientSTA->pfnSTARx = pfnSTARx;
1294 pClientSTA->pfnSTAFetchPkt = pfnSTAFetchPkt;
Jeff Johnson295189b2012-06-20 16:38:30 -07001295
Nirav Shah4f765af2015-01-21 19:51:30 +05301296 pClientSTA->pfnSTAUlaComplete = NULL;
1297 pClientSTA->pUlaCBCtx = NULL;
1298
Jeff Johnson295189b2012-06-20 16:38:30 -07001299 /* Only register if different from NULL - TL default Tx Comp Cb will
1300 release the vos packet */
1301 if ( NULL != pfnSTATxComp )
1302 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301303 pClientSTA->pfnSTATxComp = pfnSTATxComp;
Jeff Johnson295189b2012-06-20 16:38:30 -07001304 }
1305
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301306 pClientSTA->tlState = WLANTL_STA_INIT;
1307 pClientSTA->tlPri = WLANTL_STA_PRI_NORMAL;
1308 pClientSTA->wSTADesc.ucSTAId = pwSTADescType->ucSTAId;
Gopichand Nakkala8b54e912013-03-11 10:44:21 +05301309 pClientSTA->ptkInstalled = 0;
Nirav Shah4f765af2015-01-21 19:51:30 +05301310 pClientSTA->isEapolM4Transmitted = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001311
1312 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
1313 "WLAN TL:Registering STA Client ID: %d with UC %d and BC %d",
1314 pwSTADescType->ucSTAId,
1315 pwSTADescType->ucUcastSig, pwSTADescType->ucBcastSig));
1316
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301317 pClientSTA->wSTADesc.wSTAType = pwSTADescType->wSTAType;
Jeff Johnson295189b2012-06-20 16:38:30 -07001318
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301319 pClientSTA->wSTADesc.ucQosEnabled = pwSTADescType->ucQosEnabled;
Jeff Johnson295189b2012-06-20 16:38:30 -07001320
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301321 pClientSTA->wSTADesc.ucAddRmvLLC = pwSTADescType->ucAddRmvLLC;
Jeff Johnson295189b2012-06-20 16:38:30 -07001322
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301323 pClientSTA->wSTADesc.ucProtectedFrame = pwSTADescType->ucProtectedFrame;
Jeff Johnson295189b2012-06-20 16:38:30 -07001324
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001325#ifdef FEATURE_WLAN_ESE
1326 pClientSTA->wSTADesc.ucIsEseSta = pwSTADescType->ucIsEseSta;
Jeff Johnson295189b2012-06-20 16:38:30 -07001327
1328 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001329 "WLAN TL:Registering STA Client ID: %d QoS %d Add LLC %d ProtFrame %d EseSta %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07001330 pwSTADescType->ucSTAId,
1331 pwSTADescType->ucQosEnabled,
1332 pwSTADescType->ucAddRmvLLC,
1333 pwSTADescType->ucProtectedFrame,
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001334 pwSTADescType->ucIsEseSta));
Jeff Johnson295189b2012-06-20 16:38:30 -07001335#else
1336
1337 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
1338 "WLAN TL:Registering STA Client ID: %d QoS %d Add LLC %d ProtFrame %d",
1339 pwSTADescType->ucSTAId,
1340 pwSTADescType->ucQosEnabled,
1341 pwSTADescType->ucAddRmvLLC,
1342 pwSTADescType->ucProtectedFrame));
1343
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001344#endif //FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07001345#ifdef WLAN_SOFTAP_VSTA_FEATURE
1346 // if this station was not allocated resources to perform HW-based
1347 // TX frame translation then force SW-based TX frame translation
1348 // otherwise use the frame translation supplied by the client
1349
1350 if (!WDA_IsHwFrameTxTranslationCapable(pvosGCtx, pwSTADescType->ucSTAId)
1351 || ( WLAN_STA_BT_AMP == pwSTADescType->wSTAType))
1352 {
1353 pwSTADescType->ucSwFrameTXXlation = 1;
1354 }
1355#endif
1356
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301357 pClientSTA->wSTADesc.ucSwFrameTXXlation = pwSTADescType->ucSwFrameTXXlation;
1358 pClientSTA->wSTADesc.ucSwFrameRXXlation = pwSTADescType->ucSwFrameRXXlation;
Jeff Johnson295189b2012-06-20 16:38:30 -07001359
1360#ifdef FEATURE_WLAN_WAPI
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301361 pClientSTA->wSTADesc.ucIsWapiSta = pwSTADescType->ucIsWapiSta;
Jeff Johnson295189b2012-06-20 16:38:30 -07001362#endif /* FEATURE_WLAN_WAPI */
1363
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301364 vos_copy_macaddr( &pClientSTA->wSTADesc.vSTAMACAddress, &pwSTADescType->vSTAMACAddress);
Jeff Johnson295189b2012-06-20 16:38:30 -07001365
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301366 vos_copy_macaddr( &pClientSTA->wSTADesc.vBSSIDforIBSS, &pwSTADescType->vBSSIDforIBSS);
Jeff Johnson295189b2012-06-20 16:38:30 -07001367
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301368 vos_copy_macaddr( &pClientSTA->wSTADesc.vSelfMACAddress, &pwSTADescType->vSelfMACAddress);
Jeff Johnson295189b2012-06-20 16:38:30 -07001369
Jeff Johnson295189b2012-06-20 16:38:30 -07001370 /* In volans release L replay check is done at TL */
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301371 pClientSTA->ucIsReplayCheckValid = pwSTADescType->ucIsReplayCheckValid;
1372 pClientSTA->ulTotalReplayPacketsDetected = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001373/*Clear replay counters of the STA on all TIDs*/
1374 for(ucTid = 0; ucTid < WLANTL_MAX_TID ; ucTid++)
1375 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301376 pClientSTA->ullReplayCounter[ucTid] = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001377 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001378
1379 /*--------------------------------------------------------------------
1380 Set the AC for the registered station to the highest priority AC
1381 Even if this AC is not supported by the station, correction will be
1382 made in the main TL loop after the supported mask is properly
1383 updated in the pending packets call
1384 --------------------------------------------------------------------*/
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05301385 pClientSTA->ucCurrentAC = WLANTL_AC_HIGH_PRIO;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301386 pClientSTA->ucCurrentWeight = 0;
1387 pClientSTA->ucServicedAC = WLANTL_AC_BK;
1388 pClientSTA->ucEapolPktPending = 0;
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -07001389
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301390 vos_mem_zero( pClientSTA->aucACMask, sizeof(pClientSTA->aucACMask));
Jeff Johnson295189b2012-06-20 16:38:30 -07001391
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301392 vos_mem_zero( &pClientSTA->wUAPSDInfo, sizeof(pClientSTA->wUAPSDInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -07001393
1394 /*--------------------------------------------------------------------
1395 Reordering info and AMSDU de-aggregation
1396 --------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301397 vos_mem_zero( pClientSTA->atlBAReorderInfo,
1398 sizeof(pClientSTA->atlBAReorderInfo[0])*
Jeff Johnson295189b2012-06-20 16:38:30 -07001399 WLAN_MAX_TID);
1400
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301401 vos_mem_zero( pClientSTA->aucMPDUHeader,
Jeff Johnson295189b2012-06-20 16:38:30 -07001402 WLANTL_MPDU_HEADER_LEN);
1403
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301404 pClientSTA->ucMPDUHeaderLen = 0;
1405 pClientSTA->vosAMSDUChain = NULL;
1406 pClientSTA->vosAMSDUChainRoot = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07001407
1408
Leo Chang6b6faaf2014-01-24 21:21:26 -08001409 /* Reorder LOCK
1410 * During handle normal RX frame within RX thread,
1411 * if MC thread try to preempt, ADDBA, DELBA, TIMER
1412 * Context should be protected from race */
1413 for (ucTid = 0; ucTid < WLAN_MAX_TID ; ucTid++)
1414 {
1415 if (!VOS_IS_STATUS_SUCCESS(
1416 vos_lock_init(&pClientSTA->atlBAReorderInfo[ucTid].reorderLock)))
1417 {
1418 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1419 "Lock Init Fail"));
1420 return VOS_STATUS_E_FAILURE;
1421 }
1422 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001423 /*--------------------------------------------------------------------
1424 Stats info
1425 --------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301426 vos_mem_zero( pClientSTA->auRxCount,
1427 sizeof(pClientSTA->auRxCount[0])*
Jeff Johnson295189b2012-06-20 16:38:30 -07001428 WLAN_MAX_TID);
1429
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301430 vos_mem_zero( pClientSTA->auTxCount,
1431 sizeof(pClientSTA->auRxCount[0])*
Jeff Johnson295189b2012-06-20 16:38:30 -07001432 WLAN_MAX_TID);
1433 /* Initial RSSI is always reported as zero because TL doesnt have enough
1434 data to calculate RSSI. So to avoid reporting zero, we are initializing
1435 RSSI with RSSI saved in BssDescription during scanning. */
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301436 pClientSTA->rssiAvg = rssi;
Shailender Karmuchi13c0d082013-03-26 14:41:39 -07001437#ifdef FEATURE_WLAN_TDLS
1438 if(WLAN_STA_TDLS == pClientSTA->wSTADesc.wSTAType)
1439 {
1440 /* If client is TDLS, use TDLS specific alpha */
1441 pClientSTA->rssiAlpha = WLANTL_HO_TDLS_ALPHA;
1442 }
1443 else
1444 {
1445 pClientSTA->rssiAlpha = WLANTL_HO_DEFAULT_ALPHA;
1446 }
1447#else
1448 pClientSTA->rssiAlpha = WLANTL_HO_DEFAULT_ALPHA;
1449#endif /* FEATURE_WLAN_TDLS */
Dino Mycle3b9536d2014-07-09 22:05:24 +05301450#ifdef WLAN_FEATURE_LINK_LAYER_STATS
1451 pClientSTA->rssiDataAlpha = WLANTL_HO_DEFAULT_ALPHA;
1452 pClientSTA->interfaceStats.accessCategoryStats[0].ac = WLANTL_AC_BK;
1453 pClientSTA->interfaceStats.accessCategoryStats[1].ac = WLANTL_AC_BE;
1454 pClientSTA->interfaceStats.accessCategoryStats[2].ac = WLANTL_AC_VI;
1455 pClientSTA->interfaceStats.accessCategoryStats[3].ac = WLANTL_AC_VO;
1456#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001457
1458 /*Tx not suspended and station fully registered*/
1459 vos_atomic_set_U8(
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301460 &pClientSTA->ucTxSuspended, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07001461
1462 /* Used until multiple station support will be added*/
1463 pTLCb->ucRegisteredStaId = pwSTADescType->ucSTAId;
1464
1465 /* Save the BAP station ID for future usage */
1466 if ( WLAN_STA_BT_AMP == pwSTADescType->wSTAType )
1467 {
1468 pTLCb->tlBAPClient.ucBAPSTAId = pwSTADescType->ucSTAId;
1469 }
1470
1471 /*------------------------------------------------------------------------
1472 Statistics info
1473 -----------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301474 memset(&pClientSTA->trafficStatistics,
Jeff Johnson295189b2012-06-20 16:38:30 -07001475 0, sizeof(WLANTL_TRANSFER_STA_TYPE));
1476
1477
1478 /*------------------------------------------------------------------------
1479 Start with the state suggested by client caller
1480 -----------------------------------------------------------------------*/
Madan Mohan Koyylamudi64258222013-01-30 14:35:10 +05301481 pClientSTA->tlState = pwSTADescType->ucInitState;
Jeff Johnson295189b2012-06-20 16:38:30 -07001482 /*-----------------------------------------------------------------------
1483 After all the init is complete we can mark the existance flag
1484 ----------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301485 pClientSTA->ucExists++;
Jeff Johnson295189b2012-06-20 16:38:30 -07001486
Jeff Johnson295189b2012-06-20 16:38:30 -07001487 //flow control fields init
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301488 pClientSTA->ucLwmModeEnabled = FALSE;
1489 pClientSTA->ucLwmEventReported = FALSE;
1490 pClientSTA->bmuMemConsumed = 0;
1491 pClientSTA->uIngress_length = 0;
1492 pClientSTA->uBuffThresholdMax = WLANTL_STA_BMU_THRESHOLD_MAX;
Jeff Johnson295189b2012-06-20 16:38:30 -07001493
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301494 pClientSTA->uLwmThreshold = WLANTL_STA_BMU_THRESHOLD_MAX / 3;
Jeff Johnson295189b2012-06-20 16:38:30 -07001495
1496 //@@@ HDDSOFTAP does not queue unregistered packet for now
1497 if ( WLAN_STA_SOFTAP != pwSTADescType->wSTAType )
1498 {
Jeff Johnson295189b2012-06-20 16:38:30 -07001499 /*------------------------------------------------------------------------
1500 Forward received frames while STA was not yet registered
1501 - ----------------------------------------------------------------------*/
1502 if(!VOS_IS_STATUS_SUCCESS(WLANTL_StartForwarding( pwSTADescType->ucSTAId,
1503 pwSTADescType->ucUcastSig,
1504 pwSTADescType->ucBcastSig)))
1505 {
1506 VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001507 " %s fails to start forwarding", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001508 }
Sunil Ravid5406f22013-01-22 00:18:31 -08001509#ifdef FEATURE_WLAN_TDLS
1510 if( WLAN_STA_TDLS == pwSTADescType->wSTAType )
1511 pTLCb->ucTdlsPeerCount++;
1512#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001513 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001514 return VOS_STATUS_SUCCESS;
1515}/* WLANTL_RegisterSTAClient */
1516
1517/*===========================================================================
1518
1519 FUNCTION WLANTL_ClearSTAClient
1520
1521 DESCRIPTION
1522
1523 HDD will call this API when it no longer needs data services for the
1524 particular station.
1525
1526 DEPENDENCIES
1527
1528 A station must have been registered before the clear registration is
1529 called.
1530
1531 PARAMETERS
1532
1533 pvosGCtx: pointer to the global vos context; a handle to TL's
1534 control block can be extracted from its context
1535 ucSTAId: identifier for the STA to be cleared
1536
1537 RETURN VALUE
1538
1539 The result code associated with performing the operation
1540
1541 VOS_STATUS_E_FAULT: Station ID is outside array boundaries or pointer to
1542 TL cb is NULL ; access would cause a page fault
1543 VOS_STATUS_E_EXISTS: Station was not registered
1544 VOS_STATUS_SUCCESS: Everything is good :)
1545
1546 SIDE EFFECTS
1547
1548============================================================================*/
1549VOS_STATUS
1550WLANTL_ClearSTAClient
1551(
1552 v_PVOID_t pvosGCtx,
1553 v_U8_t ucSTAId
1554)
1555{
1556 WLANTL_CbType* pTLCb = NULL;
1557 v_U8_t ucIndex;
1558 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
1559
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301560 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -07001561 /*------------------------------------------------------------------------
1562 Sanity check
1563 ------------------------------------------------------------------------*/
1564 if ( WLANTL_STA_ID_INVALID( ucSTAId ) )
1565 {
1566 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1567 "WLAN TL:Invalid station id requested on WLANTL_ClearSTAClient"));
1568 return VOS_STATUS_E_FAULT;
1569 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001570 /*------------------------------------------------------------------------
1571 Extract TL control block
1572 ------------------------------------------------------------------------*/
1573 pTLCb = VOS_GET_TL_CB(pvosGCtx);
1574 if ( NULL == pTLCb )
1575 {
1576 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1577 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_ClearSTAClient"));
1578 return VOS_STATUS_E_FAULT;
1579 }
1580
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301581 if ( NULL == pTLCb->atlSTAClients[ucSTAId] )
1582 {
1583 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1584 "WLAN TL:Client Memory was not allocated on %s", __func__));
1585 return VOS_STATUS_E_FAILURE;
1586 }
1587
1588 if ( 0 == pTLCb->atlSTAClients[ucSTAId]->ucExists )
Jeff Johnson295189b2012-06-20 16:38:30 -07001589 {
1590 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1591 "WLAN TL:Station was not previously registered on WLANTL_ClearSTAClient"));
Siddharth Bhalaef8ee12014-04-02 00:09:45 +05301592 /* Clean packets cached for the STA */
1593 WLANTL_StartForwarding(ucSTAId,0,0);
Jeff Johnson295189b2012-06-20 16:38:30 -07001594 return VOS_STATUS_E_EXISTS;
1595 }
1596
1597 /* Delete BA sessions on all TID's */
Leo Chang6b6faaf2014-01-24 21:21:26 -08001598 for (ucIndex = 0; ucIndex < WLAN_MAX_TID ; ucIndex++)
Jeff Johnson295189b2012-06-20 16:38:30 -07001599 {
Leo Chang6b6faaf2014-01-24 21:21:26 -08001600 WLANTL_BaSessionDel(pvosGCtx, ucSTAId, ucIndex);
1601 vos_lock_destroy(&pTLCb->atlSTAClients[ucSTAId]->atlBAReorderInfo[ucIndex].reorderLock);
Jeff Johnson295189b2012-06-20 16:38:30 -07001602 }
1603
Sunil Ravid5406f22013-01-22 00:18:31 -08001604#ifdef FEATURE_WLAN_TDLS
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301605 /* decrement ucTdlsPeerCount only if it is non-zero */
1606 if(WLAN_STA_TDLS == pTLCb->atlSTAClients[ucSTAId]->wSTADesc.wSTAType
Sunil Ravid5406f22013-01-22 00:18:31 -08001607 && pTLCb->ucTdlsPeerCount)
1608 pTLCb->ucTdlsPeerCount--;
1609#endif
1610
Jeff Johnson295189b2012-06-20 16:38:30 -07001611 /*------------------------------------------------------------------------
1612 Clear station
1613 ------------------------------------------------------------------------*/
1614 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
1615 "WLAN TL:Clearing STA Client ID: %d", ucSTAId ));
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301616 WLANTL_CleanSTA(pTLCb->atlSTAClients[ucSTAId], 1 /*empty packets*/);
Jeff Johnson295189b2012-06-20 16:38:30 -07001617
1618 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
1619 "WLAN TL:Clearing STA Reset History RSSI and Region number"));
1620 pTLCb->hoSupport.currentHOState.historyRSSI = 0;
1621 pTLCb->hoSupport.currentHOState.regionNumber = 0;
1622
1623 return VOS_STATUS_SUCCESS;
1624}/* WLANTL_ClearSTAClient */
1625
1626/*===========================================================================
1627
1628 FUNCTION WLANTL_ChangeSTAState
1629
1630 DESCRIPTION
1631
1632 HDD will make this notification whenever a change occurs in the
1633 connectivity state of a particular STA.
1634
1635 DEPENDENCIES
1636
1637 A station must have been registered before the change state can be
1638 called.
1639
1640 RESTRICTION: A station is being notified as authenticated before the
1641 keys are installed in HW. This way if a frame is received
1642 before the keys are installed DPU will drop that frame.
1643
1644 Main thread has higher priority that Tx and Rx threads thus guaranteeing
1645 the following:
1646 - a station will be in assoc state in TL before TL receives any data
1647 for it
1648
1649 PARAMETERS
1650
1651 pvosGCtx: pointer to the global vos context; a handle to TL's
1652 control block can be extracted from its context
1653 ucSTAId: identifier for the STA that is pending transmission
1654 tlSTAState: the new state of the connection to the given station
1655
1656
1657 RETURN VALUE
1658
1659 The result code associated with performing the operation
1660
1661 VOS_STATUS_E_INVAL: Input parameters are invalid
1662 VOS_STATUS_E_FAULT: Station ID is outside array boundaries or pointer to
1663 TL cb is NULL ; access would cause a page fault
1664 VOS_STATUS_E_EXISTS: Station was not registered
1665 VOS_STATUS_SUCCESS: Everything is good :)
1666
1667 SIDE EFFECTS
1668
1669============================================================================*/
1670VOS_STATUS
1671WLANTL_ChangeSTAState
1672(
1673 v_PVOID_t pvosGCtx,
1674 v_U8_t ucSTAId,
1675 WLANTL_STAStateType tlSTAState
1676)
1677{
1678 WLANTL_CbType* pTLCb = NULL;
1679 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
1680
1681 /*------------------------------------------------------------------------
1682 Sanity check
1683 ------------------------------------------------------------------------*/
1684 if ( tlSTAState >= WLANTL_STA_MAX_STATE )
1685 {
1686 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1687 "WLAN TL:Invalid parameter sent on WLANTL_ChangeSTAState"));
1688 return VOS_STATUS_E_INVAL;
1689 }
1690
1691 if ( WLANTL_STA_ID_INVALID( ucSTAId ) )
1692 {
1693 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1694 "WLAN TL:Invalid station id requested on WLANTL_ChangeSTAState"));
1695 return VOS_STATUS_E_FAULT;
1696 }
1697
1698 /*------------------------------------------------------------------------
1699 Extract TL control block and check existance
1700 ------------------------------------------------------------------------*/
1701 pTLCb = VOS_GET_TL_CB(pvosGCtx);
1702 if ( NULL == pTLCb )
1703 {
1704 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1705 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_ChangeSTAState"));
1706 return VOS_STATUS_E_FAULT;
1707 }
1708
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301709 if ( NULL == pTLCb->atlSTAClients[ucSTAId] )
1710 {
1711 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1712 "WLAN TL:Client Memory was not allocated on %s", __func__));
1713 return VOS_STATUS_E_FAILURE;
1714 }
1715
1716 if ( 0 == pTLCb->atlSTAClients[ucSTAId]->ucExists )
Jeff Johnson295189b2012-06-20 16:38:30 -07001717 {
1718 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1719 "WLAN TL:Station was not previously registered on WLANTL_ChangeSTAState"));
1720 return VOS_STATUS_E_EXISTS;
1721 }
1722
1723 /*------------------------------------------------------------------------
1724 Change STA state
1725 No need to lock this operation, see restrictions above
1726 ------------------------------------------------------------------------*/
1727 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
1728 "WLAN TL:Changing state for STA Client ID: %d from %d to %d",
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301729 ucSTAId, pTLCb->atlSTAClients[ucSTAId]->tlState, tlSTAState));
Jeff Johnson295189b2012-06-20 16:38:30 -07001730
Katya Nigam42e16e82014-02-04 16:28:55 +05301731 MTRACE(vos_trace(VOS_MODULE_ID_TL,
1732 TRACE_CODE_TL_STA_STATE, ucSTAId,tlSTAState ));
1733
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301734 pTLCb->atlSTAClients[ucSTAId]->tlState = tlSTAState;
Jeff Johnson295189b2012-06-20 16:38:30 -07001735
1736 return VOS_STATUS_SUCCESS;
1737}/* WLANTL_ChangeSTAState */
1738
1739/*===========================================================================
1740
Agarwal Ashish16020c42014-12-29 22:01:11 +05301741 FUNCTION WLANTL_UpdateTdlsSTAClient
1742
1743 DESCRIPTION
1744
1745 HDD will call this API when ENABLE_LINK happens and HDD want to
1746 register QoS or other params for TDLS peers.
1747
1748 DEPENDENCIES
1749
1750 A station must have been registered before the WMM/QOS registration is
1751 called.
1752
1753 PARAMETERS
1754
1755 pvosGCtx: pointer to the global vos context; a handle to TL's
1756 control block can be extracted from its context
1757 wSTADescType: STA Descriptor, contains information related to the
1758 new added STA
1759
1760 RETURN VALUE
1761
1762 The result code associated with performing the operation
1763
1764 VOS_STATUS_E_FAULT: Station ID is outside array boundaries or pointer to
1765 TL cb is NULL ; access would cause a page fault
1766 VOS_STATUS_E_EXISTS: Station was not registered
1767 VOS_STATUS_SUCCESS: Everything is good :)
1768
1769 SIDE EFFECTS
1770
1771============================================================================*/
1772
1773VOS_STATUS
1774WLANTL_UpdateTdlsSTAClient
1775(
1776 v_PVOID_t pvosGCtx,
1777 WLAN_STADescType* pwSTADescType
1778)
1779{
1780 WLANTL_CbType* pTLCb = NULL;
1781 WLANTL_STAClientType* pClientSTA = NULL;
1782 /*------------------------------------------------------------------------
1783 Extract TL control block
1784 ------------------------------------------------------------------------*/
1785 pTLCb = VOS_GET_TL_CB(pvosGCtx);
1786 if ( NULL == pTLCb || ( WLAN_MAX_STA_COUNT <= pwSTADescType->ucSTAId))
1787 {
1788 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1789 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_UpdateTdlsSTAClient"));
1790 return VOS_STATUS_E_FAULT;
1791 }
1792
1793 pClientSTA = pTLCb->atlSTAClients[pwSTADescType->ucSTAId];
1794 if ((NULL == pClientSTA) || 0 == pClientSTA->ucExists)
1795 {
1796 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1797 "WLAN TL:Station not exists"));
1798 return VOS_STATUS_E_FAILURE;
1799 }
1800
1801 pClientSTA->wSTADesc.ucQosEnabled = pwSTADescType->ucQosEnabled;
1802
1803 return VOS_STATUS_SUCCESS;
1804
1805}
1806
1807
1808/*===========================================================================
1809
Gopichand Nakkala8b54e912013-03-11 10:44:21 +05301810 FUNCTION WLANTL_STAPtkInstalled
1811
1812 DESCRIPTION
1813
1814 HDD will make this notification whenever PTK is installed for the STA
1815
1816 DEPENDENCIES
1817
1818 A station must have been registered before the change state can be
1819 called.
1820
1821 PARAMETERS
1822
1823 pvosGCtx: pointer to the global vos context; a handle to TL's
1824 control block can be extracted from its context
1825 ucSTAId: identifier for the STA for which Pairwise key is
1826 installed
1827
1828 RETURN VALUE
1829
1830 The result code associated with performing the operation
1831
1832 VOS_STATUS_E_FAULT: Station ID is outside array boundaries or pointer to
1833 TL cb is NULL ; access would cause a page fault
1834 VOS_STATUS_E_EXISTS: Station was not registered
1835 VOS_STATUS_SUCCESS: Everything is good :)
1836
1837 SIDE EFFECTS
1838
1839============================================================================*/
1840VOS_STATUS
1841WLANTL_STAPtkInstalled
1842(
1843 v_PVOID_t pvosGCtx,
1844 v_U8_t ucSTAId
1845)
1846{
1847 WLANTL_CbType* pTLCb = NULL;
1848 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
1849
1850 /*------------------------------------------------------------------------
1851 Sanity check
1852 ------------------------------------------------------------------------*/
1853
1854 if ( WLANTL_STA_ID_INVALID( ucSTAId ) )
1855 {
1856 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1857 "WLAN TL:Invalid station id requested on WLANTL_ChangeSTAState"));
1858 return VOS_STATUS_E_FAULT;
1859 }
1860
1861 /*------------------------------------------------------------------------
1862 Extract TL control block and check existance
1863 ------------------------------------------------------------------------*/
1864 pTLCb = VOS_GET_TL_CB(pvosGCtx);
1865 if ( NULL == pTLCb )
1866 {
1867 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1868 FL("WLAN TL:Invalid TL pointer from pvosGCtx")));
1869 return VOS_STATUS_E_FAULT;
1870 }
1871
1872 if ( NULL == pTLCb->atlSTAClients[ucSTAId] )
1873 {
1874 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1875 FL("WLAN TL:Client Memory was not allocated")));
1876 return VOS_STATUS_E_FAILURE;
1877 }
1878
1879 if ( 0 == pTLCb->atlSTAClients[ucSTAId]->ucExists )
1880 {
1881 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1882 FL("WLAN TL:Station was not previously registered")));
1883 return VOS_STATUS_E_EXISTS;
1884 }
1885
1886 pTLCb->atlSTAClients[ucSTAId]->ptkInstalled = 1;
1887
1888 return VOS_STATUS_SUCCESS;
1889}/* WLANTL_STAPtkInstalled */
1890
1891/*===========================================================================
1892
Madan Mohan Koyyalamudifc1d1fe2012-10-18 15:07:12 -07001893 FUNCTION WLANTL_GetSTAState
1894
1895 DESCRIPTION
1896
1897 Returns connectivity state of a particular STA.
1898
1899 DEPENDENCIES
1900
1901 A station must have been registered before its state can be retrieved.
1902
1903
1904 PARAMETERS
1905
1906 IN
1907 pvosGCtx: pointer to the global vos context; a handle to TL's
1908 control block can be extracted from its context
1909 ucSTAId: identifier of the station
1910
1911 OUT
1912 ptlSTAState: the current state of the connection to the given station
1913
1914
1915 RETURN VALUE
1916
1917 The result code associated with performing the operation
1918
1919 VOS_STATUS_E_INVAL: Input parameters are invalid
1920 VOS_STATUS_E_FAULT: Station ID is outside array boundaries or pointer to
1921 TL cb is NULL ; access would cause a page fault
1922 VOS_STATUS_E_EXISTS: Station was not registered
1923 VOS_STATUS_SUCCESS: Everything is good :)
1924
1925 SIDE EFFECTS
1926
1927============================================================================*/
1928VOS_STATUS
1929WLANTL_GetSTAState
1930(
1931 v_PVOID_t pvosGCtx,
1932 v_U8_t ucSTAId,
1933 WLANTL_STAStateType *ptlSTAState
1934)
1935{
1936 WLANTL_CbType* pTLCb = NULL;
1937 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
1938
1939 /*------------------------------------------------------------------------
1940 Sanity check
1941 ------------------------------------------------------------------------*/
1942 if ( NULL == ptlSTAState )
1943 {
1944 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1945 "WLAN TL:Invalid parameter sent on WLANTL_GetSTAState"));
1946 return VOS_STATUS_E_INVAL;
1947 }
1948
1949 if ( WLANTL_STA_ID_INVALID( ucSTAId ) )
1950 {
1951 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1952 "WLAN TL:Invalid station id requested on WLANTL_GetSTAState"));
1953 return VOS_STATUS_E_FAULT;
1954 }
1955
1956 /*------------------------------------------------------------------------
1957 Extract TL control block and check existance
1958 ------------------------------------------------------------------------*/
1959 pTLCb = VOS_GET_TL_CB(pvosGCtx);
1960 if ( NULL == pTLCb )
1961 {
1962 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1963 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_GetSTAState"));
1964 return VOS_STATUS_E_FAULT;
1965 }
1966
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301967 if ( NULL == pTLCb->atlSTAClients[ucSTAId] )
1968 {
1969 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1970 "WLAN TL:Client Memory was not allocated on %s", __func__));
1971 return VOS_STATUS_E_FAILURE;
1972 }
1973
1974 if ( 0 == pTLCb->atlSTAClients[ucSTAId]->ucExists )
Madan Mohan Koyyalamudifc1d1fe2012-10-18 15:07:12 -07001975 {
Sunil Ravid5406f22013-01-22 00:18:31 -08001976 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
Madan Mohan Koyyalamudifc1d1fe2012-10-18 15:07:12 -07001977 "WLAN TL:Station was not previously registered on WLANTL_GetSTAState"));
1978 return VOS_STATUS_E_EXISTS;
1979 }
1980
1981 /*------------------------------------------------------------------------
1982 Get STA state
1983 ------------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301984 *ptlSTAState = pTLCb->atlSTAClients[ucSTAId]->tlState;
Madan Mohan Koyyalamudifc1d1fe2012-10-18 15:07:12 -07001985
1986 return VOS_STATUS_SUCCESS;
1987}/* WLANTL_GetSTAState */
1988
Shailender Karmuchia734f332013-04-19 14:02:48 -07001989/*==========================================================================
1990 FUNCTION WLANTL_UpdateSTABssIdforIBSS
1991
1992 DESCRIPTION
1993 HDD will call this API to update the BSSID for this Station.
1994
1995 DEPENDENCIES
1996 The HDD Should registered the staID with TL before calling this function.
1997
1998 PARAMETERS
1999
2000 IN
2001 pvosGCtx: Pointer to the global vos context; a handle to TL's
2002 or WDA's control block can be extracted from its context
2003 IN
2004 ucSTAId The Station ID for Bssid to be updated
2005 IN
2006 pBssid BSSID to be updated
2007
2008 RETURN VALUE
2009 The result code associated with performing the operation
2010
2011 VOS_STATUS_E_INVAL: Input parameters are invalid
2012 VOS_STATUS_E_FAULT: Station ID is outside array boundaries or pointer to
2013 TL cb is NULL ; access would cause a page fault
2014 VOS_STATUS_E_EXISTS: Station was not registered
2015 VOS_STATUS_SUCCESS: Everything is good :)
2016
2017 SIDE EFFECTS
2018============================================================================*/
2019
2020
2021VOS_STATUS
2022WLANTL_UpdateSTABssIdforIBSS
2023(
2024 v_PVOID_t pvosGCtx,
2025 v_U8_t ucSTAId,
2026 v_U8_t *pBssid
2027)
2028{
2029 WLANTL_CbType* pTLCb = NULL;
2030 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
2031
2032 /*------------------------------------------------------------------------
2033 Sanity check
2034 ------------------------------------------------------------------------*/
2035 if ( WLANTL_STA_ID_INVALID( ucSTAId ) )
2036 {
2037 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2038 "WLAN TL:Invalid station id requested %s", __func__));
2039 return VOS_STATUS_E_FAULT;
2040 }
2041
2042 /*------------------------------------------------------------------------
2043 Extract TL control block and check existance
2044 ------------------------------------------------------------------------*/
2045 pTLCb = VOS_GET_TL_CB(pvosGCtx);
2046 if ( NULL == pTLCb )
2047 {
2048 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2049 "WLAN TL:Invalid TL pointer from pvosGCtx %s", __func__));
2050 return VOS_STATUS_E_FAULT;
2051 }
2052
2053 if ( NULL == pTLCb->atlSTAClients[ucSTAId] )
2054 {
2055 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2056 "WLAN TL:Client Memory was not allocated on %s", __func__));
2057 return VOS_STATUS_E_FAILURE;
2058 }
2059
2060 if ( 0 == pTLCb->atlSTAClients[ucSTAId]->ucExists )
2061 {
2062 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
2063 "WLAN TL:Station was not previously registered %s", __func__));
2064 return VOS_STATUS_E_EXISTS;
2065 }
2066
2067 /*------------------------------------------------------------------------
2068 Update the IBSS BSSID
2069 ------------------------------------------------------------------------*/
2070 vos_mem_copy( &pTLCb->atlSTAClients[ucSTAId]->wSTADesc.vBSSIDforIBSS,
2071 pBssid, sizeof(v_MACADDR_t));
2072
2073 return VOS_STATUS_SUCCESS;
2074}
2075
Madan Mohan Koyyalamudifc1d1fe2012-10-18 15:07:12 -07002076/*===========================================================================
2077
Jeff Johnson295189b2012-06-20 16:38:30 -07002078 FUNCTION WLANTL_STAPktPending
2079
2080 DESCRIPTION
2081
2082 HDD will call this API when a packet is pending transmission in its
2083 queues.
2084
2085 DEPENDENCIES
2086
2087 A station must have been registered before the packet pending
2088 notification can be sent.
2089
2090 RESTRICTION: TL will not count packets for pending notification.
2091 HDD is expected to send the notification only when
2092 non-empty event gets triggered. Worst case scenario
2093 is that TL might end up making a call when Hdds
2094 queues are actually empty.
2095
2096 PARAMETERS
2097
2098 pvosGCtx: pointer to the global vos context; a handle to TL's
2099 control block can be extracted from its context
2100 ucSTAId: identifier for the STA that is pending transmission
2101
2102 RETURN VALUE
2103
2104 The result code associated with performing the operation
2105
2106 VOS_STATUS_E_INVAL: Input parameters are invalid
2107 VOS_STATUS_E_FAULT: Station ID is outside array boundaries or pointer
2108 to TL cb is NULL ; access would cause a page fault
2109 VOS_STATUS_E_EXISTS: Station was not registered
2110 VOS_STATUS_SUCCESS: Everything is good :)
2111
2112 SIDE EFFECTS
2113
2114============================================================================*/
2115VOS_STATUS
2116WLANTL_STAPktPending
2117(
2118 v_PVOID_t pvosGCtx,
2119 v_U8_t ucSTAId,
2120 WLANTL_ACEnumType ucAc
2121)
2122{
2123 WLANTL_CbType* pTLCb = NULL;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302124 WLANTL_STAClientType* pClientSTA = NULL;
Nirav Shah4f765af2015-01-21 19:51:30 +05302125 v_U32_t uMgmtAvailRes = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002126 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
2127
2128 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
2129 "WLAN TL:Packet pending indication for STA: %d AC: %d", ucSTAId, ucAc);
2130
2131 /*------------------------------------------------------------------------
2132 Sanity check
2133 ------------------------------------------------------------------------*/
2134 if ( WLANTL_STA_ID_INVALID( ucSTAId ) )
2135 {
2136 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2137 "WLAN TL:Invalid station id requested on WLANTL_STAPktPending"));
2138 return VOS_STATUS_E_FAULT;
2139 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002140 /*------------------------------------------------------------------------
2141 Extract TL control block and check existance
2142 ------------------------------------------------------------------------*/
2143 pTLCb = VOS_GET_TL_CB(pvosGCtx);
2144 if ( NULL == pTLCb )
2145 {
2146 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2147 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_STAPktPending"));
2148 return VOS_STATUS_E_FAULT;
2149 }
2150
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302151 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
2152
2153 if ( NULL == pClientSTA )
2154 {
2155 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2156 "WLAN TL:Client Memory was not allocated on %s", __func__));
2157 return VOS_STATUS_E_FAILURE;
2158 }
2159
2160 if ( 0 == pClientSTA->ucExists )
Jeff Johnson295189b2012-06-20 16:38:30 -07002161 {
Katya Nigamb130d572014-11-24 16:38:16 +05302162 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07002163 "WLAN TL:Station was not previously registered on WLANTL_STAPktPending"));
2164 return VOS_STATUS_E_EXISTS;
2165 }
2166
2167 /*---------------------------------------------------------------------
2168 Temporary fix to enable TL to fetch packets when multiple peers join
2169 an IBSS. To fix CR177301. Needs to go away when the actual fix of
2170 going through all STA's in round robin fashion gets merged in from
2171 BT AMP branch.
2172 --------------------------------------------------------------------*/
2173 pTLCb->ucRegisteredStaId = ucSTAId;
2174
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302175 if( WLANTL_STA_CONNECTED == pClientSTA->tlState )
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -07002176 { /* EAPOL_HI_PRIORITY : need to find out whether EAPOL is pending before
2177 WLANTL_FetchPacket()/WLANTL_TxConn() is called.
2178 change STA_AUTHENTICATED != tlState to CONNECTED == tlState
2179 to make sure TL is indeed waiting for EAPOL.
2180 Just in the case when STA got disconnected shortly after connectection */
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302181 pClientSTA->ucEapolPktPending = 1;
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -07002182
Katya Nigam42e16e82014-02-04 16:28:55 +05302183 MTRACE(vos_trace(VOS_MODULE_ID_TL,
2184 TRACE_CODE_TL_EAPOL_PKT_PENDING, ucSTAId, ucAc));
2185
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -07002186 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07002187 "WLAN TL:Packet pending indication for STA: %d AC: %d State: %d",
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302188 ucSTAId, ucAc, pClientSTA->tlState);
Nirav Shah4f765af2015-01-21 19:51:30 +05302189
2190 uMgmtAvailRes = WDA_DS_GetAvailableResCount(pvosGCtx,
2191 WDI_MGMT_POOL_ID);
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07002192 }
2193
Jeff Johnson295189b2012-06-20 16:38:30 -07002194 /*-----------------------------------------------------------------------
2195 Enable this AC in the AC mask in order for TL to start servicing it
2196 Set packet pending flag
2197 To avoid race condition, serialize the updation of AC and AC mask
2198 through WLANTL_TX_STAID_AC_IND message.
2199 -----------------------------------------------------------------------*/
Jeff Johnson295189b2012-06-20 16:38:30 -07002200
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302201 pClientSTA->aucACMask[ucAc] = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07002202
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302203 vos_atomic_set_U8( &pClientSTA->ucPktPending, 1);
Jeff Johnson295189b2012-06-20 16:38:30 -07002204
Mihir Shete5d148f12014-12-16 17:54:49 +05302205 MTRACE(vos_trace(VOS_MODULE_ID_TL, TRACE_CODE_TL_STA_PKT_PENDING, ucSTAId,
2206 (pTLCb->ucTxSuspended << 31) |
2207 ((pTLCb->uResCount >= WDA_TLI_MIN_RES_DATA) << 30) |
2208 pClientSTA->tlState));
2209
Jeff Johnson295189b2012-06-20 16:38:30 -07002210 /*------------------------------------------------------------------------
2211 Check if there are enough resources for transmission and tx is not
2212 suspended.
2213 ------------------------------------------------------------------------*/
Nirav Shah4f765af2015-01-21 19:51:30 +05302214 if ((( pTLCb->uResCount >= WDA_TLI_MIN_RES_DATA ) &&
2215 ( 0 == pTLCb->ucTxSuspended )) ||
2216 (pClientSTA->ucEapolPktPending &&
2217 uMgmtAvailRes >= WDA_TLI_MIN_RES_MF))
Jeff Johnson295189b2012-06-20 16:38:30 -07002218 {
Katya Nigam42e16e82014-02-04 16:28:55 +05302219
Jeff Johnson295189b2012-06-20 16:38:30 -07002220 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
2221 "Issuing Xmit start request to BAL"));
2222 WDA_DS_StartXmit(pvosGCtx);
2223 }
2224 else
2225 {
2226 /*---------------------------------------------------------------------
2227 No error code is sent because TL will resume tx autonomously if
2228 resources become available or tx gets resumed
2229 ---------------------------------------------------------------------*/
Madan Mohan Koyyalamudi179e6fe2012-10-15 15:31:08 -07002230 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
Jeff Johnson295189b2012-06-20 16:38:30 -07002231 "WLAN TL:Request to send but condition not met. Res: %d,Suspend: %d",
Madan Mohan Koyyalamudi48139e32012-10-11 14:43:56 -07002232 pTLCb->uResCount, pTLCb->ucTxSuspended );
Jeff Johnson295189b2012-06-20 16:38:30 -07002233 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002234 return VOS_STATUS_SUCCESS;
2235}/* WLANTL_STAPktPending */
2236
2237/*==========================================================================
2238
2239 FUNCTION WLANTL_SetSTAPriority
2240
2241 DESCRIPTION
2242
2243 TL exposes this API to allow upper layers a rough control over the
2244 priority of transmission for a given station when supporting multiple
2245 connections.
2246
2247 DEPENDENCIES
2248
2249 A station must have been registered before the change in priority can be
2250 called.
2251
2252 PARAMETERS
2253
2254 pvosGCtx: pointer to the global vos context; a handle to TL's
2255 control block can be extracted from its context
2256 ucSTAId: identifier for the STA that has to change priority
2257
2258 RETURN VALUE
2259
2260 The result code associated with performing the operation
2261
2262 VOS_STATUS_E_INVAL: Input parameters are invalid
2263 VOS_STATUS_E_FAULT: Station ID is outside array boundaries or pointer
2264 to TL cb is NULL ; access would cause a page fault
2265 VOS_STATUS_E_EXISTS: Station was not registered
2266 VOS_STATUS_SUCCESS: Everything is good :)
2267
2268 SIDE EFFECTS
2269
2270============================================================================*/
2271VOS_STATUS
2272WLANTL_SetSTAPriority
2273(
2274 v_PVOID_t pvosGCtx,
2275 v_U8_t ucSTAId,
2276 WLANTL_STAPriorityType tlSTAPri
2277)
2278{
2279 WLANTL_CbType* pTLCb = NULL;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302280 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002281 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
2282
2283 /*------------------------------------------------------------------------
2284 Sanity check
2285 ------------------------------------------------------------------------*/
2286 if ( WLANTL_STA_ID_INVALID( ucSTAId ) )
2287 {
2288 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2289 "WLAN TL:Invalid station id requested on WLANTL_SetSTAPriority"));
2290 return VOS_STATUS_E_FAULT;
2291 }
2292
2293 /*------------------------------------------------------------------------
2294 Extract TL control block
2295 ------------------------------------------------------------------------*/
2296 pTLCb = VOS_GET_TL_CB(pvosGCtx);
2297 if ( NULL == pTLCb )
2298 {
2299 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2300 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_SetSTAPriority"));
2301 return VOS_STATUS_E_FAULT;
2302 }
2303
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302304 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
2305
2306 if ( NULL == pClientSTA )
2307 {
2308 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2309 "WLAN TL:Client Memory was not allocated on %s", __func__));
2310 return VOS_STATUS_E_FAILURE;
2311 }
2312
2313 if ( 0 == pClientSTA->ucExists )
Jeff Johnson295189b2012-06-20 16:38:30 -07002314 {
2315 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2316 "WLAN TL:Station was not previously registered on WLANTL_SetSTAPriority"));
2317 return VOS_STATUS_E_EXISTS;
2318 }
2319
2320 /*------------------------------------------------------------------------
2321 Re-analize if lock is needed when adding multiple stations
2322 ------------------------------------------------------------------------*/
2323 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
2324 "WLAN TL:Changing state for STA Pri ID: %d from %d to %d",
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302325 ucSTAId, pClientSTA->tlPri, tlSTAPri));
2326 pClientSTA->tlPri = tlSTAPri;
Jeff Johnson295189b2012-06-20 16:38:30 -07002327
2328 return VOS_STATUS_SUCCESS;
2329}/* WLANTL_SetSTAPriority */
2330
2331
2332/*----------------------------------------------------------------------------
2333 INTERACTION WITH BAP
2334 ---------------------------------------------------------------------------*/
2335
2336/*==========================================================================
2337
2338 FUNCTION WLANTL_RegisterBAPClient
2339
2340 DESCRIPTION
2341 Called by SME to register itself as client for non-data BT-AMP packets.
2342
2343 DEPENDENCIES
2344 TL must be initialized before this function can be called.
2345
2346 PARAMETERS
2347
2348 IN
2349 pvosGCtx: pointer to the global vos context; a handle to TL's
2350 or SME's control block can be extracted from its context
2351 pfnTlBAPRxFrm: pointer to the receive processing routine for non-data
2352 BT-AMP packets
2353 pfnFlushOpCompleteCb:
2354 pointer to the call back function, for the Flush operation
2355 completion.
2356
2357
2358 RETURN VALUE
2359
2360 The result code associated with performing the operation
2361
2362 VOS_STATUS_E_INVAL: Input parameters are invalid
2363 VOS_STATUS_E_FAULT: Station ID is outside array boundaries or pointer
2364 to TL cb is NULL ; access would cause a page fault
2365 VOS_STATUS_E_EXISTS: BAL client was already registered
2366 VOS_STATUS_SUCCESS: Everything is good :)
2367
2368 SIDE EFFECTS
2369
2370============================================================================*/
2371VOS_STATUS
2372WLANTL_RegisterBAPClient
2373(
2374 v_PVOID_t pvosGCtx,
2375 WLANTL_BAPRxCBType pfnTlBAPRxFrm,
2376 WLANTL_FlushOpCompCBType pfnFlushOpCompleteCb
2377)
2378{
2379 WLANTL_CbType* pTLCb = NULL;
2380 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
2381
2382 /*------------------------------------------------------------------------
2383 Sanity check
2384 ------------------------------------------------------------------------*/
2385 if ( NULL == pfnTlBAPRxFrm )
2386 {
2387 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2388 "WLAN TL:Invalid parameter sent on WLANTL_RegisterBAPClient"));
2389 return VOS_STATUS_E_INVAL;
2390 }
2391
2392 if ( NULL == pfnFlushOpCompleteCb )
2393 {
2394 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2395 "Invalid Flush Complete Cb parameter sent on WLANTL_RegisterBAPClient"));
2396 return VOS_STATUS_E_INVAL;
2397 }
2398
2399 /*------------------------------------------------------------------------
2400 Extract TL control block
2401 ------------------------------------------------------------------------*/
2402 pTLCb = VOS_GET_TL_CB(pvosGCtx);
2403 if ( NULL == pTLCb )
2404 {
2405 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2406 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_RegisterBAPClient"));
2407 return VOS_STATUS_E_FAULT;
2408 }
2409
2410 /*------------------------------------------------------------------------
2411 Make sure this is the first registration attempt
2412 ------------------------------------------------------------------------*/
2413 if ( 0 != pTLCb->tlBAPClient.ucExists )
2414 {
2415 pTLCb->tlBAPClient.ucExists++;
2416 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2417 "WLAN TL:BAP client was already registered"));
2418 return VOS_STATUS_E_EXISTS;
2419 }
2420
2421 /*------------------------------------------------------------------------
2422 Register station with TL
2423 ------------------------------------------------------------------------*/
2424 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
2425 "WLAN TL:Registering BAP Client" ));
2426
2427 pTLCb->tlBAPClient.ucExists++;
2428
2429 if ( NULL != pfnTlBAPRxFrm )
2430 {
2431 pTLCb->tlBAPClient.pfnTlBAPRx = pfnTlBAPRxFrm;
2432 }
2433
2434 pTLCb->tlBAPClient.pfnFlushOpCompleteCb = pfnFlushOpCompleteCb;
2435
2436 pTLCb->tlBAPClient.vosPendingDataBuff = NULL;
2437
2438 return VOS_STATUS_SUCCESS;
2439}/* WLANTL_RegisterBAPClient */
2440
2441
2442/*==========================================================================
2443
2444 FUNCTION WLANTL_TxBAPFrm
2445
2446 DESCRIPTION
2447 BAP calls this when it wants to send a frame to the module
2448
2449 DEPENDENCIES
2450 BAP must be registered with TL before this function can be called.
2451
2452 RESTRICTION: BAP CANNOT push any packets to TL until it did not receive
2453 a tx complete from the previous packet, that means BAP
2454 sends one packet, wait for tx complete and then
2455 sends another one
2456
2457 If BAP sends another packet before TL manages to process the
2458 previously sent packet call will end in failure
2459
2460 PARAMETERS
2461
2462 IN
2463 pvosGCtx: pointer to the global vos context; a handle to TL's
2464 or BAP's control block can be extracted from its context
2465 vosDataBuff: pointer to the vOSS buffer containing the packet to be
2466 transmitted
2467 pMetaInfo: meta information about the packet
2468 pfnTlBAPTxComp: pointer to a transmit complete routine for notifying
2469 the result of the operation over the bus
2470
2471 RETURN VALUE
2472 The result code associated with performing the operation
2473
2474 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
2475 page fault
2476 VOS_STATUS_E_EXISTS: BAL client was not yet registered
2477 VOS_STATUS_E_BUSY: The previous BT-AMP packet was not yet transmitted
2478 VOS_STATUS_SUCCESS: Everything is good :)
2479
2480 Other failure messages may be returned from the BD header handling
2481 routines, please check apropriate API for more info.
2482
2483 SIDE EFFECTS
2484
2485============================================================================*/
2486VOS_STATUS
2487WLANTL_TxBAPFrm
2488(
2489 v_PVOID_t pvosGCtx,
2490 vos_pkt_t* vosDataBuff,
2491 WLANTL_MetaInfoType* pMetaInfo,
2492 WLANTL_TxCompCBType pfnTlBAPTxComp
2493)
2494{
2495 WLANTL_CbType* pTLCb = NULL;
2496 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
2497 v_MACADDR_t vDestMacAddr;
2498 v_U16_t usPktLen;
2499 v_U8_t ucStaId = 0;
2500 v_U8_t extraHeadSpace = 0;
2501 v_U8_t ucWDSEnabled = 0;
2502 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
2503
2504 /*------------------------------------------------------------------------
2505 Sanity check
2506 Extract TL control block
2507 ------------------------------------------------------------------------*/
2508 pTLCb = VOS_GET_TL_CB(pvosGCtx);
2509 if ( NULL == pTLCb )
2510 {
2511 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2512 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_TxBAPFrm"));
2513 return VOS_STATUS_E_FAULT;
2514 }
2515
2516 /*------------------------------------------------------------------------
2517 Ensure that BAP client was registered previously
2518 ------------------------------------------------------------------------*/
2519 if (( 0 == pTLCb->tlBAPClient.ucExists ) ||
2520 ( WLANTL_STA_ID_INVALID(pTLCb->tlBAPClient.ucBAPSTAId) ))
2521 {
2522 pTLCb->tlBAPClient.ucExists++;
2523 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2524 "WLAN TL:BAP client not register on WLANTL_TxBAPFrm"));
2525 return VOS_STATUS_E_EXISTS;
2526 }
2527
2528 /*------------------------------------------------------------------------
2529 Check if any BT-AMP Frm is pending
2530 ------------------------------------------------------------------------*/
2531 if ( NULL != pTLCb->tlBAPClient.vosPendingDataBuff )
2532 {
2533 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2534 "WLAN TL:BT-AMP Frame already pending tx in TL on WLANTL_TxBAPFrm"));
2535 return VOS_STATUS_E_BUSY;
2536 }
2537
2538 /*------------------------------------------------------------------------
2539 Save buffer and notify BAL; no lock is needed if the above restriction
2540 is met
2541 Save the tx complete fnct pointer as tl specific data in the vos buffer
2542 ------------------------------------------------------------------------*/
2543
2544 /*------------------------------------------------------------------------
2545 Translate 802.3 frame to 802.11
2546 ------------------------------------------------------------------------*/
2547 ucStaId = pTLCb->tlBAPClient.ucBAPSTAId;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302548 if ( NULL == pTLCb->atlSTAClients[ucStaId] )
2549 {
2550 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2551 "WLAN TL:Client Memory was not allocated on %s", __func__));
2552 return VOS_STATUS_E_FAILURE;
2553 }
2554 if (( 0 == pMetaInfo->ucDisableFrmXtl ) &&
2555 ( 0 != pTLCb->atlSTAClients[ucStaId]->wSTADesc.ucSwFrameTXXlation ))
Jeff Johnson295189b2012-06-20 16:38:30 -07002556 {
Kiran Venkatappacab0d352012-12-17 13:09:22 -08002557 vosStatus = WLANTL_Translate8023To80211Header( vosDataBuff, &vosStatus,
2558 pTLCb, &ucStaId,
Ravi Joshid0699502013-07-08 15:48:47 -07002559 pMetaInfo, &ucWDSEnabled,
2560 &extraHeadSpace);
Jeff Johnson295189b2012-06-20 16:38:30 -07002561
2562 if ( VOS_STATUS_SUCCESS != vosStatus )
2563 {
2564 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2565 "WLAN TL:Error when translating header WLANTL_TxBAPFrm"));
2566
2567 return vosStatus;
2568 }
2569
2570 pMetaInfo->ucDisableFrmXtl = 1;
2571 }
2572
2573 /*-------------------------------------------------------------------------
2574 Call HAL to fill BD header
2575 -------------------------------------------------------------------------*/
2576
2577 /* Adding Type, SubType which was missing for EAPOL from BAP */
2578 pMetaInfo->ucType |= (WLANTL_80211_DATA_TYPE << 4);
2579 pMetaInfo->ucType |= (WLANTL_80211_DATA_QOS_SUBTYPE);
2580
2581 vosStatus = WDA_DS_BuildTxPacketInfo( pvosGCtx, vosDataBuff ,
2582 &vDestMacAddr, pMetaInfo->ucDisableFrmXtl,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302583 &usPktLen, pTLCb->atlSTAClients[ucStaId]->wSTADesc.ucQosEnabled,
Jeff Johnson295189b2012-06-20 16:38:30 -07002584 ucWDSEnabled, extraHeadSpace, pMetaInfo->ucType,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302585 &pTLCb->atlSTAClients[ucStaId]->wSTADesc.vSelfMACAddress,
Jeff Johnson295189b2012-06-20 16:38:30 -07002586 pMetaInfo->ucTID, 0 /* No ACK */, pMetaInfo->usTimeStamp,
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -07002587 pMetaInfo->ucIsEapol || pMetaInfo->ucIsWai, pMetaInfo->ucUP );
Jeff Johnson295189b2012-06-20 16:38:30 -07002588
2589 if ( VOS_STATUS_SUCCESS != vosStatus )
2590 {
2591 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2592 "WLAN TL:Failed while building TX header %d", vosStatus));
2593 return vosStatus;
2594 }
2595
2596 if ( NULL != pfnTlBAPTxComp )
2597 {
2598 vos_pkt_set_user_data_ptr( vosDataBuff, VOS_PKT_USER_DATA_ID_TL,
2599 (v_PVOID_t)pfnTlBAPTxComp);
2600 }
2601 else
2602 {
2603 vos_pkt_set_user_data_ptr( vosDataBuff, VOS_PKT_USER_DATA_ID_TL,
2604 (v_PVOID_t)WLANTL_TxCompDefaultCb);
2605
2606 }
2607
Arun Kumar Khandavalli0af8d3c2014-02-07 18:05:11 +05302608 vos_atomic_set( (uintptr_t*)&pTLCb->tlBAPClient.vosPendingDataBuff,
2609 (uintptr_t)vosDataBuff);
Jeff Johnson295189b2012-06-20 16:38:30 -07002610
2611 /*------------------------------------------------------------------------
2612 Check if thre are enough resources for transmission and tx is not
2613 suspended.
2614 ------------------------------------------------------------------------*/
2615 if (( pTLCb->uResCount >= WDA_TLI_MIN_RES_BAP ) &&
2616 ( 0 == pTLCb->ucTxSuspended ))
2617 {
2618 WDA_DS_StartXmit(pvosGCtx);
2619 }
2620 else
2621 {
2622 /*---------------------------------------------------------------------
2623 No error code is sent because TL will resume tx autonomously if
2624 resources become available or tx gets resumed
2625 ---------------------------------------------------------------------*/
2626 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
2627 "WLAN TL:Request to send from BAP but condition not met.Res: %d,"
2628 "Suspend: %d", pTLCb->uResCount, pTLCb->ucTxSuspended ));
2629 }
2630
2631 return VOS_STATUS_SUCCESS;
2632}/* WLANTL_TxBAPFrm */
2633
2634
2635/*----------------------------------------------------------------------------
2636 INTERACTION WITH SME
2637 ---------------------------------------------------------------------------*/
2638
2639/*==========================================================================
2640
2641 FUNCTION WLANTL_GetRssi
2642
2643 DESCRIPTION
2644 TL will extract the RSSI information from every data packet from the
2645 ongoing traffic and will store it. It will provide the result to SME
2646 upon request.
2647
2648 DEPENDENCIES
2649
2650 WARNING: the read and write of this value will not be protected
2651 by locks, therefore the information obtained after a read
2652 might not always be consistent.
2653
2654 PARAMETERS
2655
2656 IN
2657 pvosGCtx: pointer to the global vos context; a handle to TL's
2658 or SME's control block can be extracted from its context
2659 ucSTAId: station identifier for the requested value
2660
2661 OUT
2662 puRssi: the average value of the RSSI
2663
2664
2665 RETURN VALUE
2666 The result code associated with performing the operation
2667
2668 VOS_STATUS_E_INVAL: Input parameters are invalid
2669 VOS_STATUS_E_FAULT: Station ID is outside array boundaries or pointer
2670 to TL cb is NULL ; access would cause a page fault
2671 VOS_STATUS_E_EXISTS: STA was not yet registered
2672 VOS_STATUS_SUCCESS: Everything is good :)
2673
2674 SIDE EFFECTS
2675
2676============================================================================*/
2677VOS_STATUS
2678WLANTL_GetRssi
2679(
2680 v_PVOID_t pvosGCtx,
2681 v_U8_t ucSTAId,
2682 v_S7_t* pRssi
2683)
2684{
2685 WLANTL_CbType* pTLCb = NULL;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302686 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002687 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
2688
2689 /*------------------------------------------------------------------------
2690 Sanity check
2691 ------------------------------------------------------------------------*/
2692 if ( NULL == pRssi )
2693 {
2694 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2695 "WLAN TL:Invalid parameter sent on WLANTL_GetRssi"));
2696 return VOS_STATUS_E_INVAL;
2697 }
2698
2699 if ( WLANTL_STA_ID_INVALID( ucSTAId ) )
2700 {
2701 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2702 "WLAN TL:Invalid station id requested on WLANTL_GetRssi"));
2703 return VOS_STATUS_E_FAULT;
2704 }
2705
2706 /*------------------------------------------------------------------------
2707 Extract TL control block and check existance
2708 ------------------------------------------------------------------------*/
2709 pTLCb = VOS_GET_TL_CB(pvosGCtx);
2710 if ( NULL == pTLCb )
2711 {
2712 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2713 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_GetRssi"));
2714 return VOS_STATUS_E_FAULT;
2715 }
2716
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302717 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
2718
2719 if ( NULL == pClientSTA )
2720 {
2721 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2722 "WLAN TL:Client Memory was not allocated on %s", __func__));
2723 return VOS_STATUS_E_FAILURE;
2724 }
2725
2726 if ( 0 == pClientSTA->ucExists )
Jeff Johnson295189b2012-06-20 16:38:30 -07002727 {
2728 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2729 "WLAN TL:Station was not previously registered on WLANTL_GetRssi"));
2730 return VOS_STATUS_E_EXISTS;
2731 }
2732
2733 /*------------------------------------------------------------------------
2734 Copy will not be locked; please read restriction
2735 ------------------------------------------------------------------------*/
Katya Nigam5c2e5f62013-11-15 19:19:11 +05302736 if(pTLCb->isBMPS || IS_ACTIVEMODE_OFFLOAD_FEATURE_ENABLE)
Jeff Johnson295189b2012-06-20 16:38:30 -07002737 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302738 *pRssi = pClientSTA->rssiAvgBmps;
Jeff Johnson295189b2012-06-20 16:38:30 -07002739 /* Check If RSSI is zero because we are reading rssAvgBmps updated by HAL in
2740 previous GetStatsRequest. It may be updated as zero by Hal because EnterBmps
2741 might not have happend by that time. Hence reading the most recent Rssi
2742 calcluated by TL*/
2743 if(0 == *pRssi)
2744 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302745 *pRssi = pClientSTA->rssiAvg;
Jeff Johnson295189b2012-06-20 16:38:30 -07002746 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002747 }
2748 else
2749 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302750 *pRssi = pClientSTA->rssiAvg;
Jeff Johnson295189b2012-06-20 16:38:30 -07002751 }
2752
2753 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
Jeff Johnson32d95a32012-09-10 13:15:23 -07002754 "WLAN TL:WLANTL_GetRssi for STA: %d RSSI: %d%s",
2755 ucSTAId, *pRssi,
2756 pTLCb->isBMPS ? " in BMPS" : ""));
Jeff Johnson295189b2012-06-20 16:38:30 -07002757
2758 return VOS_STATUS_SUCCESS;
2759}/* WLANTL_GetRssi */
2760
2761/*==========================================================================
2762
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05302763 FUNCTION WLANTL_GetSnr
2764
2765 DESCRIPTION
2766 TL will extract the SNR information from every data packet from the
2767 ongoing traffic and will store it. It will provide the result to SME
2768 upon request.
2769
2770 DEPENDENCIES
2771
2772 WARNING: the read and write of this value will not be protected
2773 by locks, therefore the information obtained after a read
2774 might not always be consistent.
2775
2776 PARAMETERS
2777
2778 IN
2779 pvosGCtx: pointer to the global vos context; a handle to TL's
2780 or SME's control block can be extracted from its context
2781 ucSTAId: station identifier for the requested value
2782
2783 OUT
2784 pSnr: the average value of the SNR
2785
2786
2787 RETURN VALUE
2788 The result code associated with performing the operation
2789
2790 VOS_STATUS_E_INVAL: Input parameters are invalid
2791 VOS_STATUS_E_FAULT: Station ID is outside array boundaries or pointer
2792 to TL cb is NULL ; access would cause a page fault
2793 VOS_STATUS_E_EXISTS: STA was not yet registered
2794 VOS_STATUS_SUCCESS: Everything is good :)
2795
2796 SIDE EFFECTS
2797
2798============================================================================*/
2799VOS_STATUS
2800WLANTL_GetSnr
2801(
2802 tANI_U8 ucSTAId,
2803 tANI_S8* pSnr
2804)
2805{
2806 WLANTL_CbType* pTLCb = NULL;
2807 WLANTL_STAClientType* pClientSTA = NULL;
2808 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
2809
2810 /*------------------------------------------------------------------------
2811 Sanity check
2812 ------------------------------------------------------------------------*/
2813 if (NULL == pSnr)
2814 {
2815 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2816 "WLAN TL:Invalid parameter sent on %s", __func__));
2817 return VOS_STATUS_E_INVAL;
2818 }
2819
2820 if (WLANTL_STA_ID_INVALID(ucSTAId))
2821 {
2822 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2823 "WLAN TL:Invalid station id requested on %s", __func__));
2824 return VOS_STATUS_E_FAULT;
2825 }
2826
2827 /*------------------------------------------------------------------------
2828 Extract TL control block and check existance
2829 ------------------------------------------------------------------------*/
2830 pTLCb = VOS_GET_TL_CB(vos_get_global_context(VOS_MODULE_ID_TL, NULL));
2831 if (NULL == pTLCb)
2832 {
2833 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2834 "WLAN TL:Invalid TL pointer from pvosGCtx on %s", __func__));
2835 return VOS_STATUS_E_FAULT;
2836 }
2837
2838 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
2839
2840 if (NULL == pClientSTA)
2841 {
2842 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2843 "WLAN TL:Client Memory was not allocated on %s", __func__));
2844 return VOS_STATUS_E_FAILURE;
2845 }
2846
2847 if (0 == pClientSTA->ucExists)
2848 {
2849 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2850 "WLAN TL:Station was not previously registered on %s", __func__));
2851 return VOS_STATUS_E_EXISTS;
2852 }
2853
2854 /*------------------------------------------------------------------------
2855 Copy will not be locked; please read restriction
2856 ------------------------------------------------------------------------*/
2857 if (pTLCb->isBMPS)
2858 {
2859 *pSnr = pClientSTA->snrAvgBmps;
2860 }
2861 else
2862 {
2863 /* SNR is averaged over WLANTL_MAX_SNR_DATA_SAMPLES, if there are not enough
2864 * data samples (snridx) to calculate the average then return the
2865 * average for the window of prevoius 20 packets. And if there aren't
2866 * enough samples and the average for previous window of 20 packets is
2867 * not available then return a predefined value
2868 *
2869 * NOTE: the SNR_HACK_BMPS value is defined to 127, documents from HW
2870 * team reveal that the SNR value has a ceiling well below 127 dBm,
2871 * so if SNR has value of 127 the userspace applications can know that
2872 * the SNR has not been computed yet because enough data was not
2873 * available for SNR calculation
2874 */
2875 if (pClientSTA->snrIdx > (WLANTL_MAX_SNR_DATA_SAMPLES/2)
2876 || !(pClientSTA->prevSnrAvg))
2877 {
2878 *pSnr = pClientSTA->snrSum / pClientSTA->snrIdx;
2879 }
2880 else if (pClientSTA->prevSnrAvg)
2881 {
2882 *pSnr = pClientSTA->prevSnrAvg;
2883 }
2884 else
2885 {
2886 *pSnr = SNR_HACK_BMPS;
2887 }
2888 }
2889
2890 VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
2891 "WLAN TL:WLANTL_GetSnr for STA: %d SNR: %d%s",
2892 ucSTAId, *pSnr,
2893 pTLCb->isBMPS ? " in BMPS" : "");
2894
2895 return VOS_STATUS_SUCCESS;
2896}/* WLANTL_GetSnr */
2897/*==========================================================================
2898
Jeff Johnson295189b2012-06-20 16:38:30 -07002899 FUNCTION WLANTL_GetLinkQuality
2900
2901 DESCRIPTION
2902 TL will extract the SNR information from every data packet from the
2903 ongoing traffic and will store it. It will provide the result to SME
2904 upon request.
2905
2906 DEPENDENCIES
2907
2908 WARNING: the read and write of this value will not be protected
2909 by locks, therefore the information obtained after a read
2910 might not always be consistent.
2911
2912 PARAMETERS
2913
2914 IN
2915 pvosGCtx: pointer to the global vos context; a handle to TL's
2916 or SME's control block can be extracted from its context
2917 ucSTAId: station identifier for the requested value
2918
2919 OUT
2920 puLinkQuality: the average value of the SNR
2921
2922
2923 RETURN VALUE
2924 The result code associated with performing the operation
2925
2926 VOS_STATUS_E_INVAL: Input parameters are invalid
2927 VOS_STATUS_E_FAULT: Station ID is outside array boundaries or pointer
2928 to TL cb is NULL ; access would cause a page fault
2929 VOS_STATUS_E_EXISTS: STA was not yet registered
2930 VOS_STATUS_SUCCESS: Everything is good :)
2931
2932 SIDE EFFECTS
2933
2934============================================================================*/
2935VOS_STATUS
2936WLANTL_GetLinkQuality
2937(
2938 v_PVOID_t pvosGCtx,
2939 v_U8_t ucSTAId,
2940 v_U32_t* puLinkQuality
2941)
2942{
2943 WLANTL_CbType* pTLCb = NULL;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302944 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002945
2946 /*------------------------------------------------------------------------
2947 Sanity check
2948 ------------------------------------------------------------------------*/
2949 if ( NULL == puLinkQuality )
2950 {
2951 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2952 "Invalid parameter sent on WLANTL_GetLinkQuality"));
2953 return VOS_STATUS_E_INVAL;
2954 }
2955
2956 if ( WLANTL_STA_ID_INVALID( ucSTAId ) )
2957 {
2958 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2959 "Invalid station id requested on WLANTL_GetLinkQuality"));
2960 return VOS_STATUS_E_FAULT;
2961 }
2962
2963 /*------------------------------------------------------------------------
2964 Extract TL control block and check existance
2965 ------------------------------------------------------------------------*/
2966 pTLCb = VOS_GET_TL_CB(pvosGCtx);
2967 if ( NULL == pTLCb )
2968 {
2969 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2970 "Invalid TL pointer from pvosGCtx on WLANTL_GetLinkQuality"));
2971 return VOS_STATUS_E_FAULT;
2972 }
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302973 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
Jeff Johnson295189b2012-06-20 16:38:30 -07002974
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302975 if ( NULL == pClientSTA )
2976 {
2977 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2978 "WLAN TL:Client Memory was not allocated on %s", __func__));
2979 return VOS_STATUS_E_FAILURE;
2980 }
2981
2982 if ( 0 == pClientSTA->ucExists )
Jeff Johnson295189b2012-06-20 16:38:30 -07002983 {
2984 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2985 "Station was not previously registered on WLANTL_GetLinkQuality"));
2986 return VOS_STATUS_E_EXISTS;
2987 }
2988
2989 /*------------------------------------------------------------------------
2990 Copy will not be locked; please read restriction
2991 ------------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302992 *puLinkQuality = pClientSTA->uLinkQualityAvg;
Jeff Johnson295189b2012-06-20 16:38:30 -07002993
2994 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
2995 "WLANTL_GetLinkQuality for STA: %d LinkQuality: %d", ucSTAId, *puLinkQuality));
2996
2997 return VOS_STATUS_SUCCESS;
2998}/* WLANTL_GetLinkQuality */
2999
3000/*==========================================================================
3001
3002 FUNCTION WLANTL_FlushStaTID
3003
3004 DESCRIPTION
3005 TL provides this API as an interface to SME (BAP) layer. TL inturn posts a
3006 message to HAL. This API is called by the SME inorder to perform a flush
3007 operation.
3008
3009 DEPENDENCIES
3010
3011 PARAMETERS
3012
3013 IN
3014 pvosGCtx: pointer to the global vos context; a handle to TL's
3015 or SME's control block can be extracted from its context
3016 ucSTAId: station identifier for the requested value
3017 ucTid: Tspec ID for the new BA session
3018
3019 OUT
3020 The response for this post is received in the main thread, via a response
3021 message from HAL to TL.
3022
3023 RETURN VALUE
3024 VOS_STATUS_SUCCESS: Everything is good :)
3025
3026 SIDE EFFECTS
3027============================================================================*/
3028VOS_STATUS
3029WLANTL_FlushStaTID
3030(
3031 v_PVOID_t pvosGCtx,
3032 v_U8_t ucSTAId,
3033 v_U8_t ucTid
3034)
3035{
3036 WLANTL_CbType* pTLCb = NULL;
3037 tpFlushACReq FlushACReqPtr = NULL;
3038 vos_msg_t vosMessage;
3039
3040
3041 if ( WLANTL_STA_ID_INVALID( ucSTAId ) )
3042 {
3043 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3044 "Invalid station id requested on WLANTL_FlushStaTID"));
3045 return VOS_STATUS_E_FAULT;
3046 }
3047
3048 /*------------------------------------------------------------------------
3049 Extract TL control block and check existance
3050 ------------------------------------------------------------------------*/
3051 pTLCb = VOS_GET_TL_CB(pvosGCtx);
3052 if ( NULL == pTLCb )
3053 {
3054 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3055 "Invalid TL pointer from pvosGCtx on WLANTL_FlushStaTID"));
3056 return VOS_STATUS_E_FAULT;
3057 }
3058
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05303059 if ( NULL == pTLCb->atlSTAClients[ucSTAId] )
3060 {
3061 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3062 "WLAN TL:Client Memory was not allocated on %s", __func__));
3063 return VOS_STATUS_E_FAILURE;
3064 }
3065
3066 if ( 0 == pTLCb->atlSTAClients[ucSTAId]->ucExists )
Jeff Johnson295189b2012-06-20 16:38:30 -07003067 {
3068 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3069 "Station was not previously registered on WLANTL_FlushStaTID"));
3070 return VOS_STATUS_E_EXISTS;
3071 }
3072
3073 /*------------------------------------------------------------------------
3074 We need to post a message with the STA, TID value to HAL. HAL performs the flush
3075 ------------------------------------------------------------------------*/
3076 FlushACReqPtr = vos_mem_malloc(sizeof(tFlushACReq));
3077
3078 if ( NULL == FlushACReqPtr )
3079 {
3080 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3081 "WLAN TL: fatal failure, cannot allocate Flush Req structure"));
3082 VOS_ASSERT(0);
3083 return VOS_STATUS_E_NOMEM;
3084 }
3085
3086 // Start constructing the message for HAL
3087 FlushACReqPtr->mesgType = SIR_TL_HAL_FLUSH_AC_REQ;
3088 FlushACReqPtr->mesgLen = sizeof(tFlushACReq);
3089 FlushACReqPtr->mesgLen = sizeof(tFlushACReq);
3090 FlushACReqPtr->ucSTAId = ucSTAId;
3091 FlushACReqPtr->ucTid = ucTid;
3092
3093 vosMessage.type = WDA_TL_FLUSH_AC_REQ;
3094 vosMessage.bodyptr = (void *)FlushACReqPtr;
3095
3096 vos_mq_post_message(VOS_MQ_ID_WDA, &vosMessage);
3097 return VOS_STATUS_SUCCESS;
3098}
3099
3100
3101/*----------------------------------------------------------------------------
3102 INTERACTION WITH PE
3103 ---------------------------------------------------------------------------*/
Siddharth Bhal4551b102014-10-09 21:36:36 +05303104/*==========================================================================
Jeff Johnson295189b2012-06-20 16:38:30 -07003105
Siddharth Bhal4551b102014-10-09 21:36:36 +05303106 FUNCTION WLANTL_updateSpoofMacAddr
3107
3108 DESCRIPTION
3109 Called by HDD to update macaddr
3110
3111 DEPENDENCIES
3112 TL must be initialized before this API can be called.
3113
3114 PARAMETERS
3115
3116 IN
3117 pvosGCtx: pointer to the global vos context; a handle to
3118 TL's control block can be extracted from its context
3119 spoofMacAddr: spoofed mac adderess
3120 selfMacAddr: self Mac Address
3121
3122 RETURN VALUE
3123 The result code associated with performing the operation
3124
3125 VOS_STATUS_E_INVAL: Input parameters are invalid
3126 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
3127 page fault
3128 VOS_STATUS_SUCCESS: Everything is good :)
3129
3130 SIDE EFFECTS
3131
3132============================================================================*/
3133VOS_STATUS
3134WLANTL_updateSpoofMacAddr
3135(
3136 v_PVOID_t pvosGCtx,
3137 v_MACADDR_t* spoofMacAddr,
3138 v_MACADDR_t* selfMacAddr
3139)
3140{
3141 WLANTL_CbType* pTLCb = NULL;
3142 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
3143
3144 /*------------------------------------------------------------------------
3145 Sanity check
3146 ------------------------------------------------------------------------*/
3147 if ( NULL == spoofMacAddr || NULL == selfMacAddr)
3148 {
3149 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3150 "WLAN TL:Invalid parameter sent on WLANTL_updateSpoofMacAddr");
3151 return VOS_STATUS_E_INVAL;
3152 }
3153
3154 /*------------------------------------------------------------------------
3155 Extract TL control block
3156 ------------------------------------------------------------------------*/
3157 pTLCb = VOS_GET_TL_CB(pvosGCtx);
3158 if ( NULL == pTLCb )
3159 {
3160 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3161 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_ChangeSTAState");
3162 return VOS_STATUS_E_FAULT;
3163 }
3164
3165 vos_mem_copy(pTLCb->spoofMacAddr.selfMac.bytes, selfMacAddr,
3166 VOS_MAC_ADDRESS_LEN);
3167 vos_mem_copy(pTLCb->spoofMacAddr.spoofMac.bytes, spoofMacAddr,
3168 VOS_MAC_ADDRESS_LEN);
3169
3170 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_LOW,
3171 "TL: SelfSTA mac Addr for current Scan "MAC_ADDRESS_STR,
3172 MAC_ADDR_ARRAY(pTLCb->spoofMacAddr.selfMac.bytes));
3173
3174 return VOS_STATUS_SUCCESS;
3175}/* WLANTL_updateSpoofMacAddr */
Jeff Johnson295189b2012-06-20 16:38:30 -07003176/*==========================================================================
3177
3178 FUNCTION WLANTL_RegisterMgmtFrmClient
3179
3180 DESCRIPTION
3181 Called by PE to register as a client for management frames delivery.
3182
3183 DEPENDENCIES
3184 TL must be initialized before this API can be called.
3185
3186 PARAMETERS
3187
3188 IN
3189 pvosGCtx: pointer to the global vos context; a handle to
3190 TL's control block can be extracted from its context
3191 pfnTlMgmtFrmRx: pointer to the receive processing routine for
3192 management frames
3193
3194 RETURN VALUE
3195 The result code associated with performing the operation
3196
3197 VOS_STATUS_E_INVAL: Input parameters are invalid
3198 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
3199 page fault
3200 VOS_STATUS_E_EXISTS: Mgmt Frame client was already registered
3201 VOS_STATUS_SUCCESS: Everything is good :)
3202
3203 SIDE EFFECTS
3204
3205============================================================================*/
3206VOS_STATUS
3207WLANTL_RegisterMgmtFrmClient
3208(
3209 v_PVOID_t pvosGCtx,
3210 WLANTL_MgmtFrmRxCBType pfnTlMgmtFrmRx
3211)
3212{
3213 WLANTL_CbType* pTLCb = NULL;
3214 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
3215
3216 /*------------------------------------------------------------------------
3217 Sanity check
3218 ------------------------------------------------------------------------*/
3219 if ( NULL == pfnTlMgmtFrmRx )
3220 {
3221 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3222 "WLAN TL:Invalid parameter sent on WLANTL_RegisterMgmtFrmClient"));
3223 return VOS_STATUS_E_INVAL;
3224 }
3225
3226 /*------------------------------------------------------------------------
3227 Extract TL control block
3228 ------------------------------------------------------------------------*/
3229 pTLCb = VOS_GET_TL_CB(pvosGCtx);
3230 if ( NULL == pTLCb )
3231 {
3232 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3233 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_ChangeSTAState"));
3234 return VOS_STATUS_E_FAULT;
3235 }
3236
3237 /*------------------------------------------------------------------------
3238 Make sure this is the first registration attempt
3239 ------------------------------------------------------------------------*/
3240 if ( 0 != pTLCb->tlMgmtFrmClient.ucExists )
3241 {
3242 pTLCb->tlMgmtFrmClient.ucExists++;
3243 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3244 "WLAN TL:Management frame client was already registered"));
3245 return VOS_STATUS_E_EXISTS;
3246 }
3247
3248 /*------------------------------------------------------------------------
3249 Register station with TL
3250 ------------------------------------------------------------------------*/
3251 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
3252 "WLAN TL:Registering Management Frame Client" ));
3253
3254 pTLCb->tlMgmtFrmClient.ucExists++;
3255
3256 if ( NULL != pfnTlMgmtFrmRx )
3257 {
3258 pTLCb->tlMgmtFrmClient.pfnTlMgmtFrmRx = pfnTlMgmtFrmRx;
3259 }
3260
3261 pTLCb->tlMgmtFrmClient.vosPendingDataBuff = NULL;
3262
3263 return VOS_STATUS_SUCCESS;
3264}/* WLANTL_RegisterMgmtFrmClient */
3265
3266/*==========================================================================
3267
3268 FUNCTION WLANTL_DeRegisterMgmtFrmClient
3269
3270 DESCRIPTION
3271 Called by PE to deregister as a client for management frames delivery.
3272
3273 DEPENDENCIES
3274 TL must be initialized before this API can be called.
3275
3276 PARAMETERS
3277
3278 IN
3279 pvosGCtx: pointer to the global vos context; a handle to
3280 TL's control block can be extracted from its context
3281 RETURN VALUE
3282 The result code associated with performing the operation
3283
3284 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
3285 page fault
3286 VOS_STATUS_E_EXISTS: Mgmt Frame client was never registered
3287 VOS_STATUS_SUCCESS: Everything is good :)
3288
3289 SIDE EFFECTS
3290
3291============================================================================*/
3292VOS_STATUS
3293WLANTL_DeRegisterMgmtFrmClient
3294(
3295 v_PVOID_t pvosGCtx
3296)
3297{
3298 WLANTL_CbType* pTLCb = NULL;
3299 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
3300
3301 /*------------------------------------------------------------------------
3302 Extract TL control block
3303 ------------------------------------------------------------------------*/
3304 pTLCb = VOS_GET_TL_CB(pvosGCtx);
3305 if ( NULL == pTLCb )
3306 {
3307 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3308 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_ChangeSTAState"));
3309 return VOS_STATUS_E_FAULT;
3310 }
3311
3312 /*------------------------------------------------------------------------
3313 Make sure this is the first registration attempt
3314 ------------------------------------------------------------------------*/
3315 if ( 0 == pTLCb->tlMgmtFrmClient.ucExists )
3316 {
3317 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3318 "WLAN TL:Management frame client was never registered"));
3319 return VOS_STATUS_E_EXISTS;
3320 }
3321
3322 /*------------------------------------------------------------------------
3323 Clear registration with TL
3324 ------------------------------------------------------------------------*/
3325 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
3326 "WLAN TL:Deregistering Management Frame Client" ));
3327
3328 pTLCb->tlMgmtFrmClient.pfnTlMgmtFrmRx = WLANTL_MgmtFrmRxDefaultCb;
3329 if ( NULL != pTLCb->tlMgmtFrmClient.vosPendingDataBuff)
3330 {
3331 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
3332 "WLAN TL:Management cache buffer not empty on deregistering"
3333 " - dropping packet" ));
3334 vos_pkt_return_packet(pTLCb->tlMgmtFrmClient.vosPendingDataBuff);
3335
3336 pTLCb->tlMgmtFrmClient.vosPendingDataBuff = NULL;
3337 }
3338
3339 pTLCb->tlMgmtFrmClient.ucExists = 0;
3340
3341 return VOS_STATUS_SUCCESS;
3342}/* WLANTL_RegisterMgmtFrmClient */
3343
3344/*==========================================================================
3345
3346 FUNCTION WLANTL_TxMgmtFrm
3347
3348 DESCRIPTION
3349 Called by PE when it want to send out a management frame.
3350 HAL will also use this API for the few frames it sends out, they are not
3351 management frames howevere it is accepted that an exception will be
3352 allowed ONLY for the usage of HAL.
3353 Generic data frames SHOULD NOT travel through this function.
3354
3355 DEPENDENCIES
3356 TL must be initialized before this API can be called.
3357
3358 RESTRICTION: If PE sends another packet before TL manages to process the
3359 previously sent packet call will end in failure
3360
3361 Frames comming through here must be 802.11 frames, frame
3362 translation in UMA will be automatically disabled.
3363
3364 PARAMETERS
3365
3366 IN
3367 pvosGCtx: pointer to the global vos context;a handle to TL's
3368 control block can be extracted from its context
3369 vosFrmBuf: pointer to a vOSS buffer containing the management
3370 frame to be transmitted
3371 usFrmLen: the length of the frame to be transmitted; information
3372 is already included in the vOSS buffer
3373 wFrmType: the type of the frame being transmitted
3374 tid: tid used to transmit this frame
3375 pfnCompTxFunc: function pointer to the transmit complete routine
3376 pvBDHeader: pointer to the BD header, if NULL it means it was not
3377 yet constructed and it lies within TL's responsibility
3378 to do so; if not NULL it is expected that it was
3379 already packed inside the vos packet
3380 ucAckResponse: flag notifying it an interrupt is needed for the
3381 acknowledgement received when the frame is sent out
3382 the air and ; the interrupt will be processed by HAL,
3383 only one such frame can be pending in the system at
3384 one time.
3385
3386
3387 RETURN VALUE
3388 The result code associated with performing the operation
3389
3390 VOS_STATUS_E_INVAL: Input parameters are invalid
3391 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
3392 page fault
3393 VOS_STATUS_E_EXISTS: Mgmt Frame client was not yet registered
3394 VOS_STATUS_E_BUSY: The previous Mgmt packet was not yet transmitted
3395 VOS_STATUS_SUCCESS: Everything is good :)
3396
3397 Other failure messages may be returned from the BD header handling
3398 routines, please check apropriate API for more info.
3399
3400 SIDE EFFECTS
3401
3402============================================================================*/
3403VOS_STATUS
3404WLANTL_TxMgmtFrm
3405(
3406 v_PVOID_t pvosGCtx,
3407 vos_pkt_t* vosFrmBuf,
3408 v_U16_t usFrmLen,
3409 v_U8_t wFrmType,
3410 v_U8_t ucTid,
3411 WLANTL_TxCompCBType pfnCompTxFunc,
3412 v_PVOID_t pvBDHeader,
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05303413 v_U32_t ucAckResponse
Jeff Johnson295189b2012-06-20 16:38:30 -07003414)
3415{
3416 WLANTL_CbType* pTLCb = NULL;
3417 v_MACADDR_t vDestMacAddr;
3418 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
3419 v_U16_t usPktLen;
3420 v_U32_t usTimeStamp = 0;
3421 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
3422
3423 /*------------------------------------------------------------------------
3424 Sanity check
3425 ------------------------------------------------------------------------*/
3426 if ( NULL == vosFrmBuf )
3427 {
3428 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3429 "WLAN TL:Invalid parameter sent on WLANTL_TxMgmtFrm"));
3430 return VOS_STATUS_E_INVAL;
3431 }
3432
3433 /*------------------------------------------------------------------------
3434 Extract TL control block
3435 ------------------------------------------------------------------------*/
3436 pTLCb = VOS_GET_TL_CB(pvosGCtx);
3437 if ( NULL == pTLCb )
3438 {
3439 TLLOGP(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_FATAL,
3440 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_TxMgmtFrm"));
3441 return VOS_STATUS_E_FAULT;
3442 }
3443
3444 /*------------------------------------------------------------------------
3445 Ensure that management frame client was previously registered
3446 ------------------------------------------------------------------------*/
3447 if ( 0 == pTLCb->tlMgmtFrmClient.ucExists )
3448 {
3449 pTLCb->tlMgmtFrmClient.ucExists++;
3450 TLLOGP(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_FATAL,
3451 "WLAN TL:Management Frame client not register on WLANTL_TxMgmtFrm"));
3452 return VOS_STATUS_E_EXISTS;
3453 }
3454
3455 /*------------------------------------------------------------------------
3456 Check if any Mgmt Frm is pending
3457 ------------------------------------------------------------------------*/
3458 //vosTempBuff = pTLCb->tlMgmtFrmClient.vosPendingDataBuff;
3459 if ( NULL != pTLCb->tlMgmtFrmClient.vosPendingDataBuff )
3460 {
3461
3462 TLLOGP(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_FATAL,
3463 "WLAN TL:Management Frame already pending tx in TL: failing old one"));
3464
3465
3466 /*Failing the tx for the previous packet enqued by PE*/
Arun Kumar Khandavalli0af8d3c2014-02-07 18:05:11 +05303467 //vos_atomic_set( (uintptr_t*)&pTLCb->tlMgmtFrmClient.vosPendingDataBuff,
3468 // (uintptr_t)NULL);
Jeff Johnson295189b2012-06-20 16:38:30 -07003469
3470 //vos_pkt_get_user_data_ptr( vosTempBuff, VOS_PKT_USER_DATA_ID_TL,
3471 // (v_PVOID_t)&pfnTxComp);
3472
3473 /*it should never be NULL - default handler should be registered if none*/
3474 //if ( NULL == pfnTxComp )
3475 //{
3476 // VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3477 // "NULL pointer to Tx Complete on WLANTL_TxMgmtFrm");
3478 // VOS_ASSERT(0);
3479 // return VOS_STATUS_E_FAULT;
3480 //}
3481
3482 //pfnTxComp( pvosGCtx, vosTempBuff, VOS_STATUS_E_RESOURCES );
3483 //return VOS_STATUS_E_BUSY;
3484
3485
3486 //pfnCompTxFunc( pvosGCtx, vosFrmBuf, VOS_STATUS_E_RESOURCES);
3487 return VOS_STATUS_E_RESOURCES;
3488 }
3489
3490
3491 /*------------------------------------------------------------------------
3492 Check if BD header was build, if not construct
3493 ------------------------------------------------------------------------*/
3494 if ( NULL == pvBDHeader )
3495 {
3496 v_MACADDR_t* pvAddr2MacAddr;
3497 v_U8_t uQosHdr = VOS_FALSE;
3498
3499 /* Get address 2 of Mangement Frame to give to WLANHAL_FillTxBd */
3500 vosStatus = vos_pkt_peek_data( vosFrmBuf,
3501 WLANTL_MAC_ADDR_ALIGN(1) + VOS_MAC_ADDR_SIZE,
3502 (v_PVOID_t)&pvAddr2MacAddr, VOS_MAC_ADDR_SIZE);
3503
3504 if ( VOS_STATUS_SUCCESS != vosStatus )
3505 {
3506 TLLOGP(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_FATAL,
3507 "WLAN TL:Failed while attempting to get addr2 %d", vosStatus));
3508 return vosStatus;
3509 }
Gopichand Nakkala0f3eb5c2013-05-07 16:48:38 +05303510
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003511 /* ESE IAPP/TDLS Frame which are data frames but technically used
Jeff Johnson295189b2012-06-20 16:38:30 -07003512 * for management functionality comes through route.
3513 */
3514 if (WLANTL_IS_QOS_DATA_FRAME(wFrmType)) \
3515 {
3516 uQosHdr = VOS_TRUE;
3517 }
Siddharth Bhal4551b102014-10-09 21:36:36 +05303518
3519 if (WLANTL_IS_PROBE_REQ(wFrmType))
3520 {
3521 if (VOS_TRUE == vos_mem_compare((v_VOID_t*) pvAddr2MacAddr,
3522 (v_VOID_t*) &pTLCb->spoofMacAddr.spoofMac, VOS_MAC_ADDRESS_LEN))
3523 {
3524 pvAddr2MacAddr = (v_PVOID_t)pTLCb->spoofMacAddr.selfMac.bytes;
3525 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
3526 "TL: using self sta addr to get staidx for spoofed probe req "
3527 MAC_ADDRESS_STR, MAC_ADDR_ARRAY(pvAddr2MacAddr->bytes));
3528 }
3529 }
3530
Jeff Johnson295189b2012-06-20 16:38:30 -07003531 /*----------------------------------------------------------------------
3532 Call WDA to build TX header
3533 ----------------------------------------------------------------------*/
3534 vosStatus = WDA_DS_BuildTxPacketInfo( pvosGCtx, vosFrmBuf , &vDestMacAddr,
3535 1 /* always 802.11 frames*/, &usPktLen, uQosHdr /*qos not enabled !!!*/,
Siddharth Bhal4551b102014-10-09 21:36:36 +05303536 0 /* WDS off */, 0, wFrmType, pvAddr2MacAddr, ucTid,
Jeff Johnson295189b2012-06-20 16:38:30 -07003537 ucAckResponse, usTimeStamp, 0, 0 );
3538
3539
3540 if ( !VOS_IS_STATUS_SUCCESS(vosStatus) )
3541 {
3542 TLLOGP(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_FATAL,
3543 "WLAN TL:Failed while attempting to build TX header %d", vosStatus));
3544 return vosStatus;
3545 }
3546 }/* if BD header not present */
3547
3548 /*------------------------------------------------------------------------
3549 Save buffer and notify BAL; no lock is needed if the above restriction
3550 is met
3551 Save the tx complete fnct pointer as tl specific data in the vos buffer
3552 ------------------------------------------------------------------------*/
3553 if ( NULL != pfnCompTxFunc )
3554 {
3555 vos_pkt_set_user_data_ptr( vosFrmBuf, VOS_PKT_USER_DATA_ID_TL,
3556 (v_PVOID_t)pfnCompTxFunc);
3557 }
3558 else
3559 {
3560 vos_pkt_set_user_data_ptr( vosFrmBuf, VOS_PKT_USER_DATA_ID_TL,
3561 (v_PVOID_t)WLANTL_TxCompDefaultCb);
3562
3563 }
Arun Kumar Khandavalli0af8d3c2014-02-07 18:05:11 +05303564 vos_atomic_set( (uintptr_t*)&pTLCb->tlMgmtFrmClient.vosPendingDataBuff,
3565 (uintptr_t)vosFrmBuf);
Jeff Johnson295189b2012-06-20 16:38:30 -07003566
3567 /*------------------------------------------------------------------------
3568 Check if thre are enough resources for transmission and tx is not
3569 suspended.
3570 ------------------------------------------------------------------------*/
3571 if ( pTLCb->uResCount >= WDA_TLI_MIN_RES_MF )
3572 {
3573 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
3574 "WLAN TL:Issuing Xmit start request to BAL for MGMT"));
3575 vosStatus = WDA_DS_StartXmit(pvosGCtx);
3576 if(VOS_STATUS_SUCCESS != vosStatus)
3577 {
3578 TLLOGP(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_FATAL,
3579 "WLAN TL:WDA_DS_StartXmit fails. vosStatus %d", vosStatus));
Arun Kumar Khandavalli0af8d3c2014-02-07 18:05:11 +05303580 vos_atomic_set( (uintptr_t*)&pTLCb->tlMgmtFrmClient.vosPendingDataBuff,0);
Jeff Johnson295189b2012-06-20 16:38:30 -07003581 }
3582 return vosStatus;
3583
3584 }
3585 else
3586 {
3587 /*---------------------------------------------------------------------
3588 No error code is sent because TL will resume tx autonomously if
3589 resources become available or tx gets resumed
3590 ---------------------------------------------------------------------*/
3591 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
3592 "WLAN TL:Request to send for Mgmt Frm but condition not met. Res: %d",
3593 pTLCb->uResCount));
3594 }
3595
3596 return VOS_STATUS_SUCCESS;
3597}/* WLANTL_TxMgmtFrm */
3598
3599/*----------------------------------------------------------------------------
3600 INTERACTION WITH HAL
3601 ---------------------------------------------------------------------------*/
3602
3603/*==========================================================================
3604
3605 FUNCTION WLANTL_ResetNotification
3606
3607 DESCRIPTION
3608 HAL notifies TL when the module is being reset.
3609 Currently not used.
3610
3611 DEPENDENCIES
3612
3613 PARAMETERS
3614
3615 IN
3616 pvosGCtx: pointer to the global vos context; a handle to TL's
3617 control block can be extracted from its context
3618
3619
3620 RETURN VALUE
3621 The result code associated with performing the operation
3622
3623 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
3624 page fault
3625 VOS_STATUS_SUCCESS: Everything is good :)
3626
3627 SIDE EFFECTS
3628
3629============================================================================*/
3630VOS_STATUS
3631WLANTL_ResetNotification
3632(
3633 v_PVOID_t pvosGCtx
3634)
3635{
3636 WLANTL_CbType* pTLCb = NULL;
3637 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
3638
3639 /*------------------------------------------------------------------------
3640 Sanity check
3641 Extract TL control block
3642 ------------------------------------------------------------------------*/
3643 pTLCb = VOS_GET_TL_CB(pvosGCtx);
3644 if ( NULL == pTLCb )
3645 {
3646 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3647 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_ResetNotification"));
3648 return VOS_STATUS_E_FAULT;
3649 }
3650
3651 WLANTL_CleanCB(pTLCb, 1 /*empty all queues and pending packets*/);
3652 return VOS_STATUS_SUCCESS;
3653}/* WLANTL_ResetNotification */
3654
3655/*==========================================================================
3656
3657 FUNCTION WLANTL_SuspendDataTx
3658
3659 DESCRIPTION
3660 HAL calls this API when it wishes to suspend transmission for a
3661 particular STA.
3662
3663 DEPENDENCIES
3664 The STA for which the request is made must be first registered with
3665 TL by HDD.
3666
3667 RESTRICTION: In case of a suspend, the flag write and read will not be
3668 locked: worst case scenario one more packet can get
3669 through before the flag gets updated (we can make this
3670 write atomic as well to guarantee consistency)
3671
3672 PARAMETERS
3673
3674 IN
3675 pvosGCtx: pointer to the global vos context; a handle to TL's
3676 control block can be extracted from its context
3677 pucSTAId: identifier of the station for which the request is made;
3678 a value of NULL assumes suspend on all active station
3679 pfnSuspendTxCB: pointer to the suspend result notification in case the
3680 call is asynchronous
3681
3682
3683 RETURN VALUE
3684 The result code associated with performing the operation
3685
3686 VOS_STATUS_E_FAULT: Station ID is outside array boundaries or pointer
3687 to TL cb is NULL ; access would cause a page fault
3688 VOS_STATUS_E_EXISTS: Station was not registered
3689 VOS_STATUS_SUCCESS: Everything is good :)
3690
3691 SIDE EFFECTS
3692
3693============================================================================*/
3694
3695VOS_STATUS
3696WLANTL_SuspendDataTx
3697(
3698 v_PVOID_t pvosGCtx,
3699 v_U8_t* pucSTAId,
3700 WLANTL_SuspendCBType pfnSuspendTx
3701)
3702{
3703 WLANTL_CbType* pTLCb = NULL;
3704 vos_msg_t vosMsg;
Jeff Johnson295189b2012-06-20 16:38:30 -07003705
3706 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
3707
3708 /*------------------------------------------------------------------------
3709 Sanity check
3710 Extract TL control block
3711 ------------------------------------------------------------------------*/
3712 pTLCb = VOS_GET_TL_CB(pvosGCtx);
Hoonki Lee14621352013-04-16 17:51:19 -07003713 if ( NULL == pTLCb )
Jeff Johnson295189b2012-06-20 16:38:30 -07003714 {
3715 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3716 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_SuspendDataTx"));
3717 return VOS_STATUS_E_FAULT;
3718 }
3719
3720 /*------------------------------------------------------------------------
3721 Check the type of request: generic suspend, or per station suspend
3722 ------------------------------------------------------------------------*/
Hoonki Lee14621352013-04-16 17:51:19 -07003723 if (NULL == pucSTAId)
Jeff Johnson295189b2012-06-20 16:38:30 -07003724 {
3725 /* General Suspend Request received */
3726 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
3727 "WLAN TL:General suspend requested"));
Hoonki Lee14621352013-04-16 17:51:19 -07003728 vos_atomic_set_U8( &pTLCb->ucTxSuspended, 1);
Jeff Johnson295189b2012-06-20 16:38:30 -07003729 vosMsg.reserved = WLAN_MAX_STA_COUNT;
3730 }
3731 else
3732 {
Hoonki Lee14621352013-04-16 17:51:19 -07003733 if ( WLANTL_STA_ID_INVALID( *pucSTAId ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07003734 {
Hoonki Lee14621352013-04-16 17:51:19 -07003735 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3736 "WLAN TL:Invalid station id %d requested on WLANTL_SuspendDataTx", *pucSTAId));
3737 return VOS_STATUS_E_FAULT;
3738 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003739
Gopichand Nakkalae5fef6c2013-06-19 18:04:23 +05303740 if ( NULL == pTLCb->atlSTAClients[*pucSTAId] )
3741 {
3742 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3743 "WLAN TL:Invalid pTLCb->atlSTAClients pointer for STA Id :%d on "
3744 "WLANTL_SuspendDataTx", *pucSTAId));
3745 return VOS_STATUS_E_FAULT;
3746 }
3747
3748 if ( 0 == pTLCb->atlSTAClients[*pucSTAId]->ucExists )
Hoonki Lee14621352013-04-16 17:51:19 -07003749 {
3750 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3751 "WLAN TL:Station %d was not previously registered on WLANTL_SuspendDataTx", *pucSTAId));
3752 return VOS_STATUS_E_EXISTS;
3753 }
3754
3755 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
3756 "WLAN TL:Suspend request for station: %d", *pucSTAId));
3757 vos_atomic_set_U8( &pTLCb->atlSTAClients[*pucSTAId]->ucTxSuspended, 1);
Jeff Johnson295189b2012-06-20 16:38:30 -07003758 vosMsg.reserved = *pucSTAId;
3759 }
3760
3761 /*------------------------------------------------------------------------
3762 Serialize request through TX thread
3763 ------------------------------------------------------------------------*/
3764 vosMsg.type = WLANTL_TX_SIG_SUSPEND;
3765 vosMsg.bodyptr = (v_PVOID_t)pfnSuspendTx;
3766
Katya Nigam42e16e82014-02-04 16:28:55 +05303767 MTRACE(vos_trace(VOS_MODULE_ID_TL, TRACE_CODE_TL_SUSPEND_DATA_TX,
3768 vosMsg.reserved , 0 ));
3769
Jeff Johnson295189b2012-06-20 16:38:30 -07003770 if(!VOS_IS_STATUS_SUCCESS(vos_tx_mq_serialize( VOS_MQ_ID_TL, &vosMsg)))
3771 {
3772 VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003773 " %s fails to post message", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003774 }
3775
3776 return VOS_STATUS_SUCCESS;
3777}/* WLANTL_SuspendDataTx */
3778
3779/*==========================================================================
3780
3781 FUNCTION WLANTL_ResumeDataTx
3782
3783 DESCRIPTION
3784 Called by HAL to resume data transmission for a given STA.
3785
3786 WARNING: If a station was individually suspended a global resume will
3787 not resume that station
3788
3789 DEPENDENCIES
3790
3791 PARAMETERS
3792
3793 IN
3794 pvosGCtx: pointer to the global vos context; a handle to TL's
3795 control block can be extracted from its context
3796 pucSTAId: identifier of the station which is being resumed; NULL
3797 translates into global resume
3798
3799 RETURN VALUE
3800 The result code associated with performing the operation
3801
3802 VOS_STATUS_E_FAULT: Station ID is outside array boundaries or pointer
3803 to TL cb is NULL ; access would cause a page fault
3804 VOS_STATUS_E_EXISTS: Station was not registered
3805 VOS_STATUS_SUCCESS: Everything is good :)
3806
3807 SIDE EFFECTS
3808
3809============================================================================*/
3810
3811VOS_STATUS
3812WLANTL_ResumeDataTx
3813(
3814 v_PVOID_t pvosGCtx,
3815 v_U8_t* pucSTAId
3816)
3817{
3818 WLANTL_CbType* pTLCb = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07003819 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
3820
3821 /*------------------------------------------------------------------------
3822 Sanity check
3823 Extract TL control block
3824 ------------------------------------------------------------------------*/
3825 pTLCb = VOS_GET_TL_CB(pvosGCtx);
Hoonki Lee14621352013-04-16 17:51:19 -07003826 if ( NULL == pTLCb )
Jeff Johnson295189b2012-06-20 16:38:30 -07003827 {
3828 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3829 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_ResumeDataTx"));
3830 return VOS_STATUS_E_FAULT;
3831 }
3832
Jeff Johnson295189b2012-06-20 16:38:30 -07003833 /*------------------------------------------------------------------------
3834 Check to see the type of resume
3835 ------------------------------------------------------------------------*/
Hoonki Lee14621352013-04-16 17:51:19 -07003836 if ( NULL == pucSTAId )
Jeff Johnson295189b2012-06-20 16:38:30 -07003837 {
Katya Nigam42e16e82014-02-04 16:28:55 +05303838 MTRACE(vos_trace(VOS_MODULE_ID_TL, TRACE_CODE_TL_RESUME_DATA_TX,
3839 41 , 0 ));
3840
Jeff Johnson295189b2012-06-20 16:38:30 -07003841 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
3842 "WLAN TL:General resume requested"));
3843 vos_atomic_set_U8( &pTLCb->ucTxSuspended, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07003844 }
3845 else
3846 {
Katya Nigam42e16e82014-02-04 16:28:55 +05303847 MTRACE(vos_trace(VOS_MODULE_ID_TL, TRACE_CODE_TL_RESUME_DATA_TX,
3848 *pucSTAId , 0 ));
3849
Hoonki Lee14621352013-04-16 17:51:19 -07003850 if ( WLANTL_STA_ID_INVALID( *pucSTAId ))
Jeff Johnson295189b2012-06-20 16:38:30 -07003851 {
Hoonki Lee14621352013-04-16 17:51:19 -07003852 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3853 "WLAN TL:Invalid station id %d requested on WLANTL_ResumeDataTx", *pucSTAId));
3854 return VOS_STATUS_E_FAULT;
3855 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003856
Gopichand Nakkalae5fef6c2013-06-19 18:04:23 +05303857 if ( NULL == pTLCb->atlSTAClients[*pucSTAId] )
3858 {
3859 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3860 "WLAN TL:Invalid pTLCb->atlSTAClients pointer for STA Id :%d on "
3861 "WLANTL_ResumeDataTx", *pucSTAId));
3862 return VOS_STATUS_E_FAULT;
3863 }
3864
3865 if ( 0 == pTLCb->atlSTAClients[*pucSTAId]->ucExists )
Hoonki Lee14621352013-04-16 17:51:19 -07003866 {
3867 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3868 "WLAN TL:Station %d was not previously registered on WLANTL_ResumeDataTx", *pucSTAId));
3869 return VOS_STATUS_E_EXISTS;
3870 }
3871
3872 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
3873 "WLAN TL:Resume request for station: %d", *pucSTAId));
3874 vos_atomic_set_U8( &pTLCb->atlSTAClients[*pucSTAId]->ucTxSuspended, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07003875 }
3876
3877 /*------------------------------------------------------------------------
3878 Resuming transmission
3879 ------------------------------------------------------------------------*/
Hoonki Lee14621352013-04-16 17:51:19 -07003880 if (( pTLCb->uResCount >= WDA_TLI_MIN_RES_MF ) &&
3881 ( 0 == pTLCb->ucTxSuspended ))
Jeff Johnson295189b2012-06-20 16:38:30 -07003882 {
3883 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
3884 "WLAN TL:Resuming transmission"));
3885 return WDA_DS_StartXmit(pvosGCtx);
3886 }
3887
3888 return VOS_STATUS_SUCCESS;
3889}/* WLANTL_ResumeDataTx */
3890
3891/*==========================================================================
3892 FUNCTION WLANTL_SuspendCB
3893
3894 DESCRIPTION
3895 Callback function for serializing Suspend signal through Tx thread
3896
3897 DEPENDENCIES
3898 Just notify HAL that suspend in TL is complete.
3899
3900 PARAMETERS
3901
3902 IN
3903 pvosGCtx: pointer to the global vos context; a handle to TL's
3904 control block can be extracted from its context
3905 pUserData: user data sent with the callback
3906
3907 RETURN VALUE
3908 The result code associated with performing the operation
3909
3910 VOS_STATUS_E_INVAL: invalid input parameters
3911 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
3912 page fault
3913 VOS_STATUS_SUCCESS: Everything is good :)
3914
3915
3916 SIDE EFFECTS
3917
3918============================================================================*/
3919VOS_STATUS
3920WLANTL_SuspendCB
3921(
3922 v_PVOID_t pvosGCtx,
3923 WLANTL_SuspendCBType pfnSuspendCB,
3924 v_U16_t usReserved
3925)
3926{
3927 WLANTL_CbType* pTLCb = NULL;
3928 v_U8_t ucSTAId = (v_U8_t)usReserved;
3929 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
3930
3931 /*------------------------------------------------------------------------
3932 Sanity check
3933 ------------------------------------------------------------------------*/
3934 if ( NULL == pfnSuspendCB )
3935 {
3936 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
3937 "WLAN TL: No Call back processing requested WLANTL_SuspendCB"));
3938 return VOS_STATUS_SUCCESS;
3939 }
3940
3941 /*------------------------------------------------------------------------
3942 Extract TL control block
3943 ------------------------------------------------------------------------*/
3944 pTLCb = VOS_GET_TL_CB(pvosGCtx);
3945 if ( NULL == pTLCb )
3946 {
3947 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3948 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_SuspendCB"));
3949 return VOS_STATUS_E_FAULT;
3950 }
3951
3952 if ( WLANTL_STA_ID_INVALID( ucSTAId ) )
3953 {
3954 pfnSuspendCB(pvosGCtx, NULL, VOS_STATUS_SUCCESS);
3955 }
3956 else
3957 {
3958 pfnSuspendCB(pvosGCtx, &ucSTAId, VOS_STATUS_SUCCESS);
3959 }
3960
3961 return VOS_STATUS_SUCCESS;
3962}/*WLANTL_SuspendCB*/
3963
3964
3965/*----------------------------------------------------------------------------
3966 CLIENT INDEPENDENT INTERFACE
3967 ---------------------------------------------------------------------------*/
3968
3969/*==========================================================================
3970
3971 FUNCTION WLANTL_GetTxPktCount
3972
3973 DESCRIPTION
3974 TL will provide the number of transmitted packets counted per
3975 STA per TID.
3976
3977 DEPENDENCIES
3978
3979 PARAMETERS
3980
3981 IN
3982 pvosGCtx: pointer to the global vos context; a handle to TL's
3983 control block can be extracted from its context
3984 ucSTAId: identifier of the station
3985 ucTid: identifier of the tspec
3986
3987 OUT
3988 puTxPktCount: the number of packets tx packet for this STA and TID
3989
3990 RETURN VALUE
3991 The result code associated with performing the operation
3992
3993 VOS_STATUS_E_INVAL: Input parameters are invalid
3994 VOS_STATUS_E_FAULT: Station ID is outside array boundaries or pointer
3995 to TL cb is NULL ; access would cause a page fault
3996 VOS_STATUS_E_EXISTS: Station was not registered
3997 VOS_STATUS_SUCCESS: Everything is good :)
3998
3999 SIDE EFFECTS
4000
4001============================================================================*/
4002VOS_STATUS
4003WLANTL_GetTxPktCount
4004(
4005 v_PVOID_t pvosGCtx,
4006 v_U8_t ucSTAId,
4007 v_U8_t ucTid,
4008 v_U32_t* puTxPktCount
4009)
4010{
4011 WLANTL_CbType* pTLCb = NULL;
4012 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
4013
4014 /*------------------------------------------------------------------------
4015 Sanity check
4016 ------------------------------------------------------------------------*/
4017 if ( NULL == puTxPktCount )
4018 {
4019 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
4020 "WLAN TL:Invalid parameter sent on WLANTL_GetTxPktCount"));
4021 return VOS_STATUS_E_INVAL;
4022 }
4023
4024 if ( WLANTL_STA_ID_INVALID( ucSTAId ) || WLANTL_TID_INVALID( ucTid) )
4025 {
4026 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
4027 "WLAN TL:Invalid station id %d/tid %d requested on WLANTL_GetTxPktCount",
4028 ucSTAId, ucTid));
4029 return VOS_STATUS_E_FAULT;
4030 }
4031
4032 /*------------------------------------------------------------------------
4033 Extract TL control block and check if station exists
4034 ------------------------------------------------------------------------*/
4035 pTLCb = VOS_GET_TL_CB(pvosGCtx);
4036 if ( NULL == pTLCb )
4037 {
4038 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
4039 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_GetTxPktCount"));
4040 return VOS_STATUS_E_FAULT;
4041 }
4042
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304043 if ( NULL == pTLCb->atlSTAClients[ucSTAId] )
4044 {
4045 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
4046 "WLAN TL:Client Memory was not allocated on %s", __func__));
4047 return VOS_STATUS_E_FAILURE;
4048 }
4049
4050 if ( 0 == pTLCb->atlSTAClients[ucSTAId]->ucExists )
Jeff Johnson295189b2012-06-20 16:38:30 -07004051 {
4052 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
4053 "WLAN TL:Station was not previously registered on WLANTL_GetTxPktCount %d",
4054 ucSTAId));
4055 return VOS_STATUS_E_EXISTS;
4056 }
4057
4058 /*------------------------------------------------------------------------
4059 Return data
4060 ------------------------------------------------------------------------*/
4061 //VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_MED,
4062 // "WLAN TL:Requested tx packet count for STA: %d, TID: %d",
4063 // ucSTAId, ucTid);
4064
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304065 *puTxPktCount = pTLCb->atlSTAClients[ucSTAId]->auTxCount[ucTid];
Jeff Johnson295189b2012-06-20 16:38:30 -07004066
4067 return VOS_STATUS_SUCCESS;
4068}/* WLANTL_GetTxPktCount */
4069
4070/*==========================================================================
4071
4072 FUNCTION WLANTL_GetRxPktCount
4073
4074 DESCRIPTION
4075 TL will provide the number of received packets counted per
4076 STA per TID.
4077
4078 DEPENDENCIES
4079
4080 PARAMETERS
4081
4082 IN
4083 pvosGCtx: pointer to the global vos context; a handle to TL's
4084 control block can be extracted from its context
4085 ucSTAId: identifier of the station
4086 ucTid: identifier of the tspec
4087
4088 OUT
4089 puTxPktCount: the number of packets rx packet for this STA and TID
4090
4091 RETURN VALUE
4092 The result code associated with performing the operation
4093
4094 VOS_STATUS_E_INVAL: Input parameters are invalid
4095 VOS_STATUS_E_FAULT: Station ID is outside array boundaries or pointer
4096 to TL cb is NULL ; access would cause a page fault
4097 VOS_STATUS_E_EXISTS: Station was not registered
4098 VOS_STATUS_SUCCESS: Everything is good :)
4099
4100 SIDE EFFECTS
4101
4102============================================================================*/
4103VOS_STATUS
4104WLANTL_GetRxPktCount
4105(
4106 v_PVOID_t pvosGCtx,
4107 v_U8_t ucSTAId,
4108 v_U8_t ucTid,
4109 v_U32_t* puRxPktCount
4110)
4111{
4112 WLANTL_CbType* pTLCb = NULL;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304113 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004114 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
4115
4116 /*------------------------------------------------------------------------
4117 Sanity check
4118 ------------------------------------------------------------------------*/
4119 if ( NULL == puRxPktCount )
4120 {
4121 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
4122 "WLAN TL:Invalid parameter sent on WLANTL_GetRxPktCount"));
4123 return VOS_STATUS_E_INVAL;
4124 }
4125
4126 if ( WLANTL_STA_ID_INVALID( ucSTAId ) || WLANTL_TID_INVALID( ucTid) )
4127 {
4128 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
4129 "WLAN TL:Invalid station id %d/tid %d requested on WLANTL_GetRxPktCount",
4130 ucSTAId, ucTid));
4131 return VOS_STATUS_E_FAULT;
4132 }
4133
4134 /*------------------------------------------------------------------------
4135 Extract TL control block and existance
4136 ------------------------------------------------------------------------*/
4137 pTLCb = VOS_GET_TL_CB(pvosGCtx);
4138 if ( NULL == pTLCb )
4139 {
4140 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
4141 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_GetRxPktCount"));
4142 return VOS_STATUS_E_FAULT;
4143 }
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304144 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
Jeff Johnson295189b2012-06-20 16:38:30 -07004145
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304146 if ( NULL == pClientSTA )
4147 {
4148 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
4149 "WLAN TL:Client Memory was not allocated on %s", __func__));
4150 return VOS_STATUS_E_FAILURE;
4151 }
4152
4153 if ( 0 == pClientSTA->ucExists )
Jeff Johnson295189b2012-06-20 16:38:30 -07004154 {
4155 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
4156 "WLAN TL:Station was not previously registered on WLANTL_GetRxPktCount"));
4157 return VOS_STATUS_E_EXISTS;
4158 }
4159
4160 /*------------------------------------------------------------------------
4161 Return data
4162 ------------------------------------------------------------------------*/
4163 TLLOG3(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_MED,
4164 "WLAN TL:Requested rx packet count for STA: %d, TID: %d",
4165 ucSTAId, ucTid));
4166
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304167 *puRxPktCount = pClientSTA->auRxCount[ucTid];
Jeff Johnson295189b2012-06-20 16:38:30 -07004168
4169 return VOS_STATUS_SUCCESS;
4170}/* WLANTL_GetRxPktCount */
4171
Jeff Johnson295189b2012-06-20 16:38:30 -07004172VOS_STATUS
4173WLANTL_TxFCFrame
4174(
4175 v_PVOID_t pvosGCtx
4176);
Jeff Johnson295189b2012-06-20 16:38:30 -07004177/*============================================================================
4178 TL INTERNAL API DEFINITION
4179============================================================================*/
4180
4181/*==========================================================================
4182
4183 FUNCTION WLANTL_GetFrames
4184
4185 DESCRIPTION
4186
4187 BAL calls this function at the request of the lower bus interface.
4188 When this request is being received TL will retrieve packets from HDD
4189 in accordance with the priority rules and the count supplied by BAL.
4190
4191 DEPENDENCIES
4192
4193 HDD must have registered with TL at least one STA before this function
4194 can be called.
4195
4196 PARAMETERS
4197
4198 IN
4199 pvosGCtx: pointer to the global vos context; a handle to TL's
4200 or BAL's control block can be extracted from its context
4201 uSize: maximum size accepted by the lower layer
4202 uFlowMask TX flow control mask for Prima. Each bit is defined as
4203 WDA_TXFlowEnumType
4204
4205 OUT
4206 vosDataBuff: it will contain a pointer to the first buffer supplied
4207 by TL, if there is more than one packet supplied, TL
4208 will chain them through vOSS buffers
4209
4210 RETURN VALUE
4211
4212 The result code associated with performing the operation
4213
4214 1 or more: number of required resources if there are still frames to fetch
4215 0 : error or HDD queues are drained
4216
4217 SIDE EFFECTS
4218
4219 NOTE
4220
4221 Featurized uFlowMask. If we want to remove featurization, we need to change
4222 BAL on Volans.
4223
4224============================================================================*/
4225v_U32_t
4226WLANTL_GetFrames
4227(
4228 v_PVOID_t pvosGCtx,
4229 vos_pkt_t **ppFrameDataBuff,
4230 v_U32_t uSize,
Jeff Johnson295189b2012-06-20 16:38:30 -07004231 v_U8_t uFlowMask,
Jeff Johnson295189b2012-06-20 16:38:30 -07004232 v_BOOL_t* pbUrgent
4233)
4234{
4235 vos_pkt_t** pvosDataBuff = (vos_pkt_t**)ppFrameDataBuff;
4236 WLANTL_CbType* pTLCb = NULL;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304237 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004238 v_U32_t uRemaining = uSize;
4239 vos_pkt_t* vosRoot;
4240 vos_pkt_t* vosTempBuf;
4241 WLANTL_STAFuncType pfnSTAFsm;
4242 v_U16_t usPktLen;
4243 v_U32_t uResLen;
4244 v_U8_t ucSTAId;
4245 v_U8_t ucAC;
4246 vos_pkt_t* vosDataBuff;
4247 v_U32_t uTotalPktLen;
4248 v_U32_t i=0;
Tushnim Bhattacharyya39a8f182013-02-20 18:10:30 -08004249 v_U32_t j=0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004250 v_U32_t ucResult = 0;
4251 VOS_STATUS vosStatus;
4252 WLANTL_STAEventType wSTAEvent;
4253 tBssSystemRole systemRole;
4254 tpAniSirGlobal pMac;
4255 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
4256
4257 /*------------------------------------------------------------------------
4258 Sanity check
4259 Extract TL control block
4260 ------------------------------------------------------------------------*/
4261 pTLCb = VOS_GET_TL_CB(pvosGCtx);
4262 if (( NULL == pTLCb ) || ( NULL == pvosDataBuff ))
4263 {
4264 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
4265 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_ChangeSTAState"));
4266 return ucResult;
4267 }
4268
4269 pMac = vos_get_context(VOS_MODULE_ID_PE, pvosGCtx);
4270 if ( NULL == pMac )
4271 {
4272 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004273 "%s: Invalid pMac", __func__));
Jeff Johnson295189b2012-06-20 16:38:30 -07004274 return ucResult;
4275 }
4276
4277 vosDataBuff = pTLCb->vosDummyBuf; /* Just to avoid checking for NULL at
4278 each iteration */
4279
Jeff Johnson295189b2012-06-20 16:38:30 -07004280 pTLCb->uResCount = uSize;
Jeff Johnson295189b2012-06-20 16:38:30 -07004281
4282 /*-----------------------------------------------------------------------
4283 Save the root as we will walk this chain as we fill it
4284 -----------------------------------------------------------------------*/
4285 vosRoot = vosDataBuff;
4286
4287 /*-----------------------------------------------------------------------
4288 There is still data - until FSM function says otherwise
4289 -----------------------------------------------------------------------*/
4290 pTLCb->bUrgent = FALSE;
4291
Jeff Johnson295189b2012-06-20 16:38:30 -07004292 while (( pTLCb->tlConfigInfo.uMinFramesProcThres < pTLCb->uResCount ) &&
4293 ( 0 < uRemaining ))
Jeff Johnson295189b2012-06-20 16:38:30 -07004294 {
4295 systemRole = wdaGetGlobalSystemRole(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -07004296#ifdef WLAN_SOFTAP_FLOWCTRL_EN
4297/* FIXME: The code has been disabled since it is creating issues in power save */
4298 if (eSYSTEM_AP_ROLE == systemRole)
4299 {
4300 if (pTLCb->done_once == 0 && NULL == pTLCb->vosTxFCBuf)
4301 {
4302 WLANTL_TxFCFrame (pvosGCtx);
4303 pTLCb->done_once ++;
4304 }
4305 }
4306 if ( NULL != pTLCb->vosTxFCBuf )
4307 {
4308 //there is flow control packet waiting to be sent
4309 WDA_TLI_PROCESS_FRAME_LEN( pTLCb->vosTxFCBuf, usPktLen, uResLen, uTotalPktLen);
4310
4311 if ( ( pTLCb->uResCount > uResLen ) &&
Jeff Johnson9b5dc4d2013-02-22 21:28:47 -08004312 ( uRemaining > uTotalPktLen ) &&
4313 ( uFlowMask & ( 1 << WDA_TXFLOW_FC ) ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07004314 {
4315 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
4316 "WLAN TL:Chaining FC frame first on GetFrame"));
4317
4318 vos_pkt_chain_packet( vosDataBuff, pTLCb->vosTxFCBuf, 1 /*true*/ );
4319
Arun Kumar Khandavalli0af8d3c2014-02-07 18:05:11 +05304320 vos_atomic_set( (uintptr_t*)&pTLCb->vosTxFCBuf, (uintptr_t) NULL);
Jeff Johnson295189b2012-06-20 16:38:30 -07004321
4322 /*FC frames cannot be delayed*/
4323 pTLCb->bUrgent = TRUE;
4324
4325 /*Update remaining len from SSC */
4326 uRemaining -= (usPktLen + WDA_DXE_HEADER_SIZE);
4327
4328 /*Update resource count */
4329 pTLCb->uResCount -= uResLen;
4330 }
4331 else
4332 {
4333 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004334 "WLAN TL:send fc out of source %s", __func__));
Jeff Johnson295189b2012-06-20 16:38:30 -07004335 ucResult = ( pTLCb->uResCount > uResLen )?VOS_TRUE:VOS_FALSE;
4336 break; /* Out of resources or reached max len */
4337 }
4338 }
4339 else
4340#endif //WLAN_SOFTAP_FLOWCTRL_EN
Jeff Johnson295189b2012-06-20 16:38:30 -07004341
Jeff Johnson9b5dc4d2013-02-22 21:28:47 -08004342 if (( NULL != pTLCb->tlMgmtFrmClient.vosPendingDataBuff ) &&
4343 ( uFlowMask & ( 1 << WDA_TXFLOW_MGMT ) ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07004344 {
4345 WDA_TLI_PROCESS_FRAME_LEN( pTLCb->tlMgmtFrmClient.vosPendingDataBuff,
4346 usPktLen, uResLen, uTotalPktLen);
4347
Manjunathappa Prakashfb585462013-12-23 19:07:07 -08004348 if (usPktLen > WLANTL_MAX_ALLOWED_LEN)
4349 {
4350 usPktLen = WLANTL_MAX_ALLOWED_LEN;
4351 VOS_ASSERT(0);
4352 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004353
4354 if ( ( pTLCb->uResCount > uResLen ) &&
Jeff Johnson9b5dc4d2013-02-22 21:28:47 -08004355 ( uRemaining > uTotalPktLen ) &&
4356 ( uFlowMask & ( 1 << WDA_TXFLOW_MGMT ) ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07004357 {
4358 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
4359 "WLAN TL:Chaining management frame on GetFrame"));
4360
4361 vos_pkt_chain_packet( vosDataBuff,
4362 pTLCb->tlMgmtFrmClient.vosPendingDataBuff,
4363 1 /*true*/ );
4364
Arun Kumar Khandavalli0af8d3c2014-02-07 18:05:11 +05304365 vos_atomic_set( (uintptr_t*)&pTLCb->tlMgmtFrmClient.
4366 vosPendingDataBuff, (uintptr_t)NULL);
Jeff Johnson295189b2012-06-20 16:38:30 -07004367
4368 /*management frames cannot be delayed*/
4369 pTLCb->bUrgent = TRUE;
4370
4371 /*Update remaining len from SSC */
4372 uRemaining -= (usPktLen + WDA_DXE_HEADER_SIZE);
4373
4374 /*Update resource count */
4375 pTLCb->uResCount -= uResLen;
4376 }
4377 else
4378 {
4379 ucResult = ( pTLCb->uResCount > uResLen )?VOS_TRUE:VOS_FALSE;
4380 break; /* Out of resources or reached max len */
4381 }
4382 }
4383 else if (( pTLCb->tlBAPClient.vosPendingDataBuff ) &&
4384 ( WDA_TLI_MIN_RES_BAP <= pTLCb->uResCount ) &&
Gopichand Nakkala7e48ca72012-12-31 14:15:07 -08004385 ( 0 == pTLCb->ucTxSuspended ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07004386 {
4387 WDA_TLI_PROCESS_FRAME_LEN( pTLCb->tlBAPClient.vosPendingDataBuff,
4388 usPktLen, uResLen, uTotalPktLen);
4389
Manjunathappa Prakashfb585462013-12-23 19:07:07 -08004390 if (usPktLen > WLANTL_MAX_ALLOWED_LEN)
4391 {
4392 usPktLen = WLANTL_MAX_ALLOWED_LEN;
4393 VOS_ASSERT(0);
4394 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004395
4396 if ( ( pTLCb->uResCount > (uResLen + WDA_TLI_MIN_RES_MF ) ) &&
4397 ( uRemaining > uTotalPktLen ))
4398 {
4399 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
4400 "WLAN TL:Chaining BT-AMP frame on GetFrame"));
4401
4402 vos_pkt_chain_packet( vosDataBuff,
4403 pTLCb->tlBAPClient.vosPendingDataBuff,
4404 1 /*true*/ );
4405
4406 /*BAP frames cannot be delayed*/
4407 pTLCb->bUrgent = TRUE;
4408
Arun Kumar Khandavalli0af8d3c2014-02-07 18:05:11 +05304409 vos_atomic_set( (uintptr_t*)&pTLCb->tlBAPClient.vosPendingDataBuff,
4410 (uintptr_t) NULL);
Jeff Johnson295189b2012-06-20 16:38:30 -07004411
4412 /*Update remaining len from SSC */
4413 uRemaining -= (usPktLen + WDA_DXE_HEADER_SIZE);
4414
4415 /*Update resource count */
4416 pTLCb->uResCount -= uResLen;
4417 }
4418 else
4419 {
Jeff Johnson295189b2012-06-20 16:38:30 -07004420 ucResult = uResLen + WDA_TLI_MIN_RES_MF;
Jeff Johnson295189b2012-06-20 16:38:30 -07004421 break; /* Out of resources or reached max len */
4422 }
4423 }
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -07004424 /* note: this feature implemented only after WLAN_INGETRATED_SOC */
4425 /* search 'EAPOL_HI_PRIORITY' will show EAPOL HI_PRIORITY change in TL and WDI
4426 by default, EAPOL will be treated as higher priority, which means
4427 use mgmt_pool and DXE_TX_HI prority channel.
4428 this is introduced to address EAPOL failure under high background traffic
4429 with multi-channel concurrent mode. But this change works in SCC or standalone, too.
4430 see CR#387009 and WCNSOS-8
4431 */
4432 else if (( WDA_TLI_MIN_RES_MF <= pTLCb->uResCount )&&
4433 ( 0 == pTLCb->ucTxSuspended ) &&
4434 ( uFlowMask & ( 1 << WDA_TXFLOW_MGMT ) )
4435 )
4436 {
4437 vosTempBuf = NULL;
4438 /*---------------------------------------------------------------------
4439 Check to see if there was any EAPOL packet is pending
4440 *--------------------------------------------------------------------*/
4441 for ( i = 0; i < WLAN_MAX_STA_COUNT; i++)
4442 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304443 if ((NULL != pTLCb->atlSTAClients[i]) &&
4444 (pTLCb->atlSTAClients[i]->ucExists) &&
4445 (0 == pTLCb->atlSTAClients[i]->ucTxSuspended) &&
Tushnim Bhattacharyya39a8f182013-02-20 18:10:30 -08004446 (WLANTL_STA_CONNECTED == pTLCb->atlSTAClients[i]->tlState) &&
4447 (pTLCb->atlSTAClients[i]->ucPktPending)
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -07004448 )
4449 break;
4450 }
4451
4452 if (i >= WLAN_MAX_STA_COUNT)
4453 {
4454 /* No More to Serve Exit Get Frames */
4455 break;
4456 }
4457 /* Serve EAPOL frame with HI_FLOW_MASK */
4458 ucSTAId = i;
4459
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304460 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
4461
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05304462 MTRACE(vos_trace(VOS_MODULE_ID_TL,
4463 TRACE_CODE_TL_GET_FRAMES_EAPOL, ucSTAId, pClientSTA->tlState));
4464
4465 if (pClientSTA->wSTADesc.wSTAType == WLAN_STA_INFRA)
4466 {
4467 if(0 != pClientSTA->aucACMask[WLANTL_AC_HIGH_PRIO])
4468 {
4469 pClientSTA->ucCurrentAC = WLANTL_AC_HIGH_PRIO;
4470 pTLCb->uCurServedAC = WLANTL_AC_HIGH_PRIO;
4471 }
4472 else
4473 break;
4474 }
4475 else
4476 {
4477 for (j = WLANTL_MAX_AC ; j > 0; j--)
4478 {
4479 if (0 != pClientSTA->aucACMask[j-1])
4480 {
4481 pClientSTA->ucCurrentAC = j-1;
4482 pTLCb->uCurServedAC = j-1;
4483 break;
4484 }
4485 }
4486 }
4487
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -07004488 wSTAEvent = WLANTL_TX_EVENT;
4489
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304490 pfnSTAFsm = tlSTAFsm[pClientSTA->tlState].
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -07004491 pfnSTATbl[wSTAEvent];
4492
4493 if ( NULL != pfnSTAFsm )
4494 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304495 pClientSTA->ucNoMoreData = 0;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004496 vosStatus = pfnSTAFsm( pvosGCtx, ucSTAId, &vosTempBuf, VOS_FALSE);
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -07004497
4498 if (( VOS_STATUS_SUCCESS != vosStatus ) &&
4499 ( NULL != vosTempBuf ))
4500 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304501 pClientSTA->pfnSTATxComp( pvosGCtx, vosTempBuf, vosStatus );
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -07004502 vosTempBuf = NULL;
4503 break;
4504 }/* status success*/
4505 }
4506
4507 if (NULL != vosTempBuf)
4508 {
4509 WDA_TLI_PROCESS_FRAME_LEN( vosTempBuf, usPktLen, uResLen, uTotalPktLen);
4510
Manjunathappa Prakashfb585462013-12-23 19:07:07 -08004511 if (usPktLen > WLANTL_MAX_ALLOWED_LEN)
4512 {
4513 usPktLen = WLANTL_MAX_ALLOWED_LEN;
4514 VOS_ASSERT(0);
4515 }
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -07004516
4517 TLLOG4(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_LOW,
4518 "WLAN TL:Resources needed by frame: %d", uResLen));
4519
4520 if ( ( pTLCb->uResCount >= (uResLen + WDA_TLI_MIN_RES_MF ) ) &&
4521 ( uRemaining > uTotalPktLen )
4522 )
4523 {
4524 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
4525 "WLAN TL:Chaining data frame on GetFrame"));
4526
4527 vos_pkt_chain_packet( vosDataBuff, vosTempBuf, 1 /*true*/ );
4528
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -07004529 /*EAPOL frame cannot be delayed*/
4530 pTLCb->bUrgent = TRUE;
4531
4532 vosTempBuf = NULL;
4533
4534 /*Update remaining len from SSC */
4535 uRemaining -= (usPktLen + WDA_DXE_HEADER_SIZE);
4536
4537 /*Update resource count */
4538 pTLCb->uResCount -= uResLen;
4539
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -07004540 //fow control update
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304541 pClientSTA->uIngress_length += uResLen;
4542 pClientSTA->uBuffThresholdMax = (pClientSTA->uBuffThresholdMax >= uResLen) ?
4543 (pClientSTA->uBuffThresholdMax - uResLen) : 0;
Tushnim Bhattacharyya39a8f182013-02-20 18:10:30 -08004544 pClientSTA->ucEapolPktPending = 0;
4545 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
4546 "WLAN TL:GetFrames STA: %d EAPOLPktPending %d",
4547 ucSTAId, pClientSTA->ucEapolPktPending);
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -07004548 }
4549 }
4550 else
4551 { // no EAPOL frames exit Get frames
Tushnim Bhattacharyya39a8f182013-02-20 18:10:30 -08004552 TLLOG2(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
4553 "WLAN TL:GetFrames STA: %d, no EAPOL frame, continue.",
4554 ucSTAId));
4555 continue;
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -07004556 }
4557 }
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -07004558
Jeff Johnson9b5dc4d2013-02-22 21:28:47 -08004559 else if (( WDA_TLI_MIN_RES_DATA <= pTLCb->uResCount ) &&
4560 ( 0 == pTLCb->ucTxSuspended ) &&
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05304561 ( uFlowMask & WLANTL_DATA_FLOW_MASK))
Jeff Johnson295189b2012-06-20 16:38:30 -07004562 {
4563 /*---------------------------------------------------------------------
4564 Check to see if there was any packet left behind previously due to
4565 size constraints
4566 ---------------------------------------------------------------------*/
4567 vosTempBuf = NULL;
4568
4569 if ( NULL != pTLCb->vosTempBuf )
4570 {
4571 vosTempBuf = pTLCb->vosTempBuf;
4572 pTLCb->vosTempBuf = NULL;
4573 ucSTAId = pTLCb->ucCachedSTAId;
4574 ucAC = pTLCb->ucCachedAC;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304575
4576 if ( NULL == pTLCb->atlSTAClients[ucSTAId] )
4577 {
4578 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
4579 "WLAN TL:Client Memory was not allocated on %s", __func__));
Madan Mohan Koyylamudi64258222013-01-30 14:35:10 +05304580 continue;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304581 }
4582
4583 pTLCb->atlSTAClients[ucSTAId]->ucNoMoreData = 0;
Madan Mohan Koyylamudi64258222013-01-30 14:35:10 +05304584 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
Jeff Johnson295189b2012-06-20 16:38:30 -07004585
4586 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
4587 "WLAN TL:Chaining cached data frame on GetFrame"));
4588 }
4589 else
4590 {
4591 WLAN_TLGetNextTxIds( pvosGCtx, &ucSTAId);
4592 if (ucSTAId >= WLAN_MAX_STA_COUNT)
4593 {
4594 /* Packets start coming in even after insmod Without *
4595 starting Hostapd or Interface being up *
4596 During which cases STAID is invaled and hence
4597 the check. HalMsg_ScnaComplete Triggers */
4598
4599 break;
4600 }
4601 /* ucCurrentAC should have correct AC to be served by calling
4602 WLAN_TLGetNextTxIds */
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304603 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304604 if ( NULL == pClientSTA )
4605 {
4606 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
4607 "WLAN TL:Client Memory was not allocated on %s", __func__));
Madan Mohan Koyylamudi64258222013-01-30 14:35:10 +05304608 continue;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304609 }
4610
4611 ucAC = pClientSTA->ucCurrentAC;
4612
4613 pClientSTA->ucNoMoreData = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07004614 TLLOG4(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_LOW,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004615 "WLAN TL: %s get one data frame, station ID %d ", __func__, ucSTAId));
Jeff Johnson295189b2012-06-20 16:38:30 -07004616 /*-------------------------------------------------------------------
4617 Check to see that STA is valid and tx is not suspended
4618 -------------------------------------------------------------------*/
4619 if ( ( ! WLANTL_STA_ID_INVALID( ucSTAId ) ) &&
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304620 ( 0 == pClientSTA->ucTxSuspended ) &&
4621 ( 0 == pClientSTA->fcStaTxDisabled) )
Jeff Johnson295189b2012-06-20 16:38:30 -07004622 {
4623 TLLOG4(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_LOW,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004624 "WLAN TL: %s sta id valid and not suspended ",__func__));
Jeff Johnson295189b2012-06-20 16:38:30 -07004625 wSTAEvent = WLANTL_TX_EVENT;
4626
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304627 pfnSTAFsm = tlSTAFsm[pClientSTA->tlState].
Jeff Johnson295189b2012-06-20 16:38:30 -07004628 pfnSTATbl[wSTAEvent];
4629
4630 if ( NULL != pfnSTAFsm )
4631 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304632 pClientSTA->ucNoMoreData = 0;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004633 vosStatus = pfnSTAFsm( pvosGCtx, ucSTAId, &vosTempBuf, VOS_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07004634
4635 if (( VOS_STATUS_SUCCESS != vosStatus ) &&
4636 ( NULL != vosTempBuf ))
4637 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304638 pClientSTA->pfnSTATxComp( pvosGCtx,
Jeff Johnson295189b2012-06-20 16:38:30 -07004639 vosTempBuf,
4640 vosStatus );
4641 vosTempBuf = NULL;
4642 }/* status success*/
4643 }/*NULL function state*/
4644 }/* valid STA id and ! suspended*/
4645 else
4646 {
4647 if ( ! WLANTL_STA_ID_INVALID( ucSTAId ) )
4648 {
4649 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
4650 "WLAN TL:Not fetching frame because suspended for sta ID %d",
4651 ucSTAId));
4652 }
4653 }
4654 }/* data */
4655
4656 if ( NULL != vosTempBuf )
4657 {
4658 WDA_TLI_PROCESS_FRAME_LEN( vosTempBuf, usPktLen, uResLen, uTotalPktLen);
4659
Manjunathappa Prakashfb585462013-12-23 19:07:07 -08004660 if (usPktLen > WLANTL_MAX_ALLOWED_LEN)
4661 {
4662 usPktLen = WLANTL_MAX_ALLOWED_LEN;
4663 VOS_ASSERT(0);
4664 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004665
4666 TLLOG4(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_LOW,
4667 "WLAN TL:Resources needed by frame: %d", uResLen));
4668
4669 if ( ( pTLCb->uResCount >= (uResLen + WDA_TLI_MIN_RES_BAP ) ) &&
Jeff Johnson9b5dc4d2013-02-22 21:28:47 -08004670 ( uRemaining > uTotalPktLen ) &&
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05304671 ( uFlowMask & WLANTL_DATA_FLOW_MASK ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07004672 {
4673 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
4674 "WLAN TL:Chaining data frame on GetFrame"));
4675
4676 vos_pkt_chain_packet( vosDataBuff, vosTempBuf, 1 /*true*/ );
4677 vosTempBuf = NULL;
4678
4679 /*Update remaining len from SSC */
4680 uRemaining -= (usPktLen + WDA_DXE_HEADER_SIZE);
4681
4682 /*Update resource count */
4683 pTLCb->uResCount -= uResLen;
4684
Jeff Johnson295189b2012-06-20 16:38:30 -07004685 //fow control update
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304686 pClientSTA->uIngress_length += uResLen;
4687 pClientSTA->uBuffThresholdMax = (pClientSTA->uBuffThresholdMax >= uResLen) ?
4688 (pClientSTA->uBuffThresholdMax - uResLen) : 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004689
4690 }
4691 else
4692 {
4693 /* Store this for later tx - already fetched from HDD */
4694 pTLCb->vosTempBuf = vosTempBuf;
4695 pTLCb->ucCachedSTAId = ucSTAId;
4696 pTLCb->ucCachedAC = ucAC;
Jeff Johnson295189b2012-06-20 16:38:30 -07004697 ucResult = uResLen + WDA_TLI_MIN_RES_BAP;
4698 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
4699 "min %d res required by TL.", ucResult ));
Jeff Johnson295189b2012-06-20 16:38:30 -07004700 break; /* Out of resources or reached max len */
4701 }
4702 }
4703 else
4704 {
4705 for ( i = 0; i < WLAN_MAX_STA_COUNT; i++)
4706 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304707 if (NULL != pTLCb->atlSTAClients[i] && (pTLCb->atlSTAClients[i]->ucExists) &&
4708 (pTLCb->atlSTAClients[i]->ucPktPending))
Jeff Johnson295189b2012-06-20 16:38:30 -07004709 {
4710 /* There is station to be Served */
4711 break;
4712 }
4713 }
4714 if (i >= WLAN_MAX_STA_COUNT)
4715 {
4716 /* No More to Serve Exit Get Frames */
4717 break;
4718 }
4719 else
4720 {
4721 /* More to be Served */
4722 continue;
4723 }
4724 }
4725 }
4726 else
4727 {
4728 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
4729 "WLAN TL:Returning from GetFrame: resources = %d suspended = %d",
4730 pTLCb->uResCount, pTLCb->ucTxSuspended));
Jeff Johnson295189b2012-06-20 16:38:30 -07004731 /* TL is starving even when DXE is not in low resource condition
4732 Return min resource number required and Let DXE deceide what to do */
4733 if(( 0 == pTLCb->ucTxSuspended ) &&
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05304734 ( uFlowMask & WLANTL_DATA_FLOW_MASK ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07004735 {
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07004736 TLLOG1(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -07004737 "WLAN TL:Returning from GetFrame: resources = %d",
4738 pTLCb->uResCount));
4739 ucResult = WDA_TLI_MIN_RES_DATA;
4740 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004741 break; /*out of min data resources*/
4742 }
4743
4744 pTLCb->usPendingTxCompleteCount++;
4745 /* Move data buffer up one packet */
4746 vos_pkt_walk_packet_chain( vosDataBuff, &vosDataBuff, 0/*false*/ );
4747 }
4748
4749 /*----------------------------------------------------------------------
4750 Packet chain starts at root + 1
4751 ----------------------------------------------------------------------*/
4752 vos_pkt_walk_packet_chain( vosRoot, &vosDataBuff, 1/*true*/ );
4753
4754 *pvosDataBuff = vosDataBuff;
Manjunathappa Prakashfb585462013-12-23 19:07:07 -08004755 if (pbUrgent)
4756 {
4757 *pbUrgent = pTLCb->bUrgent;
4758 }
4759 else
4760 {
4761 VOS_ASSERT( pbUrgent );
4762 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004763 return ucResult;
4764}/* WLANTL_GetFrames */
4765
4766
4767/*==========================================================================
4768
4769 FUNCTION WLANTL_TxComp
4770
4771 DESCRIPTION
4772 It is being called by BAL upon asynchronous notification of the packet
4773 or packets being sent over the bus.
4774
4775 DEPENDENCIES
4776 Tx complete cannot be called without a previous transmit.
4777
4778 PARAMETERS
4779
4780 IN
4781 pvosGCtx: pointer to the global vos context; a handle to TL's
4782 or BAL's control block can be extracted from its context
4783 vosDataBuff: it will contain a pointer to the first buffer for which
4784 the BAL report is being made, if there is more then one
4785 packet they will be chained using vOSS buffers.
4786 wTxStatus: the status of the transmitted packet, see above chapter
4787 on HDD interaction for a list of possible values
4788
4789 RETURN VALUE
4790 The result code associated with performing the operation
4791
4792 VOS_STATUS_E_INVAL: Input parameters are invalid
4793 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
4794 page fault
4795 VOS_STATUS_E_EXISTS: Station was not registered
4796 VOS_STATUS_SUCCESS: Everything is good :)
4797
4798 SIDE EFFECTS
4799
4800============================================================================*/
4801VOS_STATUS
4802WLANTL_TxComp
4803(
4804 v_PVOID_t pvosGCtx,
4805 vos_pkt_t *pFrameDataBuff,
4806 VOS_STATUS wTxStatus
4807)
4808{
4809 vos_pkt_t* vosDataBuff = (vos_pkt_t*)pFrameDataBuff;
4810 WLANTL_CbType* pTLCb = NULL;
4811 WLANTL_TxCompCBType pfnTxComp = NULL;
4812 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07004813 vos_pkt_t* vosTempTx = NULL;
4814
4815 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
4816
4817 /*------------------------------------------------------------------------
4818 Sanity check
4819 ------------------------------------------------------------------------*/
4820 if ( NULL == vosDataBuff )
4821 {
4822 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
4823 "WLAN TL:Extraneous NULL data pointer on WLANTL_TxComp"));
4824 return VOS_STATUS_E_INVAL;
4825 }
4826
4827 /*------------------------------------------------------------------------
4828 Extract TL control block
4829 ------------------------------------------------------------------------*/
4830 pTLCb = VOS_GET_TL_CB(pvosGCtx);
4831 if ( NULL == pTLCb )
4832 {
4833 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
4834 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_TxComp"));
4835 return VOS_STATUS_E_FAULT;
4836 }
4837
4838 while ((0 < pTLCb->usPendingTxCompleteCount) &&
4839 ( VOS_STATUS_SUCCESS == vosStatus ) &&
4840 ( NULL != vosDataBuff))
4841 {
4842 vos_pkt_get_user_data_ptr( vosDataBuff, VOS_PKT_USER_DATA_ID_TL,
4843 (v_PVOID_t)&pfnTxComp);
4844
4845 /*it should never be NULL - default handler should be registered if none*/
4846 if ( NULL == pfnTxComp )
4847 {
4848 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
4849 "WLAN TL:NULL pointer to Tx Complete on WLANTL_TxComp"));
4850 VOS_ASSERT(0);
4851 return VOS_STATUS_E_FAULT;
4852 }
4853
4854 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05304855 "WLAN TL:Calling Tx complete for pkt %p in function %p",
Jeff Johnson295189b2012-06-20 16:38:30 -07004856 vosDataBuff, pfnTxComp));
4857
4858 vosTempTx = vosDataBuff;
4859 vosStatus = vos_pkt_walk_packet_chain( vosDataBuff,
4860 &vosDataBuff, 1/*true*/);
4861
4862 pfnTxComp( pvosGCtx, vosTempTx, wTxStatus );
4863
4864 pTLCb->usPendingTxCompleteCount--;
4865 }
4866
Jeff Johnson295189b2012-06-20 16:38:30 -07004867
4868 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
4869 "WLAN TL: current TL values are: resources = %d "
4870 "pTLCb->usPendingTxCompleteCount = %d",
4871 pTLCb->uResCount, pTLCb->usPendingTxCompleteCount));
4872
4873 return VOS_STATUS_SUCCESS;
4874}/* WLANTL_TxComp */
4875
4876/*==========================================================================
4877
4878 FUNCTION WLANTL_CacheSTAFrame
4879
4880 DESCRIPTION
4881 Internal utility function for for caching incoming data frames that do
4882 not have a registered station yet.
4883
4884 DEPENDENCIES
4885 TL must be initiailized before this function gets called.
4886 In order to benefit from thsi caching, the components must ensure that
4887 they will only register with TL at the moment when they are fully setup
4888 and ready to receive incoming data
4889
4890 PARAMETERS
4891
4892 IN
4893
4894 pTLCb: TL control block
4895 ucSTAId: station id
4896 vosTempBuff: the data packet
4897 uDPUSig: DPU signature of the incoming packet
4898 bBcast: true if packet had the MC/BC bit set
4899
4900 RETURN VALUE
4901 The result code associated with performing the operation
4902
4903 VOS_STATUS_E_FAULT: pointer to TL cb is NULL or STA Id invalid ; access
4904 would cause a page fault
4905 VOS_STATUS_SUCCESS: Everything is good :)
4906
4907 SIDE EFFECTS
4908
4909============================================================================*/
4910static VOS_STATUS
4911WLANTL_CacheSTAFrame
4912(
4913 WLANTL_CbType* pTLCb,
4914 v_U8_t ucSTAId,
4915 vos_pkt_t* vosTempBuff,
4916 v_U32_t uDPUSig,
4917 v_U8_t bBcast,
4918 v_U8_t ucFrmType
4919)
4920{
4921 v_U8_t ucUcastSig;
4922 v_U8_t ucBcastSig;
4923 v_BOOL_t bOldSTAPkt;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304924 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004925 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
4926
4927 /*-------------------------------------------------------------------------
4928 Sanity check
4929 -------------------------------------------------------------------------*/
4930 if (( NULL == pTLCb ) || ( NULL == vosTempBuff ) )
4931 {
4932 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05304933 "WLAN TL: Invalid input pointer on WLANTL_CacheSTAFrame TL %p"
4934 " Packet %p", pTLCb, vosTempBuff ));
Jeff Johnson295189b2012-06-20 16:38:30 -07004935 return VOS_STATUS_E_FAULT;
4936 }
4937
4938 if ( WLANTL_STA_ID_INVALID( ucSTAId ) )
4939 {
4940 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
4941 "WLAN TL:Invalid station id requested on WLANTL_CacheSTAFrame"));
4942 return VOS_STATUS_E_FAULT;
4943 }
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304944 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
4945
4946 if ( NULL == pClientSTA )
4947 {
4948 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
4949 "WLAN TL:Client Memory was not allocated on %s", __func__));
4950 return VOS_STATUS_E_FAILURE;
4951 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004952
4953 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
4954 "WLAN TL:Attempting to cache pkt for STA %d, BD DPU Sig: %d with sig UC: %d, BC: %d",
4955 ucSTAId, uDPUSig,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304956 pClientSTA->wSTADesc.ucUcastSig,
4957 pClientSTA->wSTADesc.ucBcastSig));
Jeff Johnson295189b2012-06-20 16:38:30 -07004958
4959 if(WLANTL_IS_CTRL_FRAME(ucFrmType))
4960 {
4961 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
4962 "WLAN TL: No need to cache CTRL frame. Dropping"));
4963 vos_pkt_return_packet(vosTempBuff);
4964 return VOS_STATUS_SUCCESS;
4965 }
4966
4967 /*-------------------------------------------------------------------------
4968 Check if the packet that we are trying to cache belongs to the old
4969 registered station (if any) or the new (potentially)upcoming station
4970
4971 - If the STA with this Id was never registered with TL - the signature
4972 will be invalid;
4973 - If the STA was previously registered TL will have cached the former
4974 set of DPU signatures
4975 -------------------------------------------------------------------------*/
4976 if ( bBcast )
4977 {
4978 ucBcastSig = (v_U8_t)uDPUSig;
4979 bOldSTAPkt = (( WLAN_TL_INVALID_B_SIG !=
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304980 pClientSTA->wSTADesc.ucBcastSig ) &&
4981 ( ucBcastSig == pClientSTA->wSTADesc.ucBcastSig ));
Jeff Johnson295189b2012-06-20 16:38:30 -07004982 }
4983 else
4984 {
4985 ucUcastSig = (v_U8_t)uDPUSig;
4986 bOldSTAPkt = (( WLAN_TL_INVALID_U_SIG !=
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304987 pClientSTA->wSTADesc.ucUcastSig ) &&
4988 ( ucUcastSig == pClientSTA->wSTADesc.ucUcastSig ));
Jeff Johnson295189b2012-06-20 16:38:30 -07004989 }
4990
4991 /*------------------------------------------------------------------------
4992 If the value of the DPU SIG matches the old, this packet will not
4993 be cached as it belonged to the former association
4994 In case the SIG does not match - this is a packet for a potentially new
4995 associated station
4996 -------------------------------------------------------------------------*/
Varun Reddy Yeturua39b9902013-01-18 15:48:32 -08004997 if ( bOldSTAPkt || bBcast )
Jeff Johnson295189b2012-06-20 16:38:30 -07004998 {
4999 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
5000 "WLAN TL:Data packet matches old sig for sig DPU: %d UC: %d, "
5001 "BC: %d - dropping",
5002 uDPUSig,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05305003 pClientSTA->wSTADesc.ucUcastSig,
5004 pClientSTA->wSTADesc.ucBcastSig));
Jeff Johnson295189b2012-06-20 16:38:30 -07005005 vos_pkt_return_packet(vosTempBuff);
5006 }
5007 else
5008 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05305009 if ( NULL == pClientSTA->vosBegCachedFrame )
Jeff Johnson295189b2012-06-20 16:38:30 -07005010 {
5011 /*this is the first frame that we are caching */
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05305012 pClientSTA->vosBegCachedFrame = vosTempBuff;
Mihir Sheteb7337272014-04-11 15:53:08 +05305013
5014 pClientSTA->tlCacheInfo.cacheInitTime = vos_timer_get_system_time();
5015 pClientSTA->tlCacheInfo.cacheDoneTime =
5016 pClientSTA->tlCacheInfo.cacheInitTime;
5017 pClientSTA->tlCacheInfo.cacheSize = 1;
5018
Mihir Sheteae6f02b2014-04-11 19:49:21 +05305019 MTRACE(vos_trace(VOS_MODULE_ID_TL, TRACE_CODE_TL_CACHE_FRAME,
5020 ucSTAId, pClientSTA->tlCacheInfo.cacheSize));
5021
Jeff Johnson295189b2012-06-20 16:38:30 -07005022 }
5023 else
5024 {
5025 /*this is a subsequent frame that we are caching: chain to the end */
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05305026 vos_pkt_chain_packet(pClientSTA->vosEndCachedFrame,
Jeff Johnson295189b2012-06-20 16:38:30 -07005027 vosTempBuff, VOS_TRUE);
Mihir Sheteb7337272014-04-11 15:53:08 +05305028
5029 pClientSTA->tlCacheInfo.cacheDoneTime = vos_timer_get_system_time();
5030 pClientSTA->tlCacheInfo.cacheSize ++;
5031
5032 if (pClientSTA->tlCacheInfo.cacheSize % WLANTL_CACHE_TRACE_WATERMARK == 0)
5033 {
5034 VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
5035 "%s: Cache High watermark for staid:%d (%d)",
5036 __func__,ucSTAId, pClientSTA->tlCacheInfo.cacheSize);
Mihir Sheteae6f02b2014-04-11 19:49:21 +05305037 MTRACE(vos_trace(VOS_MODULE_ID_TL, TRACE_CODE_TL_CACHE_FRAME,
5038 ucSTAId, pClientSTA->tlCacheInfo.cacheSize));
Mihir Sheteb7337272014-04-11 15:53:08 +05305039 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005040 }
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05305041 pClientSTA->vosEndCachedFrame = vosTempBuff;
Jeff Johnson295189b2012-06-20 16:38:30 -07005042 }/*else new packet*/
5043
5044 return VOS_STATUS_SUCCESS;
5045}/*WLANTL_CacheSTAFrame*/
5046
5047/*==========================================================================
5048
5049 FUNCTION WLANTL_FlushCachedFrames
5050
5051 DESCRIPTION
5052 Internal utility function used by TL to flush the station cache
5053
5054 DEPENDENCIES
5055 TL must be initiailized before this function gets called.
5056
5057 PARAMETERS
5058
5059 IN
5060
5061 vosDataBuff: it will contain a pointer to the first cached buffer
5062 received,
5063
5064 RETURN VALUE
5065 The result code associated with performing the operation
5066
5067 VOS_STATUS_SUCCESS: Everything is good :)
5068
5069 SIDE EFFECTS
5070
5071 NOTE
5072 This function doesn't re-initialize vosDataBuff to NULL. It's caller's
5073 responsibility to do so, if required, after this function call.
5074 Because of this restriction, we decide to make this function to static
5075 so that upper layer doesn't need to be aware of this restriction.
5076
5077============================================================================*/
5078static VOS_STATUS
5079WLANTL_FlushCachedFrames
5080(
5081 vos_pkt_t* vosDataBuff
5082)
5083{
5084 /*----------------------------------------------------------------------
5085 Return the entire chain to vos if there are indeed cache frames
5086 ----------------------------------------------------------------------*/
5087 if ( NULL != vosDataBuff )
5088 {
5089 vos_pkt_return_packet(vosDataBuff);
5090 }
5091
5092 return VOS_STATUS_SUCCESS;
5093}/*WLANTL_FlushCachedFrames*/
5094
5095/*==========================================================================
5096
5097 FUNCTION WLANTL_ForwardSTAFrames
5098
5099 DESCRIPTION
5100 Internal utility function for either forwarding cached data to the station after
5101 the station has been registered, or flushing cached data if the station has not
5102 been registered.
5103
5104
5105 DEPENDENCIES
5106 TL must be initiailized before this function gets called.
5107
5108 PARAMETERS
5109
5110 IN
5111
5112 pTLCb: TL control block
5113 ucSTAId: station id
5114
5115 RETURN VALUE
5116 The result code associated with performing the operation
5117
5118 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
5119 page fault
5120 VOS_STATUS_SUCCESS: Everything is good :)
5121
5122 SIDE EFFECTS
5123 This function doesn't re-initialize vosDataBuff to NULL. It's caller's
5124 responsibility to do so, if required, after this function call.
5125 Because of this restriction, we decide to make this function to static
5126 so that upper layer doesn't need to be aware of this restriction.
5127
5128============================================================================*/
5129static VOS_STATUS
5130WLANTL_ForwardSTAFrames
5131(
5132 void* pvosGCtx,
5133 v_U8_t ucSTAId,
5134 v_U8_t ucUcastSig,
5135 v_U8_t ucBcastSig
5136)
5137{
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05305138 WLANTL_CbType* pTLCb = NULL;
5139 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005140 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
5141
5142 /*-------------------------------------------------------------------------
5143 Sanity check
5144 -------------------------------------------------------------------------*/
5145 pTLCb = VOS_GET_TL_CB(pvosGCtx);
5146 if ( NULL == pTLCb )
5147 {
5148 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05305149 "WLAN TL: Invalid input pointer on WLANTL_ForwardSTAFrames TL %p",
Jeff Johnson295189b2012-06-20 16:38:30 -07005150 pTLCb ));
5151 return VOS_STATUS_E_FAULT;
5152 }
5153
5154 if ( WLANTL_STA_ID_INVALID( ucSTAId ) )
5155 {
5156 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
5157 "WLAN TL:Invalid station id requested on WLANTL_ForwardSTAFrames"));
5158 return VOS_STATUS_E_FAULT;
5159 }
5160
5161 //WLAN_TL_LOCK_STA_CACHE(pTLCb->atlSTAClients[ucSTAId]);
5162
5163 /*------------------------------------------------------------------------
5164 Check if station has not been registered in the mean while
5165 if not registered, flush cached frames.
5166 ------------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05305167 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
5168
5169 if ( NULL == pClientSTA )
5170 {
5171 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
5172 "WLAN TL:Client Memory was not allocated on %s", __func__));
5173 return VOS_STATUS_E_FAILURE;
5174 }
5175
5176 if ( 0 == pClientSTA->ucExists )
Jeff Johnson295189b2012-06-20 16:38:30 -07005177 {
5178 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
5179 "WLAN TL:Station has been deleted for STA %d - flushing cache", ucSTAId));
Mihir Sheteae6f02b2014-04-11 19:49:21 +05305180 MTRACE(vos_trace(VOS_MODULE_ID_TL, TRACE_CODE_TL_FLUSH_CACHED_FRAMES,
5181 ucSTAId, pClientSTA->tlCacheInfo.cacheSize));
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05305182 WLANTL_FlushCachedFrames(pClientSTA->vosBegCachedFrame);
Jeff Johnson295189b2012-06-20 16:38:30 -07005183 goto done;
5184 }
5185
5186 /*------------------------------------------------------------------------
5187 Forwarding cache frames received while the station was in the process
5188 of being registered with the rest of the SW components
5189
5190 Access to the cache must be locked; similarly updating the signature and
5191 the existence flag must be synchronized because these values are checked
5192 during cached
5193 ------------------------------------------------------------------------*/
5194 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
5195 "WLAN TL:Preparing to fwd packets for STA %d", ucSTAId));
5196
5197 /*-----------------------------------------------------------------------
5198 Save the new signature values
5199 ------------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05305200 pClientSTA->wSTADesc.ucUcastSig = ucUcastSig;
5201 pClientSTA->wSTADesc.ucBcastSig = ucBcastSig;
Jeff Johnson295189b2012-06-20 16:38:30 -07005202
5203 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
5204 "WLAN TL:Fwd-ing packets for STA %d UC %d BC %d",
5205 ucSTAId, ucUcastSig, ucBcastSig));
5206
5207 /*-------------------------------------------------------------------------
5208 Check to see if we have any cached data to forward
5209 -------------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05305210 if ( NULL != pClientSTA->vosBegCachedFrame )
Jeff Johnson295189b2012-06-20 16:38:30 -07005211 {
5212 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
5213 "WLAN TL: Fwd-ing Cached packets for station %d", ucSTAId ));
5214
5215 WLANTL_RxCachedFrames( pTLCb,
5216 ucSTAId,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05305217 pClientSTA->vosBegCachedFrame);
Jeff Johnson295189b2012-06-20 16:38:30 -07005218 }
5219 else
5220 {
5221 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
5222 "WLAN TL: NO cached packets for station %d", ucSTAId ));
5223 }
5224
5225done:
5226 /*-------------------------------------------------------------------------
5227 Clear the station cache
5228 -------------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05305229 pClientSTA->vosBegCachedFrame = NULL;
5230 pClientSTA->vosEndCachedFrame = NULL;
Mihir Sheteb7337272014-04-11 15:53:08 +05305231 pClientSTA->tlCacheInfo.cacheSize = 0;
5232 pClientSTA->tlCacheInfo.cacheClearTime = vos_timer_get_system_time();
Jeff Johnson295189b2012-06-20 16:38:30 -07005233
5234 /*-----------------------------------------------------------------------
5235 After all the init is complete we can mark the existance flag
5236 ----------------------------------------------------------------------*/
Katya Nigam63902932014-06-26 19:04:23 +05305237 pClientSTA->enableCaching = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005238
5239 //WLAN_TL_UNLOCK_STA_CACHE(pTLCb->atlSTAClients[ucSTAId]);
5240 return VOS_STATUS_SUCCESS;
5241
5242}/*WLANTL_ForwardSTAFrames*/
5243
5244
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005245#if defined(FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_ESE_UPLOAD)
Jeff Johnson295189b2012-06-20 16:38:30 -07005246/*==========================================================================
5247
5248 FUNCTION WLANTL_IsIAPPFrame
5249
5250 DESCRIPTION
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005251 Internal utility function for detecting incoming ESE IAPP frames
Jeff Johnson295189b2012-06-20 16:38:30 -07005252
5253 DEPENDENCIES
5254
5255 PARAMETERS
5256
5257 IN
5258
5259 pvBDHeader: pointer to the BD header
5260 vosTempBuff: the data packet
5261
5262 IN/OUT
5263 pFirstDataPktArrived: static from caller function; used for rssi
5264 computation
5265 RETURN VALUE
5266 The result code associated with performing the operation
5267
5268 VOS_TRUE: It is a IAPP frame
5269 VOS_FALSE: It is NOT IAPP frame
5270
5271 SIDE EFFECTS
5272
5273============================================================================*/
5274v_BOOL_t
5275WLANTL_IsIAPPFrame
5276(
5277 v_PVOID_t pvBDHeader,
5278 vos_pkt_t* vosTempBuff
5279)
5280{
5281 v_U16_t usMPDUDOffset;
5282 v_U8_t ucOffset;
5283 v_U8_t ucSnapHdr[WLANTL_LLC_SNAP_SIZE];
5284 v_SIZE_t usSnapHdrSize = WLANTL_LLC_SNAP_SIZE;
5285 VOS_STATUS vosStatus;
5286
5287 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
5288
5289 /*------------------------------------------------------------------------
5290 Check if OUI field is present.
5291 -------------------------------------------------------------------------*/
5292 if ( VOS_FALSE == WDA_IS_RX_LLC_PRESENT(pvBDHeader) )
5293 {
5294 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
5295 "WLAN TL:LLC header removed, cannot determine BT-AMP type -"
5296 "dropping pkt"));
5297 /* Drop packet */
5298 vos_pkt_return_packet(vosTempBuff);
5299 return VOS_TRUE;
5300 }
5301 usMPDUDOffset = (v_U8_t)WDA_GET_RX_MPDU_DATA_OFFSET(pvBDHeader);
5302 ucOffset = (v_U8_t)usMPDUDOffset + WLANTL_LLC_SNAP_OFFSET;
5303
5304 vosStatus = vos_pkt_extract_data( vosTempBuff, ucOffset,
5305 (v_PVOID_t)ucSnapHdr, &usSnapHdrSize);
5306
5307 if (( VOS_STATUS_SUCCESS != vosStatus))
5308 {
5309 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
5310 "Unable to extract Snap Hdr of data packet -"
5311 "dropping pkt"));
5312 return VOS_FALSE;
5313 }
5314
5315 /*------------------------------------------------------------------------
5316 Check if this is IAPP frame by matching Aironet Snap hdr.
5317 -------------------------------------------------------------------------*/
5318 // Compare returns 1 if values are same and 0
5319 // if not the same.
5320 if (( WLANTL_LLC_SNAP_SIZE != usSnapHdrSize ) ||
5321 ( 0 == vos_mem_compare(ucSnapHdr, (v_PVOID_t)WLANTL_AIRONET_SNAP_HEADER,
5322 WLANTL_LLC_SNAP_SIZE ) ))
5323 {
5324 return VOS_FALSE;
5325 }
5326
5327 return VOS_TRUE;
5328
5329}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005330#endif //FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07005331
5332/*==========================================================================
5333
5334 FUNCTION WLANTL_ProcessBAPFrame
5335
5336 DESCRIPTION
5337 Internal utility function for processing incoming BT-AMP frames
5338
5339 DEPENDENCIES
5340 TL must be initiailized before this function gets called.
5341 Bothe the BT-AMP station and the BAP Ctrl path must have been previously
5342 registered with TL.
5343
5344 PARAMETERS
5345
5346 IN
5347
5348 pvBDHeader: pointer to the BD header
5349 vosTempBuff: the data packet
5350 pTLCb: TL control block
5351 ucSTAId: station id
5352
5353 IN/OUT
5354 pFirstDataPktArrived: static from caller function; used for rssi
5355 computation
5356 RETURN VALUE
5357 The result code associated with performing the operation
5358
5359 VOS_STATUS_E_INVAL: Input parameters are invalid
5360 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
5361 page fault
5362 VOS_STATUS_SUCCESS: Everything is good :)
5363
5364 SIDE EFFECTS
5365
5366============================================================================*/
5367v_BOOL_t
5368WLANTL_ProcessBAPFrame
5369(
5370 v_PVOID_t pvBDHeader,
5371 vos_pkt_t* vosTempBuff,
5372 WLANTL_CbType* pTLCb,
5373 v_U8_t* pFirstDataPktArrived,
5374 v_U8_t ucSTAId
5375)
5376{
5377 v_U16_t usMPDUDOffset;
5378 v_U8_t ucOffset;
5379 v_U8_t ucOUI[WLANTL_LLC_OUI_SIZE];
5380 v_SIZE_t usOUISize = WLANTL_LLC_OUI_SIZE;
5381 VOS_STATUS vosStatus;
5382 v_U16_t usType;
5383 v_SIZE_t usTypeLen = sizeof(usType);
5384 v_U8_t ucMPDUHOffset;
5385 v_U8_t ucMPDUHLen = 0;
5386 v_U16_t usActualHLen = 0;
5387
5388 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
5389
5390 /*------------------------------------------------------------------------
5391 Extract OUI and type from LLC and validate; if non-data send to BAP
5392 -------------------------------------------------------------------------*/
5393 if ( VOS_FALSE == WDA_IS_RX_LLC_PRESENT(pvBDHeader) )
5394 {
5395 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
5396 "WLAN TL:LLC header removed, cannot determine BT-AMP type -"
5397 "dropping pkt"));
5398 /* Drop packet */
5399 vos_pkt_return_packet(vosTempBuff);
5400 return VOS_TRUE;
5401 }
5402
5403 usMPDUDOffset = (v_U8_t)WDA_GET_RX_MPDU_DATA_OFFSET(pvBDHeader);
5404 ucMPDUHOffset = (v_U8_t)WDA_GET_RX_MPDU_HEADER_OFFSET(pvBDHeader);
5405 ucMPDUHLen = (v_U8_t)WDA_GET_RX_MPDU_HEADER_LEN(pvBDHeader);
5406 ucOffset = (v_U8_t)usMPDUDOffset + WLANTL_LLC_OUI_OFFSET;
5407
5408 vosStatus = vos_pkt_extract_data( vosTempBuff, ucOffset,
5409 (v_PVOID_t)ucOUI, &usOUISize);
5410
5411#if 0
5412 // Compare returns 1 if values are same and 0
5413 // if not the same.
5414 if (( WLANTL_LLC_OUI_SIZE != usOUISize ) ||
5415 ( 0 == vos_mem_compare(ucOUI, (v_PVOID_t)WLANTL_BT_AMP_OUI,
5416 WLANTL_LLC_OUI_SIZE ) ))
5417 {
5418 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
5419 "LLC header points to diff OUI in BT-AMP station -"
5420 "dropping pkt"));
5421 /* Drop packet */
5422 vos_pkt_return_packet(vosTempBuff);
5423 return VOS_TRUE;
5424 }
5425#endif
5426 /*------------------------------------------------------------------------
5427 Extract LLC OUI and ensure that this is indeed a BT-AMP frame
5428 ------------------------------------------------------------------------*/
5429 vosStatus = vos_pkt_extract_data( vosTempBuff,
5430 ucOffset + WLANTL_LLC_OUI_SIZE,
5431 (v_PVOID_t)&usType, &usTypeLen);
5432
5433 if (( VOS_STATUS_SUCCESS != vosStatus) ||
5434 ( sizeof(usType) != usTypeLen ))
5435 {
5436 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
5437 "Unable to extract type on incoming BAP packet -"
5438 "dropping pkt"));
5439 /* Drop packet */
5440 vos_pkt_return_packet(vosTempBuff);
5441 return VOS_TRUE;
5442 }
5443
5444 /*------------------------------------------------------------------------
5445 Check if this is BT-AMP data or ctrl packet(RSN, LinkSvision, ActivityR)
5446 ------------------------------------------------------------------------*/
5447 usType = vos_be16_to_cpu(usType);
5448
5449 if (WLANTL_BAP_IS_NON_DATA_PKT_TYPE(usType))
5450 {
5451 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
5452 "WLAN TL:Non-data packet received over BT-AMP link: %d, => BAP",
5453 usType));
5454
5455 /*Flatten packet as BAP expects to be able to peek*/
5456 if ( VOS_STATUS_SUCCESS != vos_pkt_flatten_rx_pkt(&vosTempBuff))
5457 {
5458 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
5459 "WLAN TL:Cannot flatten BT-AMP packet - dropping"));
5460 /* Drop packet */
5461 vos_pkt_return_packet(vosTempBuff);
5462 return VOS_TRUE;
5463 }
5464
5465 /* Send packet to BAP client*/
Jeff Johnson295189b2012-06-20 16:38:30 -07005466 if ( VOS_STATUS_SUCCESS != WDA_DS_TrimRxPacketInfo( vosTempBuff ) )
5467 {
5468 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
5469 "WLAN TL:BD header corrupted - dropping packet"));
5470 /* Drop packet */
5471 vos_pkt_return_packet(vosTempBuff);
5472 return VOS_TRUE;
5473 }
5474
5475 if ( 0 == WDA_GET_RX_FT_DONE(pvBDHeader) )
5476 {
5477 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
5478 "Non-data packet received over BT-AMP link: Sending it for "
5479 "frame Translation"));
5480
5481 if (usMPDUDOffset > ucMPDUHOffset)
5482 {
5483 usActualHLen = usMPDUDOffset - ucMPDUHOffset;
5484 }
5485
5486 /* software frame translation for BTAMP WDS.*/
5487 WLANTL_Translate80211To8023Header( vosTempBuff, &vosStatus, usActualHLen,
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005488 ucMPDUHLen, pTLCb,ucSTAId, VOS_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07005489
5490 }
5491 if (pTLCb->tlBAPClient.pfnTlBAPRx)
5492 pTLCb->tlBAPClient.pfnTlBAPRx( vos_get_global_context(VOS_MODULE_ID_TL,pTLCb),
5493 vosTempBuff,
5494 (WLANTL_BAPFrameEnumType)usType );
Manjunathappa Prakashfb585462013-12-23 19:07:07 -08005495 else
5496 {
5497 VOS_ASSERT(0);
5498 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005499
5500 return VOS_TRUE;
5501 }
5502 else
5503 {
5504 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
5505 "WLAN TL: BAP DATA packet received over BT-AMP link: %d, => BAP",
5506 usType));
5507 /*!!!FIX ME!!*/
5508 #if 0
5509 /*--------------------------------------------------------------------
5510 For data packet collect phy stats RSSI and Link Quality
5511 Calculate the RSSI average and save it. Continuous average is done.
5512 --------------------------------------------------------------------*/
5513 if ( *pFirstDataPktArrived == 0)
5514 {
5515 pTLCb->atlSTAClients[ucSTAId].rssiAvg =
5516 WLANHAL_GET_RSSI_AVERAGE( pvBDHeader );
5517 pTLCb->atlSTAClients[ucSTAId].uLinkQualityAvg =
5518 WLANHAL_RX_BD_GET_SNR( pvBDHeader );
5519
5520 // Rcvd 1st pkt, start average from next time
5521 *pFirstDataPktArrived = 1;
5522 }
5523 else
5524 {
5525 pTLCb->atlSTAClients[ucSTAId].rssiAvg =
5526 (WLANHAL_GET_RSSI_AVERAGE( pvBDHeader ) +
5527 pTLCb->atlSTAClients[ucSTAId].rssiAvg)/2;
5528 pTLCb->atlSTAClients[ucSTAId].uLinkQualityAvg =
5529 (WLANHAL_RX_BD_GET_SNR( pvBDHeader ) +
5530 pTLCb->atlSTAClients[ucSTAId].uLinkQualityAvg)/2;
5531 }/*Else, first data packet*/
5532 #endif
5533 }/*BT-AMP data packet*/
5534
5535 return VOS_FALSE;
5536}/*WLANTL_ProcessBAPFrame*/
5537
Jeff Johnson295189b2012-06-20 16:38:30 -07005538
5539/*==========================================================================
5540
5541 FUNCTION WLANTL_ProcessFCFrame
5542
5543 DESCRIPTION
5544 Internal utility function for processing incoming Flow Control frames. Enable
5545 or disable LWM mode based on the information.
5546
5547 DEPENDENCIES
5548 TL must be initiailized before this function gets called.
5549 FW sends up special flow control frame.
5550
5551 PARAMETERS
5552
5553 IN
5554 pvosGCtx pointer to vos global context
5555 pvBDHeader: pointer to the BD header
5556 pTLCb: TL control block
5557 pvBDHeader pointer to BD header.
5558
5559 IN/OUT
5560 pFirstDataPktArrived: static from caller function; used for rssi
5561 computation
5562 RETURN VALUE
5563 The result code associated with performing the operation
5564
5565 VOS_STATUS_E_INVAL: Input frame are invalid
5566 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
5567 page fault
5568 VOS_STATUS_SUCCESS: Everything is good :)
5569
5570 SIDE EFFECTS
5571 The ingress and egress of each station will be updated. If needed, LWM mode will
5572 be enabled or disabled based on the flow control algorithm.
5573
5574============================================================================*/
5575v_BOOL_t
5576WLANTL_ProcessFCFrame
5577(
5578 v_PVOID_t pvosGCtx,
5579 vos_pkt_t* pvosDataBuff,
5580 v_PVOID_t pvBDHeader
5581)
5582{
5583#if 1 //enable processing of only fcStaTxDisabled bitmap for now. the else part is old better qos code.
5584 // need to revisit the old code for full implementation.
Hoonki Lee14621352013-04-16 17:51:19 -07005585 v_U8_t ucSTAId;
5586 v_U16_t ucStaValidBitmap;
5587 v_U16_t ucStaTxDisabledBitmap;
5588 WLANTL_CbType* pTLCb = NULL;
5589 #ifdef TL_DEBUG_FC
5590 v_U32_t rxTimeStamp;
5591 v_U32_t curTick;
5592 #endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005593 /*------------------------------------------------------------------------
Hoonki Lee14621352013-04-16 17:51:19 -07005594 Extract TL control block
Jeff Johnson295189b2012-06-20 16:38:30 -07005595 ------------------------------------------------------------------------*/
5596 pTLCb = VOS_GET_TL_CB(pvosGCtx);
5597 if ( NULL == pTLCb )
5598 {
5599 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
5600 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_SuspendDataTx"));
5601 return VOS_STATUS_E_FAULT;
5602 }
Hoonki Lee14621352013-04-16 17:51:19 -07005603 ucStaValidBitmap = WDA_GET_RX_FC_VALID_STA_MASK(pvBDHeader);
5604 ucStaTxDisabledBitmap = WDA_GET_RX_FC_STA_TX_DISABLED_BITMAP(pvBDHeader);
5605#ifdef TL_DEBUG_FC
5606 rxTimeStamp = WDA_GET_RX_TIMESTAMP(pvBDHeader);
5607 /* hard code of MTU_GLOBAL_TIMER_ADDR to calculate the time between generated and processed */
5608 wpalReadRegister(0x03081400+0x1D4, &curTick);
Jeff Johnson295189b2012-06-20 16:38:30 -07005609
Jeff Johnson295189b2012-06-20 16:38:30 -07005610 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Arif Hussainf2b00992013-11-17 21:46:15 -08005611 "%ld (%ld-%ld): Disabled %x Valid %x", curTick > rxTimeStamp ? curTick - rxTimeStamp : rxTimeStamp - (0xFFFFFFFF - curTick),
Hoonki Lee14621352013-04-16 17:51:19 -07005612 curTick, rxTimeStamp, ucStaTxDisabledBitmap, ucStaValidBitmap));
5613#endif
5614 for(ucSTAId = 0; ucStaValidBitmap != 0; ucStaValidBitmap >>=1, ucStaTxDisabledBitmap >>= 1, ucSTAId ++)
Jeff Johnson295189b2012-06-20 16:38:30 -07005615 {
Hoonki Lee14621352013-04-16 17:51:19 -07005616 if ( (0 == (ucStaValidBitmap & 0x1)) || (pTLCb->atlSTAClients[ucSTAId] && (0 == pTLCb->atlSTAClients[ucSTAId]->ucExists)) )
5617 continue;
5618
5619 if (ucStaTxDisabledBitmap & 0x1)
5620 {
5621 WLANTL_SuspendDataTx(pvosGCtx, &ucSTAId, NULL);
5622 }
5623 else
5624 {
5625 WLANTL_ResumeDataTx(pvosGCtx, &ucSTAId);
5626 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005627 }
5628
5629#else
5630 VOS_STATUS vosStatus;
5631 tpHalFcRxBd pvFcRxBd = NULL;
5632 v_U8_t ucBitCheck = 0x1;
5633 v_U8_t ucStaValid = 0;
5634 v_U8_t ucSTAId = 0;
5635
5636 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
5637 "Received FC Response");
5638 if ( (NULL == pTLCb) || (NULL == pvosDataBuff))
5639 {
5640 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Arif Hussainf2b00992013-11-17 21:46:15 -08005641 "WLAN TL:Invalid pointer in %s", __func__));
Jeff Johnson295189b2012-06-20 16:38:30 -07005642 return VOS_STATUS_E_FAULT;
5643 }
5644 vosStatus = vos_pkt_peek_data( pvosDataBuff, 0, (v_PVOID_t)&pvFcRxBd,
5645 sizeof(tHalFcRxBd));
5646
5647 if ( (VOS_STATUS_SUCCESS != vosStatus) || (NULL == pvFcRxBd) )
5648 {
5649 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
5650 "WLAN TL:wrong FC Rx packet"));
5651 return VOS_STATUS_E_INVAL;
5652 }
5653
5654 // need to swap bytes in the FC contents.
5655 WLANHAL_SwapFcRxBd(&pvFcRxBd->fcSTATxQLen[0]);
5656
5657 //logic to enable/disable LWM mode for each station
5658 for( ucStaValid = (v_U8_t)pvFcRxBd->fcSTAValidMask; ucStaValid; ucStaValid >>= 1, ucBitCheck <<= 1, ucSTAId ++)
5659 {
5660 if ( (0 == (ucStaValid & 0x1)) || (0 == pTLCb->atlSTAClients[ucSTAId].ucExists) )
5661 {
5662 continue;
5663 }
5664
5665 if ( pvFcRxBd->fcSTAThreshIndMask & ucBitCheck )
5666 {
5667 //LWM event is reported by FW. Able to fetch more packet
5668 if( pTLCb->atlSTAClients[ucSTAId].ucLwmModeEnabled )
5669 {
5670 //Now memory usage is below LWM. Station can send more packets.
5671 pTLCb->atlSTAClients[ucSTAId].ucLwmEventReported = TRUE;
5672 }
5673 else
5674 {
5675 TLLOG4(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_LOW,
Arif Hussainf2b00992013-11-17 21:46:15 -08005676 "WLAN TL: FW report LWM event but the station %d is not in LWM mode", ucSTAId));
Jeff Johnson295189b2012-06-20 16:38:30 -07005677 }
5678 }
5679
5680 //calculate uEgress_length/uIngress_length only after receiving enough packets
5681 if (WLANTL_LWM_INGRESS_SAMPLE_THRESHOLD <= pTLCb->atlSTAClients[ucSTAId].uIngress_length)
5682 {
5683 //check memory usage info to see whether LWM mode should be enabled for the station
5684 v_U32_t uEgress_length = pTLCb->atlSTAClients[ucSTAId].uIngress_length +
5685 pTLCb->atlSTAClients[ucSTAId].bmuMemConsumed - pvFcRxBd->fcSTATxQLen[ucSTAId];
5686
5687 //if ((float)uEgress_length/(float)pTLCb->atlSTAClients[ucSTAId].uIngress_length
5688 // <= WLANTL_LWM_EGRESS_INGRESS_THRESHOLD)
5689 if ( (pTLCb->atlSTAClients[ucSTAId].uIngress_length > uEgress_length) &&
5690 ((pTLCb->atlSTAClients[ucSTAId].uIngress_length - uEgress_length ) >=
5691 (pTLCb->atlSTAClients[ucSTAId].uIngress_length >> 2))
5692 )
5693 {
5694 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
Arif Hussainf2b00992013-11-17 21:46:15 -08005695 "WLAN TL:Enable LWM mode for station %d", ucSTAId));
Jeff Johnson295189b2012-06-20 16:38:30 -07005696 pTLCb->atlSTAClients[ucSTAId].ucLwmModeEnabled = TRUE;
5697 }
5698 else
5699 {
5700 if( pTLCb->atlSTAClients[ucSTAId].ucLwmModeEnabled )
5701 {
5702 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
Arif Hussainf2b00992013-11-17 21:46:15 -08005703 "WLAN TL:Disable LWM mode for station %d", ucSTAId));
Jeff Johnson295189b2012-06-20 16:38:30 -07005704 pTLCb->atlSTAClients[ucSTAId].ucLwmModeEnabled = FALSE;
5705 }
5706
5707 }
5708
5709 //remember memory usage in FW starting from this round
5710 pTLCb->atlSTAClients[ucSTAId].bmuMemConsumed = pvFcRxBd->fcSTATxQLen[ucSTAId];
5711 pTLCb->atlSTAClients[ucSTAId].uIngress_length = 0;
5712 } //(WLANTL_LWM_INGRESS_SAMPLE_THRESHOLD <= pTLCb->atlSTAClients[ucSTAId].uIngress_length)
5713
5714 if( pTLCb->atlSTAClients[ucSTAId].ucLwmModeEnabled )
5715 {
5716 //always update current maximum allowed memeory usage
5717 pTLCb->atlSTAClients[ucSTAId].uBuffThresholdMax = WLANTL_STA_BMU_THRESHOLD_MAX -
5718 pvFcRxBd->fcSTATxQLen[ucSTAId];
5719 }
5720
5721 }
5722#endif
5723
5724 return VOS_STATUS_SUCCESS;
5725}
Jeff Johnson295189b2012-06-20 16:38:30 -07005726
5727
5728/*==========================================================================
5729
5730 FUNCTION WLANTL_RxFrames
5731
5732 DESCRIPTION
5733 Callback registered by TL and called by BAL when a packet is received
5734 over the bus. Upon the call of this function TL will make the necessary
5735 decision with regards to the forwarding or queuing of this packet and
5736 the layer it needs to be delivered to.
5737
5738 DEPENDENCIES
5739 TL must be initiailized before this function gets called.
5740 If the frame carried is a data frame then the station for which it is
5741 destined to must have been previously registered with TL.
5742
5743 PARAMETERS
5744
5745 IN
5746 pvosGCtx: pointer to the global vos context; a handle to TL's
5747 or BAL's control block can be extracted from its context
5748
5749 vosDataBuff: it will contain a pointer to the first buffer received,
5750 if there is more then one packet they will be chained
5751 using vOSS buffers.
5752
5753 RETURN VALUE
5754 The result code associated with performing the operation
5755
5756 VOS_STATUS_E_INVAL: Input parameters are invalid
5757 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
5758 page fault
5759 VOS_STATUS_SUCCESS: Everything is good :)
5760
5761 SIDE EFFECTS
5762
5763============================================================================*/
5764VOS_STATUS
5765WLANTL_RxFrames
5766(
5767 v_PVOID_t pvosGCtx,
5768 vos_pkt_t *pFrameDataBuff
5769)
5770{
5771 vos_pkt_t* vosDataBuff = (vos_pkt_t*)pFrameDataBuff;
5772 WLANTL_CbType* pTLCb = NULL;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05305773 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005774 WLANTL_STAFuncType pfnSTAFsm;
5775 vos_pkt_t* vosTempBuff;
5776 v_U8_t ucSTAId;
5777 VOS_STATUS vosStatus;
5778 v_U8_t ucFrmType;
5779 v_PVOID_t pvBDHeader = NULL;
5780 WLANTL_STAEventType wSTAEvent = WLANTL_RX_EVENT;
5781 v_U8_t ucTid = 0;
5782 v_BOOL_t broadcast = VOS_FALSE;
5783 v_BOOL_t selfBcastLoopback = VOS_FALSE;
Madan Mohan Koyyalamudidfd6aa82012-10-18 20:18:43 -07005784 static v_U8_t first_data_pkt_arrived;
Jeff Johnson295189b2012-06-20 16:38:30 -07005785 v_U32_t uDPUSig;
Jeff Johnson295189b2012-06-20 16:38:30 -07005786 v_U16_t usPktLen;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08005787#ifdef FEATURE_WLAN_TDLS_INTERNAL
5788 v_U8_t ucMPDUHLen = 0 ;
5789 v_U16_t usEtherType = 0;
5790#endif
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005791 v_BOOL_t bForwardIAPPwithLLC = VOS_FALSE;
Dino Mycle3b9536d2014-07-09 22:05:24 +05305792#ifdef WLAN_FEATURE_LINK_LAYER_STATS
5793 v_S7_t currentAvgRSSI = 0;
5794 v_U8_t ac;
5795
5796#endif
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005797
Jeff Johnson295189b2012-06-20 16:38:30 -07005798 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
5799
5800 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
5801 "WLAN TL:TL Receive Frames called"));
5802
5803 /*------------------------------------------------------------------------
5804 Sanity check
5805 ------------------------------------------------------------------------*/
5806 if ( NULL == vosDataBuff )
5807 {
5808 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
5809 "WLAN TL:Invalid parameter sent on WLANTL_RxFrames"));
5810 return VOS_STATUS_E_INVAL;
5811 }
5812
Katya Nigam3802f202013-12-16 19:27:14 +05305813 /*------------------------------------------------------------------------
5814 Popolaute timestamp as the time when packet arrives
5815 ---------------------------------------------------------------------- */
5816 vosDataBuff->timestamp = vos_timer_get_system_ticks();
5817
Jeff Johnson295189b2012-06-20 16:38:30 -07005818 /*------------------------------------------------------------------------
5819 Extract TL control block
5820 ------------------------------------------------------------------------*/
5821 pTLCb = VOS_GET_TL_CB(pvosGCtx);
5822 if ( NULL == pTLCb )
5823 {
5824 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
5825 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_ChangeSTAState"));
5826 return VOS_STATUS_E_FAULT;
5827 }
5828
5829 /*---------------------------------------------------------------------
5830 Save the initial buffer - this is the first received buffer
5831 ---------------------------------------------------------------------*/
5832 vosTempBuff = vosDataBuff;
5833
5834 while ( NULL != vosTempBuff )
5835 {
Madan Mohan Koyyalamudia148e1e2012-11-30 14:52:59 -08005836 broadcast = VOS_FALSE;
5837 selfBcastLoopback = VOS_FALSE;
5838
Jeff Johnson295189b2012-06-20 16:38:30 -07005839 vos_pkt_walk_packet_chain( vosDataBuff, &vosDataBuff, 1/*true*/ );
5840
5841 /*---------------------------------------------------------------------
5842 Peek at BD header - do not remove
5843 !!! Optimize me: only part of header is needed; not entire one
5844 ---------------------------------------------------------------------*/
5845 vosStatus = WDA_DS_PeekRxPacketInfo( vosTempBuff, (v_PVOID_t)&pvBDHeader, 1/*Swap BD*/ );
5846
5847 if ( NULL == pvBDHeader )
5848 {
5849 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
5850 "WLAN TL:Cannot extract BD header"));
5851 /* Drop packet */
5852 vos_pkt_return_packet(vosTempBuff);
5853 vosTempBuff = vosDataBuff;
5854 continue;
5855 }
5856
Jeff Johnson295189b2012-06-20 16:38:30 -07005857 /*---------------------------------------------------------------------
5858 Check if FC frame reported from FW
5859 ---------------------------------------------------------------------*/
5860 if(WDA_IS_RX_FC(pvBDHeader))
5861 {
5862 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
5863 "WLAN TL:receive one FC frame"));
5864
5865 WLANTL_ProcessFCFrame(pvosGCtx, vosTempBuff, pvBDHeader);
5866 /* Drop packet */
5867 vos_pkt_return_packet(vosTempBuff);
5868 vosTempBuff = vosDataBuff;
5869 continue;
5870 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005871
5872 /* AMSDU HW bug fix
5873 * After 2nd AMSDU subframe HW could not handle BD correctly
5874 * HAL workaround is needed */
5875 if(WDA_GET_RX_ASF(pvBDHeader))
5876 {
5877 WDA_DS_RxAmsduBdFix(pvosGCtx, pvBDHeader);
5878 }
5879
5880 /*---------------------------------------------------------------------
5881 Extract frame control field from 802.11 header if present
5882 (frame translation not done)
5883 ---------------------------------------------------------------------*/
5884
5885 vosStatus = WDA_DS_GetFrameTypeSubType( pvosGCtx, vosTempBuff,
5886 pvBDHeader, &ucFrmType );
5887 if ( VOS_STATUS_SUCCESS != vosStatus )
5888 {
5889 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
5890 "WLAN TL:Cannot extract Frame Control Field"));
5891 /* Drop packet */
5892 vos_pkt_return_packet(vosTempBuff);
5893 vosTempBuff = vosDataBuff;
5894 continue;
5895 }
5896
Mohit Khanna698ba2a2012-12-04 15:08:18 -08005897#ifdef FEATURE_WLAN_TDLS_INTERNAL
5898 if ( WLANTL_IS_DATA_FRAME(ucFrmType))
5899 {
5900 ucMPDUHLen = (v_U8_t)WDA_GET_RX_MPDU_HEADER_LEN(pvBDHeader);
5901 WLANTL_GetEtherType_2(pvBDHeader, vosTempBuff, ucMPDUHLen, &usEtherType) ;
5902 }
5903#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005904 vos_pkt_get_packet_length(vosTempBuff, &usPktLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07005905
5906 /*---------------------------------------------------------------------
5907 Check if management and send to PE
5908 ---------------------------------------------------------------------*/
5909
Mohit Khanna698ba2a2012-12-04 15:08:18 -08005910 if ( WLANTL_IS_MGMT_FRAME(ucFrmType)
5911#ifdef FEATURE_WLAN_TDLS_INTERNAL
5912 || (WLANTL_IS_TDLS_FRAME(usEtherType))
5913#endif
5914 )
Jeff Johnson295189b2012-06-20 16:38:30 -07005915 {
5916 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
5917 "WLAN TL:Sending packet to management client"));
5918 if ( VOS_STATUS_SUCCESS != vos_pkt_flatten_rx_pkt(&vosTempBuff))
5919 {
5920 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
5921 "WLAN TL:Cannot flatten packet - dropping"));
5922 /* Drop packet */
5923 vos_pkt_return_packet(vosTempBuff);
5924 vosTempBuff = vosDataBuff;
5925 continue;
5926 }
5927 ucSTAId = (v_U8_t)WDA_GET_RX_STAID( pvBDHeader );
5928 /* Read RSSI and update */
5929 if(!WLANTL_STA_ID_INVALID(ucSTAId))
5930 {
5931#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
5932 /* Read RSSI and update */
5933 vosStatus = WLANTL_HSHandleRXFrame(pvosGCtx,
5934 WLANTL_MGMT_FRAME_TYPE,
5935 pvBDHeader,
5936 ucSTAId,
5937 VOS_FALSE,
5938 NULL);
5939#else
5940 vosStatus = WLANTL_ReadRSSI(pvosGCtx, pvBDHeader, ucSTAId);
5941#endif
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05305942 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
5943 {
5944 TLLOGW(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
5945 "Handle RX Management Frame fail within Handoff "
5946 "support module"));
5947 /* Do Not Drop packet at here
5948 * Revisit why HO module return fail
5949 * vos_pkt_return_packet(vosTempBuff);
5950 * vosTempBuff = vosDataBuff;
5951 * continue;
5952 */
5953 }
5954 vosStatus = WLANTL_ReadSNR(pvosGCtx, pvBDHeader, ucSTAId);
5955
5956 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
5957 {
5958 TLLOGW(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
5959 FL("Failed to Read SNR")));
5960 }
Dino Mycle3b9536d2014-07-09 22:05:24 +05305961#ifdef WLAN_FEATURE_LINK_LAYER_STATS
5962 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
5963 if ( NULL != pClientSTA)
5964 {
5965 pClientSTA->interfaceStats.mgmtRx++;
Dino Mycle3b9536d2014-07-09 22:05:24 +05305966 }
5967#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005968 }
5969
Jeff Johnson295189b2012-06-20 16:38:30 -07005970 pTLCb->tlMgmtFrmClient.pfnTlMgmtFrmRx( pvosGCtx, vosTempBuff);
5971 }
5972 else /* Data Frame */
5973 {
5974 ucSTAId = (v_U8_t)WDA_GET_RX_STAID( pvBDHeader );
5975 ucTid = (v_U8_t)WDA_GET_RX_TID( pvBDHeader );
Dino Mycle3b9536d2014-07-09 22:05:24 +05305976#ifdef WLAN_FEATURE_LINK_LAYER_STATS
5977 ac = WLANTL_TID_2_AC[ucTid];
5978#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005979
5980 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
5981 "WLAN TL:Data packet received for STA %d", ucSTAId));
5982
5983 /*------------------------------------------------------------------
5984 This should be corrected when multipe sta support is added !!!
5985 for now bcast frames will be sent to the last registered STA
5986 ------------------------------------------------------------------*/
5987 if ( WDA_IS_RX_BCAST(pvBDHeader))
5988 {
5989 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
5990 "WLAN TL:TL rx Bcast frame - sending to last registered station"));
5991 broadcast = VOS_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07005992 /*-------------------------------------------------------------------
5993 If Addr1 is b/mcast, but Addr3 is our own self MAC, it is a b/mcast
5994 pkt we sent looping back to us. To be dropped if we are non BTAMP
5995 -------------------------------------------------------------------*/
5996 if( WLANHAL_RX_BD_ADDR3_SELF_IDX ==
5997 (v_U8_t)WDA_GET_RX_ADDR3_IDX( pvBDHeader ))
5998 {
5999 selfBcastLoopback = VOS_TRUE;
6000 }
6001 }/*if bcast*/
6002
6003 if ( WLANTL_STA_ID_INVALID(ucSTAId) )
6004 {
6005 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
6006 "WLAN TL:STA ID invalid - dropping pkt"));
6007 /* Drop packet */
6008 vos_pkt_return_packet(vosTempBuff);
6009 vosTempBuff = vosDataBuff;
6010 continue;
6011 }
6012
6013 /*----------------------------------------------------------------------
6014 No need to lock cache access because cache manipulation only happens
6015 in the transport thread/task context
6016 - These frames are to be forwarded to the station upon registration
6017 which happens in the main thread context
6018 The caching here can happen in either Tx or Rx thread depending
6019 on the current SSC scheduling
6020 - also we need to make sure that the frames in the cache are fwd-ed to
6021 the station before the new incoming ones
6022 -----------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306023 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
6024 if (NULL == pClientSTA)
6025 {
6026 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
6027 "WLAN TL:STA not allocated memory. Dropping packet"));
6028 vos_pkt_return_packet(vosTempBuff);
6029 vosTempBuff = vosDataBuff;
6030 continue;
6031 }
6032
Hoonki Lee5305c3a2013-04-29 23:28:59 -07006033#ifdef FEATURE_WLAN_TDLS
6034 if (( pClientSTA->ucExists ) &&
6035 (WLAN_STA_TDLS == pClientSTA->wSTADesc.wSTAType) &&
6036 (pClientSTA->ucTxSuspended))
6037 vos_atomic_set_U8( &pClientSTA->ucTxSuspended, 0 );
6038 else if ( !broadcast && (pClientSTA->ucExists == 0 ) )
6039 {
6040 tpSirMacMgmtHdr pMacHeader = WDA_GET_RX_MAC_HEADER( pvBDHeader );
6041
6042 /* from the direct peer while it is not registered to TL yet */
6043 if ( (pMacHeader->fc.fromDS == 0) &&
6044 (pMacHeader->fc.toDS == 0) )
6045 {
6046 v_U8_t ucAddr3STAId;
6047
6048 ucAddr3STAId = WDA_GET_RX_ADDR3_IDX(pvBDHeader);
6049
6050 if ( WLANTL_STA_ID_INVALID(ucAddr3STAId) )
6051 {
6052 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
6053 "WLAN TL:STA ID %d invalid - dropping pkt", ucAddr3STAId));
6054 /* Drop packet */
6055 vos_pkt_return_packet(vosTempBuff);
6056 vosTempBuff = vosDataBuff;
6057 continue;
6058 }
6059
6060 if (!(pTLCb->atlSTAClients[ucAddr3STAId] && pTLCb->atlSTAClients[ucAddr3STAId]->ucExists &&
6061 (WLAN_STA_INFRA == pTLCb->atlSTAClients[ucAddr3STAId]->wSTADesc.wSTAType) &&
6062 (WLANTL_STA_AUTHENTICATED == pTLCb->atlSTAClients[ucAddr3STAId]->tlState)))
6063 {
6064 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
Arif Hussainf2b00992013-11-17 21:46:15 -08006065 "%s: staId %d addr3Id %d tlState %d. Unkown Receiver/Transmitter Dropping packet", __func__,
Hoonki Lee5305c3a2013-04-29 23:28:59 -07006066 ucSTAId, ucAddr3STAId, pTLCb->atlSTAClients[ucAddr3STAId]->tlState));
6067 vos_pkt_return_packet(vosTempBuff);
6068 vosTempBuff = vosDataBuff;
6069 continue;
6070 }
6071 else
6072 {
6073 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
Arif Hussainf2b00992013-11-17 21:46:15 -08006074 "%s: staId %d doesn't exist, but mapped to AP staId %d", __func__,
Hoonki Lee5305c3a2013-04-29 23:28:59 -07006075 ucSTAId, ucAddr3STAId));
6076 ucSTAId = ucAddr3STAId;
6077 pClientSTA = pTLCb->atlSTAClients[ucAddr3STAId];
6078 }
6079 }
6080 }
6081#endif
6082
Katya Nigam63902932014-06-26 19:04:23 +05306083 if (( pClientSTA->enableCaching == 1 ) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07006084 /*Dont buffer Broadcast/Multicast frames. If AP transmits bursts of Broadcast/Multicast data frames,
6085 * libra buffers all Broadcast/Multicast packets after authentication with AP,
6086 * So it will lead to low resource condition in Rx Data Path.*/
Katya Nigam63902932014-06-26 19:04:23 +05306087 ( WDA_IS_RX_BCAST(pvBDHeader) == 0 ))
Jeff Johnson295189b2012-06-20 16:38:30 -07006088 {
Katya Nigam6201c3e2014-05-27 17:51:42 +05306089 if( WDA_IsSelfSTA(pvosGCtx,ucSTAId))
6090 {
6091 //drop packet for Self STA index
6092 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
6093 "%s: Packet dropped for Self STA with staId %d ", __func__, ucSTAId ));
6094
6095 vos_pkt_return_packet(vosTempBuff);
6096 vosTempBuff = vosDataBuff;
6097 continue;
6098 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006099 uDPUSig = WDA_GET_RX_DPUSIG( pvBDHeader );
6100 //Station has not yet been registered with TL - cache the frame
Hoonki Lee5305c3a2013-04-29 23:28:59 -07006101 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
Arif Hussainf2b00992013-11-17 21:46:15 -08006102 "%s: staId %d exist %d tlState %d cache rx frame", __func__, ucSTAId,
Hoonki Lee5305c3a2013-04-29 23:28:59 -07006103 pClientSTA->ucExists, pClientSTA->tlState));
Jeff Johnson295189b2012-06-20 16:38:30 -07006104 WLANTL_CacheSTAFrame( pTLCb, ucSTAId, vosTempBuff, uDPUSig, broadcast, ucFrmType);
6105 vosTempBuff = vosDataBuff;
6106 continue;
6107 }
6108
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08006109#ifdef FEATURE_WLAN_ESE_UPLOAD
6110 if ((pClientSTA->wSTADesc.ucIsEseSta)|| broadcast)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07006111 {
6112 /*--------------------------------------------------------------------
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08006113 Filter the IAPP frames for ESE connection;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07006114 if data it will return false and it
6115 will be routed through the regular data path
6116 --------------------------------------------------------------------*/
6117 if ( WLANTL_IsIAPPFrame(pvBDHeader,
6118 vosTempBuff))
6119 {
6120 bForwardIAPPwithLLC = VOS_TRUE;
6121 }
6122 }
6123#endif
6124
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08006125#if defined(FEATURE_WLAN_ESE) && !defined(FEATURE_WLAN_ESE_UPLOAD)
6126 if ((pClientSTA->wSTADesc.ucIsEseSta)|| broadcast)
Jeff Johnson295189b2012-06-20 16:38:30 -07006127 {
6128 /*--------------------------------------------------------------------
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08006129 Filter the IAPP frames for ESE connection;
Jeff Johnson295189b2012-06-20 16:38:30 -07006130 if data it will return false and it
6131 will be routed through the regular data path
6132 --------------------------------------------------------------------*/
6133 if ( WLANTL_IsIAPPFrame(pvBDHeader,
6134 vosTempBuff))
6135 {
6136 if ( VOS_STATUS_SUCCESS != vos_pkt_flatten_rx_pkt(&vosTempBuff))
6137 {
6138 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6139 "WLAN TL:Cannot flatten packet - dropping"));
6140 /* Drop packet */
6141 vos_pkt_return_packet(vosTempBuff);
6142 } else {
6143
6144 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08006145 "WLAN TL: Received ESE IAPP Frame"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006146
6147 pTLCb->tlMgmtFrmClient.pfnTlMgmtFrmRx( pvosGCtx, vosTempBuff);
6148 }
6149 vosTempBuff = vosDataBuff;
6150 continue;
6151 }
6152 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08006153#endif /* defined(FEATURE_WLAN_ESE) && !defined(FEATURE_WLAN_ESE_UPLOAD) */
Jeff Johnson295189b2012-06-20 16:38:30 -07006154
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306155 if ( WLAN_STA_BT_AMP == pClientSTA->wSTADesc.wSTAType )
Jeff Johnson295189b2012-06-20 16:38:30 -07006156 {
6157 /*--------------------------------------------------------------------
6158 Process the ctrl BAP frame; if data it will return false and it
6159 will be routed through the regular data path
6160 --------------------------------------------------------------------*/
6161 if ( WLANTL_ProcessBAPFrame( pvBDHeader,
6162 vosTempBuff,
6163 pTLCb,
6164 &first_data_pkt_arrived,
6165 ucSTAId))
6166 {
6167 vosTempBuff = vosDataBuff;
6168 continue;
6169 }
6170 }/*if BT-AMP station*/
6171 else if(selfBcastLoopback == VOS_TRUE)
6172 {
6173 /* Drop packet */
6174 vos_pkt_return_packet(vosTempBuff);
6175 vosTempBuff = vosDataBuff;
6176 continue;
6177 }
6178
6179 /*---------------------------------------------------------------------
6180 Data packet received, send to state machine
6181 ---------------------------------------------------------------------*/
6182 wSTAEvent = WLANTL_RX_EVENT;
6183
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306184 pfnSTAFsm = tlSTAFsm[pClientSTA->tlState].
Jeff Johnson295189b2012-06-20 16:38:30 -07006185 pfnSTATbl[wSTAEvent];
6186
6187 if ( NULL != pfnSTAFsm )
6188 {
6189#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
6190 /* Read RSSI and update */
6191 vosStatus = WLANTL_HSHandleRXFrame(pvosGCtx,
6192 WLANTL_DATA_FRAME_TYPE,
6193 pvBDHeader,
6194 ucSTAId,
6195 broadcast,
6196 vosTempBuff);
6197 broadcast = VOS_FALSE;
6198#else
6199 vosStatus = WLANTL_ReadRSSI(pvosGCtx, pvBDHeader, ucSTAId);
Kiet Lam47325522014-03-10 11:50:46 -07006200#endif
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05306201 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
Jeff Johnson295189b2012-06-20 16:38:30 -07006202 {
6203 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
6204 "Handle RX Data Frame fail within Handoff support module"));
6205 /* Do Not Drop packet at here
6206 * Revisit why HO module return fail
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05306207 * vos_pkt_return_packet(vosTempBuff);
6208 * vosTempBuff = vosDataBuff;
6209 * continue;
Jeff Johnson295189b2012-06-20 16:38:30 -07006210 */
6211 }
Dino Mycle3b9536d2014-07-09 22:05:24 +05306212#ifdef WLAN_FEATURE_LINK_LAYER_STATS
6213 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
6214 if ( NULL != pClientSTA)
6215 {
6216 tpSirMacMgmtHdr pMacHeader = WDA_GET_RX_MAC_HEADER( pvBDHeader );
Mahesh A Saptasagarbbdcf122014-10-28 20:57:11 +05306217 if (!IS_BROADCAST_ADD(pMacHeader->da) && IS_MULTICAST_ADD(pMacHeader->da))
Dino Mycle3b9536d2014-07-09 22:05:24 +05306218 {
6219 pClientSTA->interfaceStats.accessCategoryStats[ac].rxMcast++;
6220 }
6221
6222 WLANTL_HSGetDataRSSI(pvosGCtx, pvBDHeader, ucSTAId,
6223 &currentAvgRSSI);
6224 pClientSTA->interfaceStats.rssiData = currentAvgRSSI;
6225
6226 pClientSTA->interfaceStats.accessCategoryStats[ac].rxMpdu++;
6227 if (WDA_IS_RX_AN_AMPDU (pvBDHeader))
6228 {
6229 pClientSTA->interfaceStats.accessCategoryStats[ac].rxAmpdu++;
6230 }
6231 }
6232
6233
6234#endif
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05306235 vosStatus = WLANTL_ReadSNR(pvosGCtx, pvBDHeader, ucSTAId);
6236
6237 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
6238 {
6239 TLLOGW(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
6240 FL("Failed to Read SNR")));
6241 }
6242
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07006243 pfnSTAFsm( pvosGCtx, ucSTAId, &vosTempBuff, bForwardIAPPwithLLC);
Jeff Johnson295189b2012-06-20 16:38:30 -07006244 }
6245 else
6246 {
6247 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
6248 "WLAN TL:NULL state function, STA:%d, State: %d- dropping packet",
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306249 ucSTAId, pClientSTA->tlState));
Jeff Johnson295189b2012-06-20 16:38:30 -07006250 /* Drop packet */
6251 vos_pkt_return_packet(vosTempBuff);
6252 vosTempBuff = vosDataBuff;
6253 continue;
6254 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006255 }/* else data frame*/
6256
6257 vosTempBuff = vosDataBuff;
6258 }/*while chain*/
6259
6260 return VOS_STATUS_SUCCESS;
6261}/* WLANTL_RxFrames */
6262
Dino Mycle3b9536d2014-07-09 22:05:24 +05306263#ifdef WLAN_FEATURE_LINK_LAYER_STATS
6264/*==========================================================================
6265
6266 FUNCTION WLANTL_CollectInterfaceStats
6267
6268 DESCRIPTION
6269 Utility function used by TL to send the statitics
6270
6271 DEPENDENCIES
6272
6273
6274 PARAMETERS
6275
6276 IN
6277
6278 ucSTAId: station for which the statistics need to collected
6279
6280 vosDataBuff: it will contain the pointer to the corresponding
6281 structure
6282
6283 RETURN VALUE
6284 The result code associated with performing the operation
6285
6286 VOS_STATUS_E_INVAL: Input parameters are invalid
6287 VOS_STATUS_SUCCESS: Everything is good :)
6288
6289 SIDE EFFECTS
6290
6291============================================================================*/
6292VOS_STATUS
6293WLANTL_CollectInterfaceStats
6294(
6295 v_PVOID_t pvosGCtx,
6296 v_U8_t ucSTAId,
6297 WLANTL_InterfaceStatsType *vosDataBuff
6298)
6299{
6300 WLANTL_CbType* pTLCb = NULL;
6301 /*------------------------------------------------------------------------
6302 Sanity check
6303 ------------------------------------------------------------------------*/
6304 if ( WLANTL_STA_ID_INVALID( ucSTAId ) )
6305 {
6306 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6307 "WLAN TL:Invalid station id requested on WLANTL_CollectStats"));
6308 return VOS_STATUS_E_FAULT;
6309 }
6310 /*------------------------------------------------------------------------
6311 Extract TL control block
6312 ------------------------------------------------------------------------*/
6313 pTLCb = VOS_GET_TL_CB(pvosGCtx);
6314 if ( NULL == pTLCb )
6315 {
6316 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6317 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_CollectStats"));
6318 return VOS_STATUS_E_FAULT;
6319 }
6320
6321 if ( NULL == pTLCb->atlSTAClients[ucSTAId] )
6322 {
6323 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6324 "WLAN TL:Client Memory was not allocated on %s", __func__));
6325 return VOS_STATUS_E_FAILURE;
6326 }
Srinivas Dasari98947432014-11-07 19:41:24 +05306327 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
6328 "WLAN TL: collect WIFI_STATS_IFACE results"));
6329
Dino Mycle3b9536d2014-07-09 22:05:24 +05306330 vos_mem_copy(vosDataBuff, &pTLCb->atlSTAClients[ucSTAId]->interfaceStats,
6331 sizeof(WLANTL_InterfaceStatsType));
6332 return VOS_STATUS_SUCCESS;
6333}
6334
Srinivas Dasari98947432014-11-07 19:41:24 +05306335/*==========================================================================
6336
6337 FUNCTION WLANTL_ClearInterfaceStats
6338
6339 DESCRIPTION
6340 Utility function used by TL to clear the statitics
6341
6342 DEPENDENCIES
6343
6344
6345 PARAMETERS
6346
6347 IN
6348
6349 ucSTAId: station for which the statistics need to collected
6350
6351 RETURN VALUE
6352 The result code associated with performing the operation
6353
6354 VOS_STATUS_E_INVAL: Input parameters are invalid
6355 VOS_STATUS_SUCCESS: Everything is good :)
6356
6357 SIDE EFFECTS
6358
6359============================================================================*/
6360VOS_STATUS
6361WLANTL_ClearInterfaceStats
6362(
6363 v_PVOID_t pvosGCtx,
6364 v_U8_t ucSTAId,
6365 v_U8_t statsClearReqMask
6366)
6367{
6368 WLANTL_CbType* pTLCb = NULL;
6369 WLANTL_STAClientType* pClientSTA = NULL;
6370 /*------------------------------------------------------------------------
6371 Sanity check
6372 ------------------------------------------------------------------------*/
6373 if ( WLANTL_STA_ID_INVALID( ucSTAId ) )
6374 {
6375 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6376 "WLAN TL:Invalid station id requested on WLANTL_CollectStats"));
6377 return VOS_STATUS_E_FAULT;
6378 }
6379 /*------------------------------------------------------------------------
6380 Extract TL control block
6381 ------------------------------------------------------------------------*/
6382 pTLCb = VOS_GET_TL_CB(pvosGCtx);
6383 if ( NULL == pTLCb )
6384 {
6385 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
6386 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_CollectStats"));
6387 return VOS_STATUS_E_FAULT;
6388 }
6389
6390 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
6391 if ( NULL == pClientSTA )
6392 {
6393 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
6394 "WLAN TL:Client Memory was not allocated on %s", __func__));
6395 return VOS_STATUS_E_FAILURE;
6396 }
6397
6398 if ((statsClearReqMask & WIFI_STATS_IFACE_AC) ||
6399 (statsClearReqMask & WIFI_STATS_IFACE)) {
6400 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
6401 "WLAN TL:cleared WIFI_STATS_IFACE_AC results"));
6402 pClientSTA->interfaceStats.accessCategoryStats[0].rxMcast = 0;
6403 pClientSTA->interfaceStats.accessCategoryStats[1].rxMcast = 0;
6404 pClientSTA->interfaceStats.accessCategoryStats[2].rxMcast = 0;
6405 pClientSTA->interfaceStats.accessCategoryStats[3].rxMcast = 0;
6406
6407 pClientSTA->interfaceStats.accessCategoryStats[0].rxMpdu = 0;
6408 pClientSTA->interfaceStats.accessCategoryStats[1].rxMpdu = 0;
6409 pClientSTA->interfaceStats.accessCategoryStats[2].rxMpdu = 0;
6410 pClientSTA->interfaceStats.accessCategoryStats[3].rxMpdu = 0;
6411
6412 pClientSTA->interfaceStats.accessCategoryStats[0].rxAmpdu = 0;
6413 pClientSTA->interfaceStats.accessCategoryStats[1].rxAmpdu = 0;
6414 pClientSTA->interfaceStats.accessCategoryStats[2].rxAmpdu = 0;
6415 pClientSTA->interfaceStats.accessCategoryStats[3].rxAmpdu = 0;
6416 }
6417
6418 if (statsClearReqMask & WIFI_STATS_IFACE) {
6419 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
6420 "WLAN TL:cleared WIFI_STATS_IFACE results"));
6421 pClientSTA->interfaceStats.mgmtRx = 0;
6422 pClientSTA->interfaceStats.rssiData = 0;
6423 return VOS_STATUS_SUCCESS;
6424 }
6425
6426 return VOS_STATUS_SUCCESS;
6427}
6428
Dino Mycle3b9536d2014-07-09 22:05:24 +05306429#endif /* WLAN_FEATURE_LINK_LAYER_STATS */
Jeff Johnson295189b2012-06-20 16:38:30 -07006430
6431/*==========================================================================
6432
6433 FUNCTION WLANTL_RxCachedFrames
6434
6435 DESCRIPTION
6436 Utility function used by TL to forward the cached frames to a particular
6437 station;
6438
6439 DEPENDENCIES
6440 TL must be initiailized before this function gets called.
6441 If the frame carried is a data frame then the station for which it is
6442 destined to must have been previously registered with TL.
6443
6444 PARAMETERS
6445
6446 IN
6447 pTLCb: pointer to TL handle
6448
6449 ucSTAId: station for which we need to forward the packets
6450
6451 vosDataBuff: it will contain a pointer to the first cached buffer
6452 received, if there is more then one packet they will be
6453 chained using vOSS buffers.
6454
6455 RETURN VALUE
6456 The result code associated with performing the operation
6457
6458 VOS_STATUS_E_INVAL: Input parameters are invalid
6459 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
6460 page fault
6461 VOS_STATUS_SUCCESS: Everything is good :)
6462
6463 SIDE EFFECTS
6464
6465============================================================================*/
6466VOS_STATUS
6467WLANTL_RxCachedFrames
6468(
6469 WLANTL_CbType* pTLCb,
6470 v_U8_t ucSTAId,
6471 vos_pkt_t* vosDataBuff
6472)
6473{
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306474 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07006475 WLANTL_STAFuncType pfnSTAFsm;
6476 vos_pkt_t* vosTempBuff;
6477 VOS_STATUS vosStatus;
6478 v_PVOID_t pvBDHeader = NULL;
6479 WLANTL_STAEventType wSTAEvent = WLANTL_RX_EVENT;
6480 v_U8_t ucTid = 0;
6481 v_BOOL_t broadcast = VOS_FALSE;
6482 v_BOOL_t bSigMatch = VOS_FALSE;
6483 v_BOOL_t selfBcastLoopback = VOS_FALSE;
Madan Mohan Koyyalamudidfd6aa82012-10-18 20:18:43 -07006484 static v_U8_t first_data_pkt_arrived;
Jeff Johnson295189b2012-06-20 16:38:30 -07006485 v_U32_t uDPUSig;
6486 v_U8_t ucUcastSig;
6487 v_U8_t ucBcastSig;
6488 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
6489
6490 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
6491 "WLAN TL:TL Receive Cached Frames called"));
6492
6493 /*------------------------------------------------------------------------
6494 Sanity check
6495 ------------------------------------------------------------------------*/
6496 if ( NULL == vosDataBuff )
6497 {
6498 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6499 "WLAN TL:Invalid parameter sent on WLANTL_RxFrames"));
6500 return VOS_STATUS_E_INVAL;
6501 }
6502
Mihir Sheteae6f02b2014-04-11 19:49:21 +05306503 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
6504
6505 if ( NULL == pClientSTA )
6506 {
6507 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6508 "WLAN TL:Client Memory was not allocated on %s", __func__));
6509 return VOS_STATUS_E_FAILURE;
6510 }
6511
6512 MTRACE(vos_trace(VOS_MODULE_ID_TL, TRACE_CODE_TL_FORWARD_CACHED_FRAMES,
6513 ucSTAId, 1<<16 | pClientSTA->tlCacheInfo.cacheSize));
6514
Jeff Johnson295189b2012-06-20 16:38:30 -07006515 /*---------------------------------------------------------------------
6516 Save the initial buffer - this is the first received buffer
6517 ---------------------------------------------------------------------*/
6518 vosTempBuff = vosDataBuff;
6519
6520 while ( NULL != vosTempBuff )
6521 {
Madan Mohan Koyyalamudia148e1e2012-11-30 14:52:59 -08006522 broadcast = VOS_FALSE;
6523 selfBcastLoopback = VOS_FALSE;
6524
Jeff Johnson295189b2012-06-20 16:38:30 -07006525 vos_pkt_walk_packet_chain( vosDataBuff, &vosDataBuff, 1/*true*/ );
6526
6527 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
6528 "WLAN TL:Sending new cached packet to station %d", ucSTAId));
6529 /*---------------------------------------------------------------------
6530 Peek at BD header - do not remove
6531 !!! Optimize me: only part of header is needed; not entire one
6532 ---------------------------------------------------------------------*/
6533 vosStatus = WDA_DS_PeekRxPacketInfo( vosTempBuff, (v_PVOID_t)&pvBDHeader, 0 );
6534
6535 if ( NULL == pvBDHeader )
6536 {
6537 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6538 "WLAN TL:Cannot extract BD header"));
6539 /* Drop packet */
6540 vos_pkt_return_packet(vosTempBuff);
6541 vosTempBuff = vosDataBuff;
6542 continue;
6543 }
6544
6545 uDPUSig = WDA_GET_RX_DPUSIG( pvBDHeader );
6546
6547 /* AMSDU HW bug fix
6548 * After 2nd AMSDU subframe HW could not handle BD correctly
6549 * HAL workaround is needed */
6550 if(WDA_GET_RX_ASF(pvBDHeader))
6551 {
6552 WDA_DS_RxAmsduBdFix(vos_get_global_context(VOS_MODULE_ID_TL,pTLCb),
6553 pvBDHeader);
6554 }
6555
6556 ucTid = (v_U8_t)WDA_GET_RX_TID( pvBDHeader );
6557
6558 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
6559 "WLAN TL:Data packet cached for STA %d", ucSTAId);
6560
6561 /*------------------------------------------------------------------
6562 This should be corrected when multipe sta support is added !!!
6563 for now bcast frames will be sent to the last registered STA
6564 ------------------------------------------------------------------*/
6565 if ( WDA_IS_RX_BCAST(pvBDHeader))
6566 {
6567 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
6568 "WLAN TL:TL rx Bcast frame "));
6569 broadcast = VOS_TRUE;
6570
6571 /* If Addr1 is b/mcast, but Addr3 is our own self MAC, it is a b/mcast
6572 * pkt we sent looping back to us. To be dropped if we are non BTAMP
6573 */
6574 if( WLANHAL_RX_BD_ADDR3_SELF_IDX ==
6575 (v_U8_t)WDA_GET_RX_ADDR3_IDX( pvBDHeader ))
6576 {
6577 selfBcastLoopback = VOS_TRUE;
6578 }
6579 }/*if bcast*/
6580
6581 /*-------------------------------------------------------------------------
6582 Check if the packet that we cached matches the DPU signature of the
6583 newly added station
6584 -------------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306585 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
6586
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306587 if ( NULL == pClientSTA )
6588 {
6589 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6590 "WLAN TL:Client Memory was not allocated on %s", __func__));
6591 return VOS_STATUS_E_FAILURE;
6592 }
6593
Jeff Johnson295189b2012-06-20 16:38:30 -07006594 if ( broadcast )
6595 {
6596 ucBcastSig = (v_U8_t)uDPUSig;
6597 bSigMatch = (( WLAN_TL_INVALID_B_SIG !=
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306598 pClientSTA->wSTADesc.ucBcastSig ) &&
6599 ( ucBcastSig == pClientSTA->wSTADesc.ucBcastSig ));
Jeff Johnson295189b2012-06-20 16:38:30 -07006600 }
6601 else
6602 {
6603 ucUcastSig = (v_U8_t)uDPUSig;
6604 bSigMatch = (( WLAN_TL_INVALID_U_SIG !=
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306605 pClientSTA->wSTADesc.ucUcastSig ) &&
6606 ( ucUcastSig == pClientSTA->wSTADesc.ucUcastSig ));
Jeff Johnson295189b2012-06-20 16:38:30 -07006607 }
6608
6609 /*-------------------------------------------------------------------------
6610 If the packet doesn't match - drop it
6611 -------------------------------------------------------------------------*/
6612 if ( !bSigMatch )
6613 {
Rajesh Chauhana6b08f42013-06-18 19:01:26 -07006614 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_MED,
Jeff Johnson295189b2012-06-20 16:38:30 -07006615 "WLAN TL: Cached packet does not match DPU Sig of the new STA - drop "
6616 " DPU Sig %d UC %d BC %d B %d",
6617 uDPUSig,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306618 pClientSTA->wSTADesc.ucUcastSig,
Rajesh Chauhana6b08f42013-06-18 19:01:26 -07006619 pClientSTA->wSTADesc.ucBcastSig,
Jeff Johnson295189b2012-06-20 16:38:30 -07006620 broadcast));
6621
6622 /* Drop packet */
6623 vos_pkt_return_packet(vosTempBuff);
6624 vosTempBuff = vosDataBuff;
6625 continue;
6626
6627 }/*if signature mismatch*/
6628
6629 /*------------------------------------------------------------------------
6630 Check if BT-AMP frame:
6631 - additional processing needed in this case to separate BT-AMP date
6632 from BT-AMP Ctrl path
6633 ------------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306634 if ( WLAN_STA_BT_AMP == pClientSTA->wSTADesc.wSTAType )
Jeff Johnson295189b2012-06-20 16:38:30 -07006635 {
6636 /*--------------------------------------------------------------------
6637 Process the ctrl BAP frame; if data it will return false and it
6638 will be routed through the regular data path
6639 --------------------------------------------------------------------*/
6640 if ( WLANTL_ProcessBAPFrame( pvBDHeader,
6641 vosTempBuff,
6642 pTLCb,
6643 &first_data_pkt_arrived,
6644 ucSTAId))
6645 {
6646 vosTempBuff = vosDataBuff;
6647 continue;
6648 }
6649 }/*if BT-AMP station*/
6650 else if(selfBcastLoopback == VOS_TRUE)
6651 {
6652 /* Drop packet */
6653 vos_pkt_return_packet(vosTempBuff);
6654 vosTempBuff = vosDataBuff;
6655 continue;
6656 }
6657
6658 /*---------------------------------------------------------------------
6659 Data packet received, send to state machine
6660 ---------------------------------------------------------------------*/
6661 wSTAEvent = WLANTL_RX_EVENT;
6662
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306663 pfnSTAFsm = tlSTAFsm[pClientSTA->tlState].
Jeff Johnson295189b2012-06-20 16:38:30 -07006664 pfnSTATbl[wSTAEvent];
6665
6666 if ( NULL != pfnSTAFsm )
6667 {
6668#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
6669 /* Read RSSI and update */
6670 vosStatus = WLANTL_HSHandleRXFrame(vos_get_global_context(
6671 VOS_MODULE_ID_TL,pTLCb),
6672 WLANTL_DATA_FRAME_TYPE,
6673 pvBDHeader,
6674 ucSTAId,
6675 broadcast,
6676 vosTempBuff);
6677 broadcast = VOS_FALSE;
6678#else
6679 vosStatus = WLANTL_ReadRSSI(vos_get_global_context(VOS_MODULE_ID_TL,pTLCb), pvBDHeader, ucSTAId);
Kiet Lam47325522014-03-10 11:50:46 -07006680#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006681 if(!VOS_IS_STATUS_SUCCESS(vosStatus))
6682 {
6683 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6684 "Handle RX Data Frame fail within Handoff support module"));
6685 /* Do Not Drop packet at here
6686 * Revisit why HO module return fail
6687 vos_pkt_return_packet(vosTempBuff);
6688 vosTempBuff = vosDataBuff;
6689 continue;
6690 */
6691 }
6692 pfnSTAFsm( vos_get_global_context(VOS_MODULE_ID_TL,pTLCb), ucSTAId,
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07006693 &vosTempBuff, VOS_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07006694 }
6695 else
6696 {
6697 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6698 "WLAN TL:NULL state function, STA:%d, State: %d- dropping packet",
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306699 ucSTAId, pClientSTA->tlState));
Jeff Johnson295189b2012-06-20 16:38:30 -07006700 /* Drop packet */
6701 vos_pkt_return_packet(vosTempBuff);
6702 vosTempBuff = vosDataBuff;
6703 continue;
6704 }
6705
6706 vosTempBuff = vosDataBuff;
6707 }/*while chain*/
6708
6709 return VOS_STATUS_SUCCESS;
6710}/* WLANTL_RxCachedFrames */
6711
6712/*==========================================================================
Katya Nigam664f5032014-05-05 12:24:32 +05306713 FUNCTION WLANTL_RxProcessMsg
6714
6715 DESCRIPTION
6716 Called by VOSS when a message was serialized for TL through the
6717 rx thread/task.
6718
6719 DEPENDENCIES
6720 The TL must be initialized before this function can be called.
6721
6722 PARAMETERS
6723
6724 IN
6725 pvosGCtx: pointer to the global vos context; a handle to TL's
6726 control block can be extracted from its context
6727 message: type and content of the message
6728
6729
6730 RETURN VALUE
6731 The result code associated with performing the operation
6732
6733 VOS_STATUS_E_INVAL: invalid input parameters
6734 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
6735 page fault
6736 VOS_STATUS_SUCCESS: Everything is good :)
6737
6738 Other values can be returned as a result of a function call, please check
6739 corresponding API for more info.
6740 SIDE EFFECTS
6741
6742============================================================================*/
6743VOS_STATUS
6744WLANTL_RxProcessMsg
6745(
6746 v_PVOID_t pvosGCtx,
6747 vos_msg_t* message
6748)
6749{
6750 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
6751 v_U32_t uData;
6752 v_U8_t ucSTAId;
6753 v_U8_t ucUcastSig;
6754 v_U8_t ucBcastSig;
6755
6756 /*------------------------------------------------------------------------
6757 Sanity check
6758 ------------------------------------------------------------------------*/
6759 if ( NULL == message )
6760 {
6761 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6762 "WLAN TL:Invalid parameter sent on WLANTL_RxProcessMessage"));
6763 return VOS_STATUS_E_INVAL;
6764 }
6765
6766 /*------------------------------------------------------------------------
6767 Process message
6768 ------------------------------------------------------------------------*/
6769 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
6770 "WLAN TL:Received message: %d through rx flow", message->type));
6771
6772 switch( message->type )
6773 {
6774
6775 case WLANTL_RX_FWD_CACHED:
6776 /*---------------------------------------------------------------------
6777 The data sent with the message has the following structure:
6778 | 00 | ucBcastSignature | ucUcastSignature | ucSTAID |
6779 each field above is one byte
6780 ---------------------------------------------------------------------*/
6781 uData = message->bodyval;
6782 ucSTAId = ( uData & 0x000000FF);
6783 ucUcastSig = ( uData & 0x0000FF00)>>8;
6784 ucBcastSig = (v_U8_t)(( uData & 0x00FF0000)>>16);
6785 vosStatus = WLANTL_ForwardSTAFrames( pvosGCtx, ucSTAId,
6786 ucUcastSig, ucBcastSig);
6787 break;
6788
6789 default:
6790 /*no processing for now*/
6791 break;
6792 }
6793
6794 return VOS_STATUS_SUCCESS;
6795}
6796
6797
6798/*==========================================================================
Jeff Johnson295189b2012-06-20 16:38:30 -07006799 FUNCTION WLANTL_ResourceCB
6800
6801 DESCRIPTION
6802 Called by the TL when it has packets available for transmission.
6803
6804 DEPENDENCIES
6805 The TL must be registered with BAL before this function can be called.
6806
6807 PARAMETERS
6808
6809 IN
6810 pvosGCtx: pointer to the global vos context; a handle to TL's
6811 or BAL's control block can be extracted from its context
6812
6813 RETURN VALUE
6814 The result code associated with performing the operation
6815
6816 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
6817 page fault
6818 VOS_STATUS_SUCCESS: Everything is good :)
6819
6820 SIDE EFFECTS
6821
6822============================================================================*/
6823VOS_STATUS
6824WLANTL_ResourceCB
6825(
6826 v_PVOID_t pvosGCtx,
6827 v_U32_t uCount
6828)
6829{
6830 WLANTL_CbType* pTLCb = NULL;
6831 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
6832
6833 /*------------------------------------------------------------------------
6834 Sanity check
6835 Extract TL control block
6836 ------------------------------------------------------------------------*/
6837 pTLCb = VOS_GET_TL_CB(pvosGCtx);
6838 if ( NULL == pTLCb )
6839 {
6840 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6841 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_ChangeSTAState"));
6842 return VOS_STATUS_E_FAULT;
6843 }
6844
6845 pTLCb->uResCount = uCount;
6846
6847
6848 /*-----------------------------------------------------------------------
6849 Resume Tx if enough res and not suspended
6850 -----------------------------------------------------------------------*/
6851 if (( pTLCb->uResCount >= WDA_TLI_MIN_RES_MF ) &&
6852 ( 0 == pTLCb->ucTxSuspended ))
6853 {
6854 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
6855 "WLAN TL:Issuing Xmit start request to BAL for avail res ASYNC"));
6856 return WDA_DS_StartXmit(pvosGCtx);
6857 }
6858
6859 return VOS_STATUS_SUCCESS;
6860}/* WLANTL_ResourceCB */
6861
6862
Gopichand Nakkala11acd112012-12-31 16:04:04 -08006863/*==========================================================================
6864 FUNCTION WLANTL_IsTxXmitPending
6865
6866 DESCRIPTION
6867 Called by the WDA when it wants to know whether WDA_DS_TX_START_XMIT msg
6868 is pending in TL msg queue
6869
6870 DEPENDENCIES
6871 The TL must be registered with WDA before this function can be called.
6872
6873 PARAMETERS
6874
6875 IN
6876 pvosGCtx: pointer to the global vos context; a handle to TL's
6877 or WDA's control block can be extracted from its context
6878
6879 RETURN VALUE
6880 The result code associated with performing the operation
6881
6882 0: No WDA_DS_TX_START_XMIT msg pending
6883 1: Msg WDA_DS_TX_START_XMIT already pending in TL msg queue
6884
6885 SIDE EFFECTS
6886
6887============================================================================*/
6888v_BOOL_t
6889WLANTL_IsTxXmitPending
6890(
6891 v_PVOID_t pvosGCtx
6892)
6893{
6894
6895 WLANTL_CbType* pTLCb = NULL;
6896 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
6897
6898 /*------------------------------------------------------------------------
6899 Sanity check
6900 Extract TL control block
6901 ------------------------------------------------------------------------*/
6902 pTLCb = VOS_GET_TL_CB(pvosGCtx);
6903 if ( NULL == pTLCb )
6904 {
6905 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_FATAL,
6906 "WLAN TL:Invalid TL pointer from pvosGCtx in WLANTL_IsTxXmitPending "));
6907 return FALSE;
6908 }
6909
6910 return pTLCb->isTxTranmitMsgPending;
6911
6912}/*WLANTL_IsTxXmitPending */
6913
6914/*==========================================================================
6915 FUNCTION WLANTL_SetTxXmitPending
6916
6917 DESCRIPTION
6918 Called by the WDA when it wants to indicate that WDA_DS_TX_START_XMIT msg
6919 is pending in TL msg queue
6920
6921 DEPENDENCIES
6922 The TL must be registered with WDA before this function can be called.
6923
6924 PARAMETERS
6925
6926 IN
6927 pvosGCtx: pointer to the global vos context; a handle to TL's
6928 or WDA's control block can be extracted from its context
6929
6930 RETURN VALUE None
6931
6932 SIDE EFFECTS
6933
6934============================================================================*/
6935
6936v_VOID_t
6937WLANTL_SetTxXmitPending
6938(
6939 v_PVOID_t pvosGCtx
6940)
6941{
6942
6943 WLANTL_CbType* pTLCb = NULL;
6944 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
6945
6946 /*------------------------------------------------------------------------
6947 Sanity check
6948 Extract TL control block
6949 ------------------------------------------------------------------------*/
6950 pTLCb = VOS_GET_TL_CB(pvosGCtx);
6951 if ( NULL == pTLCb )
6952 {
6953 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_FATAL,
6954 "WLAN TL:Invalid TL pointer from pvosGCtx in WLANTL_SetTxXmitPending"));
6955 return;
6956 }
6957
6958 pTLCb->isTxTranmitMsgPending = 1;
6959 return;
6960
6961}/*WLANTL_SetTxXmitPending */
6962
6963/*==========================================================================
6964 FUNCTION WLANTL_ClearTxXmitPending
6965
6966 DESCRIPTION
6967 Called by the WDA when it wants to indicate that no WDA_DS_TX_START_XMIT msg
6968 is pending in TL msg queue
6969
6970 DEPENDENCIES
6971 The TL must be registered with WDA before this function can be called.
6972
6973 PARAMETERS
6974
6975 IN
6976 pvosGCtx: pointer to the global vos context; a handle to TL's
6977 or WDA's control block can be extracted from its context
6978
6979 RETURN VALUE None
6980
6981 SIDE EFFECTS
6982
6983============================================================================*/
6984
6985v_VOID_t
6986WLANTL_ClearTxXmitPending
6987(
6988 v_PVOID_t pvosGCtx
6989)
6990{
6991
6992 WLANTL_CbType* pTLCb = NULL;
6993 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
6994
6995 /*------------------------------------------------------------------------
6996 Sanity check
6997 Extract TL control block
6998 ------------------------------------------------------------------------*/
6999 pTLCb = VOS_GET_TL_CB(pvosGCtx);
7000 if ( NULL == pTLCb )
7001 {
7002 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_FATAL,
7003 "WLAN TL:Invalid TL pointer from pvosGCtx in WLANTL_ClearTxXmitPending "));
7004 return;
7005 }
7006
7007 pTLCb->isTxTranmitMsgPending = 0;
7008 return;
7009}/*WLANTL_ClearTxXmitPending */
7010
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307011/*==========================================================================
7012 FUNCTION WLANTL_TxThreadDebugHandler
7013
7014 DESCRIPTION
7015 Printing TL Snapshot dump, processed under TxThread context, currently
7016 information regarding the global TlCb struture. Dumps information related
7017 to per active STA connection currently in use by TL.
7018
7019 DEPENDENCIES
7020 The TL must be initialized before this gets called.
7021
7022 PARAMETERS
7023
7024 IN
7025 pvosGCtx: pointer to the global vos context; a handle to TL's
7026 or WDA's control block can be extracted from its context
7027
7028 RETURN VALUE None
7029
7030 SIDE EFFECTS
7031
7032============================================================================*/
7033
7034v_VOID_t
7035WLANTL_TxThreadDebugHandler
7036(
7037 v_PVOID_t *pVosContext
7038)
7039{
7040 WLANTL_CbType* pTLCb = NULL;
7041 WLANTL_STAClientType* pClientSTA = NULL;
7042 int i = 0;
Mihir Shete5d148f12014-12-16 17:54:49 +05307043 v_U8_t uFlowMask; // TX FlowMask from WDA
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307044
7045 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_FATAL,
7046 "WLAN TL: %s Enter ", __func__));
7047
7048 pTLCb = VOS_GET_TL_CB(pVosContext);
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307049
7050 if ( NULL == pVosContext || NULL == pTLCb )
7051 {
7052 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7053 "Global VoS Context or TL Context are NULL"));
7054 return;
7055 }
7056
Mihir Shete5d148f12014-12-16 17:54:49 +05307057 if (VOS_STATUS_SUCCESS == WDA_DS_GetTxFlowMask(pVosContext, &uFlowMask))
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307058 {
7059 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Mihir Shete5d148f12014-12-16 17:54:49 +05307060 "WDA uTxFlowMask: 0x%x", uFlowMask));
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307061 }
Mihir Shete5d148f12014-12-16 17:54:49 +05307062
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307063 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7064 "************************TL DUMP INFORMATION**************"));
7065
7066 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7067 "uDelayedTriggerFrmInt:%d\tuMinFramesProcThres:%d",
7068 pTLCb->tlConfigInfo.uDelayedTriggerFrmInt,
7069 pTLCb->tlConfigInfo.uMinFramesProcThres));
7070
7071 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7072 "Management Frame Client exists: %d",
7073 pTLCb->tlMgmtFrmClient.ucExists));
7074 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7075 "usPendingTxCompleteCount: %d\tucTxSuspended: %d",
7076 pTLCb->usPendingTxCompleteCount,
7077 pTLCb->ucTxSuspended));
7078
7079 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7080 "uResCount: %d", pTLCb->uResCount));
7081
7082 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7083 "ucRegisteredStaId: %d\tucCurrentSTA: %d",
7084 pTLCb->ucRegisteredStaId, pTLCb->ucCurrentSTA));
7085
7086 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7087 "UrgentFrameProcessing: %s\tuFramesProcThres: %d",
7088 (pTLCb->bUrgent?"True":"False"), pTLCb->uFramesProcThres));
7089
7090 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7091 "isTxTranmitMsgPending: %d\t isBMPS: %s",
7092 pTLCb->isTxTranmitMsgPending, pTLCb->isBMPS?"True":"False"));
7093
7094#ifdef FEATURE_WLAN_TDLS
7095 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7096 "TDLS Peer Count: %d", pTLCb->ucTdlsPeerCount));
7097#endif
7098
7099 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7100 "++++++++++++++++++++Registerd Client Information++++++++++"));
7101
7102 for ( i =0; i<WLAN_MAX_STA_COUNT; i++ )
7103 {
7104 pClientSTA = pTLCb->atlSTAClients[i];
7105 if( NULL == pClientSTA || 0 == pClientSTA->ucExists)
7106 {
7107 continue;
7108 }
7109
7110 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7111 "######################STA Index: %d ############################",i));
7112 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR, "WLAN_STADescType:"));
7113 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7114 "STAId: %d\t STA MAC Address: %pM", pClientSTA->wSTADesc.ucSTAId,
7115 pClientSTA->wSTADesc.vSTAMACAddress.bytes));
7116 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7117 "STA Type: %d\tProtectedFrame: %d",
7118 pClientSTA->wSTADesc.wSTAType, pClientSTA->wSTADesc.ucProtectedFrame));
7119 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7120 "QoS: %d\tRxFrameTrans: %d\tTxFrameTrans: %d",
7121 pClientSTA->wSTADesc.ucQosEnabled, pClientSTA->wSTADesc.ucSwFrameRXXlation,
7122 pClientSTA->wSTADesc.ucSwFrameTXXlation));
7123 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7124 "ucUcastSig: %d\tucBcastSig: %d", pClientSTA->wSTADesc.ucUcastSig,
7125 pClientSTA->wSTADesc.ucBcastSig));
7126
7127 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7128 "ClientIndex: %d\t Exists: %d", i, pClientSTA->ucExists));
7129 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7130 "TL State: %d\t TL Priority: %d", pClientSTA->tlState,
7131 pClientSTA->tlPri));
7132 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7133 "ucTxSuspended: %d\tucPktPending: %d", pClientSTA->ucTxSuspended,
7134 pClientSTA->ucPktPending));
7135 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7136 "ucEAPOLPktPending: %d\tucNoMoreData: %d",
7137 pClientSTA->ucEapolPktPending, pClientSTA->ucNoMoreData));
7138 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Katya Nigam63902932014-06-26 19:04:23 +05307139 "enableCaching: %d\t fcStaTxDisabled: %d", pClientSTA->enableCaching,
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307140 pClientSTA->fcStaTxDisabled));
7141 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7142 "ucCurrentAC: %d\tucServicedAC: %d", pClientSTA->ucCurrentAC,
7143 pClientSTA->ucServicedAC));
7144 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7145 "TID: %d\tautTxCount[0]: %d\tauRxCount[0]: %d",0, pClientSTA->auTxCount[0],
7146 pClientSTA->auRxCount[0]));
7147 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7148 "aucAcMask[0]: %d\taucAcMask[1]: %d\taucAcMask[2]: %d\taucAcMask[3]: %d\t",
7149 pClientSTA->aucACMask[0], pClientSTA->aucACMask[1],
7150 pClientSTA->aucACMask[2], pClientSTA->aucACMask[3]));
7151 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7152 "ucCurrentWeight: %d", pClientSTA->ucCurrentWeight));
7153
7154 if( WLAN_STA_SOFTAP == pClientSTA->wSTADesc.wSTAType)
7155 {
7156 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7157 "TrafficStatistics for SOFTAP Station:"));
7158 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7159 "RUF=%d\tRMF=%d\tRBF=%d", pClientSTA->trafficStatistics.rxUCFcnt,
7160 pClientSTA->trafficStatistics.rxMCFcnt,
7161 pClientSTA->trafficStatistics.rxBCFcnt));
7162 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7163 "RUB=%d\tRMB=%d\tRBB=%d", pClientSTA->trafficStatistics.rxUCBcnt,
7164 pClientSTA->trafficStatistics.rxMCBcnt,
7165 pClientSTA->trafficStatistics.rxBCBcnt));
7166 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7167 "TUF=%d\tTMF=%d\tTBF=%d", pClientSTA->trafficStatistics.txUCFcnt,
7168 pClientSTA->trafficStatistics.txMCFcnt,
7169 pClientSTA->trafficStatistics.txBCFcnt));
7170 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7171 "TUB=%d\tTMB=%d\tTBB=%d", pClientSTA->trafficStatistics.txUCBcnt,
7172 pClientSTA->trafficStatistics.txMCBcnt,
7173 pClientSTA->trafficStatistics.txBCBcnt));
7174 }
7175 }
7176 return;
7177}
7178
7179/*==========================================================================
Mihir Shetefd62d9d2014-08-06 15:08:21 +05307180 FUNCTION WLANTL_FatalErrorHandler
7181
7182 DESCRIPTION
7183 Handle Fatal errors detected on the TX path.
7184 Currently issues SSR to recover from the error.
7185
7186 DEPENDENCIES
7187 The TL must be initialized before this gets called.
7188
7189 PARAMETERS
7190
7191 IN
7192 pvosGCtx: pointer to the global vos context; a handle to TL's
7193 or WDA's control block can be extracted from its context
7194
7195 RETURN VALUE None
7196
7197 SIDE EFFECTS
7198
7199============================================================================*/
7200v_VOID_t
7201WLANTL_FatalErrorHandler
7202(
7203 v_PVOID_t *pVosContext
7204)
7205{
7206
7207 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_FATAL,
7208 "WLAN TL: %s Enter ", __func__));
7209
7210 if ( NULL == pVosContext )
7211 {
7212 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7213 "%s: Global VoS Context or TL Context are NULL",
7214 __func__));
7215 return;
7216 }
7217
7218 /*
7219 * Issue SSR. vos_wlanRestart has tight checks to make sure that
7220 * we do not send an FIQ if previous FIQ is not processed
7221 */
7222 vos_wlanRestart();
7223}
7224
7225/*==========================================================================
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307226 FUNCTION WLANTL_TLDebugMessage
7227
7228 DESCRIPTION
7229 Post a TL Snapshot request, posts message in TxThread.
7230
7231 DEPENDENCIES
7232 The TL must be initialized before this gets called.
7233
7234 PARAMETERS
7235
7236 IN
7237 displaySnapshot Boolean showing whether to dump the snapshot or not.
7238
7239 RETURN VALUE None
7240
7241 SIDE EFFECTS
7242
7243============================================================================*/
7244
7245v_VOID_t
7246WLANTL_TLDebugMessage
7247(
Mihir Shete327c2ab2014-11-13 15:17:02 +05307248 v_U32_t debugFlags
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307249)
7250{
7251 vos_msg_t vosMsg;
7252 VOS_STATUS status;
7253
Mihir Shete327c2ab2014-11-13 15:17:02 +05307254 if(debugFlags & WLANTL_DEBUG_TX_SNAPSHOT)
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307255 {
7256 vosMsg.reserved = 0;
7257 vosMsg.bodyptr = NULL;
7258 vosMsg.type = WLANTL_TX_SNAPSHOT;
7259
7260 status = vos_tx_mq_serialize( VOS_MODULE_ID_TL, &vosMsg);
7261 if(status != VOS_STATUS_SUCCESS)
7262 {
7263 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR, "TX Msg Posting Failed with status: %d",status));
7264 return;
7265 }
7266 }
Mihir Shete327c2ab2014-11-13 15:17:02 +05307267 if (debugFlags & WLANTL_DEBUG_FW_CLEANUP)
7268 {
7269 vosMsg.reserved = 0;
7270 vosMsg.bodyptr = NULL;
7271 vosMsg.type = WLANTL_TX_FW_DEBUG;
7272
7273 status = vos_tx_mq_serialize( VOS_MODULE_ID_TL, &vosMsg);
7274 if(status != VOS_STATUS_SUCCESS)
7275 {
7276 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR, "TX Msg Posting Failed with status: %d",status));
7277 return;
7278 }
7279 }
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307280 return;
7281}
Jeff Johnson295189b2012-06-20 16:38:30 -07007282
Mihir Shetefd62d9d2014-08-06 15:08:21 +05307283/*==========================================================================
7284 FUNCTION WLANTL_FatalError
7285
7286 DESCRIPTION
7287 Fatal error reported in TX path, post an event to TX Thread for further
7288 handling
7289
7290 DEPENDENCIES
7291 The TL must be initialized before this gets called.
7292
7293 PARAMETERS
7294
7295 VOID
7296
7297 RETURN VALUE None
7298
7299 SIDE EFFECTS
7300
7301============================================================================*/
7302
7303v_VOID_t
7304WLANTL_FatalError
7305(
7306 v_VOID_t
7307)
7308{
7309 vos_msg_t vosMsg;
7310 VOS_STATUS status;
7311
7312 vosMsg.reserved = 0;
7313 vosMsg.bodyptr = NULL;
7314 vosMsg.type = WLANTL_TX_FATAL_ERROR;
7315
7316 status = vos_tx_mq_serialize( VOS_MODULE_ID_TL, &vosMsg);
7317 if(status != VOS_STATUS_SUCCESS)
7318 {
7319 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7320 "%s: TX Msg Posting Failed with status: %d",
7321 __func__,status));
7322 }
7323 return;
7324}
Jeff Johnson295189b2012-06-20 16:38:30 -07007325/*============================================================================
7326 TL STATE MACHINE
7327============================================================================*/
7328
7329/*==========================================================================
7330 FUNCTION WLANTL_STATxConn
7331
7332 DESCRIPTION
7333 Transmit in connected state - only EAPOL and WAI packets allowed
7334
7335 DEPENDENCIES
7336 The STA must be registered with TL before this function can be called.
7337
7338 PARAMETERS
7339
7340 IN
7341 pvosGCtx: pointer to the global vos context; a handle to TL's
7342 control block can be extracted from its context
7343 ucSTAId: identifier of the station being processed
7344 vosDataBuff: pointer to the tx vos buffer
7345
7346 RETURN VALUE
7347 The result code associated with performing the operation
7348
7349 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
7350 page fault
7351 VOS_STATUS_SUCCESS: Everything is good :)
7352
7353 Other return values are possible coming from the called functions.
7354 Please check API for additional info.
7355
7356 SIDE EFFECTS
7357
7358============================================================================*/
7359VOS_STATUS
7360WLANTL_STATxConn
7361(
7362 v_PVOID_t pvosGCtx,
7363 v_U8_t ucSTAId,
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07007364 vos_pkt_t** pvosDataBuff,
7365 v_BOOL_t bForwardIAPPwithLLC
Jeff Johnson295189b2012-06-20 16:38:30 -07007366)
7367{
7368 v_U16_t usPktLen;
7369 VOS_STATUS vosStatus;
7370 v_MACADDR_t vDestMacAddr;
7371 vos_pkt_t* vosDataBuff = NULL;
7372 WLANTL_CbType* pTLCb = NULL;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307373 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07007374 WLANTL_MetaInfoType tlMetaInfo;
7375 v_U8_t ucTypeSubtype = 0;
7376 v_U8_t ucTid;
7377 v_U8_t extraHeadSpace = 0;
7378 v_U8_t ucWDSEnabled = 0;
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07007379 v_U8_t ucAC, ucACMask, i;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05307380 v_U32_t txFlag = HAL_TX_NO_ENCRYPTION_MASK;
Jeff Johnson295189b2012-06-20 16:38:30 -07007381 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
7382
7383 /*------------------------------------------------------------------------
7384 Sanity check
7385 Extract TL control block
7386 ------------------------------------------------------------------------*/
7387 pTLCb = VOS_GET_TL_CB(pvosGCtx);
7388 if ( NULL == pTLCb )
7389 {
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07007390 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7391 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_STATxConn");
Jeff Johnson295189b2012-06-20 16:38:30 -07007392 *pvosDataBuff = NULL;
7393 return VOS_STATUS_E_FAULT;
7394 }
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307395 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
7396
7397 if ( NULL == pClientSTA )
7398 {
7399 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7400 "WLAN TL:Client Memory was not allocated on %s", __func__));
7401 return VOS_STATUS_E_FAILURE;
7402 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007403
7404 /*-------------------------------------------------------------------
7405 Disable AC temporary - if successfull retrieve re-enable
7406 The order is justified because of the possible scenario
7407 - TL tryes to fetch packet for AC and it returns NULL
7408 - TL analyzes the data it has received to see if there are
7409 any more pkts available for AC -> if not TL will disable AC
7410 - however it is possible that while analyzing results TL got
7411 preempted by a pending indication where the mask was again set
7412 TL will not check again and as a result when it resumes
7413 execution it will disable AC
7414 To prevent this the AC will be disabled here and if retrieve
7415 is successfull it will be re-enabled
7416 -------------------------------------------------------------------*/
7417
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07007418
7419 //LTI:pTLCb->atlSTAClients[ucSTAId].
7420 //LTI: aucACMask[pTLCb->atlSTAClients[ucSTAId].ucCurrentAC] = 0;
7421
7422 /*------------------------------------------------------------------------
7423 Fetch packet from HDD
7424 ------------------------------------------------------------------------*/
Sunil Ravid5406f22013-01-22 00:18:31 -08007425#ifdef FEATURE_WLAN_TDLS
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307426 if ((WLAN_STA_SOFTAP != pClientSTA->wSTADesc.wSTAType) &&
Agarwal Ashishcd86f7b2014-06-16 17:11:58 +05307427 !(vos_concurrent_open_sessions_running()) &&
Sunil Ravid5406f22013-01-22 00:18:31 -08007428 !pTLCb->ucTdlsPeerCount)
7429 {
7430#else
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307431 if ((WLAN_STA_SOFTAP != pClientSTA->wSTADesc.wSTAType) &&
Agarwal Ashishcd86f7b2014-06-16 17:11:58 +05307432 !(vos_concurrent_open_sessions_running()))
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07007433 {
Sunil Ravid5406f22013-01-22 00:18:31 -08007434#endif
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307435 ucAC = pClientSTA->ucCurrentAC;
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07007436
7437 /*-------------------------------------------------------------------
7438 Disable AC temporary - if successfull retrieve re-enable
7439 The order is justified because of the possible scenario
7440 - TL tryes to fetch packet for AC and it returns NULL
7441 - TL analyzes the data it has received to see if there are
7442 any more pkts available for AC -> if not TL will disable AC
7443 - however it is possible that while analyzing results TL got
7444 preempted by a pending indication where the mask was again set
7445 TL will not check again and as a result when it resumes
7446 execution it will disable AC
7447 To prevent this the AC will be disabled here and if retrieve
7448 is successfull it will be re-enabled
7449 -------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307450 pClientSTA->aucACMask[ucAC] = 0;
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07007451 }
7452 else
7453 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307454 //softap case
7455 ucAC = pTLCb->uCurServedAC;
7456 pClientSTA->aucACMask[ucAC] = 0;
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07007457 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007458
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307459 /*You make an initial assumption that HDD has no more data and if the
Jeff Johnson295189b2012-06-20 16:38:30 -07007460 assumption was wrong you reset the flags to their original state
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307461 This will prevent from exposing a race condition between checking with HDD
Jeff Johnson295189b2012-06-20 16:38:30 -07007462 for packets and setting the flags to false*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307463 //LTI: vos_atomic_set_U8( &pTLCb->atlSTAClients[ucSTAId].ucPktPending, 0);
7464 //LTI: pTLCb->atlSTAClients[ucSTAId].ucNoMoreData = 1;
7465 vos_atomic_set_U8( &pClientSTA->ucPktPending, 0);
7466 WLAN_TL_AC_ARRAY_2_MASK( pClientSTA, ucACMask, i);
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307467 /*You make an initial assumption that HDD has no more data and if the
7468 assumption was wrong you reset the flags to their original state
7469 This will prevent from exposing a race condition between checking with HDD
7470 for packets and setting the flags to false*/
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07007471 if ( 0 == ucACMask )
7472 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307473 pClientSTA->ucNoMoreData = 1;
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07007474 }
7475 else
7476 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307477 vos_atomic_set_U8( &pClientSTA->ucPktPending, 1);
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07007478 }
7479
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07007480
Madan Mohan Koyyalamudid93f4942012-10-05 15:05:40 -07007481 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07007482 "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 +05307483 ucAC, ucACMask, pClientSTA->ucPktPending);
Jeff Johnson295189b2012-06-20 16:38:30 -07007484
7485 /*------------------------------------------------------------------------
7486 Fetch tx packet from HDD
7487 ------------------------------------------------------------------------*/
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07007488
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307489 vosStatus = pClientSTA->pfnSTAFetchPkt( pvosGCtx,
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07007490 &ucSTAId,
7491 ucAC,
7492 &vosDataBuff, &tlMetaInfo );
Jeff Johnson295189b2012-06-20 16:38:30 -07007493
7494 if (( VOS_STATUS_SUCCESS != vosStatus ) || ( NULL == vosDataBuff ))
7495 {
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07007496 TLLOG1(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -07007497 "WLAN TL:No more data at HDD status %d", vosStatus));
7498 *pvosDataBuff = NULL;
7499
7500 /*--------------------------------------------------------------------
7501 Reset AC for the serviced station to the highest priority AC
7502 -> due to no more data at the station
7503 Even if this AC is not supported by the station, correction will be
7504 made in the main TL loop
7505 --------------------------------------------------------------------*/
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05307506 pClientSTA->ucCurrentAC = WLANTL_AC_HIGH_PRIO;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307507 pClientSTA->ucCurrentWeight = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07007508
Madan Mohan Koyyalamudid8000342012-11-08 14:55:26 -08007509 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07007510 "WLAN TL: WLANTL_STATxConn no more packets in HDD for AC: %d AC Mask: %d",
7511 ucAC, ucACMask);
7512
Jeff Johnson295189b2012-06-20 16:38:30 -07007513 return vosStatus;
7514 }
7515
7516 /*There are still packets in HDD - set back the pending packets and
7517 the no more data assumption*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307518 vos_atomic_set_U8( &pClientSTA->ucPktPending, 1);
7519 pClientSTA->ucNoMoreData = 0;
7520 pClientSTA->aucACMask[ucAC] = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07007521
Jeff Johnson295189b2012-06-20 16:38:30 -07007522#ifdef WLAN_PERF
7523 vos_pkt_set_user_data_ptr( vosDataBuff, VOS_PKT_USER_DATA_ID_BAL,
7524 (v_PVOID_t)0);
7525
7526#endif /*WLAN_PERF*/
7527
7528
7529#ifdef FEATURE_WLAN_WAPI
7530 /*------------------------------------------------------------------------
7531 If the packet is neither an Eapol packet nor a WAI packet then drop it
7532 ------------------------------------------------------------------------*/
7533 if ( 0 == tlMetaInfo.ucIsEapol && 0 == tlMetaInfo.ucIsWai )
7534 {
Madan Mohan Koyyalamudid93f4942012-10-05 15:05:40 -07007535 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -07007536 "WLAN TL:Only EAPOL or WAI packets allowed before authentication"));
7537
7538 /* Fail tx for packet */
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307539 pClientSTA->pfnSTATxComp( pvosGCtx, vosDataBuff,
Jeff Johnson295189b2012-06-20 16:38:30 -07007540 VOS_STATUS_E_BADMSG);
7541 vosDataBuff = NULL;
7542 *pvosDataBuff = NULL;
7543 return VOS_STATUS_SUCCESS;
7544 }
7545#else
7546 if ( 0 == tlMetaInfo.ucIsEapol )
7547 {
7548 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
7549 "WLAN TL:Received non EAPOL packet before authentication"));
7550
7551 /* Fail tx for packet */
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307552 pClientSTA->pfnSTATxComp( pvosGCtx, vosDataBuff,
Jeff Johnson295189b2012-06-20 16:38:30 -07007553 VOS_STATUS_E_BADMSG);
7554 vosDataBuff = NULL;
7555 *pvosDataBuff = NULL;
7556 return VOS_STATUS_SUCCESS;
7557 }
7558#endif /* FEATURE_WLAN_WAPI */
7559
7560 /*-------------------------------------------------------------------------
7561 Check TID
7562 -------------------------------------------------------------------------*/
7563 ucTid = tlMetaInfo.ucTID;
7564
7565 /*Make sure TID is valid*/
7566 if ( WLANTL_TID_INVALID(ucTid))
7567 {
Rajesh Chauhan2df40bf2013-08-22 11:26:12 -07007568 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
Jeff Johnson295189b2012-06-20 16:38:30 -07007569 "WLAN TL:Invalid TID sent in meta info %d - defaulting to 0 (BE)",
7570 ucTid));
7571 ucTid = 0;
7572 }
7573
7574 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
7575 "WLAN TL:Attaching BD header to pkt on WLANTL_STATxConn"));
7576
7577#ifdef FEATURE_WLAN_WAPI
7578 /*------------------------------------------------------------------------
7579 Translate 802.3 frame to 802.11 if Frame translation is enabled or if
7580 frame is a WAI frame.
7581 ------------------------------------------------------------------------*/
7582 if ( ( 1 == tlMetaInfo.ucIsWai ) ||
7583 ( 0 == tlMetaInfo.ucDisableFrmXtl ) )
7584#else
7585 /*------------------------------------------------------------------------
7586 Translate 802.3 frame to 802.11 if Frame translation is enabled
7587 ------------------------------------------------------------------------*/
7588 if ( ( 0 == tlMetaInfo.ucDisableFrmXtl ) &&
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307589 ( 0 != pClientSTA->wSTADesc.ucSwFrameTXXlation) )
Jeff Johnson295189b2012-06-20 16:38:30 -07007590#endif //#ifdef FEATURE_WLAN_WAPI
7591 {
Kiran Venkatappacab0d352012-12-17 13:09:22 -08007592 vosStatus = WLANTL_Translate8023To80211Header( vosDataBuff, &vosStatus,
7593 pTLCb, &ucSTAId,
Ravi Joshid0699502013-07-08 15:48:47 -07007594 &tlMetaInfo, &ucWDSEnabled,
7595 &extraHeadSpace);
Jeff Johnson295189b2012-06-20 16:38:30 -07007596 if ( VOS_STATUS_SUCCESS != vosStatus )
7597 {
7598 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7599 "WLAN TL:Error when translating header WLANTL_STATxConn"));
7600
7601 return vosStatus;
7602 }
7603
7604 tlMetaInfo.ucDisableFrmXtl = 1;
7605 }
7606
7607 /*-------------------------------------------------------------------------
7608 Call HAL to fill BD header
7609 -------------------------------------------------------------------------*/
7610 ucTypeSubtype |= (WLANTL_80211_DATA_TYPE << 4);
7611
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307612 if ( pClientSTA->wSTADesc.ucQosEnabled )
Jeff Johnson295189b2012-06-20 16:38:30 -07007613 {
7614 ucTypeSubtype |= (WLANTL_80211_DATA_QOS_SUBTYPE);
7615 }
7616
Gopichand Nakkala8b54e912013-03-11 10:44:21 +05307617#ifdef FEATURE_WLAN_WAPI
7618 /* TL State does not transition to AUTHENTICATED till GTK is installed, So in
7619 * case of WPA where GTK handshake is done after the 4 way handshake, the
7620 * unicast 2/2 EAPOL packet from the STA->AP has to be encrypted even before
7621 * the TL is in authenticated state. Since the PTK has been installed
7622 * already (after the 4 way handshake) we make sure that all traffic
7623 * is encrypted henceforth.(Note: TL is still not in AUTHENTICATED state so
7624 * we will only allow EAPOL data or WAI in case of WAPI)
7625 */
7626 if (tlMetaInfo.ucIsEapol && pClientSTA->ptkInstalled)
7627 {
7628 txFlag = 0;
7629 }
7630#else
7631 if (pClientSTA->ptkInstalled)
7632 {
7633 txFlag = 0;
7634 }
7635#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007636
7637 vosStatus = (VOS_STATUS)WDA_DS_BuildTxPacketInfo( pvosGCtx, vosDataBuff , &vDestMacAddr,
7638 tlMetaInfo.ucDisableFrmXtl, &usPktLen,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307639 pClientSTA->wSTADesc.ucQosEnabled, ucWDSEnabled,
Jeff Johnson295189b2012-06-20 16:38:30 -07007640 extraHeadSpace,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307641 ucTypeSubtype, &pClientSTA->wSTADesc.vSelfMACAddress,
Gopichand Nakkala8b54e912013-03-11 10:44:21 +05307642 ucTid, txFlag,
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -07007643 tlMetaInfo.usTimeStamp, tlMetaInfo.ucIsEapol || tlMetaInfo.ucIsWai, tlMetaInfo.ucUP );
Jeff Johnson295189b2012-06-20 16:38:30 -07007644
7645 if ( VOS_STATUS_SUCCESS != vosStatus )
7646 {
7647 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7648 "WLAN TL:Failed while attempting to fill BD %d", vosStatus));
7649 *pvosDataBuff = NULL;
7650 return vosStatus;
7651 }
7652
Nirav Shah4f765af2015-01-21 19:51:30 +05307653
7654
7655 // call ULA complete once M4 BD is filled.
7656 if (tlMetaInfo.ucEapolSubType == EAPOL_M4)
7657 {
7658 pClientSTA->isEapolM4Transmitted = 1;
7659 if (pClientSTA->pfnSTAUlaComplete)
7660 pClientSTA->pfnSTAUlaComplete(pClientSTA->pUlaCBCtx);
7661 pClientSTA->pfnSTAUlaComplete = NULL;
7662 pClientSTA->pUlaCBCtx = NULL;
7663 }
7664
Jeff Johnson295189b2012-06-20 16:38:30 -07007665 /*-----------------------------------------------------------------------
7666 Update tx counter for BA session query for tx side
7667 !1 - should this be done for EAPOL frames?
7668 -----------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307669 pClientSTA->auTxCount[ucTid]++;
Jeff Johnson295189b2012-06-20 16:38:30 -07007670
7671 vos_pkt_set_user_data_ptr( vosDataBuff, VOS_PKT_USER_DATA_ID_TL,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307672 (v_PVOID_t)pClientSTA->pfnSTATxComp );
Jeff Johnson295189b2012-06-20 16:38:30 -07007673
7674 /*------------------------------------------------------------------------
7675 Save data to input pointer for TL core
7676 ------------------------------------------------------------------------*/
7677 *pvosDataBuff = vosDataBuff;
7678 /*security frames cannot be delayed*/
7679 pTLCb->bUrgent = TRUE;
7680
Jeff Johnson295189b2012-06-20 16:38:30 -07007681 /* TX Statistics */
7682 if (!(tlMetaInfo.ucBcast || tlMetaInfo.ucMcast))
7683 {
7684 /* This is TX UC frame */
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307685 pClientSTA->trafficStatistics.txUCFcnt++;
7686 pClientSTA->trafficStatistics.txUCBcnt += usPktLen;
Jeff Johnson295189b2012-06-20 16:38:30 -07007687 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007688
7689 return VOS_STATUS_SUCCESS;
7690}/* WLANTL_STATxConn */
7691
7692
7693/*==========================================================================
7694 FUNCTION WLANTL_STATxAuth
7695
7696 DESCRIPTION
7697 Transmit in authenticated state - all data allowed
7698
7699 DEPENDENCIES
7700 The STA must be registered with TL before this function can be called.
7701
7702 PARAMETERS
7703
7704 IN
7705 pvosGCtx: pointer to the global vos context; a handle to TL's
7706 control block can be extracted from its context
7707 ucSTAId: identifier of the station being processed
7708 vosDataBuff: pointer to the tx vos buffer
7709
7710 RETURN VALUE
7711 The result code associated with performing the operation
7712
7713 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
7714 page fault
7715 VOS_STATUS_SUCCESS: Everything is good :)
7716
7717 Other return values are possible coming from the called functions.
7718 Please check API for additional info.
7719
7720 SIDE EFFECTS
7721
7722============================================================================*/
7723VOS_STATUS
7724WLANTL_STATxAuth
7725(
7726 v_PVOID_t pvosGCtx,
7727 v_U8_t ucSTAId,
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07007728 vos_pkt_t** pvosDataBuff,
7729 v_BOOL_t bForwardIAPPwithLLC
Jeff Johnson295189b2012-06-20 16:38:30 -07007730)
7731{
7732 v_U16_t usPktLen;
7733 VOS_STATUS vosStatus;
7734 v_MACADDR_t vDestMacAddr;
7735 vos_pkt_t* vosDataBuff = NULL;
7736 WLANTL_CbType* pTLCb = NULL;
7737 WLANTL_MetaInfoType tlMetaInfo;
7738 v_U8_t ucTypeSubtype = 0;
7739 WLANTL_ACEnumType ucAC;
7740 WLANTL_ACEnumType ucNextAC;
7741 v_U8_t ucTid;
7742 v_U8_t ucSwFrmXtl = 0;
7743 v_U8_t extraHeadSpace = 0;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307744 WLANTL_STAClientType *pStaClient = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07007745 v_U8_t ucWDSEnabled = 0;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05307746 v_U32_t ucTxFlag = 0;
Abhishek Singh45e68fe2014-12-11 12:55:59 +05307747 v_U8_t ucACMask, i;
Jeff Johnson295189b2012-06-20 16:38:30 -07007748 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
7749
7750 /*------------------------------------------------------------------------
7751 Sanity check
7752 Extract TL control block
7753 ------------------------------------------------------------------------*/
7754 pTLCb = VOS_GET_TL_CB(pvosGCtx);
7755 if (( NULL == pTLCb ) || ( NULL == pvosDataBuff ))
7756 {
7757 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson0298bd02013-11-14 19:58:38 -08007758 "WLAN TL:Invalid input params on WLANTL_STATxAuth TL %p DB %p",
Jeff Johnson295189b2012-06-20 16:38:30 -07007759 pTLCb, pvosDataBuff));
7760 if (NULL != pvosDataBuff)
7761 {
7762 *pvosDataBuff = NULL;
7763 }
7764 if(NULL != pTLCb)
7765 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307766 if ( NULL == pTLCb->atlSTAClients[ucSTAId] )
7767 {
7768 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7769 "WLAN TL:Client Memory was not allocated on %s", __func__));
7770 return VOS_STATUS_E_FAILURE;
7771 }
7772 pTLCb->atlSTAClients[ucSTAId]->ucNoMoreData = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07007773 }
7774 return VOS_STATUS_E_FAULT;
7775 }
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307776 pStaClient = pTLCb->atlSTAClients[ucSTAId];
Jeff Johnson295189b2012-06-20 16:38:30 -07007777
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307778 if ( NULL == pStaClient )
7779 {
7780 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7781 "WLAN TL:Client Memory was not allocated on %s", __func__));
7782 return VOS_STATUS_E_FAILURE;
7783 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007784
7785 vos_mem_zero(&tlMetaInfo, sizeof(tlMetaInfo));
7786 /*------------------------------------------------------------------------
7787 Fetch packet from HDD
7788 ------------------------------------------------------------------------*/
Sunil Ravid5406f22013-01-22 00:18:31 -08007789#ifdef FEATURE_WLAN_TDLS
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307790 if ((WLAN_STA_SOFTAP != pStaClient->wSTADesc.wSTAType) &&
Agarwal Ashishcd86f7b2014-06-16 17:11:58 +05307791 (!vos_concurrent_open_sessions_running()) &&
Sunil Ravid5406f22013-01-22 00:18:31 -08007792 !pTLCb->ucTdlsPeerCount)
7793 {
7794#else
Jeff Johnson295189b2012-06-20 16:38:30 -07007795 if ((WLAN_STA_SOFTAP != pStaClient->wSTADesc.wSTAType) &&
Agarwal Ashishcd86f7b2014-06-16 17:11:58 +05307796 (!vos_concurrent_open_sessions_running()))
Jeff Johnson295189b2012-06-20 16:38:30 -07007797 {
7798#endif
7799 ucAC = pStaClient->ucCurrentAC;
7800
7801 /*-------------------------------------------------------------------
7802 Disable AC temporary - if successfull retrieve re-enable
7803 The order is justified because of the possible scenario
7804 - TL tryes to fetch packet for AC and it returns NULL
7805 - TL analyzes the data it has received to see if there are
7806 any more pkts available for AC -> if not TL will disable AC
7807 - however it is possible that while analyzing results TL got
7808 preempted by a pending indication where the mask was again set
7809 TL will not check again and as a result when it resumes
7810 execution it will disable AC
7811 To prevent this the AC will be disabled here and if retrieve
7812 is successfull it will be re-enabled
7813 -------------------------------------------------------------------*/
7814 pStaClient->aucACMask[pStaClient->ucCurrentAC] = 0;
7815
7816 // don't reset it, as other AC queues in HDD may have packets
7817 //vos_atomic_set_U8( &pStaClient->ucPktPending, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07007818 }
7819 else
7820 {
7821 //softap case
7822 ucAC = pTLCb->uCurServedAC;
7823 pStaClient->aucACMask[ucAC] = 0;
7824
7825 //vos_atomic_set_U8( &pStaClient->ucPktPending, 0);
7826 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007827
7828 WLAN_TL_AC_ARRAY_2_MASK( pStaClient, ucACMask, i);
Jeff Johnson295189b2012-06-20 16:38:30 -07007829 /*You make an initial assumption that HDD has no more data and if the
7830 assumption was wrong you reset the flags to their original state
7831 This will prevent from exposing a race condition between checking with HDD
7832 for packets and setting the flags to false*/
7833 if ( 0 == ucACMask )
7834 {
7835 vos_atomic_set_U8( &pStaClient->ucPktPending, 0);
7836 pStaClient->ucNoMoreData = 1;
7837 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007838
7839 vosStatus = pStaClient->pfnSTAFetchPkt( pvosGCtx,
7840 &ucSTAId,
7841 ucAC,
7842 &vosDataBuff, &tlMetaInfo );
7843
7844
7845 if (( VOS_STATUS_SUCCESS != vosStatus ) || ( NULL == vosDataBuff ))
7846 {
7847
7848 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05307849 "WLAN TL:Failed while attempting to fetch pkt from HDD QId:%d status:%d",
7850 ucAC, vosStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07007851 *pvosDataBuff = NULL;
7852 /*--------------------------------------------------------------------
7853 Reset AC for the serviced station to the highest priority AC
7854 -> due to no more data at the station
7855 Even if this AC is not supported by the station, correction will be
7856 made in the main TL loop
7857 --------------------------------------------------------------------*/
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05307858 pStaClient->ucCurrentAC = WLANTL_AC_HIGH_PRIO;
Jeff Johnson295189b2012-06-20 16:38:30 -07007859 pStaClient->ucCurrentWeight = 0;
7860
7861 return vosStatus;
7862 }
7863
Jeff Johnsone7245742012-09-05 17:12:55 -07007864 WLANTL_StatHandleTXFrame(pvosGCtx, ucSTAId, vosDataBuff, NULL, &tlMetaInfo);
Jeff Johnsone7245742012-09-05 17:12:55 -07007865
Jeff Johnson295189b2012-06-20 16:38:30 -07007866 /*There are still packets in HDD - set back the pending packets and
7867 the no more data assumption*/
7868 vos_atomic_set_U8( &pStaClient->ucPktPending, 1);
7869 pStaClient->ucNoMoreData = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07007870
Jeff Johnson295189b2012-06-20 16:38:30 -07007871 if (WLAN_STA_SOFTAP != pStaClient->wSTADesc.wSTAType)
7872 {
Jeff Johnson295189b2012-06-20 16:38:30 -07007873 // don't need to set it, as we don't reset it in this function.
7874 //vos_atomic_set_U8( &pTLCb->atlSTAClients[ucSTAId].ucPktPending, 1);
Jeff Johnson295189b2012-06-20 16:38:30 -07007875 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007876
7877#ifdef WLAN_PERF
7878 vos_pkt_set_user_data_ptr( vosDataBuff, VOS_PKT_USER_DATA_ID_BAL,
7879 (v_PVOID_t)0);
7880#endif /*WLAN_PERF*/
7881
7882 /*-------------------------------------------------------------------------
7883 Check TID
7884 -------------------------------------------------------------------------*/
7885 ucTid = tlMetaInfo.ucTID;
7886
7887 /*Make sure TID is valid*/
7888 if ( WLANTL_TID_INVALID(ucTid))
7889 {
Rajesh Chauhan2df40bf2013-08-22 11:26:12 -07007890 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
Jeff Johnson295189b2012-06-20 16:38:30 -07007891 "WLAN TL:Invalid TID sent in meta info %d - defaulting to 0 (BE)",
7892 ucTid));
7893 ucTid = 0;
7894 }
7895
7896 /*Save for UAPSD timer consideration*/
7897 pStaClient->ucServicedAC = ucAC;
7898
7899 if ( ucAC == pStaClient->ucCurrentAC )
7900 {
7901 pStaClient->aucACMask[pStaClient->ucCurrentAC] = 1;
7902 pStaClient->ucCurrentWeight--;
7903 }
7904 else
7905 {
7906 pStaClient->ucCurrentAC = ucAC;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307907 pStaClient->ucCurrentWeight = pTLCb->tlConfigInfo.ucAcWeights[ucAC] - 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07007908
7909 pStaClient->aucACMask[pStaClient->ucCurrentAC] = 1;
7910
7911 }
7912
Jeff Johnson295189b2012-06-20 16:38:30 -07007913 if (WLAN_STA_SOFTAP != pStaClient->wSTADesc.wSTAType)
7914 {
Jeff Johnson295189b2012-06-20 16:38:30 -07007915 if ( 0 == pStaClient->ucCurrentWeight )
7916 {
7917 WLANTL_ACEnumType tempAC = ucAC;
7918 /*-----------------------------------------------------------------------
7919 Choose next AC - !!! optimize me
7920 -----------------------------------------------------------------------*/
7921 while ( 0 != ucACMask )
7922 {
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05307923 if(tempAC == WLANTL_AC_BK)
7924 ucNextAC = WLANTL_AC_HIGH_PRIO;
7925 else
7926 ucNextAC = (tempAC - 1);
7927
Jeff Johnson295189b2012-06-20 16:38:30 -07007928 if ( 0 != pStaClient->aucACMask[ucNextAC] )
7929 {
7930 pStaClient->ucCurrentAC = ucNextAC;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307931 pStaClient->ucCurrentWeight = pTLCb->tlConfigInfo.ucAcWeights[ucNextAC];
Jeff Johnson295189b2012-06-20 16:38:30 -07007932
7933 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
7934 "WLAN TL: Changing serviced AC to: %d with Weight: %d",
7935 pStaClient->ucCurrentAC ,
7936 pStaClient->ucCurrentWeight));
7937 break;
7938 }
7939 tempAC = ucNextAC;
7940 }
7941 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007942 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007943
7944 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
7945 "WLAN TL:Attaching BD header to pkt on WLANTL_STATxAuth"));
7946
7947 /*------------------------------------------------------------------------
7948 Translate 802.3 frame to 802.11
7949 ------------------------------------------------------------------------*/
7950 if ( 0 == tlMetaInfo.ucDisableFrmXtl )
7951 {
7952 /* Needs frame translation */
7953 // if the client has not enabled SW-only frame translation
7954 // and if the frame is a unicast frame
7955 // (HW frame translation does not support multiple broadcast domains
7956 // so we use SW frame translation for broadcast/multicast frames)
7957#ifdef FEATURE_WLAN_WAPI
7958 // and if the frame is not a WAPI frame
7959#endif
7960 // then use HW_based frame translation
7961
7962 if ( ( 0 == pStaClient->wSTADesc.ucSwFrameTXXlation ) &&
7963 ( 0 == tlMetaInfo.ucBcast ) &&
7964 ( 0 == tlMetaInfo.ucMcast )
7965#ifdef FEATURE_WLAN_WAPI
7966 && ( tlMetaInfo.ucIsWai != 1 )
7967#endif
7968 )
7969 {
7970#ifdef WLAN_PERF
7971 v_U32_t uFastFwdOK = 0;
7972
7973 /* HW based translation. See if the frame could be fast forwarded */
7974 WDA_TLI_FastHwFwdDataFrame( pvosGCtx, vosDataBuff , &vosStatus,
7975 &uFastFwdOK, &tlMetaInfo, &pStaClient->wSTADesc);
7976
7977 if( VOS_STATUS_SUCCESS == vosStatus )
7978 {
7979 if(uFastFwdOK)
7980 {
7981 /* Packet could be fast forwarded now */
7982 vos_pkt_set_user_data_ptr( vosDataBuff, VOS_PKT_USER_DATA_ID_TL,
7983 (v_PVOID_t)pStaClient->pfnSTATxComp );
7984
7985 *pvosDataBuff = vosDataBuff;
7986
7987 /* TODO: Do we really need to update WLANTL_HSHandleTXFrame()
7988 stats for every pkt? */
7989 pStaClient->auTxCount[tlMetaInfo.ucTID]++;
7990 return vosStatus;
7991 }
7992 /* can't be fast forwarded, fall through normal (slow) path. */
7993 }
7994 else
7995 {
7996
7997 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7998 "WLAN TL:Failed while attempting to fastFwd BD %d", vosStatus));
7999 *pvosDataBuff = NULL;
8000 return vosStatus;
8001 }
8002#endif /*WLAN_PERF*/
8003 }
8004 else
8005 {
8006 /* SW based translation */
8007
8008#ifdef FEATURE_WLAN_WAPI
8009 gUcIsWai = tlMetaInfo.ucIsWai,
8010#endif
8011
Kiran Venkatappacab0d352012-12-17 13:09:22 -08008012 vosStatus = WLANTL_Translate8023To80211Header( vosDataBuff, &vosStatus,
8013 pTLCb, &ucSTAId,
Ravi Joshid0699502013-07-08 15:48:47 -07008014 &tlMetaInfo, &ucWDSEnabled,
8015 &extraHeadSpace);
Jeff Johnson295189b2012-06-20 16:38:30 -07008016 if ( VOS_STATUS_SUCCESS != vosStatus )
8017 {
8018 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8019 "WLAN TL:Error when translating header WLANTL_STATxAuth"));
8020 return vosStatus;
8021 }
8022
8023 TLLOG4(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_LOW,
Arif Hussainf2b00992013-11-17 21:46:15 -08008024 "WLAN TL software translation success"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008025 ucSwFrmXtl = 1;
8026 tlMetaInfo.ucDisableFrmXtl = 1;
8027 }
8028 }
Gopichand Nakkala574f6d12013-06-27 19:38:43 +05308029#ifdef FEATURE_WLAN_TDLS
8030 /*In case of TDLS, if the packet is destined to TDLS STA ucSTAId may
8031 change. so update the pStaClient accordingly */
8032 pStaClient = pTLCb->atlSTAClients[ucSTAId];
Jeff Johnson295189b2012-06-20 16:38:30 -07008033
Gopichand Nakkala574f6d12013-06-27 19:38:43 +05308034 if ( NULL == pStaClient )
8035 {
8036 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8037 "pStaClient is NULL %s", __func__));
8038 return VOS_STATUS_E_FAILURE;
8039 }
8040#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07008041 /*-------------------------------------------------------------------------
8042 Call HAL to fill BD header
8043 -------------------------------------------------------------------------*/
8044 ucTypeSubtype |= (WLANTL_80211_DATA_TYPE << 4);
8045
8046 if ( pStaClient->wSTADesc.ucQosEnabled )
8047 {
8048 ucTypeSubtype |= (WLANTL_80211_DATA_QOS_SUBTYPE);
8049 }
8050
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05308051 /* ucAC now points to TL Q ID with a new queue added in TL,
8052 * hence look for the uapsd info for the correct AC that
8053 * this packet belongs to.
8054 */
8055 ucTxFlag = (0 != pStaClient->wUAPSDInfo[tlMetaInfo.ac].ucSet)?
Jeff Johnson295189b2012-06-20 16:38:30 -07008056 HAL_TRIGGER_ENABLED_AC_MASK:0;
8057
8058#ifdef FEATURE_WLAN_WAPI
8059 if ( pStaClient->wSTADesc.ucIsWapiSta == 1 )
8060 {
8061#ifdef LIBRA_WAPI_SUPPORT
8062 ucTxFlag = ucTxFlag | HAL_WAPI_STA_MASK;
8063#endif //LIBRA_WAPI_SUPPORT
8064 if ( tlMetaInfo.ucIsWai == 1 )
8065 {
8066 ucTxFlag = ucTxFlag | HAL_TX_NO_ENCRYPTION_MASK;
8067 }
8068 }
8069#endif /* FEATURE_WLAN_WAPI */
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008070#ifdef FEATURE_WLAN_TDLS
8071 if ( pStaClient->wSTADesc.wSTAType == WLAN_STA_TDLS )
8072 {
8073 ucTxFlag = ucTxFlag | HAL_TDLS_PEER_STA_MASK;
8074 }
8075#endif /* FEATURE_WLAN_TDLS */
Abhishek Singhfa011222014-04-14 10:57:08 +05308076 if( tlMetaInfo.ucIsArp )
8077 {
8078 /*Send ARP at lowest Phy rate and through WQ5 */
8079 ucTxFlag |= HAL_USE_BD_RATE_MASK;
Abhishek Singhfa011222014-04-14 10:57:08 +05308080 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008081
8082 vosStatus = (VOS_STATUS)WDA_DS_BuildTxPacketInfo( pvosGCtx,
8083 vosDataBuff , &vDestMacAddr,
8084 tlMetaInfo.ucDisableFrmXtl, &usPktLen,
8085 pStaClient->wSTADesc.ucQosEnabled, ucWDSEnabled,
8086 extraHeadSpace,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308087 ucTypeSubtype, &pStaClient->wSTADesc.vSelfMACAddress,
Jeff Johnson295189b2012-06-20 16:38:30 -07008088 ucTid, ucTxFlag, tlMetaInfo.usTimeStamp,
8089 tlMetaInfo.ucIsEapol, tlMetaInfo.ucUP );
8090
8091 if(!VOS_IS_STATUS_SUCCESS(vosStatus))
8092 {
8093 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8094 "Fill TX BD Error status %d", vosStatus));
8095
8096 return vosStatus;
8097 }
8098
Jeff Johnson295189b2012-06-20 16:38:30 -07008099 /* TX Statistics */
8100 if (!(tlMetaInfo.ucBcast || tlMetaInfo.ucMcast))
8101 {
8102 /* This is TX UC frame */
8103 pStaClient->trafficStatistics.txUCFcnt++;
8104 pStaClient->trafficStatistics.txUCBcnt += usPktLen;
8105 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008106
Kiran Venkatappacab0d352012-12-17 13:09:22 -08008107#ifndef FEATURE_WLAN_TDLS
Jeff Johnson295189b2012-06-20 16:38:30 -07008108 /*-----------------------------------------------------------------------
8109 Update tx counter for BA session query for tx side
8110 -----------------------------------------------------------------------*/
8111 pStaClient->auTxCount[ucTid]++;
Kiran Venkatappacab0d352012-12-17 13:09:22 -08008112#else
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308113 pTLCb->atlSTAClients[ucSTAId]->auTxCount[ucTid]++;
Kiran Venkatappacab0d352012-12-17 13:09:22 -08008114#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07008115
8116 /* This code is to send traffic with lower priority AC when we does not
8117 get admitted to send it. Today HAL does not downgrade AC so this code
8118 does not get executed.(In other words, HAL doesnÂ’t change tid. The if
8119 statement is always false.)
8120 NOTE: In the case of LA downgrade occurs in HDD (that was the change
8121 Phani made during WMM-AC plugfest). If WM & BMP also took this approach,
8122 then there will be no need for any AC downgrade logic in TL/WDI. */
8123#if 0
8124 if (( ucTid != tlMetaInfo.ucTID ) &&
8125 ( 0 != pStaClient->wSTADesc.ucQosEnabled ) &&
8126 ( 0 != ucSwFrmXtl ))
8127 {
8128 /*---------------------------------------------------------------------
8129 !! FIX me: Once downgrading is clear put in the proper change
8130 ---------------------------------------------------------------------*/
8131 ucQCOffset = WLANHAL_TX_BD_HEADER_SIZE + WLANTL_802_11_HEADER_LEN;
8132
8133 //!!!Fix this replace peek with extract
8134 vos_pkt_peek_data( vosDataBuff, ucQCOffset,(v_PVOID_t)&pucQosCtrl,
8135 sizeof(*pucQosCtrl));
8136 *pucQosCtrl = ucTid; //? proper byte order
8137 }
8138#endif
8139
8140 if ( VOS_STATUS_SUCCESS != vosStatus )
8141 {
8142 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8143 "WLAN TL:Failed while attempting to fill BD %d", vosStatus));
8144 *pvosDataBuff = NULL;
8145 return vosStatus;
8146 }
8147
8148 vos_pkt_set_user_data_ptr( vosDataBuff, VOS_PKT_USER_DATA_ID_TL,
8149 (v_PVOID_t)pStaClient->pfnSTATxComp );
8150
8151 *pvosDataBuff = vosDataBuff;
8152
8153 /*BE & BK can be delayed, VO and VI not frames cannot be delayed*/
8154 if ( pStaClient->ucServicedAC > WLANTL_AC_BE )
8155 {
8156 pTLCb->bUrgent= TRUE;
8157 }
8158
8159 return VOS_STATUS_SUCCESS;
8160}/* WLANTL_STATxAuth */
8161
8162/*==========================================================================
8163 FUNCTION WLANTL_STATxDisc
8164
8165 DESCRIPTION
8166 Transmit in disconnected state - no data allowed
8167
8168 DEPENDENCIES
8169 The STA must be registered with TL before this function can be called.
8170
8171 PARAMETERS
8172
8173 IN
8174 pvosGCtx: pointer to the global vos context; a handle to TL's
8175 control block can be extracted from its context
8176 ucSTAId: identifier of the station being processed
8177 vosDataBuff: pointer to the tx vos buffer
8178
8179 RETURN VALUE
8180 The result code associated with performing the operation
8181
8182 VOS_STATUS_SUCCESS: Everything is good :)
8183
8184 SIDE EFFECTS
8185
8186============================================================================*/
8187VOS_STATUS
8188WLANTL_STATxDisc
8189(
8190 v_PVOID_t pvosGCtx,
8191 v_U8_t ucSTAId,
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07008192 vos_pkt_t** pvosDataBuff,
8193 v_BOOL_t bForwardIAPPwithLLC
Jeff Johnson295189b2012-06-20 16:38:30 -07008194)
8195{
8196 WLANTL_CbType* pTLCb = NULL;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308197 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07008198 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
8199
Jeff Johnson295189b2012-06-20 16:38:30 -07008200 /*------------------------------------------------------------------------
8201 Sanity check
8202 Extract TL control block
8203 ------------------------------------------------------------------------*/
8204 pTLCb = VOS_GET_TL_CB(pvosGCtx);
8205 if ( NULL == pTLCb )
8206 {
8207 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8208 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_STATxAuth"));
8209 *pvosDataBuff = NULL;
8210 return VOS_STATUS_E_FAULT;
8211 }
8212
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308213 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
8214
8215 if ( NULL == pClientSTA )
8216 {
8217 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8218 "WLAN TL:Client Memory was not allocated on %s", __func__));
8219 return VOS_STATUS_E_FAILURE;
8220 }
8221
Jeff Johnson295189b2012-06-20 16:38:30 -07008222 /*------------------------------------------------------------------------
8223 Error
8224 ------------------------------------------------------------------------*/
8225 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
8226 "WLAN TL:Packet should not be transmitted in state disconnected ignoring"
8227 " request"));
8228
8229 *pvosDataBuff = NULL;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308230 pClientSTA->ucNoMoreData = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07008231
8232 //Should not be anything pending in disconnect state
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308233 vos_atomic_set_U8( &pClientSTA->ucPktPending, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07008234
8235 return VOS_STATUS_SUCCESS;
8236}/* WLANTL_STATxDisc */
8237
8238/*==========================================================================
8239 FUNCTION WLANTL_STARxConn
8240
8241 DESCRIPTION
8242 Receive in connected state - only EAPOL
8243
8244 DEPENDENCIES
8245 The STA must be registered with TL before this function can be called.
8246
8247 PARAMETERS
8248
8249 IN
8250 pvosGCtx: pointer to the global vos context; a handle to TL's
8251 control block can be extracted from its context
8252 ucSTAId: identifier of the station being processed
8253 vosDataBuff: pointer to the tx/rx vos buffer
8254
8255 RETURN VALUE
8256 The result code associated with performing the operation
8257
8258 VOS_STATUS_E_INVAL: invalid input parameters
8259 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
8260 page fault
8261 VOS_STATUS_SUCCESS: Everything is good :)
8262
8263 SIDE EFFECTS
8264
8265============================================================================*/
8266VOS_STATUS
8267WLANTL_STARxConn
8268(
8269 v_PVOID_t pvosGCtx,
8270 v_U8_t ucSTAId,
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07008271 vos_pkt_t** pvosDataBuff,
8272 v_BOOL_t bForwardIAPPwithLLC
Jeff Johnson295189b2012-06-20 16:38:30 -07008273)
8274{
8275 WLANTL_CbType* pTLCb = NULL;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308276 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07008277 v_U16_t usEtherType = 0;
8278 v_U16_t usPktLen;
8279 v_U8_t ucMPDUHOffset;
8280 v_U16_t usMPDUDOffset;
8281 v_U16_t usMPDULen;
8282 v_U8_t ucMPDUHLen;
8283 v_U16_t usActualHLen = 0;
8284 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
8285 vos_pkt_t* vosDataBuff;
8286 v_PVOID_t aucBDHeader;
8287 v_U8_t ucTid;
8288 WLANTL_RxMetaInfoType wRxMetaInfo;
8289 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
8290
8291 /*------------------------------------------------------------------------
8292 Sanity check
8293 ------------------------------------------------------------------------*/
8294 if (( NULL == pvosDataBuff ) || ( NULL == ( vosDataBuff = *pvosDataBuff )))
8295 {
8296 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8297 "WLAN TL:Invalid parameter sent on WLANTL_STARxConn"));
8298 return VOS_STATUS_E_INVAL;
8299 }
8300
8301 /*------------------------------------------------------------------------
8302 Extract TL control block
8303 ------------------------------------------------------------------------*/
8304 pTLCb = VOS_GET_TL_CB(pvosGCtx);
8305 if ( NULL == pTLCb )
8306 {
8307 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8308 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_ChangeSTAState"));
8309 return VOS_STATUS_E_FAULT;
8310 }
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308311 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
8312
8313 if ( NULL == pClientSTA )
8314 {
8315 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8316 "WLAN TL:Client Memory was not allocated on %s", __func__));
8317 return VOS_STATUS_E_FAILURE;
8318 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008319
8320 /*------------------------------------------------------------------------
8321 Extract BD header and check if valid
8322 ------------------------------------------------------------------------*/
8323 vosStatus = WDA_DS_PeekRxPacketInfo( vosDataBuff, (v_PVOID_t)&aucBDHeader, 0/*Swap BD*/ );
8324
8325 if ( NULL == aucBDHeader )
8326 {
8327 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8328 "WLAN TL:Cannot extract BD header"));
8329 VOS_ASSERT( 0 );
8330 return VOS_STATUS_E_FAULT;
8331 }
8332
8333
8334 ucMPDUHOffset = (v_U8_t)WDA_GET_RX_MPDU_HEADER_OFFSET(aucBDHeader);
8335 usMPDUDOffset = (v_U16_t)WDA_GET_RX_MPDU_DATA_OFFSET(aucBDHeader);
8336 usMPDULen = (v_U16_t)WDA_GET_RX_MPDU_LEN(aucBDHeader);
8337 ucMPDUHLen = (v_U8_t)WDA_GET_RX_MPDU_HEADER_LEN(aucBDHeader);
8338 ucTid = (v_U8_t)WDA_GET_RX_TID(aucBDHeader);
8339
8340 vos_pkt_get_packet_length( vosDataBuff, &usPktLen);
8341
8342 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
8343 "WLAN TL:BD header processing data: HO %d DO %d Len %d HLen %d",
8344 ucMPDUHOffset, usMPDUDOffset, usMPDULen, ucMPDUHLen));
8345
8346 /*It will cut out the 802.11 header if not used*/
8347 if ( VOS_STATUS_SUCCESS != WDA_DS_TrimRxPacketInfo( vosDataBuff ) )
8348 {
8349 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
8350 "WLAN TL:BD header corrupted - dropping packet"));
8351 /* Drop packet */
8352 vos_pkt_return_packet(vosDataBuff);
8353 return VOS_STATUS_SUCCESS;
8354 }
8355
8356 vosStatus = WLANTL_GetEtherType(aucBDHeader,vosDataBuff,ucMPDUHLen,&usEtherType);
8357
8358 if( VOS_IS_STATUS_SUCCESS(vosStatus) )
8359 {
8360#ifdef FEATURE_WLAN_WAPI
8361 /* If frame is neither an EAPOL frame nor a WAI frame then we drop the frame*/
8362 /* TODO: Do we need a check to see if we are in WAPI mode? If not is it possible */
8363 /* that we get an EAPOL packet in WAPI mode or vice versa? */
8364 if ( WLANTL_LLC_8021X_TYPE != usEtherType && WLANTL_LLC_WAI_TYPE != usEtherType )
8365 {
Sunil Ravid5406f22013-01-22 00:18:31 -08008366 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07008367 "WLAN TL:RX Frame not EAPOL or WAI EtherType %d - dropping", usEtherType );
Jeff Johnson295189b2012-06-20 16:38:30 -07008368 /* Drop packet */
8369 vos_pkt_return_packet(vosDataBuff);
8370 }
8371#else
8372 if ( WLANTL_LLC_8021X_TYPE != usEtherType )
8373 {
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07008374 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8375 "WLAN TL:RX Frame not EAPOL EtherType %d - dropping", usEtherType);
Jeff Johnson295189b2012-06-20 16:38:30 -07008376 /* Drop packet */
8377 vos_pkt_return_packet(vosDataBuff);
8378 }
8379#endif /* FEATURE_WLAN_WAPI */
8380 else /* Frame is an EAPOL frame or a WAI frame*/
8381 {
Katya Nigam42e16e82014-02-04 16:28:55 +05308382 MTRACE(vos_trace(VOS_MODULE_ID_TL,
8383 TRACE_CODE_TL_RX_CONN_EAPOL, ucSTAId, usEtherType ));
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07008384
Madan Mohan Koyyalamudid8000342012-11-08 14:55:26 -08008385 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07008386 "WLAN TL:RX Frame EAPOL EtherType %d - processing", usEtherType);
8387
Jeff Johnson295189b2012-06-20 16:38:30 -07008388 if (( 0 == WDA_GET_RX_FT_DONE(aucBDHeader) ) &&
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308389 ( 0 != pClientSTA->wSTADesc.ucSwFrameRXXlation))
Jeff Johnson295189b2012-06-20 16:38:30 -07008390 {
8391 if (usMPDUDOffset > ucMPDUHOffset)
8392 {
8393 usActualHLen = usMPDUDOffset - ucMPDUHOffset;
8394 }
8395
8396 vosStatus = WLANTL_Translate80211To8023Header( vosDataBuff, &vosStatus, usActualHLen,
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07008397 ucMPDUHLen, pTLCb, ucSTAId, bForwardIAPPwithLLC);
Jeff Johnson295189b2012-06-20 16:38:30 -07008398
8399 if ( VOS_STATUS_SUCCESS != vosStatus )
8400 {
Kaushik, Sushante386ee12014-05-01 15:50:52 +05308401 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
Jeff Johnson295189b2012-06-20 16:38:30 -07008402 "WLAN TL:Failed to translate from 802.11 to 802.3 - dropping"));
8403 /* Drop packet */
8404 vos_pkt_return_packet(vosDataBuff);
8405 return vosStatus;
8406 }
8407 }
8408 /*-------------------------------------------------------------------
8409 Increment receive counter
8410 -------------------------------------------------------------------*/
Madan Mohan Koyyalamudic0e5bd82012-09-18 17:12:27 -07008411 if ( !WLANTL_TID_INVALID( ucTid) )
8412 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308413 pClientSTA->auRxCount[ucTid]++;
Madan Mohan Koyyalamudic0e5bd82012-09-18 17:12:27 -07008414 }
8415 else
8416 {
8417 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8418 "WLAN TL:Invalid tid %d (Station ID %d) on %s",
8419 ucTid, ucSTAId, __func__));
8420 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008421
8422 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
8423 "WLAN TL:Sending EAPoL frame to station %d AC %d", ucSTAId, ucTid));
8424
8425 /*-------------------------------------------------------------------
8426 !!!Assuming TID = UP mapping
8427 -------------------------------------------------------------------*/
8428 wRxMetaInfo.ucUP = ucTid;
8429
Jeff Johnson295189b2012-06-20 16:38:30 -07008430 TLLOG4(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_LOW,
Arif Hussainf2b00992013-11-17 21:46:15 -08008431 "WLAN TL %s:Sending data chain to station", __func__));
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308432 if ( WLAN_STA_SOFTAP == pClientSTA->wSTADesc.wSTAType )
Jeff Johnson295189b2012-06-20 16:38:30 -07008433 {
8434 wRxMetaInfo.ucDesSTAId = WLAN_RX_SAP_SELF_STA_ID;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308435 pClientSTA->pfnSTARx( pvosGCtx, vosDataBuff, ucSTAId,
Jeff Johnson295189b2012-06-20 16:38:30 -07008436 &wRxMetaInfo );
8437 }
8438 else
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308439 pClientSTA->pfnSTARx( pvosGCtx, vosDataBuff, ucSTAId,
Jeff Johnson295189b2012-06-20 16:38:30 -07008440 &wRxMetaInfo );
8441 }/*EAPOL frame or WAI frame*/
8442 }/*vos status success*/
8443
8444 return VOS_STATUS_SUCCESS;
8445}/* WLANTL_STARxConn */
8446
Jeff Johnson295189b2012-06-20 16:38:30 -07008447/*==========================================================================
8448 FUNCTION WLANTL_FwdPktToHDD
8449
8450 DESCRIPTION
8451 Determine the Destation Station ID and route the Frame to Upper Layer
8452
8453 DEPENDENCIES
8454
8455 PARAMETERS
8456
8457 IN
8458 pvosGCtx: pointer to the global vos context; a handle to TL's
8459 control block can be extracted from its context
8460 ucSTAId: identifier of the station being processed
8461 vosDataBuff: pointer to the rx vos buffer
8462
8463 RETURN VALUE
8464 The result code associated with performing the operation
8465
8466 VOS_STATUS_E_INVAL: invalid input parameters
8467 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
8468 page fault
8469 VOS_STATUS_SUCCESS: Everything is good :)
8470
8471 SIDE EFFECTS
8472
8473============================================================================*/
8474
8475VOS_STATUS
8476WLANTL_FwdPktToHDD
8477(
8478 v_PVOID_t pvosGCtx,
8479 vos_pkt_t* pvosDataBuff,
8480 v_U8_t ucSTAId
8481)
8482{
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308483 v_MACADDR_t DestMacAddress;
8484 v_MACADDR_t *pDestMacAddress = &DestMacAddress;
8485 v_SIZE_t usMacAddSize = VOS_MAC_ADDR_SIZE;
Jeff Johnson295189b2012-06-20 16:38:30 -07008486 WLANTL_CbType* pTLCb = NULL;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308487 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07008488 vos_pkt_t* vosDataBuff ;
8489 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
Girish Gowli93e3edd2014-05-01 15:42:31 +05308490 v_U32_t* STAMetaInfoPtr;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308491 vos_pkt_t* vosNextDataBuff ;
8492 v_U8_t ucDesSTAId;
Jeff Johnson295189b2012-06-20 16:38:30 -07008493 WLANTL_RxMetaInfoType wRxMetaInfo;
8494
Jeff Johnson295189b2012-06-20 16:38:30 -07008495 /*------------------------------------------------------------------------
8496 Sanity check
8497 ------------------------------------------------------------------------*/
8498 if (( NULL == pvosDataBuff ) || ( NULL == ( vosDataBuff = pvosDataBuff )))
8499 {
8500 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8501 "WLAN TL:Invalid parameter sent on WLANTL_FwdPktToHdd"));
8502 return VOS_STATUS_E_INVAL;
8503 }
8504
8505 /*------------------------------------------------------------------------
8506 Extract TL control block
8507 ------------------------------------------------------------------------*/
8508 pTLCb = VOS_GET_TL_CB(pvosGCtx);
8509 if ( NULL == pTLCb )
8510 {
8511 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8512 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_FwdPktToHdd"));
8513 return VOS_STATUS_E_FAULT;
8514 }
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308515
Tushnim Bhattacharyya5dd94562013-03-20 20:15:03 -07008516 if(WLANTL_STA_ID_INVALID(ucSTAId))
8517 {
8518 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,"ucSTAId %d is not valid",
8519 ucSTAId));
8520 return VOS_STATUS_E_INVAL;
8521 }
8522
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308523 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
8524
8525 if ( NULL == pClientSTA )
8526 {
8527 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8528 "WLAN TL:Client Memory was not allocated on %s", __func__));
8529 return VOS_STATUS_E_FAILURE;
8530 }
8531
Jeff Johnson295189b2012-06-20 16:38:30 -07008532 /* This the change required for SoftAp to handle Reordered Buffer. Since a STA
8533 may have packets destined to multiple destinations we have to process each packet
8534 at a time and determine its Destination. So the Voschain provided by Reorder code
8535 is unchain and forwarded to Upper Layer after Determining the Destination */
8536
8537 vosDataBuff = pvosDataBuff;
8538 while (vosDataBuff != NULL)
8539 {
8540 vos_pkt_walk_packet_chain( vosDataBuff, &vosNextDataBuff, 1/*true*/ );
8541 vos_pkt_get_user_data_ptr( vosDataBuff, VOS_PKT_USER_DATA_ID_TL,
Girish Gowli93e3edd2014-05-01 15:42:31 +05308542 (v_PVOID_t *)&STAMetaInfoPtr );
8543 wRxMetaInfo.ucUP = (v_U8_t)((uintptr_t)STAMetaInfoPtr & WLANTL_AC_MASK);
8544 ucDesSTAId = (v_U8_t)(((uintptr_t)STAMetaInfoPtr) >> WLANTL_STAID_OFFSET);
Jeff Johnson295189b2012-06-20 16:38:30 -07008545
8546 vosStatus = vos_pkt_extract_data( vosDataBuff, 0, (v_VOID_t *)pDestMacAddress, &usMacAddSize);
8547 if ( VOS_STATUS_SUCCESS != vosStatus )
8548 {
8549 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Arif Hussainf2b00992013-11-17 21:46:15 -08008550 "WLAN TL: recv corrupted data packet"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008551 vos_pkt_return_packet(vosDataBuff);
8552 return vosStatus;
8553 }
8554
Arif Hussaina7c8e412013-11-20 11:06:42 -08008555 TLLOG4(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_LOW,
8556 "station mac "MAC_ADDRESS_STR,
8557 MAC_ADDR_ARRAY(pDestMacAddress->bytes)));
Jeff Johnson295189b2012-06-20 16:38:30 -07008558
8559 if (vos_is_macaddr_broadcast( pDestMacAddress ) || vos_is_macaddr_group(pDestMacAddress))
8560 {
8561 // destination is mc/bc station
8562 ucDesSTAId = WLAN_RX_BCMC_STA_ID;
8563 TLLOG4(VOS_TRACE( VOS_MODULE_ID_HDD_SOFTAP, VOS_TRACE_LEVEL_INFO_LOW,
Arif Hussainf2b00992013-11-17 21:46:15 -08008564 "%s: BC/MC packet, id %d", __func__, WLAN_RX_BCMC_STA_ID));
Jeff Johnson295189b2012-06-20 16:38:30 -07008565 }
8566 else
8567 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308568 if (vos_is_macaddr_equal(pDestMacAddress, &pClientSTA->wSTADesc.vSelfMACAddress))
Jeff Johnson295189b2012-06-20 16:38:30 -07008569 {
8570 // destination is AP itself
8571 ucDesSTAId = WLAN_RX_SAP_SELF_STA_ID;
8572 TLLOG4(VOS_TRACE( VOS_MODULE_ID_HDD_SOFTAP, VOS_TRACE_LEVEL_INFO_LOW,
Arif Hussainf2b00992013-11-17 21:46:15 -08008573 "%s: packet to AP itself, id %d", __func__, WLAN_RX_SAP_SELF_STA_ID));
Jeff Johnson295189b2012-06-20 16:38:30 -07008574 }
Madan Mohan Koyylamudi64258222013-01-30 14:35:10 +05308575 else if (( WLAN_MAX_STA_COUNT <= ucDesSTAId ) || (NULL != pTLCb->atlSTAClients[ucDesSTAId] && pTLCb->atlSTAClients[ucDesSTAId]->ucExists == 0))
Jeff Johnson295189b2012-06-20 16:38:30 -07008576 {
8577 // destination station is something else
8578 TLLOG4(VOS_TRACE( VOS_MODULE_ID_HDD_SOFTAP, VOS_TRACE_LEVEL_INFO_LOW,
Arif Hussainf2b00992013-11-17 21:46:15 -08008579 "%s: get an station index larger than WLAN_MAX_STA_COUNT %d", __func__, ucDesSTAId));
Jeff Johnson295189b2012-06-20 16:38:30 -07008580 ucDesSTAId = WLAN_RX_SAP_SELF_STA_ID;
8581 }
8582
8583
8584 //loopback unicast station comes here
8585 }
8586
Girish Gowli93e3edd2014-05-01 15:42:31 +05308587 wRxMetaInfo.ucUP = (v_U8_t)((uintptr_t)STAMetaInfoPtr & WLANTL_AC_MASK);
Jeff Johnson295189b2012-06-20 16:38:30 -07008588 wRxMetaInfo.ucDesSTAId = ucDesSTAId;
8589
Madan Mohan Koyyalamudi6c2977d2013-09-04 15:42:45 +05308590 vosStatus = pClientSTA->pfnSTARx( pvosGCtx, vosDataBuff, ucDesSTAId,
Jeff Johnson295189b2012-06-20 16:38:30 -07008591 &wRxMetaInfo );
Madan Mohan Koyyalamudi6c2977d2013-09-04 15:42:45 +05308592 if ( VOS_STATUS_SUCCESS != vosStatus )
8593 {
8594 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Arif Hussainf2b00992013-11-17 21:46:15 -08008595 "WLAN TL: failed to send pkt to HDD"));
Madan Mohan Koyyalamudi6c2977d2013-09-04 15:42:45 +05308596 vos_pkt_return_packet(vosDataBuff);
8597
8598 return vosStatus;
8599 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008600 vosDataBuff = vosNextDataBuff;
8601 }
8602 return VOS_STATUS_SUCCESS;
8603}
Jeff Johnson295189b2012-06-20 16:38:30 -07008604
8605/*==========================================================================
8606 FUNCTION WLANTL_STARxAuth
8607
8608 DESCRIPTION
8609 Receive in authenticated state - all data allowed
8610
8611 DEPENDENCIES
8612 The STA must be registered with TL before this function can be called.
8613
8614 PARAMETERS
8615
8616 IN
8617 pvosGCtx: pointer to the global vos context; a handle to TL's
8618 control block can be extracted from its context
8619 ucSTAId: identifier of the station being processed
8620 vosDataBuff: pointer to the rx vos buffer
8621
8622 RETURN VALUE
8623 The result code associated with performing the operation
8624
8625 VOS_STATUS_E_INVAL: invalid input parameters
8626 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
8627 page fault
8628 VOS_STATUS_SUCCESS: Everything is good :)
8629
8630 SIDE EFFECTS
8631
8632============================================================================*/
8633VOS_STATUS
8634WLANTL_STARxAuth
8635(
8636 v_PVOID_t pvosGCtx,
8637 v_U8_t ucSTAId,
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07008638 vos_pkt_t** pvosDataBuff,
8639 v_BOOL_t bForwardIAPPwithLLC
Jeff Johnson295189b2012-06-20 16:38:30 -07008640)
8641{
8642 WLANTL_CbType* pTLCb = NULL;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308643 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07008644 v_U8_t ucAsf; /* AMSDU sub frame */
8645 v_U16_t usMPDUDOffset;
8646 v_U8_t ucMPDUHOffset;
8647 v_U16_t usMPDULen;
8648 v_U8_t ucMPDUHLen;
8649 v_U16_t usActualHLen = 0;
8650 v_U8_t ucTid;
8651#ifdef FEATURE_WLAN_WAPI
Jeff Johnsone0343db2013-04-03 16:39:24 -07008652 v_U16_t usEtherType = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07008653#endif
8654 v_U16_t usPktLen;
8655 vos_pkt_t* vosDataBuff ;
8656 v_PVOID_t aucBDHeader;
8657 VOS_STATUS vosStatus;
8658 WLANTL_RxMetaInfoType wRxMetaInfo;
Madan Mohan Koyyalamudidfd6aa82012-10-18 20:18:43 -07008659 static v_U8_t ucPMPDUHLen;
Girish Gowli93e3edd2014-05-01 15:42:31 +05308660 v_U32_t* STAMetaInfoPtr;
Jeff Johnson295189b2012-06-20 16:38:30 -07008661 v_U8_t ucEsf=0; /* first subframe of AMSDU flag */
8662 v_U64_t ullcurrentReplayCounter=0; /*current replay counter*/
8663 v_U64_t ullpreviousReplayCounter=0; /*previous replay counter*/
8664 v_U16_t ucUnicastBroadcastType=0; /*It denotes whether received frame is UC or BC*/
Madan Mohan Koyyalamudi4fe30172012-10-18 20:13:40 -07008665 struct _BARFrmStruct *pBarFrame = NULL;
8666
Jeff Johnson295189b2012-06-20 16:38:30 -07008667 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
8668
8669 /*------------------------------------------------------------------------
8670 Sanity check
8671 ------------------------------------------------------------------------*/
8672 if (( NULL == pvosDataBuff ) || ( NULL == ( vosDataBuff = *pvosDataBuff )))
8673 {
8674 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8675 "WLAN TL:Invalid parameter sent on WLANTL_STARxAuth"));
8676 return VOS_STATUS_E_INVAL;
8677 }
8678
8679 /*------------------------------------------------------------------------
8680 Extract TL control block
8681 ------------------------------------------------------------------------*/
8682 pTLCb = VOS_GET_TL_CB(pvosGCtx);
8683 if ( NULL == pTLCb )
8684 {
8685 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8686 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_STARxAuth"));
8687 return VOS_STATUS_E_FAULT;
8688 }
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308689 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
8690
8691 if ( NULL == pClientSTA )
8692 {
8693 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8694 "WLAN TL:Client Memory was not allocated on %s", __func__));
8695 return VOS_STATUS_E_FAILURE;
8696 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008697
8698 /*------------------------------------------------------------------------
8699 Extract BD header and check if valid
8700 ------------------------------------------------------------------------*/
8701 WDA_DS_PeekRxPacketInfo( vosDataBuff, (v_PVOID_t)&aucBDHeader, 0 );
8702
8703 ucMPDUHOffset = (v_U8_t)WDA_GET_RX_MPDU_HEADER_OFFSET(aucBDHeader);
8704 usMPDUDOffset = (v_U16_t)WDA_GET_RX_MPDU_DATA_OFFSET(aucBDHeader);
8705 usMPDULen = (v_U16_t)WDA_GET_RX_MPDU_LEN(aucBDHeader);
8706 ucMPDUHLen = (v_U8_t)WDA_GET_RX_MPDU_HEADER_LEN(aucBDHeader);
8707 ucTid = (v_U8_t)WDA_GET_RX_TID(aucBDHeader);
8708
Madan Mohan Koyyalamudi4fe30172012-10-18 20:13:40 -07008709 /* Fix for a hardware bug.
8710 * H/W does not update the tid field in BD header for BAR frames.
8711 * Fix is to read the tid field from MAC header of BAR frame */
8712 if( (WDA_GET_RX_TYPE(aucBDHeader) == SIR_MAC_CTRL_FRAME) &&
8713 (WDA_GET_RX_SUBTYPE(aucBDHeader) == SIR_MAC_CTRL_BAR))
8714 {
8715 pBarFrame = (struct _BARFrmStruct *)(WDA_GET_RX_MAC_HEADER(aucBDHeader));
8716 ucTid = pBarFrame->barControl.numTID;
8717 }
8718
Jeff Johnson295189b2012-06-20 16:38:30 -07008719 /*Host based replay check is needed for unicast data frames*/
8720 ucUnicastBroadcastType = (v_U16_t)WDA_IS_RX_BCAST(aucBDHeader);
Jeff Johnson295189b2012-06-20 16:38:30 -07008721 if(0 != ucMPDUHLen)
8722 {
8723 ucPMPDUHLen = ucMPDUHLen;
8724 }
8725
8726 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
8727 "WLAN TL:BD header processing data: HO %d DO %d Len %d HLen %d"
8728 " Tid %d BD %d",
8729 ucMPDUHOffset, usMPDUDOffset, usMPDULen, ucMPDUHLen, ucTid,
8730 WLANHAL_RX_BD_HEADER_SIZE));
8731
8732 vos_pkt_get_packet_length( vosDataBuff, &usPktLen);
8733
8734 if ( VOS_STATUS_SUCCESS != WDA_DS_TrimRxPacketInfo( vosDataBuff ) )
8735 {
8736 if((WDA_GET_RX_ASF(aucBDHeader) && !WDA_GET_RX_ESF(aucBDHeader)))
8737 {
8738 /* AMSDU case, ucMPDUHOffset = 0
8739 * it should be hancdled seperatly */
8740 if(( usMPDUDOffset > ucMPDUHOffset ) &&
8741 ( usMPDULen >= ucMPDUHLen ) && ( usPktLen >= usMPDULen ) &&
8742 ( !WLANTL_TID_INVALID(ucTid) ))
8743 {
8744 ucMPDUHOffset = usMPDUDOffset - WLANTL_MPDU_HEADER_LEN;
8745 }
8746 else
8747 {
8748 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
8749 "WLAN TL:BD header corrupted - dropping packet"));
8750 /* Drop packet */
8751 vos_pkt_return_packet(vosDataBuff);
8752 return VOS_STATUS_SUCCESS;
8753 }
8754 }
8755 else
8756 {
8757 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
8758 "WLAN TL:BD header corrupted - dropping packet"));
8759 /* Drop packet */
8760 vos_pkt_return_packet(vosDataBuff);
8761 return VOS_STATUS_SUCCESS;
8762 }
8763 }
8764
8765#ifdef FEATURE_WLAN_WAPI
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308766 if ( pClientSTA->wSTADesc.ucIsWapiSta )
Jeff Johnson295189b2012-06-20 16:38:30 -07008767 {
8768 vosStatus = WLANTL_GetEtherType(aucBDHeader, vosDataBuff, ucMPDUHLen, &usEtherType);
8769 if( VOS_IS_STATUS_SUCCESS(vosStatus) )
8770 {
8771 if ( WLANTL_LLC_WAI_TYPE == usEtherType )
8772 {
8773 if ( !( WLANHAL_RX_IS_UNPROTECTED_WPI_FRAME(aucBDHeader)) )
8774 {
8775 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8776 "WLAN TL:WAI frame was received encrypted - dropping"));
8777 /* Drop packet */
8778 /*Temporary fix added to fix wapi rekey issue*/
8779 //vos_pkt_return_packet(vosDataBuff);
8780 //return vosStatus; //returning success
8781 }
8782 }
8783 else
8784 {
8785 if ( WLANHAL_RX_IS_UNPROTECTED_WPI_FRAME(aucBDHeader) )
8786 {
8787 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8788 "WLAN TL:Non-WAI frame was received unencrypted - dropping"));
8789 /* Drop packet */
8790 vos_pkt_return_packet(vosDataBuff);
8791 return vosStatus; //returning success
8792 }
8793 }
8794 }
8795 else //could not extract EtherType - this should not happen
8796 {
8797 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008798 "WLAN TL:Could not extract EtherType"));
8799 //Packet is already freed
Jeff Johnson295189b2012-06-20 16:38:30 -07008800 return vosStatus; //returning failure
Jeff Johnson295189b2012-06-20 16:38:30 -07008801 }
8802 }
8803#endif /* FEATURE_WLAN_WAPI */
8804
8805 /*----------------------------------------------------------------------
8806 Increment receive counter
8807 !! not sure this is the best place to increase this - pkt might be
8808 dropped below or delayed in TL's queues
8809 - will leave it here for now
8810 ------------------------------------------------------------------------*/
Madan Mohan Koyyalamudic0e5bd82012-09-18 17:12:27 -07008811 if ( !WLANTL_TID_INVALID( ucTid) )
8812 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308813 pClientSTA->auRxCount[ucTid]++;
Madan Mohan Koyyalamudic0e5bd82012-09-18 17:12:27 -07008814 }
8815 else
8816 {
8817 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8818 "WLAN TL:Invalid tid %d (Station ID %d) on %s",
8819 ucTid, ucSTAId, __func__));
8820 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008821
8822 /*------------------------------------------------------------------------
8823 Check if AMSDU and send for processing if so
8824 ------------------------------------------------------------------------*/
8825 ucAsf = (v_U8_t)WDA_GET_RX_ASF(aucBDHeader);
8826
8827 if ( 0 != ucAsf )
8828 {
8829 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
8830 "WLAN TL:Packet is AMSDU sub frame - sending for completion"));
8831 vosStatus = WLANTL_AMSDUProcess( pvosGCtx, &vosDataBuff, aucBDHeader, ucSTAId,
8832 ucMPDUHLen, usMPDULen );
8833 if(NULL == vosDataBuff)
8834 {
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008835 //Packet is already freed
Jeff Johnson295189b2012-06-20 16:38:30 -07008836 return VOS_STATUS_SUCCESS;
8837 }
8838 }
8839 /* After AMSDU header handled
8840 * AMSDU frame just same with normal frames */
8841 /*-------------------------------------------------------------------
8842 Translating header if necesary
8843 !! Fix me: rmv comments below
8844 ----------------------------------------------------------------------*/
8845 if (( 0 == WDA_GET_RX_FT_DONE(aucBDHeader) ) &&
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308846 ( 0 != pClientSTA->wSTADesc.ucSwFrameRXXlation) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07008847 ( WLANTL_IS_DATA_FRAME(WDA_GET_RX_TYPE_SUBTYPE(aucBDHeader)) ))
8848 {
8849 if(0 == ucMPDUHLen)
8850 {
8851 ucMPDUHLen = ucPMPDUHLen;
8852 }
8853 if (usMPDUDOffset > ucMPDUHOffset)
8854 {
8855 usActualHLen = usMPDUDOffset - ucMPDUHOffset;
8856 }
8857 vosStatus = WLANTL_Translate80211To8023Header( vosDataBuff, &vosStatus, usActualHLen,
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07008858 ucMPDUHLen, pTLCb, ucSTAId, bForwardIAPPwithLLC);
Jeff Johnson295189b2012-06-20 16:38:30 -07008859
8860 if ( VOS_STATUS_SUCCESS != vosStatus )
8861 {
Kaushik, Sushante386ee12014-05-01 15:50:52 +05308862 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
Jeff Johnson295189b2012-06-20 16:38:30 -07008863 "WLAN TL:Failed to translate from 802.11 to 802.3 - dropping"));
8864 /* Drop packet */
8865 vos_pkt_return_packet(vosDataBuff);
8866 return vosStatus;
8867 }
8868 }
8869 /* Softap requires additional Info such as Destination STAID and Access
8870 Category. Voschain or Buffer returned by BA would be unchain and this
8871 Meta Data would help in routing the packets to appropriate Destination */
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308872 if( WLAN_STA_SOFTAP == pClientSTA->wSTADesc.wSTAType)
Jeff Johnson295189b2012-06-20 16:38:30 -07008873 {
Arun Kumar Khandavalli37cfc222014-01-09 22:32:40 +05308874 STAMetaInfoPtr = (v_U32_t *)(uintptr_t)(ucTid | (WDA_GET_RX_ADDR3_IDX(aucBDHeader) << WLANTL_STAID_OFFSET));
Jeff Johnson295189b2012-06-20 16:38:30 -07008875 vos_pkt_set_user_data_ptr( vosDataBuff, VOS_PKT_USER_DATA_ID_TL,
8876 (v_PVOID_t)STAMetaInfoPtr);
8877 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008878
8879 /*------------------------------------------------------------------------
8880 Check to see if re-ordering session is in place
8881 ------------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308882 if ( 0 != pClientSTA->atlBAReorderInfo[ucTid].ucExists )
Jeff Johnson295189b2012-06-20 16:38:30 -07008883 {
8884 WLANTL_MSDUReorder( pTLCb, &vosDataBuff, aucBDHeader, ucSTAId, ucTid );
8885 }
8886
Jeff Johnson295189b2012-06-20 16:38:30 -07008887if(0 == ucUnicastBroadcastType
8888#ifdef FEATURE_ON_CHIP_REORDERING
8889 && (WLANHAL_IsOnChipReorderingEnabledForTID(pvosGCtx, ucSTAId, ucTid) != TRUE)
8890#endif
8891)
8892{
8893 /* replay check code : check whether replay check is needed or not */
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308894 if(VOS_TRUE == pClientSTA->ucIsReplayCheckValid)
Jeff Johnson295189b2012-06-20 16:38:30 -07008895 {
8896 /* replay check is needed for the station */
8897
8898 /* check whether frame is AMSDU frame */
8899 if ( 0 != ucAsf )
8900 {
8901 /* Since virgo can't send AMSDU frames this leg of the code
8902 was not tested properly, it needs to be tested properly*/
8903 /* Frame is AMSDU frame. As per 802.11n only first
8904 subframe will have replay counter */
8905 ucEsf = WDA_GET_RX_ESF( aucBDHeader );
8906 if( 0 != ucEsf )
8907 {
8908 v_BOOL_t status;
8909 /* Getting 48-bit replay counter from the RX BD */
8910 ullcurrentReplayCounter = WDA_DS_GetReplayCounter(aucBDHeader);
8911
8912 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Arif Hussainf2b00992013-11-17 21:46:15 -08008913 "WLAN TL: AMSDU currentReplayCounter [0x%llX]",ullcurrentReplayCounter);
Jeff Johnson295189b2012-06-20 16:38:30 -07008914
8915 /* Getting 48-bit previous replay counter from TL control block */
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308916 ullpreviousReplayCounter = pClientSTA->ullReplayCounter[ucTid];
Jeff Johnson295189b2012-06-20 16:38:30 -07008917
8918 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Arif Hussainf2b00992013-11-17 21:46:15 -08008919 "WLAN TL: AMSDU previousReplayCounter [0x%llX]",ullpreviousReplayCounter);
Jeff Johnson295189b2012-06-20 16:38:30 -07008920
8921 /* It is first subframe of AMSDU thus it
8922 conatains replay counter perform the
8923 replay check for this first subframe*/
8924 status = WLANTL_IsReplayPacket( ullcurrentReplayCounter, ullpreviousReplayCounter);
8925 if(VOS_FALSE == status)
8926 {
8927 /* Not a replay paket, update previous replay counter in TL CB */
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308928 pClientSTA->ullReplayCounter[ucTid] = ullcurrentReplayCounter;
Jeff Johnson295189b2012-06-20 16:38:30 -07008929 }
8930 else
8931 {
8932 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Arif Hussainf2b00992013-11-17 21:46:15 -08008933 "WLAN TL: AMSDU Drop the replay packet with PN : [0x%llX]",ullcurrentReplayCounter);
Jeff Johnson295189b2012-06-20 16:38:30 -07008934
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308935 pClientSTA->ulTotalReplayPacketsDetected++;
Jeff Johnson295189b2012-06-20 16:38:30 -07008936 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Arif Hussainf2b00992013-11-17 21:46:15 -08008937 "WLAN TL: AMSDU total dropped replay packets on STA ID %X is [0x%X]",
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308938 ucSTAId, pClientSTA->ulTotalReplayPacketsDetected);
Jeff Johnson295189b2012-06-20 16:38:30 -07008939
8940 /* Drop the packet */
8941 vos_pkt_return_packet(vosDataBuff);
8942 return VOS_STATUS_SUCCESS;
8943 }
8944 }
8945 }
8946 else
8947 {
8948 v_BOOL_t status;
8949
8950 /* Getting 48-bit replay counter from the RX BD */
8951 ullcurrentReplayCounter = WDA_DS_GetReplayCounter(aucBDHeader);
8952
8953 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Arif Hussainf2b00992013-11-17 21:46:15 -08008954 "WLAN TL: Non-AMSDU currentReplayCounter [0x%llX]",ullcurrentReplayCounter);
Jeff Johnson295189b2012-06-20 16:38:30 -07008955
8956 /* Getting 48-bit previous replay counter from TL control block */
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308957 ullpreviousReplayCounter = pClientSTA->ullReplayCounter[ucTid];
Jeff Johnson295189b2012-06-20 16:38:30 -07008958
8959 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Arif Hussainf2b00992013-11-17 21:46:15 -08008960 "WLAN TL: Non-AMSDU previousReplayCounter [0x%llX]",ullpreviousReplayCounter);
Jeff Johnson295189b2012-06-20 16:38:30 -07008961
8962 /* It is not AMSDU frame so perform
8963 reaply check for each packet, as
8964 each packet contains valid replay counter*/
8965 status = WLANTL_IsReplayPacket( ullcurrentReplayCounter, ullpreviousReplayCounter);
8966 if(VOS_FALSE == status)
8967 {
8968 /* Not a replay paket, update previous replay counter in TL CB */
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308969 pClientSTA->ullReplayCounter[ucTid] = ullcurrentReplayCounter;
Jeff Johnson295189b2012-06-20 16:38:30 -07008970 }
8971 else
8972 {
8973 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Arif Hussainf2b00992013-11-17 21:46:15 -08008974 "WLAN TL: Non-AMSDU Drop the replay packet with PN : [0x%llX]",ullcurrentReplayCounter);
Jeff Johnson295189b2012-06-20 16:38:30 -07008975
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308976 pClientSTA->ulTotalReplayPacketsDetected++;
Jeff Johnson295189b2012-06-20 16:38:30 -07008977 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Arif Hussainf2b00992013-11-17 21:46:15 -08008978 "WLAN TL: Non-AMSDU total dropped replay packets on STA ID %X is [0x%X]",
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308979 ucSTAId, pClientSTA->ulTotalReplayPacketsDetected);
Jeff Johnson295189b2012-06-20 16:38:30 -07008980
8981 /* Repaly packet, drop the packet */
8982 vos_pkt_return_packet(vosDataBuff);
8983 return VOS_STATUS_SUCCESS;
8984 }
8985 }
8986 }
8987}
8988/*It is a broadast packet DPU has already done replay check for
8989 broadcast packets no need to do replay check of these packets*/
Jeff Johnson295189b2012-06-20 16:38:30 -07008990
8991 if ( NULL != vosDataBuff )
8992 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308993 if( WLAN_STA_SOFTAP == pClientSTA->wSTADesc.wSTAType)
Jeff Johnson295189b2012-06-20 16:38:30 -07008994 {
8995 WLANTL_FwdPktToHDD( pvosGCtx, vosDataBuff, ucSTAId );
8996 }
8997 else
Jeff Johnson295189b2012-06-20 16:38:30 -07008998 {
8999 wRxMetaInfo.ucUP = ucTid;
Shailender Karmuchi13c0d082013-03-26 14:41:39 -07009000 wRxMetaInfo.rssiAvg = pClientSTA->rssiAvg;
Gopichand Nakkala4a2fc1a2013-05-17 16:59:39 +05309001#ifdef FEATURE_WLAN_TDLS
9002 if (WLAN_STA_TDLS == pClientSTA->wSTADesc.wSTAType)
9003 {
9004 wRxMetaInfo.isStaTdls = TRUE;
9005 }
9006 else
9007 {
9008 wRxMetaInfo.isStaTdls = FALSE;
9009 }
9010#endif
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309011 pClientSTA->pfnSTARx( pvosGCtx, vosDataBuff, ucSTAId,
Jeff Johnson295189b2012-06-20 16:38:30 -07009012 &wRxMetaInfo );
9013 }
9014 }/* if not NULL */
9015
9016 return VOS_STATUS_SUCCESS;
9017}/* WLANTL_STARxAuth */
9018
9019
9020/*==========================================================================
9021 FUNCTION WLANTL_STARxDisc
9022
9023 DESCRIPTION
9024 Receive in disconnected state - no data allowed
9025
9026 DEPENDENCIES
9027 The STA must be registered with TL before this function can be called.
9028
9029 PARAMETERS
9030
9031 IN
9032 pvosGCtx: pointer to the global vos context; a handle to TL's
9033 control block can be extracted from its context
9034 ucSTAId: identifier of the station being processed
9035 vosDataBuff: pointer to the rx vos buffer
9036
9037 RETURN VALUE
9038 The result code associated with performing the operation
9039
9040 VOS_STATUS_SUCCESS: Everything is good :)
9041
9042 SIDE EFFECTS
9043
9044============================================================================*/
9045VOS_STATUS
9046WLANTL_STARxDisc
9047(
9048 v_PVOID_t pvosGCtx,
9049 v_U8_t ucSTAId,
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009050 vos_pkt_t** pvosDataBuff,
9051 v_BOOL_t bForwardIAPPwithLLC
Jeff Johnson295189b2012-06-20 16:38:30 -07009052)
9053{
9054 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
9055
9056 /*------------------------------------------------------------------------
9057 Sanity check
9058 ------------------------------------------------------------------------*/
9059 if (( NULL == pvosDataBuff ) || ( NULL == *pvosDataBuff ))
9060 {
9061 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9062 "WLAN TL:Invalid parameter sent on WLANTL_STARxDisc"));
9063 return VOS_STATUS_E_INVAL;
9064 }
9065
9066 /*------------------------------------------------------------------------
9067 Error - drop packet
9068 ------------------------------------------------------------------------*/
9069 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9070 "WLAN TL:Packet should not be received in state disconnected"
9071 " - dropping"));
9072 vos_pkt_return_packet(*pvosDataBuff);
9073 *pvosDataBuff = NULL;
9074
9075 return VOS_STATUS_SUCCESS;
9076}/* WLANTL_STARxDisc */
9077
9078/*==========================================================================
9079 Processing main loops for MAIN and TX threads
9080 ==========================================================================*/
9081
9082/*==========================================================================
9083 FUNCTION WLANTL_McProcessMsg
9084
9085 DESCRIPTION
9086 Called by VOSS when a message was serialized for TL through the
9087 main thread/task.
9088
9089 DEPENDENCIES
9090 The TL must be initialized before this function can be called.
9091
9092 PARAMETERS
9093
9094 IN
9095 pvosGCtx: pointer to the global vos context; a handle to TL's
9096 control block can be extracted from its context
9097 message: type and content of the message
9098
9099
9100 RETURN VALUE
9101 The result code associated with performing the operation
9102
9103 VOS_STATUS_E_INVAL: invalid input parameters
9104 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
9105 page fault
9106 VOS_STATUS_SUCCESS: Everything is good :)
9107
9108 SIDE EFFECTS
9109
9110============================================================================*/
9111VOS_STATUS
9112WLANTL_McProcessMsg
9113(
9114 v_PVOID_t pvosGCtx,
9115 vos_msg_t* message
9116)
9117{
9118 WLANTL_CbType* pTLCb = NULL;
9119 tAddBAInd* ptAddBaInd = NULL;
9120 tDelBAInd* ptDelBaInd = NULL;
9121 tAddBARsp* ptAddBaRsp = NULL;
9122 vos_msg_t vosMessage;
9123 VOS_STATUS vosStatus;
9124 tpFlushACRsp FlushACRspPtr;
9125 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
9126
9127 /*------------------------------------------------------------------------
9128 Sanity check
9129 ------------------------------------------------------------------------*/
9130 if ( NULL == message )
9131 {
9132 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9133 "WLAN TL:Invalid parameter sent on WLANTL_ProcessMainMessage"));
9134 return VOS_STATUS_E_INVAL;
9135 }
9136
9137 /*------------------------------------------------------------------------
9138 Extract TL control block
9139 ------------------------------------------------------------------------*/
9140 pTLCb = VOS_GET_TL_CB(pvosGCtx);
9141 if ( NULL == pTLCb )
9142 {
9143 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9144 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_ProcessMainMessage"));
9145 return VOS_STATUS_E_FAULT;
9146 }
9147
9148 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
9149 "WLAN TL:Received message: %d through main flow", message->type));
9150
9151 switch( message->type )
9152 {
9153 case WDA_TL_FLUSH_AC_RSP:
9154 // Extract the message from the message body
9155 FlushACRspPtr = (tpFlushACRsp)(message->bodyptr);
9156 // Make sure the call back function is not null.
Tushnim Bhattacharyya5dd94562013-03-20 20:15:03 -07009157 if ( NULL == pTLCb->tlBAPClient.pfnFlushOpCompleteCb )
9158 {
9159 VOS_ASSERT(0);
9160 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9161 "WLAN TL:Invalid TL pointer pfnFlushOpCompleteCb"));
9162 return VOS_STATUS_E_FAULT;
9163 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009164
9165 TLLOG2(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
9166 "Received message: Flush complete received by TL"));
9167
9168 // Since we have the response back from HAL, just call the BAP client
9169 // registered call back from TL. There is only 1 possible
9170 // BAP client. So directly reference tlBAPClient
9171 pTLCb->tlBAPClient.pfnFlushOpCompleteCb( pvosGCtx,
9172 FlushACRspPtr->ucSTAId,
9173 FlushACRspPtr->ucTid, FlushACRspPtr->status );
9174
9175 // Free the PAL memory, we are done with it.
9176 TLLOG2(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
9177 "Flush complete received by TL: Freeing %p", FlushACRspPtr));
9178 vos_mem_free((v_VOID_t *)FlushACRspPtr);
9179 break;
9180
9181 case WDA_HDD_ADDBA_REQ:
9182 ptAddBaInd = (tAddBAInd*)(message->bodyptr);
9183 vosStatus = WLANTL_BaSessionAdd( pvosGCtx,
9184 ptAddBaInd->baSession.baSessionID,
9185 ptAddBaInd->baSession.STAID,
9186 ptAddBaInd->baSession.baTID,
9187 (v_U32_t)ptAddBaInd->baSession.baBufferSize,
9188 ptAddBaInd->baSession.winSize,
9189 ptAddBaInd->baSession.SSN);
9190 ptAddBaRsp = vos_mem_malloc(sizeof(*ptAddBaRsp));
9191
9192 if ( NULL == ptAddBaRsp )
9193 {
9194 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9195 "WLAN TL: fatal failure, cannot allocate BA Rsp structure"));
9196 VOS_ASSERT(0);
9197 return VOS_STATUS_E_NOMEM;
9198 }
9199
9200 if ( VOS_STATUS_SUCCESS == vosStatus )
9201 {
9202 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
9203 "WLAN TL: Sending success indication to HAL for ADD BA"));
9204 /*Send success*/
9205 ptAddBaRsp->mesgType = WDA_HDD_ADDBA_RSP;
9206 vosMessage.type = WDA_HDD_ADDBA_RSP;
9207 }
9208 else
9209 {
9210 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
9211 "WLAN TL: Sending failure indication to HAL for ADD BA"));
9212
9213 /*Send failure*/
9214 ptAddBaRsp->mesgType = WDA_BA_FAIL_IND;
9215 vosMessage.type = WDA_BA_FAIL_IND;
9216 }
9217
9218 ptAddBaRsp->mesgLen = sizeof(tAddBARsp);
9219 ptAddBaRsp->baSessionID = ptAddBaInd->baSession.baSessionID;
9220 /* This is default, reply win size has to be handled BA module, FIX THIS */
9221 ptAddBaRsp->replyWinSize = WLANTL_MAX_WINSIZE;
9222 vosMessage.bodyptr = ptAddBaRsp;
9223
9224 vos_mq_post_message( VOS_MQ_ID_WDA, &vosMessage );
9225 WLANTL_McFreeMsg (pvosGCtx, message);
9226 break;
9227 case WDA_DELETEBA_IND:
9228 ptDelBaInd = (tDelBAInd*)(message->bodyptr);
9229 vosStatus = WLANTL_BaSessionDel(pvosGCtx,
9230 ptDelBaInd->staIdx,
9231 ptDelBaInd->baTID);
9232
9233 if ( VOS_STATUS_SUCCESS != vosStatus )
9234 {
9235 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9236 "WLAN TL: Failed to del BA session STA:%d TID:%d Status :%d",
9237 ptDelBaInd->staIdx,
9238 ptDelBaInd->baTID,
9239 vosStatus));
9240 }
9241 WLANTL_McFreeMsg (pvosGCtx, message);
9242 break;
9243 default:
9244 /*no processing for now*/
9245 break;
9246 }
9247
9248 return VOS_STATUS_SUCCESS;
9249}/* WLANTL_ProcessMainMessage */
9250
9251/*==========================================================================
9252 FUNCTION WLANTL_McFreeMsg
9253
9254 DESCRIPTION
9255 Called by VOSS to free a given TL message on the Main thread when there
9256 are messages pending in the queue when the whole system is been reset.
9257 For now, TL does not allocate any body so this function shout translate
9258 into a NOOP
9259
9260 DEPENDENCIES
9261 The TL must be initialized before this function can be called.
9262
9263 PARAMETERS
9264
9265 IN
9266 pvosGCtx: pointer to the global vos context; a handle to TL's
9267 control block can be extracted from its context
9268 message: type and content of the message
9269
9270
9271 RETURN VALUE
9272 The result code associated with performing the operation
9273
9274 VOS_STATUS_SUCCESS: Everything is good :)
9275
9276 SIDE EFFECTS
9277
9278============================================================================*/
9279VOS_STATUS
9280WLANTL_McFreeMsg
9281(
9282 v_PVOID_t pvosGCtx,
9283 vos_msg_t* message
9284)
9285{
9286 WLANTL_CbType* pTLCb = NULL;
9287 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
9288
9289 /*------------------------------------------------------------------------
9290 Sanity check
9291 ------------------------------------------------------------------------*/
9292 if ( NULL == message )
9293 {
9294 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9295 "WLAN TL:Invalid parameter sent on WLANTL_McFreeMsg"));
9296 return VOS_STATUS_E_INVAL;
9297 }
9298
9299 /*------------------------------------------------------------------------
9300 Extract TL control block
9301 ------------------------------------------------------------------------*/
9302 pTLCb = VOS_GET_TL_CB(pvosGCtx);
9303 if ( NULL == pTLCb )
9304 {
9305 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9306 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_McFreeMsg"));
9307 return VOS_STATUS_E_FAULT;
9308 }
9309
9310 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
9311 "WLAN TL:Received message: %d through main free", message->type));
9312
9313 switch( message->type )
9314 {
9315 case WDA_HDD_ADDBA_REQ:
9316 case WDA_DELETEBA_IND:
9317 /*vos free body pointer*/
9318 vos_mem_free(message->bodyptr);
9319 message->bodyptr = NULL;
9320 break;
9321 default:
9322 /*no processing for now*/
9323 break;
9324 }
9325
9326 return VOS_STATUS_SUCCESS;
9327}/*WLANTL_McFreeMsg*/
9328
9329/*==========================================================================
9330 FUNCTION WLANTL_TxProcessMsg
9331
9332 DESCRIPTION
9333 Called by VOSS when a message was serialized for TL through the
9334 tx thread/task.
9335
9336 DEPENDENCIES
9337 The TL must be initialized before this function can be called.
9338
9339 PARAMETERS
9340
9341 IN
9342 pvosGCtx: pointer to the global vos context; a handle to TL's
9343 control block can be extracted from its context
9344 message: type and content of the message
9345
9346
9347 RETURN VALUE
9348 The result code associated with performing the operation
9349
9350 VOS_STATUS_E_INVAL: invalid input parameters
9351 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
9352 page fault
9353 VOS_STATUS_SUCCESS: Everything is good :)
9354
9355 Other values can be returned as a result of a function call, please check
9356 corresponding API for more info.
9357 SIDE EFFECTS
9358
9359============================================================================*/
9360VOS_STATUS
9361WLANTL_TxProcessMsg
9362(
9363 v_PVOID_t pvosGCtx,
9364 vos_msg_t* message
9365)
9366{
9367 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07009368 void (*callbackRoutine) (void *callbackContext);
9369 void *callbackContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07009370 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
9371
9372 /*------------------------------------------------------------------------
9373 Sanity check
9374 ------------------------------------------------------------------------*/
9375 if ( NULL == message )
9376 {
9377 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9378 "WLAN TL:Invalid parameter sent on WLANTL_ProcessTxMessage"));
9379 return VOS_STATUS_E_INVAL;
9380 }
9381
9382 /*------------------------------------------------------------------------
9383 Process message
9384 ------------------------------------------------------------------------*/
9385 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
9386 "WLAN TL:Received message: %d through tx flow", message->type));
9387
9388 switch( message->type )
9389 {
9390 case WLANTL_TX_SIG_SUSPEND:
9391 vosStatus = WLANTL_SuspendCB( pvosGCtx,
9392 (WLANTL_SuspendCBType)message->bodyptr,
9393 message->reserved);
9394 break;
9395 case WLANTL_TX_RES_NEEDED:
9396 vosStatus = WLANTL_GetTxResourcesCB( pvosGCtx );
9397 break;
Katya Nigam664f5032014-05-05 12:24:32 +05309398
Jeff Johnson295189b2012-06-20 16:38:30 -07009399 case WDA_DS_TX_START_XMIT:
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05309400 WLANTL_ClearTxXmitPending(pvosGCtx);
9401 vosStatus = WDA_DS_TxFrames( pvosGCtx );
Jeff Johnson295189b2012-06-20 16:38:30 -07009402 break;
9403
9404 case WDA_DS_FINISH_ULA:
Arun Kumar Khandavalli8d1979d2014-01-09 21:12:25 +05309405 callbackContext = message->bodyptr;
9406 callbackRoutine = message->callback;
9407 if ( NULL != callbackRoutine )
9408 {
9409 callbackRoutine(callbackContext);
9410 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009411 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009412
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05309413 case WLANTL_TX_SNAPSHOT:
9414 /*Dumping TL State and then continuing to print
9415 the DXE Dump*/
9416 WLANTL_TxThreadDebugHandler(pvosGCtx);
9417 WDA_TransportChannelDebug(NULL, VOS_TRUE, VOS_FALSE);
9418 break;
9419
Mihir Shetefd62d9d2014-08-06 15:08:21 +05309420 case WLANTL_TX_FATAL_ERROR:
9421 WLANTL_FatalErrorHandler(pvosGCtx);
9422 break;
9423
Mihir Shete327c2ab2014-11-13 15:17:02 +05309424 case WLANTL_TX_FW_DEBUG:
Siddharth Bhal68115602015-01-18 20:44:55 +05309425 vos_fwDumpReq(274, 0, 0, 0, 0, 1); //Async event
Mihir Shete327c2ab2014-11-13 15:17:02 +05309426 break;
9427
Jeff Johnson295189b2012-06-20 16:38:30 -07009428 default:
9429 /*no processing for now*/
9430 break;
9431 }
9432
9433 return vosStatus;
9434}/* WLANTL_TxProcessMsg */
9435
9436/*==========================================================================
9437 FUNCTION WLANTL_McFreeMsg
9438
9439 DESCRIPTION
9440 Called by VOSS to free a given TL message on the Main thread when there
9441 are messages pending in the queue when the whole system is been reset.
9442 For now, TL does not allocate any body so this function shout translate
9443 into a NOOP
9444
9445 DEPENDENCIES
9446 The TL must be initialized before this function can be called.
9447
9448 PARAMETERS
9449
9450 IN
9451 pvosGCtx: pointer to the global vos context; a handle to TL's
9452 control block can be extracted from its context
9453 message: type and content of the message
9454
9455
9456 RETURN VALUE
9457 The result code associated with performing the operation
9458
9459 VOS_STATUS_SUCCESS: Everything is good :)
9460
9461 SIDE EFFECTS
9462
9463============================================================================*/
9464VOS_STATUS
9465WLANTL_TxFreeMsg
9466(
9467 v_PVOID_t pvosGCtx,
9468 vos_msg_t* message
9469)
9470{
9471 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
9472
9473 /*Nothing to do for now!!!*/
9474 return VOS_STATUS_SUCCESS;
9475}/*WLANTL_TxFreeMsg*/
9476
Jeff Johnson295189b2012-06-20 16:38:30 -07009477/*==========================================================================
9478
9479 FUNCTION WLANTL_TxFCFrame
9480
9481 DESCRIPTION
9482 Internal utility function to send FC frame. Enable
9483 or disable LWM mode based on the information.
9484
9485 DEPENDENCIES
9486 TL must be initiailized before this function gets called.
9487 FW sends up special flow control frame.
9488
9489 PARAMETERS
9490
9491 IN
9492 pvosGCtx: pointer to the global vos context; a handle to TL's
9493 control block can be extracted from its context
9494
9495 RETURN VALUE
9496 The result code associated with performing the operation
9497
9498 VOS_STATUS_E_INVAL: Input pointers are NULL.
9499 VOS_STATUS_E_FAULT: Something is wrong.
9500 VOS_STATUS_SUCCESS: Everything is good.
9501
9502 SIDE EFFECTS
9503 Newly formed FC frame is generated and waits to be transmitted. Previously unsent frame will
9504 be released.
9505
9506============================================================================*/
9507VOS_STATUS
9508WLANTL_TxFCFrame
9509(
9510 v_PVOID_t pvosGCtx
9511)
9512{
9513#if 0
9514 WLANTL_CbType* pTLCb = NULL;
9515 VOS_STATUS vosStatus;
9516 tpHalFcTxBd pvFcTxBd = NULL;
9517 vos_pkt_t * pPacket = NULL;
9518 v_U8_t ucSTAId = 0;
9519 v_U8_t ucBitCheck = 1;
9520
9521 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009522 "WLAN TL: Send FC frame %s", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07009523
9524 /*------------------------------------------------------------------------
9525 Sanity check
9526 ------------------------------------------------------------------------*/
9527 if ( NULL == pvosGCtx )
9528 {
9529 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009530 "WLAN TL:Invalid parameter %s", __func__));
Jeff Johnson295189b2012-06-20 16:38:30 -07009531 return VOS_STATUS_E_INVAL;
9532 }
9533 /*------------------------------------------------------------------------
9534 Extract TL control block
9535 ------------------------------------------------------------------------*/
9536 pTLCb = VOS_GET_TL_CB(pvosGCtx);
9537
9538 if (NULL == pTLCb)
9539 {
9540 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009541 "WLAN TL:Invalid pointer in %s \n", __func__));
Jeff Johnson295189b2012-06-20 16:38:30 -07009542 return VOS_STATUS_E_INVAL;
9543 }
9544
9545 //Get one voss packet
9546 vosStatus = vos_pkt_get_packet( &pPacket, VOS_PKT_TYPE_TX_802_11_MGMT, sizeof(tHalFcTxBd), 1,
9547 VOS_FALSE, NULL, NULL );
9548
9549 if ( VOS_STATUS_SUCCESS != vosStatus )
9550 {
9551 return VOS_STATUS_E_INVAL;
9552 }
9553
9554 vosStatus = vos_pkt_reserve_head( pPacket, (void *)&pvFcTxBd, sizeof(tHalFcTxBd));
9555
9556 if( VOS_STATUS_SUCCESS != vosStatus )
9557 {
9558 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009559 "%s: failed to reserve FC TX BD %d\n",__func__, sizeof(tHalFcTxBd)));
Jeff Johnson295189b2012-06-20 16:38:30 -07009560 vos_pkt_return_packet( pPacket );
9561 return VOS_STATUS_E_FAULT;
9562 }
9563
9564 //Generate most recent tlFCInfo. Most fields are correct.
9565 pTLCb->tlFCInfo.fcSTAThreshEnabledMask = 0;
9566 pTLCb->tlFCInfo.fcSTATxMoreDataMask = 0;
9567 for( ucSTAId = 0, ucBitCheck = 1 ; ucSTAId < WLAN_MAX_STA_COUNT; ucBitCheck <<= 1, ucSTAId ++)
9568 {
9569 if (0 == pTLCb->atlSTAClients[ucSTAId].ucExists)
9570 {
9571 continue;
9572 }
9573
9574 if (pTLCb->atlSTAClients[ucSTAId].ucPktPending)
9575 {
9576 pTLCb->tlFCInfo.fcSTATxMoreDataMask |= ucBitCheck;
9577 }
9578
9579 if ( (pTLCb->atlSTAClients[ucSTAId].ucLwmModeEnabled) &&
9580 (pTLCb->atlSTAClients[ucSTAId].bmuMemConsumed > pTLCb->atlSTAClients[ucSTAId].uLwmThreshold))
9581 {
9582 pTLCb->tlFCInfo.fcSTAThreshEnabledMask |= ucBitCheck;
9583
9584 pTLCb->tlFCInfo.fcSTAThresh[ucSTAId] = (tANI_U8)pTLCb->atlSTAClients[ucSTAId].uLwmThreshold;
9585
9586 pTLCb->atlSTAClients[ucSTAId].ucLwmEventReported = FALSE;
9587 }
9588
9589 }
9590
9591 //request immediate feedback
9592 pTLCb->tlFCInfo.fcConfig |= 0x4;
9593
9594 //fill in BD to sent
9595 vosStatus = WLANHAL_FillFcTxBd(pvosGCtx, &pTLCb->tlFCInfo, (void *)pvFcTxBd);
9596
9597 if( VOS_STATUS_SUCCESS != vosStatus )
9598 {
9599 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009600 "%s: Fill FC TX BD unsuccessful\n", __func__));
Jeff Johnson295189b2012-06-20 16:38:30 -07009601 vos_pkt_return_packet( pPacket );
9602 return VOS_STATUS_E_FAULT;
9603 }
9604
9605 if (NULL != pTLCb->vosTxFCBuf)
9606 {
9607 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009608 "%s: Previous FC TX BD not sent\n", __func__));
Jeff Johnson295189b2012-06-20 16:38:30 -07009609 vos_pkt_return_packet(pTLCb->vosTxFCBuf);
9610 }
9611
9612 pTLCb->vosTxFCBuf = pPacket;
9613
9614 vos_pkt_set_user_data_ptr( pPacket, VOS_PKT_USER_DATA_ID_TL,
9615 (v_PVOID_t)WLANTL_TxCompDefaultCb);
9616 vosStatus = WDA_DS_StartXmit(pvosGCtx);
9617
9618 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009619 "WLAN TL: send FC frame leave %s", __func__));
Jeff Johnson295189b2012-06-20 16:38:30 -07009620#endif
9621 return VOS_STATUS_SUCCESS;
9622}
9623
Jeff Johnson295189b2012-06-20 16:38:30 -07009624
9625/*==========================================================================
9626 FUNCTION WLANTL_GetTxResourcesCB
9627
9628 DESCRIPTION
9629 Processing function for Resource needed signal. A request will be issued
9630 to BAL to get more tx resources.
9631
9632 DEPENDENCIES
9633 The TL must be initialized before this function can be called.
9634
9635 PARAMETERS
9636
9637 IN
9638 pvosGCtx: pointer to the global vos context; a handle to TL's
9639 control block can be extracted from its context
9640
9641
9642 RETURN VALUE
9643 The result code associated with performing the operation
9644
9645 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
9646 page fault
9647 VOS_STATUS_SUCCESS: Everything is good :)
9648
9649 Other values can be returned as a result of a function call, please check
9650 corresponding API for more info.
9651 SIDE EFFECTS
9652
9653============================================================================*/
9654VOS_STATUS
9655WLANTL_GetTxResourcesCB
9656(
9657 v_PVOID_t pvosGCtx
9658)
9659{
9660 WLANTL_CbType* pTLCb = NULL;
9661 v_U32_t uResCount = WDA_TLI_MIN_RES_DATA;
9662 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
9663 v_U8_t ucMgmt = 0;
9664 v_U8_t ucBAP = 0;
9665 v_U8_t ucData = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07009666#ifdef WLAN_SOFTAP_FLOWCTRL_EN
9667 tBssSystemRole systemRole;
9668 tpAniSirGlobal pMac;
9669#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009670 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
9671 /*------------------------------------------------------------------------
9672 Extract TL control block
9673 ------------------------------------------------------------------------*/
9674 pTLCb = VOS_GET_TL_CB(pvosGCtx);
9675 if ( NULL == pTLCb )
9676 {
9677 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9678 "WLAN TL:Invalid TL pointer from pvosGCtx on"
9679 " WLANTL_ProcessTxMessage"));
9680 return VOS_STATUS_E_FAULT;
9681 }
9682
9683 /*------------------------------------------------------------------------
9684 Get tx resources from BAL
9685 ------------------------------------------------------------------------*/
9686 vosStatus = WDA_DS_GetTxResources( pvosGCtx, &uResCount );
9687
9688 if ( (VOS_STATUS_SUCCESS != vosStatus) && (VOS_STATUS_E_RESOURCES != vosStatus))
9689 {
9690 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9691 "WLAN TL:TL failed to get resources from BAL, Err: %d",
9692 vosStatus));
9693 return vosStatus;
9694 }
9695
9696 /* Currently only Linux BAL returns the E_RESOURCES error code when it is running
9697 out of BD/PDUs. To make use of this interrupt for throughput enhancement, similar
9698 changes should be done in BAL code of AMSS and WM */
9699 if (VOS_STATUS_E_RESOURCES == vosStatus)
9700 {
9701#ifdef VOLANS_PERF
9702 WLANHAL_EnableIdleBdPduInterrupt(pvosGCtx, (tANI_U8)bdPduInterruptGetThreshold);
9703 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
9704 "WLAN TL: Enabling Idle BD/PDU interrupt, Current resources = %d", uResCount);
9705#else
9706 return VOS_STATUS_E_FAILURE;
9707#endif
9708 }
9709
9710 pTLCb->uResCount = uResCount;
9711
9712
Jeff Johnson295189b2012-06-20 16:38:30 -07009713#ifdef WLAN_SOFTAP_FLOWCTRL_EN
9714 /* FIXME: disabled since creating issues in power-save, needs to be addressed */
9715 pTLCb->sendFCFrame ++;
9716 pMac = vos_get_context(VOS_MODULE_ID_WDA, pvosGCtx);
9717 systemRole = wdaGetGlobalSystemRole(pMac);
9718 if (eSYSTEM_AP_ROLE == systemRole)
9719 {
9720 if (pTLCb->sendFCFrame % 16 == 0)
9721 {
9722 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
9723 "Transmit FC"));
9724 WLANTL_TxFCFrame (pvosGCtx);
9725 }
9726 }
9727#endif //WLAN_SOFTAP_FLOWCTRL_EN
Jeff Johnson295189b2012-06-20 16:38:30 -07009728
9729 ucData = ( pTLCb->uResCount >= WDA_TLI_MIN_RES_DATA );
9730 ucBAP = ( pTLCb->uResCount >= WDA_TLI_MIN_RES_BAP ) &&
9731 ( NULL != pTLCb->tlBAPClient.vosPendingDataBuff );
9732 ucMgmt = ( pTLCb->uResCount >= WDA_TLI_MIN_RES_MF ) &&
9733 ( NULL != pTLCb->tlMgmtFrmClient.vosPendingDataBuff );
9734
9735 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
9736 "WLAN TL: Eval Resume tx Res: %d DATA: %d BAP: %d MGMT: %d",
9737 pTLCb->uResCount, ucData, ucBAP, ucMgmt));
9738
9739 if (( 0 == pTLCb->ucTxSuspended ) &&
9740 (( 0 != ucData ) || ( 0 != ucMgmt ) || ( 0 != ucBAP ) ) )
9741 {
9742 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
9743 "Issuing Xmit start request to BAL for avail res SYNC"));
9744 vosStatus =WDA_DS_StartXmit(pvosGCtx);
9745 }
9746 return vosStatus;
9747}/*WLANTL_GetTxResourcesCB*/
9748
9749/*==========================================================================
9750 Utility functions
9751 ==========================================================================*/
9752
9753/*==========================================================================
9754 FUNCTION WLANTL_Translate8023To80211Header
9755
9756 DESCRIPTION
9757 Inline function for translating and 802.11 header into an 802.3 header.
9758
9759 DEPENDENCIES
9760
9761
9762 PARAMETERS
9763
9764 IN
9765 pTLCb: TL control block
Kiran Venkatappaa044eb92012-12-17 15:48:49 -08009766 IN/OUT
9767 ucStaId: station ID. Incase of TDLS, this returns actual TDLS
9768 station ID used
Jeff Johnson295189b2012-06-20 16:38:30 -07009769
9770 IN/OUT
9771 vosDataBuff: vos data buffer, will contain the new header on output
9772
9773 OUT
9774 pvosStatus: status of the operation
9775
9776 RETURN VALUE
9777
9778 VOS_STATUS_SUCCESS: Everything is good :)
9779
9780 Other error codes might be returned from the vos api used in the function
9781 please check those return values.
9782
9783 SIDE EFFECTS
9784
9785============================================================================*/
Kiran Venkatappacab0d352012-12-17 13:09:22 -08009786VOS_STATUS
9787WLANTL_Translate8023To80211Header
9788(
9789 vos_pkt_t* vosDataBuff,
9790 VOS_STATUS* pvosStatus,
9791 WLANTL_CbType* pTLCb,
9792 v_U8_t *pucStaId,
Ravi Joshid0699502013-07-08 15:48:47 -07009793 WLANTL_MetaInfoType *tlMetaInfo,
Kiran Venkatappacab0d352012-12-17 13:09:22 -08009794 v_U8_t *ucWDSEnabled,
9795 v_U8_t *extraHeadSpace
9796)
Jeff Johnson295189b2012-06-20 16:38:30 -07009797{
9798 WLANTL_8023HeaderType w8023Header;
9799 WLANTL_80211HeaderType *pw80211Header; // Allocate an aligned BD and then fill it.
9800 VOS_STATUS vosStatus;
9801 v_U8_t MandatoryucHeaderSize = WLAN80211_MANDATORY_HEADER_SIZE;
9802 v_U8_t ucHeaderSize = 0;
9803 v_VOID_t *ppvBDHeader = NULL;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309804 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07009805 v_U8_t ucQoSOffset = WLAN80211_MANDATORY_HEADER_SIZE;
Kiran Venkatappacab0d352012-12-17 13:09:22 -08009806 v_U8_t ucStaId;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009807#ifdef FEATURE_WLAN_ESE_UPLOAD
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009808 v_BOOL_t bIAPPTxwithLLC = VOS_FALSE;
9809 v_SIZE_t wIAPPSnapSize = WLANTL_LLC_HEADER_LEN;
9810 v_U8_t wIAPPSnap[WLANTL_LLC_HEADER_LEN] = {0};
9811#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009812 *ucWDSEnabled = 0; // default WDS off.
9813 vosStatus = vos_pkt_pop_head( vosDataBuff, &w8023Header,
9814 sizeof(w8023Header));
9815
9816 if ( VOS_STATUS_SUCCESS != vosStatus )
9817 {
9818 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9819 "WLAN TL: Packet pop header fails on WLANTL_Translate8023To80211Header"));
9820 return vosStatus;
9821 }
9822
Kiran Venkatappacab0d352012-12-17 13:09:22 -08009823 if( NULL == pucStaId )
9824 {
9825 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9826 "WLAN TL: Invalid pointer for StaId"));
9827 return VOS_STATUS_E_INVAL;
9828 }
9829 ucStaId = *pucStaId;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309830 pClientSTA = pTLCb->atlSTAClients[ucStaId];
9831
9832 if ( NULL == pClientSTA )
9833 {
9834 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9835 "WLAN TL:Client Memory was not allocated on %s", __func__));
9836 return VOS_STATUS_E_FAILURE;
9837 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -08009838
Kiran Venkatappaa044eb92012-12-17 15:48:49 -08009839#ifdef FEATURE_WLAN_TDLS
9840
Madan Mohan Koyylamudi64258222013-01-30 14:35:10 +05309841 if ( WLAN_STA_INFRA == pTLCb->atlSTAClients[ucStaId]->wSTADesc.wSTAType
9842 && pTLCb->ucTdlsPeerCount )
Kiran Venkatappacab0d352012-12-17 13:09:22 -08009843 {
9844 v_U8_t ucIndex = 0;
9845 for ( ucIndex = 0; ucIndex < WLAN_MAX_STA_COUNT ; ucIndex++)
9846 {
Madan Mohan Koyylamudi64258222013-01-30 14:35:10 +05309847 if ( ucIndex != ucStaId && pTLCb->atlSTAClients[ucIndex] && pTLCb->atlSTAClients[ucIndex]->ucExists &&
Gopichand Nakkala471708b2013-06-04 20:03:01 +05309848 (pTLCb->atlSTAClients[ucIndex]->tlState == WLANTL_STA_AUTHENTICATED) &&
9849 (!pTLCb->atlSTAClients[ucIndex]->ucTxSuspended) &&
Madan Mohan Koyylamudi64258222013-01-30 14:35:10 +05309850 vos_mem_compare( (void*)pTLCb->atlSTAClients[ucIndex]->wSTADesc.vSTAMACAddress.bytes,
Kiran Venkatappacab0d352012-12-17 13:09:22 -08009851 (void*)w8023Header.vDA, 6) )
9852 {
9853 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_LOW,
9854 "WLAN TL: Got a TDLS station. Using that index"));
9855 ucStaId = ucIndex;
9856 *pucStaId = ucStaId;
Madan Mohan Koyylamudi64258222013-01-30 14:35:10 +05309857 pClientSTA = pTLCb->atlSTAClients[ucStaId];
9858 if ( NULL == pClientSTA )
9859 {
9860 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9861 "WLAN TL:Client Memory was not allocated on %s", __func__));
9862 return VOS_STATUS_E_FAILURE;
9863 }
Kiran Venkatappacab0d352012-12-17 13:09:22 -08009864 break;
9865 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -08009866 }
Kiran Venkatappacab0d352012-12-17 13:09:22 -08009867 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -08009868#endif
9869
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009870#ifdef FEATURE_WLAN_ESE_UPLOAD
9871if ((0 == w8023Header.usLenType) && (pClientSTA->wSTADesc.ucIsEseSta))
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009872{
9873 vos_pkt_extract_data(vosDataBuff,0,&wIAPPSnap[0],&wIAPPSnapSize);
9874 if (vos_mem_compare(wIAPPSnap,WLANTL_AIRONET_SNAP_HEADER,WLANTL_LLC_HEADER_LEN))
9875 {
9876 /*The SNAP and the protocol type are already in the data buffer.
9877 They are filled by the application (wpa_supplicant). So, Skip Adding LLC below.*/
9878 bIAPPTxwithLLC = VOS_TRUE;
9879 }
9880 else
9881 {
9882 bIAPPTxwithLLC = VOS_FALSE;
9883 }
9884}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009885#endif /* FEATURE_WLAN_ESE_UPLOAD */
Jeff Johnson295189b2012-06-20 16:38:30 -07009886
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009887 if ((0 != pClientSTA->wSTADesc.ucAddRmvLLC)
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009888#ifdef FEATURE_WLAN_ESE_UPLOAD
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009889 && (!bIAPPTxwithLLC)
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009890#endif /* FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009891 )
Jeff Johnson295189b2012-06-20 16:38:30 -07009892 {
9893 /* Push the length */
9894 vosStatus = vos_pkt_push_head(vosDataBuff,
9895 &w8023Header.usLenType, sizeof(w8023Header.usLenType));
9896
9897 if ( VOS_STATUS_SUCCESS != vosStatus )
9898 {
9899 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9900 "WLAN TL: Packet push ether type fails on"
9901 " WLANTL_Translate8023To80211Header"));
9902 return vosStatus;
9903 }
9904
9905#ifdef BTAMP_TEST
9906 // The STA side will execute this, a hack to test BTAMP by using the
9907 // infra setup. On real BTAMP this will come from BAP itself.
9908 {
9909 static v_U8_t WLANTL_BT_AMP_LLC_HEADER[] = {0xAA, 0xAA, 0x03, 0x00, 0x19, 0x58 };
9910 vosStatus = vos_pkt_push_head(vosDataBuff, WLANTL_BT_AMP_LLC_HEADER,
9911 sizeof(WLANTL_BT_AMP_LLC_HEADER));
9912
9913 if ( VOS_STATUS_SUCCESS != vosStatus )
9914 {
9915 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9916 "WLAN TL: Packet push LLC header fails on"
9917 " WLANTL_Translate8023To80211Header"));
9918 return vosStatus;
9919 }
9920 }
9921#else
9922 vosStatus = vos_pkt_push_head(vosDataBuff, WLANTL_LLC_HEADER,
9923 sizeof(WLANTL_LLC_HEADER));
9924
9925 if ( VOS_STATUS_SUCCESS != vosStatus )
9926 {
9927 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9928 "WLAN TL: Packet push LLC header fails on"
9929 " WLANTL_Translate8023To80211Header"));
9930 return vosStatus;
9931 }
9932#endif
9933 }/*If add LLC is enabled*/
9934 else
9935 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009936#ifdef FEATURE_WLAN_ESE_UPLOAD
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009937 bIAPPTxwithLLC = VOS_FALSE; /*Reset the Flag here to start afresh with the next TX pkt*/
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009938#endif /* FEATURE_WLAN_ESE_UPLOAD */
Jeff Johnson295189b2012-06-20 16:38:30 -07009939 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
9940 "WLAN TL: STA Client registered to not remove LLC"
9941 " WLANTL_Translate8023To80211Header"));
9942 }
9943
9944#ifdef BTAMP_TEST
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309945 pClientSTA->wSTADesc.wSTAType = WLAN_STA_BT_AMP;
Jeff Johnson295189b2012-06-20 16:38:30 -07009946#endif
9947
9948 // Find the space required for the 802.11 header format
9949 // based on the frame control fields.
9950 ucHeaderSize = MandatoryucHeaderSize;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309951 if (pClientSTA->wSTADesc.ucQosEnabled)
Jeff Johnson295189b2012-06-20 16:38:30 -07009952 {
9953 ucHeaderSize += sizeof(pw80211Header->usQosCtrl);
9954 }
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309955 if (pClientSTA->wSTADesc.wSTAType == WLAN_STA_BT_AMP)
Jeff Johnson295189b2012-06-20 16:38:30 -07009956 {
9957 ucHeaderSize += sizeof(pw80211Header->optvA4);
Jeff Johnson295189b2012-06-20 16:38:30 -07009958 ucQoSOffset += sizeof(pw80211Header->optvA4);
Jeff Johnson295189b2012-06-20 16:38:30 -07009959 }
9960
9961 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
9962 " WLANTL_Translate8023To80211Header : Header size = %d ", ucHeaderSize));
9963
9964 vos_pkt_reserve_head( vosDataBuff, &ppvBDHeader, ucHeaderSize );
9965 if ( NULL == ppvBDHeader )
9966 {
9967 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9968 "WLAN TL:VOSS packet corrupted "));
9969 *pvosStatus = VOS_STATUS_E_INVAL;
9970 return *pvosStatus;
9971 }
9972
Jeff Johnson295189b2012-06-20 16:38:30 -07009973
9974 // OK now we have the space. Fill the 80211 header
9975 /* Fill A2 */
9976 pw80211Header = (WLANTL_80211HeaderType *)(ppvBDHeader);
9977 // only clear the required space.
9978 vos_mem_set( pw80211Header, ucHeaderSize, 0 );
9979 vos_mem_copy( pw80211Header->vA2, w8023Header.vSA, VOS_MAC_ADDR_SIZE);
9980
9981
9982#ifdef FEATURE_WLAN_WAPI
Gopichand Nakkala8b54e912013-03-11 10:44:21 +05309983 if (( WLANTL_STA_AUTHENTICATED == pClientSTA->tlState ||
9984 pClientSTA->ptkInstalled ) && gUcIsWai != 1)
Jeff Johnson295189b2012-06-20 16:38:30 -07009985#else
Gopichand Nakkala8b54e912013-03-11 10:44:21 +05309986 if ( WLANTL_STA_AUTHENTICATED == pClientSTA->tlState ||
9987 pClientSTA->ptkInstalled )
Jeff Johnson295189b2012-06-20 16:38:30 -07009988#endif
9989 {
9990 pw80211Header->wFrmCtrl.wep =
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309991 pClientSTA->wSTADesc.ucProtectedFrame;
Jeff Johnson295189b2012-06-20 16:38:30 -07009992 }
9993
9994 pw80211Header->usDurationId = 0;
9995 pw80211Header->usSeqCtrl = 0;
9996
9997 pw80211Header->wFrmCtrl.type = WLANTL_80211_DATA_TYPE;
9998
9999
10000
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053010001 if(pClientSTA->wSTADesc.ucQosEnabled)
Jeff Johnson295189b2012-06-20 16:38:30 -070010002 {
10003 pw80211Header->wFrmCtrl.subType = WLANTL_80211_DATA_QOS_SUBTYPE;
10004
Ravi Joshid0699502013-07-08 15:48:47 -070010005 *((v_U16_t *)((v_U8_t *)ppvBDHeader + ucQoSOffset)) = tlMetaInfo->ucUP;
Jeff Johnson295189b2012-06-20 16:38:30 -070010006
10007 }
10008 else
10009 {
10010 pw80211Header->wFrmCtrl.subType = 0;
Agarwal Ashish8b343f12015-01-08 20:06:44 +053010011 tlMetaInfo->ucUP = 0;
10012 tlMetaInfo->ucTID = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070010013
10014 // NO NO NO - there is not enough memory allocated to write the QOS ctrl
10015 // field, it will overwrite the first 2 bytes of the data packet(LLC header)
10016 // pw80211Header->usQosCtrl = 0;
10017 }
10018
10019
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053010020 switch( pClientSTA->wSTADesc.wSTAType )
Jeff Johnson295189b2012-06-20 16:38:30 -070010021 {
Ravi Joshid0699502013-07-08 15:48:47 -070010022 case WLAN_STA_IBSS:
Jeff Johnson295189b2012-06-20 16:38:30 -070010023 pw80211Header->wFrmCtrl.toDS = 0;
10024 pw80211Header->wFrmCtrl.fromDS = 0;
Ravi Joshid0699502013-07-08 15:48:47 -070010025
Abhishek Singh45e68fe2014-12-11 12:55:59 +053010026 vos_copy_macaddr( (v_MACADDR_t*)&pw80211Header->vA1,
Ravi Joshid0699502013-07-08 15:48:47 -070010027 (v_MACADDR_t*)&w8023Header.vDA);
Jeff Johnson295189b2012-06-20 16:38:30 -070010028 vos_mem_copy( pw80211Header->vA3,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053010029 &pClientSTA->wSTADesc.vBSSIDforIBSS ,
Jeff Johnson295189b2012-06-20 16:38:30 -070010030 VOS_MAC_ADDR_SIZE);
10031 break;
10032
Ravi Joshid0699502013-07-08 15:48:47 -070010033 case WLAN_STA_BT_AMP:
Jeff Johnson295189b2012-06-20 16:38:30 -070010034 *ucWDSEnabled = 1; // WDS on.
10035 pw80211Header->wFrmCtrl.toDS = 1;
10036 pw80211Header->wFrmCtrl.fromDS = 1;
10037 vos_copy_macaddr( (v_MACADDR_t*)&pw80211Header->vA1,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053010038 &pClientSTA->wSTADesc.vSTAMACAddress);
Jeff Johnson295189b2012-06-20 16:38:30 -070010039 vos_mem_copy( pw80211Header->vA2,
Ravi Joshid0699502013-07-08 15:48:47 -070010040 w8023Header.vSA, VOS_MAC_ADDR_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -070010041 vos_copy_macaddr( (v_MACADDR_t*)&pw80211Header->vA3,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053010042 &pClientSTA->wSTADesc.vSTAMACAddress);
Jeff Johnson295189b2012-06-20 16:38:30 -070010043 /* fill the optional A4 header */
10044 vos_mem_copy( pw80211Header->optvA4,
Ravi Joshid0699502013-07-08 15:48:47 -070010045 w8023Header.vSA, VOS_MAC_ADDR_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -070010046 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
Arif Hussainf2b00992013-11-17 21:46:15 -080010047 "BTAMP CASE NOW ---------staid=%d",
Ravi Joshid0699502013-07-08 15:48:47 -070010048 ucStaId));
Jeff Johnson295189b2012-06-20 16:38:30 -070010049 break;
10050
Ravi Joshid0699502013-07-08 15:48:47 -070010051 case WLAN_STA_SOFTAP:
Jeff Johnson295189b2012-06-20 16:38:30 -070010052 *ucWDSEnabled = 0; // WDS off.
10053 pw80211Header->wFrmCtrl.toDS = 0;
10054 pw80211Header->wFrmCtrl.fromDS = 1;
10055 /*Copy the DA to A1*/
10056 vos_mem_copy( pw80211Header->vA1, w8023Header.vDA , VOS_MAC_ADDR_SIZE);
10057 vos_copy_macaddr( (v_MACADDR_t*)&pw80211Header->vA2,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053010058 &pClientSTA->wSTADesc.vSelfMACAddress);
Jeff Johnson295189b2012-06-20 16:38:30 -070010059 vos_mem_copy( pw80211Header->vA3,
Ravi Joshid0699502013-07-08 15:48:47 -070010060 w8023Header.vSA, VOS_MAC_ADDR_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -070010061 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
Arif Hussainf2b00992013-11-17 21:46:15 -080010062 "sw 802 to 80211 softap case ---------staid=%d",
Ravi Joshid0699502013-07-08 15:48:47 -070010063 ucStaId));
Jeff Johnson295189b2012-06-20 16:38:30 -070010064 break;
Mohit Khanna698ba2a2012-12-04 15:08:18 -080010065#ifdef FEATURE_WLAN_TDLS
Ravi Joshid0699502013-07-08 15:48:47 -070010066 case WLAN_STA_TDLS:
Mohit Khanna698ba2a2012-12-04 15:08:18 -080010067 pw80211Header->wFrmCtrl.toDS = 0;
10068 pw80211Header->wFrmCtrl.fromDS = 0;
10069 /*Fix me*/
10070 vos_copy_macaddr( (v_MACADDR_t*)&pw80211Header->vA1,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053010071 &pClientSTA->wSTADesc.vSTAMACAddress);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080010072 vos_mem_copy( pw80211Header->vA3,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053010073 &pClientSTA->wSTADesc.vBSSIDforIBSS ,
Mohit Khanna698ba2a2012-12-04 15:08:18 -080010074 VOS_MAC_ADDR_SIZE);
10075 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
Arif Hussainf2b00992013-11-17 21:46:15 -080010076 ("TL:TDLS CASE NOW ---------staid=%d"), ucStaId);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080010077 break;
10078#endif
Ravi Joshid0699502013-07-08 15:48:47 -070010079 case WLAN_STA_INFRA:
10080 default:
Jeff Johnson295189b2012-06-20 16:38:30 -070010081 pw80211Header->wFrmCtrl.toDS = 1;
10082 pw80211Header->wFrmCtrl.fromDS = 0;
10083 vos_copy_macaddr( (v_MACADDR_t*)&pw80211Header->vA1,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053010084 &pClientSTA->wSTADesc.vSTAMACAddress);
Jeff Johnson295189b2012-06-20 16:38:30 -070010085 vos_mem_copy( pw80211Header->vA3, w8023Header.vDA , VOS_MAC_ADDR_SIZE);
10086 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
Arif Hussainf2b00992013-11-17 21:46:15 -080010087 "REGULAR INFRA LINK CASE---------staid=%d",
Ravi Joshid0699502013-07-08 15:48:47 -070010088 ucStaId));
Jeff Johnson295189b2012-06-20 16:38:30 -070010089 break;
10090 }
10091 // OK now we have the space. Fill the 80211 header
10092 /* Fill A2 */
10093 pw80211Header = (WLANTL_80211HeaderType *)(ppvBDHeader);
10094 return VOS_STATUS_SUCCESS;
10095}/*WLANTL_Translate8023To80211Header*/
10096
10097
10098/*=============================================================================
10099 BEGIN LOG FUNCTION !!! Remove me or clean me
10100=============================================================================*/
Ravi Kumar Vaishnavb7652402013-01-18 19:05:15 -080010101#if 0 //def WLANTL_DEBUG
Jeff Johnson295189b2012-06-20 16:38:30 -070010102
10103#define WLANTL_DEBUG_FRAME_BYTE_PER_LINE 16
10104#define WLANTL_DEBUG_FRAME_BYTE_PER_BYTE 4
10105
10106static v_VOID_t WLANTL_DebugFrame
10107(
10108 v_PVOID_t dataPointer,
10109 v_U32_t dataSize
10110)
10111{
10112 v_U8_t lineBuffer[WLANTL_DEBUG_FRAME_BYTE_PER_LINE];
10113 v_U32_t numLines;
10114 v_U32_t numBytes;
10115 v_U32_t idx;
10116 v_U8_t *linePointer;
10117
10118 numLines = dataSize / WLANTL_DEBUG_FRAME_BYTE_PER_LINE;
10119 numBytes = dataSize % WLANTL_DEBUG_FRAME_BYTE_PER_LINE;
10120 linePointer = (v_U8_t *)dataPointer;
10121
10122 TLLOGE(VOS_TRACE(VOS_MODULE_ID_SAL, VOS_TRACE_LEVEL_ERROR, "WLAN TL:Frame Debug Frame Size %d, Pointer 0x%p", dataSize, dataPointer));
10123 for(idx = 0; idx < numLines; idx++)
10124 {
10125 memset(lineBuffer, 0, WLANTL_DEBUG_FRAME_BYTE_PER_LINE);
10126 memcpy(lineBuffer, linePointer, WLANTL_DEBUG_FRAME_BYTE_PER_LINE);
10127 TLLOGE(VOS_TRACE(VOS_MODULE_ID_SAL, VOS_TRACE_LEVEL_ERROR,
10128 "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",
10129 lineBuffer[0], lineBuffer[1], lineBuffer[2], lineBuffer[3], lineBuffer[4], lineBuffer[5], lineBuffer[6], lineBuffer[7],
10130 lineBuffer[8], lineBuffer[9], lineBuffer[10], lineBuffer[11], lineBuffer[12], lineBuffer[13], lineBuffer[14], lineBuffer[15]));
10131 linePointer += WLANTL_DEBUG_FRAME_BYTE_PER_LINE;
10132 }
10133
10134 if(0 == numBytes)
10135 return;
10136
10137 memset(lineBuffer, 0, WLANTL_DEBUG_FRAME_BYTE_PER_LINE);
10138 memcpy(lineBuffer, linePointer, numBytes);
10139 for(idx = 0; idx < WLANTL_DEBUG_FRAME_BYTE_PER_LINE / WLANTL_DEBUG_FRAME_BYTE_PER_BYTE; idx++)
10140 {
10141 TLLOGE(VOS_TRACE(VOS_MODULE_ID_SAL, VOS_TRACE_LEVEL_ERROR, "WLAN TL:0x%2x 0x%2x 0x%2x 0x%2x",
10142 lineBuffer[idx * WLANTL_DEBUG_FRAME_BYTE_PER_BYTE], lineBuffer[1 + idx * WLANTL_DEBUG_FRAME_BYTE_PER_BYTE],
10143 lineBuffer[2 + idx * WLANTL_DEBUG_FRAME_BYTE_PER_BYTE], lineBuffer[3 + idx * WLANTL_DEBUG_FRAME_BYTE_PER_BYTE]));
10144 if(((idx + 1) * WLANTL_DEBUG_FRAME_BYTE_PER_BYTE) >= numBytes)
10145 break;
10146 }
10147
10148 return;
10149}
10150#endif
10151
10152/*=============================================================================
10153 END LOG FUNCTION
10154=============================================================================*/
10155
10156/*==========================================================================
10157 FUNCTION WLANTL_Translate80211To8023Header
10158
10159 DESCRIPTION
10160 Inline function for translating and 802.11 header into an 802.3 header.
10161
10162 DEPENDENCIES
10163
10164
10165 PARAMETERS
10166
10167 IN
10168 pTLCb: TL control block
10169 ucStaId: station ID
10170 ucHeaderLen: Length of the header from BD
10171 ucActualHLen: Length of header including padding or any other trailers
10172
10173 IN/OUT
10174 vosDataBuff: vos data buffer, will contain the new header on output
10175
10176 OUT
10177 pvosStatus: status of the operation
10178
10179 RETURN VALUE
10180
10181 The result code associated with performing the operation
10182 VOS_STATUS_SUCCESS: Everything is good :)
10183
10184 SIDE EFFECTS
10185
10186============================================================================*/
10187VOS_STATUS
10188WLANTL_Translate80211To8023Header
10189(
10190 vos_pkt_t* vosDataBuff,
10191 VOS_STATUS* pvosStatus,
10192 v_U16_t usActualHLen,
10193 v_U8_t ucHeaderLen,
10194 WLANTL_CbType* pTLCb,
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070010195 v_U8_t ucSTAId,
10196 v_BOOL_t bForwardIAPPwithLLC
Jeff Johnson295189b2012-06-20 16:38:30 -070010197)
10198{
10199 WLANTL_8023HeaderType w8023Header;
10200 WLANTL_80211HeaderType w80211Header;
10201 v_U8_t aucLLCHeader[WLANTL_LLC_HEADER_LEN];
10202 VOS_STATUS vosStatus;
10203 v_U16_t usDataStartOffset = 0;
10204 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
10205
10206 if ( sizeof(w80211Header) < ucHeaderLen )
10207 {
10208 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
10209 "Warning !: Check the header size for the Rx frame structure=%d received=%dn",
10210 sizeof(w80211Header), ucHeaderLen));
10211 ucHeaderLen = sizeof(w80211Header);
10212 }
10213
10214 // This will take care of headers of all sizes, 3 address, 3 addr QOS,
10215 // WDS non-QOS and WDS QoS etc. We have space for all in the 802.11 header structure.
10216 vosStatus = vos_pkt_pop_head( vosDataBuff, &w80211Header, ucHeaderLen);
10217
10218 if ( VOS_STATUS_SUCCESS != vosStatus )
10219 {
10220 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
10221 "WLAN TL: Failed to pop 80211 header from packet %d",
10222 vosStatus));
10223
10224 return vosStatus;
10225 }
10226
10227 switch ( w80211Header.wFrmCtrl.fromDS )
10228 {
10229 case 0:
Jeff Johnson295189b2012-06-20 16:38:30 -070010230 if ( w80211Header.wFrmCtrl.toDS )
10231 {
10232 //SoftAP AP mode
10233 vos_mem_copy( w8023Header.vDA, w80211Header.vA3, VOS_MAC_ADDR_SIZE);
10234 vos_mem_copy( w8023Header.vSA, w80211Header.vA2, VOS_MAC_ADDR_SIZE);
10235 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
Arif Hussainf2b00992013-11-17 21:46:15 -080010236 "WLAN TL SoftAP: 802 3 DA %08x SA %08x",
Jeff Johnson295189b2012-06-20 16:38:30 -070010237 w8023Header.vDA, w8023Header.vSA));
10238 }
10239 else
10240 {
10241 /* IBSS */
10242 vos_mem_copy( w8023Header.vDA, w80211Header.vA1, VOS_MAC_ADDR_SIZE);
10243 vos_mem_copy( w8023Header.vSA, w80211Header.vA2, VOS_MAC_ADDR_SIZE);
10244 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010245 break;
10246 case 1:
10247 if ( w80211Header.wFrmCtrl.toDS )
10248 {
10249 /* BT-AMP case */
10250 vos_mem_copy( w8023Header.vDA, w80211Header.vA1, VOS_MAC_ADDR_SIZE);
10251 vos_mem_copy( w8023Header.vSA, w80211Header.vA2, VOS_MAC_ADDR_SIZE);
10252 }
10253 else
10254 { /* Infra */
10255 vos_mem_copy( w8023Header.vDA, w80211Header.vA1, VOS_MAC_ADDR_SIZE);
10256 vos_mem_copy( w8023Header.vSA, w80211Header.vA3, VOS_MAC_ADDR_SIZE);
10257 }
10258 break;
10259 }
10260
10261 if( usActualHLen > ucHeaderLen )
10262 {
10263 usDataStartOffset = usActualHLen - ucHeaderLen;
10264 }
10265
10266 if ( 0 < usDataStartOffset )
10267 {
10268 vosStatus = vos_pkt_trim_head( vosDataBuff, usDataStartOffset );
10269
10270 if ( VOS_STATUS_SUCCESS != vosStatus )
10271 {
10272 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
10273 "WLAN TL: Failed to trim header from packet %d",
10274 vosStatus));
10275 return vosStatus;
10276 }
10277 }
10278
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053010279 if ( NULL == pTLCb->atlSTAClients[ucSTAId] )
10280 {
10281 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
10282 "WLAN TL:Client Memory was not allocated on %s", __func__));
10283 return VOS_STATUS_E_FAILURE;
10284 }
10285
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070010286 if ( 0 != pTLCb->atlSTAClients[ucSTAId]->wSTADesc.ucAddRmvLLC
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010287#ifdef FEATURE_WLAN_ESE_UPLOAD
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070010288 && (!bForwardIAPPwithLLC)
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010289#endif /* FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070010290 )
Jeff Johnson295189b2012-06-20 16:38:30 -070010291 {
10292 // Extract the LLC header
10293 vosStatus = vos_pkt_pop_head( vosDataBuff, aucLLCHeader,
10294 WLANTL_LLC_HEADER_LEN);
10295
10296 if ( VOS_STATUS_SUCCESS != vosStatus )
10297 {
Kaushik, Sushante386ee12014-05-01 15:50:52 +053010298 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
Jeff Johnson295189b2012-06-20 16:38:30 -070010299 "WLAN TL: Failed to pop LLC header from packet %d",
10300 vosStatus));
10301
10302 return vosStatus;
10303 }
10304
10305 //Extract the length
10306 vos_mem_copy(&w8023Header.usLenType,
10307 &aucLLCHeader[WLANTL_LLC_HEADER_LEN - sizeof(w8023Header.usLenType)],
10308 sizeof(w8023Header.usLenType) );
10309 }
10310 else
10311 {
10312 vosStatus = vos_pkt_get_packet_length(vosDataBuff,
10313 &w8023Header.usLenType);
10314
10315 if ( VOS_STATUS_SUCCESS != vosStatus )
10316 {
10317 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
10318 "WLAN TL: Failed to get packet length %d",
10319 vosStatus));
10320
10321 return vosStatus;
10322 }
10323
10324 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
10325 "WLAN TL: BTAMP len (ethertype) fld = %d",
10326 w8023Header.usLenType));
10327 w8023Header.usLenType = vos_cpu_to_be16(w8023Header.usLenType);
10328 }
10329
10330 vos_pkt_push_head(vosDataBuff, &w8023Header, sizeof(w8023Header));
10331
10332#ifdef BTAMP_TEST
10333 {
10334 // AP side will execute this.
10335 v_U8_t *temp_w8023Header = NULL;
10336 vosStatus = vos_pkt_peek_data( vosDataBuff, 0,
10337 &temp_w8023Header, sizeof(w8023Header) );
10338 }
10339#endif
10340#if 0 /*TL_DEBUG*/
10341 vos_pkt_get_packet_length(vosDataBuff, &usLen);
10342 vos_pkt_pop_head( vosDataBuff, aucData, usLen);
10343
10344 WLANTL_DebugFrame(aucData, usLen);
10345
10346 vos_pkt_push_head(vosDataBuff, aucData, usLen);
10347
10348#endif
10349
10350 *pvosStatus = VOS_STATUS_SUCCESS;
10351
10352 return VOS_STATUS_SUCCESS;
10353}/*WLANTL_Translate80211To8023Header*/
10354
Madan Mohan Koyyalamudia148e1e2012-11-30 14:52:59 -080010355/*==========================================================================
10356 FUNCTION WLANTL_FindFrameTypeBcMcUc
10357
10358 DESCRIPTION
10359 Utility function to find whether received frame is broadcast, multicast
10360 or unicast.
10361
10362 DEPENDENCIES
10363 The STA must be registered with TL before this function can be called.
10364
10365 PARAMETERS
10366
10367 IN
10368 pTLCb: pointer to the TL's control block
10369 ucSTAId: identifier of the station being processed
10370 vosDataBuff: pointer to the vos buffer
10371
10372 IN/OUT
10373 pucBcMcUc: pointer to buffer, will contain frame type on return
10374
10375 RETURN VALUE
10376 The result code associated with performing the operation
10377
10378 VOS_STATUS_E_INVAL: invalid input parameters
10379 VOS_STATUS_E_BADMSG: failed to extract info from data buffer
10380 VOS_STATUS_SUCCESS: success
10381
10382 SIDE EFFECTS
10383 None.
10384============================================================================*/
10385VOS_STATUS
10386WLANTL_FindFrameTypeBcMcUc
10387(
10388 WLANTL_CbType *pTLCb,
10389 v_U8_t ucSTAId,
10390 vos_pkt_t *vosDataBuff,
10391 v_U8_t *pucBcMcUc
10392)
10393{
10394 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
10395 v_PVOID_t aucBDHeader;
10396 v_PVOID_t pvPeekData;
10397 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
10398
10399 /*------------------------------------------------------------------------
10400 Sanity check
10401 ------------------------------------------------------------------------*/
10402 if ((NULL == pTLCb) ||
10403 (NULL == vosDataBuff) ||
10404 (NULL == pucBcMcUc))
10405 {
10406 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
10407 "WLAN TL:Invalid parameter in WLANTL_FindFrameTypeBcMcUc"));
10408 return VOS_STATUS_E_INVAL;
10409 }
10410
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053010411 if ( NULL == pTLCb->atlSTAClients[ucSTAId] )
10412 {
10413 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
10414 "WLAN TL:Client Memory was not allocated on %s", __func__));
10415 return VOS_STATUS_E_FAILURE;
10416 }
10417
Madan Mohan Koyyalamudia148e1e2012-11-30 14:52:59 -080010418 /*------------------------------------------------------------------------
10419 Extract BD header and check if valid
10420 ------------------------------------------------------------------------*/
10421 vosStatus = WDA_DS_PeekRxPacketInfo(vosDataBuff, (v_PVOID_t)&aucBDHeader, 0/*Swap BD*/ );
10422
10423 if (NULL == aucBDHeader)
10424 {
10425 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
10426 "WLAN TL:WLANTL_FindFrameTypeBcMcUc - Cannot extract BD header"));
10427 VOS_ASSERT(0);
10428 return VOS_STATUS_E_BADMSG;
10429 }
10430
10431 if ((0 == WDA_GET_RX_FT_DONE(aucBDHeader)) &&
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053010432 (0 != pTLCb->atlSTAClients[ucSTAId]->wSTADesc.ucSwFrameRXXlation))
Madan Mohan Koyyalamudia148e1e2012-11-30 14:52:59 -080010433 {
10434 /* Its an 802.11 frame, extract MAC address 1 */
10435 TLLOG2(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
10436 "WLAN TL:WLANTL_FindFrameTypeBcMcUc - 802.11 frame, peeking Addr1"));
10437 vosStatus = vos_pkt_peek_data(vosDataBuff, WLANTL_MAC_ADDR_ALIGN(1),
10438 (v_PVOID_t)&pvPeekData, VOS_MAC_ADDR_SIZE);
10439 }
10440 else
10441 {
10442 /* Its an 802.3 frame, extract Destination MAC address */
10443 TLLOG2(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
10444 "WLAN TL:WLANTL_FindFrameTypeBcMcUc - 802.3 frame, peeking DA"));
10445 vosStatus = vos_pkt_peek_data(vosDataBuff, WLANTL_MAC_ADDR_ALIGN(0),
10446 (v_PVOID_t)&pvPeekData, VOS_MAC_ADDR_SIZE);
10447 }
10448
10449 if (VOS_STATUS_SUCCESS != vosStatus)
10450 {
10451 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
10452 "WLAN TL:WLANTL_FindFrameTypeBcMcUc - Failed to peek MAC address"));
10453 return vosStatus;
10454 }
10455
10456 if (((tANI_U8 *)pvPeekData)[0] == 0xff)
10457 {
10458 *pucBcMcUc = WLANTL_FRAME_TYPE_BCAST;
10459 }
10460 else
10461 {
10462 if ((((tANI_U8 *)pvPeekData)[0] & 0x01) == 0x01)
10463 *pucBcMcUc = WLANTL_FRAME_TYPE_MCAST;
10464 else
10465 *pucBcMcUc = WLANTL_FRAME_TYPE_UCAST;
10466 }
10467
10468 TLLOG2(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
10469 "WLAN TL:WLANTL_FindFrameTypeBcMcUc - Addr1Byte1 is: %x",
10470 ((tANI_U8 *)pvPeekData)[0]));
10471
10472 return VOS_STATUS_SUCCESS;
10473}
10474
Jeff Johnson295189b2012-06-20 16:38:30 -070010475#if 0
10476#ifdef WLAN_PERF
10477/*==========================================================================
10478 FUNCTION WLANTL_FastHwFwdDataFrame
10479
10480 DESCRIPTION
10481 Fast path function to quickly forward a data frame if HAL determines BD
10482 signature computed here matches the signature inside current VOSS packet.
10483 If there is a match, HAL and TL fills in the swapped packet length into
10484 BD header and DxE header, respectively. Otherwise, packet goes back to
10485 normal (slow) path and a new BD signature would be tagged into BD in this
10486 VOSS packet later by the WLANHAL_FillTxBd() function.
10487
10488 DEPENDENCIES
10489
10490 PARAMETERS
10491
10492 IN
10493 pvosGCtx VOS context
10494 vosDataBuff Ptr to VOSS packet
10495 pMetaInfo For getting frame's TID
10496 pStaInfo For checking STA type
10497
10498 OUT
10499 pvosStatus returned status
10500 puFastFwdOK Flag to indicate whether frame could be fast forwarded
10501
10502 RETURN VALUE
10503 No return.
10504
10505 SIDE EFFECTS
10506
10507============================================================================*/
10508static void
10509WLANTL_FastHwFwdDataFrame
10510(
10511 v_PVOID_t pvosGCtx,
10512 vos_pkt_t* vosDataBuff,
10513 VOS_STATUS* pvosStatus,
10514 v_U32_t* puFastFwdOK,
10515 WLANTL_MetaInfoType* pMetaInfo,
10516 WLAN_STADescType* pStaInfo
10517
10518)
10519{
10520 v_PVOID_t pvPeekData;
10521 v_U8_t ucDxEBDWLANHeaderLen = WLANTL_BD_HEADER_LEN(0) + sizeof(WLANBAL_sDXEHeaderType);
10522 v_U8_t ucIsUnicast;
10523 WLANBAL_sDXEHeaderType *pDxEHeader;
10524 v_PVOID_t pvBDHeader;
10525 v_PVOID_t pucBuffPtr;
10526 v_U16_t usPktLen;
10527
10528 /*-----------------------------------------------------------------------
10529 Extract packet length
10530 -----------------------------------------------------------------------*/
10531
10532 vos_pkt_get_packet_length( vosDataBuff, &usPktLen);
10533
10534 /*-----------------------------------------------------------------------
10535 Extract MAC address
10536 -----------------------------------------------------------------------*/
10537 *pvosStatus = vos_pkt_peek_data( vosDataBuff,
10538 WLANTL_MAC_ADDR_ALIGN(0),
10539 (v_PVOID_t)&pvPeekData,
10540 VOS_MAC_ADDR_SIZE );
10541
10542 if ( VOS_STATUS_SUCCESS != *pvosStatus )
10543 {
10544 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
10545 "WLAN TL:Failed while attempting to extract MAC Addr %d",
10546 *pvosStatus));
10547 *pvosStatus = VOS_STATUS_E_INVAL;
10548 return;
10549 }
10550
10551 /*-----------------------------------------------------------------------
10552 Reserve head room for DxE header, BD, and WLAN header
10553 -----------------------------------------------------------------------*/
10554
10555 vos_pkt_reserve_head( vosDataBuff, &pucBuffPtr,
10556 ucDxEBDWLANHeaderLen );
10557 if ( NULL == pucBuffPtr )
10558 {
10559 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
10560 "WLAN TL:No enough space in VOSS packet %p for DxE/BD/WLAN header", vosDataBuff));
10561 *pvosStatus = VOS_STATUS_E_INVAL;
10562 return;
10563 }
10564 pDxEHeader = (WLANBAL_sDXEHeaderType *)pucBuffPtr;
10565 pvBDHeader = (v_PVOID_t) &pDxEHeader[1];
10566
10567 /* UMA Tx acceleration is enabled.
10568 * UMA would help convert frames to 802.11, fill partial BD fields and
10569 * construct LLC header. To further accelerate this kind of frames,
10570 * HAL would attempt to reuse the BD descriptor if the BD signature
10571 * matches to the saved BD descriptor.
10572 */
10573 if(pStaInfo->wSTAType == WLAN_STA_IBSS)
10574 ucIsUnicast = !(((tANI_U8 *)pvPeekData)[0] & 0x01);
10575 else
10576 ucIsUnicast = 1;
10577
10578 *puFastFwdOK = (v_U32_t) WLANHAL_TxBdFastFwd(pvosGCtx, pvPeekData, pMetaInfo->ucTID, ucIsUnicast, pvBDHeader, usPktLen );
10579
10580 /* Can't be fast forwarded. Trim the VOS head back to original location. */
10581 if(! *puFastFwdOK){
10582 vos_pkt_trim_head(vosDataBuff, ucDxEBDWLANHeaderLen);
10583 }else{
10584 /* could be fast forwarded. Now notify BAL DxE header filling could be completely skipped
10585 */
10586 v_U32_t uPacketSize = WLANTL_BD_HEADER_LEN(0) + usPktLen;
10587 vos_pkt_set_user_data_ptr( vosDataBuff, VOS_PKT_USER_DATA_ID_BAL,
10588 (v_PVOID_t)uPacketSize);
10589 pDxEHeader->size = SWAP_ENDIAN_UINT32(uPacketSize);
10590 }
10591 *pvosStatus = VOS_STATUS_SUCCESS;
10592 return;
10593}
10594#endif /*WLAN_PERF*/
10595#endif
10596
10597#if 0
10598/*==========================================================================
10599 FUNCTION WLANTL_PrepareBDHeader
10600
10601 DESCRIPTION
10602 Inline function for preparing BD header before HAL processing.
10603
10604 DEPENDENCIES
10605 Just notify HAL that suspend in TL is complete.
10606
10607 PARAMETERS
10608
10609 IN
10610 vosDataBuff: vos data buffer
10611 ucDisableFrmXtl: is frame xtl disabled
10612
10613 OUT
10614 ppvBDHeader: it will contain the BD header
10615 pvDestMacAdddr: it will contain the destination MAC address
10616 pvosStatus: status of the combined processing
10617 pusPktLen: packet len.
10618
10619 RETURN VALUE
10620 No return.
10621
10622 SIDE EFFECTS
10623
10624============================================================================*/
10625void
10626WLANTL_PrepareBDHeader
10627(
10628 vos_pkt_t* vosDataBuff,
10629 v_PVOID_t* ppvBDHeader,
10630 v_MACADDR_t* pvDestMacAdddr,
10631 v_U8_t ucDisableFrmXtl,
10632 VOS_STATUS* pvosStatus,
10633 v_U16_t* pusPktLen,
10634 v_U8_t ucQosEnabled,
10635 v_U8_t ucWDSEnabled,
10636 v_U8_t extraHeadSpace
10637)
10638{
10639 v_U8_t ucHeaderOffset;
10640 v_U8_t ucHeaderLen;
Jeff Johnson295189b2012-06-20 16:38:30 -070010641 v_U8_t ucBDHeaderLen = WLANTL_BD_HEADER_LEN(ucDisableFrmXtl);
10642
10643 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
10644 /*-------------------------------------------------------------------------
10645 Get header pointer from VOSS
10646 !!! make sure reserve head zeros out the memory
10647 -------------------------------------------------------------------------*/
10648 vos_pkt_get_packet_length( vosDataBuff, pusPktLen);
10649
10650 if ( WLANTL_MAC_HEADER_LEN(ucDisableFrmXtl) > *pusPktLen )
10651 {
10652 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
10653 "WLAN TL: Length of the packet smaller than expected network"
10654 " header %d", *pusPktLen ));
10655
10656 *pvosStatus = VOS_STATUS_E_INVAL;
10657 return;
10658 }
10659
10660 vos_pkt_reserve_head( vosDataBuff, ppvBDHeader,
10661 ucBDHeaderLen );
10662 if ( NULL == *ppvBDHeader )
10663 {
10664 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
10665 "WLAN TL:VOSS packet corrupted on Attach BD header"));
10666 *pvosStatus = VOS_STATUS_E_INVAL;
10667 return;
10668 }
10669
10670 /*-----------------------------------------------------------------------
10671 Extract MAC address
10672 -----------------------------------------------------------------------*/
Jeff Johnson295189b2012-06-20 16:38:30 -070010673 {
10674 v_SIZE_t usMacAddrSize = VOS_MAC_ADDR_SIZE;
10675 *pvosStatus = vos_pkt_extract_data( vosDataBuff,
10676 ucBDHeaderLen +
10677 WLANTL_MAC_ADDR_ALIGN(ucDisableFrmXtl),
10678 (v_PVOID_t)pvDestMacAdddr,
10679 &usMacAddrSize );
10680 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010681 if ( VOS_STATUS_SUCCESS != *pvosStatus )
10682 {
10683 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
10684 "WLAN TL:Failed while attempting to extract MAC Addr %d",
10685 *pvosStatus));
10686 }
10687 else
10688 {
10689 /*---------------------------------------------------------------------
10690 Fill MPDU info fields:
10691 - MPDU data start offset
10692 - MPDU header start offset
10693 - MPDU header length
10694 - MPDU length - this is a 16b field - needs swapping
10695 --------------------------------------------------------------------*/
10696 ucHeaderOffset = ucBDHeaderLen;
10697 ucHeaderLen = WLANTL_MAC_HEADER_LEN(ucDisableFrmXtl);
10698
10699 if ( 0 != ucDisableFrmXtl )
10700 {
10701 if ( 0 != ucQosEnabled )
10702 {
10703 ucHeaderLen += WLANTL_802_11_HEADER_QOS_CTL;
10704 }
10705
10706 // Similar to Qos we need something for WDS format !
10707 if ( ucWDSEnabled != 0 )
10708 {
10709 // If we have frame translation enabled
10710 ucHeaderLen += WLANTL_802_11_HEADER_ADDR4_LEN;
10711 }
10712 if ( extraHeadSpace != 0 )
10713 {
10714 // Decrease the packet length with the extra padding after the header
10715 *pusPktLen = *pusPktLen - extraHeadSpace;
10716 }
10717 }
10718
10719 WLANHAL_TX_BD_SET_MPDU_HEADER_LEN( *ppvBDHeader, ucHeaderLen);
10720 WLANHAL_TX_BD_SET_MPDU_HEADER_OFFSET( *ppvBDHeader, ucHeaderOffset);
10721 WLANHAL_TX_BD_SET_MPDU_DATA_OFFSET( *ppvBDHeader,
10722 ucHeaderOffset + ucHeaderLen + extraHeadSpace);
10723 WLANHAL_TX_BD_SET_MPDU_LEN( *ppvBDHeader, *pusPktLen);
10724
10725 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
10726 "WLAN TL: VALUES ARE HLen=%x Hoff=%x doff=%x len=%x ex=%d",
10727 ucHeaderLen, ucHeaderOffset,
10728 (ucHeaderOffset + ucHeaderLen + extraHeadSpace),
10729 *pusPktLen, extraHeadSpace));
10730 }/* if peek MAC success*/
10731
10732}/* WLANTL_PrepareBDHeader */
10733#endif
10734
Jeff Johnson295189b2012-06-20 16:38:30 -070010735//THIS IS A HACK AND NEEDS TO BE FIXED FOR CONCURRENCY
10736/*==========================================================================
10737 FUNCTION WLAN_TLGetNextTxIds
10738
10739 DESCRIPTION
10740 Gets the next station and next AC in the list that should be served by the TL.
10741
10742 Multiple Station Scheduling and TL queue management.
10743
10744 4 HDD BC/MC data packet queue status is specified as Station 0's status. Weights used
10745 in WFQ algorith are initialized in WLANTL_OPEN and contained in tlConfigInfo field.
10746 Each station has fields of ucPktPending and AC mask to tell whether a AC has traffic
10747 or not.
10748
10749 Stations are served in a round-robin fashion from highest priority to lowest priority.
10750 The number of round-robin times of each prioirty equals to the WFQ weights and differetiates
10751 the traffic of different prioirty. As such, stations can not provide low priority packets if
10752 high priority packets are all served.
10753
10754 DEPENDENCIES
10755
10756 PARAMETERS
10757
10758 IN
10759 pvosGCtx: pointer to the global vos context; a handle to TL's
10760 control block can be extracted from its context
10761
10762 OUT
10763 pucSTAId: Station ID
10764
10765 RETURN VALUE
10766 The result code associated with performing the operation
10767
10768 VOS_STATUS_SUCCESS: Everything is good
10769
10770 SIDE EFFECTS
10771
10772 TL context contains currently served station ID in ucCurrentSTA field, currently served AC
10773 in uCurServedAC field, and unserved weights of current AC in uCurLeftWeight.
10774 When existing from the function, these three fields are changed accordingly.
10775
10776============================================================================*/
10777VOS_STATUS
10778WLAN_TLAPGetNextTxIds
10779(
10780 v_PVOID_t pvosGCtx,
10781 v_U8_t* pucSTAId
10782)
10783{
10784 WLANTL_CbType* pTLCb;
10785 v_U8_t ucACFilter = 1;
10786 v_U8_t ucNextSTA ;
10787 v_BOOL_t isServed = TRUE; //current round has find a packet or not
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +053010788 v_U8_t ucACLoopNum = WLANTL_AC_HIGH_PRIO + 1; //number of loop to go
Jeff Johnson295189b2012-06-20 16:38:30 -070010789 v_U8_t uFlowMask; // TX FlowMask from WDA
10790 uint8 ucACMask;
Gopichand Nakkala96237bc2013-01-04 12:20:29 -080010791 uint8 i = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070010792 /*------------------------------------------------------------------------
10793 Extract TL control block
10794 ------------------------------------------------------------------------*/
10795 //ENTER();
10796
10797 pTLCb = VOS_GET_TL_CB(pvosGCtx);
10798 if ( NULL == pTLCb )
10799 {
10800 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
10801 "WLAN TL:Invalid TL pointer from pvosGCtx on WLAN_TLAPGetNextTxIds"));
10802 return VOS_STATUS_E_FAULT;
10803 }
10804
10805 if ( VOS_STATUS_SUCCESS != WDA_DS_GetTxFlowMask( pvosGCtx, &uFlowMask ) )
10806 {
10807 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
10808 "WLAN TL:Failed to retrieve Flow control mask from WDA"));
10809 return VOS_STATUS_E_FAULT;
10810 }
10811
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +053010812 /* The flow mask does not differentiate between different ACs/Qs
10813 * since we use a single dxe channel for all ACs/Qs, hence it is
10814 * enough to check that there are dxe resources on data channel
10815 */
10816 uFlowMask &= WLANTL_DATA_FLOW_MASK;
10817
10818 if (0 == uFlowMask)
10819 {
10820 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
10821 "WLAN TL: No resources to send packets"));
10822
10823 // Setting STA Id to invalid if mask is 0
10824 *pucSTAId = WLAN_MAX_STA_COUNT;
10825 return VOS_STATUS_E_FAULT;
10826 }
10827
Jeff Johnson295189b2012-06-20 16:38:30 -070010828 ucNextSTA = pTLCb->ucCurrentSTA;
10829
10830 ++ucNextSTA;
10831
10832 if ( WLAN_MAX_STA_COUNT <= ucNextSTA )
10833 {
10834 //one round is done.
10835 ucNextSTA = 0;
10836 pTLCb->ucCurLeftWeight--;
10837 isServed = FALSE;
10838 if ( 0 == pTLCb->ucCurLeftWeight )
10839 {
10840 //current prioirty is done
10841 if ( WLANTL_AC_BK == (WLANTL_ACEnumType)pTLCb->uCurServedAC )
10842 {
10843 //end of current VO, VI, BE, BK loop. Reset priority.
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +053010844 pTLCb->uCurServedAC = WLANTL_AC_HIGH_PRIO;
Jeff Johnson295189b2012-06-20 16:38:30 -070010845 }
10846 else
10847 {
10848 pTLCb->uCurServedAC --;
10849 }
10850
10851 pTLCb->ucCurLeftWeight = pTLCb->tlConfigInfo.ucAcWeights[pTLCb->uCurServedAC];
10852
10853 } // (0 == pTLCb->ucCurLeftWeight)
10854 } //( WLAN_MAX_STA_COUNT == ucNextSTA )
10855
10856 //decide how many loops to go. if current loop is partial, do one extra to make sure
10857 //we cover every station
10858 if ((1 == pTLCb->ucCurLeftWeight) && (ucNextSTA != 0))
10859 {
10860 ucACLoopNum ++; // now is 5 loops
10861 }
10862
10863 /* Start with highest priority. ucNextSTA, pTLCb->uCurServedAC, pTLCb->ucCurLeftWeight
10864 all have previous values.*/
10865 for (; ucACLoopNum > 0; ucACLoopNum--)
10866 {
10867
10868 ucACFilter = 1 << pTLCb->uCurServedAC;
10869
10870 // pTLCb->ucCurLeftWeight keeps previous results.
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +053010871 for (; (pTLCb->ucCurLeftWeight > 0) ; pTLCb->ucCurLeftWeight-- )
Jeff Johnson295189b2012-06-20 16:38:30 -070010872 {
10873
10874 for ( ; ucNextSTA < WLAN_MAX_STA_COUNT; ucNextSTA ++ )
10875 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053010876 if(NULL == pTLCb->atlSTAClients[ucNextSTA])
10877 {
10878 continue;
10879 }
10880 WLAN_TL_AC_ARRAY_2_MASK (pTLCb->atlSTAClients[ucNextSTA], ucACMask, i);
Jeff Johnson295189b2012-06-20 16:38:30 -070010881
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053010882 if ( (0 == pTLCb->atlSTAClients[ucNextSTA]->ucExists) ||
10883 ((0 == pTLCb->atlSTAClients[ucNextSTA]->ucPktPending) && !(ucACMask)) ||
Jeff Johnson295189b2012-06-20 16:38:30 -070010884 (0 == (ucACMask & ucACFilter)) )
10885
10886 {
Tushnim Bhattacharyya39a8f182013-02-20 18:10:30 -080010887 //current station does not exist or have any packet to serve.
10888 continue;
10889 }
10890
10891 if (WLANTL_STA_AUTHENTICATED != pTLCb->atlSTAClients[ucNextSTA]->tlState)
10892 {
10893 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
10894 "%s Sta %d not in auth state so skipping it.",
10895 __func__, ucNextSTA));
Jeff Johnson295189b2012-06-20 16:38:30 -070010896 continue;
10897 }
10898
10899 //go to next station if current station can't send due to flow control
10900 //Station is allowed to send when it is not in LWM mode. When station is in LWM mode,
10901 //station is allowed to send only after FW reports FW memory is below threshold and on-fly
10902 //packets are less then allowed value
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053010903 if ( (TRUE == pTLCb->atlSTAClients[ucNextSTA]->ucLwmModeEnabled) &&
10904 ((FALSE == pTLCb->atlSTAClients[ucNextSTA]->ucLwmEventReported) ||
10905 (0 < pTLCb->atlSTAClients[ucNextSTA]->uBuffThresholdMax))
Jeff Johnson295189b2012-06-20 16:38:30 -070010906 )
10907 {
10908 continue;
10909 }
10910
10911
10912 // Find a station. Weight is updated already.
10913 *pucSTAId = ucNextSTA;
10914 pTLCb->ucCurrentSTA = ucNextSTA;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053010915 pTLCb->atlSTAClients[*pucSTAId]->ucCurrentAC = pTLCb->uCurServedAC;
Jeff Johnson295189b2012-06-20 16:38:30 -070010916
10917 TLLOG4(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_LOW,
10918 " TL serve one station AC: %d W: %d StaId: %d",
10919 pTLCb->uCurServedAC, pTLCb->ucCurLeftWeight, pTLCb->ucCurrentSTA ));
10920
10921 return VOS_STATUS_SUCCESS;
10922 } //STA loop
10923
10924 ucNextSTA = 0;
10925 if ( FALSE == isServed )
10926 {
10927 //current loop finds no packet.no need to repeat for the same priority
10928 break;
10929 }
10930 //current loop is partial loop. go for one more loop.
10931 isServed = FALSE;
10932
10933 } //Weight loop
10934
10935 if (WLANTL_AC_BK == pTLCb->uCurServedAC)
10936 {
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +053010937 pTLCb->uCurServedAC = WLANTL_AC_HIGH_PRIO;
Jeff Johnson295189b2012-06-20 16:38:30 -070010938 }
10939 else
10940 {
10941 pTLCb->uCurServedAC--;
10942 }
10943 pTLCb->ucCurLeftWeight = pTLCb->tlConfigInfo.ucAcWeights[pTLCb->uCurServedAC];
10944
10945 }// AC loop
10946
10947 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
Arif Hussainf2b00992013-11-17 21:46:15 -080010948 " TL can't find one station to serve" ));
Jeff Johnson295189b2012-06-20 16:38:30 -070010949
10950 pTLCb->uCurServedAC = WLANTL_AC_BK;
10951 pTLCb->ucCurLeftWeight = 1;
10952 //invalid number will be captured by caller
10953 pTLCb->ucCurrentSTA = WLAN_MAX_STA_COUNT;
10954
10955 *pucSTAId = pTLCb->ucCurrentSTA;
Jeff Johnson295189b2012-06-20 16:38:30 -070010956 return VOS_STATUS_E_FAULT;
10957}
10958
10959
10960/*==========================================================================
10961 FUNCTION WLAN_TLGetNextTxIds
10962
10963 DESCRIPTION
10964 Gets the next station and next AC in the list
10965
10966 DEPENDENCIES
10967
10968 PARAMETERS
10969
10970 IN
10971 pvosGCtx: pointer to the global vos context; a handle to TL's
10972 control block can be extracted from its context
10973
10974 OUT
10975 pucSTAId: Station ID
10976
10977
10978 RETURN VALUE
10979 The result code associated with performing the operation
10980
10981 VOS_STATUS_SUCCESS: Everything is good :)
10982
10983 SIDE EFFECTS
10984
10985============================================================================*/
10986VOS_STATUS
10987WLAN_TLGetNextTxIds
10988(
10989 v_PVOID_t pvosGCtx,
10990 v_U8_t* pucSTAId
10991)
10992{
10993 WLANTL_CbType* pTLCb;
10994 v_U8_t ucNextAC;
10995 v_U8_t ucNextSTA;
10996 v_U8_t ucCount;
10997 v_U8_t uFlowMask; // TX FlowMask from WDA
10998 v_U8_t ucACMask = 0;
10999 v_U8_t i = 0;
11000
11001 tBssSystemRole systemRole; //RG HACK to be removed
11002 tpAniSirGlobal pMac;
11003
11004 pMac = vos_get_context(VOS_MODULE_ID_PE, pvosGCtx);
11005 if ( NULL == pMac )
11006 {
11007 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070011008 "%s: Invalid pMac", __func__));
Jeff Johnson295189b2012-06-20 16:38:30 -070011009 return VOS_STATUS_E_FAULT;
11010 }
11011
11012 systemRole = wdaGetGlobalSystemRole(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -070011013
Jeff Johnson295189b2012-06-20 16:38:30 -070011014 /*------------------------------------------------------------------------
11015 Extract TL control block
11016 ------------------------------------------------------------------------*/
11017 pTLCb = VOS_GET_TL_CB(pvosGCtx);
11018 if ( NULL == pTLCb )
11019 {
11020 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11021 "WLAN TL:Invalid TL pointer from pvosGCtx on WLAN_TLGetNextTxIds"));
11022 return VOS_STATUS_E_FAULT;
11023 }
11024
Sunil Ravid5406f22013-01-22 00:18:31 -080011025#ifdef FEATURE_WLAN_TDLS
Agarwal Ashishcd86f7b2014-06-16 17:11:58 +053011026 if ((eSYSTEM_AP_ROLE == systemRole) ||
11027 (vos_concurrent_open_sessions_running()) || pTLCb->ucTdlsPeerCount)
Sunil Ravid5406f22013-01-22 00:18:31 -080011028#else
Agarwal Ashishcd86f7b2014-06-16 17:11:58 +053011029 if ((eSYSTEM_AP_ROLE == systemRole) ||
11030 (vos_concurrent_open_sessions_running()))
Sunil Ravid5406f22013-01-22 00:18:31 -080011031#endif
11032 {
11033 return WLAN_TLAPGetNextTxIds(pvosGCtx,pucSTAId);
11034 }
11035
11036
Jeff Johnson295189b2012-06-20 16:38:30 -070011037 if ( VOS_STATUS_SUCCESS != WDA_DS_GetTxFlowMask( pvosGCtx, &uFlowMask ) )
11038 {
11039 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11040 "WLAN TL:Failed to retrieve Flow control mask from WDA"));
11041 return VOS_STATUS_E_FAULT;
11042 }
11043
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +053011044 /* The flow mask does not differentiate between different ACs/Qs
11045 * since we use a single dxe channel for all ACs/Qs, hence it is
11046 * enough to check that there are dxe resources on data channel
11047 */
11048 uFlowMask &= WLANTL_DATA_FLOW_MASK;
11049
11050 if (0 == uFlowMask)
11051 {
11052 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11053 "WLAN TL: No resources to send packets"));
11054
11055 // Setting STA id to invalid if mask is 0
11056 *pucSTAId = WLAN_MAX_STA_COUNT;
11057 return VOS_STATUS_E_FAULT;
11058 }
11059
Jeff Johnson295189b2012-06-20 16:38:30 -070011060 /*STA id - no priority yet implemented */
11061 /*-----------------------------------------------------------------------
11062 Choose the next STA for tx - for now go in a round robin fashion
11063 through all the stations that have pending packets
11064 -------------------------------------------------------------------------*/
11065 ucNextSTA = pTLCb->ucCurrentSTA;
11066
11067 pTLCb->ucCurrentSTA = WLAN_MAX_STA_COUNT;
11068 for ( ucCount = 0;
11069 ucCount < WLAN_MAX_STA_COUNT;
11070 ucCount++ )
11071 {
11072 ucNextSTA = ( (ucNextSTA+1) >= WLAN_MAX_STA_COUNT )?0:(ucNextSTA+1);
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053011073 if(NULL == pTLCb->atlSTAClients[ucNextSTA])
11074 {
11075 continue;
11076 }
11077 if (( pTLCb->atlSTAClients[ucNextSTA]->ucExists ) &&
11078 ( pTLCb->atlSTAClients[ucNextSTA]->ucPktPending ))
Jeff Johnson295189b2012-06-20 16:38:30 -070011079 {
Tushnim Bhattacharyya39a8f182013-02-20 18:10:30 -080011080 if (WLANTL_STA_AUTHENTICATED == pTLCb->atlSTAClients[ucNextSTA]->tlState)
11081 {
11082 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
11083 "STA ID: %d on WLAN_TLGetNextTxIds", *pucSTAId));
11084 pTLCb->ucCurrentSTA = ucNextSTA;
11085 break;
Tushnim Bhattacharyya5dd94562013-03-20 20:15:03 -070011086 }
11087 else
11088 {
Tushnim Bhattacharyya39a8f182013-02-20 18:10:30 -080011089 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
11090 "%s Sta %d is not in auth state, skipping this sta.",
11091 __func__, ucNextSTA));
Tushnim Bhattacharyya5dd94562013-03-20 20:15:03 -070011092 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011093 }
11094 }
11095
11096 *pucSTAId = pTLCb->ucCurrentSTA;
11097
11098 if ( WLANTL_STA_ID_INVALID( *pucSTAId ) )
11099 {
11100 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
11101 "WLAN TL:No station registered with TL at this point"));
11102
11103 return VOS_STATUS_E_FAULT;
11104
11105 }
11106
11107 /*Convert the array to a mask for easier operation*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053011108 WLAN_TL_AC_ARRAY_2_MASK( pTLCb->atlSTAClients[*pucSTAId], ucACMask, i);
Jeff Johnson295189b2012-06-20 16:38:30 -070011109
11110 if ( 0 == ucACMask )
11111 {
11112 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11113 "WLAN TL: Mask 0 "
11114 "STA ID: %d on WLAN_TLGetNextTxIds", *pucSTAId));
11115
11116 /*setting STA id to invalid if mask is 0*/
11117 *pucSTAId = WLAN_MAX_STA_COUNT;
11118
11119 return VOS_STATUS_E_FAULT;
11120 }
11121
11122 /*-----------------------------------------------------------------------
11123 AC is updated whenever a packet is fetched from HDD -> the current
11124 weight of such an AC cannot be 0 -> in this case TL is expected to
11125 exit this function at this point during the main Tx loop
11126 -----------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053011127 if ( 0 < pTLCb->atlSTAClients[*pucSTAId]->ucCurrentWeight )
Jeff Johnson295189b2012-06-20 16:38:30 -070011128 {
11129 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
11130 "WLAN TL: Maintaining serviced AC to: %d for Weight: %d",
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053011131 pTLCb->atlSTAClients[*pucSTAId]->ucCurrentAC ,
11132 pTLCb->atlSTAClients[*pucSTAId]->ucCurrentWeight));
Jeff Johnson295189b2012-06-20 16:38:30 -070011133 return VOS_STATUS_SUCCESS;
11134 }
11135
11136 /*-----------------------------------------------------------------------
11137 Choose highest priority AC - !!! optimize me
11138 -----------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053011139 ucNextAC = pTLCb->atlSTAClients[*pucSTAId]->ucCurrentAC;
Jeff Johnson295189b2012-06-20 16:38:30 -070011140 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
11141 "Next AC: %d", ucNextAC));
11142
11143 while ( 0 != ucACMask )
11144 {
11145 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
11146 " AC Mask: %d Next: %d Res : %d",
11147 ucACMask, ( 1 << ucNextAC ), ( ucACMask & ( 1 << ucNextAC ))));
11148
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +053011149 if ( 0 != ( ucACMask & ( 1 << ucNextAC )))
Jeff Johnson295189b2012-06-20 16:38:30 -070011150 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053011151 pTLCb->atlSTAClients[*pucSTAId]->ucCurrentAC =
Jeff Johnson295189b2012-06-20 16:38:30 -070011152 (WLANTL_ACEnumType)ucNextAC;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053011153 pTLCb->atlSTAClients[*pucSTAId]->ucCurrentWeight =
Jeff Johnson295189b2012-06-20 16:38:30 -070011154 pTLCb->tlConfigInfo.ucAcWeights[ucNextAC];
11155
11156 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
11157 "WLAN TL: Switching serviced AC to: %d with Weight: %d",
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053011158 pTLCb->atlSTAClients[*pucSTAId]->ucCurrentAC ,
11159 pTLCb->atlSTAClients[*pucSTAId]->ucCurrentWeight));
Jeff Johnson295189b2012-06-20 16:38:30 -070011160 break;
11161 }
11162
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +053011163 if (ucNextAC == WLANTL_AC_BK)
11164 ucNextAC = WLANTL_AC_HIGH_PRIO;
11165 else
11166 ucNextAC--;
Jeff Johnson295189b2012-06-20 16:38:30 -070011167
11168 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
11169 "Next AC %d", ucNextAC));
Jeff Johnson295189b2012-06-20 16:38:30 -070011170 }
11171
11172 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
11173 " C AC: %d C W: %d",
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053011174 pTLCb->atlSTAClients[*pucSTAId]->ucCurrentAC,
11175 pTLCb->atlSTAClients[*pucSTAId]->ucCurrentWeight));
Jeff Johnson295189b2012-06-20 16:38:30 -070011176
11177 return VOS_STATUS_SUCCESS;
11178}/* WLAN_TLGetNextTxIds */
11179
Jeff Johnson295189b2012-06-20 16:38:30 -070011180
11181
11182/*==========================================================================
11183 DEFAULT HANDLERS: Registered at initialization with TL
11184 ==========================================================================*/
11185
11186/*==========================================================================
11187
11188 FUNCTION WLANTL_MgmtFrmRxDefaultCb
11189
11190 DESCRIPTION
11191 Default Mgmt Frm rx callback: asserts all the time. If this function gets
11192 called it means there is no registered rx cb pointer for Mgmt Frm.
11193
11194 DEPENDENCIES
11195
11196 PARAMETERS
11197 Not used.
11198
11199 RETURN VALUE
11200
11201 VOS_STATUS_E_FAILURE: Always FAILURE.
11202
11203============================================================================*/
11204VOS_STATUS
11205WLANTL_MgmtFrmRxDefaultCb
11206(
11207 v_PVOID_t pvosGCtx,
11208 v_PVOID_t vosBuff
11209)
11210{
11211 if ( NULL != vosBuff )
11212 {
11213 TLLOGP(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_FATAL,
11214 "WLAN TL:Fatal failure: No registered Mgmt Frm client on pkt RX"));
11215 /* Drop packet */
11216 vos_pkt_return_packet((vos_pkt_t *)vosBuff);
11217 }
11218
Jeff Johnson295189b2012-06-20 16:38:30 -070011219 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
11220 "WLAN TL: No registered Mgmt Frm client on pkt RX. Load/Unload in progress, Ignore"));
Jeff Johnson295189b2012-06-20 16:38:30 -070011221
11222 return VOS_STATUS_E_FAILURE;
11223}/*WLANTL_MgmtFrmRxDefaultCb*/
11224
11225/*==========================================================================
11226
Madan Mohan Koyyalamudi6c2977d2013-09-04 15:42:45 +053011227 FUNCTION WLANTL_BAPRxDefaultCb
Jeff Johnson295189b2012-06-20 16:38:30 -070011228
11229 DESCRIPTION
11230 Default BAP rx callback: asserts all the time. If this function gets
11231 called it means there is no registered rx cb pointer for BAP.
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_BAPRxDefaultCb
11245(
11246 v_PVOID_t pvosGCtx,
11247 vos_pkt_t* vosDataBuff,
11248 WLANTL_BAPFrameEnumType frameType
11249)
11250{
11251 TLLOGP(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_FATAL,
11252 "WLAN TL:Fatal failure: No registered BAP client on BAP pkt RX"));
11253#ifndef BTAMP_TEST
11254 VOS_ASSERT(0);
11255#endif
11256 return VOS_STATUS_E_FAILURE;
11257}/*WLANTL_MgmtFrmRxDefaultCb*/
11258
11259/*==========================================================================
11260
11261 FUNCTION WLANTL_STARxDefaultCb
11262
11263 DESCRIPTION
11264 Default STA rx callback: asserts all the time. If this function gets
11265 called it means there is no registered rx cb pointer for station.
11266 (Mem corruption most likely, it should never happen)
11267
11268 DEPENDENCIES
11269
11270 PARAMETERS
11271 Not used.
11272
11273 RETURN VALUE
11274
11275 VOS_STATUS_E_FAILURE: Always FAILURE.
11276
11277============================================================================*/
11278VOS_STATUS
11279WLANTL_STARxDefaultCb
11280(
11281 v_PVOID_t pvosGCtx,
11282 vos_pkt_t* vosDataBuff,
11283 v_U8_t ucSTAId,
11284 WLANTL_RxMetaInfoType* pRxMetaInfo
11285)
11286{
11287 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11288 "WLAN TL: No registered STA client rx cb for STAID: %d dropping pkt",
11289 ucSTAId));
11290 vos_pkt_return_packet(vosDataBuff);
Madan Mohan Koyyalamudi6c2977d2013-09-04 15:42:45 +053011291 return VOS_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070011292}/*WLANTL_MgmtFrmRxDefaultCb*/
11293
11294
11295/*==========================================================================
11296
11297 FUNCTION WLANTL_STAFetchPktDefaultCb
11298
11299 DESCRIPTION
11300 Default fetch callback: asserts all the time. If this function gets
11301 called it means there is no registered fetch cb pointer for station.
11302 (Mem corruption most likely, it should never happen)
11303
11304 DEPENDENCIES
11305
11306 PARAMETERS
11307 Not used.
11308
11309 RETURN VALUE
11310
11311 VOS_STATUS_E_FAILURE: Always FAILURE.
11312
11313============================================================================*/
11314VOS_STATUS
11315WLANTL_STAFetchPktDefaultCb
11316(
11317 v_PVOID_t pvosGCtx,
11318 v_U8_t* pucSTAId,
11319 WLANTL_ACEnumType ucAC,
11320 vos_pkt_t** vosDataBuff,
11321 WLANTL_MetaInfoType* tlMetaInfo
11322)
11323{
11324 TLLOGP(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_FATAL,
11325 "WLAN TL:Fatal failure: No registered STA client on data pkt RX"));
11326 VOS_ASSERT(0);
11327 return VOS_STATUS_E_FAILURE;
11328}/*WLANTL_MgmtFrmRxDefaultCb*/
11329
11330/*==========================================================================
11331
11332 FUNCTION WLANTL_TxCompDefaultCb
11333
11334 DESCRIPTION
11335 Default tx complete handler. It will release the completed pkt to
11336 prevent memory leaks.
11337
11338 PARAMETERS
11339
11340 IN
11341 pvosGCtx: pointer to the global vos context; a handle to
11342 TL/HAL/PE/BAP/HDD control block can be extracted from
11343 its context
11344 vosDataBuff: pointer to the VOSS data buffer that was transmitted
11345 wTxSTAtus: status of the transmission
11346
11347
11348 RETURN VALUE
11349 The result code associated with performing the operation; please
11350 check vos_pkt_return_packet for possible error codes.
11351
11352 Please check vos_pkt_return_packet API for possible return values.
11353
11354============================================================================*/
11355VOS_STATUS
11356WLANTL_TxCompDefaultCb
11357(
11358 v_PVOID_t pvosGCtx,
11359 vos_pkt_t* vosDataBuff,
11360 VOS_STATUS wTxSTAtus
11361)
11362{
11363 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
11364 "WLAN TL:TXComp not registered, releasing pkt to prevent mem leak"));
11365 return vos_pkt_return_packet(vosDataBuff);
11366}/*WLANTL_TxCompDefaultCb*/
11367
11368
11369/*==========================================================================
11370 Cleanup functions
11371 ==========================================================================*/
11372
11373/*==========================================================================
11374
11375 FUNCTION WLANTL_CleanCB
11376
11377 DESCRIPTION
11378 Cleans TL control block
11379
11380 DEPENDENCIES
11381
11382 PARAMETERS
11383
11384 IN
11385 pTLCb: pointer to TL's control block
11386 ucEmpty: set if TL has to clean up the queues and release pedning pkts
11387
11388 RETURN VALUE
11389 The result code associated with performing the operation
11390
11391 VOS_STATUS_E_INVAL: invalid input parameters
11392 VOS_STATUS_SUCCESS: Everything is good :)
11393
11394 SIDE EFFECTS
11395
11396============================================================================*/
11397VOS_STATUS
11398WLANTL_CleanCB
11399(
11400 WLANTL_CbType* pTLCb,
11401 v_U8_t ucEmpty
11402)
11403{
11404 v_U8_t ucIndex;
11405 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
11406
11407 /*-------------------------------------------------------------------------
11408 Sanity check
11409 -------------------------------------------------------------------------*/
11410 if ( NULL == pTLCb )
11411 {
11412 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11413 "WLAN TL:Invalid parameter sent on WLANTL_CleanCB"));
11414 return VOS_STATUS_E_INVAL;
11415 }
11416
11417 /* number of packets sent to BAL waiting for tx complete confirmation */
11418 pTLCb->usPendingTxCompleteCount = 0;
11419
11420 /* global suspend flag */
11421 vos_atomic_set_U8( &pTLCb->ucTxSuspended, 1);
11422
11423 /* resource flag */
11424 pTLCb->uResCount = 0;
11425
11426
11427 /*-------------------------------------------------------------------------
11428 Client stations
11429 -------------------------------------------------------------------------*/
11430 for ( ucIndex = 0; ucIndex < WLAN_MAX_STA_COUNT ; ucIndex++)
11431 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053011432 if(NULL != pTLCb->atlSTAClients[ucIndex])
11433 {
11434 WLANTL_CleanSTA( pTLCb->atlSTAClients[ucIndex], ucEmpty);
11435 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011436 }
11437
11438 /*-------------------------------------------------------------------------
11439 Management Frame client
11440 -------------------------------------------------------------------------*/
11441 pTLCb->tlMgmtFrmClient.ucExists = 0;
11442
11443 if ( ( 0 != ucEmpty) &&
11444 ( NULL != pTLCb->tlMgmtFrmClient.vosPendingDataBuff ))
11445 {
11446 vos_pkt_return_packet(pTLCb->tlMgmtFrmClient.vosPendingDataBuff);
11447 }
11448
11449 pTLCb->tlMgmtFrmClient.vosPendingDataBuff = NULL;
11450
11451 /* set to a default cb in order to prevent constant checking for NULL */
11452 pTLCb->tlMgmtFrmClient.pfnTlMgmtFrmRx = WLANTL_MgmtFrmRxDefaultCb;
11453
11454 /*-------------------------------------------------------------------------
11455 BT AMP client
11456 -------------------------------------------------------------------------*/
11457 pTLCb->tlBAPClient.ucExists = 0;
11458
11459 if (( 0 != ucEmpty) &&
11460 ( NULL != pTLCb->tlBAPClient.vosPendingDataBuff ))
11461 {
11462 vos_pkt_return_packet(pTLCb->tlBAPClient.vosPendingDataBuff);
11463 }
11464
11465 if (( 0 != ucEmpty) &&
11466 ( NULL != pTLCb->vosDummyBuf ))
11467 {
11468 vos_pkt_return_packet(pTLCb->vosDummyBuf);
11469 }
11470
11471 pTLCb->tlBAPClient.vosPendingDataBuff = NULL;
11472
11473 pTLCb->vosDummyBuf = NULL;
11474 pTLCb->vosTempBuf = NULL;
11475 pTLCb->ucCachedSTAId = WLAN_MAX_STA_COUNT;
11476
11477 /* set to a default cb in order to prevent constant checking for NULL */
11478 pTLCb->tlBAPClient.pfnTlBAPRx = WLANTL_BAPRxDefaultCb;
11479
11480 pTLCb->ucRegisteredStaId = WLAN_MAX_STA_COUNT;
11481
11482 return VOS_STATUS_SUCCESS;
11483
11484}/* WLANTL_CleanCB*/
11485
11486/*==========================================================================
11487
11488 FUNCTION WLANTL_CleanSTA
11489
11490 DESCRIPTION
11491 Cleans a station control block.
11492
11493 DEPENDENCIES
11494
11495 PARAMETERS
11496
11497 IN
11498 pvosGCtx: pointer to the global vos context; a handle to TL's
11499 control block can be extracted from its context
11500 ucEmpty: if set the queues and pending pkts will be emptyed
11501
11502 RETURN VALUE
11503 The result code associated with performing the operation
11504
11505 VOS_STATUS_E_INVAL: invalid input parameters
11506 VOS_STATUS_SUCCESS: Everything is good :)
11507
11508 SIDE EFFECTS
11509
11510============================================================================*/
11511VOS_STATUS
11512WLANTL_CleanSTA
11513(
11514 WLANTL_STAClientType* ptlSTAClient,
11515 v_U8_t ucEmpty
11516)
11517{
11518 v_U8_t ucIndex;
11519 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
11520
11521 /*-------------------------------------------------------------------------
11522 Sanity check
11523 -------------------------------------------------------------------------*/
11524 if ( NULL == ptlSTAClient )
11525 {
11526 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11527 "WLAN TL:Invalid parameter sent on WLANTL_CleanSTA"));
11528 return VOS_STATUS_E_INVAL;
11529 }
11530
11531 /*------------------------------------------------------------------------
11532 Clear station from TL
11533 ------------------------------------------------------------------------*/
11534 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
11535 "WLAN TL: Clearing STA Client ID: %d, Empty flag: %d",
11536 ptlSTAClient->wSTADesc.ucSTAId, ucEmpty ));
11537
11538 ptlSTAClient->pfnSTARx = WLANTL_STARxDefaultCb;
11539 ptlSTAClient->pfnSTATxComp = WLANTL_TxCompDefaultCb;
11540 ptlSTAClient->pfnSTAFetchPkt = WLANTL_STAFetchPktDefaultCb;
11541
11542 ptlSTAClient->tlState = WLANTL_STA_INIT;
11543 ptlSTAClient->tlPri = WLANTL_STA_PRI_NORMAL;
11544
11545 vos_zero_macaddr( &ptlSTAClient->wSTADesc.vSTAMACAddress );
11546 vos_zero_macaddr( &ptlSTAClient->wSTADesc.vBSSIDforIBSS );
11547 vos_zero_macaddr( &ptlSTAClient->wSTADesc.vSelfMACAddress );
11548
11549 ptlSTAClient->wSTADesc.ucSTAId = 0;
11550 ptlSTAClient->wSTADesc.wSTAType = WLAN_STA_MAX;
11551
11552 ptlSTAClient->wSTADesc.ucQosEnabled = 0;
11553 ptlSTAClient->wSTADesc.ucAddRmvLLC = 0;
11554 ptlSTAClient->wSTADesc.ucSwFrameTXXlation = 0;
11555 ptlSTAClient->wSTADesc.ucSwFrameRXXlation = 0;
11556 ptlSTAClient->wSTADesc.ucProtectedFrame = 0;
11557
Nirav Shah4f765af2015-01-21 19:51:30 +053011558 ptlSTAClient->pfnSTAUlaComplete = NULL;
11559 ptlSTAClient->pUlaCBCtx = NULL;
11560 ptlSTAClient->isEapolM4Transmitted = 0;
11561
Jeff Johnson295189b2012-06-20 16:38:30 -070011562 /*-------------------------------------------------------------------------
11563 AMSDU information for the STA
11564 -------------------------------------------------------------------------*/
11565 if ( ( 0 != ucEmpty ) &&
11566 ( NULL != ptlSTAClient->vosAMSDUChainRoot ))
11567 {
Madan Mohan Koyyalamudic0e5bd82012-09-18 17:12:27 -070011568 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_FATAL,
Jeff Johnson0298bd02013-11-14 19:58:38 -080011569 "WLAN TL:Non NULL vosAMSDUChainRoot on WLANTL_CleanSTA, "
Madan Mohan Koyyalamudic0e5bd82012-09-18 17:12:27 -070011570 "suspecting a memory corruption"));
11571
Jeff Johnson295189b2012-06-20 16:38:30 -070011572 }
11573
11574 ptlSTAClient->vosAMSDUChain = NULL;
11575 ptlSTAClient->vosAMSDUChainRoot = NULL;
11576
11577 vos_mem_zero( (v_PVOID_t)ptlSTAClient->aucMPDUHeader,
11578 WLANTL_MPDU_HEADER_LEN);
11579 ptlSTAClient->ucMPDUHeaderLen = 0;
11580
11581 /*-------------------------------------------------------------------------
11582 Reordering information for the STA
11583 -------------------------------------------------------------------------*/
11584 for ( ucIndex = 0; ucIndex < WLAN_MAX_TID ; ucIndex++)
11585 {
11586 if(0 == ptlSTAClient->atlBAReorderInfo[ucIndex].ucExists)
11587 {
11588 continue;
11589 }
11590 if(NULL != ptlSTAClient->atlBAReorderInfo[ucIndex].reorderBuffer)
11591 {
11592 ptlSTAClient->atlBAReorderInfo[ucIndex].reorderBuffer->isAvailable = VOS_TRUE;
11593 memset(&ptlSTAClient->atlBAReorderInfo[ucIndex].reorderBuffer->arrayBuffer[0], 0, WLANTL_MAX_WINSIZE * sizeof(v_PVOID_t));
11594 }
11595 vos_timer_destroy(&ptlSTAClient->atlBAReorderInfo[ucIndex].agingTimer);
11596 memset(&ptlSTAClient->atlBAReorderInfo[ucIndex], 0, sizeof(WLANTL_BAReorderType));
11597 }
11598
11599 /*-------------------------------------------------------------------------
11600 QOS information for the STA
11601 -------------------------------------------------------------------------*/
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +053011602 ptlSTAClient->ucCurrentAC = WLANTL_AC_HIGH_PRIO;
Jeff Johnson295189b2012-06-20 16:38:30 -070011603 ptlSTAClient->ucCurrentWeight = 0;
11604 ptlSTAClient->ucServicedAC = WLANTL_AC_BK;
11605
11606 vos_mem_zero( ptlSTAClient->aucACMask, sizeof(ptlSTAClient->aucACMask));
11607 vos_mem_zero( &ptlSTAClient->wUAPSDInfo, sizeof(ptlSTAClient->wUAPSDInfo));
11608
11609
11610 /*--------------------------------------------------------------------
11611 Stats info
11612 --------------------------------------------------------------------*/
11613 vos_mem_zero( ptlSTAClient->auRxCount,
11614 sizeof(ptlSTAClient->auRxCount[0])* WLAN_MAX_TID);
11615 vos_mem_zero( ptlSTAClient->auTxCount,
11616 sizeof(ptlSTAClient->auTxCount[0])* WLAN_MAX_TID);
11617 ptlSTAClient->rssiAvg = 0;
11618
11619 /*Tx not suspended and station fully registered*/
11620 vos_atomic_set_U8( &ptlSTAClient->ucTxSuspended, 0);
11621 vos_atomic_set_U8( &ptlSTAClient->ucNoMoreData, 1);
11622
11623 if ( 0 == ucEmpty )
11624 {
11625 ptlSTAClient->wSTADesc.ucUcastSig = WLAN_TL_INVALID_U_SIG;
11626 ptlSTAClient->wSTADesc.ucBcastSig = WLAN_TL_INVALID_B_SIG;
11627 }
11628
11629 ptlSTAClient->ucExists = 0;
11630
11631 /*--------------------------------------------------------------------
11632 Statistics info
11633 --------------------------------------------------------------------*/
11634 memset(&ptlSTAClient->trafficStatistics,
11635 0,
11636 sizeof(WLANTL_TRANSFER_STA_TYPE));
11637
11638 /*fix me!!: add new values from the TL Cb for cleanup */
11639 return VOS_STATUS_SUCCESS;
11640}/* WLANTL_CleanSTA */
11641
11642
11643/*==========================================================================
11644 FUNCTION WLANTL_EnableUAPSDForAC
11645
11646 DESCRIPTION
11647 Called by HDD to enable UAPSD. TL in turn calls WDA API to enable the
11648 logic in FW/SLM to start sending trigger frames. Previously TL had the
11649 trigger frame logic which later moved down to FW. Hence
11650 HDD -> TL -> WDA -> FW call flow.
11651
11652 DEPENDENCIES
11653 The TL must be initialized before this function can be called.
11654
11655 PARAMETERS
11656
11657 IN
11658 pvosGCtx: pointer to the global vos context; a handle to TL's
11659 control block can be extracted from its context
11660 ucSTAId: station Id
11661 ucAC: AC for which U-APSD is being enabled
11662 ucTid: TID for which U-APSD is setup
11663 ucUP: used to place in the trigger frame generation
11664 ucServiceInt: service interval used by TL to send trigger frames
11665 ucSuspendInt: suspend interval used by TL to determine that an
11666 app is idle and should start sending trigg frms less often
11667 wTSDir: direction of TSpec
11668
11669 RETURN VALUE
11670 The result code associated with performing the operation
11671
11672 VOS_STATUS_SUCCESS: Everything is good :)
11673
11674 SIDE EFFECTS
11675
11676============================================================================*/
11677VOS_STATUS
11678WLANTL_EnableUAPSDForAC
11679(
11680 v_PVOID_t pvosGCtx,
11681 v_U8_t ucSTAId,
11682 WLANTL_ACEnumType ucAC,
11683 v_U8_t ucTid,
11684 v_U8_t ucUP,
11685 v_U32_t uServiceInt,
11686 v_U32_t uSuspendInt,
11687 WLANTL_TSDirType wTSDir
11688)
11689{
11690
11691 WLANTL_CbType* pTLCb = NULL;
11692 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
11693 tUapsdInfo halUAPSDInfo;
11694 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
11695
11696 /*------------------------------------------------------------------------
11697 Sanity check
11698 Extract TL control block
11699 ------------------------------------------------------------------------*/
11700 pTLCb = VOS_GET_TL_CB(pvosGCtx);
11701 if (( NULL == pTLCb ) || WLANTL_STA_ID_INVALID( ucSTAId )
Gopichand Nakkala574f6d12013-06-27 19:38:43 +053011702 || WLANTL_AC_INVALID(ucAC))
Jeff Johnson295189b2012-06-20 16:38:30 -070011703 {
11704 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11705 "WLAN TL:Invalid input params on WLANTL_EnableUAPSDForAC"
Gopichand Nakkala574f6d12013-06-27 19:38:43 +053011706 " TL: %p STA: %d AC: %d",
11707 pTLCb, ucSTAId, ucAC));
Jeff Johnson295189b2012-06-20 16:38:30 -070011708 return VOS_STATUS_E_FAULT;
11709 }
11710
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053011711 if ( NULL == pTLCb->atlSTAClients[ucSTAId] )
11712 {
11713 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11714 "WLAN TL:Client Memory was not allocated on %s", __func__));
11715 return VOS_STATUS_E_FAILURE;
11716 }
11717
Jeff Johnson295189b2012-06-20 16:38:30 -070011718 /*Set this flag in order to remember that this is a trigger enabled AC*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053011719 pTLCb->atlSTAClients[ucSTAId]->wUAPSDInfo[ucAC].ucSet = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -070011720
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053011721#ifdef FEATURE_WLAN_TDLS
11722 if(pTLCb->atlSTAClients[ucSTAId]->wSTADesc.wSTAType != WLAN_STA_TDLS)
11723#endif
11724 {
11725 if( 0 == uServiceInt )
11726 {
11727 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi198ade32013-09-29 03:52:25 +053011728 "WLAN TL:Input params on WLANTL_EnableUAPSDForAC"
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053011729 " SI: %d", uServiceInt ));
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053011730 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011731
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053011732 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
11733 "WLAN TL:Enabling U-APSD in FW for STA: %d AC: %d SI: %d SPI: %d "
11734 "DI: %d",
11735 ucSTAId, ucAC, uServiceInt, uSuspendInt,
11736 pTLCb->tlConfigInfo.uDelayedTriggerFrmInt));
Jeff Johnson295189b2012-06-20 16:38:30 -070011737
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053011738 /*Save all info for HAL*/
11739 halUAPSDInfo.staidx = ucSTAId;
11740 halUAPSDInfo.ac = ucAC;
11741 halUAPSDInfo.up = ucUP;
11742 halUAPSDInfo.srvInterval = uServiceInt;
11743 halUAPSDInfo.susInterval = uSuspendInt;
11744 halUAPSDInfo.delayInterval = pTLCb->tlConfigInfo.uDelayedTriggerFrmInt;
11745
11746 /*Notify HAL*/
11747 vosStatus = WDA_EnableUapsdAcParams(pvosGCtx, ucSTAId, &halUAPSDInfo);
11748 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011749 return vosStatus;
11750
11751}/*WLANTL_EnableUAPSDForAC*/
11752
11753
11754/*==========================================================================
11755 FUNCTION WLANTL_DisableUAPSDForAC
11756
11757 DESCRIPTION
11758 Called by HDD to disable UAPSD. TL in turn calls WDA API to disable the
11759 logic in FW/SLM to stop sending trigger frames. Previously TL had the
11760 trigger frame logic which later moved down to FW. Hence
11761 HDD -> TL -> WDA -> FW call flow.
11762
11763 DEPENDENCIES
11764 The TL must be initialized before this function can be called.
11765
11766 PARAMETERS
11767
11768 IN
11769 pvosGCtx: pointer to the global vos context; a handle to TL's
11770 control block can be extracted from its context
11771 ucSTAId: station Id
11772 ucAC: AC for which U-APSD is being enabled
11773
11774
11775 RETURN VALUE
11776 The result code associated with performing the operation
11777
11778 VOS_STATUS_SUCCESS: Everything is good :)
11779
11780 SIDE EFFECTS
11781
11782============================================================================*/
11783VOS_STATUS
11784WLANTL_DisableUAPSDForAC
11785(
11786 v_PVOID_t pvosGCtx,
11787 v_U8_t ucSTAId,
11788 WLANTL_ACEnumType ucAC
11789)
11790{
11791 WLANTL_CbType* pTLCb;
11792 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
11793
11794 /*------------------------------------------------------------------------
11795 Sanity check
11796 Extract TL control block
11797 ------------------------------------------------------------------------*/
11798 pTLCb = VOS_GET_TL_CB(pvosGCtx);
11799 if (( NULL == pTLCb ) || WLANTL_STA_ID_INVALID( ucSTAId )
11800 || WLANTL_AC_INVALID(ucAC) )
11801 {
11802 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11803 "WLAN TL:Invalid input params on WLANTL_DisableUAPSDForAC"
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +053011804 " TL: %p STA: %d AC: %d", pTLCb, ucSTAId, ucAC ));
Jeff Johnson295189b2012-06-20 16:38:30 -070011805 return VOS_STATUS_E_FAULT;
11806 }
11807
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053011808 if ( NULL == pTLCb->atlSTAClients[ucSTAId] )
11809 {
11810 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11811 "WLAN TL:Client Memory was not allocated on %s", __func__));
11812 return VOS_STATUS_E_FAILURE;
11813 }
11814
Jeff Johnson295189b2012-06-20 16:38:30 -070011815 /*Reset this flag as this is no longer a trigger enabled AC*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053011816 pTLCb->atlSTAClients[ucSTAId]->wUAPSDInfo[ucAC].ucSet = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -070011817
11818 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
11819 "WLAN TL:Disabling U-APSD in FW for STA: %d AC: %d ",
11820 ucSTAId, ucAC));
11821
11822 /*Notify HAL*/
11823 WDA_DisableUapsdAcParams(pvosGCtx, ucSTAId, ucAC);
11824
11825 return VOS_STATUS_SUCCESS;
11826}/* WLANTL_DisableUAPSDForAC */
11827
11828#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
11829/*==========================================================================
11830 FUNCTION WLANTL_RegRSSIIndicationCB
11831
11832 DESCRIPTION Registration function to get notification if RSSI cross
11833 threshold.
11834 Client should register threshold, direction, and notification
11835 callback function pointer
11836
11837 DEPENDENCIES NONE
11838
11839 PARAMETERS in pAdapter - Global handle
11840 in rssiValue - RSSI threshold value
11841 in triggerEvent - Cross direction should be notified
11842 UP, DOWN, and CROSS
11843 in crossCBFunction - Notification CB Function
11844 in usrCtxt - user context
11845
11846 RETURN VALUE VOS_STATUS
11847
11848 SIDE EFFECTS NONE
11849
11850============================================================================*/
11851VOS_STATUS WLANTL_RegRSSIIndicationCB
11852(
11853 v_PVOID_t pAdapter,
11854 v_S7_t rssiValue,
11855 v_U8_t triggerEvent,
11856 WLANTL_RSSICrossThresholdCBType crossCBFunction,
11857 VOS_MODULE_ID moduleID,
11858 v_PVOID_t usrCtxt
11859)
11860{
11861 VOS_STATUS status = VOS_STATUS_SUCCESS;
11862
11863 status = WLANTL_HSRegRSSIIndicationCB(pAdapter,
11864 rssiValue,
11865 triggerEvent,
11866 crossCBFunction,
11867 moduleID,
11868 usrCtxt);
11869
11870 return status;
11871}
11872
11873/*==========================================================================
11874 FUNCTION WLANTL_DeregRSSIIndicationCB
11875
11876 DESCRIPTION Remove specific threshold from list
11877
11878 DEPENDENCIES NONE
11879
11880 PARAMETERS in pAdapter - Global handle
11881 in rssiValue - RSSI threshold value
11882 in triggerEvent - Cross direction should be notified
11883 UP, DOWN, and CROSS
11884
11885 RETURN VALUE VOS_STATUS
11886
11887 SIDE EFFECTS NONE
11888
11889============================================================================*/
11890VOS_STATUS WLANTL_DeregRSSIIndicationCB
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)
11898{
11899 VOS_STATUS status = VOS_STATUS_SUCCESS;
11900
11901 status = WLANTL_HSDeregRSSIIndicationCB(pAdapter,
11902 rssiValue,
11903 triggerEvent,
11904 crossCBFunction,
11905 moduleID);
11906 return status;
11907}
11908
11909/*==========================================================================
11910 FUNCTION WLANTL_SetAlpha
11911
11912 DESCRIPTION ALPLA is weight value to calculate AVG RSSI
11913 avgRSSI = (ALPHA * historyRSSI) + ((10 - ALPHA) * newRSSI)
11914 avgRSSI has (ALPHA * 10)% of history RSSI weight and
11915 (10 - ALPHA)% of newRSSI weight
11916 This portion is dynamically configurable.
11917 Default is ?
11918
11919 DEPENDENCIES NONE
11920
11921 PARAMETERS in pAdapter - Global handle
11922 in valueAlpah - ALPHA
11923
11924 RETURN VALUE VOS_STATUS
11925
11926 SIDE EFFECTS NONE
11927
11928============================================================================*/
11929VOS_STATUS WLANTL_SetAlpha
11930(
11931 v_PVOID_t pAdapter,
11932 v_U8_t valueAlpha
11933)
11934{
11935 VOS_STATUS status = VOS_STATUS_SUCCESS;
11936
11937 status = WLANTL_HSSetAlpha(pAdapter, valueAlpha);
11938 return status;
11939}
11940
11941/*==========================================================================
11942
11943 FUNCTION
11944
11945 DESCRIPTION
11946
11947 PARAMETERS
11948
11949 RETURN VALUE
11950
11951============================================================================*/
11952VOS_STATUS WLANTL_BMPSRSSIRegionChangedNotification
11953(
11954 v_PVOID_t pAdapter,
11955 tpSirRSSINotification pRSSINotification
11956)
11957{
11958 VOS_STATUS status = VOS_STATUS_SUCCESS;
11959
11960 status = WLANTL_HSBMPSRSSIRegionChangedNotification(pAdapter, pRSSINotification);
11961 return status;
11962}
11963
11964/*==========================================================================
11965 FUNCTION WLANTL_RegGetTrafficStatus
11966
11967 DESCRIPTION Registration function for traffic status monitoring
11968 During measure period count data frames.
11969 If frame count is larger then IDLE threshold set as traffic ON
11970 or OFF.
11971 And traffic status is changed send report to client with
11972 registered callback function
11973
11974 DEPENDENCIES NONE
11975
11976 PARAMETERS in pAdapter - Global handle
11977 in idleThreshold - Traffic on or off threshold
11978 in measurePeriod - Traffic state check period
11979 in trfficStatusCB - traffic status changed notification
11980 CB function
11981 in usrCtxt - user context
11982
11983 RETURN VALUE VOS_STATUS
11984
11985 SIDE EFFECTS NONE
11986
11987============================================================================*/
11988VOS_STATUS WLANTL_RegGetTrafficStatus
11989(
11990 v_PVOID_t pAdapter,
11991 v_U32_t idleThreshold,
11992 v_U32_t measurePeriod,
11993 WLANTL_TrafficStatusChangedCBType trfficStatusCB,
11994 v_PVOID_t usrCtxt
11995)
11996{
11997 VOS_STATUS status = VOS_STATUS_SUCCESS;
11998
11999 status = WLANTL_HSRegGetTrafficStatus(pAdapter,
12000 idleThreshold,
12001 measurePeriod,
12002 trfficStatusCB,
12003 usrCtxt);
12004 return status;
12005}
12006#endif
12007/*==========================================================================
12008 FUNCTION WLANTL_GetStatistics
12009
12010 DESCRIPTION Get traffic statistics for identified station
12011
12012 DEPENDENCIES NONE
12013
12014 PARAMETERS in pAdapter - Global handle
12015 in statType - specific statistics field to reset
12016 out statBuffer - traffic statistics buffer
12017
12018 RETURN VALUE VOS_STATUS
12019
12020 SIDE EFFECTS NONE
12021
12022============================================================================*/
12023VOS_STATUS WLANTL_GetStatistics
12024(
12025 v_PVOID_t pAdapter,
12026 WLANTL_TRANSFER_STA_TYPE *statBuffer,
12027 v_U8_t STAid
12028)
12029{
12030 WLANTL_CbType *pTLCb = VOS_GET_TL_CB(pAdapter);
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053012031 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070012032 VOS_STATUS status = VOS_STATUS_SUCCESS;
12033 WLANTL_TRANSFER_STA_TYPE *statistics = NULL;
12034
12035 /*------------------------------------------------------------------------
12036 Sanity check
12037 Extract TL control block
12038 ------------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053012039 if ( NULL == pTLCb )
Jeff Johnson295189b2012-06-20 16:38:30 -070012040 {
12041 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
12042 "WLAN TL:Invalid TL pointer on WLANTL_GetStatistics"));
12043 return VOS_STATUS_E_FAULT;
12044 }
12045
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053012046 pClientSTA = pTLCb->atlSTAClients[STAid];
12047
12048 if ( NULL == pClientSTA )
12049 {
12050 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
12051 "WLAN TL:Client Memory was not allocated on %s", __func__));
12052 return VOS_STATUS_E_FAILURE;
12053 }
12054
12055 if(0 == pClientSTA->ucExists)
Jeff Johnson295189b2012-06-20 16:38:30 -070012056 {
12057 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
12058 "WLAN TL: %d STA ID does not exist", STAid));
12059 return VOS_STATUS_E_INVAL;
12060 }
12061
12062 if(NULL == statBuffer)
12063 {
12064 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
12065 "WLAN TL:Invalid TL statistics buffer pointer on WLANTL_GetStatistics"));
12066 return VOS_STATUS_E_INVAL;
12067 }
12068
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053012069 statistics = &pClientSTA->trafficStatistics;
Katya Nigam493ff652014-02-11 14:31:04 +053012070 vos_mem_copy(statBuffer, statistics, sizeof(WLANTL_TRANSFER_STA_TYPE));
Jeff Johnson295189b2012-06-20 16:38:30 -070012071
12072 return status;
12073}
12074
12075/*==========================================================================
12076 FUNCTION WLANTL_ResetStatistics
12077
12078 DESCRIPTION Reset statistics structure for identified station ID
12079 Reset means set values as 0
12080
12081 DEPENDENCIES NONE
12082
12083 PARAMETERS in pAdapter - Global handle
12084 in statType - specific statistics field to reset
12085
12086 RETURN VALUE VOS_STATUS
12087
12088 SIDE EFFECTS NONE
12089
12090============================================================================*/
12091VOS_STATUS WLANTL_ResetStatistics
12092(
12093 v_PVOID_t pAdapter,
12094 v_U8_t STAid
12095)
12096{
12097 WLANTL_CbType *pTLCb = VOS_GET_TL_CB(pAdapter);
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053012098 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070012099 VOS_STATUS status = VOS_STATUS_SUCCESS;
12100 WLANTL_TRANSFER_STA_TYPE *statistics = NULL;
12101
12102 /*------------------------------------------------------------------------
12103 Sanity check
12104 Extract TL control block
12105 ------------------------------------------------------------------------*/
12106 if (NULL == pTLCb)
12107 {
12108 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
12109 "WLAN TL:Invalid TL pointer on WLANTL_GetStatistics"));
12110 return VOS_STATUS_E_FAULT;
12111 }
12112
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053012113 pClientSTA = pTLCb->atlSTAClients[STAid];
12114
12115 if ( NULL == pClientSTA )
12116 {
12117 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
12118 "WLAN TL:Client Memory was not allocated on %s", __func__));
12119 return VOS_STATUS_E_FAILURE;
12120 }
12121
12122 if(0 == pClientSTA->ucExists)
Jeff Johnson295189b2012-06-20 16:38:30 -070012123 {
12124 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
12125 "WLAN TL: %d STA ID does not exist", STAid));
12126 return VOS_STATUS_E_INVAL;
12127 }
12128
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053012129 statistics = &pClientSTA->trafficStatistics;
Jeff Johnson295189b2012-06-20 16:38:30 -070012130 vos_mem_zero((v_VOID_t *)statistics, sizeof(WLANTL_TRANSFER_STA_TYPE));
12131
12132 return status;
12133}
12134
12135/*==========================================================================
12136 FUNCTION WLANTL_GetSpecStatistic
12137
12138 DESCRIPTION Get specific field within statistics structure for
12139 identified station ID
12140
12141 DEPENDENCIES NONE
12142
12143 PARAMETERS in pAdapter - Global handle
12144 in statType - specific statistics field to reset
12145 in STAid - Station ID
12146 out buffer - Statistic value
12147
12148 RETURN VALUE VOS_STATUS
12149
12150 SIDE EFFECTS NONE
12151
12152============================================================================*/
12153VOS_STATUS WLANTL_GetSpecStatistic
12154(
12155 v_PVOID_t pAdapter,
12156 WLANTL_TRANSFER_STATIC_TYPE statType,
12157 v_U32_t *buffer,
12158 v_U8_t STAid
12159)
12160{
12161 WLANTL_CbType *pTLCb = VOS_GET_TL_CB(pAdapter);
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053012162 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070012163 VOS_STATUS status = VOS_STATUS_SUCCESS;
12164 WLANTL_TRANSFER_STA_TYPE *statistics = NULL;
12165
12166 /*------------------------------------------------------------------------
12167 Sanity check
12168 Extract TL control block
12169 ------------------------------------------------------------------------*/
12170 if (NULL == pTLCb)
12171 {
12172 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
12173 "WLAN TL:Invalid TL pointer on WLANTL_GetStatistics"));
12174 return VOS_STATUS_E_FAULT;
12175 }
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053012176 pClientSTA = pTLCb->atlSTAClients[STAid];
Jeff Johnson295189b2012-06-20 16:38:30 -070012177
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053012178 if ( NULL == pClientSTA )
12179 {
12180 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
12181 "WLAN TL:Client Memory was not allocated on %s", __func__));
12182 return VOS_STATUS_E_FAILURE;
12183 }
12184
12185 if(0 == pClientSTA->ucExists)
Jeff Johnson295189b2012-06-20 16:38:30 -070012186 {
12187 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
12188 "WLAN TL: %d STA ID does not exist", STAid));
12189 return VOS_STATUS_E_INVAL;
12190 }
12191
12192 if(NULL == buffer)
12193 {
12194 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
12195 "WLAN TL:Invalid TL statistic buffer pointer on WLANTL_GetStatistics"));
12196 return VOS_STATUS_E_INVAL;
12197 }
12198
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053012199 statistics = &pClientSTA->trafficStatistics;
Jeff Johnson295189b2012-06-20 16:38:30 -070012200 switch(statType)
12201 {
12202 case WLANTL_STATIC_TX_UC_FCNT:
12203 *buffer = statistics->txUCFcnt;
12204 break;
12205
12206 case WLANTL_STATIC_TX_MC_FCNT:
12207 *buffer = statistics->txMCFcnt;
12208 break;
12209
12210 case WLANTL_STATIC_TX_BC_FCNT:
12211 *buffer = statistics->txBCFcnt;
12212 break;
12213
12214 case WLANTL_STATIC_TX_UC_BCNT:
12215 *buffer = statistics->txUCBcnt;
12216 break;
12217
12218 case WLANTL_STATIC_TX_MC_BCNT:
12219 *buffer = statistics->txMCBcnt;
12220 break;
12221
12222 case WLANTL_STATIC_TX_BC_BCNT:
12223 *buffer = statistics->txBCBcnt;
12224 break;
12225
12226 case WLANTL_STATIC_RX_UC_FCNT:
12227 *buffer = statistics->rxUCFcnt;
12228 break;
12229
12230 case WLANTL_STATIC_RX_MC_FCNT:
12231 *buffer = statistics->rxMCFcnt;
12232 break;
12233
12234 case WLANTL_STATIC_RX_BC_FCNT:
12235 *buffer = statistics->rxBCFcnt;
12236 break;
12237
12238 case WLANTL_STATIC_RX_UC_BCNT:
12239 *buffer = statistics->rxUCBcnt;
12240 break;
12241
12242 case WLANTL_STATIC_RX_MC_BCNT:
12243 *buffer = statistics->rxMCBcnt;
12244 break;
12245
12246 case WLANTL_STATIC_RX_BC_BCNT:
12247 *buffer = statistics->rxBCBcnt;
12248 break;
12249
12250 case WLANTL_STATIC_RX_BCNT:
12251 *buffer = statistics->rxBcnt;
12252 break;
12253
12254 case WLANTL_STATIC_RX_BCNT_CRC_OK:
12255 *buffer = statistics->rxBcntCRCok;
12256 break;
12257
12258 case WLANTL_STATIC_RX_RATE:
12259 *buffer = statistics->rxRate;
12260 break;
12261
12262 default:
12263 *buffer = 0;
12264 status = VOS_STATUS_E_INVAL;
12265 break;
12266 }
12267
12268
12269 return status;
12270}
12271
12272/*==========================================================================
12273 FUNCTION WLANTL_ResetSpecStatistic
12274
12275 DESCRIPTION Reset specific field within statistics structure for
12276 identified station ID
12277 Reset means set as 0
12278
12279 DEPENDENCIES NONE
12280
12281 PARAMETERS in pAdapter - Global handle
12282 in statType - specific statistics field to reset
12283 in STAid - Station ID
12284
12285 RETURN VALUE VOS_STATUS
12286
12287 SIDE EFFECTS NONE
12288
12289============================================================================*/
12290VOS_STATUS WLANTL_ResetSpecStatistic
12291(
12292 v_PVOID_t pAdapter,
12293 WLANTL_TRANSFER_STATIC_TYPE statType,
12294 v_U8_t STAid
12295)
12296{
12297 WLANTL_CbType *pTLCb = VOS_GET_TL_CB(pAdapter);
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053012298 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070012299 VOS_STATUS status = VOS_STATUS_SUCCESS;
12300 WLANTL_TRANSFER_STA_TYPE *statistics = NULL;
12301
12302 /*------------------------------------------------------------------------
12303 Sanity check
12304 Extract TL control block
12305 ------------------------------------------------------------------------*/
12306 if (NULL == pTLCb)
12307 {
12308 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
12309 "WLAN TL:Invalid TL pointer on WLANTL_GetStatistics"));
12310 return VOS_STATUS_E_FAULT;
12311 }
12312
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053012313 pClientSTA = pTLCb->atlSTAClients[STAid];
12314
12315 if ( NULL == pClientSTA )
12316 {
12317 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
12318 "WLAN TL:Client Memory was not allocated on %s", __func__));
12319 return VOS_STATUS_E_FAILURE;
12320 }
12321
12322 if(0 == pClientSTA->ucExists)
Jeff Johnson295189b2012-06-20 16:38:30 -070012323 {
12324 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
12325 "WLAN TL: %d STA ID does not exist", STAid));
12326 return VOS_STATUS_E_INVAL;
12327 }
12328
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053012329 statistics = &pClientSTA->trafficStatistics;
Jeff Johnson295189b2012-06-20 16:38:30 -070012330 switch(statType)
12331 {
12332 case WLANTL_STATIC_TX_UC_FCNT:
12333 statistics->txUCFcnt = 0;
12334 break;
12335
12336 case WLANTL_STATIC_TX_MC_FCNT:
12337 statistics->txMCFcnt = 0;
12338 break;
12339
12340 case WLANTL_STATIC_TX_BC_FCNT:
12341 statistics->txBCFcnt = 0;
12342 break;
12343
12344 case WLANTL_STATIC_TX_UC_BCNT:
12345 statistics->txUCBcnt = 0;
12346 break;
12347
12348 case WLANTL_STATIC_TX_MC_BCNT:
12349 statistics->txMCBcnt = 0;
12350 break;
12351
12352 case WLANTL_STATIC_TX_BC_BCNT:
12353 statistics->txBCBcnt = 0;
12354 break;
12355
12356 case WLANTL_STATIC_RX_UC_FCNT:
12357 statistics->rxUCFcnt = 0;
12358 break;
12359
12360 case WLANTL_STATIC_RX_MC_FCNT:
12361 statistics->rxMCFcnt = 0;
12362 break;
12363
12364 case WLANTL_STATIC_RX_BC_FCNT:
12365 statistics->rxBCFcnt = 0;
12366 break;
12367
12368 case WLANTL_STATIC_RX_UC_BCNT:
12369 statistics->rxUCBcnt = 0;
12370 break;
12371
12372 case WLANTL_STATIC_RX_MC_BCNT:
12373 statistics->rxMCBcnt = 0;
12374 break;
12375
12376 case WLANTL_STATIC_RX_BC_BCNT:
12377 statistics->rxBCBcnt = 0;
12378 break;
12379
12380 case WLANTL_STATIC_RX_BCNT:
12381 statistics->rxBcnt = 0;
12382 break;
12383
12384 case WLANTL_STATIC_RX_BCNT_CRC_OK:
12385 statistics->rxBcntCRCok = 0;
12386 break;
12387
12388 case WLANTL_STATIC_RX_RATE:
12389 statistics->rxRate = 0;
12390 break;
12391
12392 default:
12393 status = VOS_STATUS_E_INVAL;
12394 break;
12395 }
12396
12397 return status;
12398}
12399
12400
12401/*==========================================================================
12402
12403 FUNCTION
12404
12405 DESCRIPTION Read RSSI value out of a RX BD
12406
12407 PARAMETERS: Caller must validate all parameters
12408
12409 RETURN VALUE
12410
12411============================================================================*/
12412VOS_STATUS WLANTL_ReadRSSI
12413(
12414 v_PVOID_t pAdapter,
12415 v_PVOID_t pBDHeader,
12416 v_U8_t STAid
12417)
12418{
12419 WLANTL_CbType *tlCtxt = VOS_GET_TL_CB(pAdapter);
12420 v_S7_t currentRSSI, currentRSSI0, currentRSSI1;
12421
12422
12423 if(NULL == tlCtxt)
12424 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070012425 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR, "%s Invalid TL handle", __func__));
Jeff Johnson295189b2012-06-20 16:38:30 -070012426 return VOS_STATUS_E_INVAL;
12427 }
12428
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053012429 if ( NULL == tlCtxt->atlSTAClients[STAid] )
12430 {
12431 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
12432 "WLAN TL:Client Memory was not allocated on %s", __func__));
12433 return VOS_STATUS_E_FAILURE;
12434 }
12435
Jeff Johnson295189b2012-06-20 16:38:30 -070012436 currentRSSI0 = WLANTL_GETRSSI0(pBDHeader);
12437 currentRSSI1 = WLANTL_GETRSSI1(pBDHeader);
12438 currentRSSI = (currentRSSI0 > currentRSSI1) ? currentRSSI0 : currentRSSI1;
12439
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053012440 tlCtxt->atlSTAClients[STAid]->rssiAvg = currentRSSI;
Jeff Johnson295189b2012-06-20 16:38:30 -070012441
12442 return VOS_STATUS_SUCCESS;
12443}
12444
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053012445/*==========================================================================
12446
12447 FUNCTION
12448
12449 DESCRIPTION Read SNR value out of a RX BD
12450
12451 PARAMETERS: Caller must validate all parameters
12452
12453 RETURN VALUE
12454
12455============================================================================*/
12456VOS_STATUS WLANTL_ReadSNR
12457(
12458 v_PVOID_t pAdapter,
12459 v_PVOID_t pBDHeader,
12460 v_U8_t STAid
12461)
12462{
12463 WLANTL_CbType *tlCtxt = VOS_GET_TL_CB(pAdapter);
12464 v_S7_t currentSNR;
12465
12466
12467 if (NULL == tlCtxt)
12468 {
12469 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
12470 "%s Invalid TL handle", __func__));
12471 return VOS_STATUS_E_INVAL;
12472 }
12473
12474 if (NULL == tlCtxt->atlSTAClients[STAid])
12475 {
12476 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
12477 "WLAN TL:Client Memory was not allocated on %s", __func__));
12478 return VOS_STATUS_E_FAILURE;
12479 }
12480
12481 currentSNR = WLANTL_GETSNR(pBDHeader);
12482
Madan Mohan Koyyalamudi43acf032013-09-27 04:33:28 +053012483 /* SNR reported in the Buffer Descriptor is scaled up by 2(SNR*2),
12484 * Get the correct SNR value
12485 */
12486 currentSNR = currentSNR >> 1;
12487
12488 /* SNR reported by HW cannot be more than 35dB due to HW limitations */
12489 currentSNR = (WLANTL_MAX_HW_SNR > currentSNR ? currentSNR :
12490 WLANTL_MAX_HW_SNR);
12491
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053012492 TLLOG2(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
12493 "%s: snrsum: %d snridx: %d prevsnravg: %d",
12494 __func__,
12495 tlCtxt->atlSTAClients[STAid]->snrSum,
12496 tlCtxt->atlSTAClients[STAid]->snrIdx,
12497 tlCtxt->atlSTAClients[STAid]->prevSnrAvg));
12498
12499 /* The SNR returned for all purposes is the average SNR over
12500 * WLANTL_MAX_SNR_DATA_SMAPLES.When data samples
12501 * > WLANTL_MAX_SNR_DATA_SAMPLES are obtained,
12502 * store the average of the samples in prevSnrAvg
12503 * and start a new averaging window. The prevSnrAvg is used when
12504 * enough data samples are not available when applications
12505 * actually query for SNR.
12506 *
12507 * SEE: WLANTL_GetSnr()
12508 */
12509 if (tlCtxt->atlSTAClients[STAid]->snrIdx >= WLANTL_MAX_SNR_DATA_SAMPLES)
12510 {
12511 tlCtxt->atlSTAClients[STAid]->prevSnrAvg =
12512 tlCtxt->atlSTAClients[STAid]->snrSum /
12513 tlCtxt->atlSTAClients[STAid]->snrIdx;
12514 tlCtxt->atlSTAClients[STAid]->snrSum = 0;
12515 tlCtxt->atlSTAClients[STAid]->snrIdx = 0;
12516 }
12517 tlCtxt->atlSTAClients[STAid]->snrSum += currentSNR;
12518 tlCtxt->atlSTAClients[STAid]->snrIdx += 1;
12519
12520 return VOS_STATUS_SUCCESS;
12521}
Jeff Johnson295189b2012-06-20 16:38:30 -070012522
12523/*
12524 DESCRIPTION
12525 TL returns the weight currently maintained in TL.
12526 IN
12527 pvosGCtx: pointer to the global vos context; a handle to TL's
12528 or SME's control block can be extracted from its context
12529
12530 OUT
12531 pACWeights: Caller allocated memory for filling in weights
12532
12533 RETURN VALUE VOS_STATUS
12534*/
12535VOS_STATUS
12536WLANTL_GetACWeights
12537(
12538 v_PVOID_t pvosGCtx,
12539 v_U8_t* pACWeights
12540)
12541{
12542 WLANTL_CbType* pTLCb = NULL;
12543 v_U8_t ucIndex;
12544 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
12545
12546 /*------------------------------------------------------------------------
12547 Sanity check
12548 ------------------------------------------------------------------------*/
12549 if ( NULL == pACWeights )
12550 {
12551 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
12552 "WLAN TL:Invalid parameter sent on WLANTL_GetACWeights"));
12553 return VOS_STATUS_E_INVAL;
12554 }
12555
12556 /*------------------------------------------------------------------------
12557 Extract TL control block and check existance
12558 ------------------------------------------------------------------------*/
12559 pTLCb = VOS_GET_TL_CB(pvosGCtx);
12560 if ( NULL == pTLCb )
12561 {
12562 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
12563 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_GetACWeights"));
12564 return VOS_STATUS_E_FAULT;
12565 }
12566 for ( ucIndex = 0; ucIndex < WLANTL_MAX_AC ; ucIndex++)
12567 {
12568 pACWeights[ucIndex] = pTLCb->tlConfigInfo.ucAcWeights[ucIndex];
12569 }
12570
12571 return VOS_STATUS_SUCCESS;
12572}
12573
12574
12575
12576/*
12577 DESCRIPTION
12578 Change the weight currently maintained by TL.
12579 IN
12580 pvosGCtx: pointer to the global vos context; a handle to TL's
12581 or SME's control block can be extracted from its context
12582 pACWeights: Caller allocated memory contain the weights to use
12583
12584
12585 RETURN VALUE VOS_STATUS
12586*/
12587VOS_STATUS
12588WLANTL_SetACWeights
12589(
12590 v_PVOID_t pvosGCtx,
12591 v_U8_t* pACWeights
12592)
12593{
12594 WLANTL_CbType* pTLCb = NULL;
12595 v_U8_t ucIndex;
12596 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
12597
12598 /*------------------------------------------------------------------------
12599 Sanity check
12600 ------------------------------------------------------------------------*/
12601 if ( NULL == pACWeights )
12602 {
12603 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
12604 "WLAN TL:Invalid parameter sent on WLANTL_GetACWeights"));
12605 return VOS_STATUS_E_INVAL;
12606 }
12607
12608 /*------------------------------------------------------------------------
12609 Extract TL control block and check existance
12610 ------------------------------------------------------------------------*/
12611 pTLCb = VOS_GET_TL_CB(pvosGCtx);
12612 if ( NULL == pTLCb )
12613 {
12614 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
12615 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_GetACWeights"));
12616 return VOS_STATUS_E_FAULT;
12617 }
12618 for ( ucIndex = 0; ucIndex < WLANTL_MAX_AC ; ucIndex++)
12619 {
12620 pTLCb->tlConfigInfo.ucAcWeights[ucIndex] = pACWeights[ucIndex];
12621 }
12622
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +053012623 pTLCb->tlConfigInfo.ucAcWeights[WLANTL_AC_HIGH_PRIO] = pACWeights[WLANTL_AC_VO];
Jeff Johnson295189b2012-06-20 16:38:30 -070012624 return VOS_STATUS_SUCCESS;
12625}
12626
12627
12628/*==========================================================================
12629
12630 FUNCTION
12631
12632 DESCRIPTION
12633
12634 PARAMETERS
12635
12636 RETURN VALUE
12637
12638============================================================================*/
12639void WLANTL_PowerStateChangedCB
12640(
12641 v_PVOID_t pAdapter,
12642 tPmcState newState
12643)
12644{
12645 WLANTL_CbType *tlCtxt = VOS_GET_TL_CB(pAdapter);
12646
12647 if (NULL == tlCtxt)
12648 {
12649 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +053012650 "%s: Invalid TL Control Block", __func__ );
Jeff Johnson295189b2012-06-20 16:38:30 -070012651 return;
12652 }
12653
12654 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO, "Power state changed, new state is %d", newState );
12655 switch(newState)
12656 {
12657 case FULL_POWER:
12658 tlCtxt->isBMPS = VOS_FALSE;
12659 break;
12660
12661 case BMPS:
12662#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
12663 WLANTL_SetFWRSSIThresholds(pAdapter);
12664#endif
12665
12666 tlCtxt->isBMPS = VOS_TRUE;
12667 break;
12668
12669 case IMPS:
12670 case LOW_POWER:
12671 case REQUEST_BMPS:
12672 case REQUEST_FULL_POWER:
12673 case REQUEST_IMPS:
12674 case STOPPED:
12675 case REQUEST_START_UAPSD:
12676 case REQUEST_STOP_UAPSD:
12677 case UAPSD:
12678 case REQUEST_STANDBY:
12679 case STANDBY:
12680 case REQUEST_ENTER_WOWL:
12681 case REQUEST_EXIT_WOWL:
12682 case WOWL:
12683 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN, "Not handle this events %d", newState ));
12684 break;
12685
12686 default:
12687 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR, "Not a valid event %d", newState ));
12688 break;
12689 }
12690
12691 return;
12692}
12693/*==========================================================================
12694 FUNCTION WLANTL_GetEtherType
12695
12696 DESCRIPTION Extract Ether type information from the BD
12697
12698 DEPENDENCIES NONE
12699
12700 PARAMETERS in aucBDHeader - BD header
12701 in vosDataBuff - data buffer
12702 in ucMPDUHLen - MPDU header length
12703 out pUsEtherType - pointer to Ethertype
12704
12705 RETURN VALUE VOS_STATUS_SUCCESS : if the EtherType is successfully extracted
12706 VOS_STATUS_FAILURE : if the EtherType extraction failed and
12707 the packet was dropped
12708
12709 SIDE EFFECTS NONE
12710
12711============================================================================*/
12712static VOS_STATUS WLANTL_GetEtherType
12713(
12714 v_U8_t * aucBDHeader,
12715 vos_pkt_t * vosDataBuff,
12716 v_U8_t ucMPDUHLen,
12717 v_U16_t * pUsEtherType
12718)
12719{
12720 v_U8_t ucOffset;
12721 v_U16_t usEtherType = *pUsEtherType;
12722 v_SIZE_t usLLCSize = sizeof(usEtherType);
12723 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
12724
12725 /*------------------------------------------------------------------------
12726 Check if LLC is present - if not, TL is unable to determine type
12727 ------------------------------------------------------------------------*/
12728 if ( VOS_FALSE == WDA_IS_RX_LLC_PRESENT( aucBDHeader ) )
12729 {
12730 ucOffset = WLANTL_802_3_HEADER_LEN - sizeof(usEtherType);
12731 }
12732 else
12733 {
12734 ucOffset = ucMPDUHLen + WLANTL_LLC_PROTO_TYPE_OFFSET;
12735 }
12736
12737 /*------------------------------------------------------------------------
12738 Extract LLC type
12739 ------------------------------------------------------------------------*/
12740 vosStatus = vos_pkt_extract_data( vosDataBuff, ucOffset,
12741 (v_PVOID_t)&usEtherType, &usLLCSize);
12742
12743 if (( VOS_STATUS_SUCCESS != vosStatus ) ||
12744 ( sizeof(usEtherType) != usLLCSize ))
12745
12746 {
12747 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
12748 "WLAN TL:Error extracting Ether type from data packet"));
12749 /* Drop packet */
12750 vos_pkt_return_packet(vosDataBuff);
12751 vosStatus = VOS_STATUS_E_FAILURE;
12752 }
12753 else
12754 {
12755 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
12756 "WLAN TL:Ether type retrieved before endianess conv: %d",
12757 usEtherType));
12758
12759 usEtherType = vos_be16_to_cpu(usEtherType);
12760 *pUsEtherType = usEtherType;
12761
12762 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
12763 "WLAN TL:Ether type retrieved: %d", usEtherType));
12764 }
12765
12766 return vosStatus;
12767}
12768
Jeff Johnson295189b2012-06-20 16:38:30 -070012769/*==========================================================================
12770 FUNCTION WLANTL_GetSoftAPStatistics
12771
12772 DESCRIPTION Collect the cumulative statistics for all Softap stations
12773
12774 DEPENDENCIES NONE
12775
12776 PARAMETERS in pvosGCtx - Pointer to the global vos context
12777 bReset - If set TL statistics will be cleared after reading
12778 out statsSum - pointer to collected statistics
12779
12780 RETURN VALUE VOS_STATUS_SUCCESS : if the Statistics are successfully extracted
12781
12782 SIDE EFFECTS NONE
12783
12784============================================================================*/
12785VOS_STATUS WLANTL_GetSoftAPStatistics(v_PVOID_t pAdapter, WLANTL_TRANSFER_STA_TYPE *statsSum, v_BOOL_t bReset)
12786{
12787 v_U8_t i = 0;
12788 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
12789 WLANTL_CbType *pTLCb = VOS_GET_TL_CB(pAdapter);
12790 WLANTL_TRANSFER_STA_TYPE statBufferTemp;
12791 vos_mem_zero((v_VOID_t *)&statBufferTemp, sizeof(WLANTL_TRANSFER_STA_TYPE));
12792 vos_mem_zero((v_VOID_t *)statsSum, sizeof(WLANTL_TRANSFER_STA_TYPE));
12793
12794
12795 if ( NULL == pTLCb )
12796 {
12797 return VOS_STATUS_E_FAULT;
12798 }
12799
12800 // Sum up all the statistics for stations of Soft AP from TL
12801 for (i = 0; i < WLAN_MAX_STA_COUNT; i++)
12802 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053012803 if ( NULL == pTLCb->atlSTAClients[i])
12804 {
12805 continue;
12806 }
12807 if (pTLCb->atlSTAClients[i]->wSTADesc.wSTAType == WLAN_STA_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -070012808 {
12809 vosStatus = WLANTL_GetStatistics(pAdapter, &statBufferTemp, i);// Can include staId 1 because statistics not collected for it
12810
12811 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
12812 return VOS_STATUS_E_FAULT;
12813
12814 // Add to the counters
12815 statsSum->txUCFcnt += statBufferTemp.txUCFcnt;
12816 statsSum->txMCFcnt += statBufferTemp.txMCFcnt;
12817 statsSum->txBCFcnt += statBufferTemp.txBCFcnt;
12818 statsSum->txUCBcnt += statBufferTemp.txUCBcnt;
12819 statsSum->txMCBcnt += statBufferTemp.txMCBcnt;
12820 statsSum->txBCBcnt += statBufferTemp.txBCBcnt;
12821 statsSum->rxUCFcnt += statBufferTemp.rxUCFcnt;
12822 statsSum->rxMCFcnt += statBufferTemp.rxMCFcnt;
12823 statsSum->rxBCFcnt += statBufferTemp.rxBCFcnt;
12824 statsSum->rxUCBcnt += statBufferTemp.rxUCBcnt;
12825 statsSum->rxMCBcnt += statBufferTemp.rxMCBcnt;
12826 statsSum->rxBCBcnt += statBufferTemp.rxBCBcnt;
12827
12828 if (bReset)
12829 {
12830 vosStatus = WLANTL_ResetStatistics(pAdapter, i);
12831 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
12832 return VOS_STATUS_E_FAULT;
12833 }
12834 }
12835 }
12836
12837 return vosStatus;
12838}
Mohit Khanna698ba2a2012-12-04 15:08:18 -080012839#ifdef FEATURE_WLAN_TDLS_INTERNAL
12840/*==========================================================================
12841 FUNCTION WLANTL_GetEtherType_2
12842
12843 DESCRIPTION Extract Ether type information from the BD
12844
12845 DEPENDENCIES NONE
12846
12847 PARAMETERS in aucBDHeader - BD header
12848 in vosDataBuff - data buffer
12849 in ucMPDUHLen - MPDU header length
12850 out pUsEtherType - pointer to Ethertype
12851
12852 RETURN VALUE VOS_STATUS_SUCCESS : if the EtherType is successfully extracted
12853 VOS_STATUS_FAILURE : if the EtherType extraction failed and
12854 the packet was dropped
12855
12856 SIDE EFFECTS NONE
12857
12858============================================================================*/
12859static VOS_STATUS WLANTL_GetEtherType_2
12860(
12861 v_U8_t * aucBDHeader,
12862 vos_pkt_t * vosDataBuff,
12863 v_U8_t ucMPDUHLen,
12864 v_U16_t * pUsEtherType
12865)
12866{
12867 v_U8_t ucOffset;
12868 v_U16_t usEtherType = *pUsEtherType;
12869 v_SIZE_t usLLCSize = sizeof(usEtherType);
12870 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
12871 //v_U8_t ucLLCHeader;
12872 v_U8_t ucMPDUHOffset ;
12873 /*------------------------------------------------------------------------
12874 Check if LLC is present - if not, TL is unable to determine type
12875 ------------------------------------------------------------------------*/
12876 //ucMPDUHOffset = (v_U8_t)WLANHAL_RX_BD_GET_MPDU_H_OFFSET(aucBDHeader) ;
12877 //ucLLCHeader = (v_U8_t)WLANHAL_RX_BD_GET_LLC(aucBDHeader);
12878 ucMPDUHOffset = (v_U8_t)WDA_GET_RX_MPDU_HEADER_OFFSET(aucBDHeader);
12879
12880 if ( VOS_TRUE == WDA_IS_RX_LLC_PRESENT(aucBDHeader) )
12881 {
12882 ucOffset = ucMPDUHOffset + WLANTL_802_3_HEADER_LEN - sizeof(usEtherType);
12883 }
12884 else
12885 {
12886 ucOffset = WLANHAL_RX_BD_HEADER_SIZE + ucMPDUHLen
12887 + WLANTL_LLC_PROTO_TYPE_OFFSET;
12888 }
12889
12890 /*------------------------------------------------------------------------
12891 Extract LLC type
12892 ------------------------------------------------------------------------*/
12893 vosStatus = vos_pkt_extract_data( vosDataBuff, ucOffset,
12894 (v_PVOID_t)&usEtherType, &usLLCSize);
12895
12896 /* TODO: Do it in better way */
12897 if(vos_be16_to_cpu(usEtherType) == 0x890d)
12898 {
12899 VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Arif Hussainf2b00992013-11-17 21:46:15 -080012900 ("TDLS frame llc %x"), vos_be16_to_cpu(usEtherType)) ;
Mohit Khanna698ba2a2012-12-04 15:08:18 -080012901 }
12902
12903 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
12904 "WLAN TL:Ether type retrieved before endianess conv: %d",
12905 usEtherType);
12906
12907 usEtherType = vos_be16_to_cpu(usEtherType);
12908 *pUsEtherType = usEtherType;
12909
12910 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
12911 "WLAN TL:Ether type retrieved: %d", usEtherType);
12912
12913 return vosStatus;
12914}
12915#endif /* FEATURE_WLAN_TDLS */
12916
Jeff Johnson295189b2012-06-20 16:38:30 -070012917/*===============================================================================
12918 FUNCTION WLANTL_IsReplayPacket
12919
12920 DESCRIPTION This function does replay check for valid stations
12921
12922 DEPENDENCIES Validity of replay check must be done before the function
12923 is called
12924
12925 PARAMETERS currentReplayCounter current replay counter taken from RX BD
12926 previousReplayCounter previous replay counter taken from TL CB
12927
12928 RETRUN VOS_TRUE packet is a replay packet
12929 VOS_FALSE packet is not a replay packet
12930
12931 SIDE EFFECTS none
12932 ===============================================================================*/
12933v_BOOL_t
12934WLANTL_IsReplayPacket
12935(
12936 v_U64_t ullcurrentReplayCounter,
12937 v_U64_t ullpreviousReplayCounter
12938)
12939{
12940 /* Do the replay check by comparing previous received replay counter with
12941 current received replay counter*/
12942 if(ullpreviousReplayCounter < ullcurrentReplayCounter)
12943 {
12944 /* Valid packet not replay */
12945 return VOS_FALSE;
12946 }
12947 else
12948 {
12949
12950 /* Current packet number is less than or equal to previuos received
12951 packet no, this means current packet is replay packet */
12952 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
12953 "WLAN TL: Replay packet found with replay counter :[0x%llX]",ullcurrentReplayCounter);
12954
12955 return VOS_TRUE;
12956 }
12957}
12958
12959#if 0
12960/*===============================================================================
12961 FUNCTION WLANTL_GetReplayCounterFromRxBD
12962
12963 DESCRIPTION This function extracts 48-bit replay packet number from RX BD
12964
12965 DEPENDENCIES Validity of replay check must be done before the function
12966 is called
12967
12968 PARAMETERS pucRxHeader pointer to RX BD header
12969
12970 RETRUN v_U64_t Packet number extarcted from RX BD
12971
12972 SIDE EFFECTS none
12973 ===============================================================================*/
12974v_U64_t
12975WLANTL_GetReplayCounterFromRxBD
12976(
12977 v_U8_t *pucRxBDHeader
12978)
12979{
12980/* 48-bit replay counter is created as follows
12981 from RX BD 6 byte PMI command:
12982 Addr : AES/TKIP
12983 0x38 : pn3/tsc3
12984 0x39 : pn2/tsc2
12985 0x3a : pn1/tsc1
12986 0x3b : pn0/tsc0
12987
12988 0x3c : pn5/tsc5
12989 0x3d : pn4/tsc4 */
12990
12991#ifdef ANI_BIG_BYTE_ENDIAN
12992 v_U64_t ullcurrentReplayCounter = 0;
12993 /* Getting 48-bit replay counter from the RX BD */
12994 ullcurrentReplayCounter = WLANHAL_RX_BD_GET_PMICMD_20TO23(pucRxBDHeader);
12995 ullcurrentReplayCounter <<= 16;
12996 ullcurrentReplayCounter |= (( WLANHAL_RX_BD_GET_PMICMD_24TO25(pucRxBDHeader) & 0xFFFF0000) >> 16);
12997 return ullcurrentReplayCounter;
12998#else
12999 v_U64_t ullcurrentReplayCounter = 0;
13000 /* Getting 48-bit replay counter from the RX BD */
13001 ullcurrentReplayCounter = (WLANHAL_RX_BD_GET_PMICMD_24TO25(pucRxBDHeader) & 0x0000FFFF);
13002 ullcurrentReplayCounter <<= 32;
13003 ullcurrentReplayCounter |= WLANHAL_RX_BD_GET_PMICMD_20TO23(pucRxBDHeader);
13004 return ullcurrentReplayCounter;
13005#endif
13006}
13007#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070013008
13009/*===============================================================================
13010 FUNCTION WLANTL_PostResNeeded
13011
13012 DESCRIPTION This function posts message to TL to reserve BD/PDU memory
13013
13014 DEPENDENCIES None
13015
13016 PARAMETERS pvosGCtx
13017
13018 RETURN None
13019
13020 SIDE EFFECTS none
13021 ===============================================================================*/
13022
13023void WLANTL_PostResNeeded(v_PVOID_t pvosGCtx)
13024{
13025 vos_msg_t vosMsg;
13026
13027 vosMsg.reserved = 0;
13028 vosMsg.bodyptr = NULL;
13029 vosMsg.type = WLANTL_TX_RES_NEEDED;
13030 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
13031 "WLAN TL: BD/PDU available interrupt received, Posting message to TL");
13032 if(!VOS_IS_STATUS_SUCCESS(vos_tx_mq_serialize( VOS_MQ_ID_TL, &vosMsg)))
13033 {
13034 VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070013035 " %s fails to post message", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070013036 }
13037}
13038
13039/*===============================================================================
13040 FUNCTION WLANTL_UpdateRssiBmps
13041
13042 DESCRIPTION This function updates the TL's RSSI (in BMPS mode)
13043
13044 DEPENDENCIES None
13045
13046 PARAMETERS
13047
13048 pvosGCtx VOS context VOS Global context
13049 staId Station ID Station ID
13050 rssi RSSI (BMPS mode) RSSI in BMPS mode
13051
13052 RETURN None
13053
13054 SIDE EFFECTS none
13055 ===============================================================================*/
13056
13057void WLANTL_UpdateRssiBmps(v_PVOID_t pvosGCtx, v_U8_t staId, v_S7_t rssi)
13058{
13059 WLANTL_CbType* pTLCb = VOS_GET_TL_CB(pvosGCtx);
13060
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053013061 if (NULL != pTLCb && NULL != pTLCb->atlSTAClients[staId])
Jeff Johnson295189b2012-06-20 16:38:30 -070013062 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053013063 pTLCb->atlSTAClients[staId]->rssiAvgBmps = rssi;
Jeff Johnson295189b2012-06-20 16:38:30 -070013064 }
13065}
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053013066
13067/*===============================================================================
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053013068 FUNCTION WLANTL_UpdateSnrBmps
13069
13070 DESCRIPTION This function updates the TL's SNR (in BMPS mode)
13071
13072 DEPENDENCIES None
13073
13074 PARAMETERS
13075
13076 pvosGCtx VOS context VOS Global context
13077 staId Station ID Station ID
13078 snr SNR (BMPS mode) SNR in BMPS mode
13079
13080 RETURN None
13081
13082 SIDE EFFECTS none
13083 ===============================================================================*/
13084
13085void WLANTL_UpdateSnrBmps(v_PVOID_t pvosGCtx, v_U8_t staId, v_S7_t snr)
13086{
13087 WLANTL_CbType* pTLCb = VOS_GET_TL_CB(pvosGCtx);
13088
13089 if (NULL != pTLCb && NULL != pTLCb->atlSTAClients[staId])
13090 {
13091 pTLCb->atlSTAClients[staId]->snrAvgBmps = snr;
13092 }
13093}
13094
13095/*===============================================================================
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053013096 FUNCTION WLANTL_UpdateLinkCapacity
13097
13098 DESCRIPTION This function updates the STA's Link Capacity in TL
13099
13100 DEPENDENCIES None
13101
13102 PARAMETERS
13103
13104 pvosGCtx VOS context VOS Global context
13105 staId Station ID Station ID
13106 linkCapacity linkCapacity Link Capacity
13107
13108 RETURN None
13109
13110 SIDE EFFECTS none
13111 ===============================================================================*/
13112
13113void WLANTL_UpdateLinkCapacity(v_PVOID_t pvosGCtx, v_U8_t staId, v_U32_t linkCapacity)
13114{
13115 WLANTL_CbType* pTLCb = VOS_GET_TL_CB(pvosGCtx);
13116
13117 if (NULL != pTLCb && NULL != pTLCb->atlSTAClients[staId])
13118 {
13119 pTLCb->atlSTAClients[staId]->linkCapacity = linkCapacity;
13120 }
13121}
13122
13123
13124/*===========================================================================
13125
13126 FUNCTION WLANTL_GetSTALinkCapacity
13127
13128 DESCRIPTION
13129
13130 Returns Link Capacity of a particular STA.
13131
13132 DEPENDENCIES
13133
13134 A station must have been registered before its state can be retrieved.
13135
13136
13137 PARAMETERS
13138
13139 IN
13140 pvosGCtx: pointer to the global vos context; a handle to TL's
13141 control block can be extracted from its context
13142 ucSTAId: identifier of the station
13143
13144 OUT
13145 plinkCapacity: the current link capacity the connection to
13146 the given station
13147
13148
13149 RETURN VALUE
13150
13151 The result code associated with performing the operation
13152
13153 VOS_STATUS_E_INVAL: Input parameters are invalid
13154 VOS_STATUS_E_FAULT: Station ID is outside array boundaries or pointer to
13155 TL cb is NULL ; access would cause a page fault
13156 VOS_STATUS_E_EXISTS: Station was not registered
13157 VOS_STATUS_SUCCESS: Everything is good :)
13158
13159 SIDE EFFECTS
13160
13161============================================================================*/
13162VOS_STATUS
13163WLANTL_GetSTALinkCapacity
13164(
13165 v_PVOID_t pvosGCtx,
13166 v_U8_t ucSTAId,
13167 v_U32_t *plinkCapacity
13168)
13169{
13170 WLANTL_CbType* pTLCb = NULL;
13171 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
13172
13173 /*------------------------------------------------------------------------
13174 Sanity check
13175 ------------------------------------------------------------------------*/
13176 if ( NULL == plinkCapacity )
13177 {
13178 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
13179 FL("WLAN TL:Invalid parameter")));
13180 return VOS_STATUS_E_INVAL;
13181 }
13182
13183 if ( WLANTL_STA_ID_INVALID( ucSTAId ) )
13184 {
13185 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
13186 FL("WLAN TL:Invalid station id")));
13187 return VOS_STATUS_E_FAULT;
13188 }
13189
13190 /*------------------------------------------------------------------------
13191 Extract TL control block and check existance
13192 ------------------------------------------------------------------------*/
13193 pTLCb = VOS_GET_TL_CB(pvosGCtx);
13194 if ( NULL == pTLCb )
13195 {
13196 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
13197 FL("WLAN TL:Invalid TL pointer from pvosGCtx")));
13198 return VOS_STATUS_E_FAULT;
13199 }
13200
13201 if ( NULL == pTLCb->atlSTAClients[ucSTAId] )
13202 {
13203 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
13204 FL("WLAN TL:Client Memory was not allocated")));
13205 return VOS_STATUS_E_FAILURE;
13206 }
13207
13208 if ( 0 == pTLCb->atlSTAClients[ucSTAId]->ucExists )
13209 {
13210 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
13211 FL("WLAN TL:Station was not previously registered")));
13212 return VOS_STATUS_E_EXISTS;
13213 }
13214
13215 /*------------------------------------------------------------------------
13216 Get STA state
13217 ------------------------------------------------------------------------*/
13218 *plinkCapacity = pTLCb->atlSTAClients[ucSTAId]->linkCapacity;
13219
13220 return VOS_STATUS_SUCCESS;
13221}/* WLANTL_GetSTALinkCapacity */