blob: 53930e72a28f7b6d04b08864f28fb097fe2a22e2 [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Gopichand Nakkala92f07d82013-01-08 21:16:34 -08002 * Copyright (c) 2012-2013, The Linux Foundation. All rights reserved.
3 *
4 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
5 *
6 *
7 * Permission to use, copy, modify, and/or distribute this software for
8 * any purpose with or without fee is hereby granted, provided that the
9 * above copyright notice and this permission notice appear in all
10 * copies.
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
13 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
14 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
15 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
16 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
17 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
18 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19 * PERFORMANCE OF THIS SOFTWARE.
20 */
21/*
Jeff Johnson32d95a32012-09-10 13:15:23 -070022 * Copyright (c) 2012, The Linux Foundation. All rights reserved.
Jeff Johnson295189b2012-06-20 16:38:30 -070023 *
24 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
25 *
26 *
27 * Permission to use, copy, modify, and/or distribute this software for
28 * any purpose with or without fee is hereby granted, provided that the
29 * above copyright notice and this permission notice appear in all
30 * copies.
31 *
32 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
33 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
34 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
35 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
36 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
37 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
38 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
39 * PERFORMANCE OF THIS SOFTWARE.
40 */
41
42/*===========================================================================
43
44
45 W L A N _ Q C T _ T L . C
46
47 OVERVIEW:
48
49 This software unit holds the implementation of the WLAN Transport Layer.
50
51 The functions externalized by this module are to be called ONLY by other
52 WLAN modules that properly register with the Transport Layer initially.
53
54 DEPENDENCIES:
55
56 Are listed for each API below.
57
58
59 Copyright (c) 2008 QUALCOMM Incorporated.
60 All Rights Reserved.
61 Qualcomm Confidential and Proprietary
62===========================================================================*/
63
64/*===========================================================================
65
66 EDIT HISTORY FOR FILE
67
68
69 This section contains comments describing changes made to the module.
70 Notice that changes are listed in reverse chronological order.
71
72
73 $Header$$DateTime$$Author$
74
75
76 when who what, where, why
77---------- --- --------------------------------------------------------
782010-07-13 c_shinde Fixed an issue where WAPI rekeying was failing because
79 WAI frame sent out during rekeying had the protected bit
80 set to 1.
812010-05-06 rnair Changed name of variable from usLlcType to usEtherType
82 Changed function name from GetLLCType to GetEtherType
83 Fixed 802.3 to 802.11 frame translation issue where two
84 bytes of the LLC header was getting overwritten in the
85 non-Qos path
862010-05-06 rnair RxAuth path fix for modifying the header before ether
87 type is retreived (Detected while testing rekeying
88 in WAPI Volans)
892010-02-19 bad Fixed 802.11 to 802.3 ft issues with WAPI
902010-02-19 rnair WAPI: If frame is a WAI frame in TxConn and TxAuth, TL
91 does frame translation.
922010-02-01 rnair WAPI: Fixed a bug where the value of ucIsWapiSta was not
93 being set in the TL control block in the RegisterSTA func.
942010-01-08 lti Added TL Data Caching
952009-11-04 rnair WAPI: Moving common functionality to a seperate function
96 called WLANTL_GetLLCType
972009-10-15 rnair WAPI: Featurizing WAPI code
982009-10-09 rnair WAPI: Modifications to authenticated state handling of Rx data
992009-10-06 rnair Adding support for WAPI
1002009-09-22 lti Add deregistration API for management client
1012009-07-16 rnair Temporary fix to let TL fetch packets when multiple
102 peers exist in an IBSS
1032009-06-10 lti Fix for checking TID value of meta info on TX - prevent
104 memory overwrite
105 Fix for properly checking the sta id for resuming trigger
106 frame generation
1072009-05-14 lti Fix for sending out trigger frames
1082009-05-15 lti Addr3 filtering
1092009-04-13 lti Assert if packet larger then allowed
110 Drop packet that fails flatten
1112009-04-02 lti Performance fixes for TL
1122009-02-19 lti Added fix for LLC management on Rx Connect
1132009-01-16 lti Replaced peek data with extract data for non BD opertions
114 Extracted frame control in Tl and pass to HAL for frame
115 type evaluation
1162009-02-02 sch Add handoff support
1172008-12-09 lti Fixes for AMSS compilation
118 Removed assert on receive when there is no station
1192008-12-02 lti Fix fo trigger frame generation
1202008-10-31 lti Fix fo TL tx suspend
1212008-10-01 lti Merged in fixes from reordering
122 Disabled part of UAPSD functionality in TL
123 (will be re-enabled once UAPSD is tested)
124 Fix for UAPSD multiple enable
1252008-08-10 lti Fixes following UAPSD testing
126 Fixed infinite loop on mask computation when STA no reg
1272008-08-06 lti Fixes after QOS unit testing
1282008-08-06 lti Added QOS support
1292008-07-23 lti Fix for vos packet draining
1302008-07-17 lti Fix for data type value
131 Added frame translation code in TL
132 Avoid returning failure to PE in case previous frame is
133 still pending; fail previous and cache new one for tx
134 Get frames returning boolean true if more frames are pending
1352008-07-03 lti Fixes following pre-integration testing
1362008-06-26 lti Fixes following unit testing
137 Added alloc and free for TL context
138 Using atomic set u8 instead of u32
1392008-05-16 lti Created module
140
141===========================================================================*/
142
143/*----------------------------------------------------------------------------
144 * Include Files
145 * -------------------------------------------------------------------------*/
146#include "wlan_qct_tl.h"
147#include "wlan_qct_wda.h"
148#include "wlan_qct_tli.h"
149#include "wlan_qct_tli_ba.h"
150#include "wlan_qct_tl_hosupport.h"
Jeff Johnson295189b2012-06-20 16:38:30 -0700151#include "tlDebug.h"
152#ifdef FEATURE_WLAN_WAPI
153/*Included to access WDI_RxBdType */
154#include "wlan_qct_wdi_bd.h"
155#endif
156/*Enables debugging behavior in TL*/
157#define TL_DEBUG
Hoonki Lee14621352013-04-16 17:51:19 -0700158/*Enables debugging FC control frame in TL*/
159//#define TL_DEBUG_FC
Jeff Johnson295189b2012-06-20 16:38:30 -0700160//#define WLAN_SOFTAP_FLOWCTRL_EN
Jeff Johnson295189b2012-06-20 16:38:30 -0700161//#define BTAMP_TEST
Hoonki Lee14621352013-04-16 17:51:19 -0700162#ifdef TL_DEBUG_FC
163#include <wlan_qct_pal_status.h>
164#include <wlan_qct_pal_device.h> // wpalReadRegister
165#endif
166
Jeff Johnson295189b2012-06-20 16:38:30 -0700167/*----------------------------------------------------------------------------
168 * Preprocessor Definitions and Constants
169 * -------------------------------------------------------------------------*/
170/*LLC header value*/
171static v_U8_t WLANTL_LLC_HEADER[] = {0xAA, 0xAA, 0x03, 0x00, 0x00, 0x00 };
172
173#ifdef FEATURE_WLAN_CCX
174/*Aironet SNAP header value*/
175static v_U8_t WLANTL_AIRONET_SNAP_HEADER[] = {0xAA, 0xAA, 0x03, 0x00, 0x40, 0x96, 0x00, 0x00 };
176#endif //FEATURE_WLAN_CCX
177
178/*BT-AMP packet LLC OUI value*/
179const v_U8_t WLANTL_BT_AMP_OUI[] = {0x00, 0x19, 0x58 };
180
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530181#define WLANTL_MAX_SNR_DATA_SAMPLES 20
Jeff Johnson295189b2012-06-20 16:38:30 -0700182
183#ifdef VOLANS_PERF
184#define WLANTL_BD_PDU_INTERRUPT_ENABLE_THRESHOLD 120
185#define WLANTL_BD_PDU_INTERRUPT_GET_THRESHOLD 120
186
187/* TL BD/PDU threshold to enable interrupt */
188int bdPduInterruptEnableThreshold = WLANTL_BD_PDU_INTERRUPT_ENABLE_THRESHOLD;
189int bdPduInterruptGetThreshold = WLANTL_BD_PDU_INTERRUPT_GET_THRESHOLD;
190#endif /* VOLANS_PERF */
191
192/*-----------------------------------*
193 | Type(2b) | Sub-type(4b) |
194 *-----------------------------------*/
195#define WLANTL_IS_DATA_FRAME(_type_sub) \
196 ( WLANTL_DATA_FRAME_TYPE == ( (_type_sub) & 0x30 ))
197
198#define WLANTL_IS_QOS_DATA_FRAME(_type_sub) \
199 (( WLANTL_DATA_FRAME_TYPE == ( (_type_sub) & 0x30 )) && \
200 ( WLANTL_80211_DATA_QOS_SUBTYPE == ( (_type_sub) & 0xF )))
201
202#define WLANTL_IS_MGMT_FRAME(_type_sub) \
203 ( WLANTL_MGMT_FRAME_TYPE == ( (_type_sub) & 0x30 ))
204
205#define WLANTL_IS_CTRL_FRAME(_type_sub) \
206 ( WLANTL_CTRL_FRAME_TYPE == ( (_type_sub) & 0x30 ))
207
Mohit Khanna698ba2a2012-12-04 15:08:18 -0800208#ifdef FEATURE_WLAN_TDLS
209#define WLANTL_IS_TDLS_FRAME(_eth_type) \
210 ( WLANTL_LLC_TDLS_TYPE == ( _eth_type))
211#endif
212
Jeff Johnson295189b2012-06-20 16:38:30 -0700213/*MAX Allowed len processed by TL - MAx MTU + 802.3 header + BD+DXE+XTL*/
Madan Mohan Koyyalamudia53c4dc2012-11-13 10:35:42 -0800214#define WLANTL_MAX_ALLOWED_LEN (1514 + 100)
Jeff Johnson295189b2012-06-20 16:38:30 -0700215
216#define WLANTL_MASK_AC 0x03
217
Jeff Johnson295189b2012-06-20 16:38:30 -0700218//some flow_control define
219//LWM mode will be enabled for this station if the egress/ingress falls below this ratio
220#define WLANTL_LWM_EGRESS_INGRESS_THRESHOLD (0.75)
221
222//Get enough sample to do the LWM related calculation
223#define WLANTL_LWM_INGRESS_SAMPLE_THRESHOLD (64)
224
225//Maximal on-fly packet per station in LWM mode
226#define WLANTL_STA_BMU_THRESHOLD_MAX (256)
227
228#define WLANTL_AC_MASK (0x7)
Gopichand Nakkala976e3252013-01-03 15:45:56 -0800229#define WLANTL_STAID_OFFSET (0x6)
Jeff Johnson295189b2012-06-20 16:38:30 -0700230
231/* UINT32 type endian swap */
232#define SWAP_ENDIAN_UINT32(a) ((a) = ((a) >> 0x18 ) |(((a) & 0xFF0000) >> 0x08) | \
233 (((a) & 0xFF00) << 0x08) | (((a) & 0xFF) << 0x18))
234
235
236
237/*--------------------------------------------------------------------------
238 TID to AC mapping in TL
239 --------------------------------------------------------------------------*/
240const v_U8_t WLANTL_TID_2_AC[WLAN_MAX_TID] = { WLANTL_AC_BE,
241 WLANTL_AC_BK,
242 WLANTL_AC_BK,
243 WLANTL_AC_BE,
244 WLANTL_AC_VI,
245 WLANTL_AC_VI,
246 WLANTL_AC_VO,
247 WLANTL_AC_VO };
248
249/*----------------------------------------------------------------------------
250 * Type Declarations
251 * -------------------------------------------------------------------------*/
252#define TL_LITTLE_BIT_ENDIAN
253
254typedef struct
255{
256
257#ifndef TL_LITTLE_BIT_ENDIAN
258
259 v_U8_t subType :4;
260 v_U8_t type :2;
261 v_U8_t protVer :2;
262
263 v_U8_t order :1;
264 v_U8_t wep :1;
265 v_U8_t moreData :1;
266 v_U8_t powerMgmt :1;
267 v_U8_t retry :1;
268 v_U8_t moreFrag :1;
269 v_U8_t fromDS :1;
270 v_U8_t toDS :1;
271
272#else
273
274 v_U8_t protVer :2;
275 v_U8_t type :2;
276 v_U8_t subType :4;
277
278 v_U8_t toDS :1;
279 v_U8_t fromDS :1;
280 v_U8_t moreFrag :1;
281 v_U8_t retry :1;
282 v_U8_t powerMgmt :1;
283 v_U8_t moreData :1;
284 v_U8_t wep :1;
285 v_U8_t order :1;
286
287#endif
288
289} WLANTL_MACFCType;
290
291/* 802.11 header */
292typedef struct
293{
294 /* Frame control field */
295 WLANTL_MACFCType wFrmCtrl;
296
297 /* Duration ID */
298 v_U16_t usDurationId;
299
300 /* Address 1 field */
301 v_U8_t vA1[VOS_MAC_ADDR_SIZE];
302
303 /* Address 2 field */
304 v_U8_t vA2[VOS_MAC_ADDR_SIZE];
305
306 /* Address 3 field */
307 v_U8_t vA3[VOS_MAC_ADDR_SIZE];
308
309 /* Sequence control field */
310 v_U16_t usSeqCtrl;
311
312 // Find the size of the mandatory header size.
313#define WLAN80211_MANDATORY_HEADER_SIZE \
314 (sizeof(WLANTL_MACFCType) + sizeof(v_U16_t) + \
315 (3 * (sizeof(v_U8_t) * VOS_MAC_ADDR_SIZE)) + \
316 sizeof(v_U16_t))
317
318 /* Optional A4 address */
319 v_U8_t optvA4[VOS_MAC_ADDR_SIZE];
320
321 /* Optional QOS control field */
322 v_U16_t usQosCtrl;
323}WLANTL_80211HeaderType;
324
325/* 802.3 header */
326typedef struct
327{
328 /* Destination address field */
329 v_U8_t vDA[VOS_MAC_ADDR_SIZE];
330
331 /* Source address field */
332 v_U8_t vSA[VOS_MAC_ADDR_SIZE];
333
334 /* Length field */
335 v_U16_t usLenType;
336}WLANTL_8023HeaderType;
337
338/*----------------------------------------------------------------------------
339 * Global Data Definitions
340 * -------------------------------------------------------------------------*/
341#define WLAN_TL_INVALID_U_SIG 255
342#define WLAN_TL_INVALID_B_SIG 255
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +0530343#define ENTER() VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO, "Enter:%s", __func__)
344
Jeff Johnson295189b2012-06-20 16:38:30 -0700345#define WLAN_TL_AC_ARRAY_2_MASK( _pSTA, _ucACMask, i ) \
346 do\
347 {\
348 _ucACMask = 0; \
349 for ( i = 0; i < WLANTL_MAX_AC; i++ ) \
350 { \
351 if ( 0 != (_pSTA)->aucACMask[i] ) \
352 { \
353 _ucACMask |= ( 1 << i ); \
354 } \
355 } \
356 } while (0);
357
358/*----------------------------------------------------------------------------
359 * Static Variable Definitions
360 * -------------------------------------------------------------------------*/
361
362/*----------------------------------------------------------------------------
363 * Static Function Declarations and Definitions
364 * -------------------------------------------------------------------------*/
365
366static VOS_STATUS
367WLANTL_GetEtherType
368(
369 v_U8_t * aucBDHeader,
370 vos_pkt_t * vosDataBuff,
371 v_U8_t ucMPDUHLen,
372 v_U16_t * usEtherType
373);
374
Mohit Khanna698ba2a2012-12-04 15:08:18 -0800375#ifdef FEATURE_WLAN_TDLS_INTERNAL
376/* FIXME_MUST: during TDLS integration to main/latest, WLANTL_GetEtherType() conflicts.
377But there is difference. existing WLANTL_GetEtherType() expects vosDataBuff->offset points to MPDU Header,
378wherease TDLS expect vosDataBuff->offset should still points to RxBd.
379So far, data frmae stripped RxBD and passed to data frame handler.
380(RxBd should not be stripped in case TDLS, because it will be eventually routed to mgmt packet
381handler, where RX BD should be preserved)
382To avoid breaking existing functionality, for now, I temporarily rename to
383WLANTL_GetEtherType_2(). Eventually this function should be removed and merged to WLANTL_GetEtherType()
384*/
385static VOS_STATUS
386WLANTL_GetEtherType_2
387(
388 v_U8_t * aucBDHeader,
389 vos_pkt_t * vosDataBuff,
390 v_U8_t ucMPDUHLen,
391 v_U16_t * usEtherType
392);
393#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700394#ifdef FEATURE_WLAN_WAPI
395/*---------------------------------------------------------------------------
396 * Adding a global variable to be used when doing frame translation in TxAuth
397 * state so as to not set the protected bit to 1 in the case of WAI frames
398 *---------------------------------------------------------------------------*/
Madan Mohan Koyyalamudidfd6aa82012-10-18 20:18:43 -0700399v_U8_t gUcIsWai;
Jeff Johnson295189b2012-06-20 16:38:30 -0700400#endif
401
402/*----------------------------------------------------------------------------
403 * Externalized Function Definitions
404* -------------------------------------------------------------------------*/
405
406/*----------------------------------------------------------------------------
407 * Function Declarations and Documentation
408 * -------------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +0530409/*==========================================================================
410
411 FUNCTION WLANTL_FreeClientMemory
412
413 DESCRIPTION
414 It frees up the memory allocated to all the STA clients in TLCB block
415 Can be called inside Close, Stop or when some FAULT occurs
416
417 DEPENDENCIES
418
419 PARAMETERS
420
421 IN
422 pClientSTA: Pointer to the global client pointer array
423
424 RETURN VALUE
425
426 SIDE EFFECTS
427
428============================================================================*/
429void WLANTL_FreeClientMemory
430(WLANTL_STAClientType* pClientSTA[WLAN_MAX_STA_COUNT])
431{
432 v_U32_t i = 0;
433 for(i =0; i < WLAN_MAX_STA_COUNT; i++)
434 {
435 if( NULL != pClientSTA[i] )
436 {
437 vos_mem_free(pClientSTA[i]);
438 }
439 pClientSTA[i] = NULL;
440 }
441 return;
442}
Jeff Johnson295189b2012-06-20 16:38:30 -0700443
444/*==========================================================================
445
446 FUNCTION WLANTL_Open
447
448 DESCRIPTION
449 Called by HDD at driver initialization. TL will initialize all its
450 internal resources and will wait for the call to start to register
451 with the other modules.
452
453 DEPENDENCIES
454
455 PARAMETERS
456
457 IN
458 pvosGCtx: pointer to the global vos context; a handle to TL's
459 control block can be extracted from its context
460 pTLConfig: TL Configuration
461
462 RETURN VALUE
463 The result code associated with performing the operation
464
465 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a page
466 fault
467 VOS_STATUS_SUCCESS: Everything is good :)
468
469 SIDE EFFECTS
470
471============================================================================*/
472VOS_STATUS
473WLANTL_Open
474(
475 v_PVOID_t pvosGCtx,
476 WLANTL_ConfigInfoType* pTLConfig
477)
478{
479 WLANTL_CbType* pTLCb = NULL;
480 v_U8_t ucIndex;
481 tHalHandle smeContext;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +0530482 v_U32_t i = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700483#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
484 VOS_STATUS status = VOS_STATUS_SUCCESS;
485#endif
486 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
487
488 /*------------------------------------------------------------------------
489 Sanity check
490 Extract TL control block
491 ------------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +0530492 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -0700493 vos_alloc_context( pvosGCtx, VOS_MODULE_ID_TL,
494 (void*)&pTLCb, sizeof(WLANTL_CbType));
495
496 pTLCb = VOS_GET_TL_CB(pvosGCtx);
497 if (( NULL == pTLCb ) || ( NULL == pTLConfig ) )
498 {
Madan Mohan Koyyalamudic0e5bd82012-09-18 17:12:27 -0700499 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_FATAL,
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +0530500 "WLAN TL: Invalid input pointer on WLANTL_Open TL %p Config %p", pTLCb, pTLConfig ));
Jeff Johnson295189b2012-06-20 16:38:30 -0700501 return VOS_STATUS_E_FAULT;
502 }
503
Madan Mohan Koyyalamudic0e5bd82012-09-18 17:12:27 -0700504 /* Set the default log level to VOS_TRACE_LEVEL_ERROR */
505 vos_trace_setLevel(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR);
506
Jeff Johnson295189b2012-06-20 16:38:30 -0700507 smeContext = vos_get_context(VOS_MODULE_ID_SME, pvosGCtx);
508 if ( NULL == smeContext )
509 {
510 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700511 "%s: Invalid smeContext", __func__));
Jeff Johnson295189b2012-06-20 16:38:30 -0700512 return VOS_STATUS_E_FAULT;
513 }
514
515 /* Zero out the memory so we are OK, when CleanCB is called.*/
516 vos_mem_zero((v_VOID_t *)pTLCb, sizeof(WLANTL_CbType));
517
518 /*------------------------------------------------------------------------
519 Clean up TL control block, initialize all values
520 ------------------------------------------------------------------------*/
521 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
522 "WLAN TL:WLANTL_Open"));
523
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +0530524 for ( i =0; i<WLAN_MAX_STA_COUNT; i++ )
Jeff Johnson295189b2012-06-20 16:38:30 -0700525 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +0530526 if ( i < WLAN_NON32_STA_COUNT )
527 {
528 pTLCb->atlSTAClients[i] = vos_mem_malloc(sizeof(WLANTL_STAClientType));
529 /* Allocating memory for LEGACY STA COUNT so as to avoid regression issues. */
530 if ( NULL == pTLCb->atlSTAClients[i] )
531 {
532 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR, "WLAN TL: StaClient allocation failed"));
533 WLANTL_FreeClientMemory(pTLCb->atlSTAClients);
534 vos_free_context(pvosGCtx, VOS_MODULE_ID_TL, pTLCb);
535 return VOS_STATUS_E_FAULT;
536 }
537 vos_mem_zero((v_VOID_t *) pTLCb->atlSTAClients[i], sizeof(WLANTL_STAClientType));
538 }
539 else
540 {
541 pTLCb->atlSTAClients[i] = NULL;
542 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700543 }
544
Jeff Johnson295189b2012-06-20 16:38:30 -0700545 pTLCb->reorderBufferPool = vos_mem_malloc(sizeof(WLANTL_REORDER_BUFFER_T) * WLANTL_MAX_BA_SESSION);
546 if (NULL == pTLCb->reorderBufferPool)
547 {
548 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR, "WLAN TL: Reorder buffer allocation failed\n"));
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +0530549 WLANTL_FreeClientMemory(pTLCb->atlSTAClients);
Jeff Johnson295189b2012-06-20 16:38:30 -0700550 vos_free_context(pvosGCtx, VOS_MODULE_ID_TL, pTLCb);
551 return VOS_STATUS_E_FAULT;
Jeff Johnson295189b2012-06-20 16:38:30 -0700552 }
553
554 vos_mem_zero((v_VOID_t *)pTLCb->reorderBufferPool, sizeof(WLANTL_REORDER_BUFFER_T) * WLANTL_MAX_BA_SESSION);
555
556 WLANTL_CleanCB(pTLCb, 0 /*do not empty*/);
557
558 for ( ucIndex = 0; ucIndex < WLANTL_MAX_AC ; ucIndex++)
559 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +0530560 pTLCb->tlConfigInfo.ucAcWeights[ucIndex] = pTLConfig->ucAcWeights[ucIndex];
Jeff Johnson295189b2012-06-20 16:38:30 -0700561 }
562
Jeff Johnson295189b2012-06-20 16:38:30 -0700563 // scheduling init to be the last one of previous round
564 pTLCb->uCurServedAC = WLANTL_AC_BK;
565 pTLCb->ucCurLeftWeight = 1;
566 pTLCb->ucCurrentSTA = WLAN_MAX_STA_COUNT-1;
567
568#if 0
569 //flow control field init
570 vos_mem_zero(&pTLCb->tlFCInfo, sizeof(tFcTxParams_type));
571 //bit 0: set (Bd/pdu count) bit 1: set (request station PS change notification)
572 pTLCb->tlFCInfo.fcConfig = 0x1;
573#endif
574
575 pTLCb->vosTxFCBuf = NULL;
576 pTLCb->tlConfigInfo.uMinFramesProcThres =
577 pTLConfig->uMinFramesProcThres;
Jeff Johnson295189b2012-06-20 16:38:30 -0700578
Sunil Ravid5406f22013-01-22 00:18:31 -0800579#ifdef FEATURE_WLAN_TDLS
580 pTLCb->ucTdlsPeerCount = 0;
581#endif
582
Jeff Johnson295189b2012-06-20 16:38:30 -0700583 pTLCb->tlConfigInfo.uDelayedTriggerFrmInt =
584 pTLConfig->uDelayedTriggerFrmInt;
585
586 /*------------------------------------------------------------------------
587 Allocate internal resources
588 ------------------------------------------------------------------------*/
589 vos_pkt_get_packet(&pTLCb->vosDummyBuf, VOS_PKT_TYPE_RX_RAW, 1, 1,
590 1/*true*/,NULL, NULL);
591
592 WLANTL_InitBAReorderBuffer(pvosGCtx);
593#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
594 /* Initialize Handoff support modue
595 * RSSI measure and Traffic state monitoring */
596 status = WLANTL_HSInit(pvosGCtx);
597 if(!VOS_IS_STATUS_SUCCESS(status))
598 {
599 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
600 "Handoff support module init fail"));
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +0530601 WLANTL_FreeClientMemory(pTLCb->atlSTAClients);
Jeff Johnson295189b2012-06-20 16:38:30 -0700602 vos_mem_free(pTLCb->reorderBufferPool);
603 vos_free_context(pvosGCtx, VOS_MODULE_ID_TL, pTLCb);
604 return status;
605 }
606#endif
607
608 pTLCb->isBMPS = VOS_FALSE;
609 pmcRegisterDeviceStateUpdateInd( smeContext,
610 WLANTL_PowerStateChangedCB, pvosGCtx );
611
612 return VOS_STATUS_SUCCESS;
613}/* WLANTL_Open */
614
615/*==========================================================================
616
617 FUNCTION WLANTL_Start
618
619 DESCRIPTION
620 Called by HDD as part of the overall start procedure. TL will use this
621 call to register with BAL as a transport layer entity.
622
623 DEPENDENCIES
624
625 PARAMETERS
626
627 IN
628 pvosGCtx: pointer to the global vos context; a handle to TL's
629 control block can be extracted from its context
630
631 RETURN VALUE
632 The result code associated with performing the operation
633
634 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a page
635 fault
636 VOS_STATUS_SUCCESS: Everything is good :)
637
638 Other codes can be returned as a result of a BAL failure; see BAL API
639 for more info
640
641 SIDE EFFECTS
642
643============================================================================*/
644VOS_STATUS
645WLANTL_Start
646(
647 v_PVOID_t pvosGCtx
648)
649{
650 WLANTL_CbType* pTLCb = NULL;
651 v_U32_t uResCount = WDA_TLI_MIN_RES_DATA;
652 VOS_STATUS vosStatus;
653 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
654
655 /*------------------------------------------------------------------------
656 Sanity check
657 Extract TL control block
658 ------------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +0530659 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -0700660 pTLCb = VOS_GET_TL_CB(pvosGCtx);
661 if ( NULL == pTLCb )
662 {
663 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
664 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_Start"));
665 return VOS_STATUS_E_FAULT;
666 }
667
668 /*------------------------------------------------------------------------
669 Register with WDA as transport layer client
670 Request resources for tx from bus
671 ------------------------------------------------------------------------*/
672 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
673 "WLAN TL:WLAN TL:WLANTL_Start"));
674
675 vosStatus = WDA_DS_Register( pvosGCtx,
676 WLANTL_TxComp,
677 WLANTL_RxFrames,
678 WLANTL_GetFrames,
679 WLANTL_ResourceCB,
680 WDA_TLI_MIN_RES_DATA,
681 pvosGCtx,
682 &uResCount );
683
684 if ( VOS_STATUS_SUCCESS != vosStatus )
685 {
686 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
687 "WLAN TL:TL failed to register with BAL/WDA, Err: %d",
688 vosStatus));
689 return vosStatus;
690 }
691
692 /* Enable transmission */
693 vos_atomic_set_U8( &pTLCb->ucTxSuspended, 0);
694
695 pTLCb->uResCount = uResCount;
Jeff Johnson295189b2012-06-20 16:38:30 -0700696 return VOS_STATUS_SUCCESS;
697}/* WLANTL_Start */
698
699/*==========================================================================
700
701 FUNCTION WLANTL_Stop
702
703 DESCRIPTION
704 Called by HDD to stop operation in TL, before close. TL will suspend all
705 frame transfer operation and will wait for the close request to clean up
706 its resources.
707
708 DEPENDENCIES
709
710 PARAMETERS
711
712 IN
713 pvosGCtx: pointer to the global vos context; a handle to TL's
714 control block can be extracted from its context
715
716 RETURN VALUE
717 The result code associated with performing the operation
718
719 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a page
720 fault
721 VOS_STATUS_SUCCESS: Everything is good :)
722
723 SIDE EFFECTS
724
725============================================================================*/
726VOS_STATUS
727WLANTL_Stop
728(
729 v_PVOID_t pvosGCtx
730)
731{
732 WLANTL_CbType* pTLCb = NULL;
733 v_U8_t ucIndex;
734 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
735
736 /*------------------------------------------------------------------------
737 Sanity check
738 Extract TL control block
739 ------------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +0530740 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -0700741 pTLCb = VOS_GET_TL_CB(pvosGCtx);
742 if ( NULL == pTLCb )
743 {
744 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
745 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_ChangeSTAState"));
746 return VOS_STATUS_E_FAULT;
747 }
748
749 /*------------------------------------------------------------------------
750 Stop TL and empty Station list
751 ------------------------------------------------------------------------*/
752 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
753 "WLAN TL:WLANTL_Stop"));
754
755 /* Disable transmission */
756 vos_atomic_set_U8( &pTLCb->ucTxSuspended, 1);
757
758 if ( NULL != pTLCb->tlMgmtFrmClient.vosPendingDataBuff )
759 {
760 vos_pkt_return_packet(pTLCb->tlMgmtFrmClient.vosPendingDataBuff);
761 pTLCb->tlMgmtFrmClient.vosPendingDataBuff = NULL;
762 }
763
764 if ( NULL != pTLCb->tlBAPClient.vosPendingDataBuff )
765 {
766 vos_pkt_return_packet(pTLCb->tlBAPClient.vosPendingDataBuff);
767 pTLCb->tlBAPClient.vosPendingDataBuff = NULL;
768 }
769
770#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
771 if(VOS_STATUS_SUCCESS != WLANTL_HSStop(pvosGCtx))
772 {
773 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
774 "Handoff Support module stop fail"));
775 }
776#endif
777
778 /*-------------------------------------------------------------------------
779 Clean client stations
780 -------------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +0530781 for ( ucIndex = 0; ucIndex < WLAN_MAX_STA_COUNT; ucIndex++)
Jeff Johnson295189b2012-06-20 16:38:30 -0700782 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +0530783 if ( NULL != pTLCb->atlSTAClients[ucIndex] )
784 {
785 WLANTL_CleanSTA(pTLCb->atlSTAClients[ucIndex], 1 /*empty all queues*/);
786 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700787 }
788
789
790 return VOS_STATUS_SUCCESS;
791}/* WLANTL_Stop */
792
793/*==========================================================================
794
795 FUNCTION WLANTL_Close
796
797 DESCRIPTION
798 Called by HDD during general driver close procedure. TL will clean up
799 all the internal resources.
800
801 DEPENDENCIES
802
803 PARAMETERS
804
805 IN
806 pvosGCtx: pointer to the global vos context; a handle to TL's
807 control block can be extracted from its context
808
809 RETURN VALUE
810 The result code associated with performing the operation
811
812 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a page
813 fault
814 VOS_STATUS_SUCCESS: Everything is good :)
815
816 SIDE EFFECTS
817
818============================================================================*/
819VOS_STATUS
820WLANTL_Close
821(
822 v_PVOID_t pvosGCtx
823)
824{
825 WLANTL_CbType* pTLCb = NULL;
826 tHalHandle smeContext;
827 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
828
829 /*------------------------------------------------------------------------
830 Sanity check
831 Extract TL control block
832 ------------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +0530833 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -0700834 pTLCb = VOS_GET_TL_CB(pvosGCtx);
835 if ( NULL == pTLCb )
836 {
837 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
838 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_ChangeSTAState"));
839 return VOS_STATUS_E_FAULT;
840 }
841 /*------------------------------------------------------------------------
842 Deregister from PMC
843 ------------------------------------------------------------------------*/
844 smeContext = vos_get_context(VOS_MODULE_ID_SME, pvosGCtx);
845 if ( NULL == smeContext )
846 {
847 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700848 "%s: Invalid smeContext", __func__));
Jeff Johnson295189b2012-06-20 16:38:30 -0700849 // continue so that we can cleanup as much as possible
850 }
851 else
852 {
853 pmcDeregisterDeviceStateUpdateInd( smeContext, WLANTL_PowerStateChangedCB );
854 }
855
856#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
857 if(VOS_STATUS_SUCCESS != WLANTL_HSDeInit(pvosGCtx))
858 {
859 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
860 "Handoff Support module DeInit fail"));
861 }
862#endif
863
864 /*------------------------------------------------------------------------
865 Cleanup TL control block.
866 ------------------------------------------------------------------------*/
867 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
868 "WLAN TL: WLANTL_Close"));
869 WLANTL_CleanCB(pTLCb, 1 /* empty queues/lists/pkts if any*/);
870
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +0530871 WLANTL_FreeClientMemory(pTLCb->atlSTAClients);
872
Jeff Johnson295189b2012-06-20 16:38:30 -0700873 vos_mem_free(pTLCb->reorderBufferPool);
874
875 /*------------------------------------------------------------------------
876 Free TL context from VOSS global
877 ------------------------------------------------------------------------*/
878 vos_free_context(pvosGCtx, VOS_MODULE_ID_TL, pTLCb);
879 return VOS_STATUS_SUCCESS;
880}/* WLANTL_Close */
881
882/*----------------------------------------------------------------------------
883 INTERACTION WITH HDD
884 ---------------------------------------------------------------------------*/
885/*==========================================================================
886
887 FUNCTION WLANTL_ConfigureSwFrameTXXlationForAll
888
889 DESCRIPTION
890 Function to disable/enable frame translation for all association stations.
891
892 DEPENDENCIES
893
894 PARAMETERS
895 IN
896 pvosGCtx: VOS context
897 EnableFrameXlation TRUE means enable SW translation for all stations.
898 .
899
900 RETURN VALUE
901
902 void.
903
904============================================================================*/
905void
906WLANTL_ConfigureSwFrameTXXlationForAll
907(
908 v_PVOID_t pvosGCtx,
909 v_BOOL_t enableFrameXlation
910)
911{
912 v_U8_t ucIndex;
913 /*------------------------------------------------------------------------
914 Extract TL control block
915 ------------------------------------------------------------------------*/
916 WLANTL_CbType* pTLCb = VOS_GET_TL_CB(pvosGCtx);
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +0530917 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -0700918 if ( NULL == pTLCb )
919 {
920 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
921 "WLAN TL:Invalid TL pointer from pvosGCtx on "
922 "WLANTL_ConfigureSwFrameTXXlationForAll"));
923 return;
924 }
925
926 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
927 "WLANTL_ConfigureSwFrameTXXlationForAll: Configure SW frameXlation %d",
928 enableFrameXlation));
929
930 for ( ucIndex = 0; ucIndex < WLAN_MAX_TID; ucIndex++)
931 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +0530932 pClientSTA = pTLCb->atlSTAClients[ucIndex];
933 if ( NULL != pClientSTA && 0 != pClientSTA->ucExists )
Jeff Johnson295189b2012-06-20 16:38:30 -0700934 {
935#ifdef WLAN_SOFTAP_VSTA_FEATURE
936 // if this station was not allocated resources to perform HW-based
937 // TX frame translation then force SW-based TX frame translation
938 // otherwise use the frame translation supplied by the client
939 if (!WDA_IsHwFrameTxTranslationCapable(pvosGCtx, ucIndex))
940 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +0530941 pClientSTA->wSTADesc.ucSwFrameTXXlation = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -0700942 }
943 else
944#endif
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +0530945 pClientSTA->wSTADesc.ucSwFrameTXXlation = enableFrameXlation;
Jeff Johnson295189b2012-06-20 16:38:30 -0700946 }
947 }
948}
949
950/*===========================================================================
951
952 FUNCTION WLANTL_StartForwarding
953
954 DESCRIPTION
955
956 This function is used to ask serialization through TX thread of the
957 cached frame forwarding (if statation has been registered in the mean while)
958 or flushing (if station has not been registered by the time)
959
960 In case of forwarding, upper layer is only required to call WLANTL_RegisterSTAClient()
961 and doesn't need to call this function explicitly. TL will handle this inside
962 WLANTL_RegisterSTAClient().
963
964 In case of flushing, upper layer is required to call this function explicitly
965
966 DEPENDENCIES
967
968 TL must have been initialized before this gets called.
969
970
971 PARAMETERS
972
973 ucSTAId: station id
974
975 RETURN VALUE
976
977 The result code associated with performing the operation
978 Please check return values of vos_tx_mq_serialize.
979
980 SIDE EFFECTS
981 If TL was asked to perform WLANTL_CacheSTAFrame() in WLANTL_RxFrames(),
982 either WLANTL_RegisterSTAClient() or this function must be called
983 within reasonable time. Otherwise, TL will keep cached vos buffer until
984 one of this function is called, and may end up with system buffer exhasution.
985
986 It's an upper layer's responsibility to call this function in case of
987 flushing
988
989============================================================================*/
990
991VOS_STATUS
992WLANTL_StartForwarding
993(
994 v_U8_t ucSTAId,
995 v_U8_t ucUcastSig,
996 v_U8_t ucBcastSig
997)
998{
999 vos_msg_t sMessage;
1000 v_U32_t uData;
1001 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
1002
1003 /* Signal the OS to serialize our event */
1004 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
1005 "Serializing TL Start Forwarding Cached for control STA %d",
1006 ucSTAId );
1007
1008 vos_mem_zero( &sMessage, sizeof(vos_msg_t) );
1009
1010 uData = ucSTAId | (ucUcastSig << 8 ) | (ucBcastSig << 16);
1011 sMessage.bodyptr = (v_PVOID_t)uData;
1012 sMessage.type = WLANTL_TX_FWD_CACHED;
1013
1014 return vos_tx_mq_serialize(VOS_MQ_ID_TL, &sMessage);
1015
1016} /* WLANTL_StartForwarding() */
1017
1018/*===========================================================================
1019
1020 FUNCTION WLANTL_AssocFailed
1021
1022 DESCRIPTION
1023
1024 This function is used by PE to notify TL that cache needs to flushed'
1025 when association is not successfully completed
1026
1027 Internally, TL post a message to TX_Thread to serialize the request to
1028 keep lock-free mechanism.
1029
1030
1031 DEPENDENCIES
1032
1033 TL must have been initialized before this gets called.
1034
1035
1036 PARAMETERS
1037
1038 ucSTAId: station id
1039
1040 RETURN VALUE
1041
1042 none
1043
1044 SIDE EFFECTS
1045 There may be race condition that PE call this API and send another association
1046 request immediately with same staId before TX_thread can process the message.
1047
1048 To avoid this, we might need PE to wait for TX_thread process the message,
1049 but this is not currently implemented.
1050
1051============================================================================*/
1052void WLANTL_AssocFailed(v_U8_t staId)
1053{
1054 // flushing frames and forwarding frames uses the same message
1055 // the only difference is what happens when the message is processed
1056 // if the STA exist, the frames will be forwarded
1057 // and if it doesn't exist, the frames will be flushed
1058 // in this case we know it won't exist so the DPU index signature values don't matter
1059 if(!VOS_IS_STATUS_SUCCESS(WLANTL_StartForwarding(staId,0,0)))
1060 {
1061 VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001062 " %s fails to start forwarding", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001063 }
1064}
1065
1066 /*===========================================================================
1067
1068 FUNCTION WLANTL_Finish_ULA
1069
1070 DESCRIPTION
1071 This function is used by HDD to notify TL to finish Upper layer authentication
1072 incase the last EAPOL packet is pending in the TL queue.
1073 To avoid the race condition between sme set key and the last EAPOL packet
1074 the HDD module calls this function just before calling the sme_RoamSetKey.
1075
1076 DEPENDENCIES
1077
1078 TL must have been initialized before this gets called.
1079
1080 PARAMETERS
1081
1082 callbackRoutine: HDD Callback function.
1083 callbackContext : HDD userdata context.
1084
1085 RETURN VALUE
1086
1087 VOS_STATUS_SUCCESS/VOS_STATUS_FAILURE
1088
1089 SIDE EFFECTS
1090
1091============================================================================*/
1092
1093VOS_STATUS WLANTL_Finish_ULA( void (*callbackRoutine) (void *callbackContext),
Tushnim Bhattacharyya39a8f182013-02-20 18:10:30 -08001094 void *callbackContext)
Jeff Johnson295189b2012-06-20 16:38:30 -07001095{
Tushnim Bhattacharyya39a8f182013-02-20 18:10:30 -08001096 return WDA_DS_FinishULA( callbackRoutine, callbackContext);
Jeff Johnson295189b2012-06-20 16:38:30 -07001097}
1098
1099
1100/*===========================================================================
1101
1102 FUNCTION WLANTL_RegisterSTAClient
1103
1104 DESCRIPTION
1105
1106 This function is used by HDD to register as a client for data services
1107 with TL. HDD will call this API for each new station that it adds,
1108 thus having the flexibility of registering different callback for each
1109 STA it services.
1110
1111 DEPENDENCIES
1112
1113 TL must have been initialized before this gets called.
1114
1115 Restriction:
1116 Main thread will have higher priority that Tx and Rx threads thus
1117 guaranteeing that a station will be added before any data can be
1118 received for it. (This enables TL to be lock free)
1119
1120 PARAMETERS
1121
1122 pvosGCtx: pointer to the global vos context; a handle to TL's
1123 control block can be extracted from its context
1124 pfnStARx: function pointer to the receive packet handler from HDD
1125 pfnSTATxComp: function pointer to the transmit complete confirmation
1126 handler from HDD
1127 pfnSTAFetchPkt: function pointer to the packet retrieval routine in HDD
1128 wSTADescType: STA Descriptor, contains information related to the
1129 new added STA
1130
1131 RETURN VALUE
1132
1133 The result code associated with performing the operation
1134
1135 VOS_STATUS_E_INVAL: Input parameters are invalid
1136 VOS_STATUS_E_FAULT: Station ID is outside array boundaries or pointer to
1137 TL cb is NULL ; access would cause a page fault
1138 VOS_STATUS_E_EXISTS: Station was already registered
1139 VOS_STATUS_SUCCESS: Everything is good :)
1140
1141 SIDE EFFECTS
1142
1143============================================================================*/
1144VOS_STATUS
1145WLANTL_RegisterSTAClient
1146(
1147 v_PVOID_t pvosGCtx,
1148 WLANTL_STARxCBType pfnSTARx,
1149 WLANTL_TxCompCBType pfnSTATxComp,
1150 WLANTL_STAFetchPktCBType pfnSTAFetchPkt,
1151 WLAN_STADescType* pwSTADescType,
1152 v_S7_t rssi
1153)
1154{
1155 WLANTL_CbType* pTLCb = NULL;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301156 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07001157 v_U8_t ucTid = 0;/*Local variable to clear previous replay counters of STA on all TIDs*/
Jeff Johnson295189b2012-06-20 16:38:30 -07001158 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
1159
1160 /*------------------------------------------------------------------------
1161 Sanity check
1162 ------------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301163 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -07001164 if (( NULL == pwSTADescType ) || ( NULL == pfnSTARx ) ||
1165 ( NULL == pfnSTAFetchPkt ))
1166 {
1167 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1168 "WLAN TL:Invalid parameter sent on WLANTL_RegisterSTAClient"));
1169 return VOS_STATUS_E_INVAL;
1170 }
1171
1172 if ( WLANTL_STA_ID_INVALID( pwSTADescType->ucSTAId ) )
1173 {
1174 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1175 "WLAN TL:Invalid station id requested on WLANTL_RegisterSTAClient"));
1176 return VOS_STATUS_E_FAULT;
1177 }
1178
1179 /*------------------------------------------------------------------------
1180 Extract TL control block
1181 ------------------------------------------------------------------------*/
1182 pTLCb = VOS_GET_TL_CB(pvosGCtx);
1183 if ( NULL == pTLCb )
1184 {
1185 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1186 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_RegisterSTAClient"));
1187 return VOS_STATUS_E_FAULT;
1188 }
1189
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301190 //Code for checking and allocating memory for new STA
1191 if ( NULL == pTLCb->atlSTAClients[pwSTADescType->ucSTAId] ){
1192 pTLCb->atlSTAClients[pwSTADescType->ucSTAId] = vos_mem_malloc(sizeof(WLANTL_STAClientType));
1193 if ( NULL == pTLCb->atlSTAClients[pwSTADescType->ucSTAId] ){
1194 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1195 "WLAN TL: STA Client memory allocation failed in WLANTL_RegisterSTAClient"));
1196 return VOS_STATUS_E_FAILURE;
1197 }
1198 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
1199 "WLAN TL: STA Client memory allocation in WLANTL_RegisterSTAClient"));
1200 vos_mem_zero((v_VOID_t *) pTLCb->atlSTAClients[pwSTADescType->ucSTAId],sizeof(WLANTL_STAClientType));
1201 }
1202
1203 //Assigning the pointer to local variable for easy access in future
1204 pClientSTA = pTLCb->atlSTAClients[pwSTADescType->ucSTAId];
1205 if ( 0 != pClientSTA->ucExists )
Jeff Johnson295189b2012-06-20 16:38:30 -07001206 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301207 pClientSTA->ucExists++;
Jeff Johnson295189b2012-06-20 16:38:30 -07001208 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1209 "WLAN TL:Station was already registered on WLANTL_RegisterSTAClient"));
1210 return VOS_STATUS_E_EXISTS;
1211 }
1212
1213 /*------------------------------------------------------------------------
1214 Register station with TL
1215 ------------------------------------------------------------------------*/
1216 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
1217 "WLAN TL:Registering STA Client ID: %d", pwSTADescType->ucSTAId ));
1218
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301219 pClientSTA->pfnSTARx = pfnSTARx;
1220 pClientSTA->pfnSTAFetchPkt = pfnSTAFetchPkt;
Jeff Johnson295189b2012-06-20 16:38:30 -07001221
1222 /* Only register if different from NULL - TL default Tx Comp Cb will
1223 release the vos packet */
1224 if ( NULL != pfnSTATxComp )
1225 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301226 pClientSTA->pfnSTATxComp = pfnSTATxComp;
Jeff Johnson295189b2012-06-20 16:38:30 -07001227 }
1228
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301229 pClientSTA->tlState = WLANTL_STA_INIT;
1230 pClientSTA->tlPri = WLANTL_STA_PRI_NORMAL;
1231 pClientSTA->wSTADesc.ucSTAId = pwSTADescType->ucSTAId;
Gopichand Nakkala8b54e912013-03-11 10:44:21 +05301232 pClientSTA->ptkInstalled = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001233
1234 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
1235 "WLAN TL:Registering STA Client ID: %d with UC %d and BC %d",
1236 pwSTADescType->ucSTAId,
1237 pwSTADescType->ucUcastSig, pwSTADescType->ucBcastSig));
1238
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301239 pClientSTA->wSTADesc.wSTAType = pwSTADescType->wSTAType;
Jeff Johnson295189b2012-06-20 16:38:30 -07001240
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301241 pClientSTA->wSTADesc.ucQosEnabled = pwSTADescType->ucQosEnabled;
Jeff Johnson295189b2012-06-20 16:38:30 -07001242
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301243 pClientSTA->wSTADesc.ucAddRmvLLC = pwSTADescType->ucAddRmvLLC;
Jeff Johnson295189b2012-06-20 16:38:30 -07001244
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301245 pClientSTA->wSTADesc.ucProtectedFrame = pwSTADescType->ucProtectedFrame;
Jeff Johnson295189b2012-06-20 16:38:30 -07001246
1247#ifdef FEATURE_WLAN_CCX
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301248 pClientSTA->wSTADesc.ucIsCcxSta = pwSTADescType->ucIsCcxSta;
Jeff Johnson295189b2012-06-20 16:38:30 -07001249
1250 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
1251 "WLAN TL:Registering STA Client ID: %d QoS %d Add LLC %d ProtFrame %d CcxSta %d",
1252 pwSTADescType->ucSTAId,
1253 pwSTADescType->ucQosEnabled,
1254 pwSTADescType->ucAddRmvLLC,
1255 pwSTADescType->ucProtectedFrame,
1256 pwSTADescType->ucIsCcxSta));
1257#else
1258
1259 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
1260 "WLAN TL:Registering STA Client ID: %d QoS %d Add LLC %d ProtFrame %d",
1261 pwSTADescType->ucSTAId,
1262 pwSTADescType->ucQosEnabled,
1263 pwSTADescType->ucAddRmvLLC,
1264 pwSTADescType->ucProtectedFrame));
1265
1266#endif //FEATURE_WLAN_CCX
1267#ifdef WLAN_SOFTAP_VSTA_FEATURE
1268 // if this station was not allocated resources to perform HW-based
1269 // TX frame translation then force SW-based TX frame translation
1270 // otherwise use the frame translation supplied by the client
1271
1272 if (!WDA_IsHwFrameTxTranslationCapable(pvosGCtx, pwSTADescType->ucSTAId)
1273 || ( WLAN_STA_BT_AMP == pwSTADescType->wSTAType))
1274 {
1275 pwSTADescType->ucSwFrameTXXlation = 1;
1276 }
1277#endif
1278
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301279 pClientSTA->wSTADesc.ucSwFrameTXXlation = pwSTADescType->ucSwFrameTXXlation;
1280 pClientSTA->wSTADesc.ucSwFrameRXXlation = pwSTADescType->ucSwFrameRXXlation;
Jeff Johnson295189b2012-06-20 16:38:30 -07001281
1282#ifdef FEATURE_WLAN_WAPI
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301283 pClientSTA->wSTADesc.ucIsWapiSta = pwSTADescType->ucIsWapiSta;
Jeff Johnson295189b2012-06-20 16:38:30 -07001284#endif /* FEATURE_WLAN_WAPI */
1285
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301286 vos_copy_macaddr( &pClientSTA->wSTADesc.vSTAMACAddress, &pwSTADescType->vSTAMACAddress);
Jeff Johnson295189b2012-06-20 16:38:30 -07001287
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301288 vos_copy_macaddr( &pClientSTA->wSTADesc.vBSSIDforIBSS, &pwSTADescType->vBSSIDforIBSS);
Jeff Johnson295189b2012-06-20 16:38:30 -07001289
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301290 vos_copy_macaddr( &pClientSTA->wSTADesc.vSelfMACAddress, &pwSTADescType->vSelfMACAddress);
Jeff Johnson295189b2012-06-20 16:38:30 -07001291
Jeff Johnson295189b2012-06-20 16:38:30 -07001292 /* In volans release L replay check is done at TL */
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301293 pClientSTA->ucIsReplayCheckValid = pwSTADescType->ucIsReplayCheckValid;
1294 pClientSTA->ulTotalReplayPacketsDetected = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001295/*Clear replay counters of the STA on all TIDs*/
1296 for(ucTid = 0; ucTid < WLANTL_MAX_TID ; ucTid++)
1297 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301298 pClientSTA->ullReplayCounter[ucTid] = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001299 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001300
1301 /*--------------------------------------------------------------------
1302 Set the AC for the registered station to the highest priority AC
1303 Even if this AC is not supported by the station, correction will be
1304 made in the main TL loop after the supported mask is properly
1305 updated in the pending packets call
1306 --------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301307 pClientSTA->ucCurrentAC = WLANTL_AC_VO;
1308 pClientSTA->ucCurrentWeight = 0;
1309 pClientSTA->ucServicedAC = WLANTL_AC_BK;
1310 pClientSTA->ucEapolPktPending = 0;
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -07001311
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301312 vos_mem_zero( pClientSTA->aucACMask, sizeof(pClientSTA->aucACMask));
Jeff Johnson295189b2012-06-20 16:38:30 -07001313
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301314 vos_mem_zero( &pClientSTA->wUAPSDInfo, sizeof(pClientSTA->wUAPSDInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -07001315
1316 /*--------------------------------------------------------------------
1317 Reordering info and AMSDU de-aggregation
1318 --------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301319 vos_mem_zero( pClientSTA->atlBAReorderInfo,
1320 sizeof(pClientSTA->atlBAReorderInfo[0])*
Jeff Johnson295189b2012-06-20 16:38:30 -07001321 WLAN_MAX_TID);
1322
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301323 vos_mem_zero( pClientSTA->aucMPDUHeader,
Jeff Johnson295189b2012-06-20 16:38:30 -07001324 WLANTL_MPDU_HEADER_LEN);
1325
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301326 pClientSTA->ucMPDUHeaderLen = 0;
1327 pClientSTA->vosAMSDUChain = NULL;
1328 pClientSTA->vosAMSDUChainRoot = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07001329
1330
1331 /*--------------------------------------------------------------------
1332 Stats info
1333 --------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301334 vos_mem_zero( pClientSTA->auRxCount,
1335 sizeof(pClientSTA->auRxCount[0])*
Jeff Johnson295189b2012-06-20 16:38:30 -07001336 WLAN_MAX_TID);
1337
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301338 vos_mem_zero( pClientSTA->auTxCount,
1339 sizeof(pClientSTA->auRxCount[0])*
Jeff Johnson295189b2012-06-20 16:38:30 -07001340 WLAN_MAX_TID);
1341 /* Initial RSSI is always reported as zero because TL doesnt have enough
1342 data to calculate RSSI. So to avoid reporting zero, we are initializing
1343 RSSI with RSSI saved in BssDescription during scanning. */
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301344 pClientSTA->rssiAvg = rssi;
Shailender Karmuchi13c0d082013-03-26 14:41:39 -07001345#ifdef FEATURE_WLAN_TDLS
1346 if(WLAN_STA_TDLS == pClientSTA->wSTADesc.wSTAType)
1347 {
1348 /* If client is TDLS, use TDLS specific alpha */
1349 pClientSTA->rssiAlpha = WLANTL_HO_TDLS_ALPHA;
1350 }
1351 else
1352 {
1353 pClientSTA->rssiAlpha = WLANTL_HO_DEFAULT_ALPHA;
1354 }
1355#else
1356 pClientSTA->rssiAlpha = WLANTL_HO_DEFAULT_ALPHA;
1357#endif /* FEATURE_WLAN_TDLS */
Jeff Johnson295189b2012-06-20 16:38:30 -07001358
1359 /*Tx not suspended and station fully registered*/
1360 vos_atomic_set_U8(
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301361 &pClientSTA->ucTxSuspended, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07001362
1363 /* Used until multiple station support will be added*/
1364 pTLCb->ucRegisteredStaId = pwSTADescType->ucSTAId;
1365
1366 /* Save the BAP station ID for future usage */
1367 if ( WLAN_STA_BT_AMP == pwSTADescType->wSTAType )
1368 {
1369 pTLCb->tlBAPClient.ucBAPSTAId = pwSTADescType->ucSTAId;
1370 }
1371
1372 /*------------------------------------------------------------------------
1373 Statistics info
1374 -----------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301375 memset(&pClientSTA->trafficStatistics,
Jeff Johnson295189b2012-06-20 16:38:30 -07001376 0, sizeof(WLANTL_TRANSFER_STA_TYPE));
1377
1378
1379 /*------------------------------------------------------------------------
1380 Start with the state suggested by client caller
1381 -----------------------------------------------------------------------*/
Madan Mohan Koyylamudi64258222013-01-30 14:35:10 +05301382 pClientSTA->tlState = pwSTADescType->ucInitState;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301383 pClientSTA->ucRxBlocked = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07001384 /*-----------------------------------------------------------------------
1385 After all the init is complete we can mark the existance flag
1386 ----------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301387 pClientSTA->ucExists++;
Jeff Johnson295189b2012-06-20 16:38:30 -07001388
Jeff Johnson295189b2012-06-20 16:38:30 -07001389 //flow control fields init
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301390 pClientSTA->ucLwmModeEnabled = FALSE;
1391 pClientSTA->ucLwmEventReported = FALSE;
1392 pClientSTA->bmuMemConsumed = 0;
1393 pClientSTA->uIngress_length = 0;
1394 pClientSTA->uBuffThresholdMax = WLANTL_STA_BMU_THRESHOLD_MAX;
Jeff Johnson295189b2012-06-20 16:38:30 -07001395
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301396 pClientSTA->uLwmThreshold = WLANTL_STA_BMU_THRESHOLD_MAX / 3;
Jeff Johnson295189b2012-06-20 16:38:30 -07001397
1398 //@@@ HDDSOFTAP does not queue unregistered packet for now
1399 if ( WLAN_STA_SOFTAP != pwSTADescType->wSTAType )
1400 {
Jeff Johnson295189b2012-06-20 16:38:30 -07001401 /*------------------------------------------------------------------------
1402 Forward received frames while STA was not yet registered
1403 - ----------------------------------------------------------------------*/
1404 if(!VOS_IS_STATUS_SUCCESS(WLANTL_StartForwarding( pwSTADescType->ucSTAId,
1405 pwSTADescType->ucUcastSig,
1406 pwSTADescType->ucBcastSig)))
1407 {
1408 VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001409 " %s fails to start forwarding", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001410 }
Sunil Ravid5406f22013-01-22 00:18:31 -08001411#ifdef FEATURE_WLAN_TDLS
1412 if( WLAN_STA_TDLS == pwSTADescType->wSTAType )
1413 pTLCb->ucTdlsPeerCount++;
1414#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001415 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001416 return VOS_STATUS_SUCCESS;
1417}/* WLANTL_RegisterSTAClient */
1418
1419/*===========================================================================
1420
1421 FUNCTION WLANTL_ClearSTAClient
1422
1423 DESCRIPTION
1424
1425 HDD will call this API when it no longer needs data services for the
1426 particular station.
1427
1428 DEPENDENCIES
1429
1430 A station must have been registered before the clear registration is
1431 called.
1432
1433 PARAMETERS
1434
1435 pvosGCtx: pointer to the global vos context; a handle to TL's
1436 control block can be extracted from its context
1437 ucSTAId: identifier for the STA to be cleared
1438
1439 RETURN VALUE
1440
1441 The result code associated with performing the operation
1442
1443 VOS_STATUS_E_FAULT: Station ID is outside array boundaries or pointer to
1444 TL cb is NULL ; access would cause a page fault
1445 VOS_STATUS_E_EXISTS: Station was not registered
1446 VOS_STATUS_SUCCESS: Everything is good :)
1447
1448 SIDE EFFECTS
1449
1450============================================================================*/
1451VOS_STATUS
1452WLANTL_ClearSTAClient
1453(
1454 v_PVOID_t pvosGCtx,
1455 v_U8_t ucSTAId
1456)
1457{
1458 WLANTL_CbType* pTLCb = NULL;
1459 v_U8_t ucIndex;
1460 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
1461
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301462 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -07001463 /*------------------------------------------------------------------------
1464 Sanity check
1465 ------------------------------------------------------------------------*/
1466 if ( WLANTL_STA_ID_INVALID( ucSTAId ) )
1467 {
1468 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1469 "WLAN TL:Invalid station id requested on WLANTL_ClearSTAClient"));
1470 return VOS_STATUS_E_FAULT;
1471 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001472 /*------------------------------------------------------------------------
1473 Extract TL control block
1474 ------------------------------------------------------------------------*/
1475 pTLCb = VOS_GET_TL_CB(pvosGCtx);
1476 if ( NULL == pTLCb )
1477 {
1478 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1479 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_ClearSTAClient"));
1480 return VOS_STATUS_E_FAULT;
1481 }
1482
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301483 if ( NULL == pTLCb->atlSTAClients[ucSTAId] )
1484 {
1485 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1486 "WLAN TL:Client Memory was not allocated on %s", __func__));
1487 return VOS_STATUS_E_FAILURE;
1488 }
1489
1490 if ( 0 == pTLCb->atlSTAClients[ucSTAId]->ucExists )
Jeff Johnson295189b2012-06-20 16:38:30 -07001491 {
1492 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1493 "WLAN TL:Station was not previously registered on WLANTL_ClearSTAClient"));
1494 return VOS_STATUS_E_EXISTS;
1495 }
1496
1497 /* Delete BA sessions on all TID's */
1498 for ( ucIndex = 0; ucIndex < WLAN_MAX_TID ; ucIndex++)
1499 {
1500 WLANTL_BaSessionDel (pvosGCtx, ucSTAId, ucIndex);
1501 }
1502
Sunil Ravid5406f22013-01-22 00:18:31 -08001503#ifdef FEATURE_WLAN_TDLS
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301504 /* decrement ucTdlsPeerCount only if it is non-zero */
1505 if(WLAN_STA_TDLS == pTLCb->atlSTAClients[ucSTAId]->wSTADesc.wSTAType
Sunil Ravid5406f22013-01-22 00:18:31 -08001506 && pTLCb->ucTdlsPeerCount)
1507 pTLCb->ucTdlsPeerCount--;
1508#endif
1509
Jeff Johnson295189b2012-06-20 16:38:30 -07001510 /*------------------------------------------------------------------------
1511 Clear station
1512 ------------------------------------------------------------------------*/
1513 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
1514 "WLAN TL:Clearing STA Client ID: %d", ucSTAId ));
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301515 WLANTL_CleanSTA(pTLCb->atlSTAClients[ucSTAId], 1 /*empty packets*/);
Jeff Johnson295189b2012-06-20 16:38:30 -07001516
1517 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
1518 "WLAN TL:Clearing STA Reset History RSSI and Region number"));
1519 pTLCb->hoSupport.currentHOState.historyRSSI = 0;
1520 pTLCb->hoSupport.currentHOState.regionNumber = 0;
1521
1522 return VOS_STATUS_SUCCESS;
1523}/* WLANTL_ClearSTAClient */
1524
1525/*===========================================================================
1526
1527 FUNCTION WLANTL_ChangeSTAState
1528
1529 DESCRIPTION
1530
1531 HDD will make this notification whenever a change occurs in the
1532 connectivity state of a particular STA.
1533
1534 DEPENDENCIES
1535
1536 A station must have been registered before the change state can be
1537 called.
1538
1539 RESTRICTION: A station is being notified as authenticated before the
1540 keys are installed in HW. This way if a frame is received
1541 before the keys are installed DPU will drop that frame.
1542
1543 Main thread has higher priority that Tx and Rx threads thus guaranteeing
1544 the following:
1545 - a station will be in assoc state in TL before TL receives any data
1546 for it
1547
1548 PARAMETERS
1549
1550 pvosGCtx: pointer to the global vos context; a handle to TL's
1551 control block can be extracted from its context
1552 ucSTAId: identifier for the STA that is pending transmission
1553 tlSTAState: the new state of the connection to the given station
1554
1555
1556 RETURN VALUE
1557
1558 The result code associated with performing the operation
1559
1560 VOS_STATUS_E_INVAL: Input parameters are invalid
1561 VOS_STATUS_E_FAULT: Station ID is outside array boundaries or pointer to
1562 TL cb is NULL ; access would cause a page fault
1563 VOS_STATUS_E_EXISTS: Station was not registered
1564 VOS_STATUS_SUCCESS: Everything is good :)
1565
1566 SIDE EFFECTS
1567
1568============================================================================*/
1569VOS_STATUS
1570WLANTL_ChangeSTAState
1571(
1572 v_PVOID_t pvosGCtx,
1573 v_U8_t ucSTAId,
1574 WLANTL_STAStateType tlSTAState
1575)
1576{
1577 WLANTL_CbType* pTLCb = NULL;
1578 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
1579
1580 /*------------------------------------------------------------------------
1581 Sanity check
1582 ------------------------------------------------------------------------*/
1583 if ( tlSTAState >= WLANTL_STA_MAX_STATE )
1584 {
1585 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1586 "WLAN TL:Invalid parameter sent on WLANTL_ChangeSTAState"));
1587 return VOS_STATUS_E_INVAL;
1588 }
1589
1590 if ( WLANTL_STA_ID_INVALID( ucSTAId ) )
1591 {
1592 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1593 "WLAN TL:Invalid station id requested on WLANTL_ChangeSTAState"));
1594 return VOS_STATUS_E_FAULT;
1595 }
1596
1597 /*------------------------------------------------------------------------
1598 Extract TL control block and check existance
1599 ------------------------------------------------------------------------*/
1600 pTLCb = VOS_GET_TL_CB(pvosGCtx);
1601 if ( NULL == pTLCb )
1602 {
1603 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1604 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_ChangeSTAState"));
1605 return VOS_STATUS_E_FAULT;
1606 }
1607
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301608 if ( NULL == pTLCb->atlSTAClients[ucSTAId] )
1609 {
1610 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1611 "WLAN TL:Client Memory was not allocated on %s", __func__));
1612 return VOS_STATUS_E_FAILURE;
1613 }
1614
1615 if ( 0 == pTLCb->atlSTAClients[ucSTAId]->ucExists )
Jeff Johnson295189b2012-06-20 16:38:30 -07001616 {
1617 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1618 "WLAN TL:Station was not previously registered on WLANTL_ChangeSTAState"));
1619 return VOS_STATUS_E_EXISTS;
1620 }
1621
1622 /*------------------------------------------------------------------------
1623 Change STA state
1624 No need to lock this operation, see restrictions above
1625 ------------------------------------------------------------------------*/
1626 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
1627 "WLAN TL:Changing state for STA Client ID: %d from %d to %d",
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301628 ucSTAId, pTLCb->atlSTAClients[ucSTAId]->tlState, tlSTAState));
Jeff Johnson295189b2012-06-20 16:38:30 -07001629
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301630 pTLCb->atlSTAClients[ucSTAId]->tlState = tlSTAState;
Jeff Johnson295189b2012-06-20 16:38:30 -07001631
1632 return VOS_STATUS_SUCCESS;
1633}/* WLANTL_ChangeSTAState */
1634
1635/*===========================================================================
1636
Gopichand Nakkala8b54e912013-03-11 10:44:21 +05301637 FUNCTION WLANTL_STAPtkInstalled
1638
1639 DESCRIPTION
1640
1641 HDD will make this notification whenever PTK is installed for the STA
1642
1643 DEPENDENCIES
1644
1645 A station must have been registered before the change state can be
1646 called.
1647
1648 PARAMETERS
1649
1650 pvosGCtx: pointer to the global vos context; a handle to TL's
1651 control block can be extracted from its context
1652 ucSTAId: identifier for the STA for which Pairwise key is
1653 installed
1654
1655 RETURN VALUE
1656
1657 The result code associated with performing the operation
1658
1659 VOS_STATUS_E_FAULT: Station ID is outside array boundaries or pointer to
1660 TL cb is NULL ; access would cause a page fault
1661 VOS_STATUS_E_EXISTS: Station was not registered
1662 VOS_STATUS_SUCCESS: Everything is good :)
1663
1664 SIDE EFFECTS
1665
1666============================================================================*/
1667VOS_STATUS
1668WLANTL_STAPtkInstalled
1669(
1670 v_PVOID_t pvosGCtx,
1671 v_U8_t ucSTAId
1672)
1673{
1674 WLANTL_CbType* pTLCb = NULL;
1675 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
1676
1677 /*------------------------------------------------------------------------
1678 Sanity check
1679 ------------------------------------------------------------------------*/
1680
1681 if ( WLANTL_STA_ID_INVALID( ucSTAId ) )
1682 {
1683 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1684 "WLAN TL:Invalid station id requested on WLANTL_ChangeSTAState"));
1685 return VOS_STATUS_E_FAULT;
1686 }
1687
1688 /*------------------------------------------------------------------------
1689 Extract TL control block and check existance
1690 ------------------------------------------------------------------------*/
1691 pTLCb = VOS_GET_TL_CB(pvosGCtx);
1692 if ( NULL == pTLCb )
1693 {
1694 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1695 FL("WLAN TL:Invalid TL pointer from pvosGCtx")));
1696 return VOS_STATUS_E_FAULT;
1697 }
1698
1699 if ( NULL == pTLCb->atlSTAClients[ucSTAId] )
1700 {
1701 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1702 FL("WLAN TL:Client Memory was not allocated")));
1703 return VOS_STATUS_E_FAILURE;
1704 }
1705
1706 if ( 0 == pTLCb->atlSTAClients[ucSTAId]->ucExists )
1707 {
1708 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1709 FL("WLAN TL:Station was not previously registered")));
1710 return VOS_STATUS_E_EXISTS;
1711 }
1712
1713 pTLCb->atlSTAClients[ucSTAId]->ptkInstalled = 1;
1714
1715 return VOS_STATUS_SUCCESS;
1716}/* WLANTL_STAPtkInstalled */
1717
1718/*===========================================================================
1719
Madan Mohan Koyyalamudifc1d1fe2012-10-18 15:07:12 -07001720 FUNCTION WLANTL_GetSTAState
1721
1722 DESCRIPTION
1723
1724 Returns connectivity state of a particular STA.
1725
1726 DEPENDENCIES
1727
1728 A station must have been registered before its state can be retrieved.
1729
1730
1731 PARAMETERS
1732
1733 IN
1734 pvosGCtx: pointer to the global vos context; a handle to TL's
1735 control block can be extracted from its context
1736 ucSTAId: identifier of the station
1737
1738 OUT
1739 ptlSTAState: the current state of the connection to the given station
1740
1741
1742 RETURN VALUE
1743
1744 The result code associated with performing the operation
1745
1746 VOS_STATUS_E_INVAL: Input parameters are invalid
1747 VOS_STATUS_E_FAULT: Station ID is outside array boundaries or pointer to
1748 TL cb is NULL ; access would cause a page fault
1749 VOS_STATUS_E_EXISTS: Station was not registered
1750 VOS_STATUS_SUCCESS: Everything is good :)
1751
1752 SIDE EFFECTS
1753
1754============================================================================*/
1755VOS_STATUS
1756WLANTL_GetSTAState
1757(
1758 v_PVOID_t pvosGCtx,
1759 v_U8_t ucSTAId,
1760 WLANTL_STAStateType *ptlSTAState
1761)
1762{
1763 WLANTL_CbType* pTLCb = NULL;
1764 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
1765
1766 /*------------------------------------------------------------------------
1767 Sanity check
1768 ------------------------------------------------------------------------*/
1769 if ( NULL == ptlSTAState )
1770 {
1771 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1772 "WLAN TL:Invalid parameter sent on WLANTL_GetSTAState"));
1773 return VOS_STATUS_E_INVAL;
1774 }
1775
1776 if ( WLANTL_STA_ID_INVALID( ucSTAId ) )
1777 {
1778 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1779 "WLAN TL:Invalid station id requested on WLANTL_GetSTAState"));
1780 return VOS_STATUS_E_FAULT;
1781 }
1782
1783 /*------------------------------------------------------------------------
1784 Extract TL control block and check existance
1785 ------------------------------------------------------------------------*/
1786 pTLCb = VOS_GET_TL_CB(pvosGCtx);
1787 if ( NULL == pTLCb )
1788 {
1789 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1790 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_GetSTAState"));
1791 return VOS_STATUS_E_FAULT;
1792 }
1793
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301794 if ( NULL == pTLCb->atlSTAClients[ucSTAId] )
1795 {
1796 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1797 "WLAN TL:Client Memory was not allocated on %s", __func__));
1798 return VOS_STATUS_E_FAILURE;
1799 }
1800
1801 if ( 0 == pTLCb->atlSTAClients[ucSTAId]->ucExists )
Madan Mohan Koyyalamudifc1d1fe2012-10-18 15:07:12 -07001802 {
Sunil Ravid5406f22013-01-22 00:18:31 -08001803 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
Madan Mohan Koyyalamudifc1d1fe2012-10-18 15:07:12 -07001804 "WLAN TL:Station was not previously registered on WLANTL_GetSTAState"));
1805 return VOS_STATUS_E_EXISTS;
1806 }
1807
1808 /*------------------------------------------------------------------------
1809 Get STA state
1810 ------------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301811 *ptlSTAState = pTLCb->atlSTAClients[ucSTAId]->tlState;
Madan Mohan Koyyalamudifc1d1fe2012-10-18 15:07:12 -07001812
1813 return VOS_STATUS_SUCCESS;
1814}/* WLANTL_GetSTAState */
1815
Shailender Karmuchia734f332013-04-19 14:02:48 -07001816/*==========================================================================
1817 FUNCTION WLANTL_UpdateSTABssIdforIBSS
1818
1819 DESCRIPTION
1820 HDD will call this API to update the BSSID for this Station.
1821
1822 DEPENDENCIES
1823 The HDD Should registered the staID with TL before calling this function.
1824
1825 PARAMETERS
1826
1827 IN
1828 pvosGCtx: Pointer to the global vos context; a handle to TL's
1829 or WDA's control block can be extracted from its context
1830 IN
1831 ucSTAId The Station ID for Bssid to be updated
1832 IN
1833 pBssid BSSID to be updated
1834
1835 RETURN VALUE
1836 The result code associated with performing the operation
1837
1838 VOS_STATUS_E_INVAL: Input parameters are invalid
1839 VOS_STATUS_E_FAULT: Station ID is outside array boundaries or pointer to
1840 TL cb is NULL ; access would cause a page fault
1841 VOS_STATUS_E_EXISTS: Station was not registered
1842 VOS_STATUS_SUCCESS: Everything is good :)
1843
1844 SIDE EFFECTS
1845============================================================================*/
1846
1847
1848VOS_STATUS
1849WLANTL_UpdateSTABssIdforIBSS
1850(
1851 v_PVOID_t pvosGCtx,
1852 v_U8_t ucSTAId,
1853 v_U8_t *pBssid
1854)
1855{
1856 WLANTL_CbType* pTLCb = NULL;
1857 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
1858
1859 /*------------------------------------------------------------------------
1860 Sanity check
1861 ------------------------------------------------------------------------*/
1862 if ( WLANTL_STA_ID_INVALID( ucSTAId ) )
1863 {
1864 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1865 "WLAN TL:Invalid station id requested %s", __func__));
1866 return VOS_STATUS_E_FAULT;
1867 }
1868
1869 /*------------------------------------------------------------------------
1870 Extract TL control block and check existance
1871 ------------------------------------------------------------------------*/
1872 pTLCb = VOS_GET_TL_CB(pvosGCtx);
1873 if ( NULL == pTLCb )
1874 {
1875 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1876 "WLAN TL:Invalid TL pointer from pvosGCtx %s", __func__));
1877 return VOS_STATUS_E_FAULT;
1878 }
1879
1880 if ( NULL == pTLCb->atlSTAClients[ucSTAId] )
1881 {
1882 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1883 "WLAN TL:Client Memory was not allocated on %s", __func__));
1884 return VOS_STATUS_E_FAILURE;
1885 }
1886
1887 if ( 0 == pTLCb->atlSTAClients[ucSTAId]->ucExists )
1888 {
1889 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
1890 "WLAN TL:Station was not previously registered %s", __func__));
1891 return VOS_STATUS_E_EXISTS;
1892 }
1893
1894 /*------------------------------------------------------------------------
1895 Update the IBSS BSSID
1896 ------------------------------------------------------------------------*/
1897 vos_mem_copy( &pTLCb->atlSTAClients[ucSTAId]->wSTADesc.vBSSIDforIBSS,
1898 pBssid, sizeof(v_MACADDR_t));
1899
1900 return VOS_STATUS_SUCCESS;
1901}
1902
Madan Mohan Koyyalamudifc1d1fe2012-10-18 15:07:12 -07001903/*===========================================================================
1904
Jeff Johnson295189b2012-06-20 16:38:30 -07001905 FUNCTION WLANTL_STAPktPending
1906
1907 DESCRIPTION
1908
1909 HDD will call this API when a packet is pending transmission in its
1910 queues.
1911
1912 DEPENDENCIES
1913
1914 A station must have been registered before the packet pending
1915 notification can be sent.
1916
1917 RESTRICTION: TL will not count packets for pending notification.
1918 HDD is expected to send the notification only when
1919 non-empty event gets triggered. Worst case scenario
1920 is that TL might end up making a call when Hdds
1921 queues are actually empty.
1922
1923 PARAMETERS
1924
1925 pvosGCtx: pointer to the global vos context; a handle to TL's
1926 control block can be extracted from its context
1927 ucSTAId: identifier for the STA that is pending transmission
1928
1929 RETURN VALUE
1930
1931 The result code associated with performing the operation
1932
1933 VOS_STATUS_E_INVAL: Input parameters are invalid
1934 VOS_STATUS_E_FAULT: Station ID is outside array boundaries or pointer
1935 to TL cb is NULL ; access would cause a page fault
1936 VOS_STATUS_E_EXISTS: Station was not registered
1937 VOS_STATUS_SUCCESS: Everything is good :)
1938
1939 SIDE EFFECTS
1940
1941============================================================================*/
1942VOS_STATUS
1943WLANTL_STAPktPending
1944(
1945 v_PVOID_t pvosGCtx,
1946 v_U8_t ucSTAId,
1947 WLANTL_ACEnumType ucAc
1948)
1949{
1950 WLANTL_CbType* pTLCb = NULL;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301951 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07001952 vos_msg_t vosMsg;
Jeff Johnson295189b2012-06-20 16:38:30 -07001953 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
1954
1955 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
1956 "WLAN TL:Packet pending indication for STA: %d AC: %d", ucSTAId, ucAc);
1957
1958 /*------------------------------------------------------------------------
1959 Sanity check
1960 ------------------------------------------------------------------------*/
1961 if ( WLANTL_STA_ID_INVALID( ucSTAId ) )
1962 {
1963 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1964 "WLAN TL:Invalid station id requested on WLANTL_STAPktPending"));
1965 return VOS_STATUS_E_FAULT;
1966 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001967 /*------------------------------------------------------------------------
1968 Extract TL control block and check existance
1969 ------------------------------------------------------------------------*/
1970 pTLCb = VOS_GET_TL_CB(pvosGCtx);
1971 if ( NULL == pTLCb )
1972 {
1973 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1974 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_STAPktPending"));
1975 return VOS_STATUS_E_FAULT;
1976 }
1977
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301978 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
1979
1980 if ( NULL == pClientSTA )
1981 {
1982 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1983 "WLAN TL:Client Memory was not allocated on %s", __func__));
1984 return VOS_STATUS_E_FAILURE;
1985 }
1986
1987 if ( 0 == pClientSTA->ucExists )
Jeff Johnson295189b2012-06-20 16:38:30 -07001988 {
1989 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1990 "WLAN TL:Station was not previously registered on WLANTL_STAPktPending"));
1991 return VOS_STATUS_E_EXISTS;
1992 }
1993
1994 /*---------------------------------------------------------------------
1995 Temporary fix to enable TL to fetch packets when multiple peers join
1996 an IBSS. To fix CR177301. Needs to go away when the actual fix of
1997 going through all STA's in round robin fashion gets merged in from
1998 BT AMP branch.
1999 --------------------------------------------------------------------*/
2000 pTLCb->ucRegisteredStaId = ucSTAId;
2001
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302002 if( WLANTL_STA_CONNECTED == pClientSTA->tlState )
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -07002003 { /* EAPOL_HI_PRIORITY : need to find out whether EAPOL is pending before
2004 WLANTL_FetchPacket()/WLANTL_TxConn() is called.
2005 change STA_AUTHENTICATED != tlState to CONNECTED == tlState
2006 to make sure TL is indeed waiting for EAPOL.
2007 Just in the case when STA got disconnected shortly after connectection */
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302008 pClientSTA->ucEapolPktPending = 1;
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -07002009
2010 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07002011 "WLAN TL:Packet pending indication for STA: %d AC: %d State: %d",
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302012 ucSTAId, ucAc, pClientSTA->tlState);
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07002013 }
2014
Jeff Johnson295189b2012-06-20 16:38:30 -07002015 /*-----------------------------------------------------------------------
2016 Enable this AC in the AC mask in order for TL to start servicing it
2017 Set packet pending flag
2018 To avoid race condition, serialize the updation of AC and AC mask
2019 through WLANTL_TX_STAID_AC_IND message.
2020 -----------------------------------------------------------------------*/
Sunil Ravid5406f22013-01-22 00:18:31 -08002021#ifdef FETURE_WLAN_TDLS
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302022 if ((WLAN_STA_SOFTAP != pClientSTA->wSTADesc.wSTAType) &&
Sunil Ravid5406f22013-01-22 00:18:31 -08002023 !(vos_concurrent_sessions_running()) &&
2024 !pTLCb->ucTdlsPeerCount)
2025 {
2026#else
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302027 if ((WLAN_STA_SOFTAP != pClientSTA->wSTADesc.wSTAType) &&
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -07002028 !(vos_concurrent_sessions_running()))
Jeff Johnson295189b2012-06-20 16:38:30 -07002029 {
2030#endif
2031
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302032 pClientSTA->aucACMask[ucAc] = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07002033
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302034 vos_atomic_set_U8( &pClientSTA->ucPktPending, 1);
Jeff Johnson295189b2012-06-20 16:38:30 -07002035
2036 /*------------------------------------------------------------------------
2037 Check if there are enough resources for transmission and tx is not
2038 suspended.
2039 ------------------------------------------------------------------------*/
Madan Mohan Koyyalamudi24a00f92012-10-22 15:21:02 -07002040 if (( pTLCb->uResCount >= WDA_TLI_MIN_RES_DATA ) &&
2041 ( 0 == pTLCb->ucTxSuspended ))
Jeff Johnson295189b2012-06-20 16:38:30 -07002042 {
2043 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
2044 "Issuing Xmit start request to BAL"));
2045 WDA_DS_StartXmit(pvosGCtx);
2046 }
2047 else
2048 {
2049 /*---------------------------------------------------------------------
2050 No error code is sent because TL will resume tx autonomously if
2051 resources become available or tx gets resumed
2052 ---------------------------------------------------------------------*/
Madan Mohan Koyyalamudi179e6fe2012-10-15 15:31:08 -07002053 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
Jeff Johnson295189b2012-06-20 16:38:30 -07002054 "WLAN TL:Request to send but condition not met. Res: %d,Suspend: %d",
Madan Mohan Koyyalamudi48139e32012-10-11 14:43:56 -07002055 pTLCb->uResCount, pTLCb->ucTxSuspended );
Jeff Johnson295189b2012-06-20 16:38:30 -07002056 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002057 }
2058 else
2059 {
2060 vosMsg.reserved = 0;
2061 vosMsg.bodyval = 0;
2062 vosMsg.bodyval = (ucAc | (ucSTAId << WLANTL_STAID_OFFSET));
2063 vosMsg.type = WLANTL_TX_STAID_AC_IND;
2064 return vos_tx_mq_serialize( VOS_MQ_ID_TL, &vosMsg);
2065 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002066 return VOS_STATUS_SUCCESS;
2067}/* WLANTL_STAPktPending */
2068
2069/*==========================================================================
2070
2071 FUNCTION WLANTL_SetSTAPriority
2072
2073 DESCRIPTION
2074
2075 TL exposes this API to allow upper layers a rough control over the
2076 priority of transmission for a given station when supporting multiple
2077 connections.
2078
2079 DEPENDENCIES
2080
2081 A station must have been registered before the change in priority can be
2082 called.
2083
2084 PARAMETERS
2085
2086 pvosGCtx: pointer to the global vos context; a handle to TL's
2087 control block can be extracted from its context
2088 ucSTAId: identifier for the STA that has to change priority
2089
2090 RETURN VALUE
2091
2092 The result code associated with performing the operation
2093
2094 VOS_STATUS_E_INVAL: Input parameters are invalid
2095 VOS_STATUS_E_FAULT: Station ID is outside array boundaries or pointer
2096 to TL cb is NULL ; access would cause a page fault
2097 VOS_STATUS_E_EXISTS: Station was not registered
2098 VOS_STATUS_SUCCESS: Everything is good :)
2099
2100 SIDE EFFECTS
2101
2102============================================================================*/
2103VOS_STATUS
2104WLANTL_SetSTAPriority
2105(
2106 v_PVOID_t pvosGCtx,
2107 v_U8_t ucSTAId,
2108 WLANTL_STAPriorityType tlSTAPri
2109)
2110{
2111 WLANTL_CbType* pTLCb = NULL;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302112 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002113 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
2114
2115 /*------------------------------------------------------------------------
2116 Sanity check
2117 ------------------------------------------------------------------------*/
2118 if ( WLANTL_STA_ID_INVALID( ucSTAId ) )
2119 {
2120 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2121 "WLAN TL:Invalid station id requested on WLANTL_SetSTAPriority"));
2122 return VOS_STATUS_E_FAULT;
2123 }
2124
2125 /*------------------------------------------------------------------------
2126 Extract TL control block
2127 ------------------------------------------------------------------------*/
2128 pTLCb = VOS_GET_TL_CB(pvosGCtx);
2129 if ( NULL == pTLCb )
2130 {
2131 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2132 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_SetSTAPriority"));
2133 return VOS_STATUS_E_FAULT;
2134 }
2135
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302136 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
2137
2138 if ( NULL == pClientSTA )
2139 {
2140 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2141 "WLAN TL:Client Memory was not allocated on %s", __func__));
2142 return VOS_STATUS_E_FAILURE;
2143 }
2144
2145 if ( 0 == pClientSTA->ucExists )
Jeff Johnson295189b2012-06-20 16:38:30 -07002146 {
2147 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2148 "WLAN TL:Station was not previously registered on WLANTL_SetSTAPriority"));
2149 return VOS_STATUS_E_EXISTS;
2150 }
2151
2152 /*------------------------------------------------------------------------
2153 Re-analize if lock is needed when adding multiple stations
2154 ------------------------------------------------------------------------*/
2155 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
2156 "WLAN TL:Changing state for STA Pri ID: %d from %d to %d",
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302157 ucSTAId, pClientSTA->tlPri, tlSTAPri));
2158 pClientSTA->tlPri = tlSTAPri;
Jeff Johnson295189b2012-06-20 16:38:30 -07002159
2160 return VOS_STATUS_SUCCESS;
2161}/* WLANTL_SetSTAPriority */
2162
2163
2164/*----------------------------------------------------------------------------
2165 INTERACTION WITH BAP
2166 ---------------------------------------------------------------------------*/
2167
2168/*==========================================================================
2169
2170 FUNCTION WLANTL_RegisterBAPClient
2171
2172 DESCRIPTION
2173 Called by SME to register itself as client for non-data BT-AMP packets.
2174
2175 DEPENDENCIES
2176 TL must be initialized before this function can be called.
2177
2178 PARAMETERS
2179
2180 IN
2181 pvosGCtx: pointer to the global vos context; a handle to TL's
2182 or SME's control block can be extracted from its context
2183 pfnTlBAPRxFrm: pointer to the receive processing routine for non-data
2184 BT-AMP packets
2185 pfnFlushOpCompleteCb:
2186 pointer to the call back function, for the Flush operation
2187 completion.
2188
2189
2190 RETURN VALUE
2191
2192 The result code associated with performing the operation
2193
2194 VOS_STATUS_E_INVAL: Input parameters are invalid
2195 VOS_STATUS_E_FAULT: Station ID is outside array boundaries or pointer
2196 to TL cb is NULL ; access would cause a page fault
2197 VOS_STATUS_E_EXISTS: BAL client was already registered
2198 VOS_STATUS_SUCCESS: Everything is good :)
2199
2200 SIDE EFFECTS
2201
2202============================================================================*/
2203VOS_STATUS
2204WLANTL_RegisterBAPClient
2205(
2206 v_PVOID_t pvosGCtx,
2207 WLANTL_BAPRxCBType pfnTlBAPRxFrm,
2208 WLANTL_FlushOpCompCBType pfnFlushOpCompleteCb
2209)
2210{
2211 WLANTL_CbType* pTLCb = NULL;
2212 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
2213
2214 /*------------------------------------------------------------------------
2215 Sanity check
2216 ------------------------------------------------------------------------*/
2217 if ( NULL == pfnTlBAPRxFrm )
2218 {
2219 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2220 "WLAN TL:Invalid parameter sent on WLANTL_RegisterBAPClient"));
2221 return VOS_STATUS_E_INVAL;
2222 }
2223
2224 if ( NULL == pfnFlushOpCompleteCb )
2225 {
2226 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2227 "Invalid Flush Complete Cb parameter sent on WLANTL_RegisterBAPClient"));
2228 return VOS_STATUS_E_INVAL;
2229 }
2230
2231 /*------------------------------------------------------------------------
2232 Extract TL control block
2233 ------------------------------------------------------------------------*/
2234 pTLCb = VOS_GET_TL_CB(pvosGCtx);
2235 if ( NULL == pTLCb )
2236 {
2237 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2238 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_RegisterBAPClient"));
2239 return VOS_STATUS_E_FAULT;
2240 }
2241
2242 /*------------------------------------------------------------------------
2243 Make sure this is the first registration attempt
2244 ------------------------------------------------------------------------*/
2245 if ( 0 != pTLCb->tlBAPClient.ucExists )
2246 {
2247 pTLCb->tlBAPClient.ucExists++;
2248 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2249 "WLAN TL:BAP client was already registered"));
2250 return VOS_STATUS_E_EXISTS;
2251 }
2252
2253 /*------------------------------------------------------------------------
2254 Register station with TL
2255 ------------------------------------------------------------------------*/
2256 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
2257 "WLAN TL:Registering BAP Client" ));
2258
2259 pTLCb->tlBAPClient.ucExists++;
2260
2261 if ( NULL != pfnTlBAPRxFrm )
2262 {
2263 pTLCb->tlBAPClient.pfnTlBAPRx = pfnTlBAPRxFrm;
2264 }
2265
2266 pTLCb->tlBAPClient.pfnFlushOpCompleteCb = pfnFlushOpCompleteCb;
2267
2268 pTLCb->tlBAPClient.vosPendingDataBuff = NULL;
2269
2270 return VOS_STATUS_SUCCESS;
2271}/* WLANTL_RegisterBAPClient */
2272
2273
2274/*==========================================================================
2275
2276 FUNCTION WLANTL_TxBAPFrm
2277
2278 DESCRIPTION
2279 BAP calls this when it wants to send a frame to the module
2280
2281 DEPENDENCIES
2282 BAP must be registered with TL before this function can be called.
2283
2284 RESTRICTION: BAP CANNOT push any packets to TL until it did not receive
2285 a tx complete from the previous packet, that means BAP
2286 sends one packet, wait for tx complete and then
2287 sends another one
2288
2289 If BAP sends another packet before TL manages to process the
2290 previously sent packet call will end in failure
2291
2292 PARAMETERS
2293
2294 IN
2295 pvosGCtx: pointer to the global vos context; a handle to TL's
2296 or BAP's control block can be extracted from its context
2297 vosDataBuff: pointer to the vOSS buffer containing the packet to be
2298 transmitted
2299 pMetaInfo: meta information about the packet
2300 pfnTlBAPTxComp: pointer to a transmit complete routine for notifying
2301 the result of the operation over the bus
2302
2303 RETURN VALUE
2304 The result code associated with performing the operation
2305
2306 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
2307 page fault
2308 VOS_STATUS_E_EXISTS: BAL client was not yet registered
2309 VOS_STATUS_E_BUSY: The previous BT-AMP packet was not yet transmitted
2310 VOS_STATUS_SUCCESS: Everything is good :)
2311
2312 Other failure messages may be returned from the BD header handling
2313 routines, please check apropriate API for more info.
2314
2315 SIDE EFFECTS
2316
2317============================================================================*/
2318VOS_STATUS
2319WLANTL_TxBAPFrm
2320(
2321 v_PVOID_t pvosGCtx,
2322 vos_pkt_t* vosDataBuff,
2323 WLANTL_MetaInfoType* pMetaInfo,
2324 WLANTL_TxCompCBType pfnTlBAPTxComp
2325)
2326{
2327 WLANTL_CbType* pTLCb = NULL;
2328 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
2329 v_MACADDR_t vDestMacAddr;
2330 v_U16_t usPktLen;
2331 v_U8_t ucStaId = 0;
2332 v_U8_t extraHeadSpace = 0;
2333 v_U8_t ucWDSEnabled = 0;
2334 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
2335
2336 /*------------------------------------------------------------------------
2337 Sanity check
2338 Extract TL control block
2339 ------------------------------------------------------------------------*/
2340 pTLCb = VOS_GET_TL_CB(pvosGCtx);
2341 if ( NULL == pTLCb )
2342 {
2343 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2344 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_TxBAPFrm"));
2345 return VOS_STATUS_E_FAULT;
2346 }
2347
2348 /*------------------------------------------------------------------------
2349 Ensure that BAP client was registered previously
2350 ------------------------------------------------------------------------*/
2351 if (( 0 == pTLCb->tlBAPClient.ucExists ) ||
2352 ( WLANTL_STA_ID_INVALID(pTLCb->tlBAPClient.ucBAPSTAId) ))
2353 {
2354 pTLCb->tlBAPClient.ucExists++;
2355 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2356 "WLAN TL:BAP client not register on WLANTL_TxBAPFrm"));
2357 return VOS_STATUS_E_EXISTS;
2358 }
2359
2360 /*------------------------------------------------------------------------
2361 Check if any BT-AMP Frm is pending
2362 ------------------------------------------------------------------------*/
2363 if ( NULL != pTLCb->tlBAPClient.vosPendingDataBuff )
2364 {
2365 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2366 "WLAN TL:BT-AMP Frame already pending tx in TL on WLANTL_TxBAPFrm"));
2367 return VOS_STATUS_E_BUSY;
2368 }
2369
2370 /*------------------------------------------------------------------------
2371 Save buffer and notify BAL; no lock is needed if the above restriction
2372 is met
2373 Save the tx complete fnct pointer as tl specific data in the vos buffer
2374 ------------------------------------------------------------------------*/
2375
2376 /*------------------------------------------------------------------------
2377 Translate 802.3 frame to 802.11
2378 ------------------------------------------------------------------------*/
2379 ucStaId = pTLCb->tlBAPClient.ucBAPSTAId;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302380 if ( NULL == pTLCb->atlSTAClients[ucStaId] )
2381 {
2382 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2383 "WLAN TL:Client Memory was not allocated on %s", __func__));
2384 return VOS_STATUS_E_FAILURE;
2385 }
2386 if (( 0 == pMetaInfo->ucDisableFrmXtl ) &&
2387 ( 0 != pTLCb->atlSTAClients[ucStaId]->wSTADesc.ucSwFrameTXXlation ))
Jeff Johnson295189b2012-06-20 16:38:30 -07002388 {
Kiran Venkatappacab0d352012-12-17 13:09:22 -08002389 vosStatus = WLANTL_Translate8023To80211Header( vosDataBuff, &vosStatus,
2390 pTLCb, &ucStaId,
Ravi Joshid0699502013-07-08 15:48:47 -07002391 pMetaInfo, &ucWDSEnabled,
2392 &extraHeadSpace);
Jeff Johnson295189b2012-06-20 16:38:30 -07002393
2394 if ( VOS_STATUS_SUCCESS != vosStatus )
2395 {
2396 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2397 "WLAN TL:Error when translating header WLANTL_TxBAPFrm"));
2398
2399 return vosStatus;
2400 }
2401
2402 pMetaInfo->ucDisableFrmXtl = 1;
2403 }
2404
2405 /*-------------------------------------------------------------------------
2406 Call HAL to fill BD header
2407 -------------------------------------------------------------------------*/
2408
2409 /* Adding Type, SubType which was missing for EAPOL from BAP */
2410 pMetaInfo->ucType |= (WLANTL_80211_DATA_TYPE << 4);
2411 pMetaInfo->ucType |= (WLANTL_80211_DATA_QOS_SUBTYPE);
2412
2413 vosStatus = WDA_DS_BuildTxPacketInfo( pvosGCtx, vosDataBuff ,
2414 &vDestMacAddr, pMetaInfo->ucDisableFrmXtl,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302415 &usPktLen, pTLCb->atlSTAClients[ucStaId]->wSTADesc.ucQosEnabled,
Jeff Johnson295189b2012-06-20 16:38:30 -07002416 ucWDSEnabled, extraHeadSpace, pMetaInfo->ucType,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302417 &pTLCb->atlSTAClients[ucStaId]->wSTADesc.vSelfMACAddress,
Jeff Johnson295189b2012-06-20 16:38:30 -07002418 pMetaInfo->ucTID, 0 /* No ACK */, pMetaInfo->usTimeStamp,
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -07002419 pMetaInfo->ucIsEapol || pMetaInfo->ucIsWai, pMetaInfo->ucUP );
Jeff Johnson295189b2012-06-20 16:38:30 -07002420
2421 if ( VOS_STATUS_SUCCESS != vosStatus )
2422 {
2423 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2424 "WLAN TL:Failed while building TX header %d", vosStatus));
2425 return vosStatus;
2426 }
2427
2428 if ( NULL != pfnTlBAPTxComp )
2429 {
2430 vos_pkt_set_user_data_ptr( vosDataBuff, VOS_PKT_USER_DATA_ID_TL,
2431 (v_PVOID_t)pfnTlBAPTxComp);
2432 }
2433 else
2434 {
2435 vos_pkt_set_user_data_ptr( vosDataBuff, VOS_PKT_USER_DATA_ID_TL,
2436 (v_PVOID_t)WLANTL_TxCompDefaultCb);
2437
2438 }
2439
2440 vos_atomic_set_U32( (v_U32_t*)&pTLCb->tlBAPClient.vosPendingDataBuff,
2441 (v_U32_t)vosDataBuff);
2442
2443 /*------------------------------------------------------------------------
2444 Check if thre are enough resources for transmission and tx is not
2445 suspended.
2446 ------------------------------------------------------------------------*/
2447 if (( pTLCb->uResCount >= WDA_TLI_MIN_RES_BAP ) &&
2448 ( 0 == pTLCb->ucTxSuspended ))
2449 {
2450 WDA_DS_StartXmit(pvosGCtx);
2451 }
2452 else
2453 {
2454 /*---------------------------------------------------------------------
2455 No error code is sent because TL will resume tx autonomously if
2456 resources become available or tx gets resumed
2457 ---------------------------------------------------------------------*/
2458 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
2459 "WLAN TL:Request to send from BAP but condition not met.Res: %d,"
2460 "Suspend: %d", pTLCb->uResCount, pTLCb->ucTxSuspended ));
2461 }
2462
2463 return VOS_STATUS_SUCCESS;
2464}/* WLANTL_TxBAPFrm */
2465
2466
2467/*----------------------------------------------------------------------------
2468 INTERACTION WITH SME
2469 ---------------------------------------------------------------------------*/
2470
2471/*==========================================================================
2472
2473 FUNCTION WLANTL_GetRssi
2474
2475 DESCRIPTION
2476 TL will extract the RSSI information from every data packet from the
2477 ongoing traffic and will store it. It will provide the result to SME
2478 upon request.
2479
2480 DEPENDENCIES
2481
2482 WARNING: the read and write of this value will not be protected
2483 by locks, therefore the information obtained after a read
2484 might not always be consistent.
2485
2486 PARAMETERS
2487
2488 IN
2489 pvosGCtx: pointer to the global vos context; a handle to TL's
2490 or SME's control block can be extracted from its context
2491 ucSTAId: station identifier for the requested value
2492
2493 OUT
2494 puRssi: the average value of the RSSI
2495
2496
2497 RETURN VALUE
2498 The result code associated with performing the operation
2499
2500 VOS_STATUS_E_INVAL: Input parameters are invalid
2501 VOS_STATUS_E_FAULT: Station ID is outside array boundaries or pointer
2502 to TL cb is NULL ; access would cause a page fault
2503 VOS_STATUS_E_EXISTS: STA was not yet registered
2504 VOS_STATUS_SUCCESS: Everything is good :)
2505
2506 SIDE EFFECTS
2507
2508============================================================================*/
2509VOS_STATUS
2510WLANTL_GetRssi
2511(
2512 v_PVOID_t pvosGCtx,
2513 v_U8_t ucSTAId,
2514 v_S7_t* pRssi
2515)
2516{
2517 WLANTL_CbType* pTLCb = NULL;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302518 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002519 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
2520
2521 /*------------------------------------------------------------------------
2522 Sanity check
2523 ------------------------------------------------------------------------*/
2524 if ( NULL == pRssi )
2525 {
2526 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2527 "WLAN TL:Invalid parameter sent on WLANTL_GetRssi"));
2528 return VOS_STATUS_E_INVAL;
2529 }
2530
2531 if ( WLANTL_STA_ID_INVALID( ucSTAId ) )
2532 {
2533 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2534 "WLAN TL:Invalid station id requested on WLANTL_GetRssi"));
2535 return VOS_STATUS_E_FAULT;
2536 }
2537
2538 /*------------------------------------------------------------------------
2539 Extract TL control block and check existance
2540 ------------------------------------------------------------------------*/
2541 pTLCb = VOS_GET_TL_CB(pvosGCtx);
2542 if ( NULL == pTLCb )
2543 {
2544 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2545 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_GetRssi"));
2546 return VOS_STATUS_E_FAULT;
2547 }
2548
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302549 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
2550
2551 if ( NULL == pClientSTA )
2552 {
2553 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2554 "WLAN TL:Client Memory was not allocated on %s", __func__));
2555 return VOS_STATUS_E_FAILURE;
2556 }
2557
2558 if ( 0 == pClientSTA->ucExists )
Jeff Johnson295189b2012-06-20 16:38:30 -07002559 {
2560 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2561 "WLAN TL:Station was not previously registered on WLANTL_GetRssi"));
2562 return VOS_STATUS_E_EXISTS;
2563 }
2564
2565 /*------------------------------------------------------------------------
2566 Copy will not be locked; please read restriction
2567 ------------------------------------------------------------------------*/
2568 if(pTLCb->isBMPS)
2569 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302570 *pRssi = pClientSTA->rssiAvgBmps;
Jeff Johnson295189b2012-06-20 16:38:30 -07002571 /* Check If RSSI is zero because we are reading rssAvgBmps updated by HAL in
2572 previous GetStatsRequest. It may be updated as zero by Hal because EnterBmps
2573 might not have happend by that time. Hence reading the most recent Rssi
2574 calcluated by TL*/
2575 if(0 == *pRssi)
2576 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302577 *pRssi = pClientSTA->rssiAvg;
Jeff Johnson295189b2012-06-20 16:38:30 -07002578 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002579 }
2580 else
2581 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302582 *pRssi = pClientSTA->rssiAvg;
Jeff Johnson295189b2012-06-20 16:38:30 -07002583 }
2584
2585 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
Jeff Johnson32d95a32012-09-10 13:15:23 -07002586 "WLAN TL:WLANTL_GetRssi for STA: %d RSSI: %d%s",
2587 ucSTAId, *pRssi,
2588 pTLCb->isBMPS ? " in BMPS" : ""));
Jeff Johnson295189b2012-06-20 16:38:30 -07002589
2590 return VOS_STATUS_SUCCESS;
2591}/* WLANTL_GetRssi */
2592
2593/*==========================================================================
2594
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05302595 FUNCTION WLANTL_GetSnr
2596
2597 DESCRIPTION
2598 TL will extract the SNR information from every data packet from the
2599 ongoing traffic and will store it. It will provide the result to SME
2600 upon request.
2601
2602 DEPENDENCIES
2603
2604 WARNING: the read and write of this value will not be protected
2605 by locks, therefore the information obtained after a read
2606 might not always be consistent.
2607
2608 PARAMETERS
2609
2610 IN
2611 pvosGCtx: pointer to the global vos context; a handle to TL's
2612 or SME's control block can be extracted from its context
2613 ucSTAId: station identifier for the requested value
2614
2615 OUT
2616 pSnr: the average value of the SNR
2617
2618
2619 RETURN VALUE
2620 The result code associated with performing the operation
2621
2622 VOS_STATUS_E_INVAL: Input parameters are invalid
2623 VOS_STATUS_E_FAULT: Station ID is outside array boundaries or pointer
2624 to TL cb is NULL ; access would cause a page fault
2625 VOS_STATUS_E_EXISTS: STA was not yet registered
2626 VOS_STATUS_SUCCESS: Everything is good :)
2627
2628 SIDE EFFECTS
2629
2630============================================================================*/
2631VOS_STATUS
2632WLANTL_GetSnr
2633(
2634 tANI_U8 ucSTAId,
2635 tANI_S8* pSnr
2636)
2637{
2638 WLANTL_CbType* pTLCb = NULL;
2639 WLANTL_STAClientType* pClientSTA = NULL;
2640 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
2641
2642 /*------------------------------------------------------------------------
2643 Sanity check
2644 ------------------------------------------------------------------------*/
2645 if (NULL == pSnr)
2646 {
2647 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2648 "WLAN TL:Invalid parameter sent on %s", __func__));
2649 return VOS_STATUS_E_INVAL;
2650 }
2651
2652 if (WLANTL_STA_ID_INVALID(ucSTAId))
2653 {
2654 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2655 "WLAN TL:Invalid station id requested on %s", __func__));
2656 return VOS_STATUS_E_FAULT;
2657 }
2658
2659 /*------------------------------------------------------------------------
2660 Extract TL control block and check existance
2661 ------------------------------------------------------------------------*/
2662 pTLCb = VOS_GET_TL_CB(vos_get_global_context(VOS_MODULE_ID_TL, NULL));
2663 if (NULL == pTLCb)
2664 {
2665 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2666 "WLAN TL:Invalid TL pointer from pvosGCtx on %s", __func__));
2667 return VOS_STATUS_E_FAULT;
2668 }
2669
2670 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
2671
2672 if (NULL == pClientSTA)
2673 {
2674 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2675 "WLAN TL:Client Memory was not allocated on %s", __func__));
2676 return VOS_STATUS_E_FAILURE;
2677 }
2678
2679 if (0 == pClientSTA->ucExists)
2680 {
2681 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2682 "WLAN TL:Station was not previously registered on %s", __func__));
2683 return VOS_STATUS_E_EXISTS;
2684 }
2685
2686 /*------------------------------------------------------------------------
2687 Copy will not be locked; please read restriction
2688 ------------------------------------------------------------------------*/
2689 if (pTLCb->isBMPS)
2690 {
2691 *pSnr = pClientSTA->snrAvgBmps;
2692 }
2693 else
2694 {
2695 /* SNR is averaged over WLANTL_MAX_SNR_DATA_SAMPLES, if there are not enough
2696 * data samples (snridx) to calculate the average then return the
2697 * average for the window of prevoius 20 packets. And if there aren't
2698 * enough samples and the average for previous window of 20 packets is
2699 * not available then return a predefined value
2700 *
2701 * NOTE: the SNR_HACK_BMPS value is defined to 127, documents from HW
2702 * team reveal that the SNR value has a ceiling well below 127 dBm,
2703 * so if SNR has value of 127 the userspace applications can know that
2704 * the SNR has not been computed yet because enough data was not
2705 * available for SNR calculation
2706 */
2707 if (pClientSTA->snrIdx > (WLANTL_MAX_SNR_DATA_SAMPLES/2)
2708 || !(pClientSTA->prevSnrAvg))
2709 {
2710 *pSnr = pClientSTA->snrSum / pClientSTA->snrIdx;
2711 }
2712 else if (pClientSTA->prevSnrAvg)
2713 {
2714 *pSnr = pClientSTA->prevSnrAvg;
2715 }
2716 else
2717 {
2718 *pSnr = SNR_HACK_BMPS;
2719 }
2720 }
2721
2722 VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
2723 "WLAN TL:WLANTL_GetSnr for STA: %d SNR: %d%s",
2724 ucSTAId, *pSnr,
2725 pTLCb->isBMPS ? " in BMPS" : "");
2726
2727 return VOS_STATUS_SUCCESS;
2728}/* WLANTL_GetSnr */
2729/*==========================================================================
2730
Jeff Johnson295189b2012-06-20 16:38:30 -07002731 FUNCTION WLANTL_GetLinkQuality
2732
2733 DESCRIPTION
2734 TL will extract the SNR information from every data packet from the
2735 ongoing traffic and will store it. It will provide the result to SME
2736 upon request.
2737
2738 DEPENDENCIES
2739
2740 WARNING: the read and write of this value will not be protected
2741 by locks, therefore the information obtained after a read
2742 might not always be consistent.
2743
2744 PARAMETERS
2745
2746 IN
2747 pvosGCtx: pointer to the global vos context; a handle to TL's
2748 or SME's control block can be extracted from its context
2749 ucSTAId: station identifier for the requested value
2750
2751 OUT
2752 puLinkQuality: the average value of the SNR
2753
2754
2755 RETURN VALUE
2756 The result code associated with performing the operation
2757
2758 VOS_STATUS_E_INVAL: Input parameters are invalid
2759 VOS_STATUS_E_FAULT: Station ID is outside array boundaries or pointer
2760 to TL cb is NULL ; access would cause a page fault
2761 VOS_STATUS_E_EXISTS: STA was not yet registered
2762 VOS_STATUS_SUCCESS: Everything is good :)
2763
2764 SIDE EFFECTS
2765
2766============================================================================*/
2767VOS_STATUS
2768WLANTL_GetLinkQuality
2769(
2770 v_PVOID_t pvosGCtx,
2771 v_U8_t ucSTAId,
2772 v_U32_t* puLinkQuality
2773)
2774{
2775 WLANTL_CbType* pTLCb = NULL;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302776 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002777
2778 /*------------------------------------------------------------------------
2779 Sanity check
2780 ------------------------------------------------------------------------*/
2781 if ( NULL == puLinkQuality )
2782 {
2783 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2784 "Invalid parameter sent on WLANTL_GetLinkQuality"));
2785 return VOS_STATUS_E_INVAL;
2786 }
2787
2788 if ( WLANTL_STA_ID_INVALID( ucSTAId ) )
2789 {
2790 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2791 "Invalid station id requested on WLANTL_GetLinkQuality"));
2792 return VOS_STATUS_E_FAULT;
2793 }
2794
2795 /*------------------------------------------------------------------------
2796 Extract TL control block and check existance
2797 ------------------------------------------------------------------------*/
2798 pTLCb = VOS_GET_TL_CB(pvosGCtx);
2799 if ( NULL == pTLCb )
2800 {
2801 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2802 "Invalid TL pointer from pvosGCtx on WLANTL_GetLinkQuality"));
2803 return VOS_STATUS_E_FAULT;
2804 }
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302805 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
Jeff Johnson295189b2012-06-20 16:38:30 -07002806
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302807 if ( NULL == pClientSTA )
2808 {
2809 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2810 "WLAN TL:Client Memory was not allocated on %s", __func__));
2811 return VOS_STATUS_E_FAILURE;
2812 }
2813
2814 if ( 0 == pClientSTA->ucExists )
Jeff Johnson295189b2012-06-20 16:38:30 -07002815 {
2816 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2817 "Station was not previously registered on WLANTL_GetLinkQuality"));
2818 return VOS_STATUS_E_EXISTS;
2819 }
2820
2821 /*------------------------------------------------------------------------
2822 Copy will not be locked; please read restriction
2823 ------------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302824 *puLinkQuality = pClientSTA->uLinkQualityAvg;
Jeff Johnson295189b2012-06-20 16:38:30 -07002825
2826 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
2827 "WLANTL_GetLinkQuality for STA: %d LinkQuality: %d", ucSTAId, *puLinkQuality));
2828
2829 return VOS_STATUS_SUCCESS;
2830}/* WLANTL_GetLinkQuality */
2831
2832/*==========================================================================
2833
2834 FUNCTION WLANTL_FlushStaTID
2835
2836 DESCRIPTION
2837 TL provides this API as an interface to SME (BAP) layer. TL inturn posts a
2838 message to HAL. This API is called by the SME inorder to perform a flush
2839 operation.
2840
2841 DEPENDENCIES
2842
2843 PARAMETERS
2844
2845 IN
2846 pvosGCtx: pointer to the global vos context; a handle to TL's
2847 or SME's control block can be extracted from its context
2848 ucSTAId: station identifier for the requested value
2849 ucTid: Tspec ID for the new BA session
2850
2851 OUT
2852 The response for this post is received in the main thread, via a response
2853 message from HAL to TL.
2854
2855 RETURN VALUE
2856 VOS_STATUS_SUCCESS: Everything is good :)
2857
2858 SIDE EFFECTS
2859============================================================================*/
2860VOS_STATUS
2861WLANTL_FlushStaTID
2862(
2863 v_PVOID_t pvosGCtx,
2864 v_U8_t ucSTAId,
2865 v_U8_t ucTid
2866)
2867{
2868 WLANTL_CbType* pTLCb = NULL;
2869 tpFlushACReq FlushACReqPtr = NULL;
2870 vos_msg_t vosMessage;
2871
2872
2873 if ( WLANTL_STA_ID_INVALID( ucSTAId ) )
2874 {
2875 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2876 "Invalid station id requested on WLANTL_FlushStaTID"));
2877 return VOS_STATUS_E_FAULT;
2878 }
2879
2880 /*------------------------------------------------------------------------
2881 Extract TL control block and check existance
2882 ------------------------------------------------------------------------*/
2883 pTLCb = VOS_GET_TL_CB(pvosGCtx);
2884 if ( NULL == pTLCb )
2885 {
2886 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2887 "Invalid TL pointer from pvosGCtx on WLANTL_FlushStaTID"));
2888 return VOS_STATUS_E_FAULT;
2889 }
2890
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302891 if ( NULL == pTLCb->atlSTAClients[ucSTAId] )
2892 {
2893 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2894 "WLAN TL:Client Memory was not allocated on %s", __func__));
2895 return VOS_STATUS_E_FAILURE;
2896 }
2897
2898 if ( 0 == pTLCb->atlSTAClients[ucSTAId]->ucExists )
Jeff Johnson295189b2012-06-20 16:38:30 -07002899 {
2900 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2901 "Station was not previously registered on WLANTL_FlushStaTID"));
2902 return VOS_STATUS_E_EXISTS;
2903 }
2904
2905 /*------------------------------------------------------------------------
2906 We need to post a message with the STA, TID value to HAL. HAL performs the flush
2907 ------------------------------------------------------------------------*/
2908 FlushACReqPtr = vos_mem_malloc(sizeof(tFlushACReq));
2909
2910 if ( NULL == FlushACReqPtr )
2911 {
2912 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2913 "WLAN TL: fatal failure, cannot allocate Flush Req structure"));
2914 VOS_ASSERT(0);
2915 return VOS_STATUS_E_NOMEM;
2916 }
2917
2918 // Start constructing the message for HAL
2919 FlushACReqPtr->mesgType = SIR_TL_HAL_FLUSH_AC_REQ;
2920 FlushACReqPtr->mesgLen = sizeof(tFlushACReq);
2921 FlushACReqPtr->mesgLen = sizeof(tFlushACReq);
2922 FlushACReqPtr->ucSTAId = ucSTAId;
2923 FlushACReqPtr->ucTid = ucTid;
2924
2925 vosMessage.type = WDA_TL_FLUSH_AC_REQ;
2926 vosMessage.bodyptr = (void *)FlushACReqPtr;
2927
2928 vos_mq_post_message(VOS_MQ_ID_WDA, &vosMessage);
2929 return VOS_STATUS_SUCCESS;
2930}
2931
2932
2933/*----------------------------------------------------------------------------
2934 INTERACTION WITH PE
2935 ---------------------------------------------------------------------------*/
2936
2937/*==========================================================================
2938
2939 FUNCTION WLANTL_RegisterMgmtFrmClient
2940
2941 DESCRIPTION
2942 Called by PE to register as a client for management frames delivery.
2943
2944 DEPENDENCIES
2945 TL must be initialized before this API can be called.
2946
2947 PARAMETERS
2948
2949 IN
2950 pvosGCtx: pointer to the global vos context; a handle to
2951 TL's control block can be extracted from its context
2952 pfnTlMgmtFrmRx: pointer to the receive processing routine for
2953 management frames
2954
2955 RETURN VALUE
2956 The result code associated with performing the operation
2957
2958 VOS_STATUS_E_INVAL: Input parameters are invalid
2959 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
2960 page fault
2961 VOS_STATUS_E_EXISTS: Mgmt Frame client was already registered
2962 VOS_STATUS_SUCCESS: Everything is good :)
2963
2964 SIDE EFFECTS
2965
2966============================================================================*/
2967VOS_STATUS
2968WLANTL_RegisterMgmtFrmClient
2969(
2970 v_PVOID_t pvosGCtx,
2971 WLANTL_MgmtFrmRxCBType pfnTlMgmtFrmRx
2972)
2973{
2974 WLANTL_CbType* pTLCb = NULL;
2975 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
2976
2977 /*------------------------------------------------------------------------
2978 Sanity check
2979 ------------------------------------------------------------------------*/
2980 if ( NULL == pfnTlMgmtFrmRx )
2981 {
2982 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2983 "WLAN TL:Invalid parameter sent on WLANTL_RegisterMgmtFrmClient"));
2984 return VOS_STATUS_E_INVAL;
2985 }
2986
2987 /*------------------------------------------------------------------------
2988 Extract TL control block
2989 ------------------------------------------------------------------------*/
2990 pTLCb = VOS_GET_TL_CB(pvosGCtx);
2991 if ( NULL == pTLCb )
2992 {
2993 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2994 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_ChangeSTAState"));
2995 return VOS_STATUS_E_FAULT;
2996 }
2997
2998 /*------------------------------------------------------------------------
2999 Make sure this is the first registration attempt
3000 ------------------------------------------------------------------------*/
3001 if ( 0 != pTLCb->tlMgmtFrmClient.ucExists )
3002 {
3003 pTLCb->tlMgmtFrmClient.ucExists++;
3004 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3005 "WLAN TL:Management frame client was already registered"));
3006 return VOS_STATUS_E_EXISTS;
3007 }
3008
3009 /*------------------------------------------------------------------------
3010 Register station with TL
3011 ------------------------------------------------------------------------*/
3012 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
3013 "WLAN TL:Registering Management Frame Client" ));
3014
3015 pTLCb->tlMgmtFrmClient.ucExists++;
3016
3017 if ( NULL != pfnTlMgmtFrmRx )
3018 {
3019 pTLCb->tlMgmtFrmClient.pfnTlMgmtFrmRx = pfnTlMgmtFrmRx;
3020 }
3021
3022 pTLCb->tlMgmtFrmClient.vosPendingDataBuff = NULL;
3023
3024 return VOS_STATUS_SUCCESS;
3025}/* WLANTL_RegisterMgmtFrmClient */
3026
3027/*==========================================================================
3028
3029 FUNCTION WLANTL_DeRegisterMgmtFrmClient
3030
3031 DESCRIPTION
3032 Called by PE to deregister as a client for management frames delivery.
3033
3034 DEPENDENCIES
3035 TL must be initialized before this API can be called.
3036
3037 PARAMETERS
3038
3039 IN
3040 pvosGCtx: pointer to the global vos context; a handle to
3041 TL's control block can be extracted from its context
3042 RETURN VALUE
3043 The result code associated with performing the operation
3044
3045 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
3046 page fault
3047 VOS_STATUS_E_EXISTS: Mgmt Frame client was never registered
3048 VOS_STATUS_SUCCESS: Everything is good :)
3049
3050 SIDE EFFECTS
3051
3052============================================================================*/
3053VOS_STATUS
3054WLANTL_DeRegisterMgmtFrmClient
3055(
3056 v_PVOID_t pvosGCtx
3057)
3058{
3059 WLANTL_CbType* pTLCb = NULL;
3060 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
3061
3062 /*------------------------------------------------------------------------
3063 Extract TL control block
3064 ------------------------------------------------------------------------*/
3065 pTLCb = VOS_GET_TL_CB(pvosGCtx);
3066 if ( NULL == pTLCb )
3067 {
3068 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3069 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_ChangeSTAState"));
3070 return VOS_STATUS_E_FAULT;
3071 }
3072
3073 /*------------------------------------------------------------------------
3074 Make sure this is the first registration attempt
3075 ------------------------------------------------------------------------*/
3076 if ( 0 == pTLCb->tlMgmtFrmClient.ucExists )
3077 {
3078 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3079 "WLAN TL:Management frame client was never registered"));
3080 return VOS_STATUS_E_EXISTS;
3081 }
3082
3083 /*------------------------------------------------------------------------
3084 Clear registration with TL
3085 ------------------------------------------------------------------------*/
3086 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
3087 "WLAN TL:Deregistering Management Frame Client" ));
3088
3089 pTLCb->tlMgmtFrmClient.pfnTlMgmtFrmRx = WLANTL_MgmtFrmRxDefaultCb;
3090 if ( NULL != pTLCb->tlMgmtFrmClient.vosPendingDataBuff)
3091 {
3092 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
3093 "WLAN TL:Management cache buffer not empty on deregistering"
3094 " - dropping packet" ));
3095 vos_pkt_return_packet(pTLCb->tlMgmtFrmClient.vosPendingDataBuff);
3096
3097 pTLCb->tlMgmtFrmClient.vosPendingDataBuff = NULL;
3098 }
3099
3100 pTLCb->tlMgmtFrmClient.ucExists = 0;
3101
3102 return VOS_STATUS_SUCCESS;
3103}/* WLANTL_RegisterMgmtFrmClient */
3104
3105/*==========================================================================
3106
3107 FUNCTION WLANTL_TxMgmtFrm
3108
3109 DESCRIPTION
3110 Called by PE when it want to send out a management frame.
3111 HAL will also use this API for the few frames it sends out, they are not
3112 management frames howevere it is accepted that an exception will be
3113 allowed ONLY for the usage of HAL.
3114 Generic data frames SHOULD NOT travel through this function.
3115
3116 DEPENDENCIES
3117 TL must be initialized before this API can be called.
3118
3119 RESTRICTION: If PE sends another packet before TL manages to process the
3120 previously sent packet call will end in failure
3121
3122 Frames comming through here must be 802.11 frames, frame
3123 translation in UMA will be automatically disabled.
3124
3125 PARAMETERS
3126
3127 IN
3128 pvosGCtx: pointer to the global vos context;a handle to TL's
3129 control block can be extracted from its context
3130 vosFrmBuf: pointer to a vOSS buffer containing the management
3131 frame to be transmitted
3132 usFrmLen: the length of the frame to be transmitted; information
3133 is already included in the vOSS buffer
3134 wFrmType: the type of the frame being transmitted
3135 tid: tid used to transmit this frame
3136 pfnCompTxFunc: function pointer to the transmit complete routine
3137 pvBDHeader: pointer to the BD header, if NULL it means it was not
3138 yet constructed and it lies within TL's responsibility
3139 to do so; if not NULL it is expected that it was
3140 already packed inside the vos packet
3141 ucAckResponse: flag notifying it an interrupt is needed for the
3142 acknowledgement received when the frame is sent out
3143 the air and ; the interrupt will be processed by HAL,
3144 only one such frame can be pending in the system at
3145 one time.
3146
3147
3148 RETURN VALUE
3149 The result code associated with performing the operation
3150
3151 VOS_STATUS_E_INVAL: Input parameters are invalid
3152 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
3153 page fault
3154 VOS_STATUS_E_EXISTS: Mgmt Frame client was not yet registered
3155 VOS_STATUS_E_BUSY: The previous Mgmt packet was not yet transmitted
3156 VOS_STATUS_SUCCESS: Everything is good :)
3157
3158 Other failure messages may be returned from the BD header handling
3159 routines, please check apropriate API for more info.
3160
3161 SIDE EFFECTS
3162
3163============================================================================*/
3164VOS_STATUS
3165WLANTL_TxMgmtFrm
3166(
3167 v_PVOID_t pvosGCtx,
3168 vos_pkt_t* vosFrmBuf,
3169 v_U16_t usFrmLen,
3170 v_U8_t wFrmType,
3171 v_U8_t ucTid,
3172 WLANTL_TxCompCBType pfnCompTxFunc,
3173 v_PVOID_t pvBDHeader,
3174 v_U8_t ucAckResponse
3175)
3176{
3177 WLANTL_CbType* pTLCb = NULL;
3178 v_MACADDR_t vDestMacAddr;
3179 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
3180 v_U16_t usPktLen;
3181 v_U32_t usTimeStamp = 0;
3182 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
3183
3184 /*------------------------------------------------------------------------
3185 Sanity check
3186 ------------------------------------------------------------------------*/
3187 if ( NULL == vosFrmBuf )
3188 {
3189 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3190 "WLAN TL:Invalid parameter sent on WLANTL_TxMgmtFrm"));
3191 return VOS_STATUS_E_INVAL;
3192 }
3193
3194 /*------------------------------------------------------------------------
3195 Extract TL control block
3196 ------------------------------------------------------------------------*/
3197 pTLCb = VOS_GET_TL_CB(pvosGCtx);
3198 if ( NULL == pTLCb )
3199 {
3200 TLLOGP(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_FATAL,
3201 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_TxMgmtFrm"));
3202 return VOS_STATUS_E_FAULT;
3203 }
3204
3205 /*------------------------------------------------------------------------
3206 Ensure that management frame client was previously registered
3207 ------------------------------------------------------------------------*/
3208 if ( 0 == pTLCb->tlMgmtFrmClient.ucExists )
3209 {
3210 pTLCb->tlMgmtFrmClient.ucExists++;
3211 TLLOGP(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_FATAL,
3212 "WLAN TL:Management Frame client not register on WLANTL_TxMgmtFrm"));
3213 return VOS_STATUS_E_EXISTS;
3214 }
3215
3216 /*------------------------------------------------------------------------
3217 Check if any Mgmt Frm is pending
3218 ------------------------------------------------------------------------*/
3219 //vosTempBuff = pTLCb->tlMgmtFrmClient.vosPendingDataBuff;
3220 if ( NULL != pTLCb->tlMgmtFrmClient.vosPendingDataBuff )
3221 {
3222
3223 TLLOGP(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_FATAL,
3224 "WLAN TL:Management Frame already pending tx in TL: failing old one"));
3225
3226
3227 /*Failing the tx for the previous packet enqued by PE*/
3228 //vos_atomic_set_U32( (v_U32_t*)&pTLCb->tlMgmtFrmClient.vosPendingDataBuff,
3229 // (v_U32_t)NULL);
3230
3231 //vos_pkt_get_user_data_ptr( vosTempBuff, VOS_PKT_USER_DATA_ID_TL,
3232 // (v_PVOID_t)&pfnTxComp);
3233
3234 /*it should never be NULL - default handler should be registered if none*/
3235 //if ( NULL == pfnTxComp )
3236 //{
3237 // VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3238 // "NULL pointer to Tx Complete on WLANTL_TxMgmtFrm");
3239 // VOS_ASSERT(0);
3240 // return VOS_STATUS_E_FAULT;
3241 //}
3242
3243 //pfnTxComp( pvosGCtx, vosTempBuff, VOS_STATUS_E_RESOURCES );
3244 //return VOS_STATUS_E_BUSY;
3245
3246
3247 //pfnCompTxFunc( pvosGCtx, vosFrmBuf, VOS_STATUS_E_RESOURCES);
3248 return VOS_STATUS_E_RESOURCES;
3249 }
3250
3251
3252 /*------------------------------------------------------------------------
3253 Check if BD header was build, if not construct
3254 ------------------------------------------------------------------------*/
3255 if ( NULL == pvBDHeader )
3256 {
3257 v_MACADDR_t* pvAddr2MacAddr;
3258 v_U8_t uQosHdr = VOS_FALSE;
3259
3260 /* Get address 2 of Mangement Frame to give to WLANHAL_FillTxBd */
3261 vosStatus = vos_pkt_peek_data( vosFrmBuf,
3262 WLANTL_MAC_ADDR_ALIGN(1) + VOS_MAC_ADDR_SIZE,
3263 (v_PVOID_t)&pvAddr2MacAddr, VOS_MAC_ADDR_SIZE);
3264
3265 if ( VOS_STATUS_SUCCESS != vosStatus )
3266 {
3267 TLLOGP(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_FATAL,
3268 "WLAN TL:Failed while attempting to get addr2 %d", vosStatus));
3269 return vosStatus;
3270 }
Gopichand Nakkala0f3eb5c2013-05-07 16:48:38 +05303271
3272 /* CCX IAPP/TDLS Frame which are data frames but technically used
Jeff Johnson295189b2012-06-20 16:38:30 -07003273 * for management functionality comes through route.
3274 */
3275 if (WLANTL_IS_QOS_DATA_FRAME(wFrmType)) \
3276 {
3277 uQosHdr = VOS_TRUE;
3278 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003279 /*----------------------------------------------------------------------
3280 Call WDA to build TX header
3281 ----------------------------------------------------------------------*/
3282 vosStatus = WDA_DS_BuildTxPacketInfo( pvosGCtx, vosFrmBuf , &vDestMacAddr,
3283 1 /* always 802.11 frames*/, &usPktLen, uQosHdr /*qos not enabled !!!*/,
3284 0 /* WDS off */, 0, wFrmType, pvAddr2MacAddr, ucTid,
3285 ucAckResponse, usTimeStamp, 0, 0 );
3286
3287
3288 if ( !VOS_IS_STATUS_SUCCESS(vosStatus) )
3289 {
3290 TLLOGP(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_FATAL,
3291 "WLAN TL:Failed while attempting to build TX header %d", vosStatus));
3292 return vosStatus;
3293 }
3294 }/* if BD header not present */
3295
3296 /*------------------------------------------------------------------------
3297 Save buffer and notify BAL; no lock is needed if the above restriction
3298 is met
3299 Save the tx complete fnct pointer as tl specific data in the vos buffer
3300 ------------------------------------------------------------------------*/
3301 if ( NULL != pfnCompTxFunc )
3302 {
3303 vos_pkt_set_user_data_ptr( vosFrmBuf, VOS_PKT_USER_DATA_ID_TL,
3304 (v_PVOID_t)pfnCompTxFunc);
3305 }
3306 else
3307 {
3308 vos_pkt_set_user_data_ptr( vosFrmBuf, VOS_PKT_USER_DATA_ID_TL,
3309 (v_PVOID_t)WLANTL_TxCompDefaultCb);
3310
3311 }
3312
3313 vos_atomic_set_U32( (v_U32_t*)&pTLCb->tlMgmtFrmClient.vosPendingDataBuff,
3314 (v_U32_t)vosFrmBuf);
3315
3316 /*------------------------------------------------------------------------
3317 Check if thre are enough resources for transmission and tx is not
3318 suspended.
3319 ------------------------------------------------------------------------*/
3320 if ( pTLCb->uResCount >= WDA_TLI_MIN_RES_MF )
3321 {
3322 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
3323 "WLAN TL:Issuing Xmit start request to BAL for MGMT"));
3324 vosStatus = WDA_DS_StartXmit(pvosGCtx);
3325 if(VOS_STATUS_SUCCESS != vosStatus)
3326 {
3327 TLLOGP(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_FATAL,
3328 "WLAN TL:WDA_DS_StartXmit fails. vosStatus %d", vosStatus));
3329 vos_atomic_set_U32( (v_U32_t*)&pTLCb->tlMgmtFrmClient.vosPendingDataBuff,0);
3330 }
3331 return vosStatus;
3332
3333 }
3334 else
3335 {
3336 /*---------------------------------------------------------------------
3337 No error code is sent because TL will resume tx autonomously if
3338 resources become available or tx gets resumed
3339 ---------------------------------------------------------------------*/
3340 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
3341 "WLAN TL:Request to send for Mgmt Frm but condition not met. Res: %d",
3342 pTLCb->uResCount));
3343 }
3344
3345 return VOS_STATUS_SUCCESS;
3346}/* WLANTL_TxMgmtFrm */
3347
3348/*----------------------------------------------------------------------------
3349 INTERACTION WITH HAL
3350 ---------------------------------------------------------------------------*/
3351
3352/*==========================================================================
3353
3354 FUNCTION WLANTL_ResetNotification
3355
3356 DESCRIPTION
3357 HAL notifies TL when the module is being reset.
3358 Currently not used.
3359
3360 DEPENDENCIES
3361
3362 PARAMETERS
3363
3364 IN
3365 pvosGCtx: pointer to the global vos context; a handle to TL's
3366 control block can be extracted from its context
3367
3368
3369 RETURN VALUE
3370 The result code associated with performing the operation
3371
3372 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
3373 page fault
3374 VOS_STATUS_SUCCESS: Everything is good :)
3375
3376 SIDE EFFECTS
3377
3378============================================================================*/
3379VOS_STATUS
3380WLANTL_ResetNotification
3381(
3382 v_PVOID_t pvosGCtx
3383)
3384{
3385 WLANTL_CbType* pTLCb = NULL;
3386 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
3387
3388 /*------------------------------------------------------------------------
3389 Sanity check
3390 Extract TL control block
3391 ------------------------------------------------------------------------*/
3392 pTLCb = VOS_GET_TL_CB(pvosGCtx);
3393 if ( NULL == pTLCb )
3394 {
3395 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3396 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_ResetNotification"));
3397 return VOS_STATUS_E_FAULT;
3398 }
3399
3400 WLANTL_CleanCB(pTLCb, 1 /*empty all queues and pending packets*/);
3401 return VOS_STATUS_SUCCESS;
3402}/* WLANTL_ResetNotification */
3403
3404/*==========================================================================
3405
3406 FUNCTION WLANTL_SuspendDataTx
3407
3408 DESCRIPTION
3409 HAL calls this API when it wishes to suspend transmission for a
3410 particular STA.
3411
3412 DEPENDENCIES
3413 The STA for which the request is made must be first registered with
3414 TL by HDD.
3415
3416 RESTRICTION: In case of a suspend, the flag write and read will not be
3417 locked: worst case scenario one more packet can get
3418 through before the flag gets updated (we can make this
3419 write atomic as well to guarantee consistency)
3420
3421 PARAMETERS
3422
3423 IN
3424 pvosGCtx: pointer to the global vos context; a handle to TL's
3425 control block can be extracted from its context
3426 pucSTAId: identifier of the station for which the request is made;
3427 a value of NULL assumes suspend on all active station
3428 pfnSuspendTxCB: pointer to the suspend result notification in case the
3429 call is asynchronous
3430
3431
3432 RETURN VALUE
3433 The result code associated with performing the operation
3434
3435 VOS_STATUS_E_FAULT: Station ID is outside array boundaries or pointer
3436 to TL cb is NULL ; access would cause a page fault
3437 VOS_STATUS_E_EXISTS: Station was not registered
3438 VOS_STATUS_SUCCESS: Everything is good :)
3439
3440 SIDE EFFECTS
3441
3442============================================================================*/
3443
3444VOS_STATUS
3445WLANTL_SuspendDataTx
3446(
3447 v_PVOID_t pvosGCtx,
3448 v_U8_t* pucSTAId,
3449 WLANTL_SuspendCBType pfnSuspendTx
3450)
3451{
3452 WLANTL_CbType* pTLCb = NULL;
3453 vos_msg_t vosMsg;
Jeff Johnson295189b2012-06-20 16:38:30 -07003454
3455 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
3456
3457 /*------------------------------------------------------------------------
3458 Sanity check
3459 Extract TL control block
3460 ------------------------------------------------------------------------*/
3461 pTLCb = VOS_GET_TL_CB(pvosGCtx);
Hoonki Lee14621352013-04-16 17:51:19 -07003462 if ( NULL == pTLCb )
Jeff Johnson295189b2012-06-20 16:38:30 -07003463 {
3464 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3465 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_SuspendDataTx"));
3466 return VOS_STATUS_E_FAULT;
3467 }
3468
3469 /*------------------------------------------------------------------------
3470 Check the type of request: generic suspend, or per station suspend
3471 ------------------------------------------------------------------------*/
Hoonki Lee14621352013-04-16 17:51:19 -07003472 if (NULL == pucSTAId)
Jeff Johnson295189b2012-06-20 16:38:30 -07003473 {
3474 /* General Suspend Request received */
3475 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
3476 "WLAN TL:General suspend requested"));
Hoonki Lee14621352013-04-16 17:51:19 -07003477 vos_atomic_set_U8( &pTLCb->ucTxSuspended, 1);
Jeff Johnson295189b2012-06-20 16:38:30 -07003478 vosMsg.reserved = WLAN_MAX_STA_COUNT;
3479 }
3480 else
3481 {
Hoonki Lee14621352013-04-16 17:51:19 -07003482 if ( WLANTL_STA_ID_INVALID( *pucSTAId ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07003483 {
Hoonki Lee14621352013-04-16 17:51:19 -07003484 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3485 "WLAN TL:Invalid station id %d requested on WLANTL_SuspendDataTx", *pucSTAId));
3486 return VOS_STATUS_E_FAULT;
3487 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003488
Gopichand Nakkalae5fef6c2013-06-19 18:04:23 +05303489 if ( NULL == pTLCb->atlSTAClients[*pucSTAId] )
3490 {
3491 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3492 "WLAN TL:Invalid pTLCb->atlSTAClients pointer for STA Id :%d on "
3493 "WLANTL_SuspendDataTx", *pucSTAId));
3494 return VOS_STATUS_E_FAULT;
3495 }
3496
3497 if ( 0 == pTLCb->atlSTAClients[*pucSTAId]->ucExists )
Hoonki Lee14621352013-04-16 17:51:19 -07003498 {
3499 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3500 "WLAN TL:Station %d was not previously registered on WLANTL_SuspendDataTx", *pucSTAId));
3501 return VOS_STATUS_E_EXISTS;
3502 }
3503
3504 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
3505 "WLAN TL:Suspend request for station: %d", *pucSTAId));
3506 vos_atomic_set_U8( &pTLCb->atlSTAClients[*pucSTAId]->ucTxSuspended, 1);
Jeff Johnson295189b2012-06-20 16:38:30 -07003507 vosMsg.reserved = *pucSTAId;
3508 }
3509
3510 /*------------------------------------------------------------------------
3511 Serialize request through TX thread
3512 ------------------------------------------------------------------------*/
3513 vosMsg.type = WLANTL_TX_SIG_SUSPEND;
3514 vosMsg.bodyptr = (v_PVOID_t)pfnSuspendTx;
3515
3516 if(!VOS_IS_STATUS_SUCCESS(vos_tx_mq_serialize( VOS_MQ_ID_TL, &vosMsg)))
3517 {
3518 VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003519 " %s fails to post message", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003520 }
3521
3522 return VOS_STATUS_SUCCESS;
3523}/* WLANTL_SuspendDataTx */
3524
3525/*==========================================================================
3526
3527 FUNCTION WLANTL_ResumeDataTx
3528
3529 DESCRIPTION
3530 Called by HAL to resume data transmission for a given STA.
3531
3532 WARNING: If a station was individually suspended a global resume will
3533 not resume that station
3534
3535 DEPENDENCIES
3536
3537 PARAMETERS
3538
3539 IN
3540 pvosGCtx: pointer to the global vos context; a handle to TL's
3541 control block can be extracted from its context
3542 pucSTAId: identifier of the station which is being resumed; NULL
3543 translates into global resume
3544
3545 RETURN VALUE
3546 The result code associated with performing the operation
3547
3548 VOS_STATUS_E_FAULT: Station ID is outside array boundaries or pointer
3549 to TL cb is NULL ; access would cause a page fault
3550 VOS_STATUS_E_EXISTS: Station was not registered
3551 VOS_STATUS_SUCCESS: Everything is good :)
3552
3553 SIDE EFFECTS
3554
3555============================================================================*/
3556
3557VOS_STATUS
3558WLANTL_ResumeDataTx
3559(
3560 v_PVOID_t pvosGCtx,
3561 v_U8_t* pucSTAId
3562)
3563{
3564 WLANTL_CbType* pTLCb = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07003565 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
3566
3567 /*------------------------------------------------------------------------
3568 Sanity check
3569 Extract TL control block
3570 ------------------------------------------------------------------------*/
3571 pTLCb = VOS_GET_TL_CB(pvosGCtx);
Hoonki Lee14621352013-04-16 17:51:19 -07003572 if ( NULL == pTLCb )
Jeff Johnson295189b2012-06-20 16:38:30 -07003573 {
3574 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3575 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_ResumeDataTx"));
3576 return VOS_STATUS_E_FAULT;
3577 }
3578
Jeff Johnson295189b2012-06-20 16:38:30 -07003579 /*------------------------------------------------------------------------
3580 Check to see the type of resume
3581 ------------------------------------------------------------------------*/
Hoonki Lee14621352013-04-16 17:51:19 -07003582 if ( NULL == pucSTAId )
Jeff Johnson295189b2012-06-20 16:38:30 -07003583 {
3584 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
3585 "WLAN TL:General resume requested"));
3586 vos_atomic_set_U8( &pTLCb->ucTxSuspended, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07003587 }
3588 else
3589 {
Hoonki Lee14621352013-04-16 17:51:19 -07003590 if ( WLANTL_STA_ID_INVALID( *pucSTAId ))
Jeff Johnson295189b2012-06-20 16:38:30 -07003591 {
Hoonki Lee14621352013-04-16 17:51:19 -07003592 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3593 "WLAN TL:Invalid station id %d requested on WLANTL_ResumeDataTx", *pucSTAId));
3594 return VOS_STATUS_E_FAULT;
3595 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003596
Gopichand Nakkalae5fef6c2013-06-19 18:04:23 +05303597 if ( NULL == pTLCb->atlSTAClients[*pucSTAId] )
3598 {
3599 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3600 "WLAN TL:Invalid pTLCb->atlSTAClients pointer for STA Id :%d on "
3601 "WLANTL_ResumeDataTx", *pucSTAId));
3602 return VOS_STATUS_E_FAULT;
3603 }
3604
3605 if ( 0 == pTLCb->atlSTAClients[*pucSTAId]->ucExists )
Hoonki Lee14621352013-04-16 17:51:19 -07003606 {
3607 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3608 "WLAN TL:Station %d was not previously registered on WLANTL_ResumeDataTx", *pucSTAId));
3609 return VOS_STATUS_E_EXISTS;
3610 }
3611
3612 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
3613 "WLAN TL:Resume request for station: %d", *pucSTAId));
3614 vos_atomic_set_U8( &pTLCb->atlSTAClients[*pucSTAId]->ucTxSuspended, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07003615 }
3616
3617 /*------------------------------------------------------------------------
3618 Resuming transmission
3619 ------------------------------------------------------------------------*/
Hoonki Lee14621352013-04-16 17:51:19 -07003620 if (( pTLCb->uResCount >= WDA_TLI_MIN_RES_MF ) &&
3621 ( 0 == pTLCb->ucTxSuspended ))
Jeff Johnson295189b2012-06-20 16:38:30 -07003622 {
3623 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
3624 "WLAN TL:Resuming transmission"));
3625 return WDA_DS_StartXmit(pvosGCtx);
3626 }
3627
3628 return VOS_STATUS_SUCCESS;
3629}/* WLANTL_ResumeDataTx */
3630
3631/*==========================================================================
3632 FUNCTION WLANTL_SuspendCB
3633
3634 DESCRIPTION
3635 Callback function for serializing Suspend signal through Tx thread
3636
3637 DEPENDENCIES
3638 Just notify HAL that suspend in TL is complete.
3639
3640 PARAMETERS
3641
3642 IN
3643 pvosGCtx: pointer to the global vos context; a handle to TL's
3644 control block can be extracted from its context
3645 pUserData: user data sent with the callback
3646
3647 RETURN VALUE
3648 The result code associated with performing the operation
3649
3650 VOS_STATUS_E_INVAL: invalid input parameters
3651 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
3652 page fault
3653 VOS_STATUS_SUCCESS: Everything is good :)
3654
3655
3656 SIDE EFFECTS
3657
3658============================================================================*/
3659VOS_STATUS
3660WLANTL_SuspendCB
3661(
3662 v_PVOID_t pvosGCtx,
3663 WLANTL_SuspendCBType pfnSuspendCB,
3664 v_U16_t usReserved
3665)
3666{
3667 WLANTL_CbType* pTLCb = NULL;
3668 v_U8_t ucSTAId = (v_U8_t)usReserved;
3669 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
3670
3671 /*------------------------------------------------------------------------
3672 Sanity check
3673 ------------------------------------------------------------------------*/
3674 if ( NULL == pfnSuspendCB )
3675 {
3676 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
3677 "WLAN TL: No Call back processing requested WLANTL_SuspendCB"));
3678 return VOS_STATUS_SUCCESS;
3679 }
3680
3681 /*------------------------------------------------------------------------
3682 Extract TL control block
3683 ------------------------------------------------------------------------*/
3684 pTLCb = VOS_GET_TL_CB(pvosGCtx);
3685 if ( NULL == pTLCb )
3686 {
3687 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3688 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_SuspendCB"));
3689 return VOS_STATUS_E_FAULT;
3690 }
3691
3692 if ( WLANTL_STA_ID_INVALID( ucSTAId ) )
3693 {
3694 pfnSuspendCB(pvosGCtx, NULL, VOS_STATUS_SUCCESS);
3695 }
3696 else
3697 {
3698 pfnSuspendCB(pvosGCtx, &ucSTAId, VOS_STATUS_SUCCESS);
3699 }
3700
3701 return VOS_STATUS_SUCCESS;
3702}/*WLANTL_SuspendCB*/
3703
3704
3705/*----------------------------------------------------------------------------
3706 CLIENT INDEPENDENT INTERFACE
3707 ---------------------------------------------------------------------------*/
3708
3709/*==========================================================================
3710
3711 FUNCTION WLANTL_GetTxPktCount
3712
3713 DESCRIPTION
3714 TL will provide the number of transmitted packets counted per
3715 STA per TID.
3716
3717 DEPENDENCIES
3718
3719 PARAMETERS
3720
3721 IN
3722 pvosGCtx: pointer to the global vos context; a handle to TL's
3723 control block can be extracted from its context
3724 ucSTAId: identifier of the station
3725 ucTid: identifier of the tspec
3726
3727 OUT
3728 puTxPktCount: the number of packets tx packet for this STA and TID
3729
3730 RETURN VALUE
3731 The result code associated with performing the operation
3732
3733 VOS_STATUS_E_INVAL: Input parameters are invalid
3734 VOS_STATUS_E_FAULT: Station ID is outside array boundaries or pointer
3735 to TL cb is NULL ; access would cause a page fault
3736 VOS_STATUS_E_EXISTS: Station was not registered
3737 VOS_STATUS_SUCCESS: Everything is good :)
3738
3739 SIDE EFFECTS
3740
3741============================================================================*/
3742VOS_STATUS
3743WLANTL_GetTxPktCount
3744(
3745 v_PVOID_t pvosGCtx,
3746 v_U8_t ucSTAId,
3747 v_U8_t ucTid,
3748 v_U32_t* puTxPktCount
3749)
3750{
3751 WLANTL_CbType* pTLCb = NULL;
3752 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
3753
3754 /*------------------------------------------------------------------------
3755 Sanity check
3756 ------------------------------------------------------------------------*/
3757 if ( NULL == puTxPktCount )
3758 {
3759 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3760 "WLAN TL:Invalid parameter sent on WLANTL_GetTxPktCount"));
3761 return VOS_STATUS_E_INVAL;
3762 }
3763
3764 if ( WLANTL_STA_ID_INVALID( ucSTAId ) || WLANTL_TID_INVALID( ucTid) )
3765 {
3766 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3767 "WLAN TL:Invalid station id %d/tid %d requested on WLANTL_GetTxPktCount",
3768 ucSTAId, ucTid));
3769 return VOS_STATUS_E_FAULT;
3770 }
3771
3772 /*------------------------------------------------------------------------
3773 Extract TL control block and check if station exists
3774 ------------------------------------------------------------------------*/
3775 pTLCb = VOS_GET_TL_CB(pvosGCtx);
3776 if ( NULL == pTLCb )
3777 {
3778 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3779 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_GetTxPktCount"));
3780 return VOS_STATUS_E_FAULT;
3781 }
3782
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05303783 if ( NULL == pTLCb->atlSTAClients[ucSTAId] )
3784 {
3785 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3786 "WLAN TL:Client Memory was not allocated on %s", __func__));
3787 return VOS_STATUS_E_FAILURE;
3788 }
3789
3790 if ( 0 == pTLCb->atlSTAClients[ucSTAId]->ucExists )
Jeff Johnson295189b2012-06-20 16:38:30 -07003791 {
3792 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3793 "WLAN TL:Station was not previously registered on WLANTL_GetTxPktCount %d",
3794 ucSTAId));
3795 return VOS_STATUS_E_EXISTS;
3796 }
3797
3798 /*------------------------------------------------------------------------
3799 Return data
3800 ------------------------------------------------------------------------*/
3801 //VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_MED,
3802 // "WLAN TL:Requested tx packet count for STA: %d, TID: %d",
3803 // ucSTAId, ucTid);
3804
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05303805 *puTxPktCount = pTLCb->atlSTAClients[ucSTAId]->auTxCount[ucTid];
Jeff Johnson295189b2012-06-20 16:38:30 -07003806
3807 return VOS_STATUS_SUCCESS;
3808}/* WLANTL_GetTxPktCount */
3809
3810/*==========================================================================
3811
3812 FUNCTION WLANTL_GetRxPktCount
3813
3814 DESCRIPTION
3815 TL will provide the number of received packets counted per
3816 STA per TID.
3817
3818 DEPENDENCIES
3819
3820 PARAMETERS
3821
3822 IN
3823 pvosGCtx: pointer to the global vos context; a handle to TL's
3824 control block can be extracted from its context
3825 ucSTAId: identifier of the station
3826 ucTid: identifier of the tspec
3827
3828 OUT
3829 puTxPktCount: the number of packets rx packet for this STA and TID
3830
3831 RETURN VALUE
3832 The result code associated with performing the operation
3833
3834 VOS_STATUS_E_INVAL: Input parameters are invalid
3835 VOS_STATUS_E_FAULT: Station ID is outside array boundaries or pointer
3836 to TL cb is NULL ; access would cause a page fault
3837 VOS_STATUS_E_EXISTS: Station was not registered
3838 VOS_STATUS_SUCCESS: Everything is good :)
3839
3840 SIDE EFFECTS
3841
3842============================================================================*/
3843VOS_STATUS
3844WLANTL_GetRxPktCount
3845(
3846 v_PVOID_t pvosGCtx,
3847 v_U8_t ucSTAId,
3848 v_U8_t ucTid,
3849 v_U32_t* puRxPktCount
3850)
3851{
3852 WLANTL_CbType* pTLCb = NULL;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05303853 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07003854 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
3855
3856 /*------------------------------------------------------------------------
3857 Sanity check
3858 ------------------------------------------------------------------------*/
3859 if ( NULL == puRxPktCount )
3860 {
3861 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3862 "WLAN TL:Invalid parameter sent on WLANTL_GetRxPktCount"));
3863 return VOS_STATUS_E_INVAL;
3864 }
3865
3866 if ( WLANTL_STA_ID_INVALID( ucSTAId ) || WLANTL_TID_INVALID( ucTid) )
3867 {
3868 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3869 "WLAN TL:Invalid station id %d/tid %d requested on WLANTL_GetRxPktCount",
3870 ucSTAId, ucTid));
3871 return VOS_STATUS_E_FAULT;
3872 }
3873
3874 /*------------------------------------------------------------------------
3875 Extract TL control block and existance
3876 ------------------------------------------------------------------------*/
3877 pTLCb = VOS_GET_TL_CB(pvosGCtx);
3878 if ( NULL == pTLCb )
3879 {
3880 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3881 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_GetRxPktCount"));
3882 return VOS_STATUS_E_FAULT;
3883 }
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05303884 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
Jeff Johnson295189b2012-06-20 16:38:30 -07003885
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05303886 if ( NULL == pClientSTA )
3887 {
3888 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3889 "WLAN TL:Client Memory was not allocated on %s", __func__));
3890 return VOS_STATUS_E_FAILURE;
3891 }
3892
3893 if ( 0 == pClientSTA->ucExists )
Jeff Johnson295189b2012-06-20 16:38:30 -07003894 {
3895 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3896 "WLAN TL:Station was not previously registered on WLANTL_GetRxPktCount"));
3897 return VOS_STATUS_E_EXISTS;
3898 }
3899
3900 /*------------------------------------------------------------------------
3901 Return data
3902 ------------------------------------------------------------------------*/
3903 TLLOG3(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_MED,
3904 "WLAN TL:Requested rx packet count for STA: %d, TID: %d",
3905 ucSTAId, ucTid));
3906
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05303907 *puRxPktCount = pClientSTA->auRxCount[ucTid];
Jeff Johnson295189b2012-06-20 16:38:30 -07003908
3909 return VOS_STATUS_SUCCESS;
3910}/* WLANTL_GetRxPktCount */
3911
Jeff Johnson295189b2012-06-20 16:38:30 -07003912VOS_STATUS
3913WLANTL_TxFCFrame
3914(
3915 v_PVOID_t pvosGCtx
3916);
Jeff Johnson295189b2012-06-20 16:38:30 -07003917/*============================================================================
3918 TL INTERNAL API DEFINITION
3919============================================================================*/
3920
3921/*==========================================================================
3922
3923 FUNCTION WLANTL_GetFrames
3924
3925 DESCRIPTION
3926
3927 BAL calls this function at the request of the lower bus interface.
3928 When this request is being received TL will retrieve packets from HDD
3929 in accordance with the priority rules and the count supplied by BAL.
3930
3931 DEPENDENCIES
3932
3933 HDD must have registered with TL at least one STA before this function
3934 can be called.
3935
3936 PARAMETERS
3937
3938 IN
3939 pvosGCtx: pointer to the global vos context; a handle to TL's
3940 or BAL's control block can be extracted from its context
3941 uSize: maximum size accepted by the lower layer
3942 uFlowMask TX flow control mask for Prima. Each bit is defined as
3943 WDA_TXFlowEnumType
3944
3945 OUT
3946 vosDataBuff: it will contain a pointer to the first buffer supplied
3947 by TL, if there is more than one packet supplied, TL
3948 will chain them through vOSS buffers
3949
3950 RETURN VALUE
3951
3952 The result code associated with performing the operation
3953
3954 1 or more: number of required resources if there are still frames to fetch
3955 0 : error or HDD queues are drained
3956
3957 SIDE EFFECTS
3958
3959 NOTE
3960
3961 Featurized uFlowMask. If we want to remove featurization, we need to change
3962 BAL on Volans.
3963
3964============================================================================*/
3965v_U32_t
3966WLANTL_GetFrames
3967(
3968 v_PVOID_t pvosGCtx,
3969 vos_pkt_t **ppFrameDataBuff,
3970 v_U32_t uSize,
Jeff Johnson295189b2012-06-20 16:38:30 -07003971 v_U8_t uFlowMask,
Jeff Johnson295189b2012-06-20 16:38:30 -07003972 v_BOOL_t* pbUrgent
3973)
3974{
3975 vos_pkt_t** pvosDataBuff = (vos_pkt_t**)ppFrameDataBuff;
3976 WLANTL_CbType* pTLCb = NULL;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05303977 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07003978 v_U32_t uRemaining = uSize;
3979 vos_pkt_t* vosRoot;
3980 vos_pkt_t* vosTempBuf;
3981 WLANTL_STAFuncType pfnSTAFsm;
3982 v_U16_t usPktLen;
3983 v_U32_t uResLen;
3984 v_U8_t ucSTAId;
3985 v_U8_t ucAC;
3986 vos_pkt_t* vosDataBuff;
3987 v_U32_t uTotalPktLen;
3988 v_U32_t i=0;
Tushnim Bhattacharyya39a8f182013-02-20 18:10:30 -08003989 v_U32_t j=0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003990 v_U32_t ucResult = 0;
3991 VOS_STATUS vosStatus;
3992 WLANTL_STAEventType wSTAEvent;
3993 tBssSystemRole systemRole;
3994 tpAniSirGlobal pMac;
3995 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
3996
3997 /*------------------------------------------------------------------------
3998 Sanity check
3999 Extract TL control block
4000 ------------------------------------------------------------------------*/
4001 pTLCb = VOS_GET_TL_CB(pvosGCtx);
4002 if (( NULL == pTLCb ) || ( NULL == pvosDataBuff ))
4003 {
4004 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
4005 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_ChangeSTAState"));
4006 return ucResult;
4007 }
4008
4009 pMac = vos_get_context(VOS_MODULE_ID_PE, pvosGCtx);
4010 if ( NULL == pMac )
4011 {
4012 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004013 "%s: Invalid pMac", __func__));
Jeff Johnson295189b2012-06-20 16:38:30 -07004014 return ucResult;
4015 }
4016
4017 vosDataBuff = pTLCb->vosDummyBuf; /* Just to avoid checking for NULL at
4018 each iteration */
4019
Jeff Johnson295189b2012-06-20 16:38:30 -07004020 pTLCb->uResCount = uSize;
Jeff Johnson295189b2012-06-20 16:38:30 -07004021
4022 /*-----------------------------------------------------------------------
4023 Save the root as we will walk this chain as we fill it
4024 -----------------------------------------------------------------------*/
4025 vosRoot = vosDataBuff;
4026
4027 /*-----------------------------------------------------------------------
4028 There is still data - until FSM function says otherwise
4029 -----------------------------------------------------------------------*/
4030 pTLCb->bUrgent = FALSE;
4031
Jeff Johnson295189b2012-06-20 16:38:30 -07004032 while (( pTLCb->tlConfigInfo.uMinFramesProcThres < pTLCb->uResCount ) &&
4033 ( 0 < uRemaining ))
Jeff Johnson295189b2012-06-20 16:38:30 -07004034 {
4035 systemRole = wdaGetGlobalSystemRole(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -07004036#ifdef WLAN_SOFTAP_FLOWCTRL_EN
4037/* FIXME: The code has been disabled since it is creating issues in power save */
4038 if (eSYSTEM_AP_ROLE == systemRole)
4039 {
4040 if (pTLCb->done_once == 0 && NULL == pTLCb->vosTxFCBuf)
4041 {
4042 WLANTL_TxFCFrame (pvosGCtx);
4043 pTLCb->done_once ++;
4044 }
4045 }
4046 if ( NULL != pTLCb->vosTxFCBuf )
4047 {
4048 //there is flow control packet waiting to be sent
4049 WDA_TLI_PROCESS_FRAME_LEN( pTLCb->vosTxFCBuf, usPktLen, uResLen, uTotalPktLen);
4050
4051 if ( ( pTLCb->uResCount > uResLen ) &&
Jeff Johnson9b5dc4d2013-02-22 21:28:47 -08004052 ( uRemaining > uTotalPktLen ) &&
4053 ( uFlowMask & ( 1 << WDA_TXFLOW_FC ) ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07004054 {
4055 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
4056 "WLAN TL:Chaining FC frame first on GetFrame"));
4057
4058 vos_pkt_chain_packet( vosDataBuff, pTLCb->vosTxFCBuf, 1 /*true*/ );
4059
4060 vos_atomic_set_U32( (v_U32_t*)&pTLCb->vosTxFCBuf, (v_U32_t)NULL);
4061
4062 /*FC frames cannot be delayed*/
4063 pTLCb->bUrgent = TRUE;
4064
4065 /*Update remaining len from SSC */
4066 uRemaining -= (usPktLen + WDA_DXE_HEADER_SIZE);
4067
4068 /*Update resource count */
4069 pTLCb->uResCount -= uResLen;
4070 }
4071 else
4072 {
4073 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004074 "WLAN TL:send fc out of source %s", __func__));
Jeff Johnson295189b2012-06-20 16:38:30 -07004075 ucResult = ( pTLCb->uResCount > uResLen )?VOS_TRUE:VOS_FALSE;
4076 break; /* Out of resources or reached max len */
4077 }
4078 }
4079 else
4080#endif //WLAN_SOFTAP_FLOWCTRL_EN
Jeff Johnson295189b2012-06-20 16:38:30 -07004081
Jeff Johnson9b5dc4d2013-02-22 21:28:47 -08004082 if (( NULL != pTLCb->tlMgmtFrmClient.vosPendingDataBuff ) &&
4083 ( uFlowMask & ( 1 << WDA_TXFLOW_MGMT ) ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07004084 {
4085 WDA_TLI_PROCESS_FRAME_LEN( pTLCb->tlMgmtFrmClient.vosPendingDataBuff,
4086 usPktLen, uResLen, uTotalPktLen);
4087
4088 VOS_ASSERT(usPktLen <= WLANTL_MAX_ALLOWED_LEN);
4089
4090 if ( ( pTLCb->uResCount > uResLen ) &&
Jeff Johnson9b5dc4d2013-02-22 21:28:47 -08004091 ( uRemaining > uTotalPktLen ) &&
4092 ( uFlowMask & ( 1 << WDA_TXFLOW_MGMT ) ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07004093 {
4094 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
4095 "WLAN TL:Chaining management frame on GetFrame"));
4096
4097 vos_pkt_chain_packet( vosDataBuff,
4098 pTLCb->tlMgmtFrmClient.vosPendingDataBuff,
4099 1 /*true*/ );
4100
4101 vos_atomic_set_U32( (v_U32_t*)&pTLCb->tlMgmtFrmClient.
4102 vosPendingDataBuff, (v_U32_t)NULL);
4103
4104 /*management frames cannot be delayed*/
4105 pTLCb->bUrgent = TRUE;
4106
4107 /*Update remaining len from SSC */
4108 uRemaining -= (usPktLen + WDA_DXE_HEADER_SIZE);
4109
4110 /*Update resource count */
4111 pTLCb->uResCount -= uResLen;
4112 }
4113 else
4114 {
4115 ucResult = ( pTLCb->uResCount > uResLen )?VOS_TRUE:VOS_FALSE;
4116 break; /* Out of resources or reached max len */
4117 }
4118 }
4119 else if (( pTLCb->tlBAPClient.vosPendingDataBuff ) &&
4120 ( WDA_TLI_MIN_RES_BAP <= pTLCb->uResCount ) &&
Gopichand Nakkala7e48ca72012-12-31 14:15:07 -08004121 ( 0 == pTLCb->ucTxSuspended ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07004122 {
4123 WDA_TLI_PROCESS_FRAME_LEN( pTLCb->tlBAPClient.vosPendingDataBuff,
4124 usPktLen, uResLen, uTotalPktLen);
4125
4126 VOS_ASSERT(usPktLen <= WLANTL_MAX_ALLOWED_LEN);
4127
4128 if ( ( pTLCb->uResCount > (uResLen + WDA_TLI_MIN_RES_MF ) ) &&
4129 ( uRemaining > uTotalPktLen ))
4130 {
4131 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
4132 "WLAN TL:Chaining BT-AMP frame on GetFrame"));
4133
4134 vos_pkt_chain_packet( vosDataBuff,
4135 pTLCb->tlBAPClient.vosPendingDataBuff,
4136 1 /*true*/ );
4137
4138 /*BAP frames cannot be delayed*/
4139 pTLCb->bUrgent = TRUE;
4140
4141 vos_atomic_set_U32( (v_U32_t*)&pTLCb->tlBAPClient.vosPendingDataBuff,
4142 (v_U32_t)NULL);
4143
4144 /*Update remaining len from SSC */
4145 uRemaining -= (usPktLen + WDA_DXE_HEADER_SIZE);
4146
4147 /*Update resource count */
4148 pTLCb->uResCount -= uResLen;
4149 }
4150 else
4151 {
Jeff Johnson295189b2012-06-20 16:38:30 -07004152 ucResult = uResLen + WDA_TLI_MIN_RES_MF;
Jeff Johnson295189b2012-06-20 16:38:30 -07004153 break; /* Out of resources or reached max len */
4154 }
4155 }
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -07004156 /* note: this feature implemented only after WLAN_INGETRATED_SOC */
4157 /* search 'EAPOL_HI_PRIORITY' will show EAPOL HI_PRIORITY change in TL and WDI
4158 by default, EAPOL will be treated as higher priority, which means
4159 use mgmt_pool and DXE_TX_HI prority channel.
4160 this is introduced to address EAPOL failure under high background traffic
4161 with multi-channel concurrent mode. But this change works in SCC or standalone, too.
4162 see CR#387009 and WCNSOS-8
4163 */
4164 else if (( WDA_TLI_MIN_RES_MF <= pTLCb->uResCount )&&
4165 ( 0 == pTLCb->ucTxSuspended ) &&
4166 ( uFlowMask & ( 1 << WDA_TXFLOW_MGMT ) )
4167 )
4168 {
4169 vosTempBuf = NULL;
4170 /*---------------------------------------------------------------------
4171 Check to see if there was any EAPOL packet is pending
4172 *--------------------------------------------------------------------*/
4173 for ( i = 0; i < WLAN_MAX_STA_COUNT; i++)
4174 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304175 if ((NULL != pTLCb->atlSTAClients[i]) &&
4176 (pTLCb->atlSTAClients[i]->ucExists) &&
4177 (0 == pTLCb->atlSTAClients[i]->ucTxSuspended) &&
Tushnim Bhattacharyya39a8f182013-02-20 18:10:30 -08004178 (WLANTL_STA_CONNECTED == pTLCb->atlSTAClients[i]->tlState) &&
4179 (pTLCb->atlSTAClients[i]->ucPktPending)
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -07004180 )
4181 break;
4182 }
4183
4184 if (i >= WLAN_MAX_STA_COUNT)
4185 {
4186 /* No More to Serve Exit Get Frames */
4187 break;
4188 }
4189 /* Serve EAPOL frame with HI_FLOW_MASK */
4190 ucSTAId = i;
4191
Tushnim Bhattacharyya39a8f182013-02-20 18:10:30 -08004192 for (j = WLANTL_MAX_AC ; j > 0; j--)
4193 {
4194 if (0 != pTLCb->atlSTAClients[ucSTAId]->aucACMask[j-1])
4195 {
4196 pTLCb->atlSTAClients[ucSTAId]->ucCurrentAC = j-1;
4197 pTLCb->uCurServedAC = j-1;
4198 }
4199 }
4200
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304201 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
4202
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -07004203 wSTAEvent = WLANTL_TX_EVENT;
4204
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304205 pfnSTAFsm = tlSTAFsm[pClientSTA->tlState].
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -07004206 pfnSTATbl[wSTAEvent];
4207
4208 if ( NULL != pfnSTAFsm )
4209 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304210 pClientSTA->ucNoMoreData = 0;
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -07004211 vosStatus = pfnSTAFsm( pvosGCtx, ucSTAId, &vosTempBuf);
4212
4213 if (( VOS_STATUS_SUCCESS != vosStatus ) &&
4214 ( NULL != vosTempBuf ))
4215 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304216 pClientSTA->pfnSTATxComp( pvosGCtx, vosTempBuf, vosStatus );
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -07004217 vosTempBuf = NULL;
4218 break;
4219 }/* status success*/
4220 }
4221
4222 if (NULL != vosTempBuf)
4223 {
4224 WDA_TLI_PROCESS_FRAME_LEN( vosTempBuf, usPktLen, uResLen, uTotalPktLen);
4225
4226 VOS_ASSERT( usPktLen <= WLANTL_MAX_ALLOWED_LEN);
4227
4228 TLLOG4(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_LOW,
4229 "WLAN TL:Resources needed by frame: %d", uResLen));
4230
4231 if ( ( pTLCb->uResCount >= (uResLen + WDA_TLI_MIN_RES_MF ) ) &&
4232 ( uRemaining > uTotalPktLen )
4233 )
4234 {
4235 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
4236 "WLAN TL:Chaining data frame on GetFrame"));
4237
4238 vos_pkt_chain_packet( vosDataBuff, vosTempBuf, 1 /*true*/ );
4239
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -07004240 /*EAPOL frame cannot be delayed*/
4241 pTLCb->bUrgent = TRUE;
4242
4243 vosTempBuf = NULL;
4244
4245 /*Update remaining len from SSC */
4246 uRemaining -= (usPktLen + WDA_DXE_HEADER_SIZE);
4247
4248 /*Update resource count */
4249 pTLCb->uResCount -= uResLen;
4250
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -07004251 //fow control update
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304252 pClientSTA->uIngress_length += uResLen;
4253 pClientSTA->uBuffThresholdMax = (pClientSTA->uBuffThresholdMax >= uResLen) ?
4254 (pClientSTA->uBuffThresholdMax - uResLen) : 0;
Tushnim Bhattacharyya39a8f182013-02-20 18:10:30 -08004255 pClientSTA->ucEapolPktPending = 0;
4256 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
4257 "WLAN TL:GetFrames STA: %d EAPOLPktPending %d",
4258 ucSTAId, pClientSTA->ucEapolPktPending);
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -07004259 }
4260 }
4261 else
4262 { // no EAPOL frames exit Get frames
Tushnim Bhattacharyya39a8f182013-02-20 18:10:30 -08004263 TLLOG2(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
4264 "WLAN TL:GetFrames STA: %d, no EAPOL frame, continue.",
4265 ucSTAId));
4266 continue;
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -07004267 }
4268 }
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -07004269
Jeff Johnson9b5dc4d2013-02-22 21:28:47 -08004270 else if (( WDA_TLI_MIN_RES_DATA <= pTLCb->uResCount ) &&
4271 ( 0 == pTLCb->ucTxSuspended ) &&
4272 (( uFlowMask & ( 1 << WDA_TXFLOW_AC_BK ) ) ||
4273 ( uFlowMask & ( 1 << WDA_TXFLOW_AC_BE ) ) ||
4274 ( uFlowMask & ( 1 << WDA_TXFLOW_AC_VI ) ) ||
4275 ( uFlowMask & ( 1 << WDA_TXFLOW_AC_VO ) )) )
Jeff Johnson295189b2012-06-20 16:38:30 -07004276 {
4277 /*---------------------------------------------------------------------
4278 Check to see if there was any packet left behind previously due to
4279 size constraints
4280 ---------------------------------------------------------------------*/
4281 vosTempBuf = NULL;
4282
4283 if ( NULL != pTLCb->vosTempBuf )
4284 {
4285 vosTempBuf = pTLCb->vosTempBuf;
4286 pTLCb->vosTempBuf = NULL;
4287 ucSTAId = pTLCb->ucCachedSTAId;
4288 ucAC = pTLCb->ucCachedAC;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304289
4290 if ( NULL == pTLCb->atlSTAClients[ucSTAId] )
4291 {
4292 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
4293 "WLAN TL:Client Memory was not allocated on %s", __func__));
Madan Mohan Koyylamudi64258222013-01-30 14:35:10 +05304294 continue;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304295 }
4296
4297 pTLCb->atlSTAClients[ucSTAId]->ucNoMoreData = 0;
Madan Mohan Koyylamudi64258222013-01-30 14:35:10 +05304298 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
Jeff Johnson295189b2012-06-20 16:38:30 -07004299
4300 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
4301 "WLAN TL:Chaining cached data frame on GetFrame"));
4302 }
4303 else
4304 {
4305 WLAN_TLGetNextTxIds( pvosGCtx, &ucSTAId);
4306 if (ucSTAId >= WLAN_MAX_STA_COUNT)
4307 {
4308 /* Packets start coming in even after insmod Without *
4309 starting Hostapd or Interface being up *
4310 During which cases STAID is invaled and hence
4311 the check. HalMsg_ScnaComplete Triggers */
4312
4313 break;
4314 }
4315 /* ucCurrentAC should have correct AC to be served by calling
4316 WLAN_TLGetNextTxIds */
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304317 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304318 if ( NULL == pClientSTA )
4319 {
4320 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
4321 "WLAN TL:Client Memory was not allocated on %s", __func__));
Madan Mohan Koyylamudi64258222013-01-30 14:35:10 +05304322 continue;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304323 }
4324
4325 ucAC = pClientSTA->ucCurrentAC;
4326
4327 pClientSTA->ucNoMoreData = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07004328 TLLOG4(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_LOW,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004329 "WLAN TL: %s get one data frame, station ID %d ", __func__, ucSTAId));
Jeff Johnson295189b2012-06-20 16:38:30 -07004330 /*-------------------------------------------------------------------
4331 Check to see that STA is valid and tx is not suspended
4332 -------------------------------------------------------------------*/
4333 if ( ( ! WLANTL_STA_ID_INVALID( ucSTAId ) ) &&
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304334 ( 0 == pClientSTA->ucTxSuspended ) &&
4335 ( 0 == pClientSTA->fcStaTxDisabled) )
Jeff Johnson295189b2012-06-20 16:38:30 -07004336 {
4337 TLLOG4(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_LOW,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004338 "WLAN TL: %s sta id valid and not suspended ",__func__));
Jeff Johnson295189b2012-06-20 16:38:30 -07004339 wSTAEvent = WLANTL_TX_EVENT;
4340
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304341 pfnSTAFsm = tlSTAFsm[pClientSTA->tlState].
Jeff Johnson295189b2012-06-20 16:38:30 -07004342 pfnSTATbl[wSTAEvent];
4343
4344 if ( NULL != pfnSTAFsm )
4345 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304346 pClientSTA->ucNoMoreData = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004347 vosStatus = pfnSTAFsm( pvosGCtx, ucSTAId, &vosTempBuf);
4348
4349 if (( VOS_STATUS_SUCCESS != vosStatus ) &&
4350 ( NULL != vosTempBuf ))
4351 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304352 pClientSTA->pfnSTATxComp( pvosGCtx,
Jeff Johnson295189b2012-06-20 16:38:30 -07004353 vosTempBuf,
4354 vosStatus );
4355 vosTempBuf = NULL;
4356 }/* status success*/
4357 }/*NULL function state*/
4358 }/* valid STA id and ! suspended*/
4359 else
4360 {
4361 if ( ! WLANTL_STA_ID_INVALID( ucSTAId ) )
4362 {
4363 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
4364 "WLAN TL:Not fetching frame because suspended for sta ID %d",
4365 ucSTAId));
4366 }
4367 }
4368 }/* data */
4369
4370 if ( NULL != vosTempBuf )
4371 {
4372 WDA_TLI_PROCESS_FRAME_LEN( vosTempBuf, usPktLen, uResLen, uTotalPktLen);
4373
4374 VOS_ASSERT( usPktLen <= WLANTL_MAX_ALLOWED_LEN);
4375
4376 TLLOG4(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_LOW,
4377 "WLAN TL:Resources needed by frame: %d", uResLen));
4378
4379 if ( ( pTLCb->uResCount >= (uResLen + WDA_TLI_MIN_RES_BAP ) ) &&
Jeff Johnson9b5dc4d2013-02-22 21:28:47 -08004380 ( uRemaining > uTotalPktLen ) &&
4381 ( uFlowMask & ( 1 << ucAC ) ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07004382 {
4383 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
4384 "WLAN TL:Chaining data frame on GetFrame"));
4385
4386 vos_pkt_chain_packet( vosDataBuff, vosTempBuf, 1 /*true*/ );
4387 vosTempBuf = NULL;
4388
4389 /*Update remaining len from SSC */
4390 uRemaining -= (usPktLen + WDA_DXE_HEADER_SIZE);
4391
4392 /*Update resource count */
4393 pTLCb->uResCount -= uResLen;
4394
Jeff Johnson295189b2012-06-20 16:38:30 -07004395 //fow control update
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304396 pClientSTA->uIngress_length += uResLen;
4397 pClientSTA->uBuffThresholdMax = (pClientSTA->uBuffThresholdMax >= uResLen) ?
4398 (pClientSTA->uBuffThresholdMax - uResLen) : 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004399
4400 }
4401 else
4402 {
4403 /* Store this for later tx - already fetched from HDD */
4404 pTLCb->vosTempBuf = vosTempBuf;
4405 pTLCb->ucCachedSTAId = ucSTAId;
4406 pTLCb->ucCachedAC = ucAC;
Jeff Johnson295189b2012-06-20 16:38:30 -07004407 ucResult = uResLen + WDA_TLI_MIN_RES_BAP;
4408 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
4409 "min %d res required by TL.", ucResult ));
Jeff Johnson295189b2012-06-20 16:38:30 -07004410 break; /* Out of resources or reached max len */
4411 }
4412 }
4413 else
4414 {
4415 for ( i = 0; i < WLAN_MAX_STA_COUNT; i++)
4416 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304417 if (NULL != pTLCb->atlSTAClients[i] && (pTLCb->atlSTAClients[i]->ucExists) &&
4418 (pTLCb->atlSTAClients[i]->ucPktPending))
Jeff Johnson295189b2012-06-20 16:38:30 -07004419 {
4420 /* There is station to be Served */
4421 break;
4422 }
4423 }
4424 if (i >= WLAN_MAX_STA_COUNT)
4425 {
4426 /* No More to Serve Exit Get Frames */
4427 break;
4428 }
4429 else
4430 {
4431 /* More to be Served */
4432 continue;
4433 }
4434 }
4435 }
4436 else
4437 {
4438 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
4439 "WLAN TL:Returning from GetFrame: resources = %d suspended = %d",
4440 pTLCb->uResCount, pTLCb->ucTxSuspended));
Jeff Johnson295189b2012-06-20 16:38:30 -07004441 /* TL is starving even when DXE is not in low resource condition
4442 Return min resource number required and Let DXE deceide what to do */
4443 if(( 0 == pTLCb->ucTxSuspended ) &&
4444 (( uFlowMask & ( 1 << WDA_TXFLOW_AC_BK ) ) ||
4445 ( uFlowMask & ( 1 << WDA_TXFLOW_AC_BE ) ) ||
4446 ( uFlowMask & ( 1 << WDA_TXFLOW_AC_VI ) ) ||
4447 ( uFlowMask & ( 1 << WDA_TXFLOW_AC_VO ) )))
4448 {
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07004449 TLLOG1(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -07004450 "WLAN TL:Returning from GetFrame: resources = %d",
4451 pTLCb->uResCount));
4452 ucResult = WDA_TLI_MIN_RES_DATA;
4453 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004454 break; /*out of min data resources*/
4455 }
4456
4457 pTLCb->usPendingTxCompleteCount++;
4458 /* Move data buffer up one packet */
4459 vos_pkt_walk_packet_chain( vosDataBuff, &vosDataBuff, 0/*false*/ );
4460 }
4461
4462 /*----------------------------------------------------------------------
4463 Packet chain starts at root + 1
4464 ----------------------------------------------------------------------*/
4465 vos_pkt_walk_packet_chain( vosRoot, &vosDataBuff, 1/*true*/ );
4466
4467 *pvosDataBuff = vosDataBuff;
4468 VOS_ASSERT( pbUrgent );
4469 *pbUrgent = pTLCb->bUrgent;
4470 return ucResult;
4471}/* WLANTL_GetFrames */
4472
4473
4474/*==========================================================================
4475
4476 FUNCTION WLANTL_TxComp
4477
4478 DESCRIPTION
4479 It is being called by BAL upon asynchronous notification of the packet
4480 or packets being sent over the bus.
4481
4482 DEPENDENCIES
4483 Tx complete cannot be called without a previous transmit.
4484
4485 PARAMETERS
4486
4487 IN
4488 pvosGCtx: pointer to the global vos context; a handle to TL's
4489 or BAL's control block can be extracted from its context
4490 vosDataBuff: it will contain a pointer to the first buffer for which
4491 the BAL report is being made, if there is more then one
4492 packet they will be chained using vOSS buffers.
4493 wTxStatus: the status of the transmitted packet, see above chapter
4494 on HDD interaction for a list of possible values
4495
4496 RETURN VALUE
4497 The result code associated with performing the operation
4498
4499 VOS_STATUS_E_INVAL: Input parameters are invalid
4500 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
4501 page fault
4502 VOS_STATUS_E_EXISTS: Station was not registered
4503 VOS_STATUS_SUCCESS: Everything is good :)
4504
4505 SIDE EFFECTS
4506
4507============================================================================*/
4508VOS_STATUS
4509WLANTL_TxComp
4510(
4511 v_PVOID_t pvosGCtx,
4512 vos_pkt_t *pFrameDataBuff,
4513 VOS_STATUS wTxStatus
4514)
4515{
4516 vos_pkt_t* vosDataBuff = (vos_pkt_t*)pFrameDataBuff;
4517 WLANTL_CbType* pTLCb = NULL;
4518 WLANTL_TxCompCBType pfnTxComp = NULL;
4519 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07004520 vos_pkt_t* vosTempTx = NULL;
4521
4522 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
4523
4524 /*------------------------------------------------------------------------
4525 Sanity check
4526 ------------------------------------------------------------------------*/
4527 if ( NULL == vosDataBuff )
4528 {
4529 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
4530 "WLAN TL:Extraneous NULL data pointer on WLANTL_TxComp"));
4531 return VOS_STATUS_E_INVAL;
4532 }
4533
4534 /*------------------------------------------------------------------------
4535 Extract TL control block
4536 ------------------------------------------------------------------------*/
4537 pTLCb = VOS_GET_TL_CB(pvosGCtx);
4538 if ( NULL == pTLCb )
4539 {
4540 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
4541 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_TxComp"));
4542 return VOS_STATUS_E_FAULT;
4543 }
4544
4545 while ((0 < pTLCb->usPendingTxCompleteCount) &&
4546 ( VOS_STATUS_SUCCESS == vosStatus ) &&
4547 ( NULL != vosDataBuff))
4548 {
4549 vos_pkt_get_user_data_ptr( vosDataBuff, VOS_PKT_USER_DATA_ID_TL,
4550 (v_PVOID_t)&pfnTxComp);
4551
4552 /*it should never be NULL - default handler should be registered if none*/
4553 if ( NULL == pfnTxComp )
4554 {
4555 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
4556 "WLAN TL:NULL pointer to Tx Complete on WLANTL_TxComp"));
4557 VOS_ASSERT(0);
4558 return VOS_STATUS_E_FAULT;
4559 }
4560
4561 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05304562 "WLAN TL:Calling Tx complete for pkt %p in function %p",
Jeff Johnson295189b2012-06-20 16:38:30 -07004563 vosDataBuff, pfnTxComp));
4564
4565 vosTempTx = vosDataBuff;
4566 vosStatus = vos_pkt_walk_packet_chain( vosDataBuff,
4567 &vosDataBuff, 1/*true*/);
4568
4569 pfnTxComp( pvosGCtx, vosTempTx, wTxStatus );
4570
4571 pTLCb->usPendingTxCompleteCount--;
4572 }
4573
Jeff Johnson295189b2012-06-20 16:38:30 -07004574
4575 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
4576 "WLAN TL: current TL values are: resources = %d "
4577 "pTLCb->usPendingTxCompleteCount = %d",
4578 pTLCb->uResCount, pTLCb->usPendingTxCompleteCount));
4579
4580 return VOS_STATUS_SUCCESS;
4581}/* WLANTL_TxComp */
4582
4583/*==========================================================================
4584
4585 FUNCTION WLANTL_CacheSTAFrame
4586
4587 DESCRIPTION
4588 Internal utility function for for caching incoming data frames that do
4589 not have a registered station yet.
4590
4591 DEPENDENCIES
4592 TL must be initiailized before this function gets called.
4593 In order to benefit from thsi caching, the components must ensure that
4594 they will only register with TL at the moment when they are fully setup
4595 and ready to receive incoming data
4596
4597 PARAMETERS
4598
4599 IN
4600
4601 pTLCb: TL control block
4602 ucSTAId: station id
4603 vosTempBuff: the data packet
4604 uDPUSig: DPU signature of the incoming packet
4605 bBcast: true if packet had the MC/BC bit set
4606
4607 RETURN VALUE
4608 The result code associated with performing the operation
4609
4610 VOS_STATUS_E_FAULT: pointer to TL cb is NULL or STA Id invalid ; access
4611 would cause a page fault
4612 VOS_STATUS_SUCCESS: Everything is good :)
4613
4614 SIDE EFFECTS
4615
4616============================================================================*/
4617static VOS_STATUS
4618WLANTL_CacheSTAFrame
4619(
4620 WLANTL_CbType* pTLCb,
4621 v_U8_t ucSTAId,
4622 vos_pkt_t* vosTempBuff,
4623 v_U32_t uDPUSig,
4624 v_U8_t bBcast,
4625 v_U8_t ucFrmType
4626)
4627{
4628 v_U8_t ucUcastSig;
4629 v_U8_t ucBcastSig;
4630 v_BOOL_t bOldSTAPkt;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304631 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004632 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
4633
4634 /*-------------------------------------------------------------------------
4635 Sanity check
4636 -------------------------------------------------------------------------*/
4637 if (( NULL == pTLCb ) || ( NULL == vosTempBuff ) )
4638 {
4639 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05304640 "WLAN TL: Invalid input pointer on WLANTL_CacheSTAFrame TL %p"
4641 " Packet %p", pTLCb, vosTempBuff ));
Jeff Johnson295189b2012-06-20 16:38:30 -07004642 return VOS_STATUS_E_FAULT;
4643 }
4644
4645 if ( WLANTL_STA_ID_INVALID( ucSTAId ) )
4646 {
4647 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
4648 "WLAN TL:Invalid station id requested on WLANTL_CacheSTAFrame"));
4649 return VOS_STATUS_E_FAULT;
4650 }
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304651 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
4652
4653 if ( NULL == pClientSTA )
4654 {
4655 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
4656 "WLAN TL:Client Memory was not allocated on %s", __func__));
4657 return VOS_STATUS_E_FAILURE;
4658 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004659
4660 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
4661 "WLAN TL:Attempting to cache pkt for STA %d, BD DPU Sig: %d with sig UC: %d, BC: %d",
4662 ucSTAId, uDPUSig,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304663 pClientSTA->wSTADesc.ucUcastSig,
4664 pClientSTA->wSTADesc.ucBcastSig));
Jeff Johnson295189b2012-06-20 16:38:30 -07004665
4666 if(WLANTL_IS_CTRL_FRAME(ucFrmType))
4667 {
4668 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
4669 "WLAN TL: No need to cache CTRL frame. Dropping"));
4670 vos_pkt_return_packet(vosTempBuff);
4671 return VOS_STATUS_SUCCESS;
4672 }
4673
4674 /*-------------------------------------------------------------------------
4675 Check if the packet that we are trying to cache belongs to the old
4676 registered station (if any) or the new (potentially)upcoming station
4677
4678 - If the STA with this Id was never registered with TL - the signature
4679 will be invalid;
4680 - If the STA was previously registered TL will have cached the former
4681 set of DPU signatures
4682 -------------------------------------------------------------------------*/
4683 if ( bBcast )
4684 {
4685 ucBcastSig = (v_U8_t)uDPUSig;
4686 bOldSTAPkt = (( WLAN_TL_INVALID_B_SIG !=
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304687 pClientSTA->wSTADesc.ucBcastSig ) &&
4688 ( ucBcastSig == pClientSTA->wSTADesc.ucBcastSig ));
Jeff Johnson295189b2012-06-20 16:38:30 -07004689 }
4690 else
4691 {
4692 ucUcastSig = (v_U8_t)uDPUSig;
4693 bOldSTAPkt = (( WLAN_TL_INVALID_U_SIG !=
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304694 pClientSTA->wSTADesc.ucUcastSig ) &&
4695 ( ucUcastSig == pClientSTA->wSTADesc.ucUcastSig ));
Jeff Johnson295189b2012-06-20 16:38:30 -07004696 }
4697
4698 /*------------------------------------------------------------------------
4699 If the value of the DPU SIG matches the old, this packet will not
4700 be cached as it belonged to the former association
4701 In case the SIG does not match - this is a packet for a potentially new
4702 associated station
4703 -------------------------------------------------------------------------*/
Varun Reddy Yeturua39b9902013-01-18 15:48:32 -08004704 if ( bOldSTAPkt || bBcast )
Jeff Johnson295189b2012-06-20 16:38:30 -07004705 {
4706 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
4707 "WLAN TL:Data packet matches old sig for sig DPU: %d UC: %d, "
4708 "BC: %d - dropping",
4709 uDPUSig,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304710 pClientSTA->wSTADesc.ucUcastSig,
4711 pClientSTA->wSTADesc.ucBcastSig));
Jeff Johnson295189b2012-06-20 16:38:30 -07004712 vos_pkt_return_packet(vosTempBuff);
4713 }
4714 else
4715 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304716 if ( NULL == pClientSTA->vosBegCachedFrame )
Jeff Johnson295189b2012-06-20 16:38:30 -07004717 {
4718 /*this is the first frame that we are caching */
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304719 pClientSTA->vosBegCachedFrame = vosTempBuff;
Jeff Johnson295189b2012-06-20 16:38:30 -07004720 }
4721 else
4722 {
4723 /*this is a subsequent frame that we are caching: chain to the end */
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304724 vos_pkt_chain_packet(pClientSTA->vosEndCachedFrame,
Jeff Johnson295189b2012-06-20 16:38:30 -07004725 vosTempBuff, VOS_TRUE);
4726 }
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304727 pClientSTA->vosEndCachedFrame = vosTempBuff;
Jeff Johnson295189b2012-06-20 16:38:30 -07004728 }/*else new packet*/
4729
4730 return VOS_STATUS_SUCCESS;
4731}/*WLANTL_CacheSTAFrame*/
4732
4733/*==========================================================================
4734
4735 FUNCTION WLANTL_FlushCachedFrames
4736
4737 DESCRIPTION
4738 Internal utility function used by TL to flush the station cache
4739
4740 DEPENDENCIES
4741 TL must be initiailized before this function gets called.
4742
4743 PARAMETERS
4744
4745 IN
4746
4747 vosDataBuff: it will contain a pointer to the first cached buffer
4748 received,
4749
4750 RETURN VALUE
4751 The result code associated with performing the operation
4752
4753 VOS_STATUS_SUCCESS: Everything is good :)
4754
4755 SIDE EFFECTS
4756
4757 NOTE
4758 This function doesn't re-initialize vosDataBuff to NULL. It's caller's
4759 responsibility to do so, if required, after this function call.
4760 Because of this restriction, we decide to make this function to static
4761 so that upper layer doesn't need to be aware of this restriction.
4762
4763============================================================================*/
4764static VOS_STATUS
4765WLANTL_FlushCachedFrames
4766(
4767 vos_pkt_t* vosDataBuff
4768)
4769{
4770 /*----------------------------------------------------------------------
4771 Return the entire chain to vos if there are indeed cache frames
4772 ----------------------------------------------------------------------*/
4773 if ( NULL != vosDataBuff )
4774 {
4775 vos_pkt_return_packet(vosDataBuff);
4776 }
4777
4778 return VOS_STATUS_SUCCESS;
4779}/*WLANTL_FlushCachedFrames*/
4780
4781/*==========================================================================
4782
4783 FUNCTION WLANTL_ForwardSTAFrames
4784
4785 DESCRIPTION
4786 Internal utility function for either forwarding cached data to the station after
4787 the station has been registered, or flushing cached data if the station has not
4788 been registered.
4789
4790
4791 DEPENDENCIES
4792 TL must be initiailized before this function gets called.
4793
4794 PARAMETERS
4795
4796 IN
4797
4798 pTLCb: TL control block
4799 ucSTAId: station id
4800
4801 RETURN VALUE
4802 The result code associated with performing the operation
4803
4804 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
4805 page fault
4806 VOS_STATUS_SUCCESS: Everything is good :)
4807
4808 SIDE EFFECTS
4809 This function doesn't re-initialize vosDataBuff to NULL. It's caller's
4810 responsibility to do so, if required, after this function call.
4811 Because of this restriction, we decide to make this function to static
4812 so that upper layer doesn't need to be aware of this restriction.
4813
4814============================================================================*/
4815static VOS_STATUS
4816WLANTL_ForwardSTAFrames
4817(
4818 void* pvosGCtx,
4819 v_U8_t ucSTAId,
4820 v_U8_t ucUcastSig,
4821 v_U8_t ucBcastSig
4822)
4823{
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304824 WLANTL_CbType* pTLCb = NULL;
4825 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004826 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
4827
4828 /*-------------------------------------------------------------------------
4829 Sanity check
4830 -------------------------------------------------------------------------*/
4831 pTLCb = VOS_GET_TL_CB(pvosGCtx);
4832 if ( NULL == pTLCb )
4833 {
4834 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05304835 "WLAN TL: Invalid input pointer on WLANTL_ForwardSTAFrames TL %p",
Jeff Johnson295189b2012-06-20 16:38:30 -07004836 pTLCb ));
4837 return VOS_STATUS_E_FAULT;
4838 }
4839
4840 if ( WLANTL_STA_ID_INVALID( ucSTAId ) )
4841 {
4842 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
4843 "WLAN TL:Invalid station id requested on WLANTL_ForwardSTAFrames"));
4844 return VOS_STATUS_E_FAULT;
4845 }
4846
4847 //WLAN_TL_LOCK_STA_CACHE(pTLCb->atlSTAClients[ucSTAId]);
4848
4849 /*------------------------------------------------------------------------
4850 Check if station has not been registered in the mean while
4851 if not registered, flush cached frames.
4852 ------------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304853 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
4854
4855 if ( NULL == pClientSTA )
4856 {
4857 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
4858 "WLAN TL:Client Memory was not allocated on %s", __func__));
4859 return VOS_STATUS_E_FAILURE;
4860 }
4861
4862 if ( 0 == pClientSTA->ucExists )
Jeff Johnson295189b2012-06-20 16:38:30 -07004863 {
4864 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
4865 "WLAN TL:Station has been deleted for STA %d - flushing cache", ucSTAId));
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304866 WLANTL_FlushCachedFrames(pClientSTA->vosBegCachedFrame);
Jeff Johnson295189b2012-06-20 16:38:30 -07004867 goto done;
4868 }
4869
4870 /*------------------------------------------------------------------------
4871 Forwarding cache frames received while the station was in the process
4872 of being registered with the rest of the SW components
4873
4874 Access to the cache must be locked; similarly updating the signature and
4875 the existence flag must be synchronized because these values are checked
4876 during cached
4877 ------------------------------------------------------------------------*/
4878 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
4879 "WLAN TL:Preparing to fwd packets for STA %d", ucSTAId));
4880
4881 /*-----------------------------------------------------------------------
4882 Save the new signature values
4883 ------------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304884 pClientSTA->wSTADesc.ucUcastSig = ucUcastSig;
4885 pClientSTA->wSTADesc.ucBcastSig = ucBcastSig;
Jeff Johnson295189b2012-06-20 16:38:30 -07004886
4887 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
4888 "WLAN TL:Fwd-ing packets for STA %d UC %d BC %d",
4889 ucSTAId, ucUcastSig, ucBcastSig));
4890
4891 /*-------------------------------------------------------------------------
4892 Check to see if we have any cached data to forward
4893 -------------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304894 if ( NULL != pClientSTA->vosBegCachedFrame )
Jeff Johnson295189b2012-06-20 16:38:30 -07004895 {
4896 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
4897 "WLAN TL: Fwd-ing Cached packets for station %d", ucSTAId ));
4898
4899 WLANTL_RxCachedFrames( pTLCb,
4900 ucSTAId,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304901 pClientSTA->vosBegCachedFrame);
Jeff Johnson295189b2012-06-20 16:38:30 -07004902 }
4903 else
4904 {
4905 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
4906 "WLAN TL: NO cached packets for station %d", ucSTAId ));
4907 }
4908
4909done:
4910 /*-------------------------------------------------------------------------
4911 Clear the station cache
4912 -------------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304913 pClientSTA->vosBegCachedFrame = NULL;
4914 pClientSTA->vosEndCachedFrame = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004915
4916 /*-----------------------------------------------------------------------
4917 After all the init is complete we can mark the existance flag
4918 ----------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304919 pClientSTA->ucRxBlocked = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004920
4921 //WLAN_TL_UNLOCK_STA_CACHE(pTLCb->atlSTAClients[ucSTAId]);
4922 return VOS_STATUS_SUCCESS;
4923
4924}/*WLANTL_ForwardSTAFrames*/
4925
4926
4927#ifdef FEATURE_WLAN_CCX
4928/*==========================================================================
4929
4930 FUNCTION WLANTL_IsIAPPFrame
4931
4932 DESCRIPTION
4933 Internal utility function for detecting incoming CCX IAPP frames
4934
4935 DEPENDENCIES
4936
4937 PARAMETERS
4938
4939 IN
4940
4941 pvBDHeader: pointer to the BD header
4942 vosTempBuff: the data packet
4943
4944 IN/OUT
4945 pFirstDataPktArrived: static from caller function; used for rssi
4946 computation
4947 RETURN VALUE
4948 The result code associated with performing the operation
4949
4950 VOS_TRUE: It is a IAPP frame
4951 VOS_FALSE: It is NOT IAPP frame
4952
4953 SIDE EFFECTS
4954
4955============================================================================*/
4956v_BOOL_t
4957WLANTL_IsIAPPFrame
4958(
4959 v_PVOID_t pvBDHeader,
4960 vos_pkt_t* vosTempBuff
4961)
4962{
4963 v_U16_t usMPDUDOffset;
4964 v_U8_t ucOffset;
4965 v_U8_t ucSnapHdr[WLANTL_LLC_SNAP_SIZE];
4966 v_SIZE_t usSnapHdrSize = WLANTL_LLC_SNAP_SIZE;
4967 VOS_STATUS vosStatus;
4968
4969 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
4970
4971 /*------------------------------------------------------------------------
4972 Check if OUI field is present.
4973 -------------------------------------------------------------------------*/
4974 if ( VOS_FALSE == WDA_IS_RX_LLC_PRESENT(pvBDHeader) )
4975 {
4976 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
4977 "WLAN TL:LLC header removed, cannot determine BT-AMP type -"
4978 "dropping pkt"));
4979 /* Drop packet */
4980 vos_pkt_return_packet(vosTempBuff);
4981 return VOS_TRUE;
4982 }
4983 usMPDUDOffset = (v_U8_t)WDA_GET_RX_MPDU_DATA_OFFSET(pvBDHeader);
4984 ucOffset = (v_U8_t)usMPDUDOffset + WLANTL_LLC_SNAP_OFFSET;
4985
4986 vosStatus = vos_pkt_extract_data( vosTempBuff, ucOffset,
4987 (v_PVOID_t)ucSnapHdr, &usSnapHdrSize);
4988
4989 if (( VOS_STATUS_SUCCESS != vosStatus))
4990 {
4991 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
4992 "Unable to extract Snap Hdr of data packet -"
4993 "dropping pkt"));
4994 return VOS_FALSE;
4995 }
4996
4997 /*------------------------------------------------------------------------
4998 Check if this is IAPP frame by matching Aironet Snap hdr.
4999 -------------------------------------------------------------------------*/
5000 // Compare returns 1 if values are same and 0
5001 // if not the same.
5002 if (( WLANTL_LLC_SNAP_SIZE != usSnapHdrSize ) ||
5003 ( 0 == vos_mem_compare(ucSnapHdr, (v_PVOID_t)WLANTL_AIRONET_SNAP_HEADER,
5004 WLANTL_LLC_SNAP_SIZE ) ))
5005 {
5006 return VOS_FALSE;
5007 }
5008
5009 return VOS_TRUE;
5010
5011}
5012#endif //FEATURE_WLAN_CCX
5013
5014/*==========================================================================
5015
5016 FUNCTION WLANTL_ProcessBAPFrame
5017
5018 DESCRIPTION
5019 Internal utility function for processing incoming BT-AMP frames
5020
5021 DEPENDENCIES
5022 TL must be initiailized before this function gets called.
5023 Bothe the BT-AMP station and the BAP Ctrl path must have been previously
5024 registered with TL.
5025
5026 PARAMETERS
5027
5028 IN
5029
5030 pvBDHeader: pointer to the BD header
5031 vosTempBuff: the data packet
5032 pTLCb: TL control block
5033 ucSTAId: station id
5034
5035 IN/OUT
5036 pFirstDataPktArrived: static from caller function; used for rssi
5037 computation
5038 RETURN VALUE
5039 The result code associated with performing the operation
5040
5041 VOS_STATUS_E_INVAL: Input parameters are invalid
5042 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
5043 page fault
5044 VOS_STATUS_SUCCESS: Everything is good :)
5045
5046 SIDE EFFECTS
5047
5048============================================================================*/
5049v_BOOL_t
5050WLANTL_ProcessBAPFrame
5051(
5052 v_PVOID_t pvBDHeader,
5053 vos_pkt_t* vosTempBuff,
5054 WLANTL_CbType* pTLCb,
5055 v_U8_t* pFirstDataPktArrived,
5056 v_U8_t ucSTAId
5057)
5058{
5059 v_U16_t usMPDUDOffset;
5060 v_U8_t ucOffset;
5061 v_U8_t ucOUI[WLANTL_LLC_OUI_SIZE];
5062 v_SIZE_t usOUISize = WLANTL_LLC_OUI_SIZE;
5063 VOS_STATUS vosStatus;
5064 v_U16_t usType;
5065 v_SIZE_t usTypeLen = sizeof(usType);
5066 v_U8_t ucMPDUHOffset;
5067 v_U8_t ucMPDUHLen = 0;
5068 v_U16_t usActualHLen = 0;
5069
5070 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
5071
5072 /*------------------------------------------------------------------------
5073 Extract OUI and type from LLC and validate; if non-data send to BAP
5074 -------------------------------------------------------------------------*/
5075 if ( VOS_FALSE == WDA_IS_RX_LLC_PRESENT(pvBDHeader) )
5076 {
5077 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
5078 "WLAN TL:LLC header removed, cannot determine BT-AMP type -"
5079 "dropping pkt"));
5080 /* Drop packet */
5081 vos_pkt_return_packet(vosTempBuff);
5082 return VOS_TRUE;
5083 }
5084
5085 usMPDUDOffset = (v_U8_t)WDA_GET_RX_MPDU_DATA_OFFSET(pvBDHeader);
5086 ucMPDUHOffset = (v_U8_t)WDA_GET_RX_MPDU_HEADER_OFFSET(pvBDHeader);
5087 ucMPDUHLen = (v_U8_t)WDA_GET_RX_MPDU_HEADER_LEN(pvBDHeader);
5088 ucOffset = (v_U8_t)usMPDUDOffset + WLANTL_LLC_OUI_OFFSET;
5089
5090 vosStatus = vos_pkt_extract_data( vosTempBuff, ucOffset,
5091 (v_PVOID_t)ucOUI, &usOUISize);
5092
5093#if 0
5094 // Compare returns 1 if values are same and 0
5095 // if not the same.
5096 if (( WLANTL_LLC_OUI_SIZE != usOUISize ) ||
5097 ( 0 == vos_mem_compare(ucOUI, (v_PVOID_t)WLANTL_BT_AMP_OUI,
5098 WLANTL_LLC_OUI_SIZE ) ))
5099 {
5100 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
5101 "LLC header points to diff OUI in BT-AMP station -"
5102 "dropping pkt"));
5103 /* Drop packet */
5104 vos_pkt_return_packet(vosTempBuff);
5105 return VOS_TRUE;
5106 }
5107#endif
5108 /*------------------------------------------------------------------------
5109 Extract LLC OUI and ensure that this is indeed a BT-AMP frame
5110 ------------------------------------------------------------------------*/
5111 vosStatus = vos_pkt_extract_data( vosTempBuff,
5112 ucOffset + WLANTL_LLC_OUI_SIZE,
5113 (v_PVOID_t)&usType, &usTypeLen);
5114
5115 if (( VOS_STATUS_SUCCESS != vosStatus) ||
5116 ( sizeof(usType) != usTypeLen ))
5117 {
5118 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
5119 "Unable to extract type on incoming BAP packet -"
5120 "dropping pkt"));
5121 /* Drop packet */
5122 vos_pkt_return_packet(vosTempBuff);
5123 return VOS_TRUE;
5124 }
5125
5126 /*------------------------------------------------------------------------
5127 Check if this is BT-AMP data or ctrl packet(RSN, LinkSvision, ActivityR)
5128 ------------------------------------------------------------------------*/
5129 usType = vos_be16_to_cpu(usType);
5130
5131 if (WLANTL_BAP_IS_NON_DATA_PKT_TYPE(usType))
5132 {
5133 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
5134 "WLAN TL:Non-data packet received over BT-AMP link: %d, => BAP",
5135 usType));
5136
5137 /*Flatten packet as BAP expects to be able to peek*/
5138 if ( VOS_STATUS_SUCCESS != vos_pkt_flatten_rx_pkt(&vosTempBuff))
5139 {
5140 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
5141 "WLAN TL:Cannot flatten BT-AMP packet - dropping"));
5142 /* Drop packet */
5143 vos_pkt_return_packet(vosTempBuff);
5144 return VOS_TRUE;
5145 }
5146
5147 /* Send packet to BAP client*/
5148
5149 VOS_ASSERT(pTLCb->tlBAPClient.pfnTlBAPRx != NULL);
5150
5151 if ( VOS_STATUS_SUCCESS != WDA_DS_TrimRxPacketInfo( vosTempBuff ) )
5152 {
5153 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
5154 "WLAN TL:BD header corrupted - dropping packet"));
5155 /* Drop packet */
5156 vos_pkt_return_packet(vosTempBuff);
5157 return VOS_TRUE;
5158 }
5159
5160 if ( 0 == WDA_GET_RX_FT_DONE(pvBDHeader) )
5161 {
5162 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
5163 "Non-data packet received over BT-AMP link: Sending it for "
5164 "frame Translation"));
5165
5166 if (usMPDUDOffset > ucMPDUHOffset)
5167 {
5168 usActualHLen = usMPDUDOffset - ucMPDUHOffset;
5169 }
5170
5171 /* software frame translation for BTAMP WDS.*/
5172 WLANTL_Translate80211To8023Header( vosTempBuff, &vosStatus, usActualHLen,
5173 ucMPDUHLen, pTLCb,ucSTAId );
5174
5175 }
5176 if (pTLCb->tlBAPClient.pfnTlBAPRx)
5177 pTLCb->tlBAPClient.pfnTlBAPRx( vos_get_global_context(VOS_MODULE_ID_TL,pTLCb),
5178 vosTempBuff,
5179 (WLANTL_BAPFrameEnumType)usType );
5180
5181 return VOS_TRUE;
5182 }
5183 else
5184 {
5185 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
5186 "WLAN TL: BAP DATA packet received over BT-AMP link: %d, => BAP",
5187 usType));
5188 /*!!!FIX ME!!*/
5189 #if 0
5190 /*--------------------------------------------------------------------
5191 For data packet collect phy stats RSSI and Link Quality
5192 Calculate the RSSI average and save it. Continuous average is done.
5193 --------------------------------------------------------------------*/
5194 if ( *pFirstDataPktArrived == 0)
5195 {
5196 pTLCb->atlSTAClients[ucSTAId].rssiAvg =
5197 WLANHAL_GET_RSSI_AVERAGE( pvBDHeader );
5198 pTLCb->atlSTAClients[ucSTAId].uLinkQualityAvg =
5199 WLANHAL_RX_BD_GET_SNR( pvBDHeader );
5200
5201 // Rcvd 1st pkt, start average from next time
5202 *pFirstDataPktArrived = 1;
5203 }
5204 else
5205 {
5206 pTLCb->atlSTAClients[ucSTAId].rssiAvg =
5207 (WLANHAL_GET_RSSI_AVERAGE( pvBDHeader ) +
5208 pTLCb->atlSTAClients[ucSTAId].rssiAvg)/2;
5209 pTLCb->atlSTAClients[ucSTAId].uLinkQualityAvg =
5210 (WLANHAL_RX_BD_GET_SNR( pvBDHeader ) +
5211 pTLCb->atlSTAClients[ucSTAId].uLinkQualityAvg)/2;
5212 }/*Else, first data packet*/
5213 #endif
5214 }/*BT-AMP data packet*/
5215
5216 return VOS_FALSE;
5217}/*WLANTL_ProcessBAPFrame*/
5218
Jeff Johnson295189b2012-06-20 16:38:30 -07005219
5220/*==========================================================================
5221
5222 FUNCTION WLANTL_ProcessFCFrame
5223
5224 DESCRIPTION
5225 Internal utility function for processing incoming Flow Control frames. Enable
5226 or disable LWM mode based on the information.
5227
5228 DEPENDENCIES
5229 TL must be initiailized before this function gets called.
5230 FW sends up special flow control frame.
5231
5232 PARAMETERS
5233
5234 IN
5235 pvosGCtx pointer to vos global context
5236 pvBDHeader: pointer to the BD header
5237 pTLCb: TL control block
5238 pvBDHeader pointer to BD header.
5239
5240 IN/OUT
5241 pFirstDataPktArrived: static from caller function; used for rssi
5242 computation
5243 RETURN VALUE
5244 The result code associated with performing the operation
5245
5246 VOS_STATUS_E_INVAL: Input frame are invalid
5247 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
5248 page fault
5249 VOS_STATUS_SUCCESS: Everything is good :)
5250
5251 SIDE EFFECTS
5252 The ingress and egress of each station will be updated. If needed, LWM mode will
5253 be enabled or disabled based on the flow control algorithm.
5254
5255============================================================================*/
5256v_BOOL_t
5257WLANTL_ProcessFCFrame
5258(
5259 v_PVOID_t pvosGCtx,
5260 vos_pkt_t* pvosDataBuff,
5261 v_PVOID_t pvBDHeader
5262)
5263{
5264#if 1 //enable processing of only fcStaTxDisabled bitmap for now. the else part is old better qos code.
5265 // need to revisit the old code for full implementation.
Hoonki Lee14621352013-04-16 17:51:19 -07005266 v_U8_t ucSTAId;
5267 v_U16_t ucStaValidBitmap;
5268 v_U16_t ucStaTxDisabledBitmap;
5269 WLANTL_CbType* pTLCb = NULL;
5270 #ifdef TL_DEBUG_FC
5271 v_U32_t rxTimeStamp;
5272 v_U32_t curTick;
5273 #endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005274 /*------------------------------------------------------------------------
Hoonki Lee14621352013-04-16 17:51:19 -07005275 Extract TL control block
Jeff Johnson295189b2012-06-20 16:38:30 -07005276 ------------------------------------------------------------------------*/
5277 pTLCb = VOS_GET_TL_CB(pvosGCtx);
5278 if ( NULL == pTLCb )
5279 {
5280 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
5281 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_SuspendDataTx"));
5282 return VOS_STATUS_E_FAULT;
5283 }
Hoonki Lee14621352013-04-16 17:51:19 -07005284 ucStaValidBitmap = WDA_GET_RX_FC_VALID_STA_MASK(pvBDHeader);
5285 ucStaTxDisabledBitmap = WDA_GET_RX_FC_STA_TX_DISABLED_BITMAP(pvBDHeader);
5286#ifdef TL_DEBUG_FC
5287 rxTimeStamp = WDA_GET_RX_TIMESTAMP(pvBDHeader);
5288 /* hard code of MTU_GLOBAL_TIMER_ADDR to calculate the time between generated and processed */
5289 wpalReadRegister(0x03081400+0x1D4, &curTick);
Jeff Johnson295189b2012-06-20 16:38:30 -07005290
Jeff Johnson295189b2012-06-20 16:38:30 -07005291 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Hoonki Lee14621352013-04-16 17:51:19 -07005292 "%ld (%ld-%ld): Disabled %x Valid %x\n", curTick > rxTimeStamp ? curTick - rxTimeStamp : rxTimeStamp - (0xFFFFFFFF - curTick),
5293 curTick, rxTimeStamp, ucStaTxDisabledBitmap, ucStaValidBitmap));
5294#endif
5295 for(ucSTAId = 0; ucStaValidBitmap != 0; ucStaValidBitmap >>=1, ucStaTxDisabledBitmap >>= 1, ucSTAId ++)
Jeff Johnson295189b2012-06-20 16:38:30 -07005296 {
Hoonki Lee14621352013-04-16 17:51:19 -07005297 if ( (0 == (ucStaValidBitmap & 0x1)) || (pTLCb->atlSTAClients[ucSTAId] && (0 == pTLCb->atlSTAClients[ucSTAId]->ucExists)) )
5298 continue;
5299
5300 if (ucStaTxDisabledBitmap & 0x1)
5301 {
5302 WLANTL_SuspendDataTx(pvosGCtx, &ucSTAId, NULL);
5303 }
5304 else
5305 {
5306 WLANTL_ResumeDataTx(pvosGCtx, &ucSTAId);
5307 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005308 }
5309
5310#else
5311 VOS_STATUS vosStatus;
5312 tpHalFcRxBd pvFcRxBd = NULL;
5313 v_U8_t ucBitCheck = 0x1;
5314 v_U8_t ucStaValid = 0;
5315 v_U8_t ucSTAId = 0;
5316
5317 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
5318 "Received FC Response");
5319 if ( (NULL == pTLCb) || (NULL == pvosDataBuff))
5320 {
5321 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005322 "WLAN TL:Invalid pointer in %s \n", __func__));
Jeff Johnson295189b2012-06-20 16:38:30 -07005323 return VOS_STATUS_E_FAULT;
5324 }
5325 vosStatus = vos_pkt_peek_data( pvosDataBuff, 0, (v_PVOID_t)&pvFcRxBd,
5326 sizeof(tHalFcRxBd));
5327
5328 if ( (VOS_STATUS_SUCCESS != vosStatus) || (NULL == pvFcRxBd) )
5329 {
5330 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
5331 "WLAN TL:wrong FC Rx packet"));
5332 return VOS_STATUS_E_INVAL;
5333 }
5334
5335 // need to swap bytes in the FC contents.
5336 WLANHAL_SwapFcRxBd(&pvFcRxBd->fcSTATxQLen[0]);
5337
5338 //logic to enable/disable LWM mode for each station
5339 for( ucStaValid = (v_U8_t)pvFcRxBd->fcSTAValidMask; ucStaValid; ucStaValid >>= 1, ucBitCheck <<= 1, ucSTAId ++)
5340 {
5341 if ( (0 == (ucStaValid & 0x1)) || (0 == pTLCb->atlSTAClients[ucSTAId].ucExists) )
5342 {
5343 continue;
5344 }
5345
5346 if ( pvFcRxBd->fcSTAThreshIndMask & ucBitCheck )
5347 {
5348 //LWM event is reported by FW. Able to fetch more packet
5349 if( pTLCb->atlSTAClients[ucSTAId].ucLwmModeEnabled )
5350 {
5351 //Now memory usage is below LWM. Station can send more packets.
5352 pTLCb->atlSTAClients[ucSTAId].ucLwmEventReported = TRUE;
5353 }
5354 else
5355 {
5356 TLLOG4(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_LOW,
5357 "WLAN TL: FW report LWM event but the station %d is not in LWM mode \n", ucSTAId));
5358 }
5359 }
5360
5361 //calculate uEgress_length/uIngress_length only after receiving enough packets
5362 if (WLANTL_LWM_INGRESS_SAMPLE_THRESHOLD <= pTLCb->atlSTAClients[ucSTAId].uIngress_length)
5363 {
5364 //check memory usage info to see whether LWM mode should be enabled for the station
5365 v_U32_t uEgress_length = pTLCb->atlSTAClients[ucSTAId].uIngress_length +
5366 pTLCb->atlSTAClients[ucSTAId].bmuMemConsumed - pvFcRxBd->fcSTATxQLen[ucSTAId];
5367
5368 //if ((float)uEgress_length/(float)pTLCb->atlSTAClients[ucSTAId].uIngress_length
5369 // <= WLANTL_LWM_EGRESS_INGRESS_THRESHOLD)
5370 if ( (pTLCb->atlSTAClients[ucSTAId].uIngress_length > uEgress_length) &&
5371 ((pTLCb->atlSTAClients[ucSTAId].uIngress_length - uEgress_length ) >=
5372 (pTLCb->atlSTAClients[ucSTAId].uIngress_length >> 2))
5373 )
5374 {
5375 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
5376 "WLAN TL:Enable LWM mode for station %d\n", ucSTAId));
5377 pTLCb->atlSTAClients[ucSTAId].ucLwmModeEnabled = TRUE;
5378 }
5379 else
5380 {
5381 if( pTLCb->atlSTAClients[ucSTAId].ucLwmModeEnabled )
5382 {
5383 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
5384 "WLAN TL:Disable LWM mode for station %d\n", ucSTAId));
5385 pTLCb->atlSTAClients[ucSTAId].ucLwmModeEnabled = FALSE;
5386 }
5387
5388 }
5389
5390 //remember memory usage in FW starting from this round
5391 pTLCb->atlSTAClients[ucSTAId].bmuMemConsumed = pvFcRxBd->fcSTATxQLen[ucSTAId];
5392 pTLCb->atlSTAClients[ucSTAId].uIngress_length = 0;
5393 } //(WLANTL_LWM_INGRESS_SAMPLE_THRESHOLD <= pTLCb->atlSTAClients[ucSTAId].uIngress_length)
5394
5395 if( pTLCb->atlSTAClients[ucSTAId].ucLwmModeEnabled )
5396 {
5397 //always update current maximum allowed memeory usage
5398 pTLCb->atlSTAClients[ucSTAId].uBuffThresholdMax = WLANTL_STA_BMU_THRESHOLD_MAX -
5399 pvFcRxBd->fcSTATxQLen[ucSTAId];
5400 }
5401
5402 }
5403#endif
5404
5405 return VOS_STATUS_SUCCESS;
5406}
Jeff Johnson295189b2012-06-20 16:38:30 -07005407
5408
5409/*==========================================================================
5410
5411 FUNCTION WLANTL_RxFrames
5412
5413 DESCRIPTION
5414 Callback registered by TL and called by BAL when a packet is received
5415 over the bus. Upon the call of this function TL will make the necessary
5416 decision with regards to the forwarding or queuing of this packet and
5417 the layer it needs to be delivered to.
5418
5419 DEPENDENCIES
5420 TL must be initiailized before this function gets called.
5421 If the frame carried is a data frame then the station for which it is
5422 destined to must have been previously registered with TL.
5423
5424 PARAMETERS
5425
5426 IN
5427 pvosGCtx: pointer to the global vos context; a handle to TL's
5428 or BAL's control block can be extracted from its context
5429
5430 vosDataBuff: it will contain a pointer to the first buffer received,
5431 if there is more then one packet they will be chained
5432 using vOSS buffers.
5433
5434 RETURN VALUE
5435 The result code associated with performing the operation
5436
5437 VOS_STATUS_E_INVAL: Input parameters are invalid
5438 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
5439 page fault
5440 VOS_STATUS_SUCCESS: Everything is good :)
5441
5442 SIDE EFFECTS
5443
5444============================================================================*/
5445VOS_STATUS
5446WLANTL_RxFrames
5447(
5448 v_PVOID_t pvosGCtx,
5449 vos_pkt_t *pFrameDataBuff
5450)
5451{
5452 vos_pkt_t* vosDataBuff = (vos_pkt_t*)pFrameDataBuff;
5453 WLANTL_CbType* pTLCb = NULL;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05305454 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005455 WLANTL_STAFuncType pfnSTAFsm;
5456 vos_pkt_t* vosTempBuff;
5457 v_U8_t ucSTAId;
5458 VOS_STATUS vosStatus;
5459 v_U8_t ucFrmType;
5460 v_PVOID_t pvBDHeader = NULL;
5461 WLANTL_STAEventType wSTAEvent = WLANTL_RX_EVENT;
5462 v_U8_t ucTid = 0;
5463 v_BOOL_t broadcast = VOS_FALSE;
5464 v_BOOL_t selfBcastLoopback = VOS_FALSE;
Madan Mohan Koyyalamudidfd6aa82012-10-18 20:18:43 -07005465 static v_U8_t first_data_pkt_arrived;
Jeff Johnson295189b2012-06-20 16:38:30 -07005466 v_U32_t uDPUSig;
Jeff Johnson295189b2012-06-20 16:38:30 -07005467 v_U16_t usPktLen;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08005468#ifdef FEATURE_WLAN_TDLS_INTERNAL
5469 v_U8_t ucMPDUHLen = 0 ;
5470 v_U16_t usEtherType = 0;
5471#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005472 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
5473
5474 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
5475 "WLAN TL:TL Receive Frames called"));
5476
5477 /*------------------------------------------------------------------------
5478 Sanity check
5479 ------------------------------------------------------------------------*/
5480 if ( NULL == vosDataBuff )
5481 {
5482 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
5483 "WLAN TL:Invalid parameter sent on WLANTL_RxFrames"));
5484 return VOS_STATUS_E_INVAL;
5485 }
5486
5487 /*------------------------------------------------------------------------
5488 Extract TL control block
5489 ------------------------------------------------------------------------*/
5490 pTLCb = VOS_GET_TL_CB(pvosGCtx);
5491 if ( NULL == pTLCb )
5492 {
5493 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
5494 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_ChangeSTAState"));
5495 return VOS_STATUS_E_FAULT;
5496 }
5497
5498 /*---------------------------------------------------------------------
5499 Save the initial buffer - this is the first received buffer
5500 ---------------------------------------------------------------------*/
5501 vosTempBuff = vosDataBuff;
5502
5503 while ( NULL != vosTempBuff )
5504 {
Madan Mohan Koyyalamudia148e1e2012-11-30 14:52:59 -08005505 broadcast = VOS_FALSE;
5506 selfBcastLoopback = VOS_FALSE;
5507
Jeff Johnson295189b2012-06-20 16:38:30 -07005508 vos_pkt_walk_packet_chain( vosDataBuff, &vosDataBuff, 1/*true*/ );
5509
5510 /*---------------------------------------------------------------------
5511 Peek at BD header - do not remove
5512 !!! Optimize me: only part of header is needed; not entire one
5513 ---------------------------------------------------------------------*/
5514 vosStatus = WDA_DS_PeekRxPacketInfo( vosTempBuff, (v_PVOID_t)&pvBDHeader, 1/*Swap BD*/ );
5515
5516 if ( NULL == pvBDHeader )
5517 {
5518 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
5519 "WLAN TL:Cannot extract BD header"));
5520 /* Drop packet */
5521 vos_pkt_return_packet(vosTempBuff);
5522 vosTempBuff = vosDataBuff;
5523 continue;
5524 }
5525
Jeff Johnson295189b2012-06-20 16:38:30 -07005526 /*---------------------------------------------------------------------
5527 Check if FC frame reported from FW
5528 ---------------------------------------------------------------------*/
5529 if(WDA_IS_RX_FC(pvBDHeader))
5530 {
5531 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
5532 "WLAN TL:receive one FC frame"));
5533
5534 WLANTL_ProcessFCFrame(pvosGCtx, vosTempBuff, pvBDHeader);
5535 /* Drop packet */
5536 vos_pkt_return_packet(vosTempBuff);
5537 vosTempBuff = vosDataBuff;
5538 continue;
5539 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005540
5541 /* AMSDU HW bug fix
5542 * After 2nd AMSDU subframe HW could not handle BD correctly
5543 * HAL workaround is needed */
5544 if(WDA_GET_RX_ASF(pvBDHeader))
5545 {
5546 WDA_DS_RxAmsduBdFix(pvosGCtx, pvBDHeader);
5547 }
5548
5549 /*---------------------------------------------------------------------
5550 Extract frame control field from 802.11 header if present
5551 (frame translation not done)
5552 ---------------------------------------------------------------------*/
5553
5554 vosStatus = WDA_DS_GetFrameTypeSubType( pvosGCtx, vosTempBuff,
5555 pvBDHeader, &ucFrmType );
5556 if ( VOS_STATUS_SUCCESS != vosStatus )
5557 {
5558 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
5559 "WLAN TL:Cannot extract Frame Control Field"));
5560 /* Drop packet */
5561 vos_pkt_return_packet(vosTempBuff);
5562 vosTempBuff = vosDataBuff;
5563 continue;
5564 }
5565
Mohit Khanna698ba2a2012-12-04 15:08:18 -08005566#ifdef FEATURE_WLAN_TDLS_INTERNAL
5567 if ( WLANTL_IS_DATA_FRAME(ucFrmType))
5568 {
5569 ucMPDUHLen = (v_U8_t)WDA_GET_RX_MPDU_HEADER_LEN(pvBDHeader);
5570 WLANTL_GetEtherType_2(pvBDHeader, vosTempBuff, ucMPDUHLen, &usEtherType) ;
5571 }
5572#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005573 vos_pkt_get_packet_length(vosTempBuff, &usPktLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07005574
5575 /*---------------------------------------------------------------------
5576 Check if management and send to PE
5577 ---------------------------------------------------------------------*/
5578
Mohit Khanna698ba2a2012-12-04 15:08:18 -08005579 if ( WLANTL_IS_MGMT_FRAME(ucFrmType)
5580#ifdef FEATURE_WLAN_TDLS_INTERNAL
5581 || (WLANTL_IS_TDLS_FRAME(usEtherType))
5582#endif
5583 )
Jeff Johnson295189b2012-06-20 16:38:30 -07005584 {
5585 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
5586 "WLAN TL:Sending packet to management client"));
5587 if ( VOS_STATUS_SUCCESS != vos_pkt_flatten_rx_pkt(&vosTempBuff))
5588 {
5589 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
5590 "WLAN TL:Cannot flatten packet - dropping"));
5591 /* Drop packet */
5592 vos_pkt_return_packet(vosTempBuff);
5593 vosTempBuff = vosDataBuff;
5594 continue;
5595 }
5596 ucSTAId = (v_U8_t)WDA_GET_RX_STAID( pvBDHeader );
5597 /* Read RSSI and update */
5598 if(!WLANTL_STA_ID_INVALID(ucSTAId))
5599 {
5600#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
5601 /* Read RSSI and update */
5602 vosStatus = WLANTL_HSHandleRXFrame(pvosGCtx,
5603 WLANTL_MGMT_FRAME_TYPE,
5604 pvBDHeader,
5605 ucSTAId,
5606 VOS_FALSE,
5607 NULL);
5608#else
5609 vosStatus = WLANTL_ReadRSSI(pvosGCtx, pvBDHeader, ucSTAId);
5610#endif
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05305611 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
5612 {
5613 TLLOGW(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
5614 "Handle RX Management Frame fail within Handoff "
5615 "support module"));
5616 /* Do Not Drop packet at here
5617 * Revisit why HO module return fail
5618 * vos_pkt_return_packet(vosTempBuff);
5619 * vosTempBuff = vosDataBuff;
5620 * continue;
5621 */
5622 }
5623 vosStatus = WLANTL_ReadSNR(pvosGCtx, pvBDHeader, ucSTAId);
5624
5625 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
5626 {
5627 TLLOGW(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
5628 FL("Failed to Read SNR")));
5629 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005630 }
5631
Jeff Johnson295189b2012-06-20 16:38:30 -07005632 pTLCb->tlMgmtFrmClient.pfnTlMgmtFrmRx( pvosGCtx, vosTempBuff);
5633 }
5634 else /* Data Frame */
5635 {
5636 ucSTAId = (v_U8_t)WDA_GET_RX_STAID( pvBDHeader );
5637 ucTid = (v_U8_t)WDA_GET_RX_TID( pvBDHeader );
5638
5639 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
5640 "WLAN TL:Data packet received for STA %d", ucSTAId));
5641
5642 /*------------------------------------------------------------------
5643 This should be corrected when multipe sta support is added !!!
5644 for now bcast frames will be sent to the last registered STA
5645 ------------------------------------------------------------------*/
5646 if ( WDA_IS_RX_BCAST(pvBDHeader))
5647 {
5648 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
5649 "WLAN TL:TL rx Bcast frame - sending to last registered station"));
5650 broadcast = VOS_TRUE;
5651
5652 /*-------------------------------------------------------------------
5653 If Addr1 is b/mcast, but Addr3 is our own self MAC, it is a b/mcast
5654 pkt we sent looping back to us. To be dropped if we are non BTAMP
5655 -------------------------------------------------------------------*/
5656 if( WLANHAL_RX_BD_ADDR3_SELF_IDX ==
5657 (v_U8_t)WDA_GET_RX_ADDR3_IDX( pvBDHeader ))
5658 {
5659 selfBcastLoopback = VOS_TRUE;
5660 }
5661 }/*if bcast*/
5662
5663 if ( WLANTL_STA_ID_INVALID(ucSTAId) )
5664 {
5665 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
5666 "WLAN TL:STA ID invalid - dropping pkt"));
5667 /* Drop packet */
5668 vos_pkt_return_packet(vosTempBuff);
5669 vosTempBuff = vosDataBuff;
5670 continue;
5671 }
5672
5673 /*----------------------------------------------------------------------
5674 No need to lock cache access because cache manipulation only happens
5675 in the transport thread/task context
5676 - These frames are to be forwarded to the station upon registration
5677 which happens in the main thread context
5678 The caching here can happen in either Tx or Rx thread depending
5679 on the current SSC scheduling
5680 - also we need to make sure that the frames in the cache are fwd-ed to
5681 the station before the new incoming ones
5682 -----------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05305683 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
5684 if (NULL == pClientSTA)
5685 {
5686 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
5687 "WLAN TL:STA not allocated memory. Dropping packet"));
5688 vos_pkt_return_packet(vosTempBuff);
5689 vosTempBuff = vosDataBuff;
5690 continue;
5691 }
5692
Hoonki Lee5305c3a2013-04-29 23:28:59 -07005693#ifdef FEATURE_WLAN_TDLS
5694 if (( pClientSTA->ucExists ) &&
5695 (WLAN_STA_TDLS == pClientSTA->wSTADesc.wSTAType) &&
5696 (pClientSTA->ucTxSuspended))
5697 vos_atomic_set_U8( &pClientSTA->ucTxSuspended, 0 );
5698 else if ( !broadcast && (pClientSTA->ucExists == 0 ) )
5699 {
5700 tpSirMacMgmtHdr pMacHeader = WDA_GET_RX_MAC_HEADER( pvBDHeader );
5701
5702 /* from the direct peer while it is not registered to TL yet */
5703 if ( (pMacHeader->fc.fromDS == 0) &&
5704 (pMacHeader->fc.toDS == 0) )
5705 {
5706 v_U8_t ucAddr3STAId;
5707
5708 ucAddr3STAId = WDA_GET_RX_ADDR3_IDX(pvBDHeader);
5709
5710 if ( WLANTL_STA_ID_INVALID(ucAddr3STAId) )
5711 {
5712 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
5713 "WLAN TL:STA ID %d invalid - dropping pkt", ucAddr3STAId));
5714 /* Drop packet */
5715 vos_pkt_return_packet(vosTempBuff);
5716 vosTempBuff = vosDataBuff;
5717 continue;
5718 }
5719
5720 if (!(pTLCb->atlSTAClients[ucAddr3STAId] && pTLCb->atlSTAClients[ucAddr3STAId]->ucExists &&
5721 (WLAN_STA_INFRA == pTLCb->atlSTAClients[ucAddr3STAId]->wSTADesc.wSTAType) &&
5722 (WLANTL_STA_AUTHENTICATED == pTLCb->atlSTAClients[ucAddr3STAId]->tlState)))
5723 {
5724 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
5725 "%s: staId %d addr3Id %d tlState %d. Unkown Receiver/Transmitter Dropping packet\n", __func__,
5726 ucSTAId, ucAddr3STAId, pTLCb->atlSTAClients[ucAddr3STAId]->tlState));
5727 vos_pkt_return_packet(vosTempBuff);
5728 vosTempBuff = vosDataBuff;
5729 continue;
5730 }
5731 else
5732 {
5733 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
5734 "%s: staId %d doesn't exist, but mapped to AP staId %d \n", __func__,
5735 ucSTAId, ucAddr3STAId));
5736 ucSTAId = ucAddr3STAId;
5737 pClientSTA = pTLCb->atlSTAClients[ucAddr3STAId];
5738 }
5739 }
5740 }
5741#endif
5742
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05305743 if ((( 0 == pClientSTA->ucExists ) ||
5744 ( (0 != pClientSTA->ucRxBlocked)
Jeff Johnson295189b2012-06-20 16:38:30 -07005745 ///@@@: xg: no checking in SOFTAP for now, will revisit later
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05305746 && (WLAN_STA_SOFTAP != pClientSTA->wSTADesc.wSTAType)
Jeff Johnson295189b2012-06-20 16:38:30 -07005747 ) ||
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05305748 ( WLANTL_STA_DISCONNECTED == pClientSTA->tlState)) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07005749 /*Dont buffer Broadcast/Multicast frames. If AP transmits bursts of Broadcast/Multicast data frames,
5750 * libra buffers all Broadcast/Multicast packets after authentication with AP,
5751 * So it will lead to low resource condition in Rx Data Path.*/
5752 ((WDA_IS_RX_BCAST(pvBDHeader) == 0)))
5753 {
5754 uDPUSig = WDA_GET_RX_DPUSIG( pvBDHeader );
5755 //Station has not yet been registered with TL - cache the frame
Hoonki Lee5305c3a2013-04-29 23:28:59 -07005756 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
5757 "%s: staId %d exist %d tlState %d cache rx frame \n", __func__, ucSTAId,
5758 pClientSTA->ucExists, pClientSTA->tlState));
Jeff Johnson295189b2012-06-20 16:38:30 -07005759 WLANTL_CacheSTAFrame( pTLCb, ucSTAId, vosTempBuff, uDPUSig, broadcast, ucFrmType);
5760 vosTempBuff = vosDataBuff;
5761 continue;
5762 }
5763
Jeff Johnson295189b2012-06-20 16:38:30 -07005764#ifdef FEATURE_WLAN_CCX
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05305765 if ((pClientSTA->wSTADesc.ucIsCcxSta)|| broadcast)
Jeff Johnson295189b2012-06-20 16:38:30 -07005766 {
5767 /*--------------------------------------------------------------------
5768 Filter the IAPP frames for CCX connection;
5769 if data it will return false and it
5770 will be routed through the regular data path
5771 --------------------------------------------------------------------*/
5772 if ( WLANTL_IsIAPPFrame(pvBDHeader,
5773 vosTempBuff))
5774 {
5775 if ( VOS_STATUS_SUCCESS != vos_pkt_flatten_rx_pkt(&vosTempBuff))
5776 {
5777 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
5778 "WLAN TL:Cannot flatten packet - dropping"));
5779 /* Drop packet */
5780 vos_pkt_return_packet(vosTempBuff);
5781 } else {
5782
5783 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
5784 "WLAN TL: Received CCX IAPP Frame"));
5785
5786 pTLCb->tlMgmtFrmClient.pfnTlMgmtFrmRx( pvosGCtx, vosTempBuff);
5787 }
5788 vosTempBuff = vosDataBuff;
5789 continue;
5790 }
5791 }
5792#endif
5793
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05305794 if ( WLAN_STA_BT_AMP == pClientSTA->wSTADesc.wSTAType )
Jeff Johnson295189b2012-06-20 16:38:30 -07005795 {
5796 /*--------------------------------------------------------------------
5797 Process the ctrl BAP frame; if data it will return false and it
5798 will be routed through the regular data path
5799 --------------------------------------------------------------------*/
5800 if ( WLANTL_ProcessBAPFrame( pvBDHeader,
5801 vosTempBuff,
5802 pTLCb,
5803 &first_data_pkt_arrived,
5804 ucSTAId))
5805 {
5806 vosTempBuff = vosDataBuff;
5807 continue;
5808 }
5809 }/*if BT-AMP station*/
5810 else if(selfBcastLoopback == VOS_TRUE)
5811 {
5812 /* Drop packet */
5813 vos_pkt_return_packet(vosTempBuff);
5814 vosTempBuff = vosDataBuff;
5815 continue;
5816 }
5817
5818 /*---------------------------------------------------------------------
5819 Data packet received, send to state machine
5820 ---------------------------------------------------------------------*/
5821 wSTAEvent = WLANTL_RX_EVENT;
5822
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05305823 pfnSTAFsm = tlSTAFsm[pClientSTA->tlState].
Jeff Johnson295189b2012-06-20 16:38:30 -07005824 pfnSTATbl[wSTAEvent];
5825
5826 if ( NULL != pfnSTAFsm )
5827 {
5828#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
5829 /* Read RSSI and update */
5830 vosStatus = WLANTL_HSHandleRXFrame(pvosGCtx,
5831 WLANTL_DATA_FRAME_TYPE,
5832 pvBDHeader,
5833 ucSTAId,
5834 broadcast,
5835 vosTempBuff);
5836 broadcast = VOS_FALSE;
5837#else
5838 vosStatus = WLANTL_ReadRSSI(pvosGCtx, pvBDHeader, ucSTAId);
5839#endif /*FEATURE_WLAN_GEN6_ROAMING*/
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05305840 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
Jeff Johnson295189b2012-06-20 16:38:30 -07005841 {
5842 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
5843 "Handle RX Data Frame fail within Handoff support module"));
5844 /* Do Not Drop packet at here
5845 * Revisit why HO module return fail
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05305846 * vos_pkt_return_packet(vosTempBuff);
5847 * vosTempBuff = vosDataBuff;
5848 * continue;
Jeff Johnson295189b2012-06-20 16:38:30 -07005849 */
5850 }
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05305851 vosStatus = WLANTL_ReadSNR(pvosGCtx, pvBDHeader, ucSTAId);
5852
5853 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
5854 {
5855 TLLOGW(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
5856 FL("Failed to Read SNR")));
5857 }
5858
Jeff Johnson295189b2012-06-20 16:38:30 -07005859 pfnSTAFsm( pvosGCtx, ucSTAId, &vosTempBuff);
5860 }
5861 else
5862 {
5863 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
5864 "WLAN TL:NULL state function, STA:%d, State: %d- dropping packet",
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05305865 ucSTAId, pClientSTA->tlState));
Jeff Johnson295189b2012-06-20 16:38:30 -07005866 /* Drop packet */
5867 vos_pkt_return_packet(vosTempBuff);
5868 vosTempBuff = vosDataBuff;
5869 continue;
5870 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005871 }/* else data frame*/
5872
5873 vosTempBuff = vosDataBuff;
5874 }/*while chain*/
5875
5876 return VOS_STATUS_SUCCESS;
5877}/* WLANTL_RxFrames */
5878
5879
5880/*==========================================================================
5881
5882 FUNCTION WLANTL_RxCachedFrames
5883
5884 DESCRIPTION
5885 Utility function used by TL to forward the cached frames to a particular
5886 station;
5887
5888 DEPENDENCIES
5889 TL must be initiailized before this function gets called.
5890 If the frame carried is a data frame then the station for which it is
5891 destined to must have been previously registered with TL.
5892
5893 PARAMETERS
5894
5895 IN
5896 pTLCb: pointer to TL handle
5897
5898 ucSTAId: station for which we need to forward the packets
5899
5900 vosDataBuff: it will contain a pointer to the first cached buffer
5901 received, if there is more then one packet they will be
5902 chained using vOSS buffers.
5903
5904 RETURN VALUE
5905 The result code associated with performing the operation
5906
5907 VOS_STATUS_E_INVAL: Input parameters are invalid
5908 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
5909 page fault
5910 VOS_STATUS_SUCCESS: Everything is good :)
5911
5912 SIDE EFFECTS
5913
5914============================================================================*/
5915VOS_STATUS
5916WLANTL_RxCachedFrames
5917(
5918 WLANTL_CbType* pTLCb,
5919 v_U8_t ucSTAId,
5920 vos_pkt_t* vosDataBuff
5921)
5922{
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05305923 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005924 WLANTL_STAFuncType pfnSTAFsm;
5925 vos_pkt_t* vosTempBuff;
5926 VOS_STATUS vosStatus;
5927 v_PVOID_t pvBDHeader = NULL;
5928 WLANTL_STAEventType wSTAEvent = WLANTL_RX_EVENT;
5929 v_U8_t ucTid = 0;
5930 v_BOOL_t broadcast = VOS_FALSE;
5931 v_BOOL_t bSigMatch = VOS_FALSE;
5932 v_BOOL_t selfBcastLoopback = VOS_FALSE;
Madan Mohan Koyyalamudidfd6aa82012-10-18 20:18:43 -07005933 static v_U8_t first_data_pkt_arrived;
Jeff Johnson295189b2012-06-20 16:38:30 -07005934 v_U32_t uDPUSig;
5935 v_U8_t ucUcastSig;
5936 v_U8_t ucBcastSig;
5937 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
5938
5939 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
5940 "WLAN TL:TL Receive Cached Frames called"));
5941
5942 /*------------------------------------------------------------------------
5943 Sanity check
5944 ------------------------------------------------------------------------*/
5945 if ( NULL == vosDataBuff )
5946 {
5947 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
5948 "WLAN TL:Invalid parameter sent on WLANTL_RxFrames"));
5949 return VOS_STATUS_E_INVAL;
5950 }
5951
5952 /*---------------------------------------------------------------------
5953 Save the initial buffer - this is the first received buffer
5954 ---------------------------------------------------------------------*/
5955 vosTempBuff = vosDataBuff;
5956
5957 while ( NULL != vosTempBuff )
5958 {
Madan Mohan Koyyalamudia148e1e2012-11-30 14:52:59 -08005959 broadcast = VOS_FALSE;
5960 selfBcastLoopback = VOS_FALSE;
5961
Jeff Johnson295189b2012-06-20 16:38:30 -07005962 vos_pkt_walk_packet_chain( vosDataBuff, &vosDataBuff, 1/*true*/ );
5963
5964 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
5965 "WLAN TL:Sending new cached packet to station %d", ucSTAId));
5966 /*---------------------------------------------------------------------
5967 Peek at BD header - do not remove
5968 !!! Optimize me: only part of header is needed; not entire one
5969 ---------------------------------------------------------------------*/
5970 vosStatus = WDA_DS_PeekRxPacketInfo( vosTempBuff, (v_PVOID_t)&pvBDHeader, 0 );
5971
5972 if ( NULL == pvBDHeader )
5973 {
5974 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
5975 "WLAN TL:Cannot extract BD header"));
5976 /* Drop packet */
5977 vos_pkt_return_packet(vosTempBuff);
5978 vosTempBuff = vosDataBuff;
5979 continue;
5980 }
5981
5982 uDPUSig = WDA_GET_RX_DPUSIG( pvBDHeader );
5983
5984 /* AMSDU HW bug fix
5985 * After 2nd AMSDU subframe HW could not handle BD correctly
5986 * HAL workaround is needed */
5987 if(WDA_GET_RX_ASF(pvBDHeader))
5988 {
5989 WDA_DS_RxAmsduBdFix(vos_get_global_context(VOS_MODULE_ID_TL,pTLCb),
5990 pvBDHeader);
5991 }
5992
5993 ucTid = (v_U8_t)WDA_GET_RX_TID( pvBDHeader );
5994
5995 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
5996 "WLAN TL:Data packet cached for STA %d", ucSTAId);
5997
5998 /*------------------------------------------------------------------
5999 This should be corrected when multipe sta support is added !!!
6000 for now bcast frames will be sent to the last registered STA
6001 ------------------------------------------------------------------*/
6002 if ( WDA_IS_RX_BCAST(pvBDHeader))
6003 {
6004 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
6005 "WLAN TL:TL rx Bcast frame "));
6006 broadcast = VOS_TRUE;
6007
6008 /* If Addr1 is b/mcast, but Addr3 is our own self MAC, it is a b/mcast
6009 * pkt we sent looping back to us. To be dropped if we are non BTAMP
6010 */
6011 if( WLANHAL_RX_BD_ADDR3_SELF_IDX ==
6012 (v_U8_t)WDA_GET_RX_ADDR3_IDX( pvBDHeader ))
6013 {
6014 selfBcastLoopback = VOS_TRUE;
6015 }
6016 }/*if bcast*/
6017
6018 /*-------------------------------------------------------------------------
6019 Check if the packet that we cached matches the DPU signature of the
6020 newly added station
6021 -------------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306022 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
6023
6024
6025 if ( NULL == pClientSTA )
6026 {
6027 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6028 "WLAN TL:Client Memory was not allocated on %s", __func__));
6029 return VOS_STATUS_E_FAILURE;
6030 }
6031
Jeff Johnson295189b2012-06-20 16:38:30 -07006032 if ( broadcast )
6033 {
6034 ucBcastSig = (v_U8_t)uDPUSig;
6035 bSigMatch = (( WLAN_TL_INVALID_B_SIG !=
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306036 pClientSTA->wSTADesc.ucBcastSig ) &&
6037 ( ucBcastSig == pClientSTA->wSTADesc.ucBcastSig ));
Jeff Johnson295189b2012-06-20 16:38:30 -07006038 }
6039 else
6040 {
6041 ucUcastSig = (v_U8_t)uDPUSig;
6042 bSigMatch = (( WLAN_TL_INVALID_U_SIG !=
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306043 pClientSTA->wSTADesc.ucUcastSig ) &&
6044 ( ucUcastSig == pClientSTA->wSTADesc.ucUcastSig ));
Jeff Johnson295189b2012-06-20 16:38:30 -07006045 }
6046
6047 /*-------------------------------------------------------------------------
6048 If the packet doesn't match - drop it
6049 -------------------------------------------------------------------------*/
6050 if ( !bSigMatch )
6051 {
Rajesh Chauhana6b08f42013-06-18 19:01:26 -07006052 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_MED,
Jeff Johnson295189b2012-06-20 16:38:30 -07006053 "WLAN TL: Cached packet does not match DPU Sig of the new STA - drop "
6054 " DPU Sig %d UC %d BC %d B %d",
6055 uDPUSig,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306056 pClientSTA->wSTADesc.ucUcastSig,
Rajesh Chauhana6b08f42013-06-18 19:01:26 -07006057 pClientSTA->wSTADesc.ucBcastSig,
Jeff Johnson295189b2012-06-20 16:38:30 -07006058 broadcast));
6059
6060 /* Drop packet */
6061 vos_pkt_return_packet(vosTempBuff);
6062 vosTempBuff = vosDataBuff;
6063 continue;
6064
6065 }/*if signature mismatch*/
6066
6067 /*------------------------------------------------------------------------
6068 Check if BT-AMP frame:
6069 - additional processing needed in this case to separate BT-AMP date
6070 from BT-AMP Ctrl path
6071 ------------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306072 if ( WLAN_STA_BT_AMP == pClientSTA->wSTADesc.wSTAType )
Jeff Johnson295189b2012-06-20 16:38:30 -07006073 {
6074 /*--------------------------------------------------------------------
6075 Process the ctrl BAP frame; if data it will return false and it
6076 will be routed through the regular data path
6077 --------------------------------------------------------------------*/
6078 if ( WLANTL_ProcessBAPFrame( pvBDHeader,
6079 vosTempBuff,
6080 pTLCb,
6081 &first_data_pkt_arrived,
6082 ucSTAId))
6083 {
6084 vosTempBuff = vosDataBuff;
6085 continue;
6086 }
6087 }/*if BT-AMP station*/
6088 else if(selfBcastLoopback == VOS_TRUE)
6089 {
6090 /* Drop packet */
6091 vos_pkt_return_packet(vosTempBuff);
6092 vosTempBuff = vosDataBuff;
6093 continue;
6094 }
6095
6096 /*---------------------------------------------------------------------
6097 Data packet received, send to state machine
6098 ---------------------------------------------------------------------*/
6099 wSTAEvent = WLANTL_RX_EVENT;
6100
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306101 pfnSTAFsm = tlSTAFsm[pClientSTA->tlState].
Jeff Johnson295189b2012-06-20 16:38:30 -07006102 pfnSTATbl[wSTAEvent];
6103
6104 if ( NULL != pfnSTAFsm )
6105 {
6106#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
6107 /* Read RSSI and update */
6108 vosStatus = WLANTL_HSHandleRXFrame(vos_get_global_context(
6109 VOS_MODULE_ID_TL,pTLCb),
6110 WLANTL_DATA_FRAME_TYPE,
6111 pvBDHeader,
6112 ucSTAId,
6113 broadcast,
6114 vosTempBuff);
6115 broadcast = VOS_FALSE;
6116#else
6117 vosStatus = WLANTL_ReadRSSI(vos_get_global_context(VOS_MODULE_ID_TL,pTLCb), pvBDHeader, ucSTAId);
6118#endif /*FEATURE_WLAN_GEN6_ROAMING*/
6119 if(!VOS_IS_STATUS_SUCCESS(vosStatus))
6120 {
6121 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6122 "Handle RX Data Frame fail within Handoff support module"));
6123 /* Do Not Drop packet at here
6124 * Revisit why HO module return fail
6125 vos_pkt_return_packet(vosTempBuff);
6126 vosTempBuff = vosDataBuff;
6127 continue;
6128 */
6129 }
6130 pfnSTAFsm( vos_get_global_context(VOS_MODULE_ID_TL,pTLCb), ucSTAId,
6131 &vosTempBuff);
6132 }
6133 else
6134 {
6135 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6136 "WLAN TL:NULL state function, STA:%d, State: %d- dropping packet",
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306137 ucSTAId, pClientSTA->tlState));
Jeff Johnson295189b2012-06-20 16:38:30 -07006138 /* Drop packet */
6139 vos_pkt_return_packet(vosTempBuff);
6140 vosTempBuff = vosDataBuff;
6141 continue;
6142 }
6143
6144 vosTempBuff = vosDataBuff;
6145 }/*while chain*/
6146
6147 return VOS_STATUS_SUCCESS;
6148}/* WLANTL_RxCachedFrames */
6149
6150/*==========================================================================
6151 FUNCTION WLANTL_ResourceCB
6152
6153 DESCRIPTION
6154 Called by the TL when it has packets available for transmission.
6155
6156 DEPENDENCIES
6157 The TL must be registered with BAL before this function can be called.
6158
6159 PARAMETERS
6160
6161 IN
6162 pvosGCtx: pointer to the global vos context; a handle to TL's
6163 or BAL's control block can be extracted from its context
6164
6165 RETURN VALUE
6166 The result code associated with performing the operation
6167
6168 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
6169 page fault
6170 VOS_STATUS_SUCCESS: Everything is good :)
6171
6172 SIDE EFFECTS
6173
6174============================================================================*/
6175VOS_STATUS
6176WLANTL_ResourceCB
6177(
6178 v_PVOID_t pvosGCtx,
6179 v_U32_t uCount
6180)
6181{
6182 WLANTL_CbType* pTLCb = NULL;
6183 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
6184
6185 /*------------------------------------------------------------------------
6186 Sanity check
6187 Extract TL control block
6188 ------------------------------------------------------------------------*/
6189 pTLCb = VOS_GET_TL_CB(pvosGCtx);
6190 if ( NULL == pTLCb )
6191 {
6192 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6193 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_ChangeSTAState"));
6194 return VOS_STATUS_E_FAULT;
6195 }
6196
6197 pTLCb->uResCount = uCount;
6198
6199
6200 /*-----------------------------------------------------------------------
6201 Resume Tx if enough res and not suspended
6202 -----------------------------------------------------------------------*/
6203 if (( pTLCb->uResCount >= WDA_TLI_MIN_RES_MF ) &&
6204 ( 0 == pTLCb->ucTxSuspended ))
6205 {
6206 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
6207 "WLAN TL:Issuing Xmit start request to BAL for avail res ASYNC"));
6208 return WDA_DS_StartXmit(pvosGCtx);
6209 }
6210
6211 return VOS_STATUS_SUCCESS;
6212}/* WLANTL_ResourceCB */
6213
6214
Gopichand Nakkala11acd112012-12-31 16:04:04 -08006215/*==========================================================================
6216 FUNCTION WLANTL_IsTxXmitPending
6217
6218 DESCRIPTION
6219 Called by the WDA when it wants to know whether WDA_DS_TX_START_XMIT msg
6220 is pending in TL msg queue
6221
6222 DEPENDENCIES
6223 The TL must be registered with WDA before this function can be called.
6224
6225 PARAMETERS
6226
6227 IN
6228 pvosGCtx: pointer to the global vos context; a handle to TL's
6229 or WDA's control block can be extracted from its context
6230
6231 RETURN VALUE
6232 The result code associated with performing the operation
6233
6234 0: No WDA_DS_TX_START_XMIT msg pending
6235 1: Msg WDA_DS_TX_START_XMIT already pending in TL msg queue
6236
6237 SIDE EFFECTS
6238
6239============================================================================*/
6240v_BOOL_t
6241WLANTL_IsTxXmitPending
6242(
6243 v_PVOID_t pvosGCtx
6244)
6245{
6246
6247 WLANTL_CbType* pTLCb = NULL;
6248 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
6249
6250 /*------------------------------------------------------------------------
6251 Sanity check
6252 Extract TL control block
6253 ------------------------------------------------------------------------*/
6254 pTLCb = VOS_GET_TL_CB(pvosGCtx);
6255 if ( NULL == pTLCb )
6256 {
6257 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_FATAL,
6258 "WLAN TL:Invalid TL pointer from pvosGCtx in WLANTL_IsTxXmitPending "));
6259 return FALSE;
6260 }
6261
6262 return pTLCb->isTxTranmitMsgPending;
6263
6264}/*WLANTL_IsTxXmitPending */
6265
6266/*==========================================================================
6267 FUNCTION WLANTL_SetTxXmitPending
6268
6269 DESCRIPTION
6270 Called by the WDA when it wants to indicate that WDA_DS_TX_START_XMIT msg
6271 is pending in TL msg queue
6272
6273 DEPENDENCIES
6274 The TL must be registered with WDA before this function can be called.
6275
6276 PARAMETERS
6277
6278 IN
6279 pvosGCtx: pointer to the global vos context; a handle to TL's
6280 or WDA's control block can be extracted from its context
6281
6282 RETURN VALUE None
6283
6284 SIDE EFFECTS
6285
6286============================================================================*/
6287
6288v_VOID_t
6289WLANTL_SetTxXmitPending
6290(
6291 v_PVOID_t pvosGCtx
6292)
6293{
6294
6295 WLANTL_CbType* pTLCb = NULL;
6296 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
6297
6298 /*------------------------------------------------------------------------
6299 Sanity check
6300 Extract TL control block
6301 ------------------------------------------------------------------------*/
6302 pTLCb = VOS_GET_TL_CB(pvosGCtx);
6303 if ( NULL == pTLCb )
6304 {
6305 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_FATAL,
6306 "WLAN TL:Invalid TL pointer from pvosGCtx in WLANTL_SetTxXmitPending"));
6307 return;
6308 }
6309
6310 pTLCb->isTxTranmitMsgPending = 1;
6311 return;
6312
6313}/*WLANTL_SetTxXmitPending */
6314
6315/*==========================================================================
6316 FUNCTION WLANTL_ClearTxXmitPending
6317
6318 DESCRIPTION
6319 Called by the WDA when it wants to indicate that no WDA_DS_TX_START_XMIT msg
6320 is pending in TL msg queue
6321
6322 DEPENDENCIES
6323 The TL must be registered with WDA before this function can be called.
6324
6325 PARAMETERS
6326
6327 IN
6328 pvosGCtx: pointer to the global vos context; a handle to TL's
6329 or WDA's control block can be extracted from its context
6330
6331 RETURN VALUE None
6332
6333 SIDE EFFECTS
6334
6335============================================================================*/
6336
6337v_VOID_t
6338WLANTL_ClearTxXmitPending
6339(
6340 v_PVOID_t pvosGCtx
6341)
6342{
6343
6344 WLANTL_CbType* pTLCb = NULL;
6345 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
6346
6347 /*------------------------------------------------------------------------
6348 Sanity check
6349 Extract TL control block
6350 ------------------------------------------------------------------------*/
6351 pTLCb = VOS_GET_TL_CB(pvosGCtx);
6352 if ( NULL == pTLCb )
6353 {
6354 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_FATAL,
6355 "WLAN TL:Invalid TL pointer from pvosGCtx in WLANTL_ClearTxXmitPending "));
6356 return;
6357 }
6358
6359 pTLCb->isTxTranmitMsgPending = 0;
6360 return;
6361}/*WLANTL_ClearTxXmitPending */
6362
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05306363/*==========================================================================
6364 FUNCTION WLANTL_TxThreadDebugHandler
6365
6366 DESCRIPTION
6367 Printing TL Snapshot dump, processed under TxThread context, currently
6368 information regarding the global TlCb struture. Dumps information related
6369 to per active STA connection currently in use by TL.
6370
6371 DEPENDENCIES
6372 The TL must be initialized before this gets called.
6373
6374 PARAMETERS
6375
6376 IN
6377 pvosGCtx: pointer to the global vos context; a handle to TL's
6378 or WDA's control block can be extracted from its context
6379
6380 RETURN VALUE None
6381
6382 SIDE EFFECTS
6383
6384============================================================================*/
6385
6386v_VOID_t
6387WLANTL_TxThreadDebugHandler
6388(
6389 v_PVOID_t *pVosContext
6390)
6391{
6392 WLANTL_CbType* pTLCb = NULL;
6393 WLANTL_STAClientType* pClientSTA = NULL;
6394 int i = 0;
6395 tWDA_CbContext *pWDA = NULL;
6396
6397 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_FATAL,
6398 "WLAN TL: %s Enter ", __func__));
6399
6400 pTLCb = VOS_GET_TL_CB(pVosContext);
6401 pWDA = (tWDA_CbContext *)vos_get_global_context(VOS_MODULE_ID_WDA, pVosContext);
6402
6403 if ( NULL == pVosContext || NULL == pTLCb )
6404 {
6405 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6406 "Global VoS Context or TL Context are NULL"));
6407 return;
6408 }
6409
6410 if (NULL != pWDA)
6411 {
6412 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6413 "WDA uTxFlowMask: %d", pWDA->uTxFlowMask));
6414 }
6415 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6416 "************************TL DUMP INFORMATION**************"));
6417
6418 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6419 "uDelayedTriggerFrmInt:%d\tuMinFramesProcThres:%d",
6420 pTLCb->tlConfigInfo.uDelayedTriggerFrmInt,
6421 pTLCb->tlConfigInfo.uMinFramesProcThres));
6422
6423 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6424 "Management Frame Client exists: %d",
6425 pTLCb->tlMgmtFrmClient.ucExists));
6426 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6427 "usPendingTxCompleteCount: %d\tucTxSuspended: %d",
6428 pTLCb->usPendingTxCompleteCount,
6429 pTLCb->ucTxSuspended));
6430
6431 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6432 "uResCount: %d", pTLCb->uResCount));
6433
6434 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6435 "ucRegisteredStaId: %d\tucCurrentSTA: %d",
6436 pTLCb->ucRegisteredStaId, pTLCb->ucCurrentSTA));
6437
6438 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6439 "UrgentFrameProcessing: %s\tuFramesProcThres: %d",
6440 (pTLCb->bUrgent?"True":"False"), pTLCb->uFramesProcThres));
6441
6442 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6443 "isTxTranmitMsgPending: %d\t isBMPS: %s",
6444 pTLCb->isTxTranmitMsgPending, pTLCb->isBMPS?"True":"False"));
6445
6446#ifdef FEATURE_WLAN_TDLS
6447 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6448 "TDLS Peer Count: %d", pTLCb->ucTdlsPeerCount));
6449#endif
6450
6451 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6452 "++++++++++++++++++++Registerd Client Information++++++++++"));
6453
6454 for ( i =0; i<WLAN_MAX_STA_COUNT; i++ )
6455 {
6456 pClientSTA = pTLCb->atlSTAClients[i];
6457 if( NULL == pClientSTA || 0 == pClientSTA->ucExists)
6458 {
6459 continue;
6460 }
6461
6462 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6463 "######################STA Index: %d ############################",i));
6464 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR, "WLAN_STADescType:"));
6465 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6466 "STAId: %d\t STA MAC Address: %pM", pClientSTA->wSTADesc.ucSTAId,
6467 pClientSTA->wSTADesc.vSTAMACAddress.bytes));
6468 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6469 "STA Type: %d\tProtectedFrame: %d",
6470 pClientSTA->wSTADesc.wSTAType, pClientSTA->wSTADesc.ucProtectedFrame));
6471 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6472 "QoS: %d\tRxFrameTrans: %d\tTxFrameTrans: %d",
6473 pClientSTA->wSTADesc.ucQosEnabled, pClientSTA->wSTADesc.ucSwFrameRXXlation,
6474 pClientSTA->wSTADesc.ucSwFrameTXXlation));
6475 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6476 "ucUcastSig: %d\tucBcastSig: %d", pClientSTA->wSTADesc.ucUcastSig,
6477 pClientSTA->wSTADesc.ucBcastSig));
6478
6479 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6480 "ClientIndex: %d\t Exists: %d", i, pClientSTA->ucExists));
6481 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6482 "TL State: %d\t TL Priority: %d", pClientSTA->tlState,
6483 pClientSTA->tlPri));
6484 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6485 "ucTxSuspended: %d\tucPktPending: %d", pClientSTA->ucTxSuspended,
6486 pClientSTA->ucPktPending));
6487 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6488 "ucEAPOLPktPending: %d\tucNoMoreData: %d",
6489 pClientSTA->ucEapolPktPending, pClientSTA->ucNoMoreData));
6490 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6491 "ucRxBlocked: %d\t fcStaTxDisabled: %d", pClientSTA->ucRxBlocked,
6492 pClientSTA->fcStaTxDisabled));
6493 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6494 "ucCurrentAC: %d\tucServicedAC: %d", pClientSTA->ucCurrentAC,
6495 pClientSTA->ucServicedAC));
6496 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6497 "TID: %d\tautTxCount[0]: %d\tauRxCount[0]: %d",0, pClientSTA->auTxCount[0],
6498 pClientSTA->auRxCount[0]));
6499 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6500 "aucAcMask[0]: %d\taucAcMask[1]: %d\taucAcMask[2]: %d\taucAcMask[3]: %d\t",
6501 pClientSTA->aucACMask[0], pClientSTA->aucACMask[1],
6502 pClientSTA->aucACMask[2], pClientSTA->aucACMask[3]));
6503 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6504 "ucCurrentWeight: %d", pClientSTA->ucCurrentWeight));
6505
6506 if( WLAN_STA_SOFTAP == pClientSTA->wSTADesc.wSTAType)
6507 {
6508 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6509 "TrafficStatistics for SOFTAP Station:"));
6510 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6511 "RUF=%d\tRMF=%d\tRBF=%d", pClientSTA->trafficStatistics.rxUCFcnt,
6512 pClientSTA->trafficStatistics.rxMCFcnt,
6513 pClientSTA->trafficStatistics.rxBCFcnt));
6514 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6515 "RUB=%d\tRMB=%d\tRBB=%d", pClientSTA->trafficStatistics.rxUCBcnt,
6516 pClientSTA->trafficStatistics.rxMCBcnt,
6517 pClientSTA->trafficStatistics.rxBCBcnt));
6518 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6519 "TUF=%d\tTMF=%d\tTBF=%d", pClientSTA->trafficStatistics.txUCFcnt,
6520 pClientSTA->trafficStatistics.txMCFcnt,
6521 pClientSTA->trafficStatistics.txBCFcnt));
6522 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6523 "TUB=%d\tTMB=%d\tTBB=%d", pClientSTA->trafficStatistics.txUCBcnt,
6524 pClientSTA->trafficStatistics.txMCBcnt,
6525 pClientSTA->trafficStatistics.txBCBcnt));
6526 }
6527 }
6528 return;
6529}
6530
6531/*==========================================================================
6532 FUNCTION WLANTL_TLDebugMessage
6533
6534 DESCRIPTION
6535 Post a TL Snapshot request, posts message in TxThread.
6536
6537 DEPENDENCIES
6538 The TL must be initialized before this gets called.
6539
6540 PARAMETERS
6541
6542 IN
6543 displaySnapshot Boolean showing whether to dump the snapshot or not.
6544
6545 RETURN VALUE None
6546
6547 SIDE EFFECTS
6548
6549============================================================================*/
6550
6551v_VOID_t
6552WLANTL_TLDebugMessage
6553(
6554 v_BOOL_t displaySnapshot
6555)
6556{
6557 vos_msg_t vosMsg;
6558 VOS_STATUS status;
6559
6560 if(displaySnapshot)
6561 {
6562 vosMsg.reserved = 0;
6563 vosMsg.bodyptr = NULL;
6564 vosMsg.type = WLANTL_TX_SNAPSHOT;
6565
6566 status = vos_tx_mq_serialize( VOS_MODULE_ID_TL, &vosMsg);
6567 if(status != VOS_STATUS_SUCCESS)
6568 {
6569 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR, "TX Msg Posting Failed with status: %d",status));
6570 return;
6571 }
6572 }
6573 return;
6574}
Jeff Johnson295189b2012-06-20 16:38:30 -07006575
6576/*============================================================================
6577 TL STATE MACHINE
6578============================================================================*/
6579
6580/*==========================================================================
6581 FUNCTION WLANTL_STATxConn
6582
6583 DESCRIPTION
6584 Transmit in connected state - only EAPOL and WAI packets allowed
6585
6586 DEPENDENCIES
6587 The STA must be registered with TL before this function can be called.
6588
6589 PARAMETERS
6590
6591 IN
6592 pvosGCtx: pointer to the global vos context; a handle to TL's
6593 control block can be extracted from its context
6594 ucSTAId: identifier of the station being processed
6595 vosDataBuff: pointer to the tx vos buffer
6596
6597 RETURN VALUE
6598 The result code associated with performing the operation
6599
6600 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
6601 page fault
6602 VOS_STATUS_SUCCESS: Everything is good :)
6603
6604 Other return values are possible coming from the called functions.
6605 Please check API for additional info.
6606
6607 SIDE EFFECTS
6608
6609============================================================================*/
6610VOS_STATUS
6611WLANTL_STATxConn
6612(
6613 v_PVOID_t pvosGCtx,
6614 v_U8_t ucSTAId,
6615 vos_pkt_t** pvosDataBuff
6616)
6617{
6618 v_U16_t usPktLen;
6619 VOS_STATUS vosStatus;
6620 v_MACADDR_t vDestMacAddr;
6621 vos_pkt_t* vosDataBuff = NULL;
6622 WLANTL_CbType* pTLCb = NULL;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306623 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07006624 WLANTL_MetaInfoType tlMetaInfo;
6625 v_U8_t ucTypeSubtype = 0;
6626 v_U8_t ucTid;
6627 v_U8_t extraHeadSpace = 0;
6628 v_U8_t ucWDSEnabled = 0;
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07006629 v_U8_t ucAC, ucACMask, i;
Gopichand Nakkala8b54e912013-03-11 10:44:21 +05306630 v_U8_t txFlag = HAL_TX_NO_ENCRYPTION_MASK;
Jeff Johnson295189b2012-06-20 16:38:30 -07006631 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
6632
6633 /*------------------------------------------------------------------------
6634 Sanity check
6635 Extract TL control block
6636 ------------------------------------------------------------------------*/
6637 pTLCb = VOS_GET_TL_CB(pvosGCtx);
6638 if ( NULL == pTLCb )
6639 {
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07006640 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6641 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_STATxConn");
Jeff Johnson295189b2012-06-20 16:38:30 -07006642 *pvosDataBuff = NULL;
6643 return VOS_STATUS_E_FAULT;
6644 }
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306645 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
6646
6647 if ( NULL == pClientSTA )
6648 {
6649 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6650 "WLAN TL:Client Memory was not allocated on %s", __func__));
6651 return VOS_STATUS_E_FAILURE;
6652 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006653
6654 /*-------------------------------------------------------------------
6655 Disable AC temporary - if successfull retrieve re-enable
6656 The order is justified because of the possible scenario
6657 - TL tryes to fetch packet for AC and it returns NULL
6658 - TL analyzes the data it has received to see if there are
6659 any more pkts available for AC -> if not TL will disable AC
6660 - however it is possible that while analyzing results TL got
6661 preempted by a pending indication where the mask was again set
6662 TL will not check again and as a result when it resumes
6663 execution it will disable AC
6664 To prevent this the AC will be disabled here and if retrieve
6665 is successfull it will be re-enabled
6666 -------------------------------------------------------------------*/
6667
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07006668
6669 //LTI:pTLCb->atlSTAClients[ucSTAId].
6670 //LTI: aucACMask[pTLCb->atlSTAClients[ucSTAId].ucCurrentAC] = 0;
6671
6672 /*------------------------------------------------------------------------
6673 Fetch packet from HDD
6674 ------------------------------------------------------------------------*/
Sunil Ravid5406f22013-01-22 00:18:31 -08006675#ifdef FEATURE_WLAN_TDLS
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306676 if ((WLAN_STA_SOFTAP != pClientSTA->wSTADesc.wSTAType) &&
Sunil Ravid5406f22013-01-22 00:18:31 -08006677 (!vos_concurrent_sessions_running()) &&
6678 !pTLCb->ucTdlsPeerCount)
6679 {
6680#else
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306681 if ((WLAN_STA_SOFTAP != pClientSTA->wSTADesc.wSTAType) &&
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07006682 (!vos_concurrent_sessions_running()))
6683 {
Sunil Ravid5406f22013-01-22 00:18:31 -08006684#endif
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306685 ucAC = pClientSTA->ucCurrentAC;
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07006686
6687 /*-------------------------------------------------------------------
6688 Disable AC temporary - if successfull retrieve re-enable
6689 The order is justified because of the possible scenario
6690 - TL tryes to fetch packet for AC and it returns NULL
6691 - TL analyzes the data it has received to see if there are
6692 any more pkts available for AC -> if not TL will disable AC
6693 - however it is possible that while analyzing results TL got
6694 preempted by a pending indication where the mask was again set
6695 TL will not check again and as a result when it resumes
6696 execution it will disable AC
6697 To prevent this the AC will be disabled here and if retrieve
6698 is successfull it will be re-enabled
6699 -------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306700 pClientSTA->aucACMask[ucAC] = 0;
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07006701 }
6702 else
6703 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306704 //softap case
6705 ucAC = pTLCb->uCurServedAC;
6706 pClientSTA->aucACMask[ucAC] = 0;
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07006707 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006708
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306709 /*You make an initial assumption that HDD has no more data and if the
Jeff Johnson295189b2012-06-20 16:38:30 -07006710 assumption was wrong you reset the flags to their original state
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306711 This will prevent from exposing a race condition between checking with HDD
Jeff Johnson295189b2012-06-20 16:38:30 -07006712 for packets and setting the flags to false*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306713 //LTI: vos_atomic_set_U8( &pTLCb->atlSTAClients[ucSTAId].ucPktPending, 0);
6714 //LTI: pTLCb->atlSTAClients[ucSTAId].ucNoMoreData = 1;
6715 vos_atomic_set_U8( &pClientSTA->ucPktPending, 0);
6716 WLAN_TL_AC_ARRAY_2_MASK( pClientSTA, ucACMask, i);
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306717 /*You make an initial assumption that HDD has no more data and if the
6718 assumption was wrong you reset the flags to their original state
6719 This will prevent from exposing a race condition between checking with HDD
6720 for packets and setting the flags to false*/
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07006721 if ( 0 == ucACMask )
6722 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306723 pClientSTA->ucNoMoreData = 1;
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07006724 }
6725 else
6726 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306727 vos_atomic_set_U8( &pClientSTA->ucPktPending, 1);
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07006728 }
6729
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07006730
Madan Mohan Koyyalamudid93f4942012-10-05 15:05:40 -07006731 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07006732 "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 +05306733 ucAC, ucACMask, pClientSTA->ucPktPending);
Jeff Johnson295189b2012-06-20 16:38:30 -07006734
6735 /*------------------------------------------------------------------------
6736 Fetch tx packet from HDD
6737 ------------------------------------------------------------------------*/
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07006738//LTI
6739#if 0
Jeff Johnson295189b2012-06-20 16:38:30 -07006740 if (WLAN_STA_SOFTAP != pTLCb->atlSTAClients[ucSTAId].wSTADesc.wSTAType &&
6741 (!vos_concurrent_sessions_running()))
6742 {
Jeff Johnson295189b2012-06-20 16:38:30 -07006743 // don't set 0.
6744 //vos_atomic_set_U8( &pTLCb->atlSTAClients[ucSTAId].ucPktPending, 0);
6745 vosStatus = pTLCb->atlSTAClients[ucSTAId].pfnSTAFetchPkt( pvosGCtx,
6746 &ucSTAId,
6747 pTLCb->atlSTAClients[ucSTAId].ucCurrentAC,
6748 &vosDataBuff, &tlMetaInfo );
Jeff Johnson295189b2012-06-20 16:38:30 -07006749 }
6750 else
6751 {
6752 //softap case
6753 WLANTL_ACEnumType ucAC = pTLCb->uCurServedAC;
6754 vosStatus = pTLCb->atlSTAClients[ucSTAId].pfnSTAFetchPkt( pvosGCtx,
6755 &ucSTAId,
6756 ucAC,
6757 &vosDataBuff, &tlMetaInfo );
6758 }
6759#endif
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07006760
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306761 vosStatus = pClientSTA->pfnSTAFetchPkt( pvosGCtx,
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07006762 &ucSTAId,
6763 ucAC,
6764 &vosDataBuff, &tlMetaInfo );
Jeff Johnson295189b2012-06-20 16:38:30 -07006765
6766 if (( VOS_STATUS_SUCCESS != vosStatus ) || ( NULL == vosDataBuff ))
6767 {
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07006768 TLLOG1(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -07006769 "WLAN TL:No more data at HDD status %d", vosStatus));
6770 *pvosDataBuff = NULL;
6771
6772 /*--------------------------------------------------------------------
6773 Reset AC for the serviced station to the highest priority AC
6774 -> due to no more data at the station
6775 Even if this AC is not supported by the station, correction will be
6776 made in the main TL loop
6777 --------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306778 pClientSTA->ucCurrentAC = WLANTL_AC_VO;
6779 pClientSTA->ucCurrentWeight = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07006780
Madan Mohan Koyyalamudid8000342012-11-08 14:55:26 -08006781 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07006782 "WLAN TL: WLANTL_STATxConn no more packets in HDD for AC: %d AC Mask: %d",
6783 ucAC, ucACMask);
6784
Jeff Johnson295189b2012-06-20 16:38:30 -07006785 return vosStatus;
6786 }
6787
6788 /*There are still packets in HDD - set back the pending packets and
6789 the no more data assumption*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306790 vos_atomic_set_U8( &pClientSTA->ucPktPending, 1);
6791 pClientSTA->ucNoMoreData = 0;
6792 pClientSTA->aucACMask[ucAC] = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07006793
Jeff Johnson295189b2012-06-20 16:38:30 -07006794#ifdef WLAN_PERF
6795 vos_pkt_set_user_data_ptr( vosDataBuff, VOS_PKT_USER_DATA_ID_BAL,
6796 (v_PVOID_t)0);
6797
6798#endif /*WLAN_PERF*/
6799
6800
6801#ifdef FEATURE_WLAN_WAPI
6802 /*------------------------------------------------------------------------
6803 If the packet is neither an Eapol packet nor a WAI packet then drop it
6804 ------------------------------------------------------------------------*/
6805 if ( 0 == tlMetaInfo.ucIsEapol && 0 == tlMetaInfo.ucIsWai )
6806 {
Madan Mohan Koyyalamudid93f4942012-10-05 15:05:40 -07006807 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -07006808 "WLAN TL:Only EAPOL or WAI packets allowed before authentication"));
6809
6810 /* Fail tx for packet */
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306811 pClientSTA->pfnSTATxComp( pvosGCtx, vosDataBuff,
Jeff Johnson295189b2012-06-20 16:38:30 -07006812 VOS_STATUS_E_BADMSG);
6813 vosDataBuff = NULL;
6814 *pvosDataBuff = NULL;
6815 return VOS_STATUS_SUCCESS;
6816 }
6817#else
6818 if ( 0 == tlMetaInfo.ucIsEapol )
6819 {
6820 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
6821 "WLAN TL:Received non EAPOL packet before authentication"));
6822
6823 /* Fail tx for packet */
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306824 pClientSTA->pfnSTATxComp( pvosGCtx, vosDataBuff,
Jeff Johnson295189b2012-06-20 16:38:30 -07006825 VOS_STATUS_E_BADMSG);
6826 vosDataBuff = NULL;
6827 *pvosDataBuff = NULL;
6828 return VOS_STATUS_SUCCESS;
6829 }
6830#endif /* FEATURE_WLAN_WAPI */
6831
6832 /*-------------------------------------------------------------------------
6833 Check TID
6834 -------------------------------------------------------------------------*/
6835 ucTid = tlMetaInfo.ucTID;
6836
6837 /*Make sure TID is valid*/
6838 if ( WLANTL_TID_INVALID(ucTid))
6839 {
6840 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6841 "WLAN TL:Invalid TID sent in meta info %d - defaulting to 0 (BE)",
6842 ucTid));
6843 ucTid = 0;
6844 }
6845
6846 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
6847 "WLAN TL:Attaching BD header to pkt on WLANTL_STATxConn"));
6848
6849#ifdef FEATURE_WLAN_WAPI
6850 /*------------------------------------------------------------------------
6851 Translate 802.3 frame to 802.11 if Frame translation is enabled or if
6852 frame is a WAI frame.
6853 ------------------------------------------------------------------------*/
6854 if ( ( 1 == tlMetaInfo.ucIsWai ) ||
6855 ( 0 == tlMetaInfo.ucDisableFrmXtl ) )
6856#else
6857 /*------------------------------------------------------------------------
6858 Translate 802.3 frame to 802.11 if Frame translation is enabled
6859 ------------------------------------------------------------------------*/
6860 if ( ( 0 == tlMetaInfo.ucDisableFrmXtl ) &&
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306861 ( 0 != pClientSTA->wSTADesc.ucSwFrameTXXlation) )
Jeff Johnson295189b2012-06-20 16:38:30 -07006862#endif //#ifdef FEATURE_WLAN_WAPI
6863 {
Kiran Venkatappacab0d352012-12-17 13:09:22 -08006864 vosStatus = WLANTL_Translate8023To80211Header( vosDataBuff, &vosStatus,
6865 pTLCb, &ucSTAId,
Ravi Joshid0699502013-07-08 15:48:47 -07006866 &tlMetaInfo, &ucWDSEnabled,
6867 &extraHeadSpace);
Jeff Johnson295189b2012-06-20 16:38:30 -07006868 if ( VOS_STATUS_SUCCESS != vosStatus )
6869 {
6870 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6871 "WLAN TL:Error when translating header WLANTL_STATxConn"));
6872
6873 return vosStatus;
6874 }
6875
6876 tlMetaInfo.ucDisableFrmXtl = 1;
6877 }
6878
6879 /*-------------------------------------------------------------------------
6880 Call HAL to fill BD header
6881 -------------------------------------------------------------------------*/
6882 ucTypeSubtype |= (WLANTL_80211_DATA_TYPE << 4);
6883
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306884 if ( pClientSTA->wSTADesc.ucQosEnabled )
Jeff Johnson295189b2012-06-20 16:38:30 -07006885 {
6886 ucTypeSubtype |= (WLANTL_80211_DATA_QOS_SUBTYPE);
6887 }
6888
Gopichand Nakkala8b54e912013-03-11 10:44:21 +05306889#ifdef FEATURE_WLAN_WAPI
6890 /* TL State does not transition to AUTHENTICATED till GTK is installed, So in
6891 * case of WPA where GTK handshake is done after the 4 way handshake, the
6892 * unicast 2/2 EAPOL packet from the STA->AP has to be encrypted even before
6893 * the TL is in authenticated state. Since the PTK has been installed
6894 * already (after the 4 way handshake) we make sure that all traffic
6895 * is encrypted henceforth.(Note: TL is still not in AUTHENTICATED state so
6896 * we will only allow EAPOL data or WAI in case of WAPI)
6897 */
6898 if (tlMetaInfo.ucIsEapol && pClientSTA->ptkInstalled)
6899 {
6900 txFlag = 0;
6901 }
6902#else
6903 if (pClientSTA->ptkInstalled)
6904 {
6905 txFlag = 0;
6906 }
6907#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006908
6909 vosStatus = (VOS_STATUS)WDA_DS_BuildTxPacketInfo( pvosGCtx, vosDataBuff , &vDestMacAddr,
6910 tlMetaInfo.ucDisableFrmXtl, &usPktLen,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306911 pClientSTA->wSTADesc.ucQosEnabled, ucWDSEnabled,
Jeff Johnson295189b2012-06-20 16:38:30 -07006912 extraHeadSpace,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306913 ucTypeSubtype, &pClientSTA->wSTADesc.vSelfMACAddress,
Gopichand Nakkala8b54e912013-03-11 10:44:21 +05306914 ucTid, txFlag,
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -07006915 tlMetaInfo.usTimeStamp, tlMetaInfo.ucIsEapol || tlMetaInfo.ucIsWai, tlMetaInfo.ucUP );
Jeff Johnson295189b2012-06-20 16:38:30 -07006916
6917 if ( VOS_STATUS_SUCCESS != vosStatus )
6918 {
6919 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6920 "WLAN TL:Failed while attempting to fill BD %d", vosStatus));
6921 *pvosDataBuff = NULL;
6922 return vosStatus;
6923 }
6924
6925 /*-----------------------------------------------------------------------
6926 Update tx counter for BA session query for tx side
6927 !1 - should this be done for EAPOL frames?
6928 -----------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306929 pClientSTA->auTxCount[ucTid]++;
Jeff Johnson295189b2012-06-20 16:38:30 -07006930
6931 vos_pkt_set_user_data_ptr( vosDataBuff, VOS_PKT_USER_DATA_ID_TL,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306932 (v_PVOID_t)pClientSTA->pfnSTATxComp );
Jeff Johnson295189b2012-06-20 16:38:30 -07006933
6934 /*------------------------------------------------------------------------
6935 Save data to input pointer for TL core
6936 ------------------------------------------------------------------------*/
6937 *pvosDataBuff = vosDataBuff;
6938 /*security frames cannot be delayed*/
6939 pTLCb->bUrgent = TRUE;
6940
Jeff Johnson295189b2012-06-20 16:38:30 -07006941 /* TX Statistics */
6942 if (!(tlMetaInfo.ucBcast || tlMetaInfo.ucMcast))
6943 {
6944 /* This is TX UC frame */
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306945 pClientSTA->trafficStatistics.txUCFcnt++;
6946 pClientSTA->trafficStatistics.txUCBcnt += usPktLen;
Jeff Johnson295189b2012-06-20 16:38:30 -07006947 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006948
6949 return VOS_STATUS_SUCCESS;
6950}/* WLANTL_STATxConn */
6951
6952
6953/*==========================================================================
6954 FUNCTION WLANTL_STATxAuth
6955
6956 DESCRIPTION
6957 Transmit in authenticated state - all data allowed
6958
6959 DEPENDENCIES
6960 The STA must be registered with TL before this function can be called.
6961
6962 PARAMETERS
6963
6964 IN
6965 pvosGCtx: pointer to the global vos context; a handle to TL's
6966 control block can be extracted from its context
6967 ucSTAId: identifier of the station being processed
6968 vosDataBuff: pointer to the tx vos buffer
6969
6970 RETURN VALUE
6971 The result code associated with performing the operation
6972
6973 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
6974 page fault
6975 VOS_STATUS_SUCCESS: Everything is good :)
6976
6977 Other return values are possible coming from the called functions.
6978 Please check API for additional info.
6979
6980 SIDE EFFECTS
6981
6982============================================================================*/
6983VOS_STATUS
6984WLANTL_STATxAuth
6985(
6986 v_PVOID_t pvosGCtx,
6987 v_U8_t ucSTAId,
6988 vos_pkt_t** pvosDataBuff
6989)
6990{
6991 v_U16_t usPktLen;
6992 VOS_STATUS vosStatus;
6993 v_MACADDR_t vDestMacAddr;
6994 vos_pkt_t* vosDataBuff = NULL;
6995 WLANTL_CbType* pTLCb = NULL;
6996 WLANTL_MetaInfoType tlMetaInfo;
6997 v_U8_t ucTypeSubtype = 0;
6998 WLANTL_ACEnumType ucAC;
6999 WLANTL_ACEnumType ucNextAC;
7000 v_U8_t ucTid;
7001 v_U8_t ucSwFrmXtl = 0;
7002 v_U8_t extraHeadSpace = 0;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307003 WLANTL_STAClientType *pStaClient = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07007004 v_U8_t ucWDSEnabled = 0;
7005 v_U8_t ucTxFlag = 0;
7006 v_U8_t ucACMask, i;
7007 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
7008
7009 /*------------------------------------------------------------------------
7010 Sanity check
7011 Extract TL control block
7012 ------------------------------------------------------------------------*/
7013 pTLCb = VOS_GET_TL_CB(pvosGCtx);
7014 if (( NULL == pTLCb ) || ( NULL == pvosDataBuff ))
7015 {
7016 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05307017 "WLAN TL:Invalid input params on WLANTL_STATxAuth TL %x DB %p",
Jeff Johnson295189b2012-06-20 16:38:30 -07007018 pTLCb, pvosDataBuff));
7019 if (NULL != pvosDataBuff)
7020 {
7021 *pvosDataBuff = NULL;
7022 }
7023 if(NULL != pTLCb)
7024 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307025 if ( NULL == pTLCb->atlSTAClients[ucSTAId] )
7026 {
7027 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7028 "WLAN TL:Client Memory was not allocated on %s", __func__));
7029 return VOS_STATUS_E_FAILURE;
7030 }
7031 pTLCb->atlSTAClients[ucSTAId]->ucNoMoreData = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07007032 }
7033 return VOS_STATUS_E_FAULT;
7034 }
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307035 pStaClient = pTLCb->atlSTAClients[ucSTAId];
Jeff Johnson295189b2012-06-20 16:38:30 -07007036
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307037 if ( NULL == pStaClient )
7038 {
7039 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7040 "WLAN TL:Client Memory was not allocated on %s", __func__));
7041 return VOS_STATUS_E_FAILURE;
7042 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007043
7044 vos_mem_zero(&tlMetaInfo, sizeof(tlMetaInfo));
7045 /*------------------------------------------------------------------------
7046 Fetch packet from HDD
7047 ------------------------------------------------------------------------*/
Sunil Ravid5406f22013-01-22 00:18:31 -08007048#ifdef FEATURE_WLAN_TDLS
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307049 if ((WLAN_STA_SOFTAP != pStaClient->wSTADesc.wSTAType) &&
Sunil Ravid5406f22013-01-22 00:18:31 -08007050 (!vos_concurrent_sessions_running()) &&
7051 !pTLCb->ucTdlsPeerCount)
7052 {
7053#else
Jeff Johnson295189b2012-06-20 16:38:30 -07007054 if ((WLAN_STA_SOFTAP != pStaClient->wSTADesc.wSTAType) &&
7055 (!vos_concurrent_sessions_running()))
7056 {
7057#endif
7058 ucAC = pStaClient->ucCurrentAC;
7059
7060 /*-------------------------------------------------------------------
7061 Disable AC temporary - if successfull retrieve re-enable
7062 The order is justified because of the possible scenario
7063 - TL tryes to fetch packet for AC and it returns NULL
7064 - TL analyzes the data it has received to see if there are
7065 any more pkts available for AC -> if not TL will disable AC
7066 - however it is possible that while analyzing results TL got
7067 preempted by a pending indication where the mask was again set
7068 TL will not check again and as a result when it resumes
7069 execution it will disable AC
7070 To prevent this the AC will be disabled here and if retrieve
7071 is successfull it will be re-enabled
7072 -------------------------------------------------------------------*/
7073 pStaClient->aucACMask[pStaClient->ucCurrentAC] = 0;
7074
7075 // don't reset it, as other AC queues in HDD may have packets
7076 //vos_atomic_set_U8( &pStaClient->ucPktPending, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07007077 }
7078 else
7079 {
7080 //softap case
7081 ucAC = pTLCb->uCurServedAC;
7082 pStaClient->aucACMask[ucAC] = 0;
7083
7084 //vos_atomic_set_U8( &pStaClient->ucPktPending, 0);
7085 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007086
7087 WLAN_TL_AC_ARRAY_2_MASK( pStaClient, ucACMask, i);
Jeff Johnson295189b2012-06-20 16:38:30 -07007088 /*You make an initial assumption that HDD has no more data and if the
7089 assumption was wrong you reset the flags to their original state
7090 This will prevent from exposing a race condition between checking with HDD
7091 for packets and setting the flags to false*/
7092 if ( 0 == ucACMask )
7093 {
7094 vos_atomic_set_U8( &pStaClient->ucPktPending, 0);
7095 pStaClient->ucNoMoreData = 1;
7096 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007097
7098 vosStatus = pStaClient->pfnSTAFetchPkt( pvosGCtx,
7099 &ucSTAId,
7100 ucAC,
7101 &vosDataBuff, &tlMetaInfo );
7102
7103
7104 if (( VOS_STATUS_SUCCESS != vosStatus ) || ( NULL == vosDataBuff ))
7105 {
7106
7107 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
7108 "WLAN TL:Failed while attempting to fetch pkt from HDD %d",
7109 vosStatus);
7110 *pvosDataBuff = NULL;
7111 /*--------------------------------------------------------------------
7112 Reset AC for the serviced station to the highest priority AC
7113 -> due to no more data at the station
7114 Even if this AC is not supported by the station, correction will be
7115 made in the main TL loop
7116 --------------------------------------------------------------------*/
7117 pStaClient->ucCurrentAC = WLANTL_AC_VO;
7118 pStaClient->ucCurrentWeight = 0;
7119
7120 return vosStatus;
7121 }
7122
Jeff Johnsone7245742012-09-05 17:12:55 -07007123 WLANTL_StatHandleTXFrame(pvosGCtx, ucSTAId, vosDataBuff, NULL, &tlMetaInfo);
Jeff Johnsone7245742012-09-05 17:12:55 -07007124
Jeff Johnson295189b2012-06-20 16:38:30 -07007125 /*There are still packets in HDD - set back the pending packets and
7126 the no more data assumption*/
7127 vos_atomic_set_U8( &pStaClient->ucPktPending, 1);
7128 pStaClient->ucNoMoreData = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07007129
Jeff Johnson295189b2012-06-20 16:38:30 -07007130 if (WLAN_STA_SOFTAP != pStaClient->wSTADesc.wSTAType)
7131 {
Jeff Johnson295189b2012-06-20 16:38:30 -07007132 // don't need to set it, as we don't reset it in this function.
7133 //vos_atomic_set_U8( &pTLCb->atlSTAClients[ucSTAId].ucPktPending, 1);
Jeff Johnson295189b2012-06-20 16:38:30 -07007134 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007135
7136#ifdef WLAN_PERF
7137 vos_pkt_set_user_data_ptr( vosDataBuff, VOS_PKT_USER_DATA_ID_BAL,
7138 (v_PVOID_t)0);
7139#endif /*WLAN_PERF*/
7140
7141 /*-------------------------------------------------------------------------
7142 Check TID
7143 -------------------------------------------------------------------------*/
7144 ucTid = tlMetaInfo.ucTID;
7145
7146 /*Make sure TID is valid*/
7147 if ( WLANTL_TID_INVALID(ucTid))
7148 {
7149 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7150 "WLAN TL:Invalid TID sent in meta info %d - defaulting to 0 (BE)",
7151 ucTid));
7152 ucTid = 0;
7153 }
7154
7155 /*Save for UAPSD timer consideration*/
7156 pStaClient->ucServicedAC = ucAC;
7157
7158 if ( ucAC == pStaClient->ucCurrentAC )
7159 {
7160 pStaClient->aucACMask[pStaClient->ucCurrentAC] = 1;
7161 pStaClient->ucCurrentWeight--;
7162 }
7163 else
7164 {
7165 pStaClient->ucCurrentAC = ucAC;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307166 pStaClient->ucCurrentWeight = pTLCb->tlConfigInfo.ucAcWeights[ucAC] - 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07007167
7168 pStaClient->aucACMask[pStaClient->ucCurrentAC] = 1;
7169
7170 }
7171
Jeff Johnson295189b2012-06-20 16:38:30 -07007172 if (WLAN_STA_SOFTAP != pStaClient->wSTADesc.wSTAType)
7173 {
Jeff Johnson295189b2012-06-20 16:38:30 -07007174 if ( 0 == pStaClient->ucCurrentWeight )
7175 {
7176 WLANTL_ACEnumType tempAC = ucAC;
7177 /*-----------------------------------------------------------------------
7178 Choose next AC - !!! optimize me
7179 -----------------------------------------------------------------------*/
7180 while ( 0 != ucACMask )
7181 {
7182 ucNextAC = (WLANTL_ACEnumType)(( tempAC - 1 ) & WLANTL_MASK_AC);
7183 if ( 0 != pStaClient->aucACMask[ucNextAC] )
7184 {
7185 pStaClient->ucCurrentAC = ucNextAC;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307186 pStaClient->ucCurrentWeight = pTLCb->tlConfigInfo.ucAcWeights[ucNextAC];
Jeff Johnson295189b2012-06-20 16:38:30 -07007187
7188 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
7189 "WLAN TL: Changing serviced AC to: %d with Weight: %d",
7190 pStaClient->ucCurrentAC ,
7191 pStaClient->ucCurrentWeight));
7192 break;
7193 }
7194 tempAC = ucNextAC;
7195 }
7196 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007197 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007198
7199 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
7200 "WLAN TL:Attaching BD header to pkt on WLANTL_STATxAuth"));
7201
7202 /*------------------------------------------------------------------------
7203 Translate 802.3 frame to 802.11
7204 ------------------------------------------------------------------------*/
7205 if ( 0 == tlMetaInfo.ucDisableFrmXtl )
7206 {
7207 /* Needs frame translation */
7208 // if the client has not enabled SW-only frame translation
7209 // and if the frame is a unicast frame
7210 // (HW frame translation does not support multiple broadcast domains
7211 // so we use SW frame translation for broadcast/multicast frames)
7212#ifdef FEATURE_WLAN_WAPI
7213 // and if the frame is not a WAPI frame
7214#endif
7215 // then use HW_based frame translation
7216
7217 if ( ( 0 == pStaClient->wSTADesc.ucSwFrameTXXlation ) &&
7218 ( 0 == tlMetaInfo.ucBcast ) &&
7219 ( 0 == tlMetaInfo.ucMcast )
7220#ifdef FEATURE_WLAN_WAPI
7221 && ( tlMetaInfo.ucIsWai != 1 )
7222#endif
7223 )
7224 {
7225#ifdef WLAN_PERF
7226 v_U32_t uFastFwdOK = 0;
7227
7228 /* HW based translation. See if the frame could be fast forwarded */
7229 WDA_TLI_FastHwFwdDataFrame( pvosGCtx, vosDataBuff , &vosStatus,
7230 &uFastFwdOK, &tlMetaInfo, &pStaClient->wSTADesc);
7231
7232 if( VOS_STATUS_SUCCESS == vosStatus )
7233 {
7234 if(uFastFwdOK)
7235 {
7236 /* Packet could be fast forwarded now */
7237 vos_pkt_set_user_data_ptr( vosDataBuff, VOS_PKT_USER_DATA_ID_TL,
7238 (v_PVOID_t)pStaClient->pfnSTATxComp );
7239
7240 *pvosDataBuff = vosDataBuff;
7241
7242 /* TODO: Do we really need to update WLANTL_HSHandleTXFrame()
7243 stats for every pkt? */
7244 pStaClient->auTxCount[tlMetaInfo.ucTID]++;
7245 return vosStatus;
7246 }
7247 /* can't be fast forwarded, fall through normal (slow) path. */
7248 }
7249 else
7250 {
7251
7252 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7253 "WLAN TL:Failed while attempting to fastFwd BD %d", vosStatus));
7254 *pvosDataBuff = NULL;
7255 return vosStatus;
7256 }
7257#endif /*WLAN_PERF*/
7258 }
7259 else
7260 {
7261 /* SW based translation */
7262
7263#ifdef FEATURE_WLAN_WAPI
7264 gUcIsWai = tlMetaInfo.ucIsWai,
7265#endif
7266
Kiran Venkatappacab0d352012-12-17 13:09:22 -08007267 vosStatus = WLANTL_Translate8023To80211Header( vosDataBuff, &vosStatus,
7268 pTLCb, &ucSTAId,
Ravi Joshid0699502013-07-08 15:48:47 -07007269 &tlMetaInfo, &ucWDSEnabled,
7270 &extraHeadSpace);
Jeff Johnson295189b2012-06-20 16:38:30 -07007271 if ( VOS_STATUS_SUCCESS != vosStatus )
7272 {
7273 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7274 "WLAN TL:Error when translating header WLANTL_STATxAuth"));
7275 return vosStatus;
7276 }
7277
7278 TLLOG4(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_LOW,
7279 "WLAN TL software translation success \n"));
7280 ucSwFrmXtl = 1;
7281 tlMetaInfo.ucDisableFrmXtl = 1;
7282 }
7283 }
Gopichand Nakkala574f6d12013-06-27 19:38:43 +05307284#ifdef FEATURE_WLAN_TDLS
7285 /*In case of TDLS, if the packet is destined to TDLS STA ucSTAId may
7286 change. so update the pStaClient accordingly */
7287 pStaClient = pTLCb->atlSTAClients[ucSTAId];
Jeff Johnson295189b2012-06-20 16:38:30 -07007288
Gopichand Nakkala574f6d12013-06-27 19:38:43 +05307289 if ( NULL == pStaClient )
7290 {
7291 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7292 "pStaClient is NULL %s", __func__));
7293 return VOS_STATUS_E_FAILURE;
7294 }
7295#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007296 /*-------------------------------------------------------------------------
7297 Call HAL to fill BD header
7298 -------------------------------------------------------------------------*/
7299 ucTypeSubtype |= (WLANTL_80211_DATA_TYPE << 4);
7300
7301 if ( pStaClient->wSTADesc.ucQosEnabled )
7302 {
7303 ucTypeSubtype |= (WLANTL_80211_DATA_QOS_SUBTYPE);
7304 }
7305
7306 ucTxFlag = (0 != pStaClient->wUAPSDInfo[ucAC].ucSet)?
7307 HAL_TRIGGER_ENABLED_AC_MASK:0;
7308
7309#ifdef FEATURE_WLAN_WAPI
7310 if ( pStaClient->wSTADesc.ucIsWapiSta == 1 )
7311 {
7312#ifdef LIBRA_WAPI_SUPPORT
7313 ucTxFlag = ucTxFlag | HAL_WAPI_STA_MASK;
7314#endif //LIBRA_WAPI_SUPPORT
7315 if ( tlMetaInfo.ucIsWai == 1 )
7316 {
7317 ucTxFlag = ucTxFlag | HAL_TX_NO_ENCRYPTION_MASK;
7318 }
7319 }
7320#endif /* FEATURE_WLAN_WAPI */
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007321#ifdef FEATURE_WLAN_TDLS
7322 if ( pStaClient->wSTADesc.wSTAType == WLAN_STA_TDLS )
7323 {
7324 ucTxFlag = ucTxFlag | HAL_TDLS_PEER_STA_MASK;
7325 }
7326#endif /* FEATURE_WLAN_TDLS */
Jeff Johnson295189b2012-06-20 16:38:30 -07007327
7328 vosStatus = (VOS_STATUS)WDA_DS_BuildTxPacketInfo( pvosGCtx,
7329 vosDataBuff , &vDestMacAddr,
7330 tlMetaInfo.ucDisableFrmXtl, &usPktLen,
7331 pStaClient->wSTADesc.ucQosEnabled, ucWDSEnabled,
7332 extraHeadSpace,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307333 ucTypeSubtype, &pStaClient->wSTADesc.vSelfMACAddress,
Jeff Johnson295189b2012-06-20 16:38:30 -07007334 ucTid, ucTxFlag, tlMetaInfo.usTimeStamp,
7335 tlMetaInfo.ucIsEapol, tlMetaInfo.ucUP );
7336
7337 if(!VOS_IS_STATUS_SUCCESS(vosStatus))
7338 {
7339 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7340 "Fill TX BD Error status %d", vosStatus));
7341
7342 return vosStatus;
7343 }
7344
Jeff Johnson295189b2012-06-20 16:38:30 -07007345 /* TX Statistics */
7346 if (!(tlMetaInfo.ucBcast || tlMetaInfo.ucMcast))
7347 {
7348 /* This is TX UC frame */
7349 pStaClient->trafficStatistics.txUCFcnt++;
7350 pStaClient->trafficStatistics.txUCBcnt += usPktLen;
7351 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007352
Kiran Venkatappacab0d352012-12-17 13:09:22 -08007353#ifndef FEATURE_WLAN_TDLS
Jeff Johnson295189b2012-06-20 16:38:30 -07007354 /*-----------------------------------------------------------------------
7355 Update tx counter for BA session query for tx side
7356 -----------------------------------------------------------------------*/
7357 pStaClient->auTxCount[ucTid]++;
Kiran Venkatappacab0d352012-12-17 13:09:22 -08007358#else
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307359 pTLCb->atlSTAClients[ucSTAId]->auTxCount[ucTid]++;
Kiran Venkatappacab0d352012-12-17 13:09:22 -08007360#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007361
7362 /* This code is to send traffic with lower priority AC when we does not
7363 get admitted to send it. Today HAL does not downgrade AC so this code
7364 does not get executed.(In other words, HAL doesnÂ’t change tid. The if
7365 statement is always false.)
7366 NOTE: In the case of LA downgrade occurs in HDD (that was the change
7367 Phani made during WMM-AC plugfest). If WM & BMP also took this approach,
7368 then there will be no need for any AC downgrade logic in TL/WDI. */
7369#if 0
7370 if (( ucTid != tlMetaInfo.ucTID ) &&
7371 ( 0 != pStaClient->wSTADesc.ucQosEnabled ) &&
7372 ( 0 != ucSwFrmXtl ))
7373 {
7374 /*---------------------------------------------------------------------
7375 !! FIX me: Once downgrading is clear put in the proper change
7376 ---------------------------------------------------------------------*/
7377 ucQCOffset = WLANHAL_TX_BD_HEADER_SIZE + WLANTL_802_11_HEADER_LEN;
7378
7379 //!!!Fix this replace peek with extract
7380 vos_pkt_peek_data( vosDataBuff, ucQCOffset,(v_PVOID_t)&pucQosCtrl,
7381 sizeof(*pucQosCtrl));
7382 *pucQosCtrl = ucTid; //? proper byte order
7383 }
7384#endif
7385
7386 if ( VOS_STATUS_SUCCESS != vosStatus )
7387 {
7388 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7389 "WLAN TL:Failed while attempting to fill BD %d", vosStatus));
7390 *pvosDataBuff = NULL;
7391 return vosStatus;
7392 }
7393
7394 vos_pkt_set_user_data_ptr( vosDataBuff, VOS_PKT_USER_DATA_ID_TL,
7395 (v_PVOID_t)pStaClient->pfnSTATxComp );
7396
7397 *pvosDataBuff = vosDataBuff;
7398
7399 /*BE & BK can be delayed, VO and VI not frames cannot be delayed*/
7400 if ( pStaClient->ucServicedAC > WLANTL_AC_BE )
7401 {
7402 pTLCb->bUrgent= TRUE;
7403 }
7404
7405 return VOS_STATUS_SUCCESS;
7406}/* WLANTL_STATxAuth */
7407
7408/*==========================================================================
7409 FUNCTION WLANTL_STATxDisc
7410
7411 DESCRIPTION
7412 Transmit in disconnected state - no data allowed
7413
7414 DEPENDENCIES
7415 The STA must be registered with TL before this function can be called.
7416
7417 PARAMETERS
7418
7419 IN
7420 pvosGCtx: pointer to the global vos context; a handle to TL's
7421 control block can be extracted from its context
7422 ucSTAId: identifier of the station being processed
7423 vosDataBuff: pointer to the tx vos buffer
7424
7425 RETURN VALUE
7426 The result code associated with performing the operation
7427
7428 VOS_STATUS_SUCCESS: Everything is good :)
7429
7430 SIDE EFFECTS
7431
7432============================================================================*/
7433VOS_STATUS
7434WLANTL_STATxDisc
7435(
7436 v_PVOID_t pvosGCtx,
7437 v_U8_t ucSTAId,
7438 vos_pkt_t** pvosDataBuff
7439)
7440{
7441 WLANTL_CbType* pTLCb = NULL;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307442 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07007443 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
7444
Jeff Johnson295189b2012-06-20 16:38:30 -07007445 /*------------------------------------------------------------------------
7446 Sanity check
7447 Extract TL control block
7448 ------------------------------------------------------------------------*/
7449 pTLCb = VOS_GET_TL_CB(pvosGCtx);
7450 if ( NULL == pTLCb )
7451 {
7452 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7453 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_STATxAuth"));
7454 *pvosDataBuff = NULL;
7455 return VOS_STATUS_E_FAULT;
7456 }
7457
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307458 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
7459
7460 if ( NULL == pClientSTA )
7461 {
7462 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7463 "WLAN TL:Client Memory was not allocated on %s", __func__));
7464 return VOS_STATUS_E_FAILURE;
7465 }
7466
Jeff Johnson295189b2012-06-20 16:38:30 -07007467 /*------------------------------------------------------------------------
7468 Error
7469 ------------------------------------------------------------------------*/
7470 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
7471 "WLAN TL:Packet should not be transmitted in state disconnected ignoring"
7472 " request"));
7473
7474 *pvosDataBuff = NULL;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307475 pClientSTA->ucNoMoreData = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07007476
7477 //Should not be anything pending in disconnect state
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307478 vos_atomic_set_U8( &pClientSTA->ucPktPending, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07007479
7480 return VOS_STATUS_SUCCESS;
7481}/* WLANTL_STATxDisc */
7482
7483/*==========================================================================
7484 FUNCTION WLANTL_STARxConn
7485
7486 DESCRIPTION
7487 Receive in connected state - only EAPOL
7488
7489 DEPENDENCIES
7490 The STA must be registered with TL before this function can be called.
7491
7492 PARAMETERS
7493
7494 IN
7495 pvosGCtx: pointer to the global vos context; a handle to TL's
7496 control block can be extracted from its context
7497 ucSTAId: identifier of the station being processed
7498 vosDataBuff: pointer to the tx/rx vos buffer
7499
7500 RETURN VALUE
7501 The result code associated with performing the operation
7502
7503 VOS_STATUS_E_INVAL: invalid input parameters
7504 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
7505 page fault
7506 VOS_STATUS_SUCCESS: Everything is good :)
7507
7508 SIDE EFFECTS
7509
7510============================================================================*/
7511VOS_STATUS
7512WLANTL_STARxConn
7513(
7514 v_PVOID_t pvosGCtx,
7515 v_U8_t ucSTAId,
7516 vos_pkt_t** pvosDataBuff
7517)
7518{
7519 WLANTL_CbType* pTLCb = NULL;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307520 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07007521 v_U16_t usEtherType = 0;
7522 v_U16_t usPktLen;
7523 v_U8_t ucMPDUHOffset;
7524 v_U16_t usMPDUDOffset;
7525 v_U16_t usMPDULen;
7526 v_U8_t ucMPDUHLen;
7527 v_U16_t usActualHLen = 0;
7528 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
7529 vos_pkt_t* vosDataBuff;
7530 v_PVOID_t aucBDHeader;
7531 v_U8_t ucTid;
7532 WLANTL_RxMetaInfoType wRxMetaInfo;
7533 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
7534
7535 /*------------------------------------------------------------------------
7536 Sanity check
7537 ------------------------------------------------------------------------*/
7538 if (( NULL == pvosDataBuff ) || ( NULL == ( vosDataBuff = *pvosDataBuff )))
7539 {
7540 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7541 "WLAN TL:Invalid parameter sent on WLANTL_STARxConn"));
7542 return VOS_STATUS_E_INVAL;
7543 }
7544
7545 /*------------------------------------------------------------------------
7546 Extract TL control block
7547 ------------------------------------------------------------------------*/
7548 pTLCb = VOS_GET_TL_CB(pvosGCtx);
7549 if ( NULL == pTLCb )
7550 {
7551 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7552 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_ChangeSTAState"));
7553 return VOS_STATUS_E_FAULT;
7554 }
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307555 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
7556
7557 if ( NULL == pClientSTA )
7558 {
7559 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7560 "WLAN TL:Client Memory was not allocated on %s", __func__));
7561 return VOS_STATUS_E_FAILURE;
7562 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007563
7564 /*------------------------------------------------------------------------
7565 Extract BD header and check if valid
7566 ------------------------------------------------------------------------*/
7567 vosStatus = WDA_DS_PeekRxPacketInfo( vosDataBuff, (v_PVOID_t)&aucBDHeader, 0/*Swap BD*/ );
7568
7569 if ( NULL == aucBDHeader )
7570 {
7571 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7572 "WLAN TL:Cannot extract BD header"));
7573 VOS_ASSERT( 0 );
7574 return VOS_STATUS_E_FAULT;
7575 }
7576
7577
7578 ucMPDUHOffset = (v_U8_t)WDA_GET_RX_MPDU_HEADER_OFFSET(aucBDHeader);
7579 usMPDUDOffset = (v_U16_t)WDA_GET_RX_MPDU_DATA_OFFSET(aucBDHeader);
7580 usMPDULen = (v_U16_t)WDA_GET_RX_MPDU_LEN(aucBDHeader);
7581 ucMPDUHLen = (v_U8_t)WDA_GET_RX_MPDU_HEADER_LEN(aucBDHeader);
7582 ucTid = (v_U8_t)WDA_GET_RX_TID(aucBDHeader);
7583
7584 vos_pkt_get_packet_length( vosDataBuff, &usPktLen);
7585
7586 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
7587 "WLAN TL:BD header processing data: HO %d DO %d Len %d HLen %d",
7588 ucMPDUHOffset, usMPDUDOffset, usMPDULen, ucMPDUHLen));
7589
7590 /*It will cut out the 802.11 header if not used*/
7591 if ( VOS_STATUS_SUCCESS != WDA_DS_TrimRxPacketInfo( vosDataBuff ) )
7592 {
7593 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
7594 "WLAN TL:BD header corrupted - dropping packet"));
7595 /* Drop packet */
7596 vos_pkt_return_packet(vosDataBuff);
7597 return VOS_STATUS_SUCCESS;
7598 }
7599
7600 vosStatus = WLANTL_GetEtherType(aucBDHeader,vosDataBuff,ucMPDUHLen,&usEtherType);
7601
7602 if( VOS_IS_STATUS_SUCCESS(vosStatus) )
7603 {
7604#ifdef FEATURE_WLAN_WAPI
7605 /* If frame is neither an EAPOL frame nor a WAI frame then we drop the frame*/
7606 /* TODO: Do we need a check to see if we are in WAPI mode? If not is it possible */
7607 /* that we get an EAPOL packet in WAPI mode or vice versa? */
7608 if ( WLANTL_LLC_8021X_TYPE != usEtherType && WLANTL_LLC_WAI_TYPE != usEtherType )
7609 {
Sunil Ravid5406f22013-01-22 00:18:31 -08007610 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07007611 "WLAN TL:RX Frame not EAPOL or WAI EtherType %d - dropping", usEtherType );
Jeff Johnson295189b2012-06-20 16:38:30 -07007612 /* Drop packet */
7613 vos_pkt_return_packet(vosDataBuff);
7614 }
7615#else
7616 if ( WLANTL_LLC_8021X_TYPE != usEtherType )
7617 {
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07007618 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7619 "WLAN TL:RX Frame not EAPOL EtherType %d - dropping", usEtherType);
Jeff Johnson295189b2012-06-20 16:38:30 -07007620 /* Drop packet */
7621 vos_pkt_return_packet(vosDataBuff);
7622 }
7623#endif /* FEATURE_WLAN_WAPI */
7624 else /* Frame is an EAPOL frame or a WAI frame*/
7625 {
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07007626
Madan Mohan Koyyalamudid8000342012-11-08 14:55:26 -08007627 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07007628 "WLAN TL:RX Frame EAPOL EtherType %d - processing", usEtherType);
7629
Jeff Johnson295189b2012-06-20 16:38:30 -07007630 if (( 0 == WDA_GET_RX_FT_DONE(aucBDHeader) ) &&
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307631 ( 0 != pClientSTA->wSTADesc.ucSwFrameRXXlation))
Jeff Johnson295189b2012-06-20 16:38:30 -07007632 {
7633 if (usMPDUDOffset > ucMPDUHOffset)
7634 {
7635 usActualHLen = usMPDUDOffset - ucMPDUHOffset;
7636 }
7637
7638 vosStatus = WLANTL_Translate80211To8023Header( vosDataBuff, &vosStatus, usActualHLen,
7639 ucMPDUHLen, pTLCb, ucSTAId);
7640
7641 if ( VOS_STATUS_SUCCESS != vosStatus )
7642 {
7643 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7644 "WLAN TL:Failed to translate from 802.11 to 802.3 - dropping"));
7645 /* Drop packet */
7646 vos_pkt_return_packet(vosDataBuff);
7647 return vosStatus;
7648 }
7649 }
7650 /*-------------------------------------------------------------------
7651 Increment receive counter
7652 -------------------------------------------------------------------*/
Madan Mohan Koyyalamudic0e5bd82012-09-18 17:12:27 -07007653 if ( !WLANTL_TID_INVALID( ucTid) )
7654 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307655 pClientSTA->auRxCount[ucTid]++;
Madan Mohan Koyyalamudic0e5bd82012-09-18 17:12:27 -07007656 }
7657 else
7658 {
7659 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7660 "WLAN TL:Invalid tid %d (Station ID %d) on %s",
7661 ucTid, ucSTAId, __func__));
7662 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007663
7664 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
7665 "WLAN TL:Sending EAPoL frame to station %d AC %d", ucSTAId, ucTid));
7666
7667 /*-------------------------------------------------------------------
7668 !!!Assuming TID = UP mapping
7669 -------------------------------------------------------------------*/
7670 wRxMetaInfo.ucUP = ucTid;
7671
Jeff Johnson295189b2012-06-20 16:38:30 -07007672 TLLOG4(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_LOW,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007673 "WLAN TL %s:Sending data chain to station \n", __func__));
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307674 if ( WLAN_STA_SOFTAP == pClientSTA->wSTADesc.wSTAType )
Jeff Johnson295189b2012-06-20 16:38:30 -07007675 {
7676 wRxMetaInfo.ucDesSTAId = WLAN_RX_SAP_SELF_STA_ID;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307677 pClientSTA->pfnSTARx( pvosGCtx, vosDataBuff, ucSTAId,
Jeff Johnson295189b2012-06-20 16:38:30 -07007678 &wRxMetaInfo );
7679 }
7680 else
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307681 pClientSTA->pfnSTARx( pvosGCtx, vosDataBuff, ucSTAId,
Jeff Johnson295189b2012-06-20 16:38:30 -07007682 &wRxMetaInfo );
7683 }/*EAPOL frame or WAI frame*/
7684 }/*vos status success*/
7685
7686 return VOS_STATUS_SUCCESS;
7687}/* WLANTL_STARxConn */
7688
Jeff Johnson295189b2012-06-20 16:38:30 -07007689/*==========================================================================
7690 FUNCTION WLANTL_FwdPktToHDD
7691
7692 DESCRIPTION
7693 Determine the Destation Station ID and route the Frame to Upper Layer
7694
7695 DEPENDENCIES
7696
7697 PARAMETERS
7698
7699 IN
7700 pvosGCtx: pointer to the global vos context; a handle to TL's
7701 control block can be extracted from its context
7702 ucSTAId: identifier of the station being processed
7703 vosDataBuff: pointer to the rx vos buffer
7704
7705 RETURN VALUE
7706 The result code associated with performing the operation
7707
7708 VOS_STATUS_E_INVAL: invalid input parameters
7709 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
7710 page fault
7711 VOS_STATUS_SUCCESS: Everything is good :)
7712
7713 SIDE EFFECTS
7714
7715============================================================================*/
7716
7717VOS_STATUS
7718WLANTL_FwdPktToHDD
7719(
7720 v_PVOID_t pvosGCtx,
7721 vos_pkt_t* pvosDataBuff,
7722 v_U8_t ucSTAId
7723)
7724{
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307725 v_MACADDR_t DestMacAddress;
7726 v_MACADDR_t *pDestMacAddress = &DestMacAddress;
7727 v_SIZE_t usMacAddSize = VOS_MAC_ADDR_SIZE;
Jeff Johnson295189b2012-06-20 16:38:30 -07007728 WLANTL_CbType* pTLCb = NULL;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307729 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07007730 vos_pkt_t* vosDataBuff ;
7731 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307732 v_U32_t STAMetaInfo;
7733 vos_pkt_t* vosNextDataBuff ;
7734 v_U8_t ucDesSTAId;
Jeff Johnson295189b2012-06-20 16:38:30 -07007735 WLANTL_RxMetaInfoType wRxMetaInfo;
7736
Jeff Johnson295189b2012-06-20 16:38:30 -07007737 /*------------------------------------------------------------------------
7738 Sanity check
7739 ------------------------------------------------------------------------*/
7740 if (( NULL == pvosDataBuff ) || ( NULL == ( vosDataBuff = pvosDataBuff )))
7741 {
7742 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7743 "WLAN TL:Invalid parameter sent on WLANTL_FwdPktToHdd"));
7744 return VOS_STATUS_E_INVAL;
7745 }
7746
7747 /*------------------------------------------------------------------------
7748 Extract TL control block
7749 ------------------------------------------------------------------------*/
7750 pTLCb = VOS_GET_TL_CB(pvosGCtx);
7751 if ( NULL == pTLCb )
7752 {
7753 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7754 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_FwdPktToHdd"));
7755 return VOS_STATUS_E_FAULT;
7756 }
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307757
Tushnim Bhattacharyya5dd94562013-03-20 20:15:03 -07007758 if(WLANTL_STA_ID_INVALID(ucSTAId))
7759 {
7760 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,"ucSTAId %d is not valid",
7761 ucSTAId));
7762 return VOS_STATUS_E_INVAL;
7763 }
7764
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307765 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
7766
7767 if ( NULL == pClientSTA )
7768 {
7769 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7770 "WLAN TL:Client Memory was not allocated on %s", __func__));
7771 return VOS_STATUS_E_FAILURE;
7772 }
7773
Jeff Johnson295189b2012-06-20 16:38:30 -07007774 /* This the change required for SoftAp to handle Reordered Buffer. Since a STA
7775 may have packets destined to multiple destinations we have to process each packet
7776 at a time and determine its Destination. So the Voschain provided by Reorder code
7777 is unchain and forwarded to Upper Layer after Determining the Destination */
7778
7779 vosDataBuff = pvosDataBuff;
7780 while (vosDataBuff != NULL)
7781 {
7782 vos_pkt_walk_packet_chain( vosDataBuff, &vosNextDataBuff, 1/*true*/ );
7783 vos_pkt_get_user_data_ptr( vosDataBuff, VOS_PKT_USER_DATA_ID_TL,
7784 (v_PVOID_t *)&STAMetaInfo );
7785 wRxMetaInfo.ucUP = (v_U8_t)(STAMetaInfo & WLANTL_AC_MASK);
Gopichand Nakkala976e3252013-01-03 15:45:56 -08007786 ucDesSTAId = (v_U8_t)((STAMetaInfo) >> WLANTL_STAID_OFFSET);
Jeff Johnson295189b2012-06-20 16:38:30 -07007787
7788 vosStatus = vos_pkt_extract_data( vosDataBuff, 0, (v_VOID_t *)pDestMacAddress, &usMacAddSize);
7789 if ( VOS_STATUS_SUCCESS != vosStatus )
7790 {
7791 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7792 "WLAN TL: recv corrupted data packet\n"));
7793 vos_pkt_return_packet(vosDataBuff);
7794 return vosStatus;
7795 }
7796
7797 TLLOG4(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_LOW,"station mac 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x \n",
7798 pDestMacAddress->bytes[0], pDestMacAddress->bytes[1], pDestMacAddress->bytes[2],
7799 pDestMacAddress->bytes[3], pDestMacAddress->bytes[4], pDestMacAddress->bytes[5]));
7800
7801 if (vos_is_macaddr_broadcast( pDestMacAddress ) || vos_is_macaddr_group(pDestMacAddress))
7802 {
7803 // destination is mc/bc station
7804 ucDesSTAId = WLAN_RX_BCMC_STA_ID;
7805 TLLOG4(VOS_TRACE( VOS_MODULE_ID_HDD_SOFTAP, VOS_TRACE_LEVEL_INFO_LOW,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007806 "%s: BC/MC packet, id %d\n", __func__, WLAN_RX_BCMC_STA_ID));
Jeff Johnson295189b2012-06-20 16:38:30 -07007807 }
7808 else
7809 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307810 if (vos_is_macaddr_equal(pDestMacAddress, &pClientSTA->wSTADesc.vSelfMACAddress))
Jeff Johnson295189b2012-06-20 16:38:30 -07007811 {
7812 // destination is AP itself
7813 ucDesSTAId = WLAN_RX_SAP_SELF_STA_ID;
7814 TLLOG4(VOS_TRACE( VOS_MODULE_ID_HDD_SOFTAP, VOS_TRACE_LEVEL_INFO_LOW,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007815 "%s: packet to AP itself, id %d\n", __func__, WLAN_RX_SAP_SELF_STA_ID));
Jeff Johnson295189b2012-06-20 16:38:30 -07007816 }
Madan Mohan Koyylamudi64258222013-01-30 14:35:10 +05307817 else if (( WLAN_MAX_STA_COUNT <= ucDesSTAId ) || (NULL != pTLCb->atlSTAClients[ucDesSTAId] && pTLCb->atlSTAClients[ucDesSTAId]->ucExists == 0))
Jeff Johnson295189b2012-06-20 16:38:30 -07007818 {
7819 // destination station is something else
7820 TLLOG4(VOS_TRACE( VOS_MODULE_ID_HDD_SOFTAP, VOS_TRACE_LEVEL_INFO_LOW,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007821 "%s: get an station index larger than WLAN_MAX_STA_COUNT %d\n", __func__, ucDesSTAId));
Jeff Johnson295189b2012-06-20 16:38:30 -07007822 ucDesSTAId = WLAN_RX_SAP_SELF_STA_ID;
7823 }
7824
7825
7826 //loopback unicast station comes here
7827 }
7828
7829 wRxMetaInfo.ucUP = (v_U8_t)(STAMetaInfo & WLANTL_AC_MASK);
7830 wRxMetaInfo.ucDesSTAId = ucDesSTAId;
7831
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307832 vosStatus = pClientSTA->pfnSTARx( pvosGCtx, vosDataBuff, ucDesSTAId,
Jeff Johnson295189b2012-06-20 16:38:30 -07007833 &wRxMetaInfo );
7834 if ( VOS_STATUS_SUCCESS != vosStatus )
7835 {
7836 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7837 "WLAN TL: failed to send pkt to HDD \n"));
7838 vos_pkt_return_packet(vosDataBuff);
7839 return vosStatus;
7840 }
7841 vosDataBuff = vosNextDataBuff;
7842 }
7843 return VOS_STATUS_SUCCESS;
7844}
Jeff Johnson295189b2012-06-20 16:38:30 -07007845
7846/*==========================================================================
7847 FUNCTION WLANTL_STARxAuth
7848
7849 DESCRIPTION
7850 Receive in authenticated state - all data allowed
7851
7852 DEPENDENCIES
7853 The STA must be registered with TL before this function can be called.
7854
7855 PARAMETERS
7856
7857 IN
7858 pvosGCtx: pointer to the global vos context; a handle to TL's
7859 control block can be extracted from its context
7860 ucSTAId: identifier of the station being processed
7861 vosDataBuff: pointer to the rx vos buffer
7862
7863 RETURN VALUE
7864 The result code associated with performing the operation
7865
7866 VOS_STATUS_E_INVAL: invalid input parameters
7867 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
7868 page fault
7869 VOS_STATUS_SUCCESS: Everything is good :)
7870
7871 SIDE EFFECTS
7872
7873============================================================================*/
7874VOS_STATUS
7875WLANTL_STARxAuth
7876(
7877 v_PVOID_t pvosGCtx,
7878 v_U8_t ucSTAId,
7879 vos_pkt_t** pvosDataBuff
7880)
7881{
7882 WLANTL_CbType* pTLCb = NULL;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307883 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07007884 v_U8_t ucAsf; /* AMSDU sub frame */
7885 v_U16_t usMPDUDOffset;
7886 v_U8_t ucMPDUHOffset;
7887 v_U16_t usMPDULen;
7888 v_U8_t ucMPDUHLen;
7889 v_U16_t usActualHLen = 0;
7890 v_U8_t ucTid;
7891#ifdef FEATURE_WLAN_WAPI
Jeff Johnsone0343db2013-04-03 16:39:24 -07007892 v_U16_t usEtherType = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07007893#endif
7894 v_U16_t usPktLen;
7895 vos_pkt_t* vosDataBuff ;
7896 v_PVOID_t aucBDHeader;
7897 VOS_STATUS vosStatus;
7898 WLANTL_RxMetaInfoType wRxMetaInfo;
Madan Mohan Koyyalamudidfd6aa82012-10-18 20:18:43 -07007899 static v_U8_t ucPMPDUHLen;
Gopichand Nakkala976e3252013-01-03 15:45:56 -08007900 v_U32_t* STAMetaInfoPtr;
Jeff Johnson295189b2012-06-20 16:38:30 -07007901 v_U8_t ucEsf=0; /* first subframe of AMSDU flag */
7902 v_U64_t ullcurrentReplayCounter=0; /*current replay counter*/
7903 v_U64_t ullpreviousReplayCounter=0; /*previous replay counter*/
7904 v_U16_t ucUnicastBroadcastType=0; /*It denotes whether received frame is UC or BC*/
Madan Mohan Koyyalamudi4fe30172012-10-18 20:13:40 -07007905 struct _BARFrmStruct *pBarFrame = NULL;
7906
Jeff Johnson295189b2012-06-20 16:38:30 -07007907 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
7908
7909 /*------------------------------------------------------------------------
7910 Sanity check
7911 ------------------------------------------------------------------------*/
7912 if (( NULL == pvosDataBuff ) || ( NULL == ( vosDataBuff = *pvosDataBuff )))
7913 {
7914 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7915 "WLAN TL:Invalid parameter sent on WLANTL_STARxAuth"));
7916 return VOS_STATUS_E_INVAL;
7917 }
7918
7919 /*------------------------------------------------------------------------
7920 Extract TL control block
7921 ------------------------------------------------------------------------*/
7922 pTLCb = VOS_GET_TL_CB(pvosGCtx);
7923 if ( NULL == pTLCb )
7924 {
7925 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7926 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_STARxAuth"));
7927 return VOS_STATUS_E_FAULT;
7928 }
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307929 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
7930
7931 if ( NULL == pClientSTA )
7932 {
7933 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7934 "WLAN TL:Client Memory was not allocated on %s", __func__));
7935 return VOS_STATUS_E_FAILURE;
7936 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007937
7938 /*------------------------------------------------------------------------
7939 Extract BD header and check if valid
7940 ------------------------------------------------------------------------*/
7941 WDA_DS_PeekRxPacketInfo( vosDataBuff, (v_PVOID_t)&aucBDHeader, 0 );
7942
7943 ucMPDUHOffset = (v_U8_t)WDA_GET_RX_MPDU_HEADER_OFFSET(aucBDHeader);
7944 usMPDUDOffset = (v_U16_t)WDA_GET_RX_MPDU_DATA_OFFSET(aucBDHeader);
7945 usMPDULen = (v_U16_t)WDA_GET_RX_MPDU_LEN(aucBDHeader);
7946 ucMPDUHLen = (v_U8_t)WDA_GET_RX_MPDU_HEADER_LEN(aucBDHeader);
7947 ucTid = (v_U8_t)WDA_GET_RX_TID(aucBDHeader);
7948
Madan Mohan Koyyalamudi4fe30172012-10-18 20:13:40 -07007949 /* Fix for a hardware bug.
7950 * H/W does not update the tid field in BD header for BAR frames.
7951 * Fix is to read the tid field from MAC header of BAR frame */
7952 if( (WDA_GET_RX_TYPE(aucBDHeader) == SIR_MAC_CTRL_FRAME) &&
7953 (WDA_GET_RX_SUBTYPE(aucBDHeader) == SIR_MAC_CTRL_BAR))
7954 {
7955 pBarFrame = (struct _BARFrmStruct *)(WDA_GET_RX_MAC_HEADER(aucBDHeader));
7956 ucTid = pBarFrame->barControl.numTID;
7957 }
7958
Jeff Johnson295189b2012-06-20 16:38:30 -07007959 /*Host based replay check is needed for unicast data frames*/
7960 ucUnicastBroadcastType = (v_U16_t)WDA_IS_RX_BCAST(aucBDHeader);
Jeff Johnson295189b2012-06-20 16:38:30 -07007961 if(0 != ucMPDUHLen)
7962 {
7963 ucPMPDUHLen = ucMPDUHLen;
7964 }
7965
7966 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
7967 "WLAN TL:BD header processing data: HO %d DO %d Len %d HLen %d"
7968 " Tid %d BD %d",
7969 ucMPDUHOffset, usMPDUDOffset, usMPDULen, ucMPDUHLen, ucTid,
7970 WLANHAL_RX_BD_HEADER_SIZE));
7971
7972 vos_pkt_get_packet_length( vosDataBuff, &usPktLen);
7973
7974 if ( VOS_STATUS_SUCCESS != WDA_DS_TrimRxPacketInfo( vosDataBuff ) )
7975 {
7976 if((WDA_GET_RX_ASF(aucBDHeader) && !WDA_GET_RX_ESF(aucBDHeader)))
7977 {
7978 /* AMSDU case, ucMPDUHOffset = 0
7979 * it should be hancdled seperatly */
7980 if(( usMPDUDOffset > ucMPDUHOffset ) &&
7981 ( usMPDULen >= ucMPDUHLen ) && ( usPktLen >= usMPDULen ) &&
7982 ( !WLANTL_TID_INVALID(ucTid) ))
7983 {
7984 ucMPDUHOffset = usMPDUDOffset - WLANTL_MPDU_HEADER_LEN;
7985 }
7986 else
7987 {
7988 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
7989 "WLAN TL:BD header corrupted - dropping packet"));
7990 /* Drop packet */
7991 vos_pkt_return_packet(vosDataBuff);
7992 return VOS_STATUS_SUCCESS;
7993 }
7994 }
7995 else
7996 {
7997 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
7998 "WLAN TL:BD header corrupted - dropping packet"));
7999 /* Drop packet */
8000 vos_pkt_return_packet(vosDataBuff);
8001 return VOS_STATUS_SUCCESS;
8002 }
8003 }
8004
8005#ifdef FEATURE_WLAN_WAPI
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308006 if ( pClientSTA->wSTADesc.ucIsWapiSta )
Jeff Johnson295189b2012-06-20 16:38:30 -07008007 {
8008 vosStatus = WLANTL_GetEtherType(aucBDHeader, vosDataBuff, ucMPDUHLen, &usEtherType);
8009 if( VOS_IS_STATUS_SUCCESS(vosStatus) )
8010 {
8011 if ( WLANTL_LLC_WAI_TYPE == usEtherType )
8012 {
8013 if ( !( WLANHAL_RX_IS_UNPROTECTED_WPI_FRAME(aucBDHeader)) )
8014 {
8015 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8016 "WLAN TL:WAI frame was received encrypted - dropping"));
8017 /* Drop packet */
8018 /*Temporary fix added to fix wapi rekey issue*/
8019 //vos_pkt_return_packet(vosDataBuff);
8020 //return vosStatus; //returning success
8021 }
8022 }
8023 else
8024 {
8025 if ( WLANHAL_RX_IS_UNPROTECTED_WPI_FRAME(aucBDHeader) )
8026 {
8027 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8028 "WLAN TL:Non-WAI frame was received unencrypted - dropping"));
8029 /* Drop packet */
8030 vos_pkt_return_packet(vosDataBuff);
8031 return vosStatus; //returning success
8032 }
8033 }
8034 }
8035 else //could not extract EtherType - this should not happen
8036 {
8037 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008038 "WLAN TL:Could not extract EtherType"));
8039 //Packet is already freed
Jeff Johnson295189b2012-06-20 16:38:30 -07008040 return vosStatus; //returning failure
Jeff Johnson295189b2012-06-20 16:38:30 -07008041 }
8042 }
8043#endif /* FEATURE_WLAN_WAPI */
8044
8045 /*----------------------------------------------------------------------
8046 Increment receive counter
8047 !! not sure this is the best place to increase this - pkt might be
8048 dropped below or delayed in TL's queues
8049 - will leave it here for now
8050 ------------------------------------------------------------------------*/
Madan Mohan Koyyalamudic0e5bd82012-09-18 17:12:27 -07008051 if ( !WLANTL_TID_INVALID( ucTid) )
8052 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308053 pClientSTA->auRxCount[ucTid]++;
Madan Mohan Koyyalamudic0e5bd82012-09-18 17:12:27 -07008054 }
8055 else
8056 {
8057 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8058 "WLAN TL:Invalid tid %d (Station ID %d) on %s",
8059 ucTid, ucSTAId, __func__));
8060 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008061
8062 /*------------------------------------------------------------------------
8063 Check if AMSDU and send for processing if so
8064 ------------------------------------------------------------------------*/
8065 ucAsf = (v_U8_t)WDA_GET_RX_ASF(aucBDHeader);
8066
8067 if ( 0 != ucAsf )
8068 {
8069 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
8070 "WLAN TL:Packet is AMSDU sub frame - sending for completion"));
8071 vosStatus = WLANTL_AMSDUProcess( pvosGCtx, &vosDataBuff, aucBDHeader, ucSTAId,
8072 ucMPDUHLen, usMPDULen );
8073 if(NULL == vosDataBuff)
8074 {
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008075 //Packet is already freed
Jeff Johnson295189b2012-06-20 16:38:30 -07008076 return VOS_STATUS_SUCCESS;
8077 }
8078 }
8079 /* After AMSDU header handled
8080 * AMSDU frame just same with normal frames */
8081 /*-------------------------------------------------------------------
8082 Translating header if necesary
8083 !! Fix me: rmv comments below
8084 ----------------------------------------------------------------------*/
8085 if (( 0 == WDA_GET_RX_FT_DONE(aucBDHeader) ) &&
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308086 ( 0 != pClientSTA->wSTADesc.ucSwFrameRXXlation) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07008087 ( WLANTL_IS_DATA_FRAME(WDA_GET_RX_TYPE_SUBTYPE(aucBDHeader)) ))
8088 {
8089 if(0 == ucMPDUHLen)
8090 {
8091 ucMPDUHLen = ucPMPDUHLen;
8092 }
8093 if (usMPDUDOffset > ucMPDUHOffset)
8094 {
8095 usActualHLen = usMPDUDOffset - ucMPDUHOffset;
8096 }
8097 vosStatus = WLANTL_Translate80211To8023Header( vosDataBuff, &vosStatus, usActualHLen,
8098 ucMPDUHLen, pTLCb, ucSTAId);
8099
8100 if ( VOS_STATUS_SUCCESS != vosStatus )
8101 {
8102 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8103 "WLAN TL:Failed to translate from 802.11 to 802.3 - dropping"));
8104 /* Drop packet */
8105 vos_pkt_return_packet(vosDataBuff);
8106 return vosStatus;
8107 }
8108 }
8109 /* Softap requires additional Info such as Destination STAID and Access
8110 Category. Voschain or Buffer returned by BA would be unchain and this
8111 Meta Data would help in routing the packets to appropriate Destination */
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308112 if( WLAN_STA_SOFTAP == pClientSTA->wSTADesc.wSTAType)
Jeff Johnson295189b2012-06-20 16:38:30 -07008113 {
Gopichand Nakkala976e3252013-01-03 15:45:56 -08008114 STAMetaInfoPtr = (v_U32_t *)(ucTid | (WDA_GET_RX_ADDR3_IDX(aucBDHeader) << WLANTL_STAID_OFFSET));
Jeff Johnson295189b2012-06-20 16:38:30 -07008115 vos_pkt_set_user_data_ptr( vosDataBuff, VOS_PKT_USER_DATA_ID_TL,
8116 (v_PVOID_t)STAMetaInfoPtr);
8117 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008118
8119 /*------------------------------------------------------------------------
8120 Check to see if re-ordering session is in place
8121 ------------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308122 if ( 0 != pClientSTA->atlBAReorderInfo[ucTid].ucExists )
Jeff Johnson295189b2012-06-20 16:38:30 -07008123 {
8124 WLANTL_MSDUReorder( pTLCb, &vosDataBuff, aucBDHeader, ucSTAId, ucTid );
8125 }
8126
Jeff Johnson295189b2012-06-20 16:38:30 -07008127if(0 == ucUnicastBroadcastType
8128#ifdef FEATURE_ON_CHIP_REORDERING
8129 && (WLANHAL_IsOnChipReorderingEnabledForTID(pvosGCtx, ucSTAId, ucTid) != TRUE)
8130#endif
8131)
8132{
8133 /* replay check code : check whether replay check is needed or not */
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308134 if(VOS_TRUE == pClientSTA->ucIsReplayCheckValid)
Jeff Johnson295189b2012-06-20 16:38:30 -07008135 {
8136 /* replay check is needed for the station */
8137
8138 /* check whether frame is AMSDU frame */
8139 if ( 0 != ucAsf )
8140 {
8141 /* Since virgo can't send AMSDU frames this leg of the code
8142 was not tested properly, it needs to be tested properly*/
8143 /* Frame is AMSDU frame. As per 802.11n only first
8144 subframe will have replay counter */
8145 ucEsf = WDA_GET_RX_ESF( aucBDHeader );
8146 if( 0 != ucEsf )
8147 {
8148 v_BOOL_t status;
8149 /* Getting 48-bit replay counter from the RX BD */
8150 ullcurrentReplayCounter = WDA_DS_GetReplayCounter(aucBDHeader);
8151
8152 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
8153 "WLAN TL: AMSDU currentReplayCounter [0x%llX]\n",ullcurrentReplayCounter);
8154
8155 /* Getting 48-bit previous replay counter from TL control block */
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308156 ullpreviousReplayCounter = pClientSTA->ullReplayCounter[ucTid];
Jeff Johnson295189b2012-06-20 16:38:30 -07008157
8158 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
8159 "WLAN TL: AMSDU previousReplayCounter [0x%llX]\n",ullpreviousReplayCounter);
8160
8161 /* It is first subframe of AMSDU thus it
8162 conatains replay counter perform the
8163 replay check for this first subframe*/
8164 status = WLANTL_IsReplayPacket( ullcurrentReplayCounter, ullpreviousReplayCounter);
8165 if(VOS_FALSE == status)
8166 {
8167 /* Not a replay paket, update previous replay counter in TL CB */
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308168 pClientSTA->ullReplayCounter[ucTid] = ullcurrentReplayCounter;
Jeff Johnson295189b2012-06-20 16:38:30 -07008169 }
8170 else
8171 {
8172 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8173 "WLAN TL: AMSDU Drop the replay packet with PN : [0x%llX]\n",ullcurrentReplayCounter);
8174
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308175 pClientSTA->ulTotalReplayPacketsDetected++;
Jeff Johnson295189b2012-06-20 16:38:30 -07008176 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8177 "WLAN TL: AMSDU total dropped replay packets on STA ID %X is [0x%lX]\n",
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308178 ucSTAId, pClientSTA->ulTotalReplayPacketsDetected);
Jeff Johnson295189b2012-06-20 16:38:30 -07008179
8180 /* Drop the packet */
8181 vos_pkt_return_packet(vosDataBuff);
8182 return VOS_STATUS_SUCCESS;
8183 }
8184 }
8185 }
8186 else
8187 {
8188 v_BOOL_t status;
8189
8190 /* Getting 48-bit replay counter from the RX BD */
8191 ullcurrentReplayCounter = WDA_DS_GetReplayCounter(aucBDHeader);
8192
8193 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
8194 "WLAN TL: Non-AMSDU currentReplayCounter [0x%llX]\n",ullcurrentReplayCounter);
8195
8196 /* Getting 48-bit previous replay counter from TL control block */
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308197 ullpreviousReplayCounter = pClientSTA->ullReplayCounter[ucTid];
Jeff Johnson295189b2012-06-20 16:38:30 -07008198
8199 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
8200 "WLAN TL: Non-AMSDU previousReplayCounter [0x%llX]\n",ullpreviousReplayCounter);
8201
8202 /* It is not AMSDU frame so perform
8203 reaply check for each packet, as
8204 each packet contains valid replay counter*/
8205 status = WLANTL_IsReplayPacket( ullcurrentReplayCounter, ullpreviousReplayCounter);
8206 if(VOS_FALSE == status)
8207 {
8208 /* Not a replay paket, update previous replay counter in TL CB */
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308209 pClientSTA->ullReplayCounter[ucTid] = ullcurrentReplayCounter;
Jeff Johnson295189b2012-06-20 16:38:30 -07008210 }
8211 else
8212 {
8213 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8214 "WLAN TL: Non-AMSDU Drop the replay packet with PN : [0x%llX]\n",ullcurrentReplayCounter);
8215
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308216 pClientSTA->ulTotalReplayPacketsDetected++;
Jeff Johnson295189b2012-06-20 16:38:30 -07008217 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8218 "WLAN TL: Non-AMSDU total dropped replay packets on STA ID %X is [0x%lX]\n",
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308219 ucSTAId, pClientSTA->ulTotalReplayPacketsDetected);
Jeff Johnson295189b2012-06-20 16:38:30 -07008220
8221 /* Repaly packet, drop the packet */
8222 vos_pkt_return_packet(vosDataBuff);
8223 return VOS_STATUS_SUCCESS;
8224 }
8225 }
8226 }
8227}
8228/*It is a broadast packet DPU has already done replay check for
8229 broadcast packets no need to do replay check of these packets*/
Jeff Johnson295189b2012-06-20 16:38:30 -07008230
8231 if ( NULL != vosDataBuff )
8232 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308233 if( WLAN_STA_SOFTAP == pClientSTA->wSTADesc.wSTAType)
Jeff Johnson295189b2012-06-20 16:38:30 -07008234 {
8235 WLANTL_FwdPktToHDD( pvosGCtx, vosDataBuff, ucSTAId );
8236 }
8237 else
Jeff Johnson295189b2012-06-20 16:38:30 -07008238 {
8239 wRxMetaInfo.ucUP = ucTid;
Shailender Karmuchi13c0d082013-03-26 14:41:39 -07008240 wRxMetaInfo.rssiAvg = pClientSTA->rssiAvg;
Gopichand Nakkala4a2fc1a2013-05-17 16:59:39 +05308241#ifdef FEATURE_WLAN_TDLS
8242 if (WLAN_STA_TDLS == pClientSTA->wSTADesc.wSTAType)
8243 {
8244 wRxMetaInfo.isStaTdls = TRUE;
8245 }
8246 else
8247 {
8248 wRxMetaInfo.isStaTdls = FALSE;
8249 }
8250#endif
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308251 pClientSTA->pfnSTARx( pvosGCtx, vosDataBuff, ucSTAId,
Jeff Johnson295189b2012-06-20 16:38:30 -07008252 &wRxMetaInfo );
8253 }
8254 }/* if not NULL */
8255
8256 return VOS_STATUS_SUCCESS;
8257}/* WLANTL_STARxAuth */
8258
8259
8260/*==========================================================================
8261 FUNCTION WLANTL_STARxDisc
8262
8263 DESCRIPTION
8264 Receive in disconnected state - no data allowed
8265
8266 DEPENDENCIES
8267 The STA must be registered with TL before this function can be called.
8268
8269 PARAMETERS
8270
8271 IN
8272 pvosGCtx: pointer to the global vos context; a handle to TL's
8273 control block can be extracted from its context
8274 ucSTAId: identifier of the station being processed
8275 vosDataBuff: pointer to the rx vos buffer
8276
8277 RETURN VALUE
8278 The result code associated with performing the operation
8279
8280 VOS_STATUS_SUCCESS: Everything is good :)
8281
8282 SIDE EFFECTS
8283
8284============================================================================*/
8285VOS_STATUS
8286WLANTL_STARxDisc
8287(
8288 v_PVOID_t pvosGCtx,
8289 v_U8_t ucSTAId,
8290 vos_pkt_t** pvosDataBuff
8291)
8292{
8293 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
8294
8295 /*------------------------------------------------------------------------
8296 Sanity check
8297 ------------------------------------------------------------------------*/
8298 if (( NULL == pvosDataBuff ) || ( NULL == *pvosDataBuff ))
8299 {
8300 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8301 "WLAN TL:Invalid parameter sent on WLANTL_STARxDisc"));
8302 return VOS_STATUS_E_INVAL;
8303 }
8304
8305 /*------------------------------------------------------------------------
8306 Error - drop packet
8307 ------------------------------------------------------------------------*/
8308 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8309 "WLAN TL:Packet should not be received in state disconnected"
8310 " - dropping"));
8311 vos_pkt_return_packet(*pvosDataBuff);
8312 *pvosDataBuff = NULL;
8313
8314 return VOS_STATUS_SUCCESS;
8315}/* WLANTL_STARxDisc */
8316
8317/*==========================================================================
8318 Processing main loops for MAIN and TX threads
8319 ==========================================================================*/
8320
8321/*==========================================================================
8322 FUNCTION WLANTL_McProcessMsg
8323
8324 DESCRIPTION
8325 Called by VOSS when a message was serialized for TL through the
8326 main thread/task.
8327
8328 DEPENDENCIES
8329 The TL must be initialized before this function can be called.
8330
8331 PARAMETERS
8332
8333 IN
8334 pvosGCtx: pointer to the global vos context; a handle to TL's
8335 control block can be extracted from its context
8336 message: type and content of the message
8337
8338
8339 RETURN VALUE
8340 The result code associated with performing the operation
8341
8342 VOS_STATUS_E_INVAL: invalid input parameters
8343 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
8344 page fault
8345 VOS_STATUS_SUCCESS: Everything is good :)
8346
8347 SIDE EFFECTS
8348
8349============================================================================*/
8350VOS_STATUS
8351WLANTL_McProcessMsg
8352(
8353 v_PVOID_t pvosGCtx,
8354 vos_msg_t* message
8355)
8356{
8357 WLANTL_CbType* pTLCb = NULL;
8358 tAddBAInd* ptAddBaInd = NULL;
8359 tDelBAInd* ptDelBaInd = NULL;
8360 tAddBARsp* ptAddBaRsp = NULL;
8361 vos_msg_t vosMessage;
8362 VOS_STATUS vosStatus;
8363 tpFlushACRsp FlushACRspPtr;
8364 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
8365
8366 /*------------------------------------------------------------------------
8367 Sanity check
8368 ------------------------------------------------------------------------*/
8369 if ( NULL == message )
8370 {
8371 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8372 "WLAN TL:Invalid parameter sent on WLANTL_ProcessMainMessage"));
8373 return VOS_STATUS_E_INVAL;
8374 }
8375
8376 /*------------------------------------------------------------------------
8377 Extract TL control block
8378 ------------------------------------------------------------------------*/
8379 pTLCb = VOS_GET_TL_CB(pvosGCtx);
8380 if ( NULL == pTLCb )
8381 {
8382 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8383 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_ProcessMainMessage"));
8384 return VOS_STATUS_E_FAULT;
8385 }
8386
8387 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
8388 "WLAN TL:Received message: %d through main flow", message->type));
8389
8390 switch( message->type )
8391 {
8392 case WDA_TL_FLUSH_AC_RSP:
8393 // Extract the message from the message body
8394 FlushACRspPtr = (tpFlushACRsp)(message->bodyptr);
8395 // Make sure the call back function is not null.
Tushnim Bhattacharyya5dd94562013-03-20 20:15:03 -07008396 if ( NULL == pTLCb->tlBAPClient.pfnFlushOpCompleteCb )
8397 {
8398 VOS_ASSERT(0);
8399 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8400 "WLAN TL:Invalid TL pointer pfnFlushOpCompleteCb"));
8401 return VOS_STATUS_E_FAULT;
8402 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008403
8404 TLLOG2(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
8405 "Received message: Flush complete received by TL"));
8406
8407 // Since we have the response back from HAL, just call the BAP client
8408 // registered call back from TL. There is only 1 possible
8409 // BAP client. So directly reference tlBAPClient
8410 pTLCb->tlBAPClient.pfnFlushOpCompleteCb( pvosGCtx,
8411 FlushACRspPtr->ucSTAId,
8412 FlushACRspPtr->ucTid, FlushACRspPtr->status );
8413
8414 // Free the PAL memory, we are done with it.
8415 TLLOG2(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
8416 "Flush complete received by TL: Freeing %p", FlushACRspPtr));
8417 vos_mem_free((v_VOID_t *)FlushACRspPtr);
8418 break;
8419
8420 case WDA_HDD_ADDBA_REQ:
8421 ptAddBaInd = (tAddBAInd*)(message->bodyptr);
8422 vosStatus = WLANTL_BaSessionAdd( pvosGCtx,
8423 ptAddBaInd->baSession.baSessionID,
8424 ptAddBaInd->baSession.STAID,
8425 ptAddBaInd->baSession.baTID,
8426 (v_U32_t)ptAddBaInd->baSession.baBufferSize,
8427 ptAddBaInd->baSession.winSize,
8428 ptAddBaInd->baSession.SSN);
8429 ptAddBaRsp = vos_mem_malloc(sizeof(*ptAddBaRsp));
8430
8431 if ( NULL == ptAddBaRsp )
8432 {
8433 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8434 "WLAN TL: fatal failure, cannot allocate BA Rsp structure"));
8435 VOS_ASSERT(0);
8436 return VOS_STATUS_E_NOMEM;
8437 }
8438
8439 if ( VOS_STATUS_SUCCESS == vosStatus )
8440 {
8441 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
8442 "WLAN TL: Sending success indication to HAL for ADD BA"));
8443 /*Send success*/
8444 ptAddBaRsp->mesgType = WDA_HDD_ADDBA_RSP;
8445 vosMessage.type = WDA_HDD_ADDBA_RSP;
8446 }
8447 else
8448 {
8449 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
8450 "WLAN TL: Sending failure indication to HAL for ADD BA"));
8451
8452 /*Send failure*/
8453 ptAddBaRsp->mesgType = WDA_BA_FAIL_IND;
8454 vosMessage.type = WDA_BA_FAIL_IND;
8455 }
8456
8457 ptAddBaRsp->mesgLen = sizeof(tAddBARsp);
8458 ptAddBaRsp->baSessionID = ptAddBaInd->baSession.baSessionID;
8459 /* This is default, reply win size has to be handled BA module, FIX THIS */
8460 ptAddBaRsp->replyWinSize = WLANTL_MAX_WINSIZE;
8461 vosMessage.bodyptr = ptAddBaRsp;
8462
8463 vos_mq_post_message( VOS_MQ_ID_WDA, &vosMessage );
8464 WLANTL_McFreeMsg (pvosGCtx, message);
8465 break;
8466 case WDA_DELETEBA_IND:
8467 ptDelBaInd = (tDelBAInd*)(message->bodyptr);
8468 vosStatus = WLANTL_BaSessionDel(pvosGCtx,
8469 ptDelBaInd->staIdx,
8470 ptDelBaInd->baTID);
8471
8472 if ( VOS_STATUS_SUCCESS != vosStatus )
8473 {
8474 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8475 "WLAN TL: Failed to del BA session STA:%d TID:%d Status :%d",
8476 ptDelBaInd->staIdx,
8477 ptDelBaInd->baTID,
8478 vosStatus));
8479 }
8480 WLANTL_McFreeMsg (pvosGCtx, message);
8481 break;
8482 default:
8483 /*no processing for now*/
8484 break;
8485 }
8486
8487 return VOS_STATUS_SUCCESS;
8488}/* WLANTL_ProcessMainMessage */
8489
8490/*==========================================================================
8491 FUNCTION WLANTL_McFreeMsg
8492
8493 DESCRIPTION
8494 Called by VOSS to free a given TL message on the Main thread when there
8495 are messages pending in the queue when the whole system is been reset.
8496 For now, TL does not allocate any body so this function shout translate
8497 into a NOOP
8498
8499 DEPENDENCIES
8500 The TL must be initialized before this function can be called.
8501
8502 PARAMETERS
8503
8504 IN
8505 pvosGCtx: pointer to the global vos context; a handle to TL's
8506 control block can be extracted from its context
8507 message: type and content of the message
8508
8509
8510 RETURN VALUE
8511 The result code associated with performing the operation
8512
8513 VOS_STATUS_SUCCESS: Everything is good :)
8514
8515 SIDE EFFECTS
8516
8517============================================================================*/
8518VOS_STATUS
8519WLANTL_McFreeMsg
8520(
8521 v_PVOID_t pvosGCtx,
8522 vos_msg_t* message
8523)
8524{
8525 WLANTL_CbType* pTLCb = NULL;
8526 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
8527
8528 /*------------------------------------------------------------------------
8529 Sanity check
8530 ------------------------------------------------------------------------*/
8531 if ( NULL == message )
8532 {
8533 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8534 "WLAN TL:Invalid parameter sent on WLANTL_McFreeMsg"));
8535 return VOS_STATUS_E_INVAL;
8536 }
8537
8538 /*------------------------------------------------------------------------
8539 Extract TL control block
8540 ------------------------------------------------------------------------*/
8541 pTLCb = VOS_GET_TL_CB(pvosGCtx);
8542 if ( NULL == pTLCb )
8543 {
8544 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8545 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_McFreeMsg"));
8546 return VOS_STATUS_E_FAULT;
8547 }
8548
8549 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
8550 "WLAN TL:Received message: %d through main free", message->type));
8551
8552 switch( message->type )
8553 {
8554 case WDA_HDD_ADDBA_REQ:
8555 case WDA_DELETEBA_IND:
8556 /*vos free body pointer*/
8557 vos_mem_free(message->bodyptr);
8558 message->bodyptr = NULL;
8559 break;
8560 default:
8561 /*no processing for now*/
8562 break;
8563 }
8564
8565 return VOS_STATUS_SUCCESS;
8566}/*WLANTL_McFreeMsg*/
8567
8568/*==========================================================================
8569 FUNCTION WLANTL_TxProcessMsg
8570
8571 DESCRIPTION
8572 Called by VOSS when a message was serialized for TL through the
8573 tx thread/task.
8574
8575 DEPENDENCIES
8576 The TL must be initialized before this function can be called.
8577
8578 PARAMETERS
8579
8580 IN
8581 pvosGCtx: pointer to the global vos context; a handle to TL's
8582 control block can be extracted from its context
8583 message: type and content of the message
8584
8585
8586 RETURN VALUE
8587 The result code associated with performing the operation
8588
8589 VOS_STATUS_E_INVAL: invalid input parameters
8590 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
8591 page fault
8592 VOS_STATUS_SUCCESS: Everything is good :)
8593
8594 Other values can be returned as a result of a function call, please check
8595 corresponding API for more info.
8596 SIDE EFFECTS
8597
8598============================================================================*/
8599VOS_STATUS
8600WLANTL_TxProcessMsg
8601(
8602 v_PVOID_t pvosGCtx,
8603 vos_msg_t* message
8604)
8605{
8606 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
8607 v_U32_t uData;
8608 v_U8_t ucSTAId;
8609 v_U8_t ucUcastSig;
8610 v_U8_t ucBcastSig;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308611 WLANTL_CbType* pTLCb = NULL;
8612 WLANTL_STAClientType* pClientSTA = NULL;
8613 WLANTL_ACEnumType ucAC;
Jeff Johnson295189b2012-06-20 16:38:30 -07008614 void (*callbackRoutine) (void *callbackContext);
8615 void *callbackContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07008616 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
8617
8618 /*------------------------------------------------------------------------
8619 Sanity check
8620 ------------------------------------------------------------------------*/
8621 if ( NULL == message )
8622 {
8623 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8624 "WLAN TL:Invalid parameter sent on WLANTL_ProcessTxMessage"));
8625 return VOS_STATUS_E_INVAL;
8626 }
8627
8628 /*------------------------------------------------------------------------
8629 Process message
8630 ------------------------------------------------------------------------*/
8631 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
8632 "WLAN TL:Received message: %d through tx flow", message->type));
8633
8634 switch( message->type )
8635 {
8636 case WLANTL_TX_SIG_SUSPEND:
8637 vosStatus = WLANTL_SuspendCB( pvosGCtx,
8638 (WLANTL_SuspendCBType)message->bodyptr,
8639 message->reserved);
8640 break;
8641 case WLANTL_TX_RES_NEEDED:
8642 vosStatus = WLANTL_GetTxResourcesCB( pvosGCtx );
8643 break;
8644
8645 case WLANTL_TX_FWD_CACHED:
8646 /*---------------------------------------------------------------------
8647 The data sent with the message has the following structure:
8648 | 00 | ucBcastSignature | ucUcastSignature | ucSTAID |
8649 each field above is one byte
8650 ---------------------------------------------------------------------*/
8651 uData = (v_U32_t)message->bodyptr;
8652 ucSTAId = ( uData & 0x000000FF);
8653 ucUcastSig = ( uData & 0x0000FF00)>>8;
8654 ucBcastSig = (v_U8_t)(( uData & 0x00FF0000)>>16);
8655 vosStatus = WLANTL_ForwardSTAFrames( pvosGCtx, ucSTAId,
8656 ucUcastSig, ucBcastSig);
8657 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008658 case WLANTL_TX_STAID_AC_IND:
8659 pTLCb = VOS_GET_TL_CB(pvosGCtx);
8660 if ( NULL == pTLCb )
8661 {
8662 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8663 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_STAPktPending"));
8664 return VOS_STATUS_E_FAULT;
8665 }
8666
8667 ucAC = message->bodyval & WLANTL_AC_MASK;
Gopichand Nakkala976e3252013-01-03 15:45:56 -08008668 ucSTAId = (v_U8_t)(message->bodyval >> WLANTL_STAID_OFFSET);
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308669 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
Jeff Johnson295189b2012-06-20 16:38:30 -07008670
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308671 if ( NULL == pClientSTA )
8672 {
8673 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8674 "WLAN TL:Client Memory was not allocated on %s", __func__));
8675 return VOS_STATUS_E_FAILURE;
8676 }
8677
8678 pClientSTA->aucACMask[ucAC] = 1;
8679
8680 vos_atomic_set_U8( &pClientSTA->ucPktPending, 1);
Jeff Johnson295189b2012-06-20 16:38:30 -07008681 vosStatus = WDA_DS_StartXmit(pvosGCtx);
8682 break;
Jeff Johnson017fdc32013-02-27 09:22:30 -08008683
Jeff Johnson295189b2012-06-20 16:38:30 -07008684 case WDA_DS_TX_START_XMIT:
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05308685 WLANTL_ClearTxXmitPending(pvosGCtx);
8686 vosStatus = WDA_DS_TxFrames( pvosGCtx );
Jeff Johnson295189b2012-06-20 16:38:30 -07008687 break;
8688
8689 case WDA_DS_FINISH_ULA:
Tushnim Bhattacharyya39a8f182013-02-20 18:10:30 -08008690 callbackContext = (void *)message->bodyval;
8691 callbackRoutine = message->bodyptr;
8692 callbackRoutine(callbackContext);
Jeff Johnson295189b2012-06-20 16:38:30 -07008693 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008694
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05308695 case WLANTL_TX_SNAPSHOT:
8696 /*Dumping TL State and then continuing to print
8697 the DXE Dump*/
8698 WLANTL_TxThreadDebugHandler(pvosGCtx);
8699 WDA_TransportChannelDebug(NULL, VOS_TRUE, VOS_FALSE);
8700 break;
8701
Jeff Johnson295189b2012-06-20 16:38:30 -07008702 default:
8703 /*no processing for now*/
8704 break;
8705 }
8706
8707 return vosStatus;
8708}/* WLANTL_TxProcessMsg */
8709
8710/*==========================================================================
8711 FUNCTION WLANTL_McFreeMsg
8712
8713 DESCRIPTION
8714 Called by VOSS to free a given TL message on the Main thread when there
8715 are messages pending in the queue when the whole system is been reset.
8716 For now, TL does not allocate any body so this function shout translate
8717 into a NOOP
8718
8719 DEPENDENCIES
8720 The TL must be initialized before this function can be called.
8721
8722 PARAMETERS
8723
8724 IN
8725 pvosGCtx: pointer to the global vos context; a handle to TL's
8726 control block can be extracted from its context
8727 message: type and content of the message
8728
8729
8730 RETURN VALUE
8731 The result code associated with performing the operation
8732
8733 VOS_STATUS_SUCCESS: Everything is good :)
8734
8735 SIDE EFFECTS
8736
8737============================================================================*/
8738VOS_STATUS
8739WLANTL_TxFreeMsg
8740(
8741 v_PVOID_t pvosGCtx,
8742 vos_msg_t* message
8743)
8744{
8745 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
8746
8747 /*Nothing to do for now!!!*/
8748 return VOS_STATUS_SUCCESS;
8749}/*WLANTL_TxFreeMsg*/
8750
Jeff Johnson295189b2012-06-20 16:38:30 -07008751/*==========================================================================
8752
8753 FUNCTION WLANTL_TxFCFrame
8754
8755 DESCRIPTION
8756 Internal utility function to send FC frame. Enable
8757 or disable LWM mode based on the information.
8758
8759 DEPENDENCIES
8760 TL must be initiailized before this function gets called.
8761 FW sends up special flow control frame.
8762
8763 PARAMETERS
8764
8765 IN
8766 pvosGCtx: pointer to the global vos context; a handle to TL's
8767 control block can be extracted from its context
8768
8769 RETURN VALUE
8770 The result code associated with performing the operation
8771
8772 VOS_STATUS_E_INVAL: Input pointers are NULL.
8773 VOS_STATUS_E_FAULT: Something is wrong.
8774 VOS_STATUS_SUCCESS: Everything is good.
8775
8776 SIDE EFFECTS
8777 Newly formed FC frame is generated and waits to be transmitted. Previously unsent frame will
8778 be released.
8779
8780============================================================================*/
8781VOS_STATUS
8782WLANTL_TxFCFrame
8783(
8784 v_PVOID_t pvosGCtx
8785)
8786{
8787#if 0
8788 WLANTL_CbType* pTLCb = NULL;
8789 VOS_STATUS vosStatus;
8790 tpHalFcTxBd pvFcTxBd = NULL;
8791 vos_pkt_t * pPacket = NULL;
8792 v_U8_t ucSTAId = 0;
8793 v_U8_t ucBitCheck = 1;
8794
8795 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008796 "WLAN TL: Send FC frame %s", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07008797
8798 /*------------------------------------------------------------------------
8799 Sanity check
8800 ------------------------------------------------------------------------*/
8801 if ( NULL == pvosGCtx )
8802 {
8803 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008804 "WLAN TL:Invalid parameter %s", __func__));
Jeff Johnson295189b2012-06-20 16:38:30 -07008805 return VOS_STATUS_E_INVAL;
8806 }
8807 /*------------------------------------------------------------------------
8808 Extract TL control block
8809 ------------------------------------------------------------------------*/
8810 pTLCb = VOS_GET_TL_CB(pvosGCtx);
8811
8812 if (NULL == pTLCb)
8813 {
8814 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008815 "WLAN TL:Invalid pointer in %s \n", __func__));
Jeff Johnson295189b2012-06-20 16:38:30 -07008816 return VOS_STATUS_E_INVAL;
8817 }
8818
8819 //Get one voss packet
8820 vosStatus = vos_pkt_get_packet( &pPacket, VOS_PKT_TYPE_TX_802_11_MGMT, sizeof(tHalFcTxBd), 1,
8821 VOS_FALSE, NULL, NULL );
8822
8823 if ( VOS_STATUS_SUCCESS != vosStatus )
8824 {
8825 return VOS_STATUS_E_INVAL;
8826 }
8827
8828 vosStatus = vos_pkt_reserve_head( pPacket, (void *)&pvFcTxBd, sizeof(tHalFcTxBd));
8829
8830 if( VOS_STATUS_SUCCESS != vosStatus )
8831 {
8832 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008833 "%s: failed to reserve FC TX BD %d\n",__func__, sizeof(tHalFcTxBd)));
Jeff Johnson295189b2012-06-20 16:38:30 -07008834 vos_pkt_return_packet( pPacket );
8835 return VOS_STATUS_E_FAULT;
8836 }
8837
8838 //Generate most recent tlFCInfo. Most fields are correct.
8839 pTLCb->tlFCInfo.fcSTAThreshEnabledMask = 0;
8840 pTLCb->tlFCInfo.fcSTATxMoreDataMask = 0;
8841 for( ucSTAId = 0, ucBitCheck = 1 ; ucSTAId < WLAN_MAX_STA_COUNT; ucBitCheck <<= 1, ucSTAId ++)
8842 {
8843 if (0 == pTLCb->atlSTAClients[ucSTAId].ucExists)
8844 {
8845 continue;
8846 }
8847
8848 if (pTLCb->atlSTAClients[ucSTAId].ucPktPending)
8849 {
8850 pTLCb->tlFCInfo.fcSTATxMoreDataMask |= ucBitCheck;
8851 }
8852
8853 if ( (pTLCb->atlSTAClients[ucSTAId].ucLwmModeEnabled) &&
8854 (pTLCb->atlSTAClients[ucSTAId].bmuMemConsumed > pTLCb->atlSTAClients[ucSTAId].uLwmThreshold))
8855 {
8856 pTLCb->tlFCInfo.fcSTAThreshEnabledMask |= ucBitCheck;
8857
8858 pTLCb->tlFCInfo.fcSTAThresh[ucSTAId] = (tANI_U8)pTLCb->atlSTAClients[ucSTAId].uLwmThreshold;
8859
8860 pTLCb->atlSTAClients[ucSTAId].ucLwmEventReported = FALSE;
8861 }
8862
8863 }
8864
8865 //request immediate feedback
8866 pTLCb->tlFCInfo.fcConfig |= 0x4;
8867
8868 //fill in BD to sent
8869 vosStatus = WLANHAL_FillFcTxBd(pvosGCtx, &pTLCb->tlFCInfo, (void *)pvFcTxBd);
8870
8871 if( VOS_STATUS_SUCCESS != vosStatus )
8872 {
8873 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008874 "%s: Fill FC TX BD unsuccessful\n", __func__));
Jeff Johnson295189b2012-06-20 16:38:30 -07008875 vos_pkt_return_packet( pPacket );
8876 return VOS_STATUS_E_FAULT;
8877 }
8878
8879 if (NULL != pTLCb->vosTxFCBuf)
8880 {
8881 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008882 "%s: Previous FC TX BD not sent\n", __func__));
Jeff Johnson295189b2012-06-20 16:38:30 -07008883 vos_pkt_return_packet(pTLCb->vosTxFCBuf);
8884 }
8885
8886 pTLCb->vosTxFCBuf = pPacket;
8887
8888 vos_pkt_set_user_data_ptr( pPacket, VOS_PKT_USER_DATA_ID_TL,
8889 (v_PVOID_t)WLANTL_TxCompDefaultCb);
8890 vosStatus = WDA_DS_StartXmit(pvosGCtx);
8891
8892 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008893 "WLAN TL: send FC frame leave %s", __func__));
Jeff Johnson295189b2012-06-20 16:38:30 -07008894#endif
8895 return VOS_STATUS_SUCCESS;
8896}
8897
Jeff Johnson295189b2012-06-20 16:38:30 -07008898
8899/*==========================================================================
8900 FUNCTION WLANTL_GetTxResourcesCB
8901
8902 DESCRIPTION
8903 Processing function for Resource needed signal. A request will be issued
8904 to BAL to get more tx resources.
8905
8906 DEPENDENCIES
8907 The TL must be initialized before this function can be called.
8908
8909 PARAMETERS
8910
8911 IN
8912 pvosGCtx: pointer to the global vos context; a handle to TL's
8913 control block can be extracted from its context
8914
8915
8916 RETURN VALUE
8917 The result code associated with performing the operation
8918
8919 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
8920 page fault
8921 VOS_STATUS_SUCCESS: Everything is good :)
8922
8923 Other values can be returned as a result of a function call, please check
8924 corresponding API for more info.
8925 SIDE EFFECTS
8926
8927============================================================================*/
8928VOS_STATUS
8929WLANTL_GetTxResourcesCB
8930(
8931 v_PVOID_t pvosGCtx
8932)
8933{
8934 WLANTL_CbType* pTLCb = NULL;
8935 v_U32_t uResCount = WDA_TLI_MIN_RES_DATA;
8936 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
8937 v_U8_t ucMgmt = 0;
8938 v_U8_t ucBAP = 0;
8939 v_U8_t ucData = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07008940#ifdef WLAN_SOFTAP_FLOWCTRL_EN
8941 tBssSystemRole systemRole;
8942 tpAniSirGlobal pMac;
8943#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07008944 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
8945 /*------------------------------------------------------------------------
8946 Extract TL control block
8947 ------------------------------------------------------------------------*/
8948 pTLCb = VOS_GET_TL_CB(pvosGCtx);
8949 if ( NULL == pTLCb )
8950 {
8951 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8952 "WLAN TL:Invalid TL pointer from pvosGCtx on"
8953 " WLANTL_ProcessTxMessage"));
8954 return VOS_STATUS_E_FAULT;
8955 }
8956
8957 /*------------------------------------------------------------------------
8958 Get tx resources from BAL
8959 ------------------------------------------------------------------------*/
8960 vosStatus = WDA_DS_GetTxResources( pvosGCtx, &uResCount );
8961
8962 if ( (VOS_STATUS_SUCCESS != vosStatus) && (VOS_STATUS_E_RESOURCES != vosStatus))
8963 {
8964 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8965 "WLAN TL:TL failed to get resources from BAL, Err: %d",
8966 vosStatus));
8967 return vosStatus;
8968 }
8969
8970 /* Currently only Linux BAL returns the E_RESOURCES error code when it is running
8971 out of BD/PDUs. To make use of this interrupt for throughput enhancement, similar
8972 changes should be done in BAL code of AMSS and WM */
8973 if (VOS_STATUS_E_RESOURCES == vosStatus)
8974 {
8975#ifdef VOLANS_PERF
8976 WLANHAL_EnableIdleBdPduInterrupt(pvosGCtx, (tANI_U8)bdPduInterruptGetThreshold);
8977 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
8978 "WLAN TL: Enabling Idle BD/PDU interrupt, Current resources = %d", uResCount);
8979#else
8980 return VOS_STATUS_E_FAILURE;
8981#endif
8982 }
8983
8984 pTLCb->uResCount = uResCount;
8985
8986
Jeff Johnson295189b2012-06-20 16:38:30 -07008987#ifdef WLAN_SOFTAP_FLOWCTRL_EN
8988 /* FIXME: disabled since creating issues in power-save, needs to be addressed */
8989 pTLCb->sendFCFrame ++;
8990 pMac = vos_get_context(VOS_MODULE_ID_WDA, pvosGCtx);
8991 systemRole = wdaGetGlobalSystemRole(pMac);
8992 if (eSYSTEM_AP_ROLE == systemRole)
8993 {
8994 if (pTLCb->sendFCFrame % 16 == 0)
8995 {
8996 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
8997 "Transmit FC"));
8998 WLANTL_TxFCFrame (pvosGCtx);
8999 }
9000 }
9001#endif //WLAN_SOFTAP_FLOWCTRL_EN
Jeff Johnson295189b2012-06-20 16:38:30 -07009002
9003 ucData = ( pTLCb->uResCount >= WDA_TLI_MIN_RES_DATA );
9004 ucBAP = ( pTLCb->uResCount >= WDA_TLI_MIN_RES_BAP ) &&
9005 ( NULL != pTLCb->tlBAPClient.vosPendingDataBuff );
9006 ucMgmt = ( pTLCb->uResCount >= WDA_TLI_MIN_RES_MF ) &&
9007 ( NULL != pTLCb->tlMgmtFrmClient.vosPendingDataBuff );
9008
9009 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
9010 "WLAN TL: Eval Resume tx Res: %d DATA: %d BAP: %d MGMT: %d",
9011 pTLCb->uResCount, ucData, ucBAP, ucMgmt));
9012
9013 if (( 0 == pTLCb->ucTxSuspended ) &&
9014 (( 0 != ucData ) || ( 0 != ucMgmt ) || ( 0 != ucBAP ) ) )
9015 {
9016 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
9017 "Issuing Xmit start request to BAL for avail res SYNC"));
9018 vosStatus =WDA_DS_StartXmit(pvosGCtx);
9019 }
9020 return vosStatus;
9021}/*WLANTL_GetTxResourcesCB*/
9022
9023/*==========================================================================
9024 Utility functions
9025 ==========================================================================*/
9026
9027/*==========================================================================
9028 FUNCTION WLANTL_Translate8023To80211Header
9029
9030 DESCRIPTION
9031 Inline function for translating and 802.11 header into an 802.3 header.
9032
9033 DEPENDENCIES
9034
9035
9036 PARAMETERS
9037
9038 IN
9039 pTLCb: TL control block
Kiran Venkatappaa044eb92012-12-17 15:48:49 -08009040 IN/OUT
9041 ucStaId: station ID. Incase of TDLS, this returns actual TDLS
9042 station ID used
Jeff Johnson295189b2012-06-20 16:38:30 -07009043
9044 IN/OUT
9045 vosDataBuff: vos data buffer, will contain the new header on output
9046
9047 OUT
9048 pvosStatus: status of the operation
9049
9050 RETURN VALUE
9051
9052 VOS_STATUS_SUCCESS: Everything is good :)
9053
9054 Other error codes might be returned from the vos api used in the function
9055 please check those return values.
9056
9057 SIDE EFFECTS
9058
9059============================================================================*/
Kiran Venkatappacab0d352012-12-17 13:09:22 -08009060VOS_STATUS
9061WLANTL_Translate8023To80211Header
9062(
9063 vos_pkt_t* vosDataBuff,
9064 VOS_STATUS* pvosStatus,
9065 WLANTL_CbType* pTLCb,
9066 v_U8_t *pucStaId,
Ravi Joshid0699502013-07-08 15:48:47 -07009067 WLANTL_MetaInfoType *tlMetaInfo,
Kiran Venkatappacab0d352012-12-17 13:09:22 -08009068 v_U8_t *ucWDSEnabled,
9069 v_U8_t *extraHeadSpace
9070)
Jeff Johnson295189b2012-06-20 16:38:30 -07009071{
9072 WLANTL_8023HeaderType w8023Header;
9073 WLANTL_80211HeaderType *pw80211Header; // Allocate an aligned BD and then fill it.
9074 VOS_STATUS vosStatus;
9075 v_U8_t MandatoryucHeaderSize = WLAN80211_MANDATORY_HEADER_SIZE;
9076 v_U8_t ucHeaderSize = 0;
9077 v_VOID_t *ppvBDHeader = NULL;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309078 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07009079 v_U8_t ucQoSOffset = WLAN80211_MANDATORY_HEADER_SIZE;
Kiran Venkatappacab0d352012-12-17 13:09:22 -08009080 v_U8_t ucStaId;
Jeff Johnson295189b2012-06-20 16:38:30 -07009081
9082 *ucWDSEnabled = 0; // default WDS off.
9083 vosStatus = vos_pkt_pop_head( vosDataBuff, &w8023Header,
9084 sizeof(w8023Header));
9085
9086 if ( VOS_STATUS_SUCCESS != vosStatus )
9087 {
9088 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9089 "WLAN TL: Packet pop header fails on WLANTL_Translate8023To80211Header"));
9090 return vosStatus;
9091 }
9092
Kiran Venkatappacab0d352012-12-17 13:09:22 -08009093 if( NULL == pucStaId )
9094 {
9095 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9096 "WLAN TL: Invalid pointer for StaId"));
9097 return VOS_STATUS_E_INVAL;
9098 }
9099 ucStaId = *pucStaId;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309100 pClientSTA = pTLCb->atlSTAClients[ucStaId];
9101
9102 if ( NULL == pClientSTA )
9103 {
9104 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9105 "WLAN TL:Client Memory was not allocated on %s", __func__));
9106 return VOS_STATUS_E_FAILURE;
9107 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -08009108
Kiran Venkatappaa044eb92012-12-17 15:48:49 -08009109#ifdef FEATURE_WLAN_TDLS
9110
Madan Mohan Koyylamudi64258222013-01-30 14:35:10 +05309111 if ( WLAN_STA_INFRA == pTLCb->atlSTAClients[ucStaId]->wSTADesc.wSTAType
9112 && pTLCb->ucTdlsPeerCount )
Kiran Venkatappacab0d352012-12-17 13:09:22 -08009113 {
9114 v_U8_t ucIndex = 0;
9115 for ( ucIndex = 0; ucIndex < WLAN_MAX_STA_COUNT ; ucIndex++)
9116 {
Madan Mohan Koyylamudi64258222013-01-30 14:35:10 +05309117 if ( ucIndex != ucStaId && pTLCb->atlSTAClients[ucIndex] && pTLCb->atlSTAClients[ucIndex]->ucExists &&
Gopichand Nakkala471708b2013-06-04 20:03:01 +05309118 (pTLCb->atlSTAClients[ucIndex]->tlState == WLANTL_STA_AUTHENTICATED) &&
9119 (!pTLCb->atlSTAClients[ucIndex]->ucTxSuspended) &&
Madan Mohan Koyylamudi64258222013-01-30 14:35:10 +05309120 vos_mem_compare( (void*)pTLCb->atlSTAClients[ucIndex]->wSTADesc.vSTAMACAddress.bytes,
Kiran Venkatappacab0d352012-12-17 13:09:22 -08009121 (void*)w8023Header.vDA, 6) )
9122 {
9123 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_LOW,
9124 "WLAN TL: Got a TDLS station. Using that index"));
9125 ucStaId = ucIndex;
9126 *pucStaId = ucStaId;
Madan Mohan Koyylamudi64258222013-01-30 14:35:10 +05309127 pClientSTA = pTLCb->atlSTAClients[ucStaId];
9128 if ( NULL == pClientSTA )
9129 {
9130 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9131 "WLAN TL:Client Memory was not allocated on %s", __func__));
9132 return VOS_STATUS_E_FAILURE;
9133 }
Kiran Venkatappacab0d352012-12-17 13:09:22 -08009134 break;
9135 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -08009136 }
Kiran Venkatappacab0d352012-12-17 13:09:22 -08009137 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -08009138#endif
9139
Jeff Johnson295189b2012-06-20 16:38:30 -07009140
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309141 if ( 0 != pClientSTA->wSTADesc.ucAddRmvLLC )
Jeff Johnson295189b2012-06-20 16:38:30 -07009142 {
9143 /* Push the length */
9144 vosStatus = vos_pkt_push_head(vosDataBuff,
9145 &w8023Header.usLenType, sizeof(w8023Header.usLenType));
9146
9147 if ( VOS_STATUS_SUCCESS != vosStatus )
9148 {
9149 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9150 "WLAN TL: Packet push ether type fails on"
9151 " WLANTL_Translate8023To80211Header"));
9152 return vosStatus;
9153 }
9154
9155#ifdef BTAMP_TEST
9156 // The STA side will execute this, a hack to test BTAMP by using the
9157 // infra setup. On real BTAMP this will come from BAP itself.
9158 {
9159 static v_U8_t WLANTL_BT_AMP_LLC_HEADER[] = {0xAA, 0xAA, 0x03, 0x00, 0x19, 0x58 };
9160 vosStatus = vos_pkt_push_head(vosDataBuff, WLANTL_BT_AMP_LLC_HEADER,
9161 sizeof(WLANTL_BT_AMP_LLC_HEADER));
9162
9163 if ( VOS_STATUS_SUCCESS != vosStatus )
9164 {
9165 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9166 "WLAN TL: Packet push LLC header fails on"
9167 " WLANTL_Translate8023To80211Header"));
9168 return vosStatus;
9169 }
9170 }
9171#else
9172 vosStatus = vos_pkt_push_head(vosDataBuff, WLANTL_LLC_HEADER,
9173 sizeof(WLANTL_LLC_HEADER));
9174
9175 if ( VOS_STATUS_SUCCESS != vosStatus )
9176 {
9177 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9178 "WLAN TL: Packet push LLC header fails on"
9179 " WLANTL_Translate8023To80211Header"));
9180 return vosStatus;
9181 }
9182#endif
9183 }/*If add LLC is enabled*/
9184 else
9185 {
9186 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
9187 "WLAN TL: STA Client registered to not remove LLC"
9188 " WLANTL_Translate8023To80211Header"));
9189 }
9190
9191#ifdef BTAMP_TEST
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309192 pClientSTA->wSTADesc.wSTAType = WLAN_STA_BT_AMP;
Jeff Johnson295189b2012-06-20 16:38:30 -07009193#endif
9194
9195 // Find the space required for the 802.11 header format
9196 // based on the frame control fields.
9197 ucHeaderSize = MandatoryucHeaderSize;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309198 if (pClientSTA->wSTADesc.ucQosEnabled)
Jeff Johnson295189b2012-06-20 16:38:30 -07009199 {
9200 ucHeaderSize += sizeof(pw80211Header->usQosCtrl);
9201 }
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309202 if (pClientSTA->wSTADesc.wSTAType == WLAN_STA_BT_AMP)
Jeff Johnson295189b2012-06-20 16:38:30 -07009203 {
9204 ucHeaderSize += sizeof(pw80211Header->optvA4);
Jeff Johnson295189b2012-06-20 16:38:30 -07009205 ucQoSOffset += sizeof(pw80211Header->optvA4);
Jeff Johnson295189b2012-06-20 16:38:30 -07009206 }
9207
9208 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
9209 " WLANTL_Translate8023To80211Header : Header size = %d ", ucHeaderSize));
9210
9211 vos_pkt_reserve_head( vosDataBuff, &ppvBDHeader, ucHeaderSize );
9212 if ( NULL == ppvBDHeader )
9213 {
9214 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9215 "WLAN TL:VOSS packet corrupted "));
9216 *pvosStatus = VOS_STATUS_E_INVAL;
9217 return *pvosStatus;
9218 }
9219
Jeff Johnson295189b2012-06-20 16:38:30 -07009220
9221 // OK now we have the space. Fill the 80211 header
9222 /* Fill A2 */
9223 pw80211Header = (WLANTL_80211HeaderType *)(ppvBDHeader);
9224 // only clear the required space.
9225 vos_mem_set( pw80211Header, ucHeaderSize, 0 );
9226 vos_mem_copy( pw80211Header->vA2, w8023Header.vSA, VOS_MAC_ADDR_SIZE);
9227
9228
9229#ifdef FEATURE_WLAN_WAPI
Gopichand Nakkala8b54e912013-03-11 10:44:21 +05309230 if (( WLANTL_STA_AUTHENTICATED == pClientSTA->tlState ||
9231 pClientSTA->ptkInstalled ) && gUcIsWai != 1)
Jeff Johnson295189b2012-06-20 16:38:30 -07009232#else
Gopichand Nakkala8b54e912013-03-11 10:44:21 +05309233 if ( WLANTL_STA_AUTHENTICATED == pClientSTA->tlState ||
9234 pClientSTA->ptkInstalled )
Jeff Johnson295189b2012-06-20 16:38:30 -07009235#endif
9236 {
9237 pw80211Header->wFrmCtrl.wep =
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309238 pClientSTA->wSTADesc.ucProtectedFrame;
Jeff Johnson295189b2012-06-20 16:38:30 -07009239 }
9240
9241 pw80211Header->usDurationId = 0;
9242 pw80211Header->usSeqCtrl = 0;
9243
9244 pw80211Header->wFrmCtrl.type = WLANTL_80211_DATA_TYPE;
9245
9246
9247
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309248 if(pClientSTA->wSTADesc.ucQosEnabled)
Jeff Johnson295189b2012-06-20 16:38:30 -07009249 {
9250 pw80211Header->wFrmCtrl.subType = WLANTL_80211_DATA_QOS_SUBTYPE;
9251
Ravi Joshid0699502013-07-08 15:48:47 -07009252 *((v_U16_t *)((v_U8_t *)ppvBDHeader + ucQoSOffset)) = tlMetaInfo->ucUP;
Jeff Johnson295189b2012-06-20 16:38:30 -07009253
9254 }
9255 else
9256 {
9257 pw80211Header->wFrmCtrl.subType = 0;
9258
9259 // NO NO NO - there is not enough memory allocated to write the QOS ctrl
9260 // field, it will overwrite the first 2 bytes of the data packet(LLC header)
9261 // pw80211Header->usQosCtrl = 0;
9262 }
9263
9264
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309265 switch( pClientSTA->wSTADesc.wSTAType )
Jeff Johnson295189b2012-06-20 16:38:30 -07009266 {
Ravi Joshid0699502013-07-08 15:48:47 -07009267 case WLAN_STA_IBSS:
Jeff Johnson295189b2012-06-20 16:38:30 -07009268 pw80211Header->wFrmCtrl.toDS = 0;
9269 pw80211Header->wFrmCtrl.fromDS = 0;
Ravi Joshid0699502013-07-08 15:48:47 -07009270
9271 /*
9272 * If the frame is a multicast frame, then, the Address1
9273 * should be the destination address filled in the packet. Which is
9274 * the multicast address. Otherwise, set it to BSSID
9275 */
9276 if (0 == tlMetaInfo->ucBcast && 1 == tlMetaInfo->ucMcast)
9277 {
9278 vos_copy_macaddr( (v_MACADDR_t*)&pw80211Header->vA1,
9279 (v_MACADDR_t*)&w8023Header.vDA);
9280 }
9281 else
9282 {
9283 vos_copy_macaddr( (v_MACADDR_t*)&pw80211Header->vA1,
9284 &pClientSTA->wSTADesc.vSTAMACAddress);
9285 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009286 vos_mem_copy( pw80211Header->vA3,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309287 &pClientSTA->wSTADesc.vBSSIDforIBSS ,
Jeff Johnson295189b2012-06-20 16:38:30 -07009288 VOS_MAC_ADDR_SIZE);
9289 break;
9290
Ravi Joshid0699502013-07-08 15:48:47 -07009291 case WLAN_STA_BT_AMP:
Jeff Johnson295189b2012-06-20 16:38:30 -07009292 *ucWDSEnabled = 1; // WDS on.
9293 pw80211Header->wFrmCtrl.toDS = 1;
9294 pw80211Header->wFrmCtrl.fromDS = 1;
9295 vos_copy_macaddr( (v_MACADDR_t*)&pw80211Header->vA1,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309296 &pClientSTA->wSTADesc.vSTAMACAddress);
Jeff Johnson295189b2012-06-20 16:38:30 -07009297 vos_mem_copy( pw80211Header->vA2,
Ravi Joshid0699502013-07-08 15:48:47 -07009298 w8023Header.vSA, VOS_MAC_ADDR_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -07009299 vos_copy_macaddr( (v_MACADDR_t*)&pw80211Header->vA3,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309300 &pClientSTA->wSTADesc.vSTAMACAddress);
Jeff Johnson295189b2012-06-20 16:38:30 -07009301 /* fill the optional A4 header */
9302 vos_mem_copy( pw80211Header->optvA4,
Ravi Joshid0699502013-07-08 15:48:47 -07009303 w8023Header.vSA, VOS_MAC_ADDR_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -07009304 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
Ravi Joshid0699502013-07-08 15:48:47 -07009305 "BTAMP CASE NOW ---------staid=%d\n",
9306 ucStaId));
Jeff Johnson295189b2012-06-20 16:38:30 -07009307 break;
9308
Ravi Joshid0699502013-07-08 15:48:47 -07009309 case WLAN_STA_SOFTAP:
Jeff Johnson295189b2012-06-20 16:38:30 -07009310 *ucWDSEnabled = 0; // WDS off.
9311 pw80211Header->wFrmCtrl.toDS = 0;
9312 pw80211Header->wFrmCtrl.fromDS = 1;
9313 /*Copy the DA to A1*/
9314 vos_mem_copy( pw80211Header->vA1, w8023Header.vDA , VOS_MAC_ADDR_SIZE);
9315 vos_copy_macaddr( (v_MACADDR_t*)&pw80211Header->vA2,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309316 &pClientSTA->wSTADesc.vSelfMACAddress);
Jeff Johnson295189b2012-06-20 16:38:30 -07009317 vos_mem_copy( pw80211Header->vA3,
Ravi Joshid0699502013-07-08 15:48:47 -07009318 w8023Header.vSA, VOS_MAC_ADDR_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -07009319 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
Ravi Joshid0699502013-07-08 15:48:47 -07009320 "sw 802 to 80211 softap case ---------staid=%d\n",
9321 ucStaId));
Jeff Johnson295189b2012-06-20 16:38:30 -07009322 break;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08009323#ifdef FEATURE_WLAN_TDLS
Ravi Joshid0699502013-07-08 15:48:47 -07009324 case WLAN_STA_TDLS:
Mohit Khanna698ba2a2012-12-04 15:08:18 -08009325 pw80211Header->wFrmCtrl.toDS = 0;
9326 pw80211Header->wFrmCtrl.fromDS = 0;
9327 /*Fix me*/
9328 vos_copy_macaddr( (v_MACADDR_t*)&pw80211Header->vA1,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309329 &pClientSTA->wSTADesc.vSTAMACAddress);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08009330 vos_mem_copy( pw80211Header->vA3,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309331 &pClientSTA->wSTADesc.vBSSIDforIBSS ,
Mohit Khanna698ba2a2012-12-04 15:08:18 -08009332 VOS_MAC_ADDR_SIZE);
9333 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
Ravi Joshid0699502013-07-08 15:48:47 -07009334 ("TL:TDLS CASE NOW ---------staid=%d\n"), ucStaId);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08009335 break;
9336#endif
Ravi Joshid0699502013-07-08 15:48:47 -07009337 case WLAN_STA_INFRA:
9338 default:
Jeff Johnson295189b2012-06-20 16:38:30 -07009339 pw80211Header->wFrmCtrl.toDS = 1;
9340 pw80211Header->wFrmCtrl.fromDS = 0;
9341 vos_copy_macaddr( (v_MACADDR_t*)&pw80211Header->vA1,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309342 &pClientSTA->wSTADesc.vSTAMACAddress);
Jeff Johnson295189b2012-06-20 16:38:30 -07009343 vos_mem_copy( pw80211Header->vA3, w8023Header.vDA , VOS_MAC_ADDR_SIZE);
9344 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
Ravi Joshid0699502013-07-08 15:48:47 -07009345 "REGULAR INFRA LINK CASE---------staid=%d\n",
9346 ucStaId));
Jeff Johnson295189b2012-06-20 16:38:30 -07009347 break;
9348 }
9349 // OK now we have the space. Fill the 80211 header
9350 /* Fill A2 */
9351 pw80211Header = (WLANTL_80211HeaderType *)(ppvBDHeader);
9352 return VOS_STATUS_SUCCESS;
9353}/*WLANTL_Translate8023To80211Header*/
9354
9355
9356/*=============================================================================
9357 BEGIN LOG FUNCTION !!! Remove me or clean me
9358=============================================================================*/
Ravi Kumar Vaishnavb7652402013-01-18 19:05:15 -08009359#if 0 //def WLANTL_DEBUG
Jeff Johnson295189b2012-06-20 16:38:30 -07009360
9361#define WLANTL_DEBUG_FRAME_BYTE_PER_LINE 16
9362#define WLANTL_DEBUG_FRAME_BYTE_PER_BYTE 4
9363
9364static v_VOID_t WLANTL_DebugFrame
9365(
9366 v_PVOID_t dataPointer,
9367 v_U32_t dataSize
9368)
9369{
9370 v_U8_t lineBuffer[WLANTL_DEBUG_FRAME_BYTE_PER_LINE];
9371 v_U32_t numLines;
9372 v_U32_t numBytes;
9373 v_U32_t idx;
9374 v_U8_t *linePointer;
9375
9376 numLines = dataSize / WLANTL_DEBUG_FRAME_BYTE_PER_LINE;
9377 numBytes = dataSize % WLANTL_DEBUG_FRAME_BYTE_PER_LINE;
9378 linePointer = (v_U8_t *)dataPointer;
9379
9380 TLLOGE(VOS_TRACE(VOS_MODULE_ID_SAL, VOS_TRACE_LEVEL_ERROR, "WLAN TL:Frame Debug Frame Size %d, Pointer 0x%p", dataSize, dataPointer));
9381 for(idx = 0; idx < numLines; idx++)
9382 {
9383 memset(lineBuffer, 0, WLANTL_DEBUG_FRAME_BYTE_PER_LINE);
9384 memcpy(lineBuffer, linePointer, WLANTL_DEBUG_FRAME_BYTE_PER_LINE);
9385 TLLOGE(VOS_TRACE(VOS_MODULE_ID_SAL, VOS_TRACE_LEVEL_ERROR,
9386 "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",
9387 lineBuffer[0], lineBuffer[1], lineBuffer[2], lineBuffer[3], lineBuffer[4], lineBuffer[5], lineBuffer[6], lineBuffer[7],
9388 lineBuffer[8], lineBuffer[9], lineBuffer[10], lineBuffer[11], lineBuffer[12], lineBuffer[13], lineBuffer[14], lineBuffer[15]));
9389 linePointer += WLANTL_DEBUG_FRAME_BYTE_PER_LINE;
9390 }
9391
9392 if(0 == numBytes)
9393 return;
9394
9395 memset(lineBuffer, 0, WLANTL_DEBUG_FRAME_BYTE_PER_LINE);
9396 memcpy(lineBuffer, linePointer, numBytes);
9397 for(idx = 0; idx < WLANTL_DEBUG_FRAME_BYTE_PER_LINE / WLANTL_DEBUG_FRAME_BYTE_PER_BYTE; idx++)
9398 {
9399 TLLOGE(VOS_TRACE(VOS_MODULE_ID_SAL, VOS_TRACE_LEVEL_ERROR, "WLAN TL:0x%2x 0x%2x 0x%2x 0x%2x",
9400 lineBuffer[idx * WLANTL_DEBUG_FRAME_BYTE_PER_BYTE], lineBuffer[1 + idx * WLANTL_DEBUG_FRAME_BYTE_PER_BYTE],
9401 lineBuffer[2 + idx * WLANTL_DEBUG_FRAME_BYTE_PER_BYTE], lineBuffer[3 + idx * WLANTL_DEBUG_FRAME_BYTE_PER_BYTE]));
9402 if(((idx + 1) * WLANTL_DEBUG_FRAME_BYTE_PER_BYTE) >= numBytes)
9403 break;
9404 }
9405
9406 return;
9407}
9408#endif
9409
9410/*=============================================================================
9411 END LOG FUNCTION
9412=============================================================================*/
9413
9414/*==========================================================================
9415 FUNCTION WLANTL_Translate80211To8023Header
9416
9417 DESCRIPTION
9418 Inline function for translating and 802.11 header into an 802.3 header.
9419
9420 DEPENDENCIES
9421
9422
9423 PARAMETERS
9424
9425 IN
9426 pTLCb: TL control block
9427 ucStaId: station ID
9428 ucHeaderLen: Length of the header from BD
9429 ucActualHLen: Length of header including padding or any other trailers
9430
9431 IN/OUT
9432 vosDataBuff: vos data buffer, will contain the new header on output
9433
9434 OUT
9435 pvosStatus: status of the operation
9436
9437 RETURN VALUE
9438
9439 The result code associated with performing the operation
9440 VOS_STATUS_SUCCESS: Everything is good :)
9441
9442 SIDE EFFECTS
9443
9444============================================================================*/
9445VOS_STATUS
9446WLANTL_Translate80211To8023Header
9447(
9448 vos_pkt_t* vosDataBuff,
9449 VOS_STATUS* pvosStatus,
9450 v_U16_t usActualHLen,
9451 v_U8_t ucHeaderLen,
9452 WLANTL_CbType* pTLCb,
9453 v_U8_t ucSTAId
9454)
9455{
9456 WLANTL_8023HeaderType w8023Header;
9457 WLANTL_80211HeaderType w80211Header;
9458 v_U8_t aucLLCHeader[WLANTL_LLC_HEADER_LEN];
9459 VOS_STATUS vosStatus;
9460 v_U16_t usDataStartOffset = 0;
9461 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
9462
9463 if ( sizeof(w80211Header) < ucHeaderLen )
9464 {
9465 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
9466 "Warning !: Check the header size for the Rx frame structure=%d received=%dn",
9467 sizeof(w80211Header), ucHeaderLen));
9468 ucHeaderLen = sizeof(w80211Header);
9469 }
9470
9471 // This will take care of headers of all sizes, 3 address, 3 addr QOS,
9472 // WDS non-QOS and WDS QoS etc. We have space for all in the 802.11 header structure.
9473 vosStatus = vos_pkt_pop_head( vosDataBuff, &w80211Header, ucHeaderLen);
9474
9475 if ( VOS_STATUS_SUCCESS != vosStatus )
9476 {
9477 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9478 "WLAN TL: Failed to pop 80211 header from packet %d",
9479 vosStatus));
9480
9481 return vosStatus;
9482 }
9483
9484 switch ( w80211Header.wFrmCtrl.fromDS )
9485 {
9486 case 0:
Jeff Johnson295189b2012-06-20 16:38:30 -07009487 if ( w80211Header.wFrmCtrl.toDS )
9488 {
9489 //SoftAP AP mode
9490 vos_mem_copy( w8023Header.vDA, w80211Header.vA3, VOS_MAC_ADDR_SIZE);
9491 vos_mem_copy( w8023Header.vSA, w80211Header.vA2, VOS_MAC_ADDR_SIZE);
9492 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
9493 "WLAN TL SoftAP: 802 3 DA %08x SA %08x \n",
9494 w8023Header.vDA, w8023Header.vSA));
9495 }
9496 else
9497 {
9498 /* IBSS */
9499 vos_mem_copy( w8023Header.vDA, w80211Header.vA1, VOS_MAC_ADDR_SIZE);
9500 vos_mem_copy( w8023Header.vSA, w80211Header.vA2, VOS_MAC_ADDR_SIZE);
9501 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009502 break;
9503 case 1:
9504 if ( w80211Header.wFrmCtrl.toDS )
9505 {
9506 /* BT-AMP case */
9507 vos_mem_copy( w8023Header.vDA, w80211Header.vA1, VOS_MAC_ADDR_SIZE);
9508 vos_mem_copy( w8023Header.vSA, w80211Header.vA2, VOS_MAC_ADDR_SIZE);
9509 }
9510 else
9511 { /* Infra */
9512 vos_mem_copy( w8023Header.vDA, w80211Header.vA1, VOS_MAC_ADDR_SIZE);
9513 vos_mem_copy( w8023Header.vSA, w80211Header.vA3, VOS_MAC_ADDR_SIZE);
9514 }
9515 break;
9516 }
9517
9518 if( usActualHLen > ucHeaderLen )
9519 {
9520 usDataStartOffset = usActualHLen - ucHeaderLen;
9521 }
9522
9523 if ( 0 < usDataStartOffset )
9524 {
9525 vosStatus = vos_pkt_trim_head( vosDataBuff, usDataStartOffset );
9526
9527 if ( VOS_STATUS_SUCCESS != vosStatus )
9528 {
9529 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9530 "WLAN TL: Failed to trim header from packet %d",
9531 vosStatus));
9532 return vosStatus;
9533 }
9534 }
9535
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309536 if ( NULL == pTLCb->atlSTAClients[ucSTAId] )
9537 {
9538 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9539 "WLAN TL:Client Memory was not allocated on %s", __func__));
9540 return VOS_STATUS_E_FAILURE;
9541 }
9542
9543 if ( 0 != pTLCb->atlSTAClients[ucSTAId]->wSTADesc.ucAddRmvLLC )
Jeff Johnson295189b2012-06-20 16:38:30 -07009544 {
9545 // Extract the LLC header
9546 vosStatus = vos_pkt_pop_head( vosDataBuff, aucLLCHeader,
9547 WLANTL_LLC_HEADER_LEN);
9548
9549 if ( VOS_STATUS_SUCCESS != vosStatus )
9550 {
9551 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9552 "WLAN TL: Failed to pop LLC header from packet %d",
9553 vosStatus));
9554
9555 return vosStatus;
9556 }
9557
9558 //Extract the length
9559 vos_mem_copy(&w8023Header.usLenType,
9560 &aucLLCHeader[WLANTL_LLC_HEADER_LEN - sizeof(w8023Header.usLenType)],
9561 sizeof(w8023Header.usLenType) );
9562 }
9563 else
9564 {
9565 vosStatus = vos_pkt_get_packet_length(vosDataBuff,
9566 &w8023Header.usLenType);
9567
9568 if ( VOS_STATUS_SUCCESS != vosStatus )
9569 {
9570 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9571 "WLAN TL: Failed to get packet length %d",
9572 vosStatus));
9573
9574 return vosStatus;
9575 }
9576
9577 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
9578 "WLAN TL: BTAMP len (ethertype) fld = %d",
9579 w8023Header.usLenType));
9580 w8023Header.usLenType = vos_cpu_to_be16(w8023Header.usLenType);
9581 }
9582
9583 vos_pkt_push_head(vosDataBuff, &w8023Header, sizeof(w8023Header));
9584
9585#ifdef BTAMP_TEST
9586 {
9587 // AP side will execute this.
9588 v_U8_t *temp_w8023Header = NULL;
9589 vosStatus = vos_pkt_peek_data( vosDataBuff, 0,
9590 &temp_w8023Header, sizeof(w8023Header) );
9591 }
9592#endif
9593#if 0 /*TL_DEBUG*/
9594 vos_pkt_get_packet_length(vosDataBuff, &usLen);
9595 vos_pkt_pop_head( vosDataBuff, aucData, usLen);
9596
9597 WLANTL_DebugFrame(aucData, usLen);
9598
9599 vos_pkt_push_head(vosDataBuff, aucData, usLen);
9600
9601#endif
9602
9603 *pvosStatus = VOS_STATUS_SUCCESS;
9604
9605 return VOS_STATUS_SUCCESS;
9606}/*WLANTL_Translate80211To8023Header*/
9607
Madan Mohan Koyyalamudia148e1e2012-11-30 14:52:59 -08009608/*==========================================================================
9609 FUNCTION WLANTL_FindFrameTypeBcMcUc
9610
9611 DESCRIPTION
9612 Utility function to find whether received frame is broadcast, multicast
9613 or unicast.
9614
9615 DEPENDENCIES
9616 The STA must be registered with TL before this function can be called.
9617
9618 PARAMETERS
9619
9620 IN
9621 pTLCb: pointer to the TL's control block
9622 ucSTAId: identifier of the station being processed
9623 vosDataBuff: pointer to the vos buffer
9624
9625 IN/OUT
9626 pucBcMcUc: pointer to buffer, will contain frame type on return
9627
9628 RETURN VALUE
9629 The result code associated with performing the operation
9630
9631 VOS_STATUS_E_INVAL: invalid input parameters
9632 VOS_STATUS_E_BADMSG: failed to extract info from data buffer
9633 VOS_STATUS_SUCCESS: success
9634
9635 SIDE EFFECTS
9636 None.
9637============================================================================*/
9638VOS_STATUS
9639WLANTL_FindFrameTypeBcMcUc
9640(
9641 WLANTL_CbType *pTLCb,
9642 v_U8_t ucSTAId,
9643 vos_pkt_t *vosDataBuff,
9644 v_U8_t *pucBcMcUc
9645)
9646{
9647 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
9648 v_PVOID_t aucBDHeader;
9649 v_PVOID_t pvPeekData;
9650 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
9651
9652 /*------------------------------------------------------------------------
9653 Sanity check
9654 ------------------------------------------------------------------------*/
9655 if ((NULL == pTLCb) ||
9656 (NULL == vosDataBuff) ||
9657 (NULL == pucBcMcUc))
9658 {
9659 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9660 "WLAN TL:Invalid parameter in WLANTL_FindFrameTypeBcMcUc"));
9661 return VOS_STATUS_E_INVAL;
9662 }
9663
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309664 if ( NULL == pTLCb->atlSTAClients[ucSTAId] )
9665 {
9666 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9667 "WLAN TL:Client Memory was not allocated on %s", __func__));
9668 return VOS_STATUS_E_FAILURE;
9669 }
9670
Madan Mohan Koyyalamudia148e1e2012-11-30 14:52:59 -08009671 /*------------------------------------------------------------------------
9672 Extract BD header and check if valid
9673 ------------------------------------------------------------------------*/
9674 vosStatus = WDA_DS_PeekRxPacketInfo(vosDataBuff, (v_PVOID_t)&aucBDHeader, 0/*Swap BD*/ );
9675
9676 if (NULL == aucBDHeader)
9677 {
9678 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9679 "WLAN TL:WLANTL_FindFrameTypeBcMcUc - Cannot extract BD header"));
9680 VOS_ASSERT(0);
9681 return VOS_STATUS_E_BADMSG;
9682 }
9683
9684 if ((0 == WDA_GET_RX_FT_DONE(aucBDHeader)) &&
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309685 (0 != pTLCb->atlSTAClients[ucSTAId]->wSTADesc.ucSwFrameRXXlation))
Madan Mohan Koyyalamudia148e1e2012-11-30 14:52:59 -08009686 {
9687 /* Its an 802.11 frame, extract MAC address 1 */
9688 TLLOG2(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
9689 "WLAN TL:WLANTL_FindFrameTypeBcMcUc - 802.11 frame, peeking Addr1"));
9690 vosStatus = vos_pkt_peek_data(vosDataBuff, WLANTL_MAC_ADDR_ALIGN(1),
9691 (v_PVOID_t)&pvPeekData, VOS_MAC_ADDR_SIZE);
9692 }
9693 else
9694 {
9695 /* Its an 802.3 frame, extract Destination MAC address */
9696 TLLOG2(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
9697 "WLAN TL:WLANTL_FindFrameTypeBcMcUc - 802.3 frame, peeking DA"));
9698 vosStatus = vos_pkt_peek_data(vosDataBuff, WLANTL_MAC_ADDR_ALIGN(0),
9699 (v_PVOID_t)&pvPeekData, VOS_MAC_ADDR_SIZE);
9700 }
9701
9702 if (VOS_STATUS_SUCCESS != vosStatus)
9703 {
9704 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9705 "WLAN TL:WLANTL_FindFrameTypeBcMcUc - Failed to peek MAC address"));
9706 return vosStatus;
9707 }
9708
9709 if (((tANI_U8 *)pvPeekData)[0] == 0xff)
9710 {
9711 *pucBcMcUc = WLANTL_FRAME_TYPE_BCAST;
9712 }
9713 else
9714 {
9715 if ((((tANI_U8 *)pvPeekData)[0] & 0x01) == 0x01)
9716 *pucBcMcUc = WLANTL_FRAME_TYPE_MCAST;
9717 else
9718 *pucBcMcUc = WLANTL_FRAME_TYPE_UCAST;
9719 }
9720
9721 TLLOG2(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
9722 "WLAN TL:WLANTL_FindFrameTypeBcMcUc - Addr1Byte1 is: %x",
9723 ((tANI_U8 *)pvPeekData)[0]));
9724
9725 return VOS_STATUS_SUCCESS;
9726}
9727
Jeff Johnson295189b2012-06-20 16:38:30 -07009728#if 0
9729#ifdef WLAN_PERF
9730/*==========================================================================
9731 FUNCTION WLANTL_FastHwFwdDataFrame
9732
9733 DESCRIPTION
9734 Fast path function to quickly forward a data frame if HAL determines BD
9735 signature computed here matches the signature inside current VOSS packet.
9736 If there is a match, HAL and TL fills in the swapped packet length into
9737 BD header and DxE header, respectively. Otherwise, packet goes back to
9738 normal (slow) path and a new BD signature would be tagged into BD in this
9739 VOSS packet later by the WLANHAL_FillTxBd() function.
9740
9741 DEPENDENCIES
9742
9743 PARAMETERS
9744
9745 IN
9746 pvosGCtx VOS context
9747 vosDataBuff Ptr to VOSS packet
9748 pMetaInfo For getting frame's TID
9749 pStaInfo For checking STA type
9750
9751 OUT
9752 pvosStatus returned status
9753 puFastFwdOK Flag to indicate whether frame could be fast forwarded
9754
9755 RETURN VALUE
9756 No return.
9757
9758 SIDE EFFECTS
9759
9760============================================================================*/
9761static void
9762WLANTL_FastHwFwdDataFrame
9763(
9764 v_PVOID_t pvosGCtx,
9765 vos_pkt_t* vosDataBuff,
9766 VOS_STATUS* pvosStatus,
9767 v_U32_t* puFastFwdOK,
9768 WLANTL_MetaInfoType* pMetaInfo,
9769 WLAN_STADescType* pStaInfo
9770
9771)
9772{
9773 v_PVOID_t pvPeekData;
9774 v_U8_t ucDxEBDWLANHeaderLen = WLANTL_BD_HEADER_LEN(0) + sizeof(WLANBAL_sDXEHeaderType);
9775 v_U8_t ucIsUnicast;
9776 WLANBAL_sDXEHeaderType *pDxEHeader;
9777 v_PVOID_t pvBDHeader;
9778 v_PVOID_t pucBuffPtr;
9779 v_U16_t usPktLen;
9780
9781 /*-----------------------------------------------------------------------
9782 Extract packet length
9783 -----------------------------------------------------------------------*/
9784
9785 vos_pkt_get_packet_length( vosDataBuff, &usPktLen);
9786
9787 /*-----------------------------------------------------------------------
9788 Extract MAC address
9789 -----------------------------------------------------------------------*/
9790 *pvosStatus = vos_pkt_peek_data( vosDataBuff,
9791 WLANTL_MAC_ADDR_ALIGN(0),
9792 (v_PVOID_t)&pvPeekData,
9793 VOS_MAC_ADDR_SIZE );
9794
9795 if ( VOS_STATUS_SUCCESS != *pvosStatus )
9796 {
9797 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9798 "WLAN TL:Failed while attempting to extract MAC Addr %d",
9799 *pvosStatus));
9800 *pvosStatus = VOS_STATUS_E_INVAL;
9801 return;
9802 }
9803
9804 /*-----------------------------------------------------------------------
9805 Reserve head room for DxE header, BD, and WLAN header
9806 -----------------------------------------------------------------------*/
9807
9808 vos_pkt_reserve_head( vosDataBuff, &pucBuffPtr,
9809 ucDxEBDWLANHeaderLen );
9810 if ( NULL == pucBuffPtr )
9811 {
9812 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9813 "WLAN TL:No enough space in VOSS packet %p for DxE/BD/WLAN header", vosDataBuff));
9814 *pvosStatus = VOS_STATUS_E_INVAL;
9815 return;
9816 }
9817 pDxEHeader = (WLANBAL_sDXEHeaderType *)pucBuffPtr;
9818 pvBDHeader = (v_PVOID_t) &pDxEHeader[1];
9819
9820 /* UMA Tx acceleration is enabled.
9821 * UMA would help convert frames to 802.11, fill partial BD fields and
9822 * construct LLC header. To further accelerate this kind of frames,
9823 * HAL would attempt to reuse the BD descriptor if the BD signature
9824 * matches to the saved BD descriptor.
9825 */
9826 if(pStaInfo->wSTAType == WLAN_STA_IBSS)
9827 ucIsUnicast = !(((tANI_U8 *)pvPeekData)[0] & 0x01);
9828 else
9829 ucIsUnicast = 1;
9830
9831 *puFastFwdOK = (v_U32_t) WLANHAL_TxBdFastFwd(pvosGCtx, pvPeekData, pMetaInfo->ucTID, ucIsUnicast, pvBDHeader, usPktLen );
9832
9833 /* Can't be fast forwarded. Trim the VOS head back to original location. */
9834 if(! *puFastFwdOK){
9835 vos_pkt_trim_head(vosDataBuff, ucDxEBDWLANHeaderLen);
9836 }else{
9837 /* could be fast forwarded. Now notify BAL DxE header filling could be completely skipped
9838 */
9839 v_U32_t uPacketSize = WLANTL_BD_HEADER_LEN(0) + usPktLen;
9840 vos_pkt_set_user_data_ptr( vosDataBuff, VOS_PKT_USER_DATA_ID_BAL,
9841 (v_PVOID_t)uPacketSize);
9842 pDxEHeader->size = SWAP_ENDIAN_UINT32(uPacketSize);
9843 }
9844 *pvosStatus = VOS_STATUS_SUCCESS;
9845 return;
9846}
9847#endif /*WLAN_PERF*/
9848#endif
9849
9850#if 0
9851/*==========================================================================
9852 FUNCTION WLANTL_PrepareBDHeader
9853
9854 DESCRIPTION
9855 Inline function for preparing BD header before HAL processing.
9856
9857 DEPENDENCIES
9858 Just notify HAL that suspend in TL is complete.
9859
9860 PARAMETERS
9861
9862 IN
9863 vosDataBuff: vos data buffer
9864 ucDisableFrmXtl: is frame xtl disabled
9865
9866 OUT
9867 ppvBDHeader: it will contain the BD header
9868 pvDestMacAdddr: it will contain the destination MAC address
9869 pvosStatus: status of the combined processing
9870 pusPktLen: packet len.
9871
9872 RETURN VALUE
9873 No return.
9874
9875 SIDE EFFECTS
9876
9877============================================================================*/
9878void
9879WLANTL_PrepareBDHeader
9880(
9881 vos_pkt_t* vosDataBuff,
9882 v_PVOID_t* ppvBDHeader,
9883 v_MACADDR_t* pvDestMacAdddr,
9884 v_U8_t ucDisableFrmXtl,
9885 VOS_STATUS* pvosStatus,
9886 v_U16_t* pusPktLen,
9887 v_U8_t ucQosEnabled,
9888 v_U8_t ucWDSEnabled,
9889 v_U8_t extraHeadSpace
9890)
9891{
9892 v_U8_t ucHeaderOffset;
9893 v_U8_t ucHeaderLen;
Jeff Johnson295189b2012-06-20 16:38:30 -07009894 v_U8_t ucBDHeaderLen = WLANTL_BD_HEADER_LEN(ucDisableFrmXtl);
9895
9896 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
9897 /*-------------------------------------------------------------------------
9898 Get header pointer from VOSS
9899 !!! make sure reserve head zeros out the memory
9900 -------------------------------------------------------------------------*/
9901 vos_pkt_get_packet_length( vosDataBuff, pusPktLen);
9902
9903 if ( WLANTL_MAC_HEADER_LEN(ucDisableFrmXtl) > *pusPktLen )
9904 {
9905 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9906 "WLAN TL: Length of the packet smaller than expected network"
9907 " header %d", *pusPktLen ));
9908
9909 *pvosStatus = VOS_STATUS_E_INVAL;
9910 return;
9911 }
9912
9913 vos_pkt_reserve_head( vosDataBuff, ppvBDHeader,
9914 ucBDHeaderLen );
9915 if ( NULL == *ppvBDHeader )
9916 {
9917 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9918 "WLAN TL:VOSS packet corrupted on Attach BD header"));
9919 *pvosStatus = VOS_STATUS_E_INVAL;
9920 return;
9921 }
9922
9923 /*-----------------------------------------------------------------------
9924 Extract MAC address
9925 -----------------------------------------------------------------------*/
Jeff Johnson295189b2012-06-20 16:38:30 -07009926 {
9927 v_SIZE_t usMacAddrSize = VOS_MAC_ADDR_SIZE;
9928 *pvosStatus = vos_pkt_extract_data( vosDataBuff,
9929 ucBDHeaderLen +
9930 WLANTL_MAC_ADDR_ALIGN(ucDisableFrmXtl),
9931 (v_PVOID_t)pvDestMacAdddr,
9932 &usMacAddrSize );
9933 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009934 if ( VOS_STATUS_SUCCESS != *pvosStatus )
9935 {
9936 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9937 "WLAN TL:Failed while attempting to extract MAC Addr %d",
9938 *pvosStatus));
9939 }
9940 else
9941 {
9942 /*---------------------------------------------------------------------
9943 Fill MPDU info fields:
9944 - MPDU data start offset
9945 - MPDU header start offset
9946 - MPDU header length
9947 - MPDU length - this is a 16b field - needs swapping
9948 --------------------------------------------------------------------*/
9949 ucHeaderOffset = ucBDHeaderLen;
9950 ucHeaderLen = WLANTL_MAC_HEADER_LEN(ucDisableFrmXtl);
9951
9952 if ( 0 != ucDisableFrmXtl )
9953 {
9954 if ( 0 != ucQosEnabled )
9955 {
9956 ucHeaderLen += WLANTL_802_11_HEADER_QOS_CTL;
9957 }
9958
9959 // Similar to Qos we need something for WDS format !
9960 if ( ucWDSEnabled != 0 )
9961 {
9962 // If we have frame translation enabled
9963 ucHeaderLen += WLANTL_802_11_HEADER_ADDR4_LEN;
9964 }
9965 if ( extraHeadSpace != 0 )
9966 {
9967 // Decrease the packet length with the extra padding after the header
9968 *pusPktLen = *pusPktLen - extraHeadSpace;
9969 }
9970 }
9971
9972 WLANHAL_TX_BD_SET_MPDU_HEADER_LEN( *ppvBDHeader, ucHeaderLen);
9973 WLANHAL_TX_BD_SET_MPDU_HEADER_OFFSET( *ppvBDHeader, ucHeaderOffset);
9974 WLANHAL_TX_BD_SET_MPDU_DATA_OFFSET( *ppvBDHeader,
9975 ucHeaderOffset + ucHeaderLen + extraHeadSpace);
9976 WLANHAL_TX_BD_SET_MPDU_LEN( *ppvBDHeader, *pusPktLen);
9977
9978 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
9979 "WLAN TL: VALUES ARE HLen=%x Hoff=%x doff=%x len=%x ex=%d",
9980 ucHeaderLen, ucHeaderOffset,
9981 (ucHeaderOffset + ucHeaderLen + extraHeadSpace),
9982 *pusPktLen, extraHeadSpace));
9983 }/* if peek MAC success*/
9984
9985}/* WLANTL_PrepareBDHeader */
9986#endif
9987
Jeff Johnson295189b2012-06-20 16:38:30 -07009988//THIS IS A HACK AND NEEDS TO BE FIXED FOR CONCURRENCY
9989/*==========================================================================
9990 FUNCTION WLAN_TLGetNextTxIds
9991
9992 DESCRIPTION
9993 Gets the next station and next AC in the list that should be served by the TL.
9994
9995 Multiple Station Scheduling and TL queue management.
9996
9997 4 HDD BC/MC data packet queue status is specified as Station 0's status. Weights used
9998 in WFQ algorith are initialized in WLANTL_OPEN and contained in tlConfigInfo field.
9999 Each station has fields of ucPktPending and AC mask to tell whether a AC has traffic
10000 or not.
10001
10002 Stations are served in a round-robin fashion from highest priority to lowest priority.
10003 The number of round-robin times of each prioirty equals to the WFQ weights and differetiates
10004 the traffic of different prioirty. As such, stations can not provide low priority packets if
10005 high priority packets are all served.
10006
10007 DEPENDENCIES
10008
10009 PARAMETERS
10010
10011 IN
10012 pvosGCtx: pointer to the global vos context; a handle to TL's
10013 control block can be extracted from its context
10014
10015 OUT
10016 pucSTAId: Station ID
10017
10018 RETURN VALUE
10019 The result code associated with performing the operation
10020
10021 VOS_STATUS_SUCCESS: Everything is good
10022
10023 SIDE EFFECTS
10024
10025 TL context contains currently served station ID in ucCurrentSTA field, currently served AC
10026 in uCurServedAC field, and unserved weights of current AC in uCurLeftWeight.
10027 When existing from the function, these three fields are changed accordingly.
10028
10029============================================================================*/
10030VOS_STATUS
10031WLAN_TLAPGetNextTxIds
10032(
10033 v_PVOID_t pvosGCtx,
10034 v_U8_t* pucSTAId
10035)
10036{
10037 WLANTL_CbType* pTLCb;
10038 v_U8_t ucACFilter = 1;
10039 v_U8_t ucNextSTA ;
10040 v_BOOL_t isServed = TRUE; //current round has find a packet or not
10041 v_U8_t ucACLoopNum = WLANTL_AC_VO + 1; //number of loop to go
10042 v_U8_t uFlowMask; // TX FlowMask from WDA
10043 uint8 ucACMask;
Gopichand Nakkala96237bc2013-01-04 12:20:29 -080010044 uint8 i = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070010045 /*------------------------------------------------------------------------
10046 Extract TL control block
10047 ------------------------------------------------------------------------*/
10048 //ENTER();
10049
10050 pTLCb = VOS_GET_TL_CB(pvosGCtx);
10051 if ( NULL == pTLCb )
10052 {
10053 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
10054 "WLAN TL:Invalid TL pointer from pvosGCtx on WLAN_TLAPGetNextTxIds"));
10055 return VOS_STATUS_E_FAULT;
10056 }
10057
10058 if ( VOS_STATUS_SUCCESS != WDA_DS_GetTxFlowMask( pvosGCtx, &uFlowMask ) )
10059 {
10060 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
10061 "WLAN TL:Failed to retrieve Flow control mask from WDA"));
10062 return VOS_STATUS_E_FAULT;
10063 }
10064
10065 ucNextSTA = pTLCb->ucCurrentSTA;
10066
10067 ++ucNextSTA;
10068
10069 if ( WLAN_MAX_STA_COUNT <= ucNextSTA )
10070 {
10071 //one round is done.
10072 ucNextSTA = 0;
10073 pTLCb->ucCurLeftWeight--;
10074 isServed = FALSE;
10075 if ( 0 == pTLCb->ucCurLeftWeight )
10076 {
10077 //current prioirty is done
10078 if ( WLANTL_AC_BK == (WLANTL_ACEnumType)pTLCb->uCurServedAC )
10079 {
10080 //end of current VO, VI, BE, BK loop. Reset priority.
10081 pTLCb->uCurServedAC = WLANTL_AC_VO;
10082 }
10083 else
10084 {
10085 pTLCb->uCurServedAC --;
10086 }
10087
10088 pTLCb->ucCurLeftWeight = pTLCb->tlConfigInfo.ucAcWeights[pTLCb->uCurServedAC];
10089
10090 } // (0 == pTLCb->ucCurLeftWeight)
10091 } //( WLAN_MAX_STA_COUNT == ucNextSTA )
10092
10093 //decide how many loops to go. if current loop is partial, do one extra to make sure
10094 //we cover every station
10095 if ((1 == pTLCb->ucCurLeftWeight) && (ucNextSTA != 0))
10096 {
10097 ucACLoopNum ++; // now is 5 loops
10098 }
10099
10100 /* Start with highest priority. ucNextSTA, pTLCb->uCurServedAC, pTLCb->ucCurLeftWeight
10101 all have previous values.*/
10102 for (; ucACLoopNum > 0; ucACLoopNum--)
10103 {
10104
10105 ucACFilter = 1 << pTLCb->uCurServedAC;
10106
10107 // pTLCb->ucCurLeftWeight keeps previous results.
10108 for (; (pTLCb->ucCurLeftWeight > 0) && (uFlowMask & ucACFilter); pTLCb->ucCurLeftWeight-- )
10109 {
10110
10111 for ( ; ucNextSTA < WLAN_MAX_STA_COUNT; ucNextSTA ++ )
10112 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053010113 if(NULL == pTLCb->atlSTAClients[ucNextSTA])
10114 {
10115 continue;
10116 }
10117 WLAN_TL_AC_ARRAY_2_MASK (pTLCb->atlSTAClients[ucNextSTA], ucACMask, i);
Jeff Johnson295189b2012-06-20 16:38:30 -070010118
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053010119 if ( (0 == pTLCb->atlSTAClients[ucNextSTA]->ucExists) ||
10120 ((0 == pTLCb->atlSTAClients[ucNextSTA]->ucPktPending) && !(ucACMask)) ||
Jeff Johnson295189b2012-06-20 16:38:30 -070010121 (0 == (ucACMask & ucACFilter)) )
10122
10123 {
Tushnim Bhattacharyya39a8f182013-02-20 18:10:30 -080010124 //current station does not exist or have any packet to serve.
10125 continue;
10126 }
10127
10128 if (WLANTL_STA_AUTHENTICATED != pTLCb->atlSTAClients[ucNextSTA]->tlState)
10129 {
10130 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
10131 "%s Sta %d not in auth state so skipping it.",
10132 __func__, ucNextSTA));
Jeff Johnson295189b2012-06-20 16:38:30 -070010133 continue;
10134 }
10135
10136 //go to next station if current station can't send due to flow control
10137 //Station is allowed to send when it is not in LWM mode. When station is in LWM mode,
10138 //station is allowed to send only after FW reports FW memory is below threshold and on-fly
10139 //packets are less then allowed value
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053010140 if ( (TRUE == pTLCb->atlSTAClients[ucNextSTA]->ucLwmModeEnabled) &&
10141 ((FALSE == pTLCb->atlSTAClients[ucNextSTA]->ucLwmEventReported) ||
10142 (0 < pTLCb->atlSTAClients[ucNextSTA]->uBuffThresholdMax))
Jeff Johnson295189b2012-06-20 16:38:30 -070010143 )
10144 {
10145 continue;
10146 }
10147
10148
10149 // Find a station. Weight is updated already.
10150 *pucSTAId = ucNextSTA;
10151 pTLCb->ucCurrentSTA = ucNextSTA;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053010152 pTLCb->atlSTAClients[*pucSTAId]->ucCurrentAC = pTLCb->uCurServedAC;
Jeff Johnson295189b2012-06-20 16:38:30 -070010153
10154 TLLOG4(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_LOW,
10155 " TL serve one station AC: %d W: %d StaId: %d",
10156 pTLCb->uCurServedAC, pTLCb->ucCurLeftWeight, pTLCb->ucCurrentSTA ));
10157
10158 return VOS_STATUS_SUCCESS;
10159 } //STA loop
10160
10161 ucNextSTA = 0;
10162 if ( FALSE == isServed )
10163 {
10164 //current loop finds no packet.no need to repeat for the same priority
10165 break;
10166 }
10167 //current loop is partial loop. go for one more loop.
10168 isServed = FALSE;
10169
10170 } //Weight loop
10171
10172 if (WLANTL_AC_BK == pTLCb->uCurServedAC)
10173 {
10174 pTLCb->uCurServedAC = WLANTL_AC_VO;
10175 }
10176 else
10177 {
10178 pTLCb->uCurServedAC--;
10179 }
10180 pTLCb->ucCurLeftWeight = pTLCb->tlConfigInfo.ucAcWeights[pTLCb->uCurServedAC];
10181
10182 }// AC loop
10183
10184 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
10185 " TL can't find one station to serve \n" ));
10186
10187 pTLCb->uCurServedAC = WLANTL_AC_BK;
10188 pTLCb->ucCurLeftWeight = 1;
10189 //invalid number will be captured by caller
10190 pTLCb->ucCurrentSTA = WLAN_MAX_STA_COUNT;
10191
10192 *pucSTAId = pTLCb->ucCurrentSTA;
Jeff Johnson295189b2012-06-20 16:38:30 -070010193 return VOS_STATUS_E_FAULT;
10194}
10195
10196
10197/*==========================================================================
10198 FUNCTION WLAN_TLGetNextTxIds
10199
10200 DESCRIPTION
10201 Gets the next station and next AC in the list
10202
10203 DEPENDENCIES
10204
10205 PARAMETERS
10206
10207 IN
10208 pvosGCtx: pointer to the global vos context; a handle to TL's
10209 control block can be extracted from its context
10210
10211 OUT
10212 pucSTAId: Station ID
10213
10214
10215 RETURN VALUE
10216 The result code associated with performing the operation
10217
10218 VOS_STATUS_SUCCESS: Everything is good :)
10219
10220 SIDE EFFECTS
10221
10222============================================================================*/
10223VOS_STATUS
10224WLAN_TLGetNextTxIds
10225(
10226 v_PVOID_t pvosGCtx,
10227 v_U8_t* pucSTAId
10228)
10229{
10230 WLANTL_CbType* pTLCb;
10231 v_U8_t ucNextAC;
10232 v_U8_t ucNextSTA;
10233 v_U8_t ucCount;
10234 v_U8_t uFlowMask; // TX FlowMask from WDA
10235 v_U8_t ucACMask = 0;
10236 v_U8_t i = 0;
10237
10238 tBssSystemRole systemRole; //RG HACK to be removed
10239 tpAniSirGlobal pMac;
10240
10241 pMac = vos_get_context(VOS_MODULE_ID_PE, pvosGCtx);
10242 if ( NULL == pMac )
10243 {
10244 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070010245 "%s: Invalid pMac", __func__));
Jeff Johnson295189b2012-06-20 16:38:30 -070010246 return VOS_STATUS_E_FAULT;
10247 }
10248
10249 systemRole = wdaGetGlobalSystemRole(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -070010250
Jeff Johnson295189b2012-06-20 16:38:30 -070010251 /*------------------------------------------------------------------------
10252 Extract TL control block
10253 ------------------------------------------------------------------------*/
10254 pTLCb = VOS_GET_TL_CB(pvosGCtx);
10255 if ( NULL == pTLCb )
10256 {
10257 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
10258 "WLAN TL:Invalid TL pointer from pvosGCtx on WLAN_TLGetNextTxIds"));
10259 return VOS_STATUS_E_FAULT;
10260 }
10261
Sunil Ravid5406f22013-01-22 00:18:31 -080010262#ifdef FEATURE_WLAN_TDLS
10263 if ((eSYSTEM_AP_ROLE == systemRole) || (vos_concurrent_sessions_running()) || pTLCb->ucTdlsPeerCount)
10264#else
10265 if ((eSYSTEM_AP_ROLE == systemRole) || (vos_concurrent_sessions_running()))
10266#endif
10267 {
10268 return WLAN_TLAPGetNextTxIds(pvosGCtx,pucSTAId);
10269 }
10270
10271
Jeff Johnson295189b2012-06-20 16:38:30 -070010272 if ( VOS_STATUS_SUCCESS != WDA_DS_GetTxFlowMask( pvosGCtx, &uFlowMask ) )
10273 {
10274 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
10275 "WLAN TL:Failed to retrieve Flow control mask from WDA"));
10276 return VOS_STATUS_E_FAULT;
10277 }
10278
10279 /*STA id - no priority yet implemented */
10280 /*-----------------------------------------------------------------------
10281 Choose the next STA for tx - for now go in a round robin fashion
10282 through all the stations that have pending packets
10283 -------------------------------------------------------------------------*/
10284 ucNextSTA = pTLCb->ucCurrentSTA;
10285
10286 pTLCb->ucCurrentSTA = WLAN_MAX_STA_COUNT;
10287 for ( ucCount = 0;
10288 ucCount < WLAN_MAX_STA_COUNT;
10289 ucCount++ )
10290 {
10291 ucNextSTA = ( (ucNextSTA+1) >= WLAN_MAX_STA_COUNT )?0:(ucNextSTA+1);
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053010292 if(NULL == pTLCb->atlSTAClients[ucNextSTA])
10293 {
10294 continue;
10295 }
10296 if (( pTLCb->atlSTAClients[ucNextSTA]->ucExists ) &&
10297 ( pTLCb->atlSTAClients[ucNextSTA]->ucPktPending ))
Jeff Johnson295189b2012-06-20 16:38:30 -070010298 {
Tushnim Bhattacharyya39a8f182013-02-20 18:10:30 -080010299 if (WLANTL_STA_AUTHENTICATED == pTLCb->atlSTAClients[ucNextSTA]->tlState)
10300 {
10301 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
10302 "STA ID: %d on WLAN_TLGetNextTxIds", *pucSTAId));
10303 pTLCb->ucCurrentSTA = ucNextSTA;
10304 break;
Tushnim Bhattacharyya5dd94562013-03-20 20:15:03 -070010305 }
10306 else
10307 {
Tushnim Bhattacharyya39a8f182013-02-20 18:10:30 -080010308 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
10309 "%s Sta %d is not in auth state, skipping this sta.",
10310 __func__, ucNextSTA));
Tushnim Bhattacharyya5dd94562013-03-20 20:15:03 -070010311 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010312 }
10313 }
10314
10315 *pucSTAId = pTLCb->ucCurrentSTA;
10316
10317 if ( WLANTL_STA_ID_INVALID( *pucSTAId ) )
10318 {
10319 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
10320 "WLAN TL:No station registered with TL at this point"));
10321
10322 return VOS_STATUS_E_FAULT;
10323
10324 }
10325
10326 /*Convert the array to a mask for easier operation*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053010327 WLAN_TL_AC_ARRAY_2_MASK( pTLCb->atlSTAClients[*pucSTAId], ucACMask, i);
Jeff Johnson295189b2012-06-20 16:38:30 -070010328
10329 if ( 0 == ucACMask )
10330 {
10331 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
10332 "WLAN TL: Mask 0 "
10333 "STA ID: %d on WLAN_TLGetNextTxIds", *pucSTAId));
10334
10335 /*setting STA id to invalid if mask is 0*/
10336 *pucSTAId = WLAN_MAX_STA_COUNT;
10337
10338 return VOS_STATUS_E_FAULT;
10339 }
10340
10341 /*-----------------------------------------------------------------------
10342 AC is updated whenever a packet is fetched from HDD -> the current
10343 weight of such an AC cannot be 0 -> in this case TL is expected to
10344 exit this function at this point during the main Tx loop
10345 -----------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053010346 if ( 0 < pTLCb->atlSTAClients[*pucSTAId]->ucCurrentWeight )
Jeff Johnson295189b2012-06-20 16:38:30 -070010347 {
10348 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
10349 "WLAN TL: Maintaining serviced AC to: %d for Weight: %d",
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053010350 pTLCb->atlSTAClients[*pucSTAId]->ucCurrentAC ,
10351 pTLCb->atlSTAClients[*pucSTAId]->ucCurrentWeight));
Jeff Johnson295189b2012-06-20 16:38:30 -070010352 return VOS_STATUS_SUCCESS;
10353 }
10354
10355 /*-----------------------------------------------------------------------
10356 Choose highest priority AC - !!! optimize me
10357 -----------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053010358 ucNextAC = pTLCb->atlSTAClients[*pucSTAId]->ucCurrentAC;
Jeff Johnson295189b2012-06-20 16:38:30 -070010359 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
10360 "Next AC: %d", ucNextAC));
10361
10362 while ( 0 != ucACMask )
10363 {
10364 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
10365 " AC Mask: %d Next: %d Res : %d",
10366 ucACMask, ( 1 << ucNextAC ), ( ucACMask & ( 1 << ucNextAC ))));
10367
10368 if ( 0 != ( ucACMask & ( 1 << ucNextAC ) & uFlowMask ))
10369 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053010370 pTLCb->atlSTAClients[*pucSTAId]->ucCurrentAC =
Jeff Johnson295189b2012-06-20 16:38:30 -070010371 (WLANTL_ACEnumType)ucNextAC;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053010372 pTLCb->atlSTAClients[*pucSTAId]->ucCurrentWeight =
Jeff Johnson295189b2012-06-20 16:38:30 -070010373 pTLCb->tlConfigInfo.ucAcWeights[ucNextAC];
10374
10375 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
10376 "WLAN TL: Switching serviced AC to: %d with Weight: %d",
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053010377 pTLCb->atlSTAClients[*pucSTAId]->ucCurrentAC ,
10378 pTLCb->atlSTAClients[*pucSTAId]->ucCurrentWeight));
Jeff Johnson295189b2012-06-20 16:38:30 -070010379 break;
10380 }
10381
10382 ucNextAC = ( ucNextAC - 1 ) & WLANTL_MASK_AC;
10383
10384 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
10385 "Next AC %d", ucNextAC));
10386
10387 }
10388
10389 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
10390 " C AC: %d C W: %d",
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053010391 pTLCb->atlSTAClients[*pucSTAId]->ucCurrentAC,
10392 pTLCb->atlSTAClients[*pucSTAId]->ucCurrentWeight));
Jeff Johnson295189b2012-06-20 16:38:30 -070010393
10394 return VOS_STATUS_SUCCESS;
10395}/* WLAN_TLGetNextTxIds */
10396
Jeff Johnson295189b2012-06-20 16:38:30 -070010397
10398
10399/*==========================================================================
10400 DEFAULT HANDLERS: Registered at initialization with TL
10401 ==========================================================================*/
10402
10403/*==========================================================================
10404
10405 FUNCTION WLANTL_MgmtFrmRxDefaultCb
10406
10407 DESCRIPTION
10408 Default Mgmt Frm rx callback: asserts all the time. If this function gets
10409 called it means there is no registered rx cb pointer for Mgmt Frm.
10410
10411 DEPENDENCIES
10412
10413 PARAMETERS
10414 Not used.
10415
10416 RETURN VALUE
10417
10418 VOS_STATUS_E_FAILURE: Always FAILURE.
10419
10420============================================================================*/
10421VOS_STATUS
10422WLANTL_MgmtFrmRxDefaultCb
10423(
10424 v_PVOID_t pvosGCtx,
10425 v_PVOID_t vosBuff
10426)
10427{
10428 if ( NULL != vosBuff )
10429 {
10430 TLLOGP(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_FATAL,
10431 "WLAN TL:Fatal failure: No registered Mgmt Frm client on pkt RX"));
10432 /* Drop packet */
10433 vos_pkt_return_packet((vos_pkt_t *)vosBuff);
10434 }
10435
Jeff Johnson295189b2012-06-20 16:38:30 -070010436 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
10437 "WLAN TL: No registered Mgmt Frm client on pkt RX. Load/Unload in progress, Ignore"));
Jeff Johnson295189b2012-06-20 16:38:30 -070010438
10439 return VOS_STATUS_E_FAILURE;
10440}/*WLANTL_MgmtFrmRxDefaultCb*/
10441
10442/*==========================================================================
10443
10444 FUNCTION WLANTL_STARxDefaultCb
10445
10446 DESCRIPTION
10447 Default BAP rx callback: asserts all the time. If this function gets
10448 called it means there is no registered rx cb pointer for BAP.
10449
10450 DEPENDENCIES
10451
10452 PARAMETERS
10453 Not used.
10454
10455 RETURN VALUE
10456
10457 VOS_STATUS_E_FAILURE: Always FAILURE.
10458
10459============================================================================*/
10460VOS_STATUS
10461WLANTL_BAPRxDefaultCb
10462(
10463 v_PVOID_t pvosGCtx,
10464 vos_pkt_t* vosDataBuff,
10465 WLANTL_BAPFrameEnumType frameType
10466)
10467{
10468 TLLOGP(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_FATAL,
10469 "WLAN TL:Fatal failure: No registered BAP client on BAP pkt RX"));
10470#ifndef BTAMP_TEST
10471 VOS_ASSERT(0);
10472#endif
10473 return VOS_STATUS_E_FAILURE;
10474}/*WLANTL_MgmtFrmRxDefaultCb*/
10475
10476/*==========================================================================
10477
10478 FUNCTION WLANTL_STARxDefaultCb
10479
10480 DESCRIPTION
10481 Default STA rx callback: asserts all the time. If this function gets
10482 called it means there is no registered rx cb pointer for station.
10483 (Mem corruption most likely, it should never happen)
10484
10485 DEPENDENCIES
10486
10487 PARAMETERS
10488 Not used.
10489
10490 RETURN VALUE
10491
10492 VOS_STATUS_E_FAILURE: Always FAILURE.
10493
10494============================================================================*/
10495VOS_STATUS
10496WLANTL_STARxDefaultCb
10497(
10498 v_PVOID_t pvosGCtx,
10499 vos_pkt_t* vosDataBuff,
10500 v_U8_t ucSTAId,
10501 WLANTL_RxMetaInfoType* pRxMetaInfo
10502)
10503{
10504 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
10505 "WLAN TL: No registered STA client rx cb for STAID: %d dropping pkt",
10506 ucSTAId));
10507 vos_pkt_return_packet(vosDataBuff);
10508 return VOS_STATUS_E_FAILURE;
10509}/*WLANTL_MgmtFrmRxDefaultCb*/
10510
10511
10512/*==========================================================================
10513
10514 FUNCTION WLANTL_STAFetchPktDefaultCb
10515
10516 DESCRIPTION
10517 Default fetch callback: asserts all the time. If this function gets
10518 called it means there is no registered fetch cb pointer for station.
10519 (Mem corruption most likely, it should never happen)
10520
10521 DEPENDENCIES
10522
10523 PARAMETERS
10524 Not used.
10525
10526 RETURN VALUE
10527
10528 VOS_STATUS_E_FAILURE: Always FAILURE.
10529
10530============================================================================*/
10531VOS_STATUS
10532WLANTL_STAFetchPktDefaultCb
10533(
10534 v_PVOID_t pvosGCtx,
10535 v_U8_t* pucSTAId,
10536 WLANTL_ACEnumType ucAC,
10537 vos_pkt_t** vosDataBuff,
10538 WLANTL_MetaInfoType* tlMetaInfo
10539)
10540{
10541 TLLOGP(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_FATAL,
10542 "WLAN TL:Fatal failure: No registered STA client on data pkt RX"));
10543 VOS_ASSERT(0);
10544 return VOS_STATUS_E_FAILURE;
10545}/*WLANTL_MgmtFrmRxDefaultCb*/
10546
10547/*==========================================================================
10548
10549 FUNCTION WLANTL_TxCompDefaultCb
10550
10551 DESCRIPTION
10552 Default tx complete handler. It will release the completed pkt to
10553 prevent memory leaks.
10554
10555 PARAMETERS
10556
10557 IN
10558 pvosGCtx: pointer to the global vos context; a handle to
10559 TL/HAL/PE/BAP/HDD control block can be extracted from
10560 its context
10561 vosDataBuff: pointer to the VOSS data buffer that was transmitted
10562 wTxSTAtus: status of the transmission
10563
10564
10565 RETURN VALUE
10566 The result code associated with performing the operation; please
10567 check vos_pkt_return_packet for possible error codes.
10568
10569 Please check vos_pkt_return_packet API for possible return values.
10570
10571============================================================================*/
10572VOS_STATUS
10573WLANTL_TxCompDefaultCb
10574(
10575 v_PVOID_t pvosGCtx,
10576 vos_pkt_t* vosDataBuff,
10577 VOS_STATUS wTxSTAtus
10578)
10579{
10580 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
10581 "WLAN TL:TXComp not registered, releasing pkt to prevent mem leak"));
10582 return vos_pkt_return_packet(vosDataBuff);
10583}/*WLANTL_TxCompDefaultCb*/
10584
10585
10586/*==========================================================================
10587 Cleanup functions
10588 ==========================================================================*/
10589
10590/*==========================================================================
10591
10592 FUNCTION WLANTL_CleanCB
10593
10594 DESCRIPTION
10595 Cleans TL control block
10596
10597 DEPENDENCIES
10598
10599 PARAMETERS
10600
10601 IN
10602 pTLCb: pointer to TL's control block
10603 ucEmpty: set if TL has to clean up the queues and release pedning pkts
10604
10605 RETURN VALUE
10606 The result code associated with performing the operation
10607
10608 VOS_STATUS_E_INVAL: invalid input parameters
10609 VOS_STATUS_SUCCESS: Everything is good :)
10610
10611 SIDE EFFECTS
10612
10613============================================================================*/
10614VOS_STATUS
10615WLANTL_CleanCB
10616(
10617 WLANTL_CbType* pTLCb,
10618 v_U8_t ucEmpty
10619)
10620{
10621 v_U8_t ucIndex;
10622 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
10623
10624 /*-------------------------------------------------------------------------
10625 Sanity check
10626 -------------------------------------------------------------------------*/
10627 if ( NULL == pTLCb )
10628 {
10629 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
10630 "WLAN TL:Invalid parameter sent on WLANTL_CleanCB"));
10631 return VOS_STATUS_E_INVAL;
10632 }
10633
10634 /* number of packets sent to BAL waiting for tx complete confirmation */
10635 pTLCb->usPendingTxCompleteCount = 0;
10636
10637 /* global suspend flag */
10638 vos_atomic_set_U8( &pTLCb->ucTxSuspended, 1);
10639
10640 /* resource flag */
10641 pTLCb->uResCount = 0;
10642
10643
10644 /*-------------------------------------------------------------------------
10645 Client stations
10646 -------------------------------------------------------------------------*/
10647 for ( ucIndex = 0; ucIndex < WLAN_MAX_STA_COUNT ; ucIndex++)
10648 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053010649 if(NULL != pTLCb->atlSTAClients[ucIndex])
10650 {
10651 WLANTL_CleanSTA( pTLCb->atlSTAClients[ucIndex], ucEmpty);
10652 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010653 }
10654
10655 /*-------------------------------------------------------------------------
10656 Management Frame client
10657 -------------------------------------------------------------------------*/
10658 pTLCb->tlMgmtFrmClient.ucExists = 0;
10659
10660 if ( ( 0 != ucEmpty) &&
10661 ( NULL != pTLCb->tlMgmtFrmClient.vosPendingDataBuff ))
10662 {
10663 vos_pkt_return_packet(pTLCb->tlMgmtFrmClient.vosPendingDataBuff);
10664 }
10665
10666 pTLCb->tlMgmtFrmClient.vosPendingDataBuff = NULL;
10667
10668 /* set to a default cb in order to prevent constant checking for NULL */
10669 pTLCb->tlMgmtFrmClient.pfnTlMgmtFrmRx = WLANTL_MgmtFrmRxDefaultCb;
10670
10671 /*-------------------------------------------------------------------------
10672 BT AMP client
10673 -------------------------------------------------------------------------*/
10674 pTLCb->tlBAPClient.ucExists = 0;
10675
10676 if (( 0 != ucEmpty) &&
10677 ( NULL != pTLCb->tlBAPClient.vosPendingDataBuff ))
10678 {
10679 vos_pkt_return_packet(pTLCb->tlBAPClient.vosPendingDataBuff);
10680 }
10681
10682 if (( 0 != ucEmpty) &&
10683 ( NULL != pTLCb->vosDummyBuf ))
10684 {
10685 vos_pkt_return_packet(pTLCb->vosDummyBuf);
10686 }
10687
10688 pTLCb->tlBAPClient.vosPendingDataBuff = NULL;
10689
10690 pTLCb->vosDummyBuf = NULL;
10691 pTLCb->vosTempBuf = NULL;
10692 pTLCb->ucCachedSTAId = WLAN_MAX_STA_COUNT;
10693
10694 /* set to a default cb in order to prevent constant checking for NULL */
10695 pTLCb->tlBAPClient.pfnTlBAPRx = WLANTL_BAPRxDefaultCb;
10696
10697 pTLCb->ucRegisteredStaId = WLAN_MAX_STA_COUNT;
10698
10699 return VOS_STATUS_SUCCESS;
10700
10701}/* WLANTL_CleanCB*/
10702
10703/*==========================================================================
10704
10705 FUNCTION WLANTL_CleanSTA
10706
10707 DESCRIPTION
10708 Cleans a station control block.
10709
10710 DEPENDENCIES
10711
10712 PARAMETERS
10713
10714 IN
10715 pvosGCtx: pointer to the global vos context; a handle to TL's
10716 control block can be extracted from its context
10717 ucEmpty: if set the queues and pending pkts will be emptyed
10718
10719 RETURN VALUE
10720 The result code associated with performing the operation
10721
10722 VOS_STATUS_E_INVAL: invalid input parameters
10723 VOS_STATUS_SUCCESS: Everything is good :)
10724
10725 SIDE EFFECTS
10726
10727============================================================================*/
10728VOS_STATUS
10729WLANTL_CleanSTA
10730(
10731 WLANTL_STAClientType* ptlSTAClient,
10732 v_U8_t ucEmpty
10733)
10734{
10735 v_U8_t ucIndex;
10736 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
10737
10738 /*-------------------------------------------------------------------------
10739 Sanity check
10740 -------------------------------------------------------------------------*/
10741 if ( NULL == ptlSTAClient )
10742 {
10743 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
10744 "WLAN TL:Invalid parameter sent on WLANTL_CleanSTA"));
10745 return VOS_STATUS_E_INVAL;
10746 }
10747
10748 /*------------------------------------------------------------------------
10749 Clear station from TL
10750 ------------------------------------------------------------------------*/
10751 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
10752 "WLAN TL: Clearing STA Client ID: %d, Empty flag: %d",
10753 ptlSTAClient->wSTADesc.ucSTAId, ucEmpty ));
10754
10755 ptlSTAClient->pfnSTARx = WLANTL_STARxDefaultCb;
10756 ptlSTAClient->pfnSTATxComp = WLANTL_TxCompDefaultCb;
10757 ptlSTAClient->pfnSTAFetchPkt = WLANTL_STAFetchPktDefaultCb;
10758
10759 ptlSTAClient->tlState = WLANTL_STA_INIT;
10760 ptlSTAClient->tlPri = WLANTL_STA_PRI_NORMAL;
10761
10762 vos_zero_macaddr( &ptlSTAClient->wSTADesc.vSTAMACAddress );
10763 vos_zero_macaddr( &ptlSTAClient->wSTADesc.vBSSIDforIBSS );
10764 vos_zero_macaddr( &ptlSTAClient->wSTADesc.vSelfMACAddress );
10765
10766 ptlSTAClient->wSTADesc.ucSTAId = 0;
10767 ptlSTAClient->wSTADesc.wSTAType = WLAN_STA_MAX;
10768
10769 ptlSTAClient->wSTADesc.ucQosEnabled = 0;
10770 ptlSTAClient->wSTADesc.ucAddRmvLLC = 0;
10771 ptlSTAClient->wSTADesc.ucSwFrameTXXlation = 0;
10772 ptlSTAClient->wSTADesc.ucSwFrameRXXlation = 0;
10773 ptlSTAClient->wSTADesc.ucProtectedFrame = 0;
10774
10775 /*-------------------------------------------------------------------------
10776 AMSDU information for the STA
10777 -------------------------------------------------------------------------*/
10778 if ( ( 0 != ucEmpty ) &&
10779 ( NULL != ptlSTAClient->vosAMSDUChainRoot ))
10780 {
Madan Mohan Koyyalamudic0e5bd82012-09-18 17:12:27 -070010781 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_FATAL,
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +053010782 "WLAN TL:Non NULL vosAMSDUChainRoot (=%p) on WLANTL_CleanSTA,"
Madan Mohan Koyyalamudic0e5bd82012-09-18 17:12:27 -070010783 "suspecting a memory corruption"));
10784
Jeff Johnson295189b2012-06-20 16:38:30 -070010785 }
10786
10787 ptlSTAClient->vosAMSDUChain = NULL;
10788 ptlSTAClient->vosAMSDUChainRoot = NULL;
10789
10790 vos_mem_zero( (v_PVOID_t)ptlSTAClient->aucMPDUHeader,
10791 WLANTL_MPDU_HEADER_LEN);
10792 ptlSTAClient->ucMPDUHeaderLen = 0;
10793
10794 /*-------------------------------------------------------------------------
10795 Reordering information for the STA
10796 -------------------------------------------------------------------------*/
10797 for ( ucIndex = 0; ucIndex < WLAN_MAX_TID ; ucIndex++)
10798 {
10799 if(0 == ptlSTAClient->atlBAReorderInfo[ucIndex].ucExists)
10800 {
10801 continue;
10802 }
10803 if(NULL != ptlSTAClient->atlBAReorderInfo[ucIndex].reorderBuffer)
10804 {
10805 ptlSTAClient->atlBAReorderInfo[ucIndex].reorderBuffer->isAvailable = VOS_TRUE;
10806 memset(&ptlSTAClient->atlBAReorderInfo[ucIndex].reorderBuffer->arrayBuffer[0], 0, WLANTL_MAX_WINSIZE * sizeof(v_PVOID_t));
10807 }
10808 vos_timer_destroy(&ptlSTAClient->atlBAReorderInfo[ucIndex].agingTimer);
10809 memset(&ptlSTAClient->atlBAReorderInfo[ucIndex], 0, sizeof(WLANTL_BAReorderType));
10810 }
10811
10812 /*-------------------------------------------------------------------------
10813 QOS information for the STA
10814 -------------------------------------------------------------------------*/
10815 ptlSTAClient->ucCurrentAC = WLANTL_AC_VO;
10816 ptlSTAClient->ucCurrentWeight = 0;
10817 ptlSTAClient->ucServicedAC = WLANTL_AC_BK;
10818
10819 vos_mem_zero( ptlSTAClient->aucACMask, sizeof(ptlSTAClient->aucACMask));
10820 vos_mem_zero( &ptlSTAClient->wUAPSDInfo, sizeof(ptlSTAClient->wUAPSDInfo));
10821
10822
10823 /*--------------------------------------------------------------------
10824 Stats info
10825 --------------------------------------------------------------------*/
10826 vos_mem_zero( ptlSTAClient->auRxCount,
10827 sizeof(ptlSTAClient->auRxCount[0])* WLAN_MAX_TID);
10828 vos_mem_zero( ptlSTAClient->auTxCount,
10829 sizeof(ptlSTAClient->auTxCount[0])* WLAN_MAX_TID);
10830 ptlSTAClient->rssiAvg = 0;
10831
10832 /*Tx not suspended and station fully registered*/
10833 vos_atomic_set_U8( &ptlSTAClient->ucTxSuspended, 0);
10834 vos_atomic_set_U8( &ptlSTAClient->ucNoMoreData, 1);
10835
10836 if ( 0 == ucEmpty )
10837 {
10838 ptlSTAClient->wSTADesc.ucUcastSig = WLAN_TL_INVALID_U_SIG;
10839 ptlSTAClient->wSTADesc.ucBcastSig = WLAN_TL_INVALID_B_SIG;
10840 }
10841
10842 ptlSTAClient->ucExists = 0;
10843
10844 /*--------------------------------------------------------------------
10845 Statistics info
10846 --------------------------------------------------------------------*/
10847 memset(&ptlSTAClient->trafficStatistics,
10848 0,
10849 sizeof(WLANTL_TRANSFER_STA_TYPE));
10850
10851 /*fix me!!: add new values from the TL Cb for cleanup */
10852 return VOS_STATUS_SUCCESS;
10853}/* WLANTL_CleanSTA */
10854
10855
10856/*==========================================================================
10857 FUNCTION WLANTL_EnableUAPSDForAC
10858
10859 DESCRIPTION
10860 Called by HDD to enable UAPSD. TL in turn calls WDA API to enable the
10861 logic in FW/SLM to start sending trigger frames. Previously TL had the
10862 trigger frame logic which later moved down to FW. Hence
10863 HDD -> TL -> WDA -> FW call flow.
10864
10865 DEPENDENCIES
10866 The TL must be initialized before this function can be called.
10867
10868 PARAMETERS
10869
10870 IN
10871 pvosGCtx: pointer to the global vos context; a handle to TL's
10872 control block can be extracted from its context
10873 ucSTAId: station Id
10874 ucAC: AC for which U-APSD is being enabled
10875 ucTid: TID for which U-APSD is setup
10876 ucUP: used to place in the trigger frame generation
10877 ucServiceInt: service interval used by TL to send trigger frames
10878 ucSuspendInt: suspend interval used by TL to determine that an
10879 app is idle and should start sending trigg frms less often
10880 wTSDir: direction of TSpec
10881
10882 RETURN VALUE
10883 The result code associated with performing the operation
10884
10885 VOS_STATUS_SUCCESS: Everything is good :)
10886
10887 SIDE EFFECTS
10888
10889============================================================================*/
10890VOS_STATUS
10891WLANTL_EnableUAPSDForAC
10892(
10893 v_PVOID_t pvosGCtx,
10894 v_U8_t ucSTAId,
10895 WLANTL_ACEnumType ucAC,
10896 v_U8_t ucTid,
10897 v_U8_t ucUP,
10898 v_U32_t uServiceInt,
10899 v_U32_t uSuspendInt,
10900 WLANTL_TSDirType wTSDir
10901)
10902{
10903
10904 WLANTL_CbType* pTLCb = NULL;
10905 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
10906 tUapsdInfo halUAPSDInfo;
10907 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
10908
10909 /*------------------------------------------------------------------------
10910 Sanity check
10911 Extract TL control block
10912 ------------------------------------------------------------------------*/
10913 pTLCb = VOS_GET_TL_CB(pvosGCtx);
10914 if (( NULL == pTLCb ) || WLANTL_STA_ID_INVALID( ucSTAId )
Gopichand Nakkala574f6d12013-06-27 19:38:43 +053010915 || WLANTL_AC_INVALID(ucAC))
Jeff Johnson295189b2012-06-20 16:38:30 -070010916 {
10917 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
10918 "WLAN TL:Invalid input params on WLANTL_EnableUAPSDForAC"
Gopichand Nakkala574f6d12013-06-27 19:38:43 +053010919 " TL: %p STA: %d AC: %d",
10920 pTLCb, ucSTAId, ucAC));
Jeff Johnson295189b2012-06-20 16:38:30 -070010921 return VOS_STATUS_E_FAULT;
10922 }
10923
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053010924 if ( NULL == pTLCb->atlSTAClients[ucSTAId] )
10925 {
10926 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
10927 "WLAN TL:Client Memory was not allocated on %s", __func__));
10928 return VOS_STATUS_E_FAILURE;
10929 }
10930
Jeff Johnson295189b2012-06-20 16:38:30 -070010931 /*Set this flag in order to remember that this is a trigger enabled AC*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053010932 pTLCb->atlSTAClients[ucSTAId]->wUAPSDInfo[ucAC].ucSet = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -070010933
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053010934#ifdef FEATURE_WLAN_TDLS
10935 if(pTLCb->atlSTAClients[ucSTAId]->wSTADesc.wSTAType != WLAN_STA_TDLS)
10936#endif
10937 {
10938 if( 0 == uServiceInt )
10939 {
10940 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
10941 "WLAN TL:Invalid input params on WLANTL_EnableUAPSDForAC"
10942 " SI: %d", uServiceInt ));
10943 return VOS_STATUS_E_FAULT;
10944 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010945
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053010946 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
10947 "WLAN TL:Enabling U-APSD in FW for STA: %d AC: %d SI: %d SPI: %d "
10948 "DI: %d",
10949 ucSTAId, ucAC, uServiceInt, uSuspendInt,
10950 pTLCb->tlConfigInfo.uDelayedTriggerFrmInt));
Jeff Johnson295189b2012-06-20 16:38:30 -070010951
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053010952 /*Save all info for HAL*/
10953 halUAPSDInfo.staidx = ucSTAId;
10954 halUAPSDInfo.ac = ucAC;
10955 halUAPSDInfo.up = ucUP;
10956 halUAPSDInfo.srvInterval = uServiceInt;
10957 halUAPSDInfo.susInterval = uSuspendInt;
10958 halUAPSDInfo.delayInterval = pTLCb->tlConfigInfo.uDelayedTriggerFrmInt;
10959
10960 /*Notify HAL*/
10961 vosStatus = WDA_EnableUapsdAcParams(pvosGCtx, ucSTAId, &halUAPSDInfo);
10962 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010963 return vosStatus;
10964
10965}/*WLANTL_EnableUAPSDForAC*/
10966
10967
10968/*==========================================================================
10969 FUNCTION WLANTL_DisableUAPSDForAC
10970
10971 DESCRIPTION
10972 Called by HDD to disable UAPSD. TL in turn calls WDA API to disable the
10973 logic in FW/SLM to stop sending trigger frames. Previously TL had the
10974 trigger frame logic which later moved down to FW. Hence
10975 HDD -> TL -> WDA -> FW call flow.
10976
10977 DEPENDENCIES
10978 The TL must be initialized before this function can be called.
10979
10980 PARAMETERS
10981
10982 IN
10983 pvosGCtx: pointer to the global vos context; a handle to TL's
10984 control block can be extracted from its context
10985 ucSTAId: station Id
10986 ucAC: AC for which U-APSD is being enabled
10987
10988
10989 RETURN VALUE
10990 The result code associated with performing the operation
10991
10992 VOS_STATUS_SUCCESS: Everything is good :)
10993
10994 SIDE EFFECTS
10995
10996============================================================================*/
10997VOS_STATUS
10998WLANTL_DisableUAPSDForAC
10999(
11000 v_PVOID_t pvosGCtx,
11001 v_U8_t ucSTAId,
11002 WLANTL_ACEnumType ucAC
11003)
11004{
11005 WLANTL_CbType* pTLCb;
11006 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
11007
11008 /*------------------------------------------------------------------------
11009 Sanity check
11010 Extract TL control block
11011 ------------------------------------------------------------------------*/
11012 pTLCb = VOS_GET_TL_CB(pvosGCtx);
11013 if (( NULL == pTLCb ) || WLANTL_STA_ID_INVALID( ucSTAId )
11014 || WLANTL_AC_INVALID(ucAC) )
11015 {
11016 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11017 "WLAN TL:Invalid input params on WLANTL_DisableUAPSDForAC"
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +053011018 " TL: %p STA: %d AC: %d", pTLCb, ucSTAId, ucAC ));
Jeff Johnson295189b2012-06-20 16:38:30 -070011019 return VOS_STATUS_E_FAULT;
11020 }
11021
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053011022 if ( NULL == pTLCb->atlSTAClients[ucSTAId] )
11023 {
11024 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11025 "WLAN TL:Client Memory was not allocated on %s", __func__));
11026 return VOS_STATUS_E_FAILURE;
11027 }
11028
Jeff Johnson295189b2012-06-20 16:38:30 -070011029 /*Reset this flag as this is no longer a trigger enabled AC*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053011030 pTLCb->atlSTAClients[ucSTAId]->wUAPSDInfo[ucAC].ucSet = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -070011031
11032 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
11033 "WLAN TL:Disabling U-APSD in FW for STA: %d AC: %d ",
11034 ucSTAId, ucAC));
11035
11036 /*Notify HAL*/
11037 WDA_DisableUapsdAcParams(pvosGCtx, ucSTAId, ucAC);
11038
11039 return VOS_STATUS_SUCCESS;
11040}/* WLANTL_DisableUAPSDForAC */
11041
11042#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
11043/*==========================================================================
11044 FUNCTION WLANTL_RegRSSIIndicationCB
11045
11046 DESCRIPTION Registration function to get notification if RSSI cross
11047 threshold.
11048 Client should register threshold, direction, and notification
11049 callback function pointer
11050
11051 DEPENDENCIES NONE
11052
11053 PARAMETERS in pAdapter - Global handle
11054 in rssiValue - RSSI threshold value
11055 in triggerEvent - Cross direction should be notified
11056 UP, DOWN, and CROSS
11057 in crossCBFunction - Notification CB Function
11058 in usrCtxt - user context
11059
11060 RETURN VALUE VOS_STATUS
11061
11062 SIDE EFFECTS NONE
11063
11064============================================================================*/
11065VOS_STATUS WLANTL_RegRSSIIndicationCB
11066(
11067 v_PVOID_t pAdapter,
11068 v_S7_t rssiValue,
11069 v_U8_t triggerEvent,
11070 WLANTL_RSSICrossThresholdCBType crossCBFunction,
11071 VOS_MODULE_ID moduleID,
11072 v_PVOID_t usrCtxt
11073)
11074{
11075 VOS_STATUS status = VOS_STATUS_SUCCESS;
11076
11077 status = WLANTL_HSRegRSSIIndicationCB(pAdapter,
11078 rssiValue,
11079 triggerEvent,
11080 crossCBFunction,
11081 moduleID,
11082 usrCtxt);
11083
11084 return status;
11085}
11086
11087/*==========================================================================
11088 FUNCTION WLANTL_DeregRSSIIndicationCB
11089
11090 DESCRIPTION Remove specific threshold from list
11091
11092 DEPENDENCIES NONE
11093
11094 PARAMETERS in pAdapter - Global handle
11095 in rssiValue - RSSI threshold value
11096 in triggerEvent - Cross direction should be notified
11097 UP, DOWN, and CROSS
11098
11099 RETURN VALUE VOS_STATUS
11100
11101 SIDE EFFECTS NONE
11102
11103============================================================================*/
11104VOS_STATUS WLANTL_DeregRSSIIndicationCB
11105(
11106 v_PVOID_t pAdapter,
11107 v_S7_t rssiValue,
11108 v_U8_t triggerEvent,
11109 WLANTL_RSSICrossThresholdCBType crossCBFunction,
11110 VOS_MODULE_ID moduleID
11111)
11112{
11113 VOS_STATUS status = VOS_STATUS_SUCCESS;
11114
11115 status = WLANTL_HSDeregRSSIIndicationCB(pAdapter,
11116 rssiValue,
11117 triggerEvent,
11118 crossCBFunction,
11119 moduleID);
11120 return status;
11121}
11122
11123/*==========================================================================
11124 FUNCTION WLANTL_SetAlpha
11125
11126 DESCRIPTION ALPLA is weight value to calculate AVG RSSI
11127 avgRSSI = (ALPHA * historyRSSI) + ((10 - ALPHA) * newRSSI)
11128 avgRSSI has (ALPHA * 10)% of history RSSI weight and
11129 (10 - ALPHA)% of newRSSI weight
11130 This portion is dynamically configurable.
11131 Default is ?
11132
11133 DEPENDENCIES NONE
11134
11135 PARAMETERS in pAdapter - Global handle
11136 in valueAlpah - ALPHA
11137
11138 RETURN VALUE VOS_STATUS
11139
11140 SIDE EFFECTS NONE
11141
11142============================================================================*/
11143VOS_STATUS WLANTL_SetAlpha
11144(
11145 v_PVOID_t pAdapter,
11146 v_U8_t valueAlpha
11147)
11148{
11149 VOS_STATUS status = VOS_STATUS_SUCCESS;
11150
11151 status = WLANTL_HSSetAlpha(pAdapter, valueAlpha);
11152 return status;
11153}
11154
11155/*==========================================================================
11156
11157 FUNCTION
11158
11159 DESCRIPTION
11160
11161 PARAMETERS
11162
11163 RETURN VALUE
11164
11165============================================================================*/
11166VOS_STATUS WLANTL_BMPSRSSIRegionChangedNotification
11167(
11168 v_PVOID_t pAdapter,
11169 tpSirRSSINotification pRSSINotification
11170)
11171{
11172 VOS_STATUS status = VOS_STATUS_SUCCESS;
11173
11174 status = WLANTL_HSBMPSRSSIRegionChangedNotification(pAdapter, pRSSINotification);
11175 return status;
11176}
11177
11178/*==========================================================================
11179 FUNCTION WLANTL_RegGetTrafficStatus
11180
11181 DESCRIPTION Registration function for traffic status monitoring
11182 During measure period count data frames.
11183 If frame count is larger then IDLE threshold set as traffic ON
11184 or OFF.
11185 And traffic status is changed send report to client with
11186 registered callback function
11187
11188 DEPENDENCIES NONE
11189
11190 PARAMETERS in pAdapter - Global handle
11191 in idleThreshold - Traffic on or off threshold
11192 in measurePeriod - Traffic state check period
11193 in trfficStatusCB - traffic status changed notification
11194 CB function
11195 in usrCtxt - user context
11196
11197 RETURN VALUE VOS_STATUS
11198
11199 SIDE EFFECTS NONE
11200
11201============================================================================*/
11202VOS_STATUS WLANTL_RegGetTrafficStatus
11203(
11204 v_PVOID_t pAdapter,
11205 v_U32_t idleThreshold,
11206 v_U32_t measurePeriod,
11207 WLANTL_TrafficStatusChangedCBType trfficStatusCB,
11208 v_PVOID_t usrCtxt
11209)
11210{
11211 VOS_STATUS status = VOS_STATUS_SUCCESS;
11212
11213 status = WLANTL_HSRegGetTrafficStatus(pAdapter,
11214 idleThreshold,
11215 measurePeriod,
11216 trfficStatusCB,
11217 usrCtxt);
11218 return status;
11219}
11220#endif
11221/*==========================================================================
11222 FUNCTION WLANTL_GetStatistics
11223
11224 DESCRIPTION Get traffic statistics for identified station
11225
11226 DEPENDENCIES NONE
11227
11228 PARAMETERS in pAdapter - Global handle
11229 in statType - specific statistics field to reset
11230 out statBuffer - traffic statistics buffer
11231
11232 RETURN VALUE VOS_STATUS
11233
11234 SIDE EFFECTS NONE
11235
11236============================================================================*/
11237VOS_STATUS WLANTL_GetStatistics
11238(
11239 v_PVOID_t pAdapter,
11240 WLANTL_TRANSFER_STA_TYPE *statBuffer,
11241 v_U8_t STAid
11242)
11243{
11244 WLANTL_CbType *pTLCb = VOS_GET_TL_CB(pAdapter);
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053011245 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070011246 VOS_STATUS status = VOS_STATUS_SUCCESS;
11247 WLANTL_TRANSFER_STA_TYPE *statistics = NULL;
11248
11249 /*------------------------------------------------------------------------
11250 Sanity check
11251 Extract TL control block
11252 ------------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053011253 if ( NULL == pTLCb )
Jeff Johnson295189b2012-06-20 16:38:30 -070011254 {
11255 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11256 "WLAN TL:Invalid TL pointer on WLANTL_GetStatistics"));
11257 return VOS_STATUS_E_FAULT;
11258 }
11259
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053011260 pClientSTA = pTLCb->atlSTAClients[STAid];
11261
11262 if ( NULL == pClientSTA )
11263 {
11264 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11265 "WLAN TL:Client Memory was not allocated on %s", __func__));
11266 return VOS_STATUS_E_FAILURE;
11267 }
11268
11269 if(0 == pClientSTA->ucExists)
Jeff Johnson295189b2012-06-20 16:38:30 -070011270 {
11271 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11272 "WLAN TL: %d STA ID does not exist", STAid));
11273 return VOS_STATUS_E_INVAL;
11274 }
11275
11276 if(NULL == statBuffer)
11277 {
11278 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11279 "WLAN TL:Invalid TL statistics buffer pointer on WLANTL_GetStatistics"));
11280 return VOS_STATUS_E_INVAL;
11281 }
11282
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053011283 statistics = &pClientSTA->trafficStatistics;
Jeff Johnson295189b2012-06-20 16:38:30 -070011284 memcpy(statBuffer, statistics, sizeof(WLANTL_TRANSFER_STA_TYPE));
11285
11286 return status;
11287}
11288
11289/*==========================================================================
11290 FUNCTION WLANTL_ResetStatistics
11291
11292 DESCRIPTION Reset statistics structure for identified station ID
11293 Reset means set values as 0
11294
11295 DEPENDENCIES NONE
11296
11297 PARAMETERS in pAdapter - Global handle
11298 in statType - specific statistics field to reset
11299
11300 RETURN VALUE VOS_STATUS
11301
11302 SIDE EFFECTS NONE
11303
11304============================================================================*/
11305VOS_STATUS WLANTL_ResetStatistics
11306(
11307 v_PVOID_t pAdapter,
11308 v_U8_t STAid
11309)
11310{
11311 WLANTL_CbType *pTLCb = VOS_GET_TL_CB(pAdapter);
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053011312 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070011313 VOS_STATUS status = VOS_STATUS_SUCCESS;
11314 WLANTL_TRANSFER_STA_TYPE *statistics = NULL;
11315
11316 /*------------------------------------------------------------------------
11317 Sanity check
11318 Extract TL control block
11319 ------------------------------------------------------------------------*/
11320 if (NULL == pTLCb)
11321 {
11322 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11323 "WLAN TL:Invalid TL pointer on WLANTL_GetStatistics"));
11324 return VOS_STATUS_E_FAULT;
11325 }
11326
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053011327 pClientSTA = pTLCb->atlSTAClients[STAid];
11328
11329 if ( NULL == pClientSTA )
11330 {
11331 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11332 "WLAN TL:Client Memory was not allocated on %s", __func__));
11333 return VOS_STATUS_E_FAILURE;
11334 }
11335
11336 if(0 == pClientSTA->ucExists)
Jeff Johnson295189b2012-06-20 16:38:30 -070011337 {
11338 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11339 "WLAN TL: %d STA ID does not exist", STAid));
11340 return VOS_STATUS_E_INVAL;
11341 }
11342
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053011343 statistics = &pClientSTA->trafficStatistics;
Jeff Johnson295189b2012-06-20 16:38:30 -070011344 vos_mem_zero((v_VOID_t *)statistics, sizeof(WLANTL_TRANSFER_STA_TYPE));
11345
11346 return status;
11347}
11348
11349/*==========================================================================
11350 FUNCTION WLANTL_GetSpecStatistic
11351
11352 DESCRIPTION Get specific field within statistics structure for
11353 identified station ID
11354
11355 DEPENDENCIES NONE
11356
11357 PARAMETERS in pAdapter - Global handle
11358 in statType - specific statistics field to reset
11359 in STAid - Station ID
11360 out buffer - Statistic value
11361
11362 RETURN VALUE VOS_STATUS
11363
11364 SIDE EFFECTS NONE
11365
11366============================================================================*/
11367VOS_STATUS WLANTL_GetSpecStatistic
11368(
11369 v_PVOID_t pAdapter,
11370 WLANTL_TRANSFER_STATIC_TYPE statType,
11371 v_U32_t *buffer,
11372 v_U8_t STAid
11373)
11374{
11375 WLANTL_CbType *pTLCb = VOS_GET_TL_CB(pAdapter);
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053011376 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070011377 VOS_STATUS status = VOS_STATUS_SUCCESS;
11378 WLANTL_TRANSFER_STA_TYPE *statistics = NULL;
11379
11380 /*------------------------------------------------------------------------
11381 Sanity check
11382 Extract TL control block
11383 ------------------------------------------------------------------------*/
11384 if (NULL == pTLCb)
11385 {
11386 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11387 "WLAN TL:Invalid TL pointer on WLANTL_GetStatistics"));
11388 return VOS_STATUS_E_FAULT;
11389 }
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053011390 pClientSTA = pTLCb->atlSTAClients[STAid];
Jeff Johnson295189b2012-06-20 16:38:30 -070011391
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053011392 if ( NULL == pClientSTA )
11393 {
11394 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11395 "WLAN TL:Client Memory was not allocated on %s", __func__));
11396 return VOS_STATUS_E_FAILURE;
11397 }
11398
11399 if(0 == pClientSTA->ucExists)
Jeff Johnson295189b2012-06-20 16:38:30 -070011400 {
11401 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11402 "WLAN TL: %d STA ID does not exist", STAid));
11403 return VOS_STATUS_E_INVAL;
11404 }
11405
11406 if(NULL == buffer)
11407 {
11408 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11409 "WLAN TL:Invalid TL statistic buffer pointer on WLANTL_GetStatistics"));
11410 return VOS_STATUS_E_INVAL;
11411 }
11412
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053011413 statistics = &pClientSTA->trafficStatistics;
Jeff Johnson295189b2012-06-20 16:38:30 -070011414 switch(statType)
11415 {
11416 case WLANTL_STATIC_TX_UC_FCNT:
11417 *buffer = statistics->txUCFcnt;
11418 break;
11419
11420 case WLANTL_STATIC_TX_MC_FCNT:
11421 *buffer = statistics->txMCFcnt;
11422 break;
11423
11424 case WLANTL_STATIC_TX_BC_FCNT:
11425 *buffer = statistics->txBCFcnt;
11426 break;
11427
11428 case WLANTL_STATIC_TX_UC_BCNT:
11429 *buffer = statistics->txUCBcnt;
11430 break;
11431
11432 case WLANTL_STATIC_TX_MC_BCNT:
11433 *buffer = statistics->txMCBcnt;
11434 break;
11435
11436 case WLANTL_STATIC_TX_BC_BCNT:
11437 *buffer = statistics->txBCBcnt;
11438 break;
11439
11440 case WLANTL_STATIC_RX_UC_FCNT:
11441 *buffer = statistics->rxUCFcnt;
11442 break;
11443
11444 case WLANTL_STATIC_RX_MC_FCNT:
11445 *buffer = statistics->rxMCFcnt;
11446 break;
11447
11448 case WLANTL_STATIC_RX_BC_FCNT:
11449 *buffer = statistics->rxBCFcnt;
11450 break;
11451
11452 case WLANTL_STATIC_RX_UC_BCNT:
11453 *buffer = statistics->rxUCBcnt;
11454 break;
11455
11456 case WLANTL_STATIC_RX_MC_BCNT:
11457 *buffer = statistics->rxMCBcnt;
11458 break;
11459
11460 case WLANTL_STATIC_RX_BC_BCNT:
11461 *buffer = statistics->rxBCBcnt;
11462 break;
11463
11464 case WLANTL_STATIC_RX_BCNT:
11465 *buffer = statistics->rxBcnt;
11466 break;
11467
11468 case WLANTL_STATIC_RX_BCNT_CRC_OK:
11469 *buffer = statistics->rxBcntCRCok;
11470 break;
11471
11472 case WLANTL_STATIC_RX_RATE:
11473 *buffer = statistics->rxRate;
11474 break;
11475
11476 default:
11477 *buffer = 0;
11478 status = VOS_STATUS_E_INVAL;
11479 break;
11480 }
11481
11482
11483 return status;
11484}
11485
11486/*==========================================================================
11487 FUNCTION WLANTL_ResetSpecStatistic
11488
11489 DESCRIPTION Reset specific field within statistics structure for
11490 identified station ID
11491 Reset means set as 0
11492
11493 DEPENDENCIES NONE
11494
11495 PARAMETERS in pAdapter - Global handle
11496 in statType - specific statistics field to reset
11497 in STAid - Station ID
11498
11499 RETURN VALUE VOS_STATUS
11500
11501 SIDE EFFECTS NONE
11502
11503============================================================================*/
11504VOS_STATUS WLANTL_ResetSpecStatistic
11505(
11506 v_PVOID_t pAdapter,
11507 WLANTL_TRANSFER_STATIC_TYPE statType,
11508 v_U8_t STAid
11509)
11510{
11511 WLANTL_CbType *pTLCb = VOS_GET_TL_CB(pAdapter);
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053011512 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070011513 VOS_STATUS status = VOS_STATUS_SUCCESS;
11514 WLANTL_TRANSFER_STA_TYPE *statistics = NULL;
11515
11516 /*------------------------------------------------------------------------
11517 Sanity check
11518 Extract TL control block
11519 ------------------------------------------------------------------------*/
11520 if (NULL == pTLCb)
11521 {
11522 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11523 "WLAN TL:Invalid TL pointer on WLANTL_GetStatistics"));
11524 return VOS_STATUS_E_FAULT;
11525 }
11526
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053011527 pClientSTA = pTLCb->atlSTAClients[STAid];
11528
11529 if ( NULL == pClientSTA )
11530 {
11531 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11532 "WLAN TL:Client Memory was not allocated on %s", __func__));
11533 return VOS_STATUS_E_FAILURE;
11534 }
11535
11536 if(0 == pClientSTA->ucExists)
Jeff Johnson295189b2012-06-20 16:38:30 -070011537 {
11538 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11539 "WLAN TL: %d STA ID does not exist", STAid));
11540 return VOS_STATUS_E_INVAL;
11541 }
11542
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053011543 statistics = &pClientSTA->trafficStatistics;
Jeff Johnson295189b2012-06-20 16:38:30 -070011544 switch(statType)
11545 {
11546 case WLANTL_STATIC_TX_UC_FCNT:
11547 statistics->txUCFcnt = 0;
11548 break;
11549
11550 case WLANTL_STATIC_TX_MC_FCNT:
11551 statistics->txMCFcnt = 0;
11552 break;
11553
11554 case WLANTL_STATIC_TX_BC_FCNT:
11555 statistics->txBCFcnt = 0;
11556 break;
11557
11558 case WLANTL_STATIC_TX_UC_BCNT:
11559 statistics->txUCBcnt = 0;
11560 break;
11561
11562 case WLANTL_STATIC_TX_MC_BCNT:
11563 statistics->txMCBcnt = 0;
11564 break;
11565
11566 case WLANTL_STATIC_TX_BC_BCNT:
11567 statistics->txBCBcnt = 0;
11568 break;
11569
11570 case WLANTL_STATIC_RX_UC_FCNT:
11571 statistics->rxUCFcnt = 0;
11572 break;
11573
11574 case WLANTL_STATIC_RX_MC_FCNT:
11575 statistics->rxMCFcnt = 0;
11576 break;
11577
11578 case WLANTL_STATIC_RX_BC_FCNT:
11579 statistics->rxBCFcnt = 0;
11580 break;
11581
11582 case WLANTL_STATIC_RX_UC_BCNT:
11583 statistics->rxUCBcnt = 0;
11584 break;
11585
11586 case WLANTL_STATIC_RX_MC_BCNT:
11587 statistics->rxMCBcnt = 0;
11588 break;
11589
11590 case WLANTL_STATIC_RX_BC_BCNT:
11591 statistics->rxBCBcnt = 0;
11592 break;
11593
11594 case WLANTL_STATIC_RX_BCNT:
11595 statistics->rxBcnt = 0;
11596 break;
11597
11598 case WLANTL_STATIC_RX_BCNT_CRC_OK:
11599 statistics->rxBcntCRCok = 0;
11600 break;
11601
11602 case WLANTL_STATIC_RX_RATE:
11603 statistics->rxRate = 0;
11604 break;
11605
11606 default:
11607 status = VOS_STATUS_E_INVAL;
11608 break;
11609 }
11610
11611 return status;
11612}
11613
11614
11615/*==========================================================================
11616
11617 FUNCTION
11618
11619 DESCRIPTION Read RSSI value out of a RX BD
11620
11621 PARAMETERS: Caller must validate all parameters
11622
11623 RETURN VALUE
11624
11625============================================================================*/
11626VOS_STATUS WLANTL_ReadRSSI
11627(
11628 v_PVOID_t pAdapter,
11629 v_PVOID_t pBDHeader,
11630 v_U8_t STAid
11631)
11632{
11633 WLANTL_CbType *tlCtxt = VOS_GET_TL_CB(pAdapter);
11634 v_S7_t currentRSSI, currentRSSI0, currentRSSI1;
11635
11636
11637 if(NULL == tlCtxt)
11638 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070011639 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR, "%s Invalid TL handle", __func__));
Jeff Johnson295189b2012-06-20 16:38:30 -070011640 return VOS_STATUS_E_INVAL;
11641 }
11642
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053011643 if ( NULL == tlCtxt->atlSTAClients[STAid] )
11644 {
11645 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11646 "WLAN TL:Client Memory was not allocated on %s", __func__));
11647 return VOS_STATUS_E_FAILURE;
11648 }
11649
Jeff Johnson295189b2012-06-20 16:38:30 -070011650 currentRSSI0 = WLANTL_GETRSSI0(pBDHeader);
11651 currentRSSI1 = WLANTL_GETRSSI1(pBDHeader);
11652 currentRSSI = (currentRSSI0 > currentRSSI1) ? currentRSSI0 : currentRSSI1;
11653
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053011654 tlCtxt->atlSTAClients[STAid]->rssiAvg = currentRSSI;
Jeff Johnson295189b2012-06-20 16:38:30 -070011655
11656 return VOS_STATUS_SUCCESS;
11657}
11658
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053011659/*==========================================================================
11660
11661 FUNCTION
11662
11663 DESCRIPTION Read SNR value out of a RX BD
11664
11665 PARAMETERS: Caller must validate all parameters
11666
11667 RETURN VALUE
11668
11669============================================================================*/
11670VOS_STATUS WLANTL_ReadSNR
11671(
11672 v_PVOID_t pAdapter,
11673 v_PVOID_t pBDHeader,
11674 v_U8_t STAid
11675)
11676{
11677 WLANTL_CbType *tlCtxt = VOS_GET_TL_CB(pAdapter);
11678 v_S7_t currentSNR;
11679
11680
11681 if (NULL == tlCtxt)
11682 {
11683 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11684 "%s Invalid TL handle", __func__));
11685 return VOS_STATUS_E_INVAL;
11686 }
11687
11688 if (NULL == tlCtxt->atlSTAClients[STAid])
11689 {
11690 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11691 "WLAN TL:Client Memory was not allocated on %s", __func__));
11692 return VOS_STATUS_E_FAILURE;
11693 }
11694
11695 currentSNR = WLANTL_GETSNR(pBDHeader);
11696
11697 TLLOG2(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
11698 "%s: snrsum: %d snridx: %d prevsnravg: %d",
11699 __func__,
11700 tlCtxt->atlSTAClients[STAid]->snrSum,
11701 tlCtxt->atlSTAClients[STAid]->snrIdx,
11702 tlCtxt->atlSTAClients[STAid]->prevSnrAvg));
11703
11704 /* The SNR returned for all purposes is the average SNR over
11705 * WLANTL_MAX_SNR_DATA_SMAPLES.When data samples
11706 * > WLANTL_MAX_SNR_DATA_SAMPLES are obtained,
11707 * store the average of the samples in prevSnrAvg
11708 * and start a new averaging window. The prevSnrAvg is used when
11709 * enough data samples are not available when applications
11710 * actually query for SNR.
11711 *
11712 * SEE: WLANTL_GetSnr()
11713 */
11714 if (tlCtxt->atlSTAClients[STAid]->snrIdx >= WLANTL_MAX_SNR_DATA_SAMPLES)
11715 {
11716 tlCtxt->atlSTAClients[STAid]->prevSnrAvg =
11717 tlCtxt->atlSTAClients[STAid]->snrSum /
11718 tlCtxt->atlSTAClients[STAid]->snrIdx;
11719 tlCtxt->atlSTAClients[STAid]->snrSum = 0;
11720 tlCtxt->atlSTAClients[STAid]->snrIdx = 0;
11721 }
11722 tlCtxt->atlSTAClients[STAid]->snrSum += currentSNR;
11723 tlCtxt->atlSTAClients[STAid]->snrIdx += 1;
11724
11725 return VOS_STATUS_SUCCESS;
11726}
Jeff Johnson295189b2012-06-20 16:38:30 -070011727
11728/*
11729 DESCRIPTION
11730 TL returns the weight currently maintained in TL.
11731 IN
11732 pvosGCtx: pointer to the global vos context; a handle to TL's
11733 or SME's control block can be extracted from its context
11734
11735 OUT
11736 pACWeights: Caller allocated memory for filling in weights
11737
11738 RETURN VALUE VOS_STATUS
11739*/
11740VOS_STATUS
11741WLANTL_GetACWeights
11742(
11743 v_PVOID_t pvosGCtx,
11744 v_U8_t* pACWeights
11745)
11746{
11747 WLANTL_CbType* pTLCb = NULL;
11748 v_U8_t ucIndex;
11749 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
11750
11751 /*------------------------------------------------------------------------
11752 Sanity check
11753 ------------------------------------------------------------------------*/
11754 if ( NULL == pACWeights )
11755 {
11756 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11757 "WLAN TL:Invalid parameter sent on WLANTL_GetACWeights"));
11758 return VOS_STATUS_E_INVAL;
11759 }
11760
11761 /*------------------------------------------------------------------------
11762 Extract TL control block and check existance
11763 ------------------------------------------------------------------------*/
11764 pTLCb = VOS_GET_TL_CB(pvosGCtx);
11765 if ( NULL == pTLCb )
11766 {
11767 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11768 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_GetACWeights"));
11769 return VOS_STATUS_E_FAULT;
11770 }
11771 for ( ucIndex = 0; ucIndex < WLANTL_MAX_AC ; ucIndex++)
11772 {
11773 pACWeights[ucIndex] = pTLCb->tlConfigInfo.ucAcWeights[ucIndex];
11774 }
11775
11776 return VOS_STATUS_SUCCESS;
11777}
11778
11779
11780
11781/*
11782 DESCRIPTION
11783 Change the weight currently maintained by TL.
11784 IN
11785 pvosGCtx: pointer to the global vos context; a handle to TL's
11786 or SME's control block can be extracted from its context
11787 pACWeights: Caller allocated memory contain the weights to use
11788
11789
11790 RETURN VALUE VOS_STATUS
11791*/
11792VOS_STATUS
11793WLANTL_SetACWeights
11794(
11795 v_PVOID_t pvosGCtx,
11796 v_U8_t* pACWeights
11797)
11798{
11799 WLANTL_CbType* pTLCb = NULL;
11800 v_U8_t ucIndex;
11801 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
11802
11803 /*------------------------------------------------------------------------
11804 Sanity check
11805 ------------------------------------------------------------------------*/
11806 if ( NULL == pACWeights )
11807 {
11808 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11809 "WLAN TL:Invalid parameter sent on WLANTL_GetACWeights"));
11810 return VOS_STATUS_E_INVAL;
11811 }
11812
11813 /*------------------------------------------------------------------------
11814 Extract TL control block and check existance
11815 ------------------------------------------------------------------------*/
11816 pTLCb = VOS_GET_TL_CB(pvosGCtx);
11817 if ( NULL == pTLCb )
11818 {
11819 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11820 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_GetACWeights"));
11821 return VOS_STATUS_E_FAULT;
11822 }
11823 for ( ucIndex = 0; ucIndex < WLANTL_MAX_AC ; ucIndex++)
11824 {
11825 pTLCb->tlConfigInfo.ucAcWeights[ucIndex] = pACWeights[ucIndex];
11826 }
11827
11828 return VOS_STATUS_SUCCESS;
11829}
11830
11831
11832/*==========================================================================
11833
11834 FUNCTION
11835
11836 DESCRIPTION
11837
11838 PARAMETERS
11839
11840 RETURN VALUE
11841
11842============================================================================*/
11843void WLANTL_PowerStateChangedCB
11844(
11845 v_PVOID_t pAdapter,
11846 tPmcState newState
11847)
11848{
11849 WLANTL_CbType *tlCtxt = VOS_GET_TL_CB(pAdapter);
11850
11851 if (NULL == tlCtxt)
11852 {
11853 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +053011854 "%s: Invalid TL Control Block", __func__ );
Jeff Johnson295189b2012-06-20 16:38:30 -070011855 return;
11856 }
11857
11858 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO, "Power state changed, new state is %d", newState );
11859 switch(newState)
11860 {
11861 case FULL_POWER:
11862 tlCtxt->isBMPS = VOS_FALSE;
11863 break;
11864
11865 case BMPS:
11866#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
11867 WLANTL_SetFWRSSIThresholds(pAdapter);
11868#endif
11869
11870 tlCtxt->isBMPS = VOS_TRUE;
11871 break;
11872
11873 case IMPS:
11874 case LOW_POWER:
11875 case REQUEST_BMPS:
11876 case REQUEST_FULL_POWER:
11877 case REQUEST_IMPS:
11878 case STOPPED:
11879 case REQUEST_START_UAPSD:
11880 case REQUEST_STOP_UAPSD:
11881 case UAPSD:
11882 case REQUEST_STANDBY:
11883 case STANDBY:
11884 case REQUEST_ENTER_WOWL:
11885 case REQUEST_EXIT_WOWL:
11886 case WOWL:
11887 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN, "Not handle this events %d", newState ));
11888 break;
11889
11890 default:
11891 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR, "Not a valid event %d", newState ));
11892 break;
11893 }
11894
11895 return;
11896}
11897/*==========================================================================
11898 FUNCTION WLANTL_GetEtherType
11899
11900 DESCRIPTION Extract Ether type information from the BD
11901
11902 DEPENDENCIES NONE
11903
11904 PARAMETERS in aucBDHeader - BD header
11905 in vosDataBuff - data buffer
11906 in ucMPDUHLen - MPDU header length
11907 out pUsEtherType - pointer to Ethertype
11908
11909 RETURN VALUE VOS_STATUS_SUCCESS : if the EtherType is successfully extracted
11910 VOS_STATUS_FAILURE : if the EtherType extraction failed and
11911 the packet was dropped
11912
11913 SIDE EFFECTS NONE
11914
11915============================================================================*/
11916static VOS_STATUS WLANTL_GetEtherType
11917(
11918 v_U8_t * aucBDHeader,
11919 vos_pkt_t * vosDataBuff,
11920 v_U8_t ucMPDUHLen,
11921 v_U16_t * pUsEtherType
11922)
11923{
11924 v_U8_t ucOffset;
11925 v_U16_t usEtherType = *pUsEtherType;
11926 v_SIZE_t usLLCSize = sizeof(usEtherType);
11927 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
11928
11929 /*------------------------------------------------------------------------
11930 Check if LLC is present - if not, TL is unable to determine type
11931 ------------------------------------------------------------------------*/
11932 if ( VOS_FALSE == WDA_IS_RX_LLC_PRESENT( aucBDHeader ) )
11933 {
11934 ucOffset = WLANTL_802_3_HEADER_LEN - sizeof(usEtherType);
11935 }
11936 else
11937 {
11938 ucOffset = ucMPDUHLen + WLANTL_LLC_PROTO_TYPE_OFFSET;
11939 }
11940
11941 /*------------------------------------------------------------------------
11942 Extract LLC type
11943 ------------------------------------------------------------------------*/
11944 vosStatus = vos_pkt_extract_data( vosDataBuff, ucOffset,
11945 (v_PVOID_t)&usEtherType, &usLLCSize);
11946
11947 if (( VOS_STATUS_SUCCESS != vosStatus ) ||
11948 ( sizeof(usEtherType) != usLLCSize ))
11949
11950 {
11951 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11952 "WLAN TL:Error extracting Ether type from data packet"));
11953 /* Drop packet */
11954 vos_pkt_return_packet(vosDataBuff);
11955 vosStatus = VOS_STATUS_E_FAILURE;
11956 }
11957 else
11958 {
11959 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
11960 "WLAN TL:Ether type retrieved before endianess conv: %d",
11961 usEtherType));
11962
11963 usEtherType = vos_be16_to_cpu(usEtherType);
11964 *pUsEtherType = usEtherType;
11965
11966 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
11967 "WLAN TL:Ether type retrieved: %d", usEtherType));
11968 }
11969
11970 return vosStatus;
11971}
11972
Jeff Johnson295189b2012-06-20 16:38:30 -070011973/*==========================================================================
11974 FUNCTION WLANTL_GetSoftAPStatistics
11975
11976 DESCRIPTION Collect the cumulative statistics for all Softap stations
11977
11978 DEPENDENCIES NONE
11979
11980 PARAMETERS in pvosGCtx - Pointer to the global vos context
11981 bReset - If set TL statistics will be cleared after reading
11982 out statsSum - pointer to collected statistics
11983
11984 RETURN VALUE VOS_STATUS_SUCCESS : if the Statistics are successfully extracted
11985
11986 SIDE EFFECTS NONE
11987
11988============================================================================*/
11989VOS_STATUS WLANTL_GetSoftAPStatistics(v_PVOID_t pAdapter, WLANTL_TRANSFER_STA_TYPE *statsSum, v_BOOL_t bReset)
11990{
11991 v_U8_t i = 0;
11992 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
11993 WLANTL_CbType *pTLCb = VOS_GET_TL_CB(pAdapter);
11994 WLANTL_TRANSFER_STA_TYPE statBufferTemp;
11995 vos_mem_zero((v_VOID_t *)&statBufferTemp, sizeof(WLANTL_TRANSFER_STA_TYPE));
11996 vos_mem_zero((v_VOID_t *)statsSum, sizeof(WLANTL_TRANSFER_STA_TYPE));
11997
11998
11999 if ( NULL == pTLCb )
12000 {
12001 return VOS_STATUS_E_FAULT;
12002 }
12003
12004 // Sum up all the statistics for stations of Soft AP from TL
12005 for (i = 0; i < WLAN_MAX_STA_COUNT; i++)
12006 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053012007 if ( NULL == pTLCb->atlSTAClients[i])
12008 {
12009 continue;
12010 }
12011 if (pTLCb->atlSTAClients[i]->wSTADesc.wSTAType == WLAN_STA_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -070012012 {
12013 vosStatus = WLANTL_GetStatistics(pAdapter, &statBufferTemp, i);// Can include staId 1 because statistics not collected for it
12014
12015 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
12016 return VOS_STATUS_E_FAULT;
12017
12018 // Add to the counters
12019 statsSum->txUCFcnt += statBufferTemp.txUCFcnt;
12020 statsSum->txMCFcnt += statBufferTemp.txMCFcnt;
12021 statsSum->txBCFcnt += statBufferTemp.txBCFcnt;
12022 statsSum->txUCBcnt += statBufferTemp.txUCBcnt;
12023 statsSum->txMCBcnt += statBufferTemp.txMCBcnt;
12024 statsSum->txBCBcnt += statBufferTemp.txBCBcnt;
12025 statsSum->rxUCFcnt += statBufferTemp.rxUCFcnt;
12026 statsSum->rxMCFcnt += statBufferTemp.rxMCFcnt;
12027 statsSum->rxBCFcnt += statBufferTemp.rxBCFcnt;
12028 statsSum->rxUCBcnt += statBufferTemp.rxUCBcnt;
12029 statsSum->rxMCBcnt += statBufferTemp.rxMCBcnt;
12030 statsSum->rxBCBcnt += statBufferTemp.rxBCBcnt;
12031
12032 if (bReset)
12033 {
12034 vosStatus = WLANTL_ResetStatistics(pAdapter, i);
12035 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
12036 return VOS_STATUS_E_FAULT;
12037 }
12038 }
12039 }
12040
12041 return vosStatus;
12042}
Mohit Khanna698ba2a2012-12-04 15:08:18 -080012043#ifdef FEATURE_WLAN_TDLS_INTERNAL
12044/*==========================================================================
12045 FUNCTION WLANTL_GetEtherType_2
12046
12047 DESCRIPTION Extract Ether type information from the BD
12048
12049 DEPENDENCIES NONE
12050
12051 PARAMETERS in aucBDHeader - BD header
12052 in vosDataBuff - data buffer
12053 in ucMPDUHLen - MPDU header length
12054 out pUsEtherType - pointer to Ethertype
12055
12056 RETURN VALUE VOS_STATUS_SUCCESS : if the EtherType is successfully extracted
12057 VOS_STATUS_FAILURE : if the EtherType extraction failed and
12058 the packet was dropped
12059
12060 SIDE EFFECTS NONE
12061
12062============================================================================*/
12063static VOS_STATUS WLANTL_GetEtherType_2
12064(
12065 v_U8_t * aucBDHeader,
12066 vos_pkt_t * vosDataBuff,
12067 v_U8_t ucMPDUHLen,
12068 v_U16_t * pUsEtherType
12069)
12070{
12071 v_U8_t ucOffset;
12072 v_U16_t usEtherType = *pUsEtherType;
12073 v_SIZE_t usLLCSize = sizeof(usEtherType);
12074 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
12075 //v_U8_t ucLLCHeader;
12076 v_U8_t ucMPDUHOffset ;
12077 /*------------------------------------------------------------------------
12078 Check if LLC is present - if not, TL is unable to determine type
12079 ------------------------------------------------------------------------*/
12080 //ucMPDUHOffset = (v_U8_t)WLANHAL_RX_BD_GET_MPDU_H_OFFSET(aucBDHeader) ;
12081 //ucLLCHeader = (v_U8_t)WLANHAL_RX_BD_GET_LLC(aucBDHeader);
12082 ucMPDUHOffset = (v_U8_t)WDA_GET_RX_MPDU_HEADER_OFFSET(aucBDHeader);
12083
12084 if ( VOS_TRUE == WDA_IS_RX_LLC_PRESENT(aucBDHeader) )
12085 {
12086 ucOffset = ucMPDUHOffset + WLANTL_802_3_HEADER_LEN - sizeof(usEtherType);
12087 }
12088 else
12089 {
12090 ucOffset = WLANHAL_RX_BD_HEADER_SIZE + ucMPDUHLen
12091 + WLANTL_LLC_PROTO_TYPE_OFFSET;
12092 }
12093
12094 /*------------------------------------------------------------------------
12095 Extract LLC type
12096 ------------------------------------------------------------------------*/
12097 vosStatus = vos_pkt_extract_data( vosDataBuff, ucOffset,
12098 (v_PVOID_t)&usEtherType, &usLLCSize);
12099
12100 /* TODO: Do it in better way */
12101 if(vos_be16_to_cpu(usEtherType) == 0x890d)
12102 {
12103 VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
12104 ("TDLS frame llc %x \n"), vos_be16_to_cpu(usEtherType)) ;
12105 }
12106
12107 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
12108 "WLAN TL:Ether type retrieved before endianess conv: %d",
12109 usEtherType);
12110
12111 usEtherType = vos_be16_to_cpu(usEtherType);
12112 *pUsEtherType = usEtherType;
12113
12114 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
12115 "WLAN TL:Ether type retrieved: %d", usEtherType);
12116
12117 return vosStatus;
12118}
12119#endif /* FEATURE_WLAN_TDLS */
12120
Jeff Johnson295189b2012-06-20 16:38:30 -070012121/*===============================================================================
12122 FUNCTION WLANTL_IsReplayPacket
12123
12124 DESCRIPTION This function does replay check for valid stations
12125
12126 DEPENDENCIES Validity of replay check must be done before the function
12127 is called
12128
12129 PARAMETERS currentReplayCounter current replay counter taken from RX BD
12130 previousReplayCounter previous replay counter taken from TL CB
12131
12132 RETRUN VOS_TRUE packet is a replay packet
12133 VOS_FALSE packet is not a replay packet
12134
12135 SIDE EFFECTS none
12136 ===============================================================================*/
12137v_BOOL_t
12138WLANTL_IsReplayPacket
12139(
12140 v_U64_t ullcurrentReplayCounter,
12141 v_U64_t ullpreviousReplayCounter
12142)
12143{
12144 /* Do the replay check by comparing previous received replay counter with
12145 current received replay counter*/
12146 if(ullpreviousReplayCounter < ullcurrentReplayCounter)
12147 {
12148 /* Valid packet not replay */
12149 return VOS_FALSE;
12150 }
12151 else
12152 {
12153
12154 /* Current packet number is less than or equal to previuos received
12155 packet no, this means current packet is replay packet */
12156 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
12157 "WLAN TL: Replay packet found with replay counter :[0x%llX]",ullcurrentReplayCounter);
12158
12159 return VOS_TRUE;
12160 }
12161}
12162
12163#if 0
12164/*===============================================================================
12165 FUNCTION WLANTL_GetReplayCounterFromRxBD
12166
12167 DESCRIPTION This function extracts 48-bit replay packet number from RX BD
12168
12169 DEPENDENCIES Validity of replay check must be done before the function
12170 is called
12171
12172 PARAMETERS pucRxHeader pointer to RX BD header
12173
12174 RETRUN v_U64_t Packet number extarcted from RX BD
12175
12176 SIDE EFFECTS none
12177 ===============================================================================*/
12178v_U64_t
12179WLANTL_GetReplayCounterFromRxBD
12180(
12181 v_U8_t *pucRxBDHeader
12182)
12183{
12184/* 48-bit replay counter is created as follows
12185 from RX BD 6 byte PMI command:
12186 Addr : AES/TKIP
12187 0x38 : pn3/tsc3
12188 0x39 : pn2/tsc2
12189 0x3a : pn1/tsc1
12190 0x3b : pn0/tsc0
12191
12192 0x3c : pn5/tsc5
12193 0x3d : pn4/tsc4 */
12194
12195#ifdef ANI_BIG_BYTE_ENDIAN
12196 v_U64_t ullcurrentReplayCounter = 0;
12197 /* Getting 48-bit replay counter from the RX BD */
12198 ullcurrentReplayCounter = WLANHAL_RX_BD_GET_PMICMD_20TO23(pucRxBDHeader);
12199 ullcurrentReplayCounter <<= 16;
12200 ullcurrentReplayCounter |= (( WLANHAL_RX_BD_GET_PMICMD_24TO25(pucRxBDHeader) & 0xFFFF0000) >> 16);
12201 return ullcurrentReplayCounter;
12202#else
12203 v_U64_t ullcurrentReplayCounter = 0;
12204 /* Getting 48-bit replay counter from the RX BD */
12205 ullcurrentReplayCounter = (WLANHAL_RX_BD_GET_PMICMD_24TO25(pucRxBDHeader) & 0x0000FFFF);
12206 ullcurrentReplayCounter <<= 32;
12207 ullcurrentReplayCounter |= WLANHAL_RX_BD_GET_PMICMD_20TO23(pucRxBDHeader);
12208 return ullcurrentReplayCounter;
12209#endif
12210}
12211#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070012212
12213/*===============================================================================
12214 FUNCTION WLANTL_PostResNeeded
12215
12216 DESCRIPTION This function posts message to TL to reserve BD/PDU memory
12217
12218 DEPENDENCIES None
12219
12220 PARAMETERS pvosGCtx
12221
12222 RETURN None
12223
12224 SIDE EFFECTS none
12225 ===============================================================================*/
12226
12227void WLANTL_PostResNeeded(v_PVOID_t pvosGCtx)
12228{
12229 vos_msg_t vosMsg;
12230
12231 vosMsg.reserved = 0;
12232 vosMsg.bodyptr = NULL;
12233 vosMsg.type = WLANTL_TX_RES_NEEDED;
12234 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
12235 "WLAN TL: BD/PDU available interrupt received, Posting message to TL");
12236 if(!VOS_IS_STATUS_SUCCESS(vos_tx_mq_serialize( VOS_MQ_ID_TL, &vosMsg)))
12237 {
12238 VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070012239 " %s fails to post message", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070012240 }
12241}
12242
12243/*===============================================================================
12244 FUNCTION WLANTL_UpdateRssiBmps
12245
12246 DESCRIPTION This function updates the TL's RSSI (in BMPS mode)
12247
12248 DEPENDENCIES None
12249
12250 PARAMETERS
12251
12252 pvosGCtx VOS context VOS Global context
12253 staId Station ID Station ID
12254 rssi RSSI (BMPS mode) RSSI in BMPS mode
12255
12256 RETURN None
12257
12258 SIDE EFFECTS none
12259 ===============================================================================*/
12260
12261void WLANTL_UpdateRssiBmps(v_PVOID_t pvosGCtx, v_U8_t staId, v_S7_t rssi)
12262{
12263 WLANTL_CbType* pTLCb = VOS_GET_TL_CB(pvosGCtx);
12264
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053012265 if (NULL != pTLCb && NULL != pTLCb->atlSTAClients[staId])
Jeff Johnson295189b2012-06-20 16:38:30 -070012266 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053012267 pTLCb->atlSTAClients[staId]->rssiAvgBmps = rssi;
Jeff Johnson295189b2012-06-20 16:38:30 -070012268 }
12269}
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053012270
12271/*===============================================================================
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053012272 FUNCTION WLANTL_UpdateSnrBmps
12273
12274 DESCRIPTION This function updates the TL's SNR (in BMPS mode)
12275
12276 DEPENDENCIES None
12277
12278 PARAMETERS
12279
12280 pvosGCtx VOS context VOS Global context
12281 staId Station ID Station ID
12282 snr SNR (BMPS mode) SNR in BMPS mode
12283
12284 RETURN None
12285
12286 SIDE EFFECTS none
12287 ===============================================================================*/
12288
12289void WLANTL_UpdateSnrBmps(v_PVOID_t pvosGCtx, v_U8_t staId, v_S7_t snr)
12290{
12291 WLANTL_CbType* pTLCb = VOS_GET_TL_CB(pvosGCtx);
12292
12293 if (NULL != pTLCb && NULL != pTLCb->atlSTAClients[staId])
12294 {
12295 pTLCb->atlSTAClients[staId]->snrAvgBmps = snr;
12296 }
12297}
12298
12299/*===============================================================================
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053012300 FUNCTION WLANTL_UpdateLinkCapacity
12301
12302 DESCRIPTION This function updates the STA's Link Capacity in TL
12303
12304 DEPENDENCIES None
12305
12306 PARAMETERS
12307
12308 pvosGCtx VOS context VOS Global context
12309 staId Station ID Station ID
12310 linkCapacity linkCapacity Link Capacity
12311
12312 RETURN None
12313
12314 SIDE EFFECTS none
12315 ===============================================================================*/
12316
12317void WLANTL_UpdateLinkCapacity(v_PVOID_t pvosGCtx, v_U8_t staId, v_U32_t linkCapacity)
12318{
12319 WLANTL_CbType* pTLCb = VOS_GET_TL_CB(pvosGCtx);
12320
12321 if (NULL != pTLCb && NULL != pTLCb->atlSTAClients[staId])
12322 {
12323 pTLCb->atlSTAClients[staId]->linkCapacity = linkCapacity;
12324 }
12325}
12326
12327
12328/*===========================================================================
12329
12330 FUNCTION WLANTL_GetSTALinkCapacity
12331
12332 DESCRIPTION
12333
12334 Returns Link Capacity of a particular STA.
12335
12336 DEPENDENCIES
12337
12338 A station must have been registered before its state can be retrieved.
12339
12340
12341 PARAMETERS
12342
12343 IN
12344 pvosGCtx: pointer to the global vos context; a handle to TL's
12345 control block can be extracted from its context
12346 ucSTAId: identifier of the station
12347
12348 OUT
12349 plinkCapacity: the current link capacity the connection to
12350 the given station
12351
12352
12353 RETURN VALUE
12354
12355 The result code associated with performing the operation
12356
12357 VOS_STATUS_E_INVAL: Input parameters are invalid
12358 VOS_STATUS_E_FAULT: Station ID is outside array boundaries or pointer to
12359 TL cb is NULL ; access would cause a page fault
12360 VOS_STATUS_E_EXISTS: Station was not registered
12361 VOS_STATUS_SUCCESS: Everything is good :)
12362
12363 SIDE EFFECTS
12364
12365============================================================================*/
12366VOS_STATUS
12367WLANTL_GetSTALinkCapacity
12368(
12369 v_PVOID_t pvosGCtx,
12370 v_U8_t ucSTAId,
12371 v_U32_t *plinkCapacity
12372)
12373{
12374 WLANTL_CbType* pTLCb = NULL;
12375 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
12376
12377 /*------------------------------------------------------------------------
12378 Sanity check
12379 ------------------------------------------------------------------------*/
12380 if ( NULL == plinkCapacity )
12381 {
12382 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
12383 FL("WLAN TL:Invalid parameter")));
12384 return VOS_STATUS_E_INVAL;
12385 }
12386
12387 if ( WLANTL_STA_ID_INVALID( ucSTAId ) )
12388 {
12389 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
12390 FL("WLAN TL:Invalid station id")));
12391 return VOS_STATUS_E_FAULT;
12392 }
12393
12394 /*------------------------------------------------------------------------
12395 Extract TL control block and check existance
12396 ------------------------------------------------------------------------*/
12397 pTLCb = VOS_GET_TL_CB(pvosGCtx);
12398 if ( NULL == pTLCb )
12399 {
12400 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
12401 FL("WLAN TL:Invalid TL pointer from pvosGCtx")));
12402 return VOS_STATUS_E_FAULT;
12403 }
12404
12405 if ( NULL == pTLCb->atlSTAClients[ucSTAId] )
12406 {
12407 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
12408 FL("WLAN TL:Client Memory was not allocated")));
12409 return VOS_STATUS_E_FAILURE;
12410 }
12411
12412 if ( 0 == pTLCb->atlSTAClients[ucSTAId]->ucExists )
12413 {
12414 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
12415 FL("WLAN TL:Station was not previously registered")));
12416 return VOS_STATUS_E_EXISTS;
12417 }
12418
12419 /*------------------------------------------------------------------------
12420 Get STA state
12421 ------------------------------------------------------------------------*/
12422 *plinkCapacity = pTLCb->atlSTAClients[ucSTAId]->linkCapacity;
12423
12424 return VOS_STATUS_SUCCESS;
12425}/* WLANTL_GetSTALinkCapacity */