blob: d695bfa12ca2ba9267e8ae01b4b2b27be8bc48d2 [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
Jeff Johnson295189b2012-06-20 16:38:30 -0700181
182#ifdef VOLANS_PERF
183#define WLANTL_BD_PDU_INTERRUPT_ENABLE_THRESHOLD 120
184#define WLANTL_BD_PDU_INTERRUPT_GET_THRESHOLD 120
185
186/* TL BD/PDU threshold to enable interrupt */
187int bdPduInterruptEnableThreshold = WLANTL_BD_PDU_INTERRUPT_ENABLE_THRESHOLD;
188int bdPduInterruptGetThreshold = WLANTL_BD_PDU_INTERRUPT_GET_THRESHOLD;
189#endif /* VOLANS_PERF */
190
191/*-----------------------------------*
192 | Type(2b) | Sub-type(4b) |
193 *-----------------------------------*/
194#define WLANTL_IS_DATA_FRAME(_type_sub) \
195 ( WLANTL_DATA_FRAME_TYPE == ( (_type_sub) & 0x30 ))
196
197#define WLANTL_IS_QOS_DATA_FRAME(_type_sub) \
198 (( WLANTL_DATA_FRAME_TYPE == ( (_type_sub) & 0x30 )) && \
199 ( WLANTL_80211_DATA_QOS_SUBTYPE == ( (_type_sub) & 0xF )))
200
201#define WLANTL_IS_MGMT_FRAME(_type_sub) \
202 ( WLANTL_MGMT_FRAME_TYPE == ( (_type_sub) & 0x30 ))
203
204#define WLANTL_IS_CTRL_FRAME(_type_sub) \
205 ( WLANTL_CTRL_FRAME_TYPE == ( (_type_sub) & 0x30 ))
206
Mohit Khanna698ba2a2012-12-04 15:08:18 -0800207#ifdef FEATURE_WLAN_TDLS
208#define WLANTL_IS_TDLS_FRAME(_eth_type) \
209 ( WLANTL_LLC_TDLS_TYPE == ( _eth_type))
210#endif
211
Jeff Johnson295189b2012-06-20 16:38:30 -0700212/*MAX Allowed len processed by TL - MAx MTU + 802.3 header + BD+DXE+XTL*/
Madan Mohan Koyyalamudia53c4dc2012-11-13 10:35:42 -0800213#define WLANTL_MAX_ALLOWED_LEN (1514 + 100)
Jeff Johnson295189b2012-06-20 16:38:30 -0700214
215#define WLANTL_MASK_AC 0x03
216
Jeff Johnson295189b2012-06-20 16:38:30 -0700217//some flow_control define
218//LWM mode will be enabled for this station if the egress/ingress falls below this ratio
219#define WLANTL_LWM_EGRESS_INGRESS_THRESHOLD (0.75)
220
221//Get enough sample to do the LWM related calculation
222#define WLANTL_LWM_INGRESS_SAMPLE_THRESHOLD (64)
223
224//Maximal on-fly packet per station in LWM mode
225#define WLANTL_STA_BMU_THRESHOLD_MAX (256)
226
227#define WLANTL_AC_MASK (0x7)
Gopichand Nakkala976e3252013-01-03 15:45:56 -0800228#define WLANTL_STAID_OFFSET (0x6)
Jeff Johnson295189b2012-06-20 16:38:30 -0700229
230/* UINT32 type endian swap */
231#define SWAP_ENDIAN_UINT32(a) ((a) = ((a) >> 0x18 ) |(((a) & 0xFF0000) >> 0x08) | \
232 (((a) & 0xFF00) << 0x08) | (((a) & 0xFF) << 0x18))
233
234
235
236/*--------------------------------------------------------------------------
237 TID to AC mapping in TL
238 --------------------------------------------------------------------------*/
239const v_U8_t WLANTL_TID_2_AC[WLAN_MAX_TID] = { WLANTL_AC_BE,
240 WLANTL_AC_BK,
241 WLANTL_AC_BK,
242 WLANTL_AC_BE,
243 WLANTL_AC_VI,
244 WLANTL_AC_VI,
245 WLANTL_AC_VO,
246 WLANTL_AC_VO };
247
248/*----------------------------------------------------------------------------
249 * Type Declarations
250 * -------------------------------------------------------------------------*/
251#define TL_LITTLE_BIT_ENDIAN
252
253typedef struct
254{
255
256#ifndef TL_LITTLE_BIT_ENDIAN
257
258 v_U8_t subType :4;
259 v_U8_t type :2;
260 v_U8_t protVer :2;
261
262 v_U8_t order :1;
263 v_U8_t wep :1;
264 v_U8_t moreData :1;
265 v_U8_t powerMgmt :1;
266 v_U8_t retry :1;
267 v_U8_t moreFrag :1;
268 v_U8_t fromDS :1;
269 v_U8_t toDS :1;
270
271#else
272
273 v_U8_t protVer :2;
274 v_U8_t type :2;
275 v_U8_t subType :4;
276
277 v_U8_t toDS :1;
278 v_U8_t fromDS :1;
279 v_U8_t moreFrag :1;
280 v_U8_t retry :1;
281 v_U8_t powerMgmt :1;
282 v_U8_t moreData :1;
283 v_U8_t wep :1;
284 v_U8_t order :1;
285
286#endif
287
288} WLANTL_MACFCType;
289
290/* 802.11 header */
291typedef struct
292{
293 /* Frame control field */
294 WLANTL_MACFCType wFrmCtrl;
295
296 /* Duration ID */
297 v_U16_t usDurationId;
298
299 /* Address 1 field */
300 v_U8_t vA1[VOS_MAC_ADDR_SIZE];
301
302 /* Address 2 field */
303 v_U8_t vA2[VOS_MAC_ADDR_SIZE];
304
305 /* Address 3 field */
306 v_U8_t vA3[VOS_MAC_ADDR_SIZE];
307
308 /* Sequence control field */
309 v_U16_t usSeqCtrl;
310
311 // Find the size of the mandatory header size.
312#define WLAN80211_MANDATORY_HEADER_SIZE \
313 (sizeof(WLANTL_MACFCType) + sizeof(v_U16_t) + \
314 (3 * (sizeof(v_U8_t) * VOS_MAC_ADDR_SIZE)) + \
315 sizeof(v_U16_t))
316
317 /* Optional A4 address */
318 v_U8_t optvA4[VOS_MAC_ADDR_SIZE];
319
320 /* Optional QOS control field */
321 v_U16_t usQosCtrl;
322}WLANTL_80211HeaderType;
323
324/* 802.3 header */
325typedef struct
326{
327 /* Destination address field */
328 v_U8_t vDA[VOS_MAC_ADDR_SIZE];
329
330 /* Source address field */
331 v_U8_t vSA[VOS_MAC_ADDR_SIZE];
332
333 /* Length field */
334 v_U16_t usLenType;
335}WLANTL_8023HeaderType;
336
337/*----------------------------------------------------------------------------
338 * Global Data Definitions
339 * -------------------------------------------------------------------------*/
340#define WLAN_TL_INVALID_U_SIG 255
341#define WLAN_TL_INVALID_B_SIG 255
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +0530342#define ENTER() VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO, "Enter:%s", __func__)
343
Jeff Johnson295189b2012-06-20 16:38:30 -0700344#define WLAN_TL_AC_ARRAY_2_MASK( _pSTA, _ucACMask, i ) \
345 do\
346 {\
347 _ucACMask = 0; \
348 for ( i = 0; i < WLANTL_MAX_AC; i++ ) \
349 { \
350 if ( 0 != (_pSTA)->aucACMask[i] ) \
351 { \
352 _ucACMask |= ( 1 << i ); \
353 } \
354 } \
355 } while (0);
356
357/*----------------------------------------------------------------------------
358 * Static Variable Definitions
359 * -------------------------------------------------------------------------*/
360
361/*----------------------------------------------------------------------------
362 * Static Function Declarations and Definitions
363 * -------------------------------------------------------------------------*/
364
365static VOS_STATUS
366WLANTL_GetEtherType
367(
368 v_U8_t * aucBDHeader,
369 vos_pkt_t * vosDataBuff,
370 v_U8_t ucMPDUHLen,
371 v_U16_t * usEtherType
372);
373
Mohit Khanna698ba2a2012-12-04 15:08:18 -0800374#ifdef FEATURE_WLAN_TDLS_INTERNAL
375/* FIXME_MUST: during TDLS integration to main/latest, WLANTL_GetEtherType() conflicts.
376But there is difference. existing WLANTL_GetEtherType() expects vosDataBuff->offset points to MPDU Header,
377wherease TDLS expect vosDataBuff->offset should still points to RxBd.
378So far, data frmae stripped RxBD and passed to data frame handler.
379(RxBd should not be stripped in case TDLS, because it will be eventually routed to mgmt packet
380handler, where RX BD should be preserved)
381To avoid breaking existing functionality, for now, I temporarily rename to
382WLANTL_GetEtherType_2(). Eventually this function should be removed and merged to WLANTL_GetEtherType()
383*/
384static VOS_STATUS
385WLANTL_GetEtherType_2
386(
387 v_U8_t * aucBDHeader,
388 vos_pkt_t * vosDataBuff,
389 v_U8_t ucMPDUHLen,
390 v_U16_t * usEtherType
391);
392#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700393#ifdef FEATURE_WLAN_WAPI
394/*---------------------------------------------------------------------------
395 * Adding a global variable to be used when doing frame translation in TxAuth
396 * state so as to not set the protected bit to 1 in the case of WAI frames
397 *---------------------------------------------------------------------------*/
Madan Mohan Koyyalamudidfd6aa82012-10-18 20:18:43 -0700398v_U8_t gUcIsWai;
Jeff Johnson295189b2012-06-20 16:38:30 -0700399#endif
400
401/*----------------------------------------------------------------------------
402 * Externalized Function Definitions
403* -------------------------------------------------------------------------*/
404
405/*----------------------------------------------------------------------------
406 * Function Declarations and Documentation
407 * -------------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +0530408/*==========================================================================
409
410 FUNCTION WLANTL_FreeClientMemory
411
412 DESCRIPTION
413 It frees up the memory allocated to all the STA clients in TLCB block
414 Can be called inside Close, Stop or when some FAULT occurs
415
416 DEPENDENCIES
417
418 PARAMETERS
419
420 IN
421 pClientSTA: Pointer to the global client pointer array
422
423 RETURN VALUE
424
425 SIDE EFFECTS
426
427============================================================================*/
428void WLANTL_FreeClientMemory
429(WLANTL_STAClientType* pClientSTA[WLAN_MAX_STA_COUNT])
430{
431 v_U32_t i = 0;
432 for(i =0; i < WLAN_MAX_STA_COUNT; i++)
433 {
434 if( NULL != pClientSTA[i] )
435 {
436 vos_mem_free(pClientSTA[i]);
437 }
438 pClientSTA[i] = NULL;
439 }
440 return;
441}
Jeff Johnson295189b2012-06-20 16:38:30 -0700442
443/*==========================================================================
444
445 FUNCTION WLANTL_Open
446
447 DESCRIPTION
448 Called by HDD at driver initialization. TL will initialize all its
449 internal resources and will wait for the call to start to register
450 with the other modules.
451
452 DEPENDENCIES
453
454 PARAMETERS
455
456 IN
457 pvosGCtx: pointer to the global vos context; a handle to TL's
458 control block can be extracted from its context
459 pTLConfig: TL Configuration
460
461 RETURN VALUE
462 The result code associated with performing the operation
463
464 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a page
465 fault
466 VOS_STATUS_SUCCESS: Everything is good :)
467
468 SIDE EFFECTS
469
470============================================================================*/
471VOS_STATUS
472WLANTL_Open
473(
474 v_PVOID_t pvosGCtx,
475 WLANTL_ConfigInfoType* pTLConfig
476)
477{
478 WLANTL_CbType* pTLCb = NULL;
479 v_U8_t ucIndex;
480 tHalHandle smeContext;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +0530481 v_U32_t i = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700482#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
483 VOS_STATUS status = VOS_STATUS_SUCCESS;
484#endif
485 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
486
487 /*------------------------------------------------------------------------
488 Sanity check
489 Extract TL control block
490 ------------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +0530491 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -0700492 vos_alloc_context( pvosGCtx, VOS_MODULE_ID_TL,
493 (void*)&pTLCb, sizeof(WLANTL_CbType));
494
495 pTLCb = VOS_GET_TL_CB(pvosGCtx);
496 if (( NULL == pTLCb ) || ( NULL == pTLConfig ) )
497 {
Madan Mohan Koyyalamudic0e5bd82012-09-18 17:12:27 -0700498 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_FATAL,
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +0530499 "WLAN TL: Invalid input pointer on WLANTL_Open TL %p Config %p", pTLCb, pTLConfig ));
Jeff Johnson295189b2012-06-20 16:38:30 -0700500 return VOS_STATUS_E_FAULT;
501 }
502
Madan Mohan Koyyalamudic0e5bd82012-09-18 17:12:27 -0700503 /* Set the default log level to VOS_TRACE_LEVEL_ERROR */
504 vos_trace_setLevel(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR);
505
Jeff Johnson295189b2012-06-20 16:38:30 -0700506 smeContext = vos_get_context(VOS_MODULE_ID_SME, pvosGCtx);
507 if ( NULL == smeContext )
508 {
509 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700510 "%s: Invalid smeContext", __func__));
Jeff Johnson295189b2012-06-20 16:38:30 -0700511 return VOS_STATUS_E_FAULT;
512 }
513
514 /* Zero out the memory so we are OK, when CleanCB is called.*/
515 vos_mem_zero((v_VOID_t *)pTLCb, sizeof(WLANTL_CbType));
516
517 /*------------------------------------------------------------------------
518 Clean up TL control block, initialize all values
519 ------------------------------------------------------------------------*/
520 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
521 "WLAN TL:WLANTL_Open"));
522
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +0530523 for ( i =0; i<WLAN_MAX_STA_COUNT; i++ )
Jeff Johnson295189b2012-06-20 16:38:30 -0700524 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +0530525 if ( i < WLAN_NON32_STA_COUNT )
526 {
527 pTLCb->atlSTAClients[i] = vos_mem_malloc(sizeof(WLANTL_STAClientType));
528 /* Allocating memory for LEGACY STA COUNT so as to avoid regression issues. */
529 if ( NULL == pTLCb->atlSTAClients[i] )
530 {
531 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR, "WLAN TL: StaClient allocation failed"));
532 WLANTL_FreeClientMemory(pTLCb->atlSTAClients);
533 vos_free_context(pvosGCtx, VOS_MODULE_ID_TL, pTLCb);
534 return VOS_STATUS_E_FAULT;
535 }
536 vos_mem_zero((v_VOID_t *) pTLCb->atlSTAClients[i], sizeof(WLANTL_STAClientType));
537 }
538 else
539 {
540 pTLCb->atlSTAClients[i] = NULL;
541 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700542 }
543
Jeff Johnson295189b2012-06-20 16:38:30 -0700544 pTLCb->reorderBufferPool = vos_mem_malloc(sizeof(WLANTL_REORDER_BUFFER_T) * WLANTL_MAX_BA_SESSION);
545 if (NULL == pTLCb->reorderBufferPool)
546 {
547 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 +0530548 WLANTL_FreeClientMemory(pTLCb->atlSTAClients);
Jeff Johnson295189b2012-06-20 16:38:30 -0700549 vos_free_context(pvosGCtx, VOS_MODULE_ID_TL, pTLCb);
550 return VOS_STATUS_E_FAULT;
Jeff Johnson295189b2012-06-20 16:38:30 -0700551 }
552
553 vos_mem_zero((v_VOID_t *)pTLCb->reorderBufferPool, sizeof(WLANTL_REORDER_BUFFER_T) * WLANTL_MAX_BA_SESSION);
554
555 WLANTL_CleanCB(pTLCb, 0 /*do not empty*/);
556
557 for ( ucIndex = 0; ucIndex < WLANTL_MAX_AC ; ucIndex++)
558 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +0530559 pTLCb->tlConfigInfo.ucAcWeights[ucIndex] = pTLConfig->ucAcWeights[ucIndex];
Jeff Johnson295189b2012-06-20 16:38:30 -0700560 }
561
Jeff Johnson295189b2012-06-20 16:38:30 -0700562 // scheduling init to be the last one of previous round
563 pTLCb->uCurServedAC = WLANTL_AC_BK;
564 pTLCb->ucCurLeftWeight = 1;
565 pTLCb->ucCurrentSTA = WLAN_MAX_STA_COUNT-1;
566
567#if 0
568 //flow control field init
569 vos_mem_zero(&pTLCb->tlFCInfo, sizeof(tFcTxParams_type));
570 //bit 0: set (Bd/pdu count) bit 1: set (request station PS change notification)
571 pTLCb->tlFCInfo.fcConfig = 0x1;
572#endif
573
574 pTLCb->vosTxFCBuf = NULL;
575 pTLCb->tlConfigInfo.uMinFramesProcThres =
576 pTLConfig->uMinFramesProcThres;
Jeff Johnson295189b2012-06-20 16:38:30 -0700577
Sunil Ravid5406f22013-01-22 00:18:31 -0800578#ifdef FEATURE_WLAN_TDLS
579 pTLCb->ucTdlsPeerCount = 0;
580#endif
581
Jeff Johnson295189b2012-06-20 16:38:30 -0700582 pTLCb->tlConfigInfo.uDelayedTriggerFrmInt =
583 pTLConfig->uDelayedTriggerFrmInt;
584
585 /*------------------------------------------------------------------------
586 Allocate internal resources
587 ------------------------------------------------------------------------*/
588 vos_pkt_get_packet(&pTLCb->vosDummyBuf, VOS_PKT_TYPE_RX_RAW, 1, 1,
589 1/*true*/,NULL, NULL);
590
591 WLANTL_InitBAReorderBuffer(pvosGCtx);
592#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
593 /* Initialize Handoff support modue
594 * RSSI measure and Traffic state monitoring */
595 status = WLANTL_HSInit(pvosGCtx);
596 if(!VOS_IS_STATUS_SUCCESS(status))
597 {
598 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
599 "Handoff support module init fail"));
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +0530600 WLANTL_FreeClientMemory(pTLCb->atlSTAClients);
Jeff Johnson295189b2012-06-20 16:38:30 -0700601 vos_mem_free(pTLCb->reorderBufferPool);
602 vos_free_context(pvosGCtx, VOS_MODULE_ID_TL, pTLCb);
603 return status;
604 }
605#endif
606
607 pTLCb->isBMPS = VOS_FALSE;
608 pmcRegisterDeviceStateUpdateInd( smeContext,
609 WLANTL_PowerStateChangedCB, pvosGCtx );
610
611 return VOS_STATUS_SUCCESS;
612}/* WLANTL_Open */
613
614/*==========================================================================
615
616 FUNCTION WLANTL_Start
617
618 DESCRIPTION
619 Called by HDD as part of the overall start procedure. TL will use this
620 call to register with BAL as a transport layer entity.
621
622 DEPENDENCIES
623
624 PARAMETERS
625
626 IN
627 pvosGCtx: pointer to the global vos context; a handle to TL's
628 control block can be extracted from its context
629
630 RETURN VALUE
631 The result code associated with performing the operation
632
633 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a page
634 fault
635 VOS_STATUS_SUCCESS: Everything is good :)
636
637 Other codes can be returned as a result of a BAL failure; see BAL API
638 for more info
639
640 SIDE EFFECTS
641
642============================================================================*/
643VOS_STATUS
644WLANTL_Start
645(
646 v_PVOID_t pvosGCtx
647)
648{
649 WLANTL_CbType* pTLCb = NULL;
650 v_U32_t uResCount = WDA_TLI_MIN_RES_DATA;
651 VOS_STATUS vosStatus;
652 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
653
654 /*------------------------------------------------------------------------
655 Sanity check
656 Extract TL control block
657 ------------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +0530658 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -0700659 pTLCb = VOS_GET_TL_CB(pvosGCtx);
660 if ( NULL == pTLCb )
661 {
662 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
663 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_Start"));
664 return VOS_STATUS_E_FAULT;
665 }
666
667 /*------------------------------------------------------------------------
668 Register with WDA as transport layer client
669 Request resources for tx from bus
670 ------------------------------------------------------------------------*/
671 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
672 "WLAN TL:WLAN TL:WLANTL_Start"));
673
674 vosStatus = WDA_DS_Register( pvosGCtx,
675 WLANTL_TxComp,
676 WLANTL_RxFrames,
677 WLANTL_GetFrames,
678 WLANTL_ResourceCB,
679 WDA_TLI_MIN_RES_DATA,
680 pvosGCtx,
681 &uResCount );
682
683 if ( VOS_STATUS_SUCCESS != vosStatus )
684 {
685 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
686 "WLAN TL:TL failed to register with BAL/WDA, Err: %d",
687 vosStatus));
688 return vosStatus;
689 }
690
691 /* Enable transmission */
692 vos_atomic_set_U8( &pTLCb->ucTxSuspended, 0);
693
694 pTLCb->uResCount = uResCount;
Jeff Johnson295189b2012-06-20 16:38:30 -0700695 return VOS_STATUS_SUCCESS;
696}/* WLANTL_Start */
697
698/*==========================================================================
699
700 FUNCTION WLANTL_Stop
701
702 DESCRIPTION
703 Called by HDD to stop operation in TL, before close. TL will suspend all
704 frame transfer operation and will wait for the close request to clean up
705 its resources.
706
707 DEPENDENCIES
708
709 PARAMETERS
710
711 IN
712 pvosGCtx: pointer to the global vos context; a handle to TL's
713 control block can be extracted from its context
714
715 RETURN VALUE
716 The result code associated with performing the operation
717
718 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a page
719 fault
720 VOS_STATUS_SUCCESS: Everything is good :)
721
722 SIDE EFFECTS
723
724============================================================================*/
725VOS_STATUS
726WLANTL_Stop
727(
728 v_PVOID_t pvosGCtx
729)
730{
731 WLANTL_CbType* pTLCb = NULL;
732 v_U8_t ucIndex;
733 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
734
735 /*------------------------------------------------------------------------
736 Sanity check
737 Extract TL control block
738 ------------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +0530739 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -0700740 pTLCb = VOS_GET_TL_CB(pvosGCtx);
741 if ( NULL == pTLCb )
742 {
743 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
744 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_ChangeSTAState"));
745 return VOS_STATUS_E_FAULT;
746 }
747
748 /*------------------------------------------------------------------------
749 Stop TL and empty Station list
750 ------------------------------------------------------------------------*/
751 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
752 "WLAN TL:WLANTL_Stop"));
753
754 /* Disable transmission */
755 vos_atomic_set_U8( &pTLCb->ucTxSuspended, 1);
756
757 if ( NULL != pTLCb->tlMgmtFrmClient.vosPendingDataBuff )
758 {
759 vos_pkt_return_packet(pTLCb->tlMgmtFrmClient.vosPendingDataBuff);
760 pTLCb->tlMgmtFrmClient.vosPendingDataBuff = NULL;
761 }
762
763 if ( NULL != pTLCb->tlBAPClient.vosPendingDataBuff )
764 {
765 vos_pkt_return_packet(pTLCb->tlBAPClient.vosPendingDataBuff);
766 pTLCb->tlBAPClient.vosPendingDataBuff = NULL;
767 }
768
769#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
770 if(VOS_STATUS_SUCCESS != WLANTL_HSStop(pvosGCtx))
771 {
772 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
773 "Handoff Support module stop fail"));
774 }
775#endif
776
777 /*-------------------------------------------------------------------------
778 Clean client stations
779 -------------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +0530780 for ( ucIndex = 0; ucIndex < WLAN_MAX_STA_COUNT; ucIndex++)
Jeff Johnson295189b2012-06-20 16:38:30 -0700781 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +0530782 if ( NULL != pTLCb->atlSTAClients[ucIndex] )
783 {
784 WLANTL_CleanSTA(pTLCb->atlSTAClients[ucIndex], 1 /*empty all queues*/);
785 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700786 }
787
788
789 return VOS_STATUS_SUCCESS;
790}/* WLANTL_Stop */
791
792/*==========================================================================
793
794 FUNCTION WLANTL_Close
795
796 DESCRIPTION
797 Called by HDD during general driver close procedure. TL will clean up
798 all the internal resources.
799
800 DEPENDENCIES
801
802 PARAMETERS
803
804 IN
805 pvosGCtx: pointer to the global vos context; a handle to TL's
806 control block can be extracted from its context
807
808 RETURN VALUE
809 The result code associated with performing the operation
810
811 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a page
812 fault
813 VOS_STATUS_SUCCESS: Everything is good :)
814
815 SIDE EFFECTS
816
817============================================================================*/
818VOS_STATUS
819WLANTL_Close
820(
821 v_PVOID_t pvosGCtx
822)
823{
824 WLANTL_CbType* pTLCb = NULL;
825 tHalHandle smeContext;
826 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
827
828 /*------------------------------------------------------------------------
829 Sanity check
830 Extract TL control block
831 ------------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +0530832 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -0700833 pTLCb = VOS_GET_TL_CB(pvosGCtx);
834 if ( NULL == pTLCb )
835 {
836 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
837 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_ChangeSTAState"));
838 return VOS_STATUS_E_FAULT;
839 }
840 /*------------------------------------------------------------------------
841 Deregister from PMC
842 ------------------------------------------------------------------------*/
843 smeContext = vos_get_context(VOS_MODULE_ID_SME, pvosGCtx);
844 if ( NULL == smeContext )
845 {
846 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700847 "%s: Invalid smeContext", __func__));
Jeff Johnson295189b2012-06-20 16:38:30 -0700848 // continue so that we can cleanup as much as possible
849 }
850 else
851 {
852 pmcDeregisterDeviceStateUpdateInd( smeContext, WLANTL_PowerStateChangedCB );
853 }
854
855#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
856 if(VOS_STATUS_SUCCESS != WLANTL_HSDeInit(pvosGCtx))
857 {
858 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
859 "Handoff Support module DeInit fail"));
860 }
861#endif
862
863 /*------------------------------------------------------------------------
864 Cleanup TL control block.
865 ------------------------------------------------------------------------*/
866 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
867 "WLAN TL: WLANTL_Close"));
868 WLANTL_CleanCB(pTLCb, 1 /* empty queues/lists/pkts if any*/);
869
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +0530870 WLANTL_FreeClientMemory(pTLCb->atlSTAClients);
871
Jeff Johnson295189b2012-06-20 16:38:30 -0700872 vos_mem_free(pTLCb->reorderBufferPool);
873
874 /*------------------------------------------------------------------------
875 Free TL context from VOSS global
876 ------------------------------------------------------------------------*/
877 vos_free_context(pvosGCtx, VOS_MODULE_ID_TL, pTLCb);
878 return VOS_STATUS_SUCCESS;
879}/* WLANTL_Close */
880
881/*----------------------------------------------------------------------------
882 INTERACTION WITH HDD
883 ---------------------------------------------------------------------------*/
884/*==========================================================================
885
886 FUNCTION WLANTL_ConfigureSwFrameTXXlationForAll
887
888 DESCRIPTION
889 Function to disable/enable frame translation for all association stations.
890
891 DEPENDENCIES
892
893 PARAMETERS
894 IN
895 pvosGCtx: VOS context
896 EnableFrameXlation TRUE means enable SW translation for all stations.
897 .
898
899 RETURN VALUE
900
901 void.
902
903============================================================================*/
904void
905WLANTL_ConfigureSwFrameTXXlationForAll
906(
907 v_PVOID_t pvosGCtx,
908 v_BOOL_t enableFrameXlation
909)
910{
911 v_U8_t ucIndex;
912 /*------------------------------------------------------------------------
913 Extract TL control block
914 ------------------------------------------------------------------------*/
915 WLANTL_CbType* pTLCb = VOS_GET_TL_CB(pvosGCtx);
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +0530916 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -0700917 if ( NULL == pTLCb )
918 {
919 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
920 "WLAN TL:Invalid TL pointer from pvosGCtx on "
921 "WLANTL_ConfigureSwFrameTXXlationForAll"));
922 return;
923 }
924
925 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
926 "WLANTL_ConfigureSwFrameTXXlationForAll: Configure SW frameXlation %d",
927 enableFrameXlation));
928
929 for ( ucIndex = 0; ucIndex < WLAN_MAX_TID; ucIndex++)
930 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +0530931 pClientSTA = pTLCb->atlSTAClients[ucIndex];
932 if ( NULL != pClientSTA && 0 != pClientSTA->ucExists )
Jeff Johnson295189b2012-06-20 16:38:30 -0700933 {
934#ifdef WLAN_SOFTAP_VSTA_FEATURE
935 // if this station was not allocated resources to perform HW-based
936 // TX frame translation then force SW-based TX frame translation
937 // otherwise use the frame translation supplied by the client
938 if (!WDA_IsHwFrameTxTranslationCapable(pvosGCtx, ucIndex))
939 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +0530940 pClientSTA->wSTADesc.ucSwFrameTXXlation = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -0700941 }
942 else
943#endif
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +0530944 pClientSTA->wSTADesc.ucSwFrameTXXlation = enableFrameXlation;
Jeff Johnson295189b2012-06-20 16:38:30 -0700945 }
946 }
947}
948
949/*===========================================================================
950
951 FUNCTION WLANTL_StartForwarding
952
953 DESCRIPTION
954
955 This function is used to ask serialization through TX thread of the
956 cached frame forwarding (if statation has been registered in the mean while)
957 or flushing (if station has not been registered by the time)
958
959 In case of forwarding, upper layer is only required to call WLANTL_RegisterSTAClient()
960 and doesn't need to call this function explicitly. TL will handle this inside
961 WLANTL_RegisterSTAClient().
962
963 In case of flushing, upper layer is required to call this function explicitly
964
965 DEPENDENCIES
966
967 TL must have been initialized before this gets called.
968
969
970 PARAMETERS
971
972 ucSTAId: station id
973
974 RETURN VALUE
975
976 The result code associated with performing the operation
977 Please check return values of vos_tx_mq_serialize.
978
979 SIDE EFFECTS
980 If TL was asked to perform WLANTL_CacheSTAFrame() in WLANTL_RxFrames(),
981 either WLANTL_RegisterSTAClient() or this function must be called
982 within reasonable time. Otherwise, TL will keep cached vos buffer until
983 one of this function is called, and may end up with system buffer exhasution.
984
985 It's an upper layer's responsibility to call this function in case of
986 flushing
987
988============================================================================*/
989
990VOS_STATUS
991WLANTL_StartForwarding
992(
993 v_U8_t ucSTAId,
994 v_U8_t ucUcastSig,
995 v_U8_t ucBcastSig
996)
997{
998 vos_msg_t sMessage;
999 v_U32_t uData;
1000 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
1001
1002 /* Signal the OS to serialize our event */
1003 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
1004 "Serializing TL Start Forwarding Cached for control STA %d",
1005 ucSTAId );
1006
1007 vos_mem_zero( &sMessage, sizeof(vos_msg_t) );
1008
1009 uData = ucSTAId | (ucUcastSig << 8 ) | (ucBcastSig << 16);
1010 sMessage.bodyptr = (v_PVOID_t)uData;
1011 sMessage.type = WLANTL_TX_FWD_CACHED;
1012
1013 return vos_tx_mq_serialize(VOS_MQ_ID_TL, &sMessage);
1014
1015} /* WLANTL_StartForwarding() */
1016
1017/*===========================================================================
1018
1019 FUNCTION WLANTL_AssocFailed
1020
1021 DESCRIPTION
1022
1023 This function is used by PE to notify TL that cache needs to flushed'
1024 when association is not successfully completed
1025
1026 Internally, TL post a message to TX_Thread to serialize the request to
1027 keep lock-free mechanism.
1028
1029
1030 DEPENDENCIES
1031
1032 TL must have been initialized before this gets called.
1033
1034
1035 PARAMETERS
1036
1037 ucSTAId: station id
1038
1039 RETURN VALUE
1040
1041 none
1042
1043 SIDE EFFECTS
1044 There may be race condition that PE call this API and send another association
1045 request immediately with same staId before TX_thread can process the message.
1046
1047 To avoid this, we might need PE to wait for TX_thread process the message,
1048 but this is not currently implemented.
1049
1050============================================================================*/
1051void WLANTL_AssocFailed(v_U8_t staId)
1052{
1053 // flushing frames and forwarding frames uses the same message
1054 // the only difference is what happens when the message is processed
1055 // if the STA exist, the frames will be forwarded
1056 // and if it doesn't exist, the frames will be flushed
1057 // in this case we know it won't exist so the DPU index signature values don't matter
1058 if(!VOS_IS_STATUS_SUCCESS(WLANTL_StartForwarding(staId,0,0)))
1059 {
1060 VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001061 " %s fails to start forwarding", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001062 }
1063}
1064
1065 /*===========================================================================
1066
1067 FUNCTION WLANTL_Finish_ULA
1068
1069 DESCRIPTION
1070 This function is used by HDD to notify TL to finish Upper layer authentication
1071 incase the last EAPOL packet is pending in the TL queue.
1072 To avoid the race condition between sme set key and the last EAPOL packet
1073 the HDD module calls this function just before calling the sme_RoamSetKey.
1074
1075 DEPENDENCIES
1076
1077 TL must have been initialized before this gets called.
1078
1079 PARAMETERS
1080
1081 callbackRoutine: HDD Callback function.
1082 callbackContext : HDD userdata context.
1083
1084 RETURN VALUE
1085
1086 VOS_STATUS_SUCCESS/VOS_STATUS_FAILURE
1087
1088 SIDE EFFECTS
1089
1090============================================================================*/
1091
1092VOS_STATUS WLANTL_Finish_ULA( void (*callbackRoutine) (void *callbackContext),
Tushnim Bhattacharyya39a8f182013-02-20 18:10:30 -08001093 void *callbackContext)
Jeff Johnson295189b2012-06-20 16:38:30 -07001094{
Tushnim Bhattacharyya39a8f182013-02-20 18:10:30 -08001095 return WDA_DS_FinishULA( callbackRoutine, callbackContext);
Jeff Johnson295189b2012-06-20 16:38:30 -07001096}
1097
1098
1099/*===========================================================================
1100
1101 FUNCTION WLANTL_RegisterSTAClient
1102
1103 DESCRIPTION
1104
1105 This function is used by HDD to register as a client for data services
1106 with TL. HDD will call this API for each new station that it adds,
1107 thus having the flexibility of registering different callback for each
1108 STA it services.
1109
1110 DEPENDENCIES
1111
1112 TL must have been initialized before this gets called.
1113
1114 Restriction:
1115 Main thread will have higher priority that Tx and Rx threads thus
1116 guaranteeing that a station will be added before any data can be
1117 received for it. (This enables TL to be lock free)
1118
1119 PARAMETERS
1120
1121 pvosGCtx: pointer to the global vos context; a handle to TL's
1122 control block can be extracted from its context
1123 pfnStARx: function pointer to the receive packet handler from HDD
1124 pfnSTATxComp: function pointer to the transmit complete confirmation
1125 handler from HDD
1126 pfnSTAFetchPkt: function pointer to the packet retrieval routine in HDD
1127 wSTADescType: STA Descriptor, contains information related to the
1128 new added STA
1129
1130 RETURN VALUE
1131
1132 The result code associated with performing the operation
1133
1134 VOS_STATUS_E_INVAL: Input parameters are invalid
1135 VOS_STATUS_E_FAULT: Station ID is outside array boundaries or pointer to
1136 TL cb is NULL ; access would cause a page fault
1137 VOS_STATUS_E_EXISTS: Station was already registered
1138 VOS_STATUS_SUCCESS: Everything is good :)
1139
1140 SIDE EFFECTS
1141
1142============================================================================*/
1143VOS_STATUS
1144WLANTL_RegisterSTAClient
1145(
1146 v_PVOID_t pvosGCtx,
1147 WLANTL_STARxCBType pfnSTARx,
1148 WLANTL_TxCompCBType pfnSTATxComp,
1149 WLANTL_STAFetchPktCBType pfnSTAFetchPkt,
1150 WLAN_STADescType* pwSTADescType,
1151 v_S7_t rssi
1152)
1153{
1154 WLANTL_CbType* pTLCb = NULL;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301155 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07001156 v_U8_t ucTid = 0;/*Local variable to clear previous replay counters of STA on all TIDs*/
Jeff Johnson295189b2012-06-20 16:38:30 -07001157 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
1158
1159 /*------------------------------------------------------------------------
1160 Sanity check
1161 ------------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301162 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -07001163 if (( NULL == pwSTADescType ) || ( NULL == pfnSTARx ) ||
1164 ( NULL == pfnSTAFetchPkt ))
1165 {
1166 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1167 "WLAN TL:Invalid parameter sent on WLANTL_RegisterSTAClient"));
1168 return VOS_STATUS_E_INVAL;
1169 }
1170
1171 if ( WLANTL_STA_ID_INVALID( pwSTADescType->ucSTAId ) )
1172 {
1173 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1174 "WLAN TL:Invalid station id requested on WLANTL_RegisterSTAClient"));
1175 return VOS_STATUS_E_FAULT;
1176 }
1177
1178 /*------------------------------------------------------------------------
1179 Extract TL control block
1180 ------------------------------------------------------------------------*/
1181 pTLCb = VOS_GET_TL_CB(pvosGCtx);
1182 if ( NULL == pTLCb )
1183 {
1184 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1185 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_RegisterSTAClient"));
1186 return VOS_STATUS_E_FAULT;
1187 }
1188
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301189 //Code for checking and allocating memory for new STA
1190 if ( NULL == pTLCb->atlSTAClients[pwSTADescType->ucSTAId] ){
1191 pTLCb->atlSTAClients[pwSTADescType->ucSTAId] = vos_mem_malloc(sizeof(WLANTL_STAClientType));
1192 if ( NULL == pTLCb->atlSTAClients[pwSTADescType->ucSTAId] ){
1193 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1194 "WLAN TL: STA Client memory allocation failed in WLANTL_RegisterSTAClient"));
1195 return VOS_STATUS_E_FAILURE;
1196 }
1197 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
1198 "WLAN TL: STA Client memory allocation in WLANTL_RegisterSTAClient"));
1199 vos_mem_zero((v_VOID_t *) pTLCb->atlSTAClients[pwSTADescType->ucSTAId],sizeof(WLANTL_STAClientType));
1200 }
1201
1202 //Assigning the pointer to local variable for easy access in future
1203 pClientSTA = pTLCb->atlSTAClients[pwSTADescType->ucSTAId];
1204 if ( 0 != pClientSTA->ucExists )
Jeff Johnson295189b2012-06-20 16:38:30 -07001205 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301206 pClientSTA->ucExists++;
Jeff Johnson295189b2012-06-20 16:38:30 -07001207 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1208 "WLAN TL:Station was already registered on WLANTL_RegisterSTAClient"));
1209 return VOS_STATUS_E_EXISTS;
1210 }
1211
1212 /*------------------------------------------------------------------------
1213 Register station with TL
1214 ------------------------------------------------------------------------*/
1215 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
1216 "WLAN TL:Registering STA Client ID: %d", pwSTADescType->ucSTAId ));
1217
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301218 pClientSTA->pfnSTARx = pfnSTARx;
1219 pClientSTA->pfnSTAFetchPkt = pfnSTAFetchPkt;
Jeff Johnson295189b2012-06-20 16:38:30 -07001220
1221 /* Only register if different from NULL - TL default Tx Comp Cb will
1222 release the vos packet */
1223 if ( NULL != pfnSTATxComp )
1224 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301225 pClientSTA->pfnSTATxComp = pfnSTATxComp;
Jeff Johnson295189b2012-06-20 16:38:30 -07001226 }
1227
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301228 pClientSTA->tlState = WLANTL_STA_INIT;
1229 pClientSTA->tlPri = WLANTL_STA_PRI_NORMAL;
1230 pClientSTA->wSTADesc.ucSTAId = pwSTADescType->ucSTAId;
Gopichand Nakkala8b54e912013-03-11 10:44:21 +05301231 pClientSTA->ptkInstalled = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001232
1233 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
1234 "WLAN TL:Registering STA Client ID: %d with UC %d and BC %d",
1235 pwSTADescType->ucSTAId,
1236 pwSTADescType->ucUcastSig, pwSTADescType->ucBcastSig));
1237
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301238 pClientSTA->wSTADesc.wSTAType = pwSTADescType->wSTAType;
Jeff Johnson295189b2012-06-20 16:38:30 -07001239
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301240 pClientSTA->wSTADesc.ucQosEnabled = pwSTADescType->ucQosEnabled;
Jeff Johnson295189b2012-06-20 16:38:30 -07001241
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301242 pClientSTA->wSTADesc.ucAddRmvLLC = pwSTADescType->ucAddRmvLLC;
Jeff Johnson295189b2012-06-20 16:38:30 -07001243
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301244 pClientSTA->wSTADesc.ucProtectedFrame = pwSTADescType->ucProtectedFrame;
Jeff Johnson295189b2012-06-20 16:38:30 -07001245
1246#ifdef FEATURE_WLAN_CCX
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301247 pClientSTA->wSTADesc.ucIsCcxSta = pwSTADescType->ucIsCcxSta;
Jeff Johnson295189b2012-06-20 16:38:30 -07001248
1249 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
1250 "WLAN TL:Registering STA Client ID: %d QoS %d Add LLC %d ProtFrame %d CcxSta %d",
1251 pwSTADescType->ucSTAId,
1252 pwSTADescType->ucQosEnabled,
1253 pwSTADescType->ucAddRmvLLC,
1254 pwSTADescType->ucProtectedFrame,
1255 pwSTADescType->ucIsCcxSta));
1256#else
1257
1258 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
1259 "WLAN TL:Registering STA Client ID: %d QoS %d Add LLC %d ProtFrame %d",
1260 pwSTADescType->ucSTAId,
1261 pwSTADescType->ucQosEnabled,
1262 pwSTADescType->ucAddRmvLLC,
1263 pwSTADescType->ucProtectedFrame));
1264
1265#endif //FEATURE_WLAN_CCX
1266#ifdef WLAN_SOFTAP_VSTA_FEATURE
1267 // if this station was not allocated resources to perform HW-based
1268 // TX frame translation then force SW-based TX frame translation
1269 // otherwise use the frame translation supplied by the client
1270
1271 if (!WDA_IsHwFrameTxTranslationCapable(pvosGCtx, pwSTADescType->ucSTAId)
1272 || ( WLAN_STA_BT_AMP == pwSTADescType->wSTAType))
1273 {
1274 pwSTADescType->ucSwFrameTXXlation = 1;
1275 }
1276#endif
1277
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301278 pClientSTA->wSTADesc.ucSwFrameTXXlation = pwSTADescType->ucSwFrameTXXlation;
1279 pClientSTA->wSTADesc.ucSwFrameRXXlation = pwSTADescType->ucSwFrameRXXlation;
Jeff Johnson295189b2012-06-20 16:38:30 -07001280
1281#ifdef FEATURE_WLAN_WAPI
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301282 pClientSTA->wSTADesc.ucIsWapiSta = pwSTADescType->ucIsWapiSta;
Jeff Johnson295189b2012-06-20 16:38:30 -07001283#endif /* FEATURE_WLAN_WAPI */
1284
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301285 vos_copy_macaddr( &pClientSTA->wSTADesc.vSTAMACAddress, &pwSTADescType->vSTAMACAddress);
Jeff Johnson295189b2012-06-20 16:38:30 -07001286
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301287 vos_copy_macaddr( &pClientSTA->wSTADesc.vBSSIDforIBSS, &pwSTADescType->vBSSIDforIBSS);
Jeff Johnson295189b2012-06-20 16:38:30 -07001288
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301289 vos_copy_macaddr( &pClientSTA->wSTADesc.vSelfMACAddress, &pwSTADescType->vSelfMACAddress);
Jeff Johnson295189b2012-06-20 16:38:30 -07001290
Jeff Johnson295189b2012-06-20 16:38:30 -07001291 /* In volans release L replay check is done at TL */
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301292 pClientSTA->ucIsReplayCheckValid = pwSTADescType->ucIsReplayCheckValid;
1293 pClientSTA->ulTotalReplayPacketsDetected = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001294/*Clear replay counters of the STA on all TIDs*/
1295 for(ucTid = 0; ucTid < WLANTL_MAX_TID ; ucTid++)
1296 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301297 pClientSTA->ullReplayCounter[ucTid] = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001298 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001299
1300 /*--------------------------------------------------------------------
1301 Set the AC for the registered station to the highest priority AC
1302 Even if this AC is not supported by the station, correction will be
1303 made in the main TL loop after the supported mask is properly
1304 updated in the pending packets call
1305 --------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301306 pClientSTA->ucCurrentAC = WLANTL_AC_VO;
1307 pClientSTA->ucCurrentWeight = 0;
1308 pClientSTA->ucServicedAC = WLANTL_AC_BK;
1309 pClientSTA->ucEapolPktPending = 0;
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -07001310
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301311 vos_mem_zero( pClientSTA->aucACMask, sizeof(pClientSTA->aucACMask));
Jeff Johnson295189b2012-06-20 16:38:30 -07001312
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301313 vos_mem_zero( &pClientSTA->wUAPSDInfo, sizeof(pClientSTA->wUAPSDInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -07001314
1315 /*--------------------------------------------------------------------
1316 Reordering info and AMSDU de-aggregation
1317 --------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301318 vos_mem_zero( pClientSTA->atlBAReorderInfo,
1319 sizeof(pClientSTA->atlBAReorderInfo[0])*
Jeff Johnson295189b2012-06-20 16:38:30 -07001320 WLAN_MAX_TID);
1321
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301322 vos_mem_zero( pClientSTA->aucMPDUHeader,
Jeff Johnson295189b2012-06-20 16:38:30 -07001323 WLANTL_MPDU_HEADER_LEN);
1324
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301325 pClientSTA->ucMPDUHeaderLen = 0;
1326 pClientSTA->vosAMSDUChain = NULL;
1327 pClientSTA->vosAMSDUChainRoot = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07001328
1329
1330 /*--------------------------------------------------------------------
1331 Stats info
1332 --------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301333 vos_mem_zero( pClientSTA->auRxCount,
1334 sizeof(pClientSTA->auRxCount[0])*
Jeff Johnson295189b2012-06-20 16:38:30 -07001335 WLAN_MAX_TID);
1336
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301337 vos_mem_zero( pClientSTA->auTxCount,
1338 sizeof(pClientSTA->auRxCount[0])*
Jeff Johnson295189b2012-06-20 16:38:30 -07001339 WLAN_MAX_TID);
1340 /* Initial RSSI is always reported as zero because TL doesnt have enough
1341 data to calculate RSSI. So to avoid reporting zero, we are initializing
1342 RSSI with RSSI saved in BssDescription during scanning. */
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301343 pClientSTA->rssiAvg = rssi;
Shailender Karmuchi13c0d082013-03-26 14:41:39 -07001344#ifdef FEATURE_WLAN_TDLS
1345 if(WLAN_STA_TDLS == pClientSTA->wSTADesc.wSTAType)
1346 {
1347 /* If client is TDLS, use TDLS specific alpha */
1348 pClientSTA->rssiAlpha = WLANTL_HO_TDLS_ALPHA;
1349 }
1350 else
1351 {
1352 pClientSTA->rssiAlpha = WLANTL_HO_DEFAULT_ALPHA;
1353 }
1354#else
1355 pClientSTA->rssiAlpha = WLANTL_HO_DEFAULT_ALPHA;
1356#endif /* FEATURE_WLAN_TDLS */
Jeff Johnson295189b2012-06-20 16:38:30 -07001357
1358 /*Tx not suspended and station fully registered*/
1359 vos_atomic_set_U8(
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301360 &pClientSTA->ucTxSuspended, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07001361
1362 /* Used until multiple station support will be added*/
1363 pTLCb->ucRegisteredStaId = pwSTADescType->ucSTAId;
1364
1365 /* Save the BAP station ID for future usage */
1366 if ( WLAN_STA_BT_AMP == pwSTADescType->wSTAType )
1367 {
1368 pTLCb->tlBAPClient.ucBAPSTAId = pwSTADescType->ucSTAId;
1369 }
1370
1371 /*------------------------------------------------------------------------
1372 Statistics info
1373 -----------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301374 memset(&pClientSTA->trafficStatistics,
Jeff Johnson295189b2012-06-20 16:38:30 -07001375 0, sizeof(WLANTL_TRANSFER_STA_TYPE));
1376
1377
1378 /*------------------------------------------------------------------------
1379 Start with the state suggested by client caller
1380 -----------------------------------------------------------------------*/
Madan Mohan Koyylamudi64258222013-01-30 14:35:10 +05301381 pClientSTA->tlState = pwSTADescType->ucInitState;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301382 pClientSTA->ucRxBlocked = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07001383 /*-----------------------------------------------------------------------
1384 After all the init is complete we can mark the existance flag
1385 ----------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301386 pClientSTA->ucExists++;
Jeff Johnson295189b2012-06-20 16:38:30 -07001387
Jeff Johnson295189b2012-06-20 16:38:30 -07001388 //flow control fields init
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301389 pClientSTA->ucLwmModeEnabled = FALSE;
1390 pClientSTA->ucLwmEventReported = FALSE;
1391 pClientSTA->bmuMemConsumed = 0;
1392 pClientSTA->uIngress_length = 0;
1393 pClientSTA->uBuffThresholdMax = WLANTL_STA_BMU_THRESHOLD_MAX;
Jeff Johnson295189b2012-06-20 16:38:30 -07001394
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301395 pClientSTA->uLwmThreshold = WLANTL_STA_BMU_THRESHOLD_MAX / 3;
Jeff Johnson295189b2012-06-20 16:38:30 -07001396
1397 //@@@ HDDSOFTAP does not queue unregistered packet for now
1398 if ( WLAN_STA_SOFTAP != pwSTADescType->wSTAType )
1399 {
Jeff Johnson295189b2012-06-20 16:38:30 -07001400 /*------------------------------------------------------------------------
1401 Forward received frames while STA was not yet registered
1402 - ----------------------------------------------------------------------*/
1403 if(!VOS_IS_STATUS_SUCCESS(WLANTL_StartForwarding( pwSTADescType->ucSTAId,
1404 pwSTADescType->ucUcastSig,
1405 pwSTADescType->ucBcastSig)))
1406 {
1407 VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001408 " %s fails to start forwarding", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001409 }
Sunil Ravid5406f22013-01-22 00:18:31 -08001410#ifdef FEATURE_WLAN_TDLS
1411 if( WLAN_STA_TDLS == pwSTADescType->wSTAType )
1412 pTLCb->ucTdlsPeerCount++;
1413#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001414 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001415 return VOS_STATUS_SUCCESS;
1416}/* WLANTL_RegisterSTAClient */
1417
1418/*===========================================================================
1419
1420 FUNCTION WLANTL_ClearSTAClient
1421
1422 DESCRIPTION
1423
1424 HDD will call this API when it no longer needs data services for the
1425 particular station.
1426
1427 DEPENDENCIES
1428
1429 A station must have been registered before the clear registration is
1430 called.
1431
1432 PARAMETERS
1433
1434 pvosGCtx: pointer to the global vos context; a handle to TL's
1435 control block can be extracted from its context
1436 ucSTAId: identifier for the STA to be cleared
1437
1438 RETURN VALUE
1439
1440 The result code associated with performing the operation
1441
1442 VOS_STATUS_E_FAULT: Station ID is outside array boundaries or pointer to
1443 TL cb is NULL ; access would cause a page fault
1444 VOS_STATUS_E_EXISTS: Station was not registered
1445 VOS_STATUS_SUCCESS: Everything is good :)
1446
1447 SIDE EFFECTS
1448
1449============================================================================*/
1450VOS_STATUS
1451WLANTL_ClearSTAClient
1452(
1453 v_PVOID_t pvosGCtx,
1454 v_U8_t ucSTAId
1455)
1456{
1457 WLANTL_CbType* pTLCb = NULL;
1458 v_U8_t ucIndex;
1459 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
1460
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301461 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -07001462 /*------------------------------------------------------------------------
1463 Sanity check
1464 ------------------------------------------------------------------------*/
1465 if ( WLANTL_STA_ID_INVALID( ucSTAId ) )
1466 {
1467 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1468 "WLAN TL:Invalid station id requested on WLANTL_ClearSTAClient"));
1469 return VOS_STATUS_E_FAULT;
1470 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001471 /*------------------------------------------------------------------------
1472 Extract TL control block
1473 ------------------------------------------------------------------------*/
1474 pTLCb = VOS_GET_TL_CB(pvosGCtx);
1475 if ( NULL == pTLCb )
1476 {
1477 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1478 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_ClearSTAClient"));
1479 return VOS_STATUS_E_FAULT;
1480 }
1481
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301482 if ( NULL == pTLCb->atlSTAClients[ucSTAId] )
1483 {
1484 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1485 "WLAN TL:Client Memory was not allocated on %s", __func__));
1486 return VOS_STATUS_E_FAILURE;
1487 }
1488
1489 if ( 0 == pTLCb->atlSTAClients[ucSTAId]->ucExists )
Jeff Johnson295189b2012-06-20 16:38:30 -07001490 {
1491 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1492 "WLAN TL:Station was not previously registered on WLANTL_ClearSTAClient"));
1493 return VOS_STATUS_E_EXISTS;
1494 }
1495
1496 /* Delete BA sessions on all TID's */
1497 for ( ucIndex = 0; ucIndex < WLAN_MAX_TID ; ucIndex++)
1498 {
1499 WLANTL_BaSessionDel (pvosGCtx, ucSTAId, ucIndex);
1500 }
1501
Sunil Ravid5406f22013-01-22 00:18:31 -08001502#ifdef FEATURE_WLAN_TDLS
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301503 /* decrement ucTdlsPeerCount only if it is non-zero */
1504 if(WLAN_STA_TDLS == pTLCb->atlSTAClients[ucSTAId]->wSTADesc.wSTAType
Sunil Ravid5406f22013-01-22 00:18:31 -08001505 && pTLCb->ucTdlsPeerCount)
1506 pTLCb->ucTdlsPeerCount--;
1507#endif
1508
Jeff Johnson295189b2012-06-20 16:38:30 -07001509 /*------------------------------------------------------------------------
1510 Clear station
1511 ------------------------------------------------------------------------*/
1512 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
1513 "WLAN TL:Clearing STA Client ID: %d", ucSTAId ));
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301514 WLANTL_CleanSTA(pTLCb->atlSTAClients[ucSTAId], 1 /*empty packets*/);
Jeff Johnson295189b2012-06-20 16:38:30 -07001515
1516 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
1517 "WLAN TL:Clearing STA Reset History RSSI and Region number"));
1518 pTLCb->hoSupport.currentHOState.historyRSSI = 0;
1519 pTLCb->hoSupport.currentHOState.regionNumber = 0;
1520
1521 return VOS_STATUS_SUCCESS;
1522}/* WLANTL_ClearSTAClient */
1523
1524/*===========================================================================
1525
1526 FUNCTION WLANTL_ChangeSTAState
1527
1528 DESCRIPTION
1529
1530 HDD will make this notification whenever a change occurs in the
1531 connectivity state of a particular STA.
1532
1533 DEPENDENCIES
1534
1535 A station must have been registered before the change state can be
1536 called.
1537
1538 RESTRICTION: A station is being notified as authenticated before the
1539 keys are installed in HW. This way if a frame is received
1540 before the keys are installed DPU will drop that frame.
1541
1542 Main thread has higher priority that Tx and Rx threads thus guaranteeing
1543 the following:
1544 - a station will be in assoc state in TL before TL receives any data
1545 for it
1546
1547 PARAMETERS
1548
1549 pvosGCtx: pointer to the global vos context; a handle to TL's
1550 control block can be extracted from its context
1551 ucSTAId: identifier for the STA that is pending transmission
1552 tlSTAState: the new state of the connection to the given station
1553
1554
1555 RETURN VALUE
1556
1557 The result code associated with performing the operation
1558
1559 VOS_STATUS_E_INVAL: Input parameters are invalid
1560 VOS_STATUS_E_FAULT: Station ID is outside array boundaries or pointer to
1561 TL cb is NULL ; access would cause a page fault
1562 VOS_STATUS_E_EXISTS: Station was not registered
1563 VOS_STATUS_SUCCESS: Everything is good :)
1564
1565 SIDE EFFECTS
1566
1567============================================================================*/
1568VOS_STATUS
1569WLANTL_ChangeSTAState
1570(
1571 v_PVOID_t pvosGCtx,
1572 v_U8_t ucSTAId,
1573 WLANTL_STAStateType tlSTAState
1574)
1575{
1576 WLANTL_CbType* pTLCb = NULL;
1577 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
1578
1579 /*------------------------------------------------------------------------
1580 Sanity check
1581 ------------------------------------------------------------------------*/
1582 if ( tlSTAState >= WLANTL_STA_MAX_STATE )
1583 {
1584 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1585 "WLAN TL:Invalid parameter sent on WLANTL_ChangeSTAState"));
1586 return VOS_STATUS_E_INVAL;
1587 }
1588
1589 if ( WLANTL_STA_ID_INVALID( ucSTAId ) )
1590 {
1591 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1592 "WLAN TL:Invalid station id requested on WLANTL_ChangeSTAState"));
1593 return VOS_STATUS_E_FAULT;
1594 }
1595
1596 /*------------------------------------------------------------------------
1597 Extract TL control block and check existance
1598 ------------------------------------------------------------------------*/
1599 pTLCb = VOS_GET_TL_CB(pvosGCtx);
1600 if ( NULL == pTLCb )
1601 {
1602 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1603 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_ChangeSTAState"));
1604 return VOS_STATUS_E_FAULT;
1605 }
1606
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301607 if ( NULL == pTLCb->atlSTAClients[ucSTAId] )
1608 {
1609 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1610 "WLAN TL:Client Memory was not allocated on %s", __func__));
1611 return VOS_STATUS_E_FAILURE;
1612 }
1613
1614 if ( 0 == pTLCb->atlSTAClients[ucSTAId]->ucExists )
Jeff Johnson295189b2012-06-20 16:38:30 -07001615 {
1616 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1617 "WLAN TL:Station was not previously registered on WLANTL_ChangeSTAState"));
1618 return VOS_STATUS_E_EXISTS;
1619 }
1620
1621 /*------------------------------------------------------------------------
1622 Change STA state
1623 No need to lock this operation, see restrictions above
1624 ------------------------------------------------------------------------*/
1625 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
1626 "WLAN TL:Changing state for STA Client ID: %d from %d to %d",
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301627 ucSTAId, pTLCb->atlSTAClients[ucSTAId]->tlState, tlSTAState));
Jeff Johnson295189b2012-06-20 16:38:30 -07001628
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301629 pTLCb->atlSTAClients[ucSTAId]->tlState = tlSTAState;
Jeff Johnson295189b2012-06-20 16:38:30 -07001630
1631 return VOS_STATUS_SUCCESS;
1632}/* WLANTL_ChangeSTAState */
1633
1634/*===========================================================================
1635
Gopichand Nakkala8b54e912013-03-11 10:44:21 +05301636 FUNCTION WLANTL_STAPtkInstalled
1637
1638 DESCRIPTION
1639
1640 HDD will make this notification whenever PTK is installed for the STA
1641
1642 DEPENDENCIES
1643
1644 A station must have been registered before the change state can be
1645 called.
1646
1647 PARAMETERS
1648
1649 pvosGCtx: pointer to the global vos context; a handle to TL's
1650 control block can be extracted from its context
1651 ucSTAId: identifier for the STA for which Pairwise key is
1652 installed
1653
1654 RETURN VALUE
1655
1656 The result code associated with performing the operation
1657
1658 VOS_STATUS_E_FAULT: Station ID is outside array boundaries or pointer to
1659 TL cb is NULL ; access would cause a page fault
1660 VOS_STATUS_E_EXISTS: Station was not registered
1661 VOS_STATUS_SUCCESS: Everything is good :)
1662
1663 SIDE EFFECTS
1664
1665============================================================================*/
1666VOS_STATUS
1667WLANTL_STAPtkInstalled
1668(
1669 v_PVOID_t pvosGCtx,
1670 v_U8_t ucSTAId
1671)
1672{
1673 WLANTL_CbType* pTLCb = NULL;
1674 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
1675
1676 /*------------------------------------------------------------------------
1677 Sanity check
1678 ------------------------------------------------------------------------*/
1679
1680 if ( WLANTL_STA_ID_INVALID( ucSTAId ) )
1681 {
1682 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1683 "WLAN TL:Invalid station id requested on WLANTL_ChangeSTAState"));
1684 return VOS_STATUS_E_FAULT;
1685 }
1686
1687 /*------------------------------------------------------------------------
1688 Extract TL control block and check existance
1689 ------------------------------------------------------------------------*/
1690 pTLCb = VOS_GET_TL_CB(pvosGCtx);
1691 if ( NULL == pTLCb )
1692 {
1693 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1694 FL("WLAN TL:Invalid TL pointer from pvosGCtx")));
1695 return VOS_STATUS_E_FAULT;
1696 }
1697
1698 if ( NULL == pTLCb->atlSTAClients[ucSTAId] )
1699 {
1700 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1701 FL("WLAN TL:Client Memory was not allocated")));
1702 return VOS_STATUS_E_FAILURE;
1703 }
1704
1705 if ( 0 == pTLCb->atlSTAClients[ucSTAId]->ucExists )
1706 {
1707 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1708 FL("WLAN TL:Station was not previously registered")));
1709 return VOS_STATUS_E_EXISTS;
1710 }
1711
1712 pTLCb->atlSTAClients[ucSTAId]->ptkInstalled = 1;
1713
1714 return VOS_STATUS_SUCCESS;
1715}/* WLANTL_STAPtkInstalled */
1716
1717/*===========================================================================
1718
Madan Mohan Koyyalamudifc1d1fe2012-10-18 15:07:12 -07001719 FUNCTION WLANTL_GetSTAState
1720
1721 DESCRIPTION
1722
1723 Returns connectivity state of a particular STA.
1724
1725 DEPENDENCIES
1726
1727 A station must have been registered before its state can be retrieved.
1728
1729
1730 PARAMETERS
1731
1732 IN
1733 pvosGCtx: pointer to the global vos context; a handle to TL's
1734 control block can be extracted from its context
1735 ucSTAId: identifier of the station
1736
1737 OUT
1738 ptlSTAState: the current state of the connection to the given station
1739
1740
1741 RETURN VALUE
1742
1743 The result code associated with performing the operation
1744
1745 VOS_STATUS_E_INVAL: Input parameters are invalid
1746 VOS_STATUS_E_FAULT: Station ID is outside array boundaries or pointer to
1747 TL cb is NULL ; access would cause a page fault
1748 VOS_STATUS_E_EXISTS: Station was not registered
1749 VOS_STATUS_SUCCESS: Everything is good :)
1750
1751 SIDE EFFECTS
1752
1753============================================================================*/
1754VOS_STATUS
1755WLANTL_GetSTAState
1756(
1757 v_PVOID_t pvosGCtx,
1758 v_U8_t ucSTAId,
1759 WLANTL_STAStateType *ptlSTAState
1760)
1761{
1762 WLANTL_CbType* pTLCb = NULL;
1763 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
1764
1765 /*------------------------------------------------------------------------
1766 Sanity check
1767 ------------------------------------------------------------------------*/
1768 if ( NULL == ptlSTAState )
1769 {
1770 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1771 "WLAN TL:Invalid parameter sent on WLANTL_GetSTAState"));
1772 return VOS_STATUS_E_INVAL;
1773 }
1774
1775 if ( WLANTL_STA_ID_INVALID( ucSTAId ) )
1776 {
1777 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1778 "WLAN TL:Invalid station id requested on WLANTL_GetSTAState"));
1779 return VOS_STATUS_E_FAULT;
1780 }
1781
1782 /*------------------------------------------------------------------------
1783 Extract TL control block and check existance
1784 ------------------------------------------------------------------------*/
1785 pTLCb = VOS_GET_TL_CB(pvosGCtx);
1786 if ( NULL == pTLCb )
1787 {
1788 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1789 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_GetSTAState"));
1790 return VOS_STATUS_E_FAULT;
1791 }
1792
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301793 if ( NULL == pTLCb->atlSTAClients[ucSTAId] )
1794 {
1795 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1796 "WLAN TL:Client Memory was not allocated on %s", __func__));
1797 return VOS_STATUS_E_FAILURE;
1798 }
1799
1800 if ( 0 == pTLCb->atlSTAClients[ucSTAId]->ucExists )
Madan Mohan Koyyalamudifc1d1fe2012-10-18 15:07:12 -07001801 {
Sunil Ravid5406f22013-01-22 00:18:31 -08001802 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
Madan Mohan Koyyalamudifc1d1fe2012-10-18 15:07:12 -07001803 "WLAN TL:Station was not previously registered on WLANTL_GetSTAState"));
1804 return VOS_STATUS_E_EXISTS;
1805 }
1806
1807 /*------------------------------------------------------------------------
1808 Get STA state
1809 ------------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301810 *ptlSTAState = pTLCb->atlSTAClients[ucSTAId]->tlState;
Madan Mohan Koyyalamudifc1d1fe2012-10-18 15:07:12 -07001811
1812 return VOS_STATUS_SUCCESS;
1813}/* WLANTL_GetSTAState */
1814
Shailender Karmuchia734f332013-04-19 14:02:48 -07001815/*==========================================================================
1816 FUNCTION WLANTL_UpdateSTABssIdforIBSS
1817
1818 DESCRIPTION
1819 HDD will call this API to update the BSSID for this Station.
1820
1821 DEPENDENCIES
1822 The HDD Should registered the staID with TL before calling this function.
1823
1824 PARAMETERS
1825
1826 IN
1827 pvosGCtx: Pointer to the global vos context; a handle to TL's
1828 or WDA's control block can be extracted from its context
1829 IN
1830 ucSTAId The Station ID for Bssid to be updated
1831 IN
1832 pBssid BSSID to be updated
1833
1834 RETURN VALUE
1835 The result code associated with performing the operation
1836
1837 VOS_STATUS_E_INVAL: Input parameters are invalid
1838 VOS_STATUS_E_FAULT: Station ID is outside array boundaries or pointer to
1839 TL cb is NULL ; access would cause a page fault
1840 VOS_STATUS_E_EXISTS: Station was not registered
1841 VOS_STATUS_SUCCESS: Everything is good :)
1842
1843 SIDE EFFECTS
1844============================================================================*/
1845
1846
1847VOS_STATUS
1848WLANTL_UpdateSTABssIdforIBSS
1849(
1850 v_PVOID_t pvosGCtx,
1851 v_U8_t ucSTAId,
1852 v_U8_t *pBssid
1853)
1854{
1855 WLANTL_CbType* pTLCb = NULL;
1856 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
1857
1858 /*------------------------------------------------------------------------
1859 Sanity check
1860 ------------------------------------------------------------------------*/
1861 if ( WLANTL_STA_ID_INVALID( ucSTAId ) )
1862 {
1863 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1864 "WLAN TL:Invalid station id requested %s", __func__));
1865 return VOS_STATUS_E_FAULT;
1866 }
1867
1868 /*------------------------------------------------------------------------
1869 Extract TL control block and check existance
1870 ------------------------------------------------------------------------*/
1871 pTLCb = VOS_GET_TL_CB(pvosGCtx);
1872 if ( NULL == pTLCb )
1873 {
1874 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1875 "WLAN TL:Invalid TL pointer from pvosGCtx %s", __func__));
1876 return VOS_STATUS_E_FAULT;
1877 }
1878
1879 if ( NULL == pTLCb->atlSTAClients[ucSTAId] )
1880 {
1881 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1882 "WLAN TL:Client Memory was not allocated on %s", __func__));
1883 return VOS_STATUS_E_FAILURE;
1884 }
1885
1886 if ( 0 == pTLCb->atlSTAClients[ucSTAId]->ucExists )
1887 {
1888 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
1889 "WLAN TL:Station was not previously registered %s", __func__));
1890 return VOS_STATUS_E_EXISTS;
1891 }
1892
1893 /*------------------------------------------------------------------------
1894 Update the IBSS BSSID
1895 ------------------------------------------------------------------------*/
1896 vos_mem_copy( &pTLCb->atlSTAClients[ucSTAId]->wSTADesc.vBSSIDforIBSS,
1897 pBssid, sizeof(v_MACADDR_t));
1898
1899 return VOS_STATUS_SUCCESS;
1900}
1901
Madan Mohan Koyyalamudifc1d1fe2012-10-18 15:07:12 -07001902/*===========================================================================
1903
Jeff Johnson295189b2012-06-20 16:38:30 -07001904 FUNCTION WLANTL_STAPktPending
1905
1906 DESCRIPTION
1907
1908 HDD will call this API when a packet is pending transmission in its
1909 queues.
1910
1911 DEPENDENCIES
1912
1913 A station must have been registered before the packet pending
1914 notification can be sent.
1915
1916 RESTRICTION: TL will not count packets for pending notification.
1917 HDD is expected to send the notification only when
1918 non-empty event gets triggered. Worst case scenario
1919 is that TL might end up making a call when Hdds
1920 queues are actually empty.
1921
1922 PARAMETERS
1923
1924 pvosGCtx: pointer to the global vos context; a handle to TL's
1925 control block can be extracted from its context
1926 ucSTAId: identifier for the STA that is pending transmission
1927
1928 RETURN VALUE
1929
1930 The result code associated with performing the operation
1931
1932 VOS_STATUS_E_INVAL: Input parameters are invalid
1933 VOS_STATUS_E_FAULT: Station ID is outside array boundaries or pointer
1934 to TL cb is NULL ; access would cause a page fault
1935 VOS_STATUS_E_EXISTS: Station was not registered
1936 VOS_STATUS_SUCCESS: Everything is good :)
1937
1938 SIDE EFFECTS
1939
1940============================================================================*/
1941VOS_STATUS
1942WLANTL_STAPktPending
1943(
1944 v_PVOID_t pvosGCtx,
1945 v_U8_t ucSTAId,
1946 WLANTL_ACEnumType ucAc
1947)
1948{
1949 WLANTL_CbType* pTLCb = NULL;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301950 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07001951 vos_msg_t vosMsg;
Jeff Johnson295189b2012-06-20 16:38:30 -07001952 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
1953
1954 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
1955 "WLAN TL:Packet pending indication for STA: %d AC: %d", ucSTAId, ucAc);
1956
1957 /*------------------------------------------------------------------------
1958 Sanity check
1959 ------------------------------------------------------------------------*/
1960 if ( WLANTL_STA_ID_INVALID( ucSTAId ) )
1961 {
1962 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1963 "WLAN TL:Invalid station id requested on WLANTL_STAPktPending"));
1964 return VOS_STATUS_E_FAULT;
1965 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001966 /*------------------------------------------------------------------------
1967 Extract TL control block and check existance
1968 ------------------------------------------------------------------------*/
1969 pTLCb = VOS_GET_TL_CB(pvosGCtx);
1970 if ( NULL == pTLCb )
1971 {
1972 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1973 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_STAPktPending"));
1974 return VOS_STATUS_E_FAULT;
1975 }
1976
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301977 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
1978
1979 if ( NULL == pClientSTA )
1980 {
1981 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1982 "WLAN TL:Client Memory was not allocated on %s", __func__));
1983 return VOS_STATUS_E_FAILURE;
1984 }
1985
1986 if ( 0 == pClientSTA->ucExists )
Jeff Johnson295189b2012-06-20 16:38:30 -07001987 {
1988 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1989 "WLAN TL:Station was not previously registered on WLANTL_STAPktPending"));
1990 return VOS_STATUS_E_EXISTS;
1991 }
1992
1993 /*---------------------------------------------------------------------
1994 Temporary fix to enable TL to fetch packets when multiple peers join
1995 an IBSS. To fix CR177301. Needs to go away when the actual fix of
1996 going through all STA's in round robin fashion gets merged in from
1997 BT AMP branch.
1998 --------------------------------------------------------------------*/
1999 pTLCb->ucRegisteredStaId = ucSTAId;
2000
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302001 if( WLANTL_STA_CONNECTED == pClientSTA->tlState )
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -07002002 { /* EAPOL_HI_PRIORITY : need to find out whether EAPOL is pending before
2003 WLANTL_FetchPacket()/WLANTL_TxConn() is called.
2004 change STA_AUTHENTICATED != tlState to CONNECTED == tlState
2005 to make sure TL is indeed waiting for EAPOL.
2006 Just in the case when STA got disconnected shortly after connectection */
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302007 pClientSTA->ucEapolPktPending = 1;
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -07002008
2009 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07002010 "WLAN TL:Packet pending indication for STA: %d AC: %d State: %d",
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302011 ucSTAId, ucAc, pClientSTA->tlState);
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07002012 }
2013
Jeff Johnson295189b2012-06-20 16:38:30 -07002014 /*-----------------------------------------------------------------------
2015 Enable this AC in the AC mask in order for TL to start servicing it
2016 Set packet pending flag
2017 To avoid race condition, serialize the updation of AC and AC mask
2018 through WLANTL_TX_STAID_AC_IND message.
2019 -----------------------------------------------------------------------*/
Sunil Ravid5406f22013-01-22 00:18:31 -08002020#ifdef FETURE_WLAN_TDLS
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302021 if ((WLAN_STA_SOFTAP != pClientSTA->wSTADesc.wSTAType) &&
Sunil Ravid5406f22013-01-22 00:18:31 -08002022 !(vos_concurrent_sessions_running()) &&
2023 !pTLCb->ucTdlsPeerCount)
2024 {
2025#else
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302026 if ((WLAN_STA_SOFTAP != pClientSTA->wSTADesc.wSTAType) &&
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -07002027 !(vos_concurrent_sessions_running()))
Jeff Johnson295189b2012-06-20 16:38:30 -07002028 {
2029#endif
2030
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302031 pClientSTA->aucACMask[ucAc] = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07002032
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302033 vos_atomic_set_U8( &pClientSTA->ucPktPending, 1);
Jeff Johnson295189b2012-06-20 16:38:30 -07002034
2035 /*------------------------------------------------------------------------
2036 Check if there are enough resources for transmission and tx is not
2037 suspended.
2038 ------------------------------------------------------------------------*/
Madan Mohan Koyyalamudi24a00f92012-10-22 15:21:02 -07002039 if (( pTLCb->uResCount >= WDA_TLI_MIN_RES_DATA ) &&
2040 ( 0 == pTLCb->ucTxSuspended ))
Jeff Johnson295189b2012-06-20 16:38:30 -07002041 {
2042 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
2043 "Issuing Xmit start request to BAL"));
2044 WDA_DS_StartXmit(pvosGCtx);
2045 }
2046 else
2047 {
2048 /*---------------------------------------------------------------------
2049 No error code is sent because TL will resume tx autonomously if
2050 resources become available or tx gets resumed
2051 ---------------------------------------------------------------------*/
Madan Mohan Koyyalamudi179e6fe2012-10-15 15:31:08 -07002052 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
Jeff Johnson295189b2012-06-20 16:38:30 -07002053 "WLAN TL:Request to send but condition not met. Res: %d,Suspend: %d",
Madan Mohan Koyyalamudi48139e32012-10-11 14:43:56 -07002054 pTLCb->uResCount, pTLCb->ucTxSuspended );
Jeff Johnson295189b2012-06-20 16:38:30 -07002055 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002056 }
2057 else
2058 {
2059 vosMsg.reserved = 0;
2060 vosMsg.bodyval = 0;
2061 vosMsg.bodyval = (ucAc | (ucSTAId << WLANTL_STAID_OFFSET));
2062 vosMsg.type = WLANTL_TX_STAID_AC_IND;
2063 return vos_tx_mq_serialize( VOS_MQ_ID_TL, &vosMsg);
2064 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002065 return VOS_STATUS_SUCCESS;
2066}/* WLANTL_STAPktPending */
2067
2068/*==========================================================================
2069
2070 FUNCTION WLANTL_SetSTAPriority
2071
2072 DESCRIPTION
2073
2074 TL exposes this API to allow upper layers a rough control over the
2075 priority of transmission for a given station when supporting multiple
2076 connections.
2077
2078 DEPENDENCIES
2079
2080 A station must have been registered before the change in priority can be
2081 called.
2082
2083 PARAMETERS
2084
2085 pvosGCtx: pointer to the global vos context; a handle to TL's
2086 control block can be extracted from its context
2087 ucSTAId: identifier for the STA that has to change priority
2088
2089 RETURN VALUE
2090
2091 The result code associated with performing the operation
2092
2093 VOS_STATUS_E_INVAL: Input parameters are invalid
2094 VOS_STATUS_E_FAULT: Station ID is outside array boundaries or pointer
2095 to TL cb is NULL ; access would cause a page fault
2096 VOS_STATUS_E_EXISTS: Station was not registered
2097 VOS_STATUS_SUCCESS: Everything is good :)
2098
2099 SIDE EFFECTS
2100
2101============================================================================*/
2102VOS_STATUS
2103WLANTL_SetSTAPriority
2104(
2105 v_PVOID_t pvosGCtx,
2106 v_U8_t ucSTAId,
2107 WLANTL_STAPriorityType tlSTAPri
2108)
2109{
2110 WLANTL_CbType* pTLCb = NULL;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302111 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002112 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
2113
2114 /*------------------------------------------------------------------------
2115 Sanity check
2116 ------------------------------------------------------------------------*/
2117 if ( WLANTL_STA_ID_INVALID( ucSTAId ) )
2118 {
2119 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2120 "WLAN TL:Invalid station id requested on WLANTL_SetSTAPriority"));
2121 return VOS_STATUS_E_FAULT;
2122 }
2123
2124 /*------------------------------------------------------------------------
2125 Extract TL control block
2126 ------------------------------------------------------------------------*/
2127 pTLCb = VOS_GET_TL_CB(pvosGCtx);
2128 if ( NULL == pTLCb )
2129 {
2130 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2131 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_SetSTAPriority"));
2132 return VOS_STATUS_E_FAULT;
2133 }
2134
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302135 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
2136
2137 if ( NULL == pClientSTA )
2138 {
2139 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2140 "WLAN TL:Client Memory was not allocated on %s", __func__));
2141 return VOS_STATUS_E_FAILURE;
2142 }
2143
2144 if ( 0 == pClientSTA->ucExists )
Jeff Johnson295189b2012-06-20 16:38:30 -07002145 {
2146 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2147 "WLAN TL:Station was not previously registered on WLANTL_SetSTAPriority"));
2148 return VOS_STATUS_E_EXISTS;
2149 }
2150
2151 /*------------------------------------------------------------------------
2152 Re-analize if lock is needed when adding multiple stations
2153 ------------------------------------------------------------------------*/
2154 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
2155 "WLAN TL:Changing state for STA Pri ID: %d from %d to %d",
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302156 ucSTAId, pClientSTA->tlPri, tlSTAPri));
2157 pClientSTA->tlPri = tlSTAPri;
Jeff Johnson295189b2012-06-20 16:38:30 -07002158
2159 return VOS_STATUS_SUCCESS;
2160}/* WLANTL_SetSTAPriority */
2161
2162
2163/*----------------------------------------------------------------------------
2164 INTERACTION WITH BAP
2165 ---------------------------------------------------------------------------*/
2166
2167/*==========================================================================
2168
2169 FUNCTION WLANTL_RegisterBAPClient
2170
2171 DESCRIPTION
2172 Called by SME to register itself as client for non-data BT-AMP packets.
2173
2174 DEPENDENCIES
2175 TL must be initialized before this function can be called.
2176
2177 PARAMETERS
2178
2179 IN
2180 pvosGCtx: pointer to the global vos context; a handle to TL's
2181 or SME's control block can be extracted from its context
2182 pfnTlBAPRxFrm: pointer to the receive processing routine for non-data
2183 BT-AMP packets
2184 pfnFlushOpCompleteCb:
2185 pointer to the call back function, for the Flush operation
2186 completion.
2187
2188
2189 RETURN VALUE
2190
2191 The result code associated with performing the operation
2192
2193 VOS_STATUS_E_INVAL: Input parameters are invalid
2194 VOS_STATUS_E_FAULT: Station ID is outside array boundaries or pointer
2195 to TL cb is NULL ; access would cause a page fault
2196 VOS_STATUS_E_EXISTS: BAL client was already registered
2197 VOS_STATUS_SUCCESS: Everything is good :)
2198
2199 SIDE EFFECTS
2200
2201============================================================================*/
2202VOS_STATUS
2203WLANTL_RegisterBAPClient
2204(
2205 v_PVOID_t pvosGCtx,
2206 WLANTL_BAPRxCBType pfnTlBAPRxFrm,
2207 WLANTL_FlushOpCompCBType pfnFlushOpCompleteCb
2208)
2209{
2210 WLANTL_CbType* pTLCb = NULL;
2211 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
2212
2213 /*------------------------------------------------------------------------
2214 Sanity check
2215 ------------------------------------------------------------------------*/
2216 if ( NULL == pfnTlBAPRxFrm )
2217 {
2218 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2219 "WLAN TL:Invalid parameter sent on WLANTL_RegisterBAPClient"));
2220 return VOS_STATUS_E_INVAL;
2221 }
2222
2223 if ( NULL == pfnFlushOpCompleteCb )
2224 {
2225 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2226 "Invalid Flush Complete Cb parameter sent on WLANTL_RegisterBAPClient"));
2227 return VOS_STATUS_E_INVAL;
2228 }
2229
2230 /*------------------------------------------------------------------------
2231 Extract TL control block
2232 ------------------------------------------------------------------------*/
2233 pTLCb = VOS_GET_TL_CB(pvosGCtx);
2234 if ( NULL == pTLCb )
2235 {
2236 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2237 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_RegisterBAPClient"));
2238 return VOS_STATUS_E_FAULT;
2239 }
2240
2241 /*------------------------------------------------------------------------
2242 Make sure this is the first registration attempt
2243 ------------------------------------------------------------------------*/
2244 if ( 0 != pTLCb->tlBAPClient.ucExists )
2245 {
2246 pTLCb->tlBAPClient.ucExists++;
2247 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2248 "WLAN TL:BAP client was already registered"));
2249 return VOS_STATUS_E_EXISTS;
2250 }
2251
2252 /*------------------------------------------------------------------------
2253 Register station with TL
2254 ------------------------------------------------------------------------*/
2255 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
2256 "WLAN TL:Registering BAP Client" ));
2257
2258 pTLCb->tlBAPClient.ucExists++;
2259
2260 if ( NULL != pfnTlBAPRxFrm )
2261 {
2262 pTLCb->tlBAPClient.pfnTlBAPRx = pfnTlBAPRxFrm;
2263 }
2264
2265 pTLCb->tlBAPClient.pfnFlushOpCompleteCb = pfnFlushOpCompleteCb;
2266
2267 pTLCb->tlBAPClient.vosPendingDataBuff = NULL;
2268
2269 return VOS_STATUS_SUCCESS;
2270}/* WLANTL_RegisterBAPClient */
2271
2272
2273/*==========================================================================
2274
2275 FUNCTION WLANTL_TxBAPFrm
2276
2277 DESCRIPTION
2278 BAP calls this when it wants to send a frame to the module
2279
2280 DEPENDENCIES
2281 BAP must be registered with TL before this function can be called.
2282
2283 RESTRICTION: BAP CANNOT push any packets to TL until it did not receive
2284 a tx complete from the previous packet, that means BAP
2285 sends one packet, wait for tx complete and then
2286 sends another one
2287
2288 If BAP sends another packet before TL manages to process the
2289 previously sent packet call will end in failure
2290
2291 PARAMETERS
2292
2293 IN
2294 pvosGCtx: pointer to the global vos context; a handle to TL's
2295 or BAP's control block can be extracted from its context
2296 vosDataBuff: pointer to the vOSS buffer containing the packet to be
2297 transmitted
2298 pMetaInfo: meta information about the packet
2299 pfnTlBAPTxComp: pointer to a transmit complete routine for notifying
2300 the result of the operation over the bus
2301
2302 RETURN VALUE
2303 The result code associated with performing the operation
2304
2305 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
2306 page fault
2307 VOS_STATUS_E_EXISTS: BAL client was not yet registered
2308 VOS_STATUS_E_BUSY: The previous BT-AMP packet was not yet transmitted
2309 VOS_STATUS_SUCCESS: Everything is good :)
2310
2311 Other failure messages may be returned from the BD header handling
2312 routines, please check apropriate API for more info.
2313
2314 SIDE EFFECTS
2315
2316============================================================================*/
2317VOS_STATUS
2318WLANTL_TxBAPFrm
2319(
2320 v_PVOID_t pvosGCtx,
2321 vos_pkt_t* vosDataBuff,
2322 WLANTL_MetaInfoType* pMetaInfo,
2323 WLANTL_TxCompCBType pfnTlBAPTxComp
2324)
2325{
2326 WLANTL_CbType* pTLCb = NULL;
2327 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
2328 v_MACADDR_t vDestMacAddr;
2329 v_U16_t usPktLen;
2330 v_U8_t ucStaId = 0;
2331 v_U8_t extraHeadSpace = 0;
2332 v_U8_t ucWDSEnabled = 0;
2333 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
2334
2335 /*------------------------------------------------------------------------
2336 Sanity check
2337 Extract TL control block
2338 ------------------------------------------------------------------------*/
2339 pTLCb = VOS_GET_TL_CB(pvosGCtx);
2340 if ( NULL == pTLCb )
2341 {
2342 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2343 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_TxBAPFrm"));
2344 return VOS_STATUS_E_FAULT;
2345 }
2346
2347 /*------------------------------------------------------------------------
2348 Ensure that BAP client was registered previously
2349 ------------------------------------------------------------------------*/
2350 if (( 0 == pTLCb->tlBAPClient.ucExists ) ||
2351 ( WLANTL_STA_ID_INVALID(pTLCb->tlBAPClient.ucBAPSTAId) ))
2352 {
2353 pTLCb->tlBAPClient.ucExists++;
2354 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2355 "WLAN TL:BAP client not register on WLANTL_TxBAPFrm"));
2356 return VOS_STATUS_E_EXISTS;
2357 }
2358
2359 /*------------------------------------------------------------------------
2360 Check if any BT-AMP Frm is pending
2361 ------------------------------------------------------------------------*/
2362 if ( NULL != pTLCb->tlBAPClient.vosPendingDataBuff )
2363 {
2364 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2365 "WLAN TL:BT-AMP Frame already pending tx in TL on WLANTL_TxBAPFrm"));
2366 return VOS_STATUS_E_BUSY;
2367 }
2368
2369 /*------------------------------------------------------------------------
2370 Save buffer and notify BAL; no lock is needed if the above restriction
2371 is met
2372 Save the tx complete fnct pointer as tl specific data in the vos buffer
2373 ------------------------------------------------------------------------*/
2374
2375 /*------------------------------------------------------------------------
2376 Translate 802.3 frame to 802.11
2377 ------------------------------------------------------------------------*/
2378 ucStaId = pTLCb->tlBAPClient.ucBAPSTAId;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302379 if ( NULL == pTLCb->atlSTAClients[ucStaId] )
2380 {
2381 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2382 "WLAN TL:Client Memory was not allocated on %s", __func__));
2383 return VOS_STATUS_E_FAILURE;
2384 }
2385 if (( 0 == pMetaInfo->ucDisableFrmXtl ) &&
2386 ( 0 != pTLCb->atlSTAClients[ucStaId]->wSTADesc.ucSwFrameTXXlation ))
Jeff Johnson295189b2012-06-20 16:38:30 -07002387 {
Kiran Venkatappacab0d352012-12-17 13:09:22 -08002388 vosStatus = WLANTL_Translate8023To80211Header( vosDataBuff, &vosStatus,
2389 pTLCb, &ucStaId,
Ravi Joshid0699502013-07-08 15:48:47 -07002390 pMetaInfo, &ucWDSEnabled,
2391 &extraHeadSpace);
Jeff Johnson295189b2012-06-20 16:38:30 -07002392
2393 if ( VOS_STATUS_SUCCESS != vosStatus )
2394 {
2395 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2396 "WLAN TL:Error when translating header WLANTL_TxBAPFrm"));
2397
2398 return vosStatus;
2399 }
2400
2401 pMetaInfo->ucDisableFrmXtl = 1;
2402 }
2403
2404 /*-------------------------------------------------------------------------
2405 Call HAL to fill BD header
2406 -------------------------------------------------------------------------*/
2407
2408 /* Adding Type, SubType which was missing for EAPOL from BAP */
2409 pMetaInfo->ucType |= (WLANTL_80211_DATA_TYPE << 4);
2410 pMetaInfo->ucType |= (WLANTL_80211_DATA_QOS_SUBTYPE);
2411
2412 vosStatus = WDA_DS_BuildTxPacketInfo( pvosGCtx, vosDataBuff ,
2413 &vDestMacAddr, pMetaInfo->ucDisableFrmXtl,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302414 &usPktLen, pTLCb->atlSTAClients[ucStaId]->wSTADesc.ucQosEnabled,
Jeff Johnson295189b2012-06-20 16:38:30 -07002415 ucWDSEnabled, extraHeadSpace, pMetaInfo->ucType,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302416 &pTLCb->atlSTAClients[ucStaId]->wSTADesc.vSelfMACAddress,
Jeff Johnson295189b2012-06-20 16:38:30 -07002417 pMetaInfo->ucTID, 0 /* No ACK */, pMetaInfo->usTimeStamp,
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -07002418 pMetaInfo->ucIsEapol || pMetaInfo->ucIsWai, pMetaInfo->ucUP );
Jeff Johnson295189b2012-06-20 16:38:30 -07002419
2420 if ( VOS_STATUS_SUCCESS != vosStatus )
2421 {
2422 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2423 "WLAN TL:Failed while building TX header %d", vosStatus));
2424 return vosStatus;
2425 }
2426
2427 if ( NULL != pfnTlBAPTxComp )
2428 {
2429 vos_pkt_set_user_data_ptr( vosDataBuff, VOS_PKT_USER_DATA_ID_TL,
2430 (v_PVOID_t)pfnTlBAPTxComp);
2431 }
2432 else
2433 {
2434 vos_pkt_set_user_data_ptr( vosDataBuff, VOS_PKT_USER_DATA_ID_TL,
2435 (v_PVOID_t)WLANTL_TxCompDefaultCb);
2436
2437 }
2438
2439 vos_atomic_set_U32( (v_U32_t*)&pTLCb->tlBAPClient.vosPendingDataBuff,
2440 (v_U32_t)vosDataBuff);
2441
2442 /*------------------------------------------------------------------------
2443 Check if thre are enough resources for transmission and tx is not
2444 suspended.
2445 ------------------------------------------------------------------------*/
2446 if (( pTLCb->uResCount >= WDA_TLI_MIN_RES_BAP ) &&
2447 ( 0 == pTLCb->ucTxSuspended ))
2448 {
2449 WDA_DS_StartXmit(pvosGCtx);
2450 }
2451 else
2452 {
2453 /*---------------------------------------------------------------------
2454 No error code is sent because TL will resume tx autonomously if
2455 resources become available or tx gets resumed
2456 ---------------------------------------------------------------------*/
2457 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
2458 "WLAN TL:Request to send from BAP but condition not met.Res: %d,"
2459 "Suspend: %d", pTLCb->uResCount, pTLCb->ucTxSuspended ));
2460 }
2461
2462 return VOS_STATUS_SUCCESS;
2463}/* WLANTL_TxBAPFrm */
2464
2465
2466/*----------------------------------------------------------------------------
2467 INTERACTION WITH SME
2468 ---------------------------------------------------------------------------*/
2469
2470/*==========================================================================
2471
2472 FUNCTION WLANTL_GetRssi
2473
2474 DESCRIPTION
2475 TL will extract the RSSI information from every data packet from the
2476 ongoing traffic and will store it. It will provide the result to SME
2477 upon request.
2478
2479 DEPENDENCIES
2480
2481 WARNING: the read and write of this value will not be protected
2482 by locks, therefore the information obtained after a read
2483 might not always be consistent.
2484
2485 PARAMETERS
2486
2487 IN
2488 pvosGCtx: pointer to the global vos context; a handle to TL's
2489 or SME's control block can be extracted from its context
2490 ucSTAId: station identifier for the requested value
2491
2492 OUT
2493 puRssi: the average value of the RSSI
2494
2495
2496 RETURN VALUE
2497 The result code associated with performing the operation
2498
2499 VOS_STATUS_E_INVAL: Input parameters are invalid
2500 VOS_STATUS_E_FAULT: Station ID is outside array boundaries or pointer
2501 to TL cb is NULL ; access would cause a page fault
2502 VOS_STATUS_E_EXISTS: STA was not yet registered
2503 VOS_STATUS_SUCCESS: Everything is good :)
2504
2505 SIDE EFFECTS
2506
2507============================================================================*/
2508VOS_STATUS
2509WLANTL_GetRssi
2510(
2511 v_PVOID_t pvosGCtx,
2512 v_U8_t ucSTAId,
2513 v_S7_t* pRssi
2514)
2515{
2516 WLANTL_CbType* pTLCb = NULL;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302517 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002518 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
2519
2520 /*------------------------------------------------------------------------
2521 Sanity check
2522 ------------------------------------------------------------------------*/
2523 if ( NULL == pRssi )
2524 {
2525 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2526 "WLAN TL:Invalid parameter sent on WLANTL_GetRssi"));
2527 return VOS_STATUS_E_INVAL;
2528 }
2529
2530 if ( WLANTL_STA_ID_INVALID( ucSTAId ) )
2531 {
2532 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2533 "WLAN TL:Invalid station id requested on WLANTL_GetRssi"));
2534 return VOS_STATUS_E_FAULT;
2535 }
2536
2537 /*------------------------------------------------------------------------
2538 Extract TL control block and check existance
2539 ------------------------------------------------------------------------*/
2540 pTLCb = VOS_GET_TL_CB(pvosGCtx);
2541 if ( NULL == pTLCb )
2542 {
2543 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2544 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_GetRssi"));
2545 return VOS_STATUS_E_FAULT;
2546 }
2547
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302548 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
2549
2550 if ( NULL == pClientSTA )
2551 {
2552 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2553 "WLAN TL:Client Memory was not allocated on %s", __func__));
2554 return VOS_STATUS_E_FAILURE;
2555 }
2556
2557 if ( 0 == pClientSTA->ucExists )
Jeff Johnson295189b2012-06-20 16:38:30 -07002558 {
2559 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2560 "WLAN TL:Station was not previously registered on WLANTL_GetRssi"));
2561 return VOS_STATUS_E_EXISTS;
2562 }
2563
2564 /*------------------------------------------------------------------------
2565 Copy will not be locked; please read restriction
2566 ------------------------------------------------------------------------*/
2567 if(pTLCb->isBMPS)
2568 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302569 *pRssi = pClientSTA->rssiAvgBmps;
Jeff Johnson295189b2012-06-20 16:38:30 -07002570 /* Check If RSSI is zero because we are reading rssAvgBmps updated by HAL in
2571 previous GetStatsRequest. It may be updated as zero by Hal because EnterBmps
2572 might not have happend by that time. Hence reading the most recent Rssi
2573 calcluated by TL*/
2574 if(0 == *pRssi)
2575 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302576 *pRssi = pClientSTA->rssiAvg;
Jeff Johnson295189b2012-06-20 16:38:30 -07002577 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002578 }
2579 else
2580 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302581 *pRssi = pClientSTA->rssiAvg;
Jeff Johnson295189b2012-06-20 16:38:30 -07002582 }
2583
2584 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
Jeff Johnson32d95a32012-09-10 13:15:23 -07002585 "WLAN TL:WLANTL_GetRssi for STA: %d RSSI: %d%s",
2586 ucSTAId, *pRssi,
2587 pTLCb->isBMPS ? " in BMPS" : ""));
Jeff Johnson295189b2012-06-20 16:38:30 -07002588
2589 return VOS_STATUS_SUCCESS;
2590}/* WLANTL_GetRssi */
2591
2592/*==========================================================================
2593
2594 FUNCTION WLANTL_GetLinkQuality
2595
2596 DESCRIPTION
2597 TL will extract the SNR information from every data packet from the
2598 ongoing traffic and will store it. It will provide the result to SME
2599 upon request.
2600
2601 DEPENDENCIES
2602
2603 WARNING: the read and write of this value will not be protected
2604 by locks, therefore the information obtained after a read
2605 might not always be consistent.
2606
2607 PARAMETERS
2608
2609 IN
2610 pvosGCtx: pointer to the global vos context; a handle to TL's
2611 or SME's control block can be extracted from its context
2612 ucSTAId: station identifier for the requested value
2613
2614 OUT
2615 puLinkQuality: the average value of the SNR
2616
2617
2618 RETURN VALUE
2619 The result code associated with performing the operation
2620
2621 VOS_STATUS_E_INVAL: Input parameters are invalid
2622 VOS_STATUS_E_FAULT: Station ID is outside array boundaries or pointer
2623 to TL cb is NULL ; access would cause a page fault
2624 VOS_STATUS_E_EXISTS: STA was not yet registered
2625 VOS_STATUS_SUCCESS: Everything is good :)
2626
2627 SIDE EFFECTS
2628
2629============================================================================*/
2630VOS_STATUS
2631WLANTL_GetLinkQuality
2632(
2633 v_PVOID_t pvosGCtx,
2634 v_U8_t ucSTAId,
2635 v_U32_t* puLinkQuality
2636)
2637{
2638 WLANTL_CbType* pTLCb = NULL;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302639 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002640
2641 /*------------------------------------------------------------------------
2642 Sanity check
2643 ------------------------------------------------------------------------*/
2644 if ( NULL == puLinkQuality )
2645 {
2646 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2647 "Invalid parameter sent on WLANTL_GetLinkQuality"));
2648 return VOS_STATUS_E_INVAL;
2649 }
2650
2651 if ( WLANTL_STA_ID_INVALID( ucSTAId ) )
2652 {
2653 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2654 "Invalid station id requested on WLANTL_GetLinkQuality"));
2655 return VOS_STATUS_E_FAULT;
2656 }
2657
2658 /*------------------------------------------------------------------------
2659 Extract TL control block and check existance
2660 ------------------------------------------------------------------------*/
2661 pTLCb = VOS_GET_TL_CB(pvosGCtx);
2662 if ( NULL == pTLCb )
2663 {
2664 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2665 "Invalid TL pointer from pvosGCtx on WLANTL_GetLinkQuality"));
2666 return VOS_STATUS_E_FAULT;
2667 }
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302668 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
Jeff Johnson295189b2012-06-20 16:38:30 -07002669
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302670 if ( NULL == pClientSTA )
2671 {
2672 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2673 "WLAN TL:Client Memory was not allocated on %s", __func__));
2674 return VOS_STATUS_E_FAILURE;
2675 }
2676
2677 if ( 0 == pClientSTA->ucExists )
Jeff Johnson295189b2012-06-20 16:38:30 -07002678 {
2679 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2680 "Station was not previously registered on WLANTL_GetLinkQuality"));
2681 return VOS_STATUS_E_EXISTS;
2682 }
2683
2684 /*------------------------------------------------------------------------
2685 Copy will not be locked; please read restriction
2686 ------------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302687 *puLinkQuality = pClientSTA->uLinkQualityAvg;
Jeff Johnson295189b2012-06-20 16:38:30 -07002688
2689 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
2690 "WLANTL_GetLinkQuality for STA: %d LinkQuality: %d", ucSTAId, *puLinkQuality));
2691
2692 return VOS_STATUS_SUCCESS;
2693}/* WLANTL_GetLinkQuality */
2694
2695/*==========================================================================
2696
2697 FUNCTION WLANTL_FlushStaTID
2698
2699 DESCRIPTION
2700 TL provides this API as an interface to SME (BAP) layer. TL inturn posts a
2701 message to HAL. This API is called by the SME inorder to perform a flush
2702 operation.
2703
2704 DEPENDENCIES
2705
2706 PARAMETERS
2707
2708 IN
2709 pvosGCtx: pointer to the global vos context; a handle to TL's
2710 or SME's control block can be extracted from its context
2711 ucSTAId: station identifier for the requested value
2712 ucTid: Tspec ID for the new BA session
2713
2714 OUT
2715 The response for this post is received in the main thread, via a response
2716 message from HAL to TL.
2717
2718 RETURN VALUE
2719 VOS_STATUS_SUCCESS: Everything is good :)
2720
2721 SIDE EFFECTS
2722============================================================================*/
2723VOS_STATUS
2724WLANTL_FlushStaTID
2725(
2726 v_PVOID_t pvosGCtx,
2727 v_U8_t ucSTAId,
2728 v_U8_t ucTid
2729)
2730{
2731 WLANTL_CbType* pTLCb = NULL;
2732 tpFlushACReq FlushACReqPtr = NULL;
2733 vos_msg_t vosMessage;
2734
2735
2736 if ( WLANTL_STA_ID_INVALID( ucSTAId ) )
2737 {
2738 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2739 "Invalid station id requested on WLANTL_FlushStaTID"));
2740 return VOS_STATUS_E_FAULT;
2741 }
2742
2743 /*------------------------------------------------------------------------
2744 Extract TL control block and check existance
2745 ------------------------------------------------------------------------*/
2746 pTLCb = VOS_GET_TL_CB(pvosGCtx);
2747 if ( NULL == pTLCb )
2748 {
2749 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2750 "Invalid TL pointer from pvosGCtx on WLANTL_FlushStaTID"));
2751 return VOS_STATUS_E_FAULT;
2752 }
2753
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302754 if ( NULL == pTLCb->atlSTAClients[ucSTAId] )
2755 {
2756 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2757 "WLAN TL:Client Memory was not allocated on %s", __func__));
2758 return VOS_STATUS_E_FAILURE;
2759 }
2760
2761 if ( 0 == pTLCb->atlSTAClients[ucSTAId]->ucExists )
Jeff Johnson295189b2012-06-20 16:38:30 -07002762 {
2763 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2764 "Station was not previously registered on WLANTL_FlushStaTID"));
2765 return VOS_STATUS_E_EXISTS;
2766 }
2767
2768 /*------------------------------------------------------------------------
2769 We need to post a message with the STA, TID value to HAL. HAL performs the flush
2770 ------------------------------------------------------------------------*/
2771 FlushACReqPtr = vos_mem_malloc(sizeof(tFlushACReq));
2772
2773 if ( NULL == FlushACReqPtr )
2774 {
2775 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2776 "WLAN TL: fatal failure, cannot allocate Flush Req structure"));
2777 VOS_ASSERT(0);
2778 return VOS_STATUS_E_NOMEM;
2779 }
2780
2781 // Start constructing the message for HAL
2782 FlushACReqPtr->mesgType = SIR_TL_HAL_FLUSH_AC_REQ;
2783 FlushACReqPtr->mesgLen = sizeof(tFlushACReq);
2784 FlushACReqPtr->mesgLen = sizeof(tFlushACReq);
2785 FlushACReqPtr->ucSTAId = ucSTAId;
2786 FlushACReqPtr->ucTid = ucTid;
2787
2788 vosMessage.type = WDA_TL_FLUSH_AC_REQ;
2789 vosMessage.bodyptr = (void *)FlushACReqPtr;
2790
2791 vos_mq_post_message(VOS_MQ_ID_WDA, &vosMessage);
2792 return VOS_STATUS_SUCCESS;
2793}
2794
2795
2796/*----------------------------------------------------------------------------
2797 INTERACTION WITH PE
2798 ---------------------------------------------------------------------------*/
2799
2800/*==========================================================================
2801
2802 FUNCTION WLANTL_RegisterMgmtFrmClient
2803
2804 DESCRIPTION
2805 Called by PE to register as a client for management frames delivery.
2806
2807 DEPENDENCIES
2808 TL must be initialized before this API can be called.
2809
2810 PARAMETERS
2811
2812 IN
2813 pvosGCtx: pointer to the global vos context; a handle to
2814 TL's control block can be extracted from its context
2815 pfnTlMgmtFrmRx: pointer to the receive processing routine for
2816 management frames
2817
2818 RETURN VALUE
2819 The result code associated with performing the operation
2820
2821 VOS_STATUS_E_INVAL: Input parameters are invalid
2822 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
2823 page fault
2824 VOS_STATUS_E_EXISTS: Mgmt Frame client was already registered
2825 VOS_STATUS_SUCCESS: Everything is good :)
2826
2827 SIDE EFFECTS
2828
2829============================================================================*/
2830VOS_STATUS
2831WLANTL_RegisterMgmtFrmClient
2832(
2833 v_PVOID_t pvosGCtx,
2834 WLANTL_MgmtFrmRxCBType pfnTlMgmtFrmRx
2835)
2836{
2837 WLANTL_CbType* pTLCb = NULL;
2838 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
2839
2840 /*------------------------------------------------------------------------
2841 Sanity check
2842 ------------------------------------------------------------------------*/
2843 if ( NULL == pfnTlMgmtFrmRx )
2844 {
2845 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2846 "WLAN TL:Invalid parameter sent on WLANTL_RegisterMgmtFrmClient"));
2847 return VOS_STATUS_E_INVAL;
2848 }
2849
2850 /*------------------------------------------------------------------------
2851 Extract TL control block
2852 ------------------------------------------------------------------------*/
2853 pTLCb = VOS_GET_TL_CB(pvosGCtx);
2854 if ( NULL == pTLCb )
2855 {
2856 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2857 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_ChangeSTAState"));
2858 return VOS_STATUS_E_FAULT;
2859 }
2860
2861 /*------------------------------------------------------------------------
2862 Make sure this is the first registration attempt
2863 ------------------------------------------------------------------------*/
2864 if ( 0 != pTLCb->tlMgmtFrmClient.ucExists )
2865 {
2866 pTLCb->tlMgmtFrmClient.ucExists++;
2867 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2868 "WLAN TL:Management frame client was already registered"));
2869 return VOS_STATUS_E_EXISTS;
2870 }
2871
2872 /*------------------------------------------------------------------------
2873 Register station with TL
2874 ------------------------------------------------------------------------*/
2875 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
2876 "WLAN TL:Registering Management Frame Client" ));
2877
2878 pTLCb->tlMgmtFrmClient.ucExists++;
2879
2880 if ( NULL != pfnTlMgmtFrmRx )
2881 {
2882 pTLCb->tlMgmtFrmClient.pfnTlMgmtFrmRx = pfnTlMgmtFrmRx;
2883 }
2884
2885 pTLCb->tlMgmtFrmClient.vosPendingDataBuff = NULL;
2886
2887 return VOS_STATUS_SUCCESS;
2888}/* WLANTL_RegisterMgmtFrmClient */
2889
2890/*==========================================================================
2891
2892 FUNCTION WLANTL_DeRegisterMgmtFrmClient
2893
2894 DESCRIPTION
2895 Called by PE to deregister as a client for management frames delivery.
2896
2897 DEPENDENCIES
2898 TL must be initialized before this API can be called.
2899
2900 PARAMETERS
2901
2902 IN
2903 pvosGCtx: pointer to the global vos context; a handle to
2904 TL's control block can be extracted from its context
2905 RETURN VALUE
2906 The result code associated with performing the operation
2907
2908 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
2909 page fault
2910 VOS_STATUS_E_EXISTS: Mgmt Frame client was never registered
2911 VOS_STATUS_SUCCESS: Everything is good :)
2912
2913 SIDE EFFECTS
2914
2915============================================================================*/
2916VOS_STATUS
2917WLANTL_DeRegisterMgmtFrmClient
2918(
2919 v_PVOID_t pvosGCtx
2920)
2921{
2922 WLANTL_CbType* pTLCb = NULL;
2923 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
2924
2925 /*------------------------------------------------------------------------
2926 Extract TL control block
2927 ------------------------------------------------------------------------*/
2928 pTLCb = VOS_GET_TL_CB(pvosGCtx);
2929 if ( NULL == pTLCb )
2930 {
2931 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2932 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_ChangeSTAState"));
2933 return VOS_STATUS_E_FAULT;
2934 }
2935
2936 /*------------------------------------------------------------------------
2937 Make sure this is the first registration attempt
2938 ------------------------------------------------------------------------*/
2939 if ( 0 == pTLCb->tlMgmtFrmClient.ucExists )
2940 {
2941 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2942 "WLAN TL:Management frame client was never registered"));
2943 return VOS_STATUS_E_EXISTS;
2944 }
2945
2946 /*------------------------------------------------------------------------
2947 Clear registration with TL
2948 ------------------------------------------------------------------------*/
2949 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
2950 "WLAN TL:Deregistering Management Frame Client" ));
2951
2952 pTLCb->tlMgmtFrmClient.pfnTlMgmtFrmRx = WLANTL_MgmtFrmRxDefaultCb;
2953 if ( NULL != pTLCb->tlMgmtFrmClient.vosPendingDataBuff)
2954 {
2955 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
2956 "WLAN TL:Management cache buffer not empty on deregistering"
2957 " - dropping packet" ));
2958 vos_pkt_return_packet(pTLCb->tlMgmtFrmClient.vosPendingDataBuff);
2959
2960 pTLCb->tlMgmtFrmClient.vosPendingDataBuff = NULL;
2961 }
2962
2963 pTLCb->tlMgmtFrmClient.ucExists = 0;
2964
2965 return VOS_STATUS_SUCCESS;
2966}/* WLANTL_RegisterMgmtFrmClient */
2967
2968/*==========================================================================
2969
2970 FUNCTION WLANTL_TxMgmtFrm
2971
2972 DESCRIPTION
2973 Called by PE when it want to send out a management frame.
2974 HAL will also use this API for the few frames it sends out, they are not
2975 management frames howevere it is accepted that an exception will be
2976 allowed ONLY for the usage of HAL.
2977 Generic data frames SHOULD NOT travel through this function.
2978
2979 DEPENDENCIES
2980 TL must be initialized before this API can be called.
2981
2982 RESTRICTION: If PE sends another packet before TL manages to process the
2983 previously sent packet call will end in failure
2984
2985 Frames comming through here must be 802.11 frames, frame
2986 translation in UMA will be automatically disabled.
2987
2988 PARAMETERS
2989
2990 IN
2991 pvosGCtx: pointer to the global vos context;a handle to TL's
2992 control block can be extracted from its context
2993 vosFrmBuf: pointer to a vOSS buffer containing the management
2994 frame to be transmitted
2995 usFrmLen: the length of the frame to be transmitted; information
2996 is already included in the vOSS buffer
2997 wFrmType: the type of the frame being transmitted
2998 tid: tid used to transmit this frame
2999 pfnCompTxFunc: function pointer to the transmit complete routine
3000 pvBDHeader: pointer to the BD header, if NULL it means it was not
3001 yet constructed and it lies within TL's responsibility
3002 to do so; if not NULL it is expected that it was
3003 already packed inside the vos packet
3004 ucAckResponse: flag notifying it an interrupt is needed for the
3005 acknowledgement received when the frame is sent out
3006 the air and ; the interrupt will be processed by HAL,
3007 only one such frame can be pending in the system at
3008 one time.
3009
3010
3011 RETURN VALUE
3012 The result code associated with performing the operation
3013
3014 VOS_STATUS_E_INVAL: Input parameters are invalid
3015 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
3016 page fault
3017 VOS_STATUS_E_EXISTS: Mgmt Frame client was not yet registered
3018 VOS_STATUS_E_BUSY: The previous Mgmt packet was not yet transmitted
3019 VOS_STATUS_SUCCESS: Everything is good :)
3020
3021 Other failure messages may be returned from the BD header handling
3022 routines, please check apropriate API for more info.
3023
3024 SIDE EFFECTS
3025
3026============================================================================*/
3027VOS_STATUS
3028WLANTL_TxMgmtFrm
3029(
3030 v_PVOID_t pvosGCtx,
3031 vos_pkt_t* vosFrmBuf,
3032 v_U16_t usFrmLen,
3033 v_U8_t wFrmType,
3034 v_U8_t ucTid,
3035 WLANTL_TxCompCBType pfnCompTxFunc,
3036 v_PVOID_t pvBDHeader,
3037 v_U8_t ucAckResponse
3038)
3039{
3040 WLANTL_CbType* pTLCb = NULL;
3041 v_MACADDR_t vDestMacAddr;
3042 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
3043 v_U16_t usPktLen;
3044 v_U32_t usTimeStamp = 0;
3045 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
3046
3047 /*------------------------------------------------------------------------
3048 Sanity check
3049 ------------------------------------------------------------------------*/
3050 if ( NULL == vosFrmBuf )
3051 {
3052 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3053 "WLAN TL:Invalid parameter sent on WLANTL_TxMgmtFrm"));
3054 return VOS_STATUS_E_INVAL;
3055 }
3056
3057 /*------------------------------------------------------------------------
3058 Extract TL control block
3059 ------------------------------------------------------------------------*/
3060 pTLCb = VOS_GET_TL_CB(pvosGCtx);
3061 if ( NULL == pTLCb )
3062 {
3063 TLLOGP(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_FATAL,
3064 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_TxMgmtFrm"));
3065 return VOS_STATUS_E_FAULT;
3066 }
3067
3068 /*------------------------------------------------------------------------
3069 Ensure that management frame client was previously registered
3070 ------------------------------------------------------------------------*/
3071 if ( 0 == pTLCb->tlMgmtFrmClient.ucExists )
3072 {
3073 pTLCb->tlMgmtFrmClient.ucExists++;
3074 TLLOGP(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_FATAL,
3075 "WLAN TL:Management Frame client not register on WLANTL_TxMgmtFrm"));
3076 return VOS_STATUS_E_EXISTS;
3077 }
3078
3079 /*------------------------------------------------------------------------
3080 Check if any Mgmt Frm is pending
3081 ------------------------------------------------------------------------*/
3082 //vosTempBuff = pTLCb->tlMgmtFrmClient.vosPendingDataBuff;
3083 if ( NULL != pTLCb->tlMgmtFrmClient.vosPendingDataBuff )
3084 {
3085
3086 TLLOGP(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_FATAL,
3087 "WLAN TL:Management Frame already pending tx in TL: failing old one"));
3088
3089
3090 /*Failing the tx for the previous packet enqued by PE*/
3091 //vos_atomic_set_U32( (v_U32_t*)&pTLCb->tlMgmtFrmClient.vosPendingDataBuff,
3092 // (v_U32_t)NULL);
3093
3094 //vos_pkt_get_user_data_ptr( vosTempBuff, VOS_PKT_USER_DATA_ID_TL,
3095 // (v_PVOID_t)&pfnTxComp);
3096
3097 /*it should never be NULL - default handler should be registered if none*/
3098 //if ( NULL == pfnTxComp )
3099 //{
3100 // VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3101 // "NULL pointer to Tx Complete on WLANTL_TxMgmtFrm");
3102 // VOS_ASSERT(0);
3103 // return VOS_STATUS_E_FAULT;
3104 //}
3105
3106 //pfnTxComp( pvosGCtx, vosTempBuff, VOS_STATUS_E_RESOURCES );
3107 //return VOS_STATUS_E_BUSY;
3108
3109
3110 //pfnCompTxFunc( pvosGCtx, vosFrmBuf, VOS_STATUS_E_RESOURCES);
3111 return VOS_STATUS_E_RESOURCES;
3112 }
3113
3114
3115 /*------------------------------------------------------------------------
3116 Check if BD header was build, if not construct
3117 ------------------------------------------------------------------------*/
3118 if ( NULL == pvBDHeader )
3119 {
3120 v_MACADDR_t* pvAddr2MacAddr;
3121 v_U8_t uQosHdr = VOS_FALSE;
3122
3123 /* Get address 2 of Mangement Frame to give to WLANHAL_FillTxBd */
3124 vosStatus = vos_pkt_peek_data( vosFrmBuf,
3125 WLANTL_MAC_ADDR_ALIGN(1) + VOS_MAC_ADDR_SIZE,
3126 (v_PVOID_t)&pvAddr2MacAddr, VOS_MAC_ADDR_SIZE);
3127
3128 if ( VOS_STATUS_SUCCESS != vosStatus )
3129 {
3130 TLLOGP(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_FATAL,
3131 "WLAN TL:Failed while attempting to get addr2 %d", vosStatus));
3132 return vosStatus;
3133 }
Gopichand Nakkala0f3eb5c2013-05-07 16:48:38 +05303134
3135 /* CCX IAPP/TDLS Frame which are data frames but technically used
Jeff Johnson295189b2012-06-20 16:38:30 -07003136 * for management functionality comes through route.
3137 */
3138 if (WLANTL_IS_QOS_DATA_FRAME(wFrmType)) \
3139 {
3140 uQosHdr = VOS_TRUE;
3141 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003142 /*----------------------------------------------------------------------
3143 Call WDA to build TX header
3144 ----------------------------------------------------------------------*/
3145 vosStatus = WDA_DS_BuildTxPacketInfo( pvosGCtx, vosFrmBuf , &vDestMacAddr,
3146 1 /* always 802.11 frames*/, &usPktLen, uQosHdr /*qos not enabled !!!*/,
3147 0 /* WDS off */, 0, wFrmType, pvAddr2MacAddr, ucTid,
3148 ucAckResponse, usTimeStamp, 0, 0 );
3149
3150
3151 if ( !VOS_IS_STATUS_SUCCESS(vosStatus) )
3152 {
3153 TLLOGP(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_FATAL,
3154 "WLAN TL:Failed while attempting to build TX header %d", vosStatus));
3155 return vosStatus;
3156 }
3157 }/* if BD header not present */
3158
3159 /*------------------------------------------------------------------------
3160 Save buffer and notify BAL; no lock is needed if the above restriction
3161 is met
3162 Save the tx complete fnct pointer as tl specific data in the vos buffer
3163 ------------------------------------------------------------------------*/
3164 if ( NULL != pfnCompTxFunc )
3165 {
3166 vos_pkt_set_user_data_ptr( vosFrmBuf, VOS_PKT_USER_DATA_ID_TL,
3167 (v_PVOID_t)pfnCompTxFunc);
3168 }
3169 else
3170 {
3171 vos_pkt_set_user_data_ptr( vosFrmBuf, VOS_PKT_USER_DATA_ID_TL,
3172 (v_PVOID_t)WLANTL_TxCompDefaultCb);
3173
3174 }
3175
3176 vos_atomic_set_U32( (v_U32_t*)&pTLCb->tlMgmtFrmClient.vosPendingDataBuff,
3177 (v_U32_t)vosFrmBuf);
3178
3179 /*------------------------------------------------------------------------
3180 Check if thre are enough resources for transmission and tx is not
3181 suspended.
3182 ------------------------------------------------------------------------*/
3183 if ( pTLCb->uResCount >= WDA_TLI_MIN_RES_MF )
3184 {
3185 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
3186 "WLAN TL:Issuing Xmit start request to BAL for MGMT"));
3187 vosStatus = WDA_DS_StartXmit(pvosGCtx);
3188 if(VOS_STATUS_SUCCESS != vosStatus)
3189 {
3190 TLLOGP(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_FATAL,
3191 "WLAN TL:WDA_DS_StartXmit fails. vosStatus %d", vosStatus));
3192 vos_atomic_set_U32( (v_U32_t*)&pTLCb->tlMgmtFrmClient.vosPendingDataBuff,0);
3193 }
3194 return vosStatus;
3195
3196 }
3197 else
3198 {
3199 /*---------------------------------------------------------------------
3200 No error code is sent because TL will resume tx autonomously if
3201 resources become available or tx gets resumed
3202 ---------------------------------------------------------------------*/
3203 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
3204 "WLAN TL:Request to send for Mgmt Frm but condition not met. Res: %d",
3205 pTLCb->uResCount));
3206 }
3207
3208 return VOS_STATUS_SUCCESS;
3209}/* WLANTL_TxMgmtFrm */
3210
3211/*----------------------------------------------------------------------------
3212 INTERACTION WITH HAL
3213 ---------------------------------------------------------------------------*/
3214
3215/*==========================================================================
3216
3217 FUNCTION WLANTL_ResetNotification
3218
3219 DESCRIPTION
3220 HAL notifies TL when the module is being reset.
3221 Currently not used.
3222
3223 DEPENDENCIES
3224
3225 PARAMETERS
3226
3227 IN
3228 pvosGCtx: pointer to the global vos context; a handle to TL's
3229 control block can be extracted from its context
3230
3231
3232 RETURN VALUE
3233 The result code associated with performing the operation
3234
3235 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
3236 page fault
3237 VOS_STATUS_SUCCESS: Everything is good :)
3238
3239 SIDE EFFECTS
3240
3241============================================================================*/
3242VOS_STATUS
3243WLANTL_ResetNotification
3244(
3245 v_PVOID_t pvosGCtx
3246)
3247{
3248 WLANTL_CbType* pTLCb = NULL;
3249 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
3250
3251 /*------------------------------------------------------------------------
3252 Sanity check
3253 Extract TL control block
3254 ------------------------------------------------------------------------*/
3255 pTLCb = VOS_GET_TL_CB(pvosGCtx);
3256 if ( NULL == pTLCb )
3257 {
3258 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3259 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_ResetNotification"));
3260 return VOS_STATUS_E_FAULT;
3261 }
3262
3263 WLANTL_CleanCB(pTLCb, 1 /*empty all queues and pending packets*/);
3264 return VOS_STATUS_SUCCESS;
3265}/* WLANTL_ResetNotification */
3266
3267/*==========================================================================
3268
3269 FUNCTION WLANTL_SuspendDataTx
3270
3271 DESCRIPTION
3272 HAL calls this API when it wishes to suspend transmission for a
3273 particular STA.
3274
3275 DEPENDENCIES
3276 The STA for which the request is made must be first registered with
3277 TL by HDD.
3278
3279 RESTRICTION: In case of a suspend, the flag write and read will not be
3280 locked: worst case scenario one more packet can get
3281 through before the flag gets updated (we can make this
3282 write atomic as well to guarantee consistency)
3283
3284 PARAMETERS
3285
3286 IN
3287 pvosGCtx: pointer to the global vos context; a handle to TL's
3288 control block can be extracted from its context
3289 pucSTAId: identifier of the station for which the request is made;
3290 a value of NULL assumes suspend on all active station
3291 pfnSuspendTxCB: pointer to the suspend result notification in case the
3292 call is asynchronous
3293
3294
3295 RETURN VALUE
3296 The result code associated with performing the operation
3297
3298 VOS_STATUS_E_FAULT: Station ID is outside array boundaries or pointer
3299 to TL cb is NULL ; access would cause a page fault
3300 VOS_STATUS_E_EXISTS: Station was not registered
3301 VOS_STATUS_SUCCESS: Everything is good :)
3302
3303 SIDE EFFECTS
3304
3305============================================================================*/
3306
3307VOS_STATUS
3308WLANTL_SuspendDataTx
3309(
3310 v_PVOID_t pvosGCtx,
3311 v_U8_t* pucSTAId,
3312 WLANTL_SuspendCBType pfnSuspendTx
3313)
3314{
3315 WLANTL_CbType* pTLCb = NULL;
3316 vos_msg_t vosMsg;
Jeff Johnson295189b2012-06-20 16:38:30 -07003317
3318 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
3319
3320 /*------------------------------------------------------------------------
3321 Sanity check
3322 Extract TL control block
3323 ------------------------------------------------------------------------*/
3324 pTLCb = VOS_GET_TL_CB(pvosGCtx);
Hoonki Lee14621352013-04-16 17:51:19 -07003325 if ( NULL == pTLCb )
Jeff Johnson295189b2012-06-20 16:38:30 -07003326 {
3327 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3328 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_SuspendDataTx"));
3329 return VOS_STATUS_E_FAULT;
3330 }
3331
3332 /*------------------------------------------------------------------------
3333 Check the type of request: generic suspend, or per station suspend
3334 ------------------------------------------------------------------------*/
Hoonki Lee14621352013-04-16 17:51:19 -07003335 if (NULL == pucSTAId)
Jeff Johnson295189b2012-06-20 16:38:30 -07003336 {
3337 /* General Suspend Request received */
3338 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
3339 "WLAN TL:General suspend requested"));
Hoonki Lee14621352013-04-16 17:51:19 -07003340 vos_atomic_set_U8( &pTLCb->ucTxSuspended, 1);
Jeff Johnson295189b2012-06-20 16:38:30 -07003341 vosMsg.reserved = WLAN_MAX_STA_COUNT;
3342 }
3343 else
3344 {
Hoonki Lee14621352013-04-16 17:51:19 -07003345 if ( WLANTL_STA_ID_INVALID( *pucSTAId ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07003346 {
Hoonki Lee14621352013-04-16 17:51:19 -07003347 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3348 "WLAN TL:Invalid station id %d requested on WLANTL_SuspendDataTx", *pucSTAId));
3349 return VOS_STATUS_E_FAULT;
3350 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003351
Gopichand Nakkalae5fef6c2013-06-19 18:04:23 +05303352 if ( NULL == pTLCb->atlSTAClients[*pucSTAId] )
3353 {
3354 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3355 "WLAN TL:Invalid pTLCb->atlSTAClients pointer for STA Id :%d on "
3356 "WLANTL_SuspendDataTx", *pucSTAId));
3357 return VOS_STATUS_E_FAULT;
3358 }
3359
3360 if ( 0 == pTLCb->atlSTAClients[*pucSTAId]->ucExists )
Hoonki Lee14621352013-04-16 17:51:19 -07003361 {
3362 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3363 "WLAN TL:Station %d was not previously registered on WLANTL_SuspendDataTx", *pucSTAId));
3364 return VOS_STATUS_E_EXISTS;
3365 }
3366
3367 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
3368 "WLAN TL:Suspend request for station: %d", *pucSTAId));
3369 vos_atomic_set_U8( &pTLCb->atlSTAClients[*pucSTAId]->ucTxSuspended, 1);
Jeff Johnson295189b2012-06-20 16:38:30 -07003370 vosMsg.reserved = *pucSTAId;
3371 }
3372
3373 /*------------------------------------------------------------------------
3374 Serialize request through TX thread
3375 ------------------------------------------------------------------------*/
3376 vosMsg.type = WLANTL_TX_SIG_SUSPEND;
3377 vosMsg.bodyptr = (v_PVOID_t)pfnSuspendTx;
3378
3379 if(!VOS_IS_STATUS_SUCCESS(vos_tx_mq_serialize( VOS_MQ_ID_TL, &vosMsg)))
3380 {
3381 VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003382 " %s fails to post message", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003383 }
3384
3385 return VOS_STATUS_SUCCESS;
3386}/* WLANTL_SuspendDataTx */
3387
3388/*==========================================================================
3389
3390 FUNCTION WLANTL_ResumeDataTx
3391
3392 DESCRIPTION
3393 Called by HAL to resume data transmission for a given STA.
3394
3395 WARNING: If a station was individually suspended a global resume will
3396 not resume that station
3397
3398 DEPENDENCIES
3399
3400 PARAMETERS
3401
3402 IN
3403 pvosGCtx: pointer to the global vos context; a handle to TL's
3404 control block can be extracted from its context
3405 pucSTAId: identifier of the station which is being resumed; NULL
3406 translates into global resume
3407
3408 RETURN VALUE
3409 The result code associated with performing the operation
3410
3411 VOS_STATUS_E_FAULT: Station ID is outside array boundaries or pointer
3412 to TL cb is NULL ; access would cause a page fault
3413 VOS_STATUS_E_EXISTS: Station was not registered
3414 VOS_STATUS_SUCCESS: Everything is good :)
3415
3416 SIDE EFFECTS
3417
3418============================================================================*/
3419
3420VOS_STATUS
3421WLANTL_ResumeDataTx
3422(
3423 v_PVOID_t pvosGCtx,
3424 v_U8_t* pucSTAId
3425)
3426{
3427 WLANTL_CbType* pTLCb = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07003428 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
3429
3430 /*------------------------------------------------------------------------
3431 Sanity check
3432 Extract TL control block
3433 ------------------------------------------------------------------------*/
3434 pTLCb = VOS_GET_TL_CB(pvosGCtx);
Hoonki Lee14621352013-04-16 17:51:19 -07003435 if ( NULL == pTLCb )
Jeff Johnson295189b2012-06-20 16:38:30 -07003436 {
3437 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3438 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_ResumeDataTx"));
3439 return VOS_STATUS_E_FAULT;
3440 }
3441
Jeff Johnson295189b2012-06-20 16:38:30 -07003442 /*------------------------------------------------------------------------
3443 Check to see the type of resume
3444 ------------------------------------------------------------------------*/
Hoonki Lee14621352013-04-16 17:51:19 -07003445 if ( NULL == pucSTAId )
Jeff Johnson295189b2012-06-20 16:38:30 -07003446 {
3447 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
3448 "WLAN TL:General resume requested"));
3449 vos_atomic_set_U8( &pTLCb->ucTxSuspended, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07003450 }
3451 else
3452 {
Hoonki Lee14621352013-04-16 17:51:19 -07003453 if ( WLANTL_STA_ID_INVALID( *pucSTAId ))
Jeff Johnson295189b2012-06-20 16:38:30 -07003454 {
Hoonki Lee14621352013-04-16 17:51:19 -07003455 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3456 "WLAN TL:Invalid station id %d requested on WLANTL_ResumeDataTx", *pucSTAId));
3457 return VOS_STATUS_E_FAULT;
3458 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003459
Gopichand Nakkalae5fef6c2013-06-19 18:04:23 +05303460 if ( NULL == pTLCb->atlSTAClients[*pucSTAId] )
3461 {
3462 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3463 "WLAN TL:Invalid pTLCb->atlSTAClients pointer for STA Id :%d on "
3464 "WLANTL_ResumeDataTx", *pucSTAId));
3465 return VOS_STATUS_E_FAULT;
3466 }
3467
3468 if ( 0 == pTLCb->atlSTAClients[*pucSTAId]->ucExists )
Hoonki Lee14621352013-04-16 17:51:19 -07003469 {
3470 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3471 "WLAN TL:Station %d was not previously registered on WLANTL_ResumeDataTx", *pucSTAId));
3472 return VOS_STATUS_E_EXISTS;
3473 }
3474
3475 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
3476 "WLAN TL:Resume request for station: %d", *pucSTAId));
3477 vos_atomic_set_U8( &pTLCb->atlSTAClients[*pucSTAId]->ucTxSuspended, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07003478 }
3479
3480 /*------------------------------------------------------------------------
3481 Resuming transmission
3482 ------------------------------------------------------------------------*/
Hoonki Lee14621352013-04-16 17:51:19 -07003483 if (( pTLCb->uResCount >= WDA_TLI_MIN_RES_MF ) &&
3484 ( 0 == pTLCb->ucTxSuspended ))
Jeff Johnson295189b2012-06-20 16:38:30 -07003485 {
3486 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
3487 "WLAN TL:Resuming transmission"));
3488 return WDA_DS_StartXmit(pvosGCtx);
3489 }
3490
3491 return VOS_STATUS_SUCCESS;
3492}/* WLANTL_ResumeDataTx */
3493
3494/*==========================================================================
3495 FUNCTION WLANTL_SuspendCB
3496
3497 DESCRIPTION
3498 Callback function for serializing Suspend signal through Tx thread
3499
3500 DEPENDENCIES
3501 Just notify HAL that suspend in TL is complete.
3502
3503 PARAMETERS
3504
3505 IN
3506 pvosGCtx: pointer to the global vos context; a handle to TL's
3507 control block can be extracted from its context
3508 pUserData: user data sent with the callback
3509
3510 RETURN VALUE
3511 The result code associated with performing the operation
3512
3513 VOS_STATUS_E_INVAL: invalid input parameters
3514 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
3515 page fault
3516 VOS_STATUS_SUCCESS: Everything is good :)
3517
3518
3519 SIDE EFFECTS
3520
3521============================================================================*/
3522VOS_STATUS
3523WLANTL_SuspendCB
3524(
3525 v_PVOID_t pvosGCtx,
3526 WLANTL_SuspendCBType pfnSuspendCB,
3527 v_U16_t usReserved
3528)
3529{
3530 WLANTL_CbType* pTLCb = NULL;
3531 v_U8_t ucSTAId = (v_U8_t)usReserved;
3532 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
3533
3534 /*------------------------------------------------------------------------
3535 Sanity check
3536 ------------------------------------------------------------------------*/
3537 if ( NULL == pfnSuspendCB )
3538 {
3539 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
3540 "WLAN TL: No Call back processing requested WLANTL_SuspendCB"));
3541 return VOS_STATUS_SUCCESS;
3542 }
3543
3544 /*------------------------------------------------------------------------
3545 Extract TL control block
3546 ------------------------------------------------------------------------*/
3547 pTLCb = VOS_GET_TL_CB(pvosGCtx);
3548 if ( NULL == pTLCb )
3549 {
3550 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3551 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_SuspendCB"));
3552 return VOS_STATUS_E_FAULT;
3553 }
3554
3555 if ( WLANTL_STA_ID_INVALID( ucSTAId ) )
3556 {
3557 pfnSuspendCB(pvosGCtx, NULL, VOS_STATUS_SUCCESS);
3558 }
3559 else
3560 {
3561 pfnSuspendCB(pvosGCtx, &ucSTAId, VOS_STATUS_SUCCESS);
3562 }
3563
3564 return VOS_STATUS_SUCCESS;
3565}/*WLANTL_SuspendCB*/
3566
3567
3568/*----------------------------------------------------------------------------
3569 CLIENT INDEPENDENT INTERFACE
3570 ---------------------------------------------------------------------------*/
3571
3572/*==========================================================================
3573
3574 FUNCTION WLANTL_GetTxPktCount
3575
3576 DESCRIPTION
3577 TL will provide the number of transmitted packets counted per
3578 STA per TID.
3579
3580 DEPENDENCIES
3581
3582 PARAMETERS
3583
3584 IN
3585 pvosGCtx: pointer to the global vos context; a handle to TL's
3586 control block can be extracted from its context
3587 ucSTAId: identifier of the station
3588 ucTid: identifier of the tspec
3589
3590 OUT
3591 puTxPktCount: the number of packets tx packet for this STA and TID
3592
3593 RETURN VALUE
3594 The result code associated with performing the operation
3595
3596 VOS_STATUS_E_INVAL: Input parameters are invalid
3597 VOS_STATUS_E_FAULT: Station ID is outside array boundaries or pointer
3598 to TL cb is NULL ; access would cause a page fault
3599 VOS_STATUS_E_EXISTS: Station was not registered
3600 VOS_STATUS_SUCCESS: Everything is good :)
3601
3602 SIDE EFFECTS
3603
3604============================================================================*/
3605VOS_STATUS
3606WLANTL_GetTxPktCount
3607(
3608 v_PVOID_t pvosGCtx,
3609 v_U8_t ucSTAId,
3610 v_U8_t ucTid,
3611 v_U32_t* puTxPktCount
3612)
3613{
3614 WLANTL_CbType* pTLCb = NULL;
3615 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
3616
3617 /*------------------------------------------------------------------------
3618 Sanity check
3619 ------------------------------------------------------------------------*/
3620 if ( NULL == puTxPktCount )
3621 {
3622 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3623 "WLAN TL:Invalid parameter sent on WLANTL_GetTxPktCount"));
3624 return VOS_STATUS_E_INVAL;
3625 }
3626
3627 if ( WLANTL_STA_ID_INVALID( ucSTAId ) || WLANTL_TID_INVALID( ucTid) )
3628 {
3629 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3630 "WLAN TL:Invalid station id %d/tid %d requested on WLANTL_GetTxPktCount",
3631 ucSTAId, ucTid));
3632 return VOS_STATUS_E_FAULT;
3633 }
3634
3635 /*------------------------------------------------------------------------
3636 Extract TL control block and check if station exists
3637 ------------------------------------------------------------------------*/
3638 pTLCb = VOS_GET_TL_CB(pvosGCtx);
3639 if ( NULL == pTLCb )
3640 {
3641 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3642 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_GetTxPktCount"));
3643 return VOS_STATUS_E_FAULT;
3644 }
3645
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05303646 if ( NULL == pTLCb->atlSTAClients[ucSTAId] )
3647 {
3648 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3649 "WLAN TL:Client Memory was not allocated on %s", __func__));
3650 return VOS_STATUS_E_FAILURE;
3651 }
3652
3653 if ( 0 == pTLCb->atlSTAClients[ucSTAId]->ucExists )
Jeff Johnson295189b2012-06-20 16:38:30 -07003654 {
3655 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3656 "WLAN TL:Station was not previously registered on WLANTL_GetTxPktCount %d",
3657 ucSTAId));
3658 return VOS_STATUS_E_EXISTS;
3659 }
3660
3661 /*------------------------------------------------------------------------
3662 Return data
3663 ------------------------------------------------------------------------*/
3664 //VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_MED,
3665 // "WLAN TL:Requested tx packet count for STA: %d, TID: %d",
3666 // ucSTAId, ucTid);
3667
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05303668 *puTxPktCount = pTLCb->atlSTAClients[ucSTAId]->auTxCount[ucTid];
Jeff Johnson295189b2012-06-20 16:38:30 -07003669
3670 return VOS_STATUS_SUCCESS;
3671}/* WLANTL_GetTxPktCount */
3672
3673/*==========================================================================
3674
3675 FUNCTION WLANTL_GetRxPktCount
3676
3677 DESCRIPTION
3678 TL will provide the number of received packets counted per
3679 STA per TID.
3680
3681 DEPENDENCIES
3682
3683 PARAMETERS
3684
3685 IN
3686 pvosGCtx: pointer to the global vos context; a handle to TL's
3687 control block can be extracted from its context
3688 ucSTAId: identifier of the station
3689 ucTid: identifier of the tspec
3690
3691 OUT
3692 puTxPktCount: the number of packets rx packet for this STA and TID
3693
3694 RETURN VALUE
3695 The result code associated with performing the operation
3696
3697 VOS_STATUS_E_INVAL: Input parameters are invalid
3698 VOS_STATUS_E_FAULT: Station ID is outside array boundaries or pointer
3699 to TL cb is NULL ; access would cause a page fault
3700 VOS_STATUS_E_EXISTS: Station was not registered
3701 VOS_STATUS_SUCCESS: Everything is good :)
3702
3703 SIDE EFFECTS
3704
3705============================================================================*/
3706VOS_STATUS
3707WLANTL_GetRxPktCount
3708(
3709 v_PVOID_t pvosGCtx,
3710 v_U8_t ucSTAId,
3711 v_U8_t ucTid,
3712 v_U32_t* puRxPktCount
3713)
3714{
3715 WLANTL_CbType* pTLCb = NULL;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05303716 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07003717 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
3718
3719 /*------------------------------------------------------------------------
3720 Sanity check
3721 ------------------------------------------------------------------------*/
3722 if ( NULL == puRxPktCount )
3723 {
3724 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3725 "WLAN TL:Invalid parameter sent on WLANTL_GetRxPktCount"));
3726 return VOS_STATUS_E_INVAL;
3727 }
3728
3729 if ( WLANTL_STA_ID_INVALID( ucSTAId ) || WLANTL_TID_INVALID( ucTid) )
3730 {
3731 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3732 "WLAN TL:Invalid station id %d/tid %d requested on WLANTL_GetRxPktCount",
3733 ucSTAId, ucTid));
3734 return VOS_STATUS_E_FAULT;
3735 }
3736
3737 /*------------------------------------------------------------------------
3738 Extract TL control block and existance
3739 ------------------------------------------------------------------------*/
3740 pTLCb = VOS_GET_TL_CB(pvosGCtx);
3741 if ( NULL == pTLCb )
3742 {
3743 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3744 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_GetRxPktCount"));
3745 return VOS_STATUS_E_FAULT;
3746 }
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05303747 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
Jeff Johnson295189b2012-06-20 16:38:30 -07003748
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05303749 if ( NULL == pClientSTA )
3750 {
3751 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3752 "WLAN TL:Client Memory was not allocated on %s", __func__));
3753 return VOS_STATUS_E_FAILURE;
3754 }
3755
3756 if ( 0 == pClientSTA->ucExists )
Jeff Johnson295189b2012-06-20 16:38:30 -07003757 {
3758 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3759 "WLAN TL:Station was not previously registered on WLANTL_GetRxPktCount"));
3760 return VOS_STATUS_E_EXISTS;
3761 }
3762
3763 /*------------------------------------------------------------------------
3764 Return data
3765 ------------------------------------------------------------------------*/
3766 TLLOG3(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_MED,
3767 "WLAN TL:Requested rx packet count for STA: %d, TID: %d",
3768 ucSTAId, ucTid));
3769
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05303770 *puRxPktCount = pClientSTA->auRxCount[ucTid];
Jeff Johnson295189b2012-06-20 16:38:30 -07003771
3772 return VOS_STATUS_SUCCESS;
3773}/* WLANTL_GetRxPktCount */
3774
Jeff Johnson295189b2012-06-20 16:38:30 -07003775VOS_STATUS
3776WLANTL_TxFCFrame
3777(
3778 v_PVOID_t pvosGCtx
3779);
Jeff Johnson295189b2012-06-20 16:38:30 -07003780/*============================================================================
3781 TL INTERNAL API DEFINITION
3782============================================================================*/
3783
3784/*==========================================================================
3785
3786 FUNCTION WLANTL_GetFrames
3787
3788 DESCRIPTION
3789
3790 BAL calls this function at the request of the lower bus interface.
3791 When this request is being received TL will retrieve packets from HDD
3792 in accordance with the priority rules and the count supplied by BAL.
3793
3794 DEPENDENCIES
3795
3796 HDD must have registered with TL at least one STA before this function
3797 can be called.
3798
3799 PARAMETERS
3800
3801 IN
3802 pvosGCtx: pointer to the global vos context; a handle to TL's
3803 or BAL's control block can be extracted from its context
3804 uSize: maximum size accepted by the lower layer
3805 uFlowMask TX flow control mask for Prima. Each bit is defined as
3806 WDA_TXFlowEnumType
3807
3808 OUT
3809 vosDataBuff: it will contain a pointer to the first buffer supplied
3810 by TL, if there is more than one packet supplied, TL
3811 will chain them through vOSS buffers
3812
3813 RETURN VALUE
3814
3815 The result code associated with performing the operation
3816
3817 1 or more: number of required resources if there are still frames to fetch
3818 0 : error or HDD queues are drained
3819
3820 SIDE EFFECTS
3821
3822 NOTE
3823
3824 Featurized uFlowMask. If we want to remove featurization, we need to change
3825 BAL on Volans.
3826
3827============================================================================*/
3828v_U32_t
3829WLANTL_GetFrames
3830(
3831 v_PVOID_t pvosGCtx,
3832 vos_pkt_t **ppFrameDataBuff,
3833 v_U32_t uSize,
Jeff Johnson295189b2012-06-20 16:38:30 -07003834 v_U8_t uFlowMask,
Jeff Johnson295189b2012-06-20 16:38:30 -07003835 v_BOOL_t* pbUrgent
3836)
3837{
3838 vos_pkt_t** pvosDataBuff = (vos_pkt_t**)ppFrameDataBuff;
3839 WLANTL_CbType* pTLCb = NULL;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05303840 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07003841 v_U32_t uRemaining = uSize;
3842 vos_pkt_t* vosRoot;
3843 vos_pkt_t* vosTempBuf;
3844 WLANTL_STAFuncType pfnSTAFsm;
3845 v_U16_t usPktLen;
3846 v_U32_t uResLen;
3847 v_U8_t ucSTAId;
3848 v_U8_t ucAC;
3849 vos_pkt_t* vosDataBuff;
3850 v_U32_t uTotalPktLen;
3851 v_U32_t i=0;
Tushnim Bhattacharyya39a8f182013-02-20 18:10:30 -08003852 v_U32_t j=0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003853 v_U32_t ucResult = 0;
3854 VOS_STATUS vosStatus;
3855 WLANTL_STAEventType wSTAEvent;
3856 tBssSystemRole systemRole;
3857 tpAniSirGlobal pMac;
3858 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
3859
3860 /*------------------------------------------------------------------------
3861 Sanity check
3862 Extract TL control block
3863 ------------------------------------------------------------------------*/
3864 pTLCb = VOS_GET_TL_CB(pvosGCtx);
3865 if (( NULL == pTLCb ) || ( NULL == pvosDataBuff ))
3866 {
3867 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3868 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_ChangeSTAState"));
3869 return ucResult;
3870 }
3871
3872 pMac = vos_get_context(VOS_MODULE_ID_PE, pvosGCtx);
3873 if ( NULL == pMac )
3874 {
3875 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003876 "%s: Invalid pMac", __func__));
Jeff Johnson295189b2012-06-20 16:38:30 -07003877 return ucResult;
3878 }
3879
3880 vosDataBuff = pTLCb->vosDummyBuf; /* Just to avoid checking for NULL at
3881 each iteration */
3882
Jeff Johnson295189b2012-06-20 16:38:30 -07003883 pTLCb->uResCount = uSize;
Jeff Johnson295189b2012-06-20 16:38:30 -07003884
3885 /*-----------------------------------------------------------------------
3886 Save the root as we will walk this chain as we fill it
3887 -----------------------------------------------------------------------*/
3888 vosRoot = vosDataBuff;
3889
3890 /*-----------------------------------------------------------------------
3891 There is still data - until FSM function says otherwise
3892 -----------------------------------------------------------------------*/
3893 pTLCb->bUrgent = FALSE;
3894
Jeff Johnson295189b2012-06-20 16:38:30 -07003895 while (( pTLCb->tlConfigInfo.uMinFramesProcThres < pTLCb->uResCount ) &&
3896 ( 0 < uRemaining ))
Jeff Johnson295189b2012-06-20 16:38:30 -07003897 {
3898 systemRole = wdaGetGlobalSystemRole(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -07003899#ifdef WLAN_SOFTAP_FLOWCTRL_EN
3900/* FIXME: The code has been disabled since it is creating issues in power save */
3901 if (eSYSTEM_AP_ROLE == systemRole)
3902 {
3903 if (pTLCb->done_once == 0 && NULL == pTLCb->vosTxFCBuf)
3904 {
3905 WLANTL_TxFCFrame (pvosGCtx);
3906 pTLCb->done_once ++;
3907 }
3908 }
3909 if ( NULL != pTLCb->vosTxFCBuf )
3910 {
3911 //there is flow control packet waiting to be sent
3912 WDA_TLI_PROCESS_FRAME_LEN( pTLCb->vosTxFCBuf, usPktLen, uResLen, uTotalPktLen);
3913
3914 if ( ( pTLCb->uResCount > uResLen ) &&
Jeff Johnson9b5dc4d2013-02-22 21:28:47 -08003915 ( uRemaining > uTotalPktLen ) &&
3916 ( uFlowMask & ( 1 << WDA_TXFLOW_FC ) ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07003917 {
3918 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
3919 "WLAN TL:Chaining FC frame first on GetFrame"));
3920
3921 vos_pkt_chain_packet( vosDataBuff, pTLCb->vosTxFCBuf, 1 /*true*/ );
3922
3923 vos_atomic_set_U32( (v_U32_t*)&pTLCb->vosTxFCBuf, (v_U32_t)NULL);
3924
3925 /*FC frames cannot be delayed*/
3926 pTLCb->bUrgent = TRUE;
3927
3928 /*Update remaining len from SSC */
3929 uRemaining -= (usPktLen + WDA_DXE_HEADER_SIZE);
3930
3931 /*Update resource count */
3932 pTLCb->uResCount -= uResLen;
3933 }
3934 else
3935 {
3936 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003937 "WLAN TL:send fc out of source %s", __func__));
Jeff Johnson295189b2012-06-20 16:38:30 -07003938 ucResult = ( pTLCb->uResCount > uResLen )?VOS_TRUE:VOS_FALSE;
3939 break; /* Out of resources or reached max len */
3940 }
3941 }
3942 else
3943#endif //WLAN_SOFTAP_FLOWCTRL_EN
Jeff Johnson295189b2012-06-20 16:38:30 -07003944
Jeff Johnson9b5dc4d2013-02-22 21:28:47 -08003945 if (( NULL != pTLCb->tlMgmtFrmClient.vosPendingDataBuff ) &&
3946 ( uFlowMask & ( 1 << WDA_TXFLOW_MGMT ) ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07003947 {
3948 WDA_TLI_PROCESS_FRAME_LEN( pTLCb->tlMgmtFrmClient.vosPendingDataBuff,
3949 usPktLen, uResLen, uTotalPktLen);
3950
3951 VOS_ASSERT(usPktLen <= WLANTL_MAX_ALLOWED_LEN);
3952
3953 if ( ( pTLCb->uResCount > uResLen ) &&
Jeff Johnson9b5dc4d2013-02-22 21:28:47 -08003954 ( uRemaining > uTotalPktLen ) &&
3955 ( uFlowMask & ( 1 << WDA_TXFLOW_MGMT ) ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07003956 {
3957 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
3958 "WLAN TL:Chaining management frame on GetFrame"));
3959
3960 vos_pkt_chain_packet( vosDataBuff,
3961 pTLCb->tlMgmtFrmClient.vosPendingDataBuff,
3962 1 /*true*/ );
3963
3964 vos_atomic_set_U32( (v_U32_t*)&pTLCb->tlMgmtFrmClient.
3965 vosPendingDataBuff, (v_U32_t)NULL);
3966
3967 /*management frames cannot be delayed*/
3968 pTLCb->bUrgent = TRUE;
3969
3970 /*Update remaining len from SSC */
3971 uRemaining -= (usPktLen + WDA_DXE_HEADER_SIZE);
3972
3973 /*Update resource count */
3974 pTLCb->uResCount -= uResLen;
3975 }
3976 else
3977 {
3978 ucResult = ( pTLCb->uResCount > uResLen )?VOS_TRUE:VOS_FALSE;
3979 break; /* Out of resources or reached max len */
3980 }
3981 }
3982 else if (( pTLCb->tlBAPClient.vosPendingDataBuff ) &&
3983 ( WDA_TLI_MIN_RES_BAP <= pTLCb->uResCount ) &&
Gopichand Nakkala7e48ca72012-12-31 14:15:07 -08003984 ( 0 == pTLCb->ucTxSuspended ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07003985 {
3986 WDA_TLI_PROCESS_FRAME_LEN( pTLCb->tlBAPClient.vosPendingDataBuff,
3987 usPktLen, uResLen, uTotalPktLen);
3988
3989 VOS_ASSERT(usPktLen <= WLANTL_MAX_ALLOWED_LEN);
3990
3991 if ( ( pTLCb->uResCount > (uResLen + WDA_TLI_MIN_RES_MF ) ) &&
3992 ( uRemaining > uTotalPktLen ))
3993 {
3994 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
3995 "WLAN TL:Chaining BT-AMP frame on GetFrame"));
3996
3997 vos_pkt_chain_packet( vosDataBuff,
3998 pTLCb->tlBAPClient.vosPendingDataBuff,
3999 1 /*true*/ );
4000
4001 /*BAP frames cannot be delayed*/
4002 pTLCb->bUrgent = TRUE;
4003
4004 vos_atomic_set_U32( (v_U32_t*)&pTLCb->tlBAPClient.vosPendingDataBuff,
4005 (v_U32_t)NULL);
4006
4007 /*Update remaining len from SSC */
4008 uRemaining -= (usPktLen + WDA_DXE_HEADER_SIZE);
4009
4010 /*Update resource count */
4011 pTLCb->uResCount -= uResLen;
4012 }
4013 else
4014 {
Jeff Johnson295189b2012-06-20 16:38:30 -07004015 ucResult = uResLen + WDA_TLI_MIN_RES_MF;
Jeff Johnson295189b2012-06-20 16:38:30 -07004016 break; /* Out of resources or reached max len */
4017 }
4018 }
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -07004019 /* note: this feature implemented only after WLAN_INGETRATED_SOC */
4020 /* search 'EAPOL_HI_PRIORITY' will show EAPOL HI_PRIORITY change in TL and WDI
4021 by default, EAPOL will be treated as higher priority, which means
4022 use mgmt_pool and DXE_TX_HI prority channel.
4023 this is introduced to address EAPOL failure under high background traffic
4024 with multi-channel concurrent mode. But this change works in SCC or standalone, too.
4025 see CR#387009 and WCNSOS-8
4026 */
4027 else if (( WDA_TLI_MIN_RES_MF <= pTLCb->uResCount )&&
4028 ( 0 == pTLCb->ucTxSuspended ) &&
4029 ( uFlowMask & ( 1 << WDA_TXFLOW_MGMT ) )
4030 )
4031 {
4032 vosTempBuf = NULL;
4033 /*---------------------------------------------------------------------
4034 Check to see if there was any EAPOL packet is pending
4035 *--------------------------------------------------------------------*/
4036 for ( i = 0; i < WLAN_MAX_STA_COUNT; i++)
4037 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304038 if ((NULL != pTLCb->atlSTAClients[i]) &&
4039 (pTLCb->atlSTAClients[i]->ucExists) &&
4040 (0 == pTLCb->atlSTAClients[i]->ucTxSuspended) &&
Tushnim Bhattacharyya39a8f182013-02-20 18:10:30 -08004041 (WLANTL_STA_CONNECTED == pTLCb->atlSTAClients[i]->tlState) &&
4042 (pTLCb->atlSTAClients[i]->ucPktPending)
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -07004043 )
4044 break;
4045 }
4046
4047 if (i >= WLAN_MAX_STA_COUNT)
4048 {
4049 /* No More to Serve Exit Get Frames */
4050 break;
4051 }
4052 /* Serve EAPOL frame with HI_FLOW_MASK */
4053 ucSTAId = i;
4054
Tushnim Bhattacharyya39a8f182013-02-20 18:10:30 -08004055 for (j = WLANTL_MAX_AC ; j > 0; j--)
4056 {
4057 if (0 != pTLCb->atlSTAClients[ucSTAId]->aucACMask[j-1])
4058 {
4059 pTLCb->atlSTAClients[ucSTAId]->ucCurrentAC = j-1;
4060 pTLCb->uCurServedAC = j-1;
4061 }
4062 }
4063
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304064 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
4065
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -07004066 wSTAEvent = WLANTL_TX_EVENT;
4067
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304068 pfnSTAFsm = tlSTAFsm[pClientSTA->tlState].
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -07004069 pfnSTATbl[wSTAEvent];
4070
4071 if ( NULL != pfnSTAFsm )
4072 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304073 pClientSTA->ucNoMoreData = 0;
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -07004074 vosStatus = pfnSTAFsm( pvosGCtx, ucSTAId, &vosTempBuf);
4075
4076 if (( VOS_STATUS_SUCCESS != vosStatus ) &&
4077 ( NULL != vosTempBuf ))
4078 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304079 pClientSTA->pfnSTATxComp( pvosGCtx, vosTempBuf, vosStatus );
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -07004080 vosTempBuf = NULL;
4081 break;
4082 }/* status success*/
4083 }
4084
4085 if (NULL != vosTempBuf)
4086 {
4087 WDA_TLI_PROCESS_FRAME_LEN( vosTempBuf, usPktLen, uResLen, uTotalPktLen);
4088
4089 VOS_ASSERT( usPktLen <= WLANTL_MAX_ALLOWED_LEN);
4090
4091 TLLOG4(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_LOW,
4092 "WLAN TL:Resources needed by frame: %d", uResLen));
4093
4094 if ( ( pTLCb->uResCount >= (uResLen + WDA_TLI_MIN_RES_MF ) ) &&
4095 ( uRemaining > uTotalPktLen )
4096 )
4097 {
4098 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
4099 "WLAN TL:Chaining data frame on GetFrame"));
4100
4101 vos_pkt_chain_packet( vosDataBuff, vosTempBuf, 1 /*true*/ );
4102
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -07004103 /*EAPOL frame cannot be delayed*/
4104 pTLCb->bUrgent = TRUE;
4105
4106 vosTempBuf = NULL;
4107
4108 /*Update remaining len from SSC */
4109 uRemaining -= (usPktLen + WDA_DXE_HEADER_SIZE);
4110
4111 /*Update resource count */
4112 pTLCb->uResCount -= uResLen;
4113
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -07004114 //fow control update
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304115 pClientSTA->uIngress_length += uResLen;
4116 pClientSTA->uBuffThresholdMax = (pClientSTA->uBuffThresholdMax >= uResLen) ?
4117 (pClientSTA->uBuffThresholdMax - uResLen) : 0;
Tushnim Bhattacharyya39a8f182013-02-20 18:10:30 -08004118 pClientSTA->ucEapolPktPending = 0;
4119 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
4120 "WLAN TL:GetFrames STA: %d EAPOLPktPending %d",
4121 ucSTAId, pClientSTA->ucEapolPktPending);
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -07004122 }
4123 }
4124 else
4125 { // no EAPOL frames exit Get frames
Tushnim Bhattacharyya39a8f182013-02-20 18:10:30 -08004126 TLLOG2(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
4127 "WLAN TL:GetFrames STA: %d, no EAPOL frame, continue.",
4128 ucSTAId));
4129 continue;
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -07004130 }
4131 }
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -07004132
Jeff Johnson9b5dc4d2013-02-22 21:28:47 -08004133 else if (( WDA_TLI_MIN_RES_DATA <= pTLCb->uResCount ) &&
4134 ( 0 == pTLCb->ucTxSuspended ) &&
4135 (( uFlowMask & ( 1 << WDA_TXFLOW_AC_BK ) ) ||
4136 ( uFlowMask & ( 1 << WDA_TXFLOW_AC_BE ) ) ||
4137 ( uFlowMask & ( 1 << WDA_TXFLOW_AC_VI ) ) ||
4138 ( uFlowMask & ( 1 << WDA_TXFLOW_AC_VO ) )) )
Jeff Johnson295189b2012-06-20 16:38:30 -07004139 {
4140 /*---------------------------------------------------------------------
4141 Check to see if there was any packet left behind previously due to
4142 size constraints
4143 ---------------------------------------------------------------------*/
4144 vosTempBuf = NULL;
4145
4146 if ( NULL != pTLCb->vosTempBuf )
4147 {
4148 vosTempBuf = pTLCb->vosTempBuf;
4149 pTLCb->vosTempBuf = NULL;
4150 ucSTAId = pTLCb->ucCachedSTAId;
4151 ucAC = pTLCb->ucCachedAC;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304152
4153 if ( NULL == pTLCb->atlSTAClients[ucSTAId] )
4154 {
4155 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
4156 "WLAN TL:Client Memory was not allocated on %s", __func__));
Madan Mohan Koyylamudi64258222013-01-30 14:35:10 +05304157 continue;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304158 }
4159
4160 pTLCb->atlSTAClients[ucSTAId]->ucNoMoreData = 0;
Madan Mohan Koyylamudi64258222013-01-30 14:35:10 +05304161 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
Jeff Johnson295189b2012-06-20 16:38:30 -07004162
4163 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
4164 "WLAN TL:Chaining cached data frame on GetFrame"));
4165 }
4166 else
4167 {
4168 WLAN_TLGetNextTxIds( pvosGCtx, &ucSTAId);
4169 if (ucSTAId >= WLAN_MAX_STA_COUNT)
4170 {
4171 /* Packets start coming in even after insmod Without *
4172 starting Hostapd or Interface being up *
4173 During which cases STAID is invaled and hence
4174 the check. HalMsg_ScnaComplete Triggers */
4175
4176 break;
4177 }
4178 /* ucCurrentAC should have correct AC to be served by calling
4179 WLAN_TLGetNextTxIds */
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304180 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304181 if ( NULL == pClientSTA )
4182 {
4183 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
4184 "WLAN TL:Client Memory was not allocated on %s", __func__));
Madan Mohan Koyylamudi64258222013-01-30 14:35:10 +05304185 continue;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304186 }
4187
4188 ucAC = pClientSTA->ucCurrentAC;
4189
4190 pClientSTA->ucNoMoreData = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07004191 TLLOG4(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_LOW,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004192 "WLAN TL: %s get one data frame, station ID %d ", __func__, ucSTAId));
Jeff Johnson295189b2012-06-20 16:38:30 -07004193 /*-------------------------------------------------------------------
4194 Check to see that STA is valid and tx is not suspended
4195 -------------------------------------------------------------------*/
4196 if ( ( ! WLANTL_STA_ID_INVALID( ucSTAId ) ) &&
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304197 ( 0 == pClientSTA->ucTxSuspended ) &&
4198 ( 0 == pClientSTA->fcStaTxDisabled) )
Jeff Johnson295189b2012-06-20 16:38:30 -07004199 {
4200 TLLOG4(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_LOW,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004201 "WLAN TL: %s sta id valid and not suspended ",__func__));
Jeff Johnson295189b2012-06-20 16:38:30 -07004202 wSTAEvent = WLANTL_TX_EVENT;
4203
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304204 pfnSTAFsm = tlSTAFsm[pClientSTA->tlState].
Jeff Johnson295189b2012-06-20 16:38:30 -07004205 pfnSTATbl[wSTAEvent];
4206
4207 if ( NULL != pfnSTAFsm )
4208 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304209 pClientSTA->ucNoMoreData = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004210 vosStatus = pfnSTAFsm( pvosGCtx, ucSTAId, &vosTempBuf);
4211
4212 if (( VOS_STATUS_SUCCESS != vosStatus ) &&
4213 ( NULL != vosTempBuf ))
4214 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304215 pClientSTA->pfnSTATxComp( pvosGCtx,
Jeff Johnson295189b2012-06-20 16:38:30 -07004216 vosTempBuf,
4217 vosStatus );
4218 vosTempBuf = NULL;
4219 }/* status success*/
4220 }/*NULL function state*/
4221 }/* valid STA id and ! suspended*/
4222 else
4223 {
4224 if ( ! WLANTL_STA_ID_INVALID( ucSTAId ) )
4225 {
4226 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
4227 "WLAN TL:Not fetching frame because suspended for sta ID %d",
4228 ucSTAId));
4229 }
4230 }
4231 }/* data */
4232
4233 if ( NULL != vosTempBuf )
4234 {
4235 WDA_TLI_PROCESS_FRAME_LEN( vosTempBuf, usPktLen, uResLen, uTotalPktLen);
4236
4237 VOS_ASSERT( usPktLen <= WLANTL_MAX_ALLOWED_LEN);
4238
4239 TLLOG4(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_LOW,
4240 "WLAN TL:Resources needed by frame: %d", uResLen));
4241
4242 if ( ( pTLCb->uResCount >= (uResLen + WDA_TLI_MIN_RES_BAP ) ) &&
Jeff Johnson9b5dc4d2013-02-22 21:28:47 -08004243 ( uRemaining > uTotalPktLen ) &&
4244 ( uFlowMask & ( 1 << ucAC ) ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07004245 {
4246 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
4247 "WLAN TL:Chaining data frame on GetFrame"));
4248
4249 vos_pkt_chain_packet( vosDataBuff, vosTempBuf, 1 /*true*/ );
4250 vosTempBuf = NULL;
4251
4252 /*Update remaining len from SSC */
4253 uRemaining -= (usPktLen + WDA_DXE_HEADER_SIZE);
4254
4255 /*Update resource count */
4256 pTLCb->uResCount -= uResLen;
4257
Jeff Johnson295189b2012-06-20 16:38:30 -07004258 //fow control update
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304259 pClientSTA->uIngress_length += uResLen;
4260 pClientSTA->uBuffThresholdMax = (pClientSTA->uBuffThresholdMax >= uResLen) ?
4261 (pClientSTA->uBuffThresholdMax - uResLen) : 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004262
4263 }
4264 else
4265 {
4266 /* Store this for later tx - already fetched from HDD */
4267 pTLCb->vosTempBuf = vosTempBuf;
4268 pTLCb->ucCachedSTAId = ucSTAId;
4269 pTLCb->ucCachedAC = ucAC;
Jeff Johnson295189b2012-06-20 16:38:30 -07004270 ucResult = uResLen + WDA_TLI_MIN_RES_BAP;
4271 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
4272 "min %d res required by TL.", ucResult ));
Jeff Johnson295189b2012-06-20 16:38:30 -07004273 break; /* Out of resources or reached max len */
4274 }
4275 }
4276 else
4277 {
4278 for ( i = 0; i < WLAN_MAX_STA_COUNT; i++)
4279 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304280 if (NULL != pTLCb->atlSTAClients[i] && (pTLCb->atlSTAClients[i]->ucExists) &&
4281 (pTLCb->atlSTAClients[i]->ucPktPending))
Jeff Johnson295189b2012-06-20 16:38:30 -07004282 {
4283 /* There is station to be Served */
4284 break;
4285 }
4286 }
4287 if (i >= WLAN_MAX_STA_COUNT)
4288 {
4289 /* No More to Serve Exit Get Frames */
4290 break;
4291 }
4292 else
4293 {
4294 /* More to be Served */
4295 continue;
4296 }
4297 }
4298 }
4299 else
4300 {
4301 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
4302 "WLAN TL:Returning from GetFrame: resources = %d suspended = %d",
4303 pTLCb->uResCount, pTLCb->ucTxSuspended));
Jeff Johnson295189b2012-06-20 16:38:30 -07004304 /* TL is starving even when DXE is not in low resource condition
4305 Return min resource number required and Let DXE deceide what to do */
4306 if(( 0 == pTLCb->ucTxSuspended ) &&
4307 (( uFlowMask & ( 1 << WDA_TXFLOW_AC_BK ) ) ||
4308 ( uFlowMask & ( 1 << WDA_TXFLOW_AC_BE ) ) ||
4309 ( uFlowMask & ( 1 << WDA_TXFLOW_AC_VI ) ) ||
4310 ( uFlowMask & ( 1 << WDA_TXFLOW_AC_VO ) )))
4311 {
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07004312 TLLOG1(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -07004313 "WLAN TL:Returning from GetFrame: resources = %d",
4314 pTLCb->uResCount));
4315 ucResult = WDA_TLI_MIN_RES_DATA;
4316 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004317 break; /*out of min data resources*/
4318 }
4319
4320 pTLCb->usPendingTxCompleteCount++;
4321 /* Move data buffer up one packet */
4322 vos_pkt_walk_packet_chain( vosDataBuff, &vosDataBuff, 0/*false*/ );
4323 }
4324
4325 /*----------------------------------------------------------------------
4326 Packet chain starts at root + 1
4327 ----------------------------------------------------------------------*/
4328 vos_pkt_walk_packet_chain( vosRoot, &vosDataBuff, 1/*true*/ );
4329
4330 *pvosDataBuff = vosDataBuff;
4331 VOS_ASSERT( pbUrgent );
4332 *pbUrgent = pTLCb->bUrgent;
4333 return ucResult;
4334}/* WLANTL_GetFrames */
4335
4336
4337/*==========================================================================
4338
4339 FUNCTION WLANTL_TxComp
4340
4341 DESCRIPTION
4342 It is being called by BAL upon asynchronous notification of the packet
4343 or packets being sent over the bus.
4344
4345 DEPENDENCIES
4346 Tx complete cannot be called without a previous transmit.
4347
4348 PARAMETERS
4349
4350 IN
4351 pvosGCtx: pointer to the global vos context; a handle to TL's
4352 or BAL's control block can be extracted from its context
4353 vosDataBuff: it will contain a pointer to the first buffer for which
4354 the BAL report is being made, if there is more then one
4355 packet they will be chained using vOSS buffers.
4356 wTxStatus: the status of the transmitted packet, see above chapter
4357 on HDD interaction for a list of possible values
4358
4359 RETURN VALUE
4360 The result code associated with performing the operation
4361
4362 VOS_STATUS_E_INVAL: Input parameters are invalid
4363 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
4364 page fault
4365 VOS_STATUS_E_EXISTS: Station was not registered
4366 VOS_STATUS_SUCCESS: Everything is good :)
4367
4368 SIDE EFFECTS
4369
4370============================================================================*/
4371VOS_STATUS
4372WLANTL_TxComp
4373(
4374 v_PVOID_t pvosGCtx,
4375 vos_pkt_t *pFrameDataBuff,
4376 VOS_STATUS wTxStatus
4377)
4378{
4379 vos_pkt_t* vosDataBuff = (vos_pkt_t*)pFrameDataBuff;
4380 WLANTL_CbType* pTLCb = NULL;
4381 WLANTL_TxCompCBType pfnTxComp = NULL;
4382 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07004383 vos_pkt_t* vosTempTx = NULL;
4384
4385 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
4386
4387 /*------------------------------------------------------------------------
4388 Sanity check
4389 ------------------------------------------------------------------------*/
4390 if ( NULL == vosDataBuff )
4391 {
4392 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
4393 "WLAN TL:Extraneous NULL data pointer on WLANTL_TxComp"));
4394 return VOS_STATUS_E_INVAL;
4395 }
4396
4397 /*------------------------------------------------------------------------
4398 Extract TL control block
4399 ------------------------------------------------------------------------*/
4400 pTLCb = VOS_GET_TL_CB(pvosGCtx);
4401 if ( NULL == pTLCb )
4402 {
4403 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
4404 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_TxComp"));
4405 return VOS_STATUS_E_FAULT;
4406 }
4407
4408 while ((0 < pTLCb->usPendingTxCompleteCount) &&
4409 ( VOS_STATUS_SUCCESS == vosStatus ) &&
4410 ( NULL != vosDataBuff))
4411 {
4412 vos_pkt_get_user_data_ptr( vosDataBuff, VOS_PKT_USER_DATA_ID_TL,
4413 (v_PVOID_t)&pfnTxComp);
4414
4415 /*it should never be NULL - default handler should be registered if none*/
4416 if ( NULL == pfnTxComp )
4417 {
4418 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
4419 "WLAN TL:NULL pointer to Tx Complete on WLANTL_TxComp"));
4420 VOS_ASSERT(0);
4421 return VOS_STATUS_E_FAULT;
4422 }
4423
4424 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05304425 "WLAN TL:Calling Tx complete for pkt %p in function %p",
Jeff Johnson295189b2012-06-20 16:38:30 -07004426 vosDataBuff, pfnTxComp));
4427
4428 vosTempTx = vosDataBuff;
4429 vosStatus = vos_pkt_walk_packet_chain( vosDataBuff,
4430 &vosDataBuff, 1/*true*/);
4431
4432 pfnTxComp( pvosGCtx, vosTempTx, wTxStatus );
4433
4434 pTLCb->usPendingTxCompleteCount--;
4435 }
4436
Jeff Johnson295189b2012-06-20 16:38:30 -07004437
4438 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
4439 "WLAN TL: current TL values are: resources = %d "
4440 "pTLCb->usPendingTxCompleteCount = %d",
4441 pTLCb->uResCount, pTLCb->usPendingTxCompleteCount));
4442
4443 return VOS_STATUS_SUCCESS;
4444}/* WLANTL_TxComp */
4445
4446/*==========================================================================
4447
4448 FUNCTION WLANTL_CacheSTAFrame
4449
4450 DESCRIPTION
4451 Internal utility function for for caching incoming data frames that do
4452 not have a registered station yet.
4453
4454 DEPENDENCIES
4455 TL must be initiailized before this function gets called.
4456 In order to benefit from thsi caching, the components must ensure that
4457 they will only register with TL at the moment when they are fully setup
4458 and ready to receive incoming data
4459
4460 PARAMETERS
4461
4462 IN
4463
4464 pTLCb: TL control block
4465 ucSTAId: station id
4466 vosTempBuff: the data packet
4467 uDPUSig: DPU signature of the incoming packet
4468 bBcast: true if packet had the MC/BC bit set
4469
4470 RETURN VALUE
4471 The result code associated with performing the operation
4472
4473 VOS_STATUS_E_FAULT: pointer to TL cb is NULL or STA Id invalid ; access
4474 would cause a page fault
4475 VOS_STATUS_SUCCESS: Everything is good :)
4476
4477 SIDE EFFECTS
4478
4479============================================================================*/
4480static VOS_STATUS
4481WLANTL_CacheSTAFrame
4482(
4483 WLANTL_CbType* pTLCb,
4484 v_U8_t ucSTAId,
4485 vos_pkt_t* vosTempBuff,
4486 v_U32_t uDPUSig,
4487 v_U8_t bBcast,
4488 v_U8_t ucFrmType
4489)
4490{
4491 v_U8_t ucUcastSig;
4492 v_U8_t ucBcastSig;
4493 v_BOOL_t bOldSTAPkt;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304494 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004495 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
4496
4497 /*-------------------------------------------------------------------------
4498 Sanity check
4499 -------------------------------------------------------------------------*/
4500 if (( NULL == pTLCb ) || ( NULL == vosTempBuff ) )
4501 {
4502 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05304503 "WLAN TL: Invalid input pointer on WLANTL_CacheSTAFrame TL %p"
4504 " Packet %p", pTLCb, vosTempBuff ));
Jeff Johnson295189b2012-06-20 16:38:30 -07004505 return VOS_STATUS_E_FAULT;
4506 }
4507
4508 if ( WLANTL_STA_ID_INVALID( ucSTAId ) )
4509 {
4510 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
4511 "WLAN TL:Invalid station id requested on WLANTL_CacheSTAFrame"));
4512 return VOS_STATUS_E_FAULT;
4513 }
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304514 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
4515
4516 if ( NULL == pClientSTA )
4517 {
4518 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
4519 "WLAN TL:Client Memory was not allocated on %s", __func__));
4520 return VOS_STATUS_E_FAILURE;
4521 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004522
4523 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
4524 "WLAN TL:Attempting to cache pkt for STA %d, BD DPU Sig: %d with sig UC: %d, BC: %d",
4525 ucSTAId, uDPUSig,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304526 pClientSTA->wSTADesc.ucUcastSig,
4527 pClientSTA->wSTADesc.ucBcastSig));
Jeff Johnson295189b2012-06-20 16:38:30 -07004528
4529 if(WLANTL_IS_CTRL_FRAME(ucFrmType))
4530 {
4531 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
4532 "WLAN TL: No need to cache CTRL frame. Dropping"));
4533 vos_pkt_return_packet(vosTempBuff);
4534 return VOS_STATUS_SUCCESS;
4535 }
4536
4537 /*-------------------------------------------------------------------------
4538 Check if the packet that we are trying to cache belongs to the old
4539 registered station (if any) or the new (potentially)upcoming station
4540
4541 - If the STA with this Id was never registered with TL - the signature
4542 will be invalid;
4543 - If the STA was previously registered TL will have cached the former
4544 set of DPU signatures
4545 -------------------------------------------------------------------------*/
4546 if ( bBcast )
4547 {
4548 ucBcastSig = (v_U8_t)uDPUSig;
4549 bOldSTAPkt = (( WLAN_TL_INVALID_B_SIG !=
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304550 pClientSTA->wSTADesc.ucBcastSig ) &&
4551 ( ucBcastSig == pClientSTA->wSTADesc.ucBcastSig ));
Jeff Johnson295189b2012-06-20 16:38:30 -07004552 }
4553 else
4554 {
4555 ucUcastSig = (v_U8_t)uDPUSig;
4556 bOldSTAPkt = (( WLAN_TL_INVALID_U_SIG !=
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304557 pClientSTA->wSTADesc.ucUcastSig ) &&
4558 ( ucUcastSig == pClientSTA->wSTADesc.ucUcastSig ));
Jeff Johnson295189b2012-06-20 16:38:30 -07004559 }
4560
4561 /*------------------------------------------------------------------------
4562 If the value of the DPU SIG matches the old, this packet will not
4563 be cached as it belonged to the former association
4564 In case the SIG does not match - this is a packet for a potentially new
4565 associated station
4566 -------------------------------------------------------------------------*/
Varun Reddy Yeturua39b9902013-01-18 15:48:32 -08004567 if ( bOldSTAPkt || bBcast )
Jeff Johnson295189b2012-06-20 16:38:30 -07004568 {
4569 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
4570 "WLAN TL:Data packet matches old sig for sig DPU: %d UC: %d, "
4571 "BC: %d - dropping",
4572 uDPUSig,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304573 pClientSTA->wSTADesc.ucUcastSig,
4574 pClientSTA->wSTADesc.ucBcastSig));
Jeff Johnson295189b2012-06-20 16:38:30 -07004575 vos_pkt_return_packet(vosTempBuff);
4576 }
4577 else
4578 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304579 if ( NULL == pClientSTA->vosBegCachedFrame )
Jeff Johnson295189b2012-06-20 16:38:30 -07004580 {
4581 /*this is the first frame that we are caching */
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304582 pClientSTA->vosBegCachedFrame = vosTempBuff;
Jeff Johnson295189b2012-06-20 16:38:30 -07004583 }
4584 else
4585 {
4586 /*this is a subsequent frame that we are caching: chain to the end */
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304587 vos_pkt_chain_packet(pClientSTA->vosEndCachedFrame,
Jeff Johnson295189b2012-06-20 16:38:30 -07004588 vosTempBuff, VOS_TRUE);
4589 }
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304590 pClientSTA->vosEndCachedFrame = vosTempBuff;
Jeff Johnson295189b2012-06-20 16:38:30 -07004591 }/*else new packet*/
4592
4593 return VOS_STATUS_SUCCESS;
4594}/*WLANTL_CacheSTAFrame*/
4595
4596/*==========================================================================
4597
4598 FUNCTION WLANTL_FlushCachedFrames
4599
4600 DESCRIPTION
4601 Internal utility function used by TL to flush the station cache
4602
4603 DEPENDENCIES
4604 TL must be initiailized before this function gets called.
4605
4606 PARAMETERS
4607
4608 IN
4609
4610 vosDataBuff: it will contain a pointer to the first cached buffer
4611 received,
4612
4613 RETURN VALUE
4614 The result code associated with performing the operation
4615
4616 VOS_STATUS_SUCCESS: Everything is good :)
4617
4618 SIDE EFFECTS
4619
4620 NOTE
4621 This function doesn't re-initialize vosDataBuff to NULL. It's caller's
4622 responsibility to do so, if required, after this function call.
4623 Because of this restriction, we decide to make this function to static
4624 so that upper layer doesn't need to be aware of this restriction.
4625
4626============================================================================*/
4627static VOS_STATUS
4628WLANTL_FlushCachedFrames
4629(
4630 vos_pkt_t* vosDataBuff
4631)
4632{
4633 /*----------------------------------------------------------------------
4634 Return the entire chain to vos if there are indeed cache frames
4635 ----------------------------------------------------------------------*/
4636 if ( NULL != vosDataBuff )
4637 {
4638 vos_pkt_return_packet(vosDataBuff);
4639 }
4640
4641 return VOS_STATUS_SUCCESS;
4642}/*WLANTL_FlushCachedFrames*/
4643
4644/*==========================================================================
4645
4646 FUNCTION WLANTL_ForwardSTAFrames
4647
4648 DESCRIPTION
4649 Internal utility function for either forwarding cached data to the station after
4650 the station has been registered, or flushing cached data if the station has not
4651 been registered.
4652
4653
4654 DEPENDENCIES
4655 TL must be initiailized before this function gets called.
4656
4657 PARAMETERS
4658
4659 IN
4660
4661 pTLCb: TL control block
4662 ucSTAId: station id
4663
4664 RETURN VALUE
4665 The result code associated with performing the operation
4666
4667 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
4668 page fault
4669 VOS_STATUS_SUCCESS: Everything is good :)
4670
4671 SIDE EFFECTS
4672 This function doesn't re-initialize vosDataBuff to NULL. It's caller's
4673 responsibility to do so, if required, after this function call.
4674 Because of this restriction, we decide to make this function to static
4675 so that upper layer doesn't need to be aware of this restriction.
4676
4677============================================================================*/
4678static VOS_STATUS
4679WLANTL_ForwardSTAFrames
4680(
4681 void* pvosGCtx,
4682 v_U8_t ucSTAId,
4683 v_U8_t ucUcastSig,
4684 v_U8_t ucBcastSig
4685)
4686{
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304687 WLANTL_CbType* pTLCb = NULL;
4688 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004689 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
4690
4691 /*-------------------------------------------------------------------------
4692 Sanity check
4693 -------------------------------------------------------------------------*/
4694 pTLCb = VOS_GET_TL_CB(pvosGCtx);
4695 if ( NULL == pTLCb )
4696 {
4697 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05304698 "WLAN TL: Invalid input pointer on WLANTL_ForwardSTAFrames TL %p",
Jeff Johnson295189b2012-06-20 16:38:30 -07004699 pTLCb ));
4700 return VOS_STATUS_E_FAULT;
4701 }
4702
4703 if ( WLANTL_STA_ID_INVALID( ucSTAId ) )
4704 {
4705 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
4706 "WLAN TL:Invalid station id requested on WLANTL_ForwardSTAFrames"));
4707 return VOS_STATUS_E_FAULT;
4708 }
4709
4710 //WLAN_TL_LOCK_STA_CACHE(pTLCb->atlSTAClients[ucSTAId]);
4711
4712 /*------------------------------------------------------------------------
4713 Check if station has not been registered in the mean while
4714 if not registered, flush cached frames.
4715 ------------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304716 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
4717
4718 if ( NULL == pClientSTA )
4719 {
4720 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
4721 "WLAN TL:Client Memory was not allocated on %s", __func__));
4722 return VOS_STATUS_E_FAILURE;
4723 }
4724
4725 if ( 0 == pClientSTA->ucExists )
Jeff Johnson295189b2012-06-20 16:38:30 -07004726 {
4727 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
4728 "WLAN TL:Station has been deleted for STA %d - flushing cache", ucSTAId));
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304729 WLANTL_FlushCachedFrames(pClientSTA->vosBegCachedFrame);
Jeff Johnson295189b2012-06-20 16:38:30 -07004730 goto done;
4731 }
4732
4733 /*------------------------------------------------------------------------
4734 Forwarding cache frames received while the station was in the process
4735 of being registered with the rest of the SW components
4736
4737 Access to the cache must be locked; similarly updating the signature and
4738 the existence flag must be synchronized because these values are checked
4739 during cached
4740 ------------------------------------------------------------------------*/
4741 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
4742 "WLAN TL:Preparing to fwd packets for STA %d", ucSTAId));
4743
4744 /*-----------------------------------------------------------------------
4745 Save the new signature values
4746 ------------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304747 pClientSTA->wSTADesc.ucUcastSig = ucUcastSig;
4748 pClientSTA->wSTADesc.ucBcastSig = ucBcastSig;
Jeff Johnson295189b2012-06-20 16:38:30 -07004749
4750 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
4751 "WLAN TL:Fwd-ing packets for STA %d UC %d BC %d",
4752 ucSTAId, ucUcastSig, ucBcastSig));
4753
4754 /*-------------------------------------------------------------------------
4755 Check to see if we have any cached data to forward
4756 -------------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304757 if ( NULL != pClientSTA->vosBegCachedFrame )
Jeff Johnson295189b2012-06-20 16:38:30 -07004758 {
4759 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
4760 "WLAN TL: Fwd-ing Cached packets for station %d", ucSTAId ));
4761
4762 WLANTL_RxCachedFrames( pTLCb,
4763 ucSTAId,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304764 pClientSTA->vosBegCachedFrame);
Jeff Johnson295189b2012-06-20 16:38:30 -07004765 }
4766 else
4767 {
4768 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
4769 "WLAN TL: NO cached packets for station %d", ucSTAId ));
4770 }
4771
4772done:
4773 /*-------------------------------------------------------------------------
4774 Clear the station cache
4775 -------------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304776 pClientSTA->vosBegCachedFrame = NULL;
4777 pClientSTA->vosEndCachedFrame = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004778
4779 /*-----------------------------------------------------------------------
4780 After all the init is complete we can mark the existance flag
4781 ----------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304782 pClientSTA->ucRxBlocked = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004783
4784 //WLAN_TL_UNLOCK_STA_CACHE(pTLCb->atlSTAClients[ucSTAId]);
4785 return VOS_STATUS_SUCCESS;
4786
4787}/*WLANTL_ForwardSTAFrames*/
4788
4789
4790#ifdef FEATURE_WLAN_CCX
4791/*==========================================================================
4792
4793 FUNCTION WLANTL_IsIAPPFrame
4794
4795 DESCRIPTION
4796 Internal utility function for detecting incoming CCX IAPP frames
4797
4798 DEPENDENCIES
4799
4800 PARAMETERS
4801
4802 IN
4803
4804 pvBDHeader: pointer to the BD header
4805 vosTempBuff: the data packet
4806
4807 IN/OUT
4808 pFirstDataPktArrived: static from caller function; used for rssi
4809 computation
4810 RETURN VALUE
4811 The result code associated with performing the operation
4812
4813 VOS_TRUE: It is a IAPP frame
4814 VOS_FALSE: It is NOT IAPP frame
4815
4816 SIDE EFFECTS
4817
4818============================================================================*/
4819v_BOOL_t
4820WLANTL_IsIAPPFrame
4821(
4822 v_PVOID_t pvBDHeader,
4823 vos_pkt_t* vosTempBuff
4824)
4825{
4826 v_U16_t usMPDUDOffset;
4827 v_U8_t ucOffset;
4828 v_U8_t ucSnapHdr[WLANTL_LLC_SNAP_SIZE];
4829 v_SIZE_t usSnapHdrSize = WLANTL_LLC_SNAP_SIZE;
4830 VOS_STATUS vosStatus;
4831
4832 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
4833
4834 /*------------------------------------------------------------------------
4835 Check if OUI field is present.
4836 -------------------------------------------------------------------------*/
4837 if ( VOS_FALSE == WDA_IS_RX_LLC_PRESENT(pvBDHeader) )
4838 {
4839 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
4840 "WLAN TL:LLC header removed, cannot determine BT-AMP type -"
4841 "dropping pkt"));
4842 /* Drop packet */
4843 vos_pkt_return_packet(vosTempBuff);
4844 return VOS_TRUE;
4845 }
4846 usMPDUDOffset = (v_U8_t)WDA_GET_RX_MPDU_DATA_OFFSET(pvBDHeader);
4847 ucOffset = (v_U8_t)usMPDUDOffset + WLANTL_LLC_SNAP_OFFSET;
4848
4849 vosStatus = vos_pkt_extract_data( vosTempBuff, ucOffset,
4850 (v_PVOID_t)ucSnapHdr, &usSnapHdrSize);
4851
4852 if (( VOS_STATUS_SUCCESS != vosStatus))
4853 {
4854 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
4855 "Unable to extract Snap Hdr of data packet -"
4856 "dropping pkt"));
4857 return VOS_FALSE;
4858 }
4859
4860 /*------------------------------------------------------------------------
4861 Check if this is IAPP frame by matching Aironet Snap hdr.
4862 -------------------------------------------------------------------------*/
4863 // Compare returns 1 if values are same and 0
4864 // if not the same.
4865 if (( WLANTL_LLC_SNAP_SIZE != usSnapHdrSize ) ||
4866 ( 0 == vos_mem_compare(ucSnapHdr, (v_PVOID_t)WLANTL_AIRONET_SNAP_HEADER,
4867 WLANTL_LLC_SNAP_SIZE ) ))
4868 {
4869 return VOS_FALSE;
4870 }
4871
4872 return VOS_TRUE;
4873
4874}
4875#endif //FEATURE_WLAN_CCX
4876
4877/*==========================================================================
4878
4879 FUNCTION WLANTL_ProcessBAPFrame
4880
4881 DESCRIPTION
4882 Internal utility function for processing incoming BT-AMP frames
4883
4884 DEPENDENCIES
4885 TL must be initiailized before this function gets called.
4886 Bothe the BT-AMP station and the BAP Ctrl path must have been previously
4887 registered with TL.
4888
4889 PARAMETERS
4890
4891 IN
4892
4893 pvBDHeader: pointer to the BD header
4894 vosTempBuff: the data packet
4895 pTLCb: TL control block
4896 ucSTAId: station id
4897
4898 IN/OUT
4899 pFirstDataPktArrived: static from caller function; used for rssi
4900 computation
4901 RETURN VALUE
4902 The result code associated with performing the operation
4903
4904 VOS_STATUS_E_INVAL: Input parameters are invalid
4905 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
4906 page fault
4907 VOS_STATUS_SUCCESS: Everything is good :)
4908
4909 SIDE EFFECTS
4910
4911============================================================================*/
4912v_BOOL_t
4913WLANTL_ProcessBAPFrame
4914(
4915 v_PVOID_t pvBDHeader,
4916 vos_pkt_t* vosTempBuff,
4917 WLANTL_CbType* pTLCb,
4918 v_U8_t* pFirstDataPktArrived,
4919 v_U8_t ucSTAId
4920)
4921{
4922 v_U16_t usMPDUDOffset;
4923 v_U8_t ucOffset;
4924 v_U8_t ucOUI[WLANTL_LLC_OUI_SIZE];
4925 v_SIZE_t usOUISize = WLANTL_LLC_OUI_SIZE;
4926 VOS_STATUS vosStatus;
4927 v_U16_t usType;
4928 v_SIZE_t usTypeLen = sizeof(usType);
4929 v_U8_t ucMPDUHOffset;
4930 v_U8_t ucMPDUHLen = 0;
4931 v_U16_t usActualHLen = 0;
4932
4933 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
4934
4935 /*------------------------------------------------------------------------
4936 Extract OUI and type from LLC and validate; if non-data send to BAP
4937 -------------------------------------------------------------------------*/
4938 if ( VOS_FALSE == WDA_IS_RX_LLC_PRESENT(pvBDHeader) )
4939 {
4940 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
4941 "WLAN TL:LLC header removed, cannot determine BT-AMP type -"
4942 "dropping pkt"));
4943 /* Drop packet */
4944 vos_pkt_return_packet(vosTempBuff);
4945 return VOS_TRUE;
4946 }
4947
4948 usMPDUDOffset = (v_U8_t)WDA_GET_RX_MPDU_DATA_OFFSET(pvBDHeader);
4949 ucMPDUHOffset = (v_U8_t)WDA_GET_RX_MPDU_HEADER_OFFSET(pvBDHeader);
4950 ucMPDUHLen = (v_U8_t)WDA_GET_RX_MPDU_HEADER_LEN(pvBDHeader);
4951 ucOffset = (v_U8_t)usMPDUDOffset + WLANTL_LLC_OUI_OFFSET;
4952
4953 vosStatus = vos_pkt_extract_data( vosTempBuff, ucOffset,
4954 (v_PVOID_t)ucOUI, &usOUISize);
4955
4956#if 0
4957 // Compare returns 1 if values are same and 0
4958 // if not the same.
4959 if (( WLANTL_LLC_OUI_SIZE != usOUISize ) ||
4960 ( 0 == vos_mem_compare(ucOUI, (v_PVOID_t)WLANTL_BT_AMP_OUI,
4961 WLANTL_LLC_OUI_SIZE ) ))
4962 {
4963 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
4964 "LLC header points to diff OUI in BT-AMP station -"
4965 "dropping pkt"));
4966 /* Drop packet */
4967 vos_pkt_return_packet(vosTempBuff);
4968 return VOS_TRUE;
4969 }
4970#endif
4971 /*------------------------------------------------------------------------
4972 Extract LLC OUI and ensure that this is indeed a BT-AMP frame
4973 ------------------------------------------------------------------------*/
4974 vosStatus = vos_pkt_extract_data( vosTempBuff,
4975 ucOffset + WLANTL_LLC_OUI_SIZE,
4976 (v_PVOID_t)&usType, &usTypeLen);
4977
4978 if (( VOS_STATUS_SUCCESS != vosStatus) ||
4979 ( sizeof(usType) != usTypeLen ))
4980 {
4981 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
4982 "Unable to extract type on incoming BAP packet -"
4983 "dropping pkt"));
4984 /* Drop packet */
4985 vos_pkt_return_packet(vosTempBuff);
4986 return VOS_TRUE;
4987 }
4988
4989 /*------------------------------------------------------------------------
4990 Check if this is BT-AMP data or ctrl packet(RSN, LinkSvision, ActivityR)
4991 ------------------------------------------------------------------------*/
4992 usType = vos_be16_to_cpu(usType);
4993
4994 if (WLANTL_BAP_IS_NON_DATA_PKT_TYPE(usType))
4995 {
4996 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
4997 "WLAN TL:Non-data packet received over BT-AMP link: %d, => BAP",
4998 usType));
4999
5000 /*Flatten packet as BAP expects to be able to peek*/
5001 if ( VOS_STATUS_SUCCESS != vos_pkt_flatten_rx_pkt(&vosTempBuff))
5002 {
5003 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
5004 "WLAN TL:Cannot flatten BT-AMP packet - dropping"));
5005 /* Drop packet */
5006 vos_pkt_return_packet(vosTempBuff);
5007 return VOS_TRUE;
5008 }
5009
5010 /* Send packet to BAP client*/
5011
5012 VOS_ASSERT(pTLCb->tlBAPClient.pfnTlBAPRx != NULL);
5013
5014 if ( VOS_STATUS_SUCCESS != WDA_DS_TrimRxPacketInfo( vosTempBuff ) )
5015 {
5016 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
5017 "WLAN TL:BD header corrupted - dropping packet"));
5018 /* Drop packet */
5019 vos_pkt_return_packet(vosTempBuff);
5020 return VOS_TRUE;
5021 }
5022
5023 if ( 0 == WDA_GET_RX_FT_DONE(pvBDHeader) )
5024 {
5025 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
5026 "Non-data packet received over BT-AMP link: Sending it for "
5027 "frame Translation"));
5028
5029 if (usMPDUDOffset > ucMPDUHOffset)
5030 {
5031 usActualHLen = usMPDUDOffset - ucMPDUHOffset;
5032 }
5033
5034 /* software frame translation for BTAMP WDS.*/
5035 WLANTL_Translate80211To8023Header( vosTempBuff, &vosStatus, usActualHLen,
5036 ucMPDUHLen, pTLCb,ucSTAId );
5037
5038 }
5039 if (pTLCb->tlBAPClient.pfnTlBAPRx)
5040 pTLCb->tlBAPClient.pfnTlBAPRx( vos_get_global_context(VOS_MODULE_ID_TL,pTLCb),
5041 vosTempBuff,
5042 (WLANTL_BAPFrameEnumType)usType );
5043
5044 return VOS_TRUE;
5045 }
5046 else
5047 {
5048 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
5049 "WLAN TL: BAP DATA packet received over BT-AMP link: %d, => BAP",
5050 usType));
5051 /*!!!FIX ME!!*/
5052 #if 0
5053 /*--------------------------------------------------------------------
5054 For data packet collect phy stats RSSI and Link Quality
5055 Calculate the RSSI average and save it. Continuous average is done.
5056 --------------------------------------------------------------------*/
5057 if ( *pFirstDataPktArrived == 0)
5058 {
5059 pTLCb->atlSTAClients[ucSTAId].rssiAvg =
5060 WLANHAL_GET_RSSI_AVERAGE( pvBDHeader );
5061 pTLCb->atlSTAClients[ucSTAId].uLinkQualityAvg =
5062 WLANHAL_RX_BD_GET_SNR( pvBDHeader );
5063
5064 // Rcvd 1st pkt, start average from next time
5065 *pFirstDataPktArrived = 1;
5066 }
5067 else
5068 {
5069 pTLCb->atlSTAClients[ucSTAId].rssiAvg =
5070 (WLANHAL_GET_RSSI_AVERAGE( pvBDHeader ) +
5071 pTLCb->atlSTAClients[ucSTAId].rssiAvg)/2;
5072 pTLCb->atlSTAClients[ucSTAId].uLinkQualityAvg =
5073 (WLANHAL_RX_BD_GET_SNR( pvBDHeader ) +
5074 pTLCb->atlSTAClients[ucSTAId].uLinkQualityAvg)/2;
5075 }/*Else, first data packet*/
5076 #endif
5077 }/*BT-AMP data packet*/
5078
5079 return VOS_FALSE;
5080}/*WLANTL_ProcessBAPFrame*/
5081
Jeff Johnson295189b2012-06-20 16:38:30 -07005082
5083/*==========================================================================
5084
5085 FUNCTION WLANTL_ProcessFCFrame
5086
5087 DESCRIPTION
5088 Internal utility function for processing incoming Flow Control frames. Enable
5089 or disable LWM mode based on the information.
5090
5091 DEPENDENCIES
5092 TL must be initiailized before this function gets called.
5093 FW sends up special flow control frame.
5094
5095 PARAMETERS
5096
5097 IN
5098 pvosGCtx pointer to vos global context
5099 pvBDHeader: pointer to the BD header
5100 pTLCb: TL control block
5101 pvBDHeader pointer to BD header.
5102
5103 IN/OUT
5104 pFirstDataPktArrived: static from caller function; used for rssi
5105 computation
5106 RETURN VALUE
5107 The result code associated with performing the operation
5108
5109 VOS_STATUS_E_INVAL: Input frame are invalid
5110 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
5111 page fault
5112 VOS_STATUS_SUCCESS: Everything is good :)
5113
5114 SIDE EFFECTS
5115 The ingress and egress of each station will be updated. If needed, LWM mode will
5116 be enabled or disabled based on the flow control algorithm.
5117
5118============================================================================*/
5119v_BOOL_t
5120WLANTL_ProcessFCFrame
5121(
5122 v_PVOID_t pvosGCtx,
5123 vos_pkt_t* pvosDataBuff,
5124 v_PVOID_t pvBDHeader
5125)
5126{
5127#if 1 //enable processing of only fcStaTxDisabled bitmap for now. the else part is old better qos code.
5128 // need to revisit the old code for full implementation.
Hoonki Lee14621352013-04-16 17:51:19 -07005129 v_U8_t ucSTAId;
5130 v_U16_t ucStaValidBitmap;
5131 v_U16_t ucStaTxDisabledBitmap;
5132 WLANTL_CbType* pTLCb = NULL;
5133 #ifdef TL_DEBUG_FC
5134 v_U32_t rxTimeStamp;
5135 v_U32_t curTick;
5136 #endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005137 /*------------------------------------------------------------------------
Hoonki Lee14621352013-04-16 17:51:19 -07005138 Extract TL control block
Jeff Johnson295189b2012-06-20 16:38:30 -07005139 ------------------------------------------------------------------------*/
5140 pTLCb = VOS_GET_TL_CB(pvosGCtx);
5141 if ( NULL == pTLCb )
5142 {
5143 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
5144 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_SuspendDataTx"));
5145 return VOS_STATUS_E_FAULT;
5146 }
Hoonki Lee14621352013-04-16 17:51:19 -07005147 ucStaValidBitmap = WDA_GET_RX_FC_VALID_STA_MASK(pvBDHeader);
5148 ucStaTxDisabledBitmap = WDA_GET_RX_FC_STA_TX_DISABLED_BITMAP(pvBDHeader);
5149#ifdef TL_DEBUG_FC
5150 rxTimeStamp = WDA_GET_RX_TIMESTAMP(pvBDHeader);
5151 /* hard code of MTU_GLOBAL_TIMER_ADDR to calculate the time between generated and processed */
5152 wpalReadRegister(0x03081400+0x1D4, &curTick);
Jeff Johnson295189b2012-06-20 16:38:30 -07005153
Jeff Johnson295189b2012-06-20 16:38:30 -07005154 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Hoonki Lee14621352013-04-16 17:51:19 -07005155 "%ld (%ld-%ld): Disabled %x Valid %x\n", curTick > rxTimeStamp ? curTick - rxTimeStamp : rxTimeStamp - (0xFFFFFFFF - curTick),
5156 curTick, rxTimeStamp, ucStaTxDisabledBitmap, ucStaValidBitmap));
5157#endif
5158 for(ucSTAId = 0; ucStaValidBitmap != 0; ucStaValidBitmap >>=1, ucStaTxDisabledBitmap >>= 1, ucSTAId ++)
Jeff Johnson295189b2012-06-20 16:38:30 -07005159 {
Hoonki Lee14621352013-04-16 17:51:19 -07005160 if ( (0 == (ucStaValidBitmap & 0x1)) || (pTLCb->atlSTAClients[ucSTAId] && (0 == pTLCb->atlSTAClients[ucSTAId]->ucExists)) )
5161 continue;
5162
5163 if (ucStaTxDisabledBitmap & 0x1)
5164 {
5165 WLANTL_SuspendDataTx(pvosGCtx, &ucSTAId, NULL);
5166 }
5167 else
5168 {
5169 WLANTL_ResumeDataTx(pvosGCtx, &ucSTAId);
5170 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005171 }
5172
5173#else
5174 VOS_STATUS vosStatus;
5175 tpHalFcRxBd pvFcRxBd = NULL;
5176 v_U8_t ucBitCheck = 0x1;
5177 v_U8_t ucStaValid = 0;
5178 v_U8_t ucSTAId = 0;
5179
5180 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
5181 "Received FC Response");
5182 if ( (NULL == pTLCb) || (NULL == pvosDataBuff))
5183 {
5184 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005185 "WLAN TL:Invalid pointer in %s \n", __func__));
Jeff Johnson295189b2012-06-20 16:38:30 -07005186 return VOS_STATUS_E_FAULT;
5187 }
5188 vosStatus = vos_pkt_peek_data( pvosDataBuff, 0, (v_PVOID_t)&pvFcRxBd,
5189 sizeof(tHalFcRxBd));
5190
5191 if ( (VOS_STATUS_SUCCESS != vosStatus) || (NULL == pvFcRxBd) )
5192 {
5193 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
5194 "WLAN TL:wrong FC Rx packet"));
5195 return VOS_STATUS_E_INVAL;
5196 }
5197
5198 // need to swap bytes in the FC contents.
5199 WLANHAL_SwapFcRxBd(&pvFcRxBd->fcSTATxQLen[0]);
5200
5201 //logic to enable/disable LWM mode for each station
5202 for( ucStaValid = (v_U8_t)pvFcRxBd->fcSTAValidMask; ucStaValid; ucStaValid >>= 1, ucBitCheck <<= 1, ucSTAId ++)
5203 {
5204 if ( (0 == (ucStaValid & 0x1)) || (0 == pTLCb->atlSTAClients[ucSTAId].ucExists) )
5205 {
5206 continue;
5207 }
5208
5209 if ( pvFcRxBd->fcSTAThreshIndMask & ucBitCheck )
5210 {
5211 //LWM event is reported by FW. Able to fetch more packet
5212 if( pTLCb->atlSTAClients[ucSTAId].ucLwmModeEnabled )
5213 {
5214 //Now memory usage is below LWM. Station can send more packets.
5215 pTLCb->atlSTAClients[ucSTAId].ucLwmEventReported = TRUE;
5216 }
5217 else
5218 {
5219 TLLOG4(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_LOW,
5220 "WLAN TL: FW report LWM event but the station %d is not in LWM mode \n", ucSTAId));
5221 }
5222 }
5223
5224 //calculate uEgress_length/uIngress_length only after receiving enough packets
5225 if (WLANTL_LWM_INGRESS_SAMPLE_THRESHOLD <= pTLCb->atlSTAClients[ucSTAId].uIngress_length)
5226 {
5227 //check memory usage info to see whether LWM mode should be enabled for the station
5228 v_U32_t uEgress_length = pTLCb->atlSTAClients[ucSTAId].uIngress_length +
5229 pTLCb->atlSTAClients[ucSTAId].bmuMemConsumed - pvFcRxBd->fcSTATxQLen[ucSTAId];
5230
5231 //if ((float)uEgress_length/(float)pTLCb->atlSTAClients[ucSTAId].uIngress_length
5232 // <= WLANTL_LWM_EGRESS_INGRESS_THRESHOLD)
5233 if ( (pTLCb->atlSTAClients[ucSTAId].uIngress_length > uEgress_length) &&
5234 ((pTLCb->atlSTAClients[ucSTAId].uIngress_length - uEgress_length ) >=
5235 (pTLCb->atlSTAClients[ucSTAId].uIngress_length >> 2))
5236 )
5237 {
5238 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
5239 "WLAN TL:Enable LWM mode for station %d\n", ucSTAId));
5240 pTLCb->atlSTAClients[ucSTAId].ucLwmModeEnabled = TRUE;
5241 }
5242 else
5243 {
5244 if( pTLCb->atlSTAClients[ucSTAId].ucLwmModeEnabled )
5245 {
5246 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
5247 "WLAN TL:Disable LWM mode for station %d\n", ucSTAId));
5248 pTLCb->atlSTAClients[ucSTAId].ucLwmModeEnabled = FALSE;
5249 }
5250
5251 }
5252
5253 //remember memory usage in FW starting from this round
5254 pTLCb->atlSTAClients[ucSTAId].bmuMemConsumed = pvFcRxBd->fcSTATxQLen[ucSTAId];
5255 pTLCb->atlSTAClients[ucSTAId].uIngress_length = 0;
5256 } //(WLANTL_LWM_INGRESS_SAMPLE_THRESHOLD <= pTLCb->atlSTAClients[ucSTAId].uIngress_length)
5257
5258 if( pTLCb->atlSTAClients[ucSTAId].ucLwmModeEnabled )
5259 {
5260 //always update current maximum allowed memeory usage
5261 pTLCb->atlSTAClients[ucSTAId].uBuffThresholdMax = WLANTL_STA_BMU_THRESHOLD_MAX -
5262 pvFcRxBd->fcSTATxQLen[ucSTAId];
5263 }
5264
5265 }
5266#endif
5267
5268 return VOS_STATUS_SUCCESS;
5269}
Jeff Johnson295189b2012-06-20 16:38:30 -07005270
5271
5272/*==========================================================================
5273
5274 FUNCTION WLANTL_RxFrames
5275
5276 DESCRIPTION
5277 Callback registered by TL and called by BAL when a packet is received
5278 over the bus. Upon the call of this function TL will make the necessary
5279 decision with regards to the forwarding or queuing of this packet and
5280 the layer it needs to be delivered to.
5281
5282 DEPENDENCIES
5283 TL must be initiailized before this function gets called.
5284 If the frame carried is a data frame then the station for which it is
5285 destined to must have been previously registered with TL.
5286
5287 PARAMETERS
5288
5289 IN
5290 pvosGCtx: pointer to the global vos context; a handle to TL's
5291 or BAL's control block can be extracted from its context
5292
5293 vosDataBuff: it will contain a pointer to the first buffer received,
5294 if there is more then one packet they will be chained
5295 using vOSS buffers.
5296
5297 RETURN VALUE
5298 The result code associated with performing the operation
5299
5300 VOS_STATUS_E_INVAL: Input parameters are invalid
5301 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
5302 page fault
5303 VOS_STATUS_SUCCESS: Everything is good :)
5304
5305 SIDE EFFECTS
5306
5307============================================================================*/
5308VOS_STATUS
5309WLANTL_RxFrames
5310(
5311 v_PVOID_t pvosGCtx,
5312 vos_pkt_t *pFrameDataBuff
5313)
5314{
5315 vos_pkt_t* vosDataBuff = (vos_pkt_t*)pFrameDataBuff;
5316 WLANTL_CbType* pTLCb = NULL;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05305317 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005318 WLANTL_STAFuncType pfnSTAFsm;
5319 vos_pkt_t* vosTempBuff;
5320 v_U8_t ucSTAId;
5321 VOS_STATUS vosStatus;
5322 v_U8_t ucFrmType;
5323 v_PVOID_t pvBDHeader = NULL;
5324 WLANTL_STAEventType wSTAEvent = WLANTL_RX_EVENT;
5325 v_U8_t ucTid = 0;
5326 v_BOOL_t broadcast = VOS_FALSE;
5327 v_BOOL_t selfBcastLoopback = VOS_FALSE;
Madan Mohan Koyyalamudidfd6aa82012-10-18 20:18:43 -07005328 static v_U8_t first_data_pkt_arrived;
Jeff Johnson295189b2012-06-20 16:38:30 -07005329 v_U32_t uDPUSig;
Jeff Johnson295189b2012-06-20 16:38:30 -07005330 v_U16_t usPktLen;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08005331#ifdef FEATURE_WLAN_TDLS_INTERNAL
5332 v_U8_t ucMPDUHLen = 0 ;
5333 v_U16_t usEtherType = 0;
5334#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005335 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
5336
5337 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
5338 "WLAN TL:TL Receive Frames called"));
5339
5340 /*------------------------------------------------------------------------
5341 Sanity check
5342 ------------------------------------------------------------------------*/
5343 if ( NULL == vosDataBuff )
5344 {
5345 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
5346 "WLAN TL:Invalid parameter sent on WLANTL_RxFrames"));
5347 return VOS_STATUS_E_INVAL;
5348 }
5349
5350 /*------------------------------------------------------------------------
5351 Extract TL control block
5352 ------------------------------------------------------------------------*/
5353 pTLCb = VOS_GET_TL_CB(pvosGCtx);
5354 if ( NULL == pTLCb )
5355 {
5356 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
5357 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_ChangeSTAState"));
5358 return VOS_STATUS_E_FAULT;
5359 }
5360
5361 /*---------------------------------------------------------------------
5362 Save the initial buffer - this is the first received buffer
5363 ---------------------------------------------------------------------*/
5364 vosTempBuff = vosDataBuff;
5365
5366 while ( NULL != vosTempBuff )
5367 {
Madan Mohan Koyyalamudia148e1e2012-11-30 14:52:59 -08005368 broadcast = VOS_FALSE;
5369 selfBcastLoopback = VOS_FALSE;
5370
Jeff Johnson295189b2012-06-20 16:38:30 -07005371 vos_pkt_walk_packet_chain( vosDataBuff, &vosDataBuff, 1/*true*/ );
5372
5373 /*---------------------------------------------------------------------
5374 Peek at BD header - do not remove
5375 !!! Optimize me: only part of header is needed; not entire one
5376 ---------------------------------------------------------------------*/
5377 vosStatus = WDA_DS_PeekRxPacketInfo( vosTempBuff, (v_PVOID_t)&pvBDHeader, 1/*Swap BD*/ );
5378
5379 if ( NULL == pvBDHeader )
5380 {
5381 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
5382 "WLAN TL:Cannot extract BD header"));
5383 /* Drop packet */
5384 vos_pkt_return_packet(vosTempBuff);
5385 vosTempBuff = vosDataBuff;
5386 continue;
5387 }
5388
Jeff Johnson295189b2012-06-20 16:38:30 -07005389 /*---------------------------------------------------------------------
5390 Check if FC frame reported from FW
5391 ---------------------------------------------------------------------*/
5392 if(WDA_IS_RX_FC(pvBDHeader))
5393 {
5394 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
5395 "WLAN TL:receive one FC frame"));
5396
5397 WLANTL_ProcessFCFrame(pvosGCtx, vosTempBuff, pvBDHeader);
5398 /* Drop packet */
5399 vos_pkt_return_packet(vosTempBuff);
5400 vosTempBuff = vosDataBuff;
5401 continue;
5402 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005403
5404 /* AMSDU HW bug fix
5405 * After 2nd AMSDU subframe HW could not handle BD correctly
5406 * HAL workaround is needed */
5407 if(WDA_GET_RX_ASF(pvBDHeader))
5408 {
5409 WDA_DS_RxAmsduBdFix(pvosGCtx, pvBDHeader);
5410 }
5411
5412 /*---------------------------------------------------------------------
5413 Extract frame control field from 802.11 header if present
5414 (frame translation not done)
5415 ---------------------------------------------------------------------*/
5416
5417 vosStatus = WDA_DS_GetFrameTypeSubType( pvosGCtx, vosTempBuff,
5418 pvBDHeader, &ucFrmType );
5419 if ( VOS_STATUS_SUCCESS != vosStatus )
5420 {
5421 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
5422 "WLAN TL:Cannot extract Frame Control Field"));
5423 /* Drop packet */
5424 vos_pkt_return_packet(vosTempBuff);
5425 vosTempBuff = vosDataBuff;
5426 continue;
5427 }
5428
Mohit Khanna698ba2a2012-12-04 15:08:18 -08005429#ifdef FEATURE_WLAN_TDLS_INTERNAL
5430 if ( WLANTL_IS_DATA_FRAME(ucFrmType))
5431 {
5432 ucMPDUHLen = (v_U8_t)WDA_GET_RX_MPDU_HEADER_LEN(pvBDHeader);
5433 WLANTL_GetEtherType_2(pvBDHeader, vosTempBuff, ucMPDUHLen, &usEtherType) ;
5434 }
5435#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005436 vos_pkt_get_packet_length(vosTempBuff, &usPktLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07005437
5438 /*---------------------------------------------------------------------
5439 Check if management and send to PE
5440 ---------------------------------------------------------------------*/
5441
Mohit Khanna698ba2a2012-12-04 15:08:18 -08005442 if ( WLANTL_IS_MGMT_FRAME(ucFrmType)
5443#ifdef FEATURE_WLAN_TDLS_INTERNAL
5444 || (WLANTL_IS_TDLS_FRAME(usEtherType))
5445#endif
5446 )
Jeff Johnson295189b2012-06-20 16:38:30 -07005447 {
5448 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
5449 "WLAN TL:Sending packet to management client"));
5450 if ( VOS_STATUS_SUCCESS != vos_pkt_flatten_rx_pkt(&vosTempBuff))
5451 {
5452 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
5453 "WLAN TL:Cannot flatten packet - dropping"));
5454 /* Drop packet */
5455 vos_pkt_return_packet(vosTempBuff);
5456 vosTempBuff = vosDataBuff;
5457 continue;
5458 }
5459 ucSTAId = (v_U8_t)WDA_GET_RX_STAID( pvBDHeader );
5460 /* Read RSSI and update */
5461 if(!WLANTL_STA_ID_INVALID(ucSTAId))
5462 {
5463#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
5464 /* Read RSSI and update */
5465 vosStatus = WLANTL_HSHandleRXFrame(pvosGCtx,
5466 WLANTL_MGMT_FRAME_TYPE,
5467 pvBDHeader,
5468 ucSTAId,
5469 VOS_FALSE,
5470 NULL);
5471#else
5472 vosStatus = WLANTL_ReadRSSI(pvosGCtx, pvBDHeader, ucSTAId);
5473#endif
5474 }
5475
5476 if(!VOS_IS_STATUS_SUCCESS(vosStatus))
5477 {
5478 TLLOGW(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
5479 "Handle RX Management Frame fail within Handoff support module"));
5480 /* Do Not Drop packet at here
5481 * Revisit why HO module return fail
5482 vos_pkt_return_packet(vosTempBuff);
5483 vosTempBuff = vosDataBuff;
5484 continue;
5485 */
5486 }
5487 pTLCb->tlMgmtFrmClient.pfnTlMgmtFrmRx( pvosGCtx, vosTempBuff);
5488 }
5489 else /* Data Frame */
5490 {
5491 ucSTAId = (v_U8_t)WDA_GET_RX_STAID( pvBDHeader );
5492 ucTid = (v_U8_t)WDA_GET_RX_TID( pvBDHeader );
5493
5494 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
5495 "WLAN TL:Data packet received for STA %d", ucSTAId));
5496
5497 /*------------------------------------------------------------------
5498 This should be corrected when multipe sta support is added !!!
5499 for now bcast frames will be sent to the last registered STA
5500 ------------------------------------------------------------------*/
5501 if ( WDA_IS_RX_BCAST(pvBDHeader))
5502 {
5503 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
5504 "WLAN TL:TL rx Bcast frame - sending to last registered station"));
5505 broadcast = VOS_TRUE;
5506
5507 /*-------------------------------------------------------------------
5508 If Addr1 is b/mcast, but Addr3 is our own self MAC, it is a b/mcast
5509 pkt we sent looping back to us. To be dropped if we are non BTAMP
5510 -------------------------------------------------------------------*/
5511 if( WLANHAL_RX_BD_ADDR3_SELF_IDX ==
5512 (v_U8_t)WDA_GET_RX_ADDR3_IDX( pvBDHeader ))
5513 {
5514 selfBcastLoopback = VOS_TRUE;
5515 }
5516 }/*if bcast*/
5517
5518 if ( WLANTL_STA_ID_INVALID(ucSTAId) )
5519 {
5520 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
5521 "WLAN TL:STA ID invalid - dropping pkt"));
5522 /* Drop packet */
5523 vos_pkt_return_packet(vosTempBuff);
5524 vosTempBuff = vosDataBuff;
5525 continue;
5526 }
5527
5528 /*----------------------------------------------------------------------
5529 No need to lock cache access because cache manipulation only happens
5530 in the transport thread/task context
5531 - These frames are to be forwarded to the station upon registration
5532 which happens in the main thread context
5533 The caching here can happen in either Tx or Rx thread depending
5534 on the current SSC scheduling
5535 - also we need to make sure that the frames in the cache are fwd-ed to
5536 the station before the new incoming ones
5537 -----------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05305538 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
5539 if (NULL == pClientSTA)
5540 {
5541 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
5542 "WLAN TL:STA not allocated memory. Dropping packet"));
5543 vos_pkt_return_packet(vosTempBuff);
5544 vosTempBuff = vosDataBuff;
5545 continue;
5546 }
5547
Hoonki Lee5305c3a2013-04-29 23:28:59 -07005548#ifdef FEATURE_WLAN_TDLS
5549 if (( pClientSTA->ucExists ) &&
5550 (WLAN_STA_TDLS == pClientSTA->wSTADesc.wSTAType) &&
5551 (pClientSTA->ucTxSuspended))
5552 vos_atomic_set_U8( &pClientSTA->ucTxSuspended, 0 );
5553 else if ( !broadcast && (pClientSTA->ucExists == 0 ) )
5554 {
5555 tpSirMacMgmtHdr pMacHeader = WDA_GET_RX_MAC_HEADER( pvBDHeader );
5556
5557 /* from the direct peer while it is not registered to TL yet */
5558 if ( (pMacHeader->fc.fromDS == 0) &&
5559 (pMacHeader->fc.toDS == 0) )
5560 {
5561 v_U8_t ucAddr3STAId;
5562
5563 ucAddr3STAId = WDA_GET_RX_ADDR3_IDX(pvBDHeader);
5564
5565 if ( WLANTL_STA_ID_INVALID(ucAddr3STAId) )
5566 {
5567 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
5568 "WLAN TL:STA ID %d invalid - dropping pkt", ucAddr3STAId));
5569 /* Drop packet */
5570 vos_pkt_return_packet(vosTempBuff);
5571 vosTempBuff = vosDataBuff;
5572 continue;
5573 }
5574
5575 if (!(pTLCb->atlSTAClients[ucAddr3STAId] && pTLCb->atlSTAClients[ucAddr3STAId]->ucExists &&
5576 (WLAN_STA_INFRA == pTLCb->atlSTAClients[ucAddr3STAId]->wSTADesc.wSTAType) &&
5577 (WLANTL_STA_AUTHENTICATED == pTLCb->atlSTAClients[ucAddr3STAId]->tlState)))
5578 {
5579 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
5580 "%s: staId %d addr3Id %d tlState %d. Unkown Receiver/Transmitter Dropping packet\n", __func__,
5581 ucSTAId, ucAddr3STAId, pTLCb->atlSTAClients[ucAddr3STAId]->tlState));
5582 vos_pkt_return_packet(vosTempBuff);
5583 vosTempBuff = vosDataBuff;
5584 continue;
5585 }
5586 else
5587 {
5588 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
5589 "%s: staId %d doesn't exist, but mapped to AP staId %d \n", __func__,
5590 ucSTAId, ucAddr3STAId));
5591 ucSTAId = ucAddr3STAId;
5592 pClientSTA = pTLCb->atlSTAClients[ucAddr3STAId];
5593 }
5594 }
5595 }
5596#endif
5597
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05305598 if ((( 0 == pClientSTA->ucExists ) ||
5599 ( (0 != pClientSTA->ucRxBlocked)
Jeff Johnson295189b2012-06-20 16:38:30 -07005600 ///@@@: xg: no checking in SOFTAP for now, will revisit later
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05305601 && (WLAN_STA_SOFTAP != pClientSTA->wSTADesc.wSTAType)
Jeff Johnson295189b2012-06-20 16:38:30 -07005602 ) ||
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05305603 ( WLANTL_STA_DISCONNECTED == pClientSTA->tlState)) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07005604 /*Dont buffer Broadcast/Multicast frames. If AP transmits bursts of Broadcast/Multicast data frames,
5605 * libra buffers all Broadcast/Multicast packets after authentication with AP,
5606 * So it will lead to low resource condition in Rx Data Path.*/
5607 ((WDA_IS_RX_BCAST(pvBDHeader) == 0)))
5608 {
5609 uDPUSig = WDA_GET_RX_DPUSIG( pvBDHeader );
5610 //Station has not yet been registered with TL - cache the frame
Hoonki Lee5305c3a2013-04-29 23:28:59 -07005611 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
5612 "%s: staId %d exist %d tlState %d cache rx frame \n", __func__, ucSTAId,
5613 pClientSTA->ucExists, pClientSTA->tlState));
Jeff Johnson295189b2012-06-20 16:38:30 -07005614 WLANTL_CacheSTAFrame( pTLCb, ucSTAId, vosTempBuff, uDPUSig, broadcast, ucFrmType);
5615 vosTempBuff = vosDataBuff;
5616 continue;
5617 }
5618
Jeff Johnson295189b2012-06-20 16:38:30 -07005619#ifdef FEATURE_WLAN_CCX
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05305620 if ((pClientSTA->wSTADesc.ucIsCcxSta)|| broadcast)
Jeff Johnson295189b2012-06-20 16:38:30 -07005621 {
5622 /*--------------------------------------------------------------------
5623 Filter the IAPP frames for CCX connection;
5624 if data it will return false and it
5625 will be routed through the regular data path
5626 --------------------------------------------------------------------*/
5627 if ( WLANTL_IsIAPPFrame(pvBDHeader,
5628 vosTempBuff))
5629 {
5630 if ( VOS_STATUS_SUCCESS != vos_pkt_flatten_rx_pkt(&vosTempBuff))
5631 {
5632 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
5633 "WLAN TL:Cannot flatten packet - dropping"));
5634 /* Drop packet */
5635 vos_pkt_return_packet(vosTempBuff);
5636 } else {
5637
5638 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
5639 "WLAN TL: Received CCX IAPP Frame"));
5640
5641 pTLCb->tlMgmtFrmClient.pfnTlMgmtFrmRx( pvosGCtx, vosTempBuff);
5642 }
5643 vosTempBuff = vosDataBuff;
5644 continue;
5645 }
5646 }
5647#endif
5648
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05305649 if ( WLAN_STA_BT_AMP == pClientSTA->wSTADesc.wSTAType )
Jeff Johnson295189b2012-06-20 16:38:30 -07005650 {
5651 /*--------------------------------------------------------------------
5652 Process the ctrl BAP frame; if data it will return false and it
5653 will be routed through the regular data path
5654 --------------------------------------------------------------------*/
5655 if ( WLANTL_ProcessBAPFrame( pvBDHeader,
5656 vosTempBuff,
5657 pTLCb,
5658 &first_data_pkt_arrived,
5659 ucSTAId))
5660 {
5661 vosTempBuff = vosDataBuff;
5662 continue;
5663 }
5664 }/*if BT-AMP station*/
5665 else if(selfBcastLoopback == VOS_TRUE)
5666 {
5667 /* Drop packet */
5668 vos_pkt_return_packet(vosTempBuff);
5669 vosTempBuff = vosDataBuff;
5670 continue;
5671 }
5672
5673 /*---------------------------------------------------------------------
5674 Data packet received, send to state machine
5675 ---------------------------------------------------------------------*/
5676 wSTAEvent = WLANTL_RX_EVENT;
5677
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05305678 pfnSTAFsm = tlSTAFsm[pClientSTA->tlState].
Jeff Johnson295189b2012-06-20 16:38:30 -07005679 pfnSTATbl[wSTAEvent];
5680
5681 if ( NULL != pfnSTAFsm )
5682 {
5683#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
5684 /* Read RSSI and update */
5685 vosStatus = WLANTL_HSHandleRXFrame(pvosGCtx,
5686 WLANTL_DATA_FRAME_TYPE,
5687 pvBDHeader,
5688 ucSTAId,
5689 broadcast,
5690 vosTempBuff);
5691 broadcast = VOS_FALSE;
5692#else
5693 vosStatus = WLANTL_ReadRSSI(pvosGCtx, pvBDHeader, ucSTAId);
5694#endif /*FEATURE_WLAN_GEN6_ROAMING*/
5695 if(!VOS_IS_STATUS_SUCCESS(vosStatus))
5696 {
5697 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
5698 "Handle RX Data Frame fail within Handoff support module"));
5699 /* Do Not Drop packet at here
5700 * Revisit why HO module return fail
5701 vos_pkt_return_packet(vosTempBuff);
5702 vosTempBuff = vosDataBuff;
5703 continue;
5704 */
5705 }
5706 pfnSTAFsm( pvosGCtx, ucSTAId, &vosTempBuff);
5707 }
5708 else
5709 {
5710 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
5711 "WLAN TL:NULL state function, STA:%d, State: %d- dropping packet",
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05305712 ucSTAId, pClientSTA->tlState));
Jeff Johnson295189b2012-06-20 16:38:30 -07005713 /* Drop packet */
5714 vos_pkt_return_packet(vosTempBuff);
5715 vosTempBuff = vosDataBuff;
5716 continue;
5717 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005718 }/* else data frame*/
5719
5720 vosTempBuff = vosDataBuff;
5721 }/*while chain*/
5722
5723 return VOS_STATUS_SUCCESS;
5724}/* WLANTL_RxFrames */
5725
5726
5727/*==========================================================================
5728
5729 FUNCTION WLANTL_RxCachedFrames
5730
5731 DESCRIPTION
5732 Utility function used by TL to forward the cached frames to a particular
5733 station;
5734
5735 DEPENDENCIES
5736 TL must be initiailized before this function gets called.
5737 If the frame carried is a data frame then the station for which it is
5738 destined to must have been previously registered with TL.
5739
5740 PARAMETERS
5741
5742 IN
5743 pTLCb: pointer to TL handle
5744
5745 ucSTAId: station for which we need to forward the packets
5746
5747 vosDataBuff: it will contain a pointer to the first cached buffer
5748 received, if there is more then one packet they will be
5749 chained using vOSS buffers.
5750
5751 RETURN VALUE
5752 The result code associated with performing the operation
5753
5754 VOS_STATUS_E_INVAL: Input parameters are invalid
5755 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
5756 page fault
5757 VOS_STATUS_SUCCESS: Everything is good :)
5758
5759 SIDE EFFECTS
5760
5761============================================================================*/
5762VOS_STATUS
5763WLANTL_RxCachedFrames
5764(
5765 WLANTL_CbType* pTLCb,
5766 v_U8_t ucSTAId,
5767 vos_pkt_t* vosDataBuff
5768)
5769{
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05305770 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005771 WLANTL_STAFuncType pfnSTAFsm;
5772 vos_pkt_t* vosTempBuff;
5773 VOS_STATUS vosStatus;
5774 v_PVOID_t pvBDHeader = NULL;
5775 WLANTL_STAEventType wSTAEvent = WLANTL_RX_EVENT;
5776 v_U8_t ucTid = 0;
5777 v_BOOL_t broadcast = VOS_FALSE;
5778 v_BOOL_t bSigMatch = VOS_FALSE;
5779 v_BOOL_t selfBcastLoopback = VOS_FALSE;
Madan Mohan Koyyalamudidfd6aa82012-10-18 20:18:43 -07005780 static v_U8_t first_data_pkt_arrived;
Jeff Johnson295189b2012-06-20 16:38:30 -07005781 v_U32_t uDPUSig;
5782 v_U8_t ucUcastSig;
5783 v_U8_t ucBcastSig;
5784 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
5785
5786 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
5787 "WLAN TL:TL Receive Cached Frames called"));
5788
5789 /*------------------------------------------------------------------------
5790 Sanity check
5791 ------------------------------------------------------------------------*/
5792 if ( NULL == vosDataBuff )
5793 {
5794 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
5795 "WLAN TL:Invalid parameter sent on WLANTL_RxFrames"));
5796 return VOS_STATUS_E_INVAL;
5797 }
5798
5799 /*---------------------------------------------------------------------
5800 Save the initial buffer - this is the first received buffer
5801 ---------------------------------------------------------------------*/
5802 vosTempBuff = vosDataBuff;
5803
5804 while ( NULL != vosTempBuff )
5805 {
Madan Mohan Koyyalamudia148e1e2012-11-30 14:52:59 -08005806 broadcast = VOS_FALSE;
5807 selfBcastLoopback = VOS_FALSE;
5808
Jeff Johnson295189b2012-06-20 16:38:30 -07005809 vos_pkt_walk_packet_chain( vosDataBuff, &vosDataBuff, 1/*true*/ );
5810
5811 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
5812 "WLAN TL:Sending new cached packet to station %d", ucSTAId));
5813 /*---------------------------------------------------------------------
5814 Peek at BD header - do not remove
5815 !!! Optimize me: only part of header is needed; not entire one
5816 ---------------------------------------------------------------------*/
5817 vosStatus = WDA_DS_PeekRxPacketInfo( vosTempBuff, (v_PVOID_t)&pvBDHeader, 0 );
5818
5819 if ( NULL == pvBDHeader )
5820 {
5821 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
5822 "WLAN TL:Cannot extract BD header"));
5823 /* Drop packet */
5824 vos_pkt_return_packet(vosTempBuff);
5825 vosTempBuff = vosDataBuff;
5826 continue;
5827 }
5828
5829 uDPUSig = WDA_GET_RX_DPUSIG( pvBDHeader );
5830
5831 /* AMSDU HW bug fix
5832 * After 2nd AMSDU subframe HW could not handle BD correctly
5833 * HAL workaround is needed */
5834 if(WDA_GET_RX_ASF(pvBDHeader))
5835 {
5836 WDA_DS_RxAmsduBdFix(vos_get_global_context(VOS_MODULE_ID_TL,pTLCb),
5837 pvBDHeader);
5838 }
5839
5840 ucTid = (v_U8_t)WDA_GET_RX_TID( pvBDHeader );
5841
5842 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
5843 "WLAN TL:Data packet cached for STA %d", ucSTAId);
5844
5845 /*------------------------------------------------------------------
5846 This should be corrected when multipe sta support is added !!!
5847 for now bcast frames will be sent to the last registered STA
5848 ------------------------------------------------------------------*/
5849 if ( WDA_IS_RX_BCAST(pvBDHeader))
5850 {
5851 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
5852 "WLAN TL:TL rx Bcast frame "));
5853 broadcast = VOS_TRUE;
5854
5855 /* If Addr1 is b/mcast, but Addr3 is our own self MAC, it is a b/mcast
5856 * pkt we sent looping back to us. To be dropped if we are non BTAMP
5857 */
5858 if( WLANHAL_RX_BD_ADDR3_SELF_IDX ==
5859 (v_U8_t)WDA_GET_RX_ADDR3_IDX( pvBDHeader ))
5860 {
5861 selfBcastLoopback = VOS_TRUE;
5862 }
5863 }/*if bcast*/
5864
5865 /*-------------------------------------------------------------------------
5866 Check if the packet that we cached matches the DPU signature of the
5867 newly added station
5868 -------------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05305869 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
5870
5871
5872 if ( NULL == pClientSTA )
5873 {
5874 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
5875 "WLAN TL:Client Memory was not allocated on %s", __func__));
5876 return VOS_STATUS_E_FAILURE;
5877 }
5878
Jeff Johnson295189b2012-06-20 16:38:30 -07005879 if ( broadcast )
5880 {
5881 ucBcastSig = (v_U8_t)uDPUSig;
5882 bSigMatch = (( WLAN_TL_INVALID_B_SIG !=
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05305883 pClientSTA->wSTADesc.ucBcastSig ) &&
5884 ( ucBcastSig == pClientSTA->wSTADesc.ucBcastSig ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005885 }
5886 else
5887 {
5888 ucUcastSig = (v_U8_t)uDPUSig;
5889 bSigMatch = (( WLAN_TL_INVALID_U_SIG !=
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05305890 pClientSTA->wSTADesc.ucUcastSig ) &&
5891 ( ucUcastSig == pClientSTA->wSTADesc.ucUcastSig ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005892 }
5893
5894 /*-------------------------------------------------------------------------
5895 If the packet doesn't match - drop it
5896 -------------------------------------------------------------------------*/
5897 if ( !bSigMatch )
5898 {
Rajesh Chauhana6b08f42013-06-18 19:01:26 -07005899 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_MED,
Jeff Johnson295189b2012-06-20 16:38:30 -07005900 "WLAN TL: Cached packet does not match DPU Sig of the new STA - drop "
5901 " DPU Sig %d UC %d BC %d B %d",
5902 uDPUSig,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05305903 pClientSTA->wSTADesc.ucUcastSig,
Rajesh Chauhana6b08f42013-06-18 19:01:26 -07005904 pClientSTA->wSTADesc.ucBcastSig,
Jeff Johnson295189b2012-06-20 16:38:30 -07005905 broadcast));
5906
5907 /* Drop packet */
5908 vos_pkt_return_packet(vosTempBuff);
5909 vosTempBuff = vosDataBuff;
5910 continue;
5911
5912 }/*if signature mismatch*/
5913
5914 /*------------------------------------------------------------------------
5915 Check if BT-AMP frame:
5916 - additional processing needed in this case to separate BT-AMP date
5917 from BT-AMP Ctrl path
5918 ------------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05305919 if ( WLAN_STA_BT_AMP == pClientSTA->wSTADesc.wSTAType )
Jeff Johnson295189b2012-06-20 16:38:30 -07005920 {
5921 /*--------------------------------------------------------------------
5922 Process the ctrl BAP frame; if data it will return false and it
5923 will be routed through the regular data path
5924 --------------------------------------------------------------------*/
5925 if ( WLANTL_ProcessBAPFrame( pvBDHeader,
5926 vosTempBuff,
5927 pTLCb,
5928 &first_data_pkt_arrived,
5929 ucSTAId))
5930 {
5931 vosTempBuff = vosDataBuff;
5932 continue;
5933 }
5934 }/*if BT-AMP station*/
5935 else if(selfBcastLoopback == VOS_TRUE)
5936 {
5937 /* Drop packet */
5938 vos_pkt_return_packet(vosTempBuff);
5939 vosTempBuff = vosDataBuff;
5940 continue;
5941 }
5942
5943 /*---------------------------------------------------------------------
5944 Data packet received, send to state machine
5945 ---------------------------------------------------------------------*/
5946 wSTAEvent = WLANTL_RX_EVENT;
5947
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05305948 pfnSTAFsm = tlSTAFsm[pClientSTA->tlState].
Jeff Johnson295189b2012-06-20 16:38:30 -07005949 pfnSTATbl[wSTAEvent];
5950
5951 if ( NULL != pfnSTAFsm )
5952 {
5953#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
5954 /* Read RSSI and update */
5955 vosStatus = WLANTL_HSHandleRXFrame(vos_get_global_context(
5956 VOS_MODULE_ID_TL,pTLCb),
5957 WLANTL_DATA_FRAME_TYPE,
5958 pvBDHeader,
5959 ucSTAId,
5960 broadcast,
5961 vosTempBuff);
5962 broadcast = VOS_FALSE;
5963#else
5964 vosStatus = WLANTL_ReadRSSI(vos_get_global_context(VOS_MODULE_ID_TL,pTLCb), pvBDHeader, ucSTAId);
5965#endif /*FEATURE_WLAN_GEN6_ROAMING*/
5966 if(!VOS_IS_STATUS_SUCCESS(vosStatus))
5967 {
5968 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
5969 "Handle RX Data Frame fail within Handoff support module"));
5970 /* Do Not Drop packet at here
5971 * Revisit why HO module return fail
5972 vos_pkt_return_packet(vosTempBuff);
5973 vosTempBuff = vosDataBuff;
5974 continue;
5975 */
5976 }
5977 pfnSTAFsm( vos_get_global_context(VOS_MODULE_ID_TL,pTLCb), ucSTAId,
5978 &vosTempBuff);
5979 }
5980 else
5981 {
5982 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
5983 "WLAN TL:NULL state function, STA:%d, State: %d- dropping packet",
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05305984 ucSTAId, pClientSTA->tlState));
Jeff Johnson295189b2012-06-20 16:38:30 -07005985 /* Drop packet */
5986 vos_pkt_return_packet(vosTempBuff);
5987 vosTempBuff = vosDataBuff;
5988 continue;
5989 }
5990
5991 vosTempBuff = vosDataBuff;
5992 }/*while chain*/
5993
5994 return VOS_STATUS_SUCCESS;
5995}/* WLANTL_RxCachedFrames */
5996
5997/*==========================================================================
5998 FUNCTION WLANTL_ResourceCB
5999
6000 DESCRIPTION
6001 Called by the TL when it has packets available for transmission.
6002
6003 DEPENDENCIES
6004 The TL must be registered with BAL before this function can be called.
6005
6006 PARAMETERS
6007
6008 IN
6009 pvosGCtx: pointer to the global vos context; a handle to TL's
6010 or BAL's control block can be extracted from its context
6011
6012 RETURN VALUE
6013 The result code associated with performing the operation
6014
6015 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
6016 page fault
6017 VOS_STATUS_SUCCESS: Everything is good :)
6018
6019 SIDE EFFECTS
6020
6021============================================================================*/
6022VOS_STATUS
6023WLANTL_ResourceCB
6024(
6025 v_PVOID_t pvosGCtx,
6026 v_U32_t uCount
6027)
6028{
6029 WLANTL_CbType* pTLCb = NULL;
6030 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
6031
6032 /*------------------------------------------------------------------------
6033 Sanity check
6034 Extract TL control block
6035 ------------------------------------------------------------------------*/
6036 pTLCb = VOS_GET_TL_CB(pvosGCtx);
6037 if ( NULL == pTLCb )
6038 {
6039 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6040 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_ChangeSTAState"));
6041 return VOS_STATUS_E_FAULT;
6042 }
6043
6044 pTLCb->uResCount = uCount;
6045
6046
6047 /*-----------------------------------------------------------------------
6048 Resume Tx if enough res and not suspended
6049 -----------------------------------------------------------------------*/
6050 if (( pTLCb->uResCount >= WDA_TLI_MIN_RES_MF ) &&
6051 ( 0 == pTLCb->ucTxSuspended ))
6052 {
6053 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
6054 "WLAN TL:Issuing Xmit start request to BAL for avail res ASYNC"));
6055 return WDA_DS_StartXmit(pvosGCtx);
6056 }
6057
6058 return VOS_STATUS_SUCCESS;
6059}/* WLANTL_ResourceCB */
6060
6061
Gopichand Nakkala11acd112012-12-31 16:04:04 -08006062/*==========================================================================
6063 FUNCTION WLANTL_IsTxXmitPending
6064
6065 DESCRIPTION
6066 Called by the WDA when it wants to know whether WDA_DS_TX_START_XMIT msg
6067 is pending in TL msg queue
6068
6069 DEPENDENCIES
6070 The TL must be registered with WDA before this function can be called.
6071
6072 PARAMETERS
6073
6074 IN
6075 pvosGCtx: pointer to the global vos context; a handle to TL's
6076 or WDA's control block can be extracted from its context
6077
6078 RETURN VALUE
6079 The result code associated with performing the operation
6080
6081 0: No WDA_DS_TX_START_XMIT msg pending
6082 1: Msg WDA_DS_TX_START_XMIT already pending in TL msg queue
6083
6084 SIDE EFFECTS
6085
6086============================================================================*/
6087v_BOOL_t
6088WLANTL_IsTxXmitPending
6089(
6090 v_PVOID_t pvosGCtx
6091)
6092{
6093
6094 WLANTL_CbType* pTLCb = NULL;
6095 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
6096
6097 /*------------------------------------------------------------------------
6098 Sanity check
6099 Extract TL control block
6100 ------------------------------------------------------------------------*/
6101 pTLCb = VOS_GET_TL_CB(pvosGCtx);
6102 if ( NULL == pTLCb )
6103 {
6104 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_FATAL,
6105 "WLAN TL:Invalid TL pointer from pvosGCtx in WLANTL_IsTxXmitPending "));
6106 return FALSE;
6107 }
6108
6109 return pTLCb->isTxTranmitMsgPending;
6110
6111}/*WLANTL_IsTxXmitPending */
6112
6113/*==========================================================================
6114 FUNCTION WLANTL_SetTxXmitPending
6115
6116 DESCRIPTION
6117 Called by the WDA when it wants to indicate that WDA_DS_TX_START_XMIT msg
6118 is pending in TL msg queue
6119
6120 DEPENDENCIES
6121 The TL must be registered with WDA before this function can be called.
6122
6123 PARAMETERS
6124
6125 IN
6126 pvosGCtx: pointer to the global vos context; a handle to TL's
6127 or WDA's control block can be extracted from its context
6128
6129 RETURN VALUE None
6130
6131 SIDE EFFECTS
6132
6133============================================================================*/
6134
6135v_VOID_t
6136WLANTL_SetTxXmitPending
6137(
6138 v_PVOID_t pvosGCtx
6139)
6140{
6141
6142 WLANTL_CbType* pTLCb = NULL;
6143 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
6144
6145 /*------------------------------------------------------------------------
6146 Sanity check
6147 Extract TL control block
6148 ------------------------------------------------------------------------*/
6149 pTLCb = VOS_GET_TL_CB(pvosGCtx);
6150 if ( NULL == pTLCb )
6151 {
6152 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_FATAL,
6153 "WLAN TL:Invalid TL pointer from pvosGCtx in WLANTL_SetTxXmitPending"));
6154 return;
6155 }
6156
6157 pTLCb->isTxTranmitMsgPending = 1;
6158 return;
6159
6160}/*WLANTL_SetTxXmitPending */
6161
6162/*==========================================================================
6163 FUNCTION WLANTL_ClearTxXmitPending
6164
6165 DESCRIPTION
6166 Called by the WDA when it wants to indicate that no WDA_DS_TX_START_XMIT msg
6167 is pending in TL msg queue
6168
6169 DEPENDENCIES
6170 The TL must be registered with WDA before this function can be called.
6171
6172 PARAMETERS
6173
6174 IN
6175 pvosGCtx: pointer to the global vos context; a handle to TL's
6176 or WDA's control block can be extracted from its context
6177
6178 RETURN VALUE None
6179
6180 SIDE EFFECTS
6181
6182============================================================================*/
6183
6184v_VOID_t
6185WLANTL_ClearTxXmitPending
6186(
6187 v_PVOID_t pvosGCtx
6188)
6189{
6190
6191 WLANTL_CbType* pTLCb = NULL;
6192 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
6193
6194 /*------------------------------------------------------------------------
6195 Sanity check
6196 Extract TL control block
6197 ------------------------------------------------------------------------*/
6198 pTLCb = VOS_GET_TL_CB(pvosGCtx);
6199 if ( NULL == pTLCb )
6200 {
6201 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_FATAL,
6202 "WLAN TL:Invalid TL pointer from pvosGCtx in WLANTL_ClearTxXmitPending "));
6203 return;
6204 }
6205
6206 pTLCb->isTxTranmitMsgPending = 0;
6207 return;
6208}/*WLANTL_ClearTxXmitPending */
6209
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05306210/*==========================================================================
6211 FUNCTION WLANTL_TxThreadDebugHandler
6212
6213 DESCRIPTION
6214 Printing TL Snapshot dump, processed under TxThread context, currently
6215 information regarding the global TlCb struture. Dumps information related
6216 to per active STA connection currently in use by TL.
6217
6218 DEPENDENCIES
6219 The TL must be initialized before this gets called.
6220
6221 PARAMETERS
6222
6223 IN
6224 pvosGCtx: pointer to the global vos context; a handle to TL's
6225 or WDA's control block can be extracted from its context
6226
6227 RETURN VALUE None
6228
6229 SIDE EFFECTS
6230
6231============================================================================*/
6232
6233v_VOID_t
6234WLANTL_TxThreadDebugHandler
6235(
6236 v_PVOID_t *pVosContext
6237)
6238{
6239 WLANTL_CbType* pTLCb = NULL;
6240 WLANTL_STAClientType* pClientSTA = NULL;
6241 int i = 0;
6242 tWDA_CbContext *pWDA = NULL;
6243
6244 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_FATAL,
6245 "WLAN TL: %s Enter ", __func__));
6246
6247 pTLCb = VOS_GET_TL_CB(pVosContext);
6248 pWDA = (tWDA_CbContext *)vos_get_global_context(VOS_MODULE_ID_WDA, pVosContext);
6249
6250 if ( NULL == pVosContext || NULL == pTLCb )
6251 {
6252 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6253 "Global VoS Context or TL Context are NULL"));
6254 return;
6255 }
6256
6257 if (NULL != pWDA)
6258 {
6259 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6260 "WDA uTxFlowMask: %d", pWDA->uTxFlowMask));
6261 }
6262 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6263 "************************TL DUMP INFORMATION**************"));
6264
6265 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6266 "uDelayedTriggerFrmInt:%d\tuMinFramesProcThres:%d",
6267 pTLCb->tlConfigInfo.uDelayedTriggerFrmInt,
6268 pTLCb->tlConfigInfo.uMinFramesProcThres));
6269
6270 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6271 "Management Frame Client exists: %d",
6272 pTLCb->tlMgmtFrmClient.ucExists));
6273 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6274 "usPendingTxCompleteCount: %d\tucTxSuspended: %d",
6275 pTLCb->usPendingTxCompleteCount,
6276 pTLCb->ucTxSuspended));
6277
6278 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6279 "uResCount: %d", pTLCb->uResCount));
6280
6281 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6282 "ucRegisteredStaId: %d\tucCurrentSTA: %d",
6283 pTLCb->ucRegisteredStaId, pTLCb->ucCurrentSTA));
6284
6285 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6286 "UrgentFrameProcessing: %s\tuFramesProcThres: %d",
6287 (pTLCb->bUrgent?"True":"False"), pTLCb->uFramesProcThres));
6288
6289 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6290 "isTxTranmitMsgPending: %d\t isBMPS: %s",
6291 pTLCb->isTxTranmitMsgPending, pTLCb->isBMPS?"True":"False"));
6292
6293#ifdef FEATURE_WLAN_TDLS
6294 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6295 "TDLS Peer Count: %d", pTLCb->ucTdlsPeerCount));
6296#endif
6297
6298 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6299 "++++++++++++++++++++Registerd Client Information++++++++++"));
6300
6301 for ( i =0; i<WLAN_MAX_STA_COUNT; i++ )
6302 {
6303 pClientSTA = pTLCb->atlSTAClients[i];
6304 if( NULL == pClientSTA || 0 == pClientSTA->ucExists)
6305 {
6306 continue;
6307 }
6308
6309 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6310 "######################STA Index: %d ############################",i));
6311 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR, "WLAN_STADescType:"));
6312 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6313 "STAId: %d\t STA MAC Address: %pM", pClientSTA->wSTADesc.ucSTAId,
6314 pClientSTA->wSTADesc.vSTAMACAddress.bytes));
6315 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6316 "STA Type: %d\tProtectedFrame: %d",
6317 pClientSTA->wSTADesc.wSTAType, pClientSTA->wSTADesc.ucProtectedFrame));
6318 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6319 "QoS: %d\tRxFrameTrans: %d\tTxFrameTrans: %d",
6320 pClientSTA->wSTADesc.ucQosEnabled, pClientSTA->wSTADesc.ucSwFrameRXXlation,
6321 pClientSTA->wSTADesc.ucSwFrameTXXlation));
6322 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6323 "ucUcastSig: %d\tucBcastSig: %d", pClientSTA->wSTADesc.ucUcastSig,
6324 pClientSTA->wSTADesc.ucBcastSig));
6325
6326 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6327 "ClientIndex: %d\t Exists: %d", i, pClientSTA->ucExists));
6328 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6329 "TL State: %d\t TL Priority: %d", pClientSTA->tlState,
6330 pClientSTA->tlPri));
6331 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6332 "ucTxSuspended: %d\tucPktPending: %d", pClientSTA->ucTxSuspended,
6333 pClientSTA->ucPktPending));
6334 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6335 "ucEAPOLPktPending: %d\tucNoMoreData: %d",
6336 pClientSTA->ucEapolPktPending, pClientSTA->ucNoMoreData));
6337 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6338 "ucRxBlocked: %d\t fcStaTxDisabled: %d", pClientSTA->ucRxBlocked,
6339 pClientSTA->fcStaTxDisabled));
6340 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6341 "ucCurrentAC: %d\tucServicedAC: %d", pClientSTA->ucCurrentAC,
6342 pClientSTA->ucServicedAC));
6343 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6344 "TID: %d\tautTxCount[0]: %d\tauRxCount[0]: %d",0, pClientSTA->auTxCount[0],
6345 pClientSTA->auRxCount[0]));
6346 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6347 "aucAcMask[0]: %d\taucAcMask[1]: %d\taucAcMask[2]: %d\taucAcMask[3]: %d\t",
6348 pClientSTA->aucACMask[0], pClientSTA->aucACMask[1],
6349 pClientSTA->aucACMask[2], pClientSTA->aucACMask[3]));
6350 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6351 "ucCurrentWeight: %d", pClientSTA->ucCurrentWeight));
6352
6353 if( WLAN_STA_SOFTAP == pClientSTA->wSTADesc.wSTAType)
6354 {
6355 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6356 "TrafficStatistics for SOFTAP Station:"));
6357 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6358 "RUF=%d\tRMF=%d\tRBF=%d", pClientSTA->trafficStatistics.rxUCFcnt,
6359 pClientSTA->trafficStatistics.rxMCFcnt,
6360 pClientSTA->trafficStatistics.rxBCFcnt));
6361 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6362 "RUB=%d\tRMB=%d\tRBB=%d", pClientSTA->trafficStatistics.rxUCBcnt,
6363 pClientSTA->trafficStatistics.rxMCBcnt,
6364 pClientSTA->trafficStatistics.rxBCBcnt));
6365 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6366 "TUF=%d\tTMF=%d\tTBF=%d", pClientSTA->trafficStatistics.txUCFcnt,
6367 pClientSTA->trafficStatistics.txMCFcnt,
6368 pClientSTA->trafficStatistics.txBCFcnt));
6369 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6370 "TUB=%d\tTMB=%d\tTBB=%d", pClientSTA->trafficStatistics.txUCBcnt,
6371 pClientSTA->trafficStatistics.txMCBcnt,
6372 pClientSTA->trafficStatistics.txBCBcnt));
6373 }
6374 }
6375 return;
6376}
6377
6378/*==========================================================================
6379 FUNCTION WLANTL_TLDebugMessage
6380
6381 DESCRIPTION
6382 Post a TL Snapshot request, posts message in TxThread.
6383
6384 DEPENDENCIES
6385 The TL must be initialized before this gets called.
6386
6387 PARAMETERS
6388
6389 IN
6390 displaySnapshot Boolean showing whether to dump the snapshot or not.
6391
6392 RETURN VALUE None
6393
6394 SIDE EFFECTS
6395
6396============================================================================*/
6397
6398v_VOID_t
6399WLANTL_TLDebugMessage
6400(
6401 v_BOOL_t displaySnapshot
6402)
6403{
6404 vos_msg_t vosMsg;
6405 VOS_STATUS status;
6406
6407 if(displaySnapshot)
6408 {
6409 vosMsg.reserved = 0;
6410 vosMsg.bodyptr = NULL;
6411 vosMsg.type = WLANTL_TX_SNAPSHOT;
6412
6413 status = vos_tx_mq_serialize( VOS_MODULE_ID_TL, &vosMsg);
6414 if(status != VOS_STATUS_SUCCESS)
6415 {
6416 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR, "TX Msg Posting Failed with status: %d",status));
6417 return;
6418 }
6419 }
6420 return;
6421}
Jeff Johnson295189b2012-06-20 16:38:30 -07006422
6423/*============================================================================
6424 TL STATE MACHINE
6425============================================================================*/
6426
6427/*==========================================================================
6428 FUNCTION WLANTL_STATxConn
6429
6430 DESCRIPTION
6431 Transmit in connected state - only EAPOL and WAI packets allowed
6432
6433 DEPENDENCIES
6434 The STA must be registered with TL before this function can be called.
6435
6436 PARAMETERS
6437
6438 IN
6439 pvosGCtx: pointer to the global vos context; a handle to TL's
6440 control block can be extracted from its context
6441 ucSTAId: identifier of the station being processed
6442 vosDataBuff: pointer to the tx vos buffer
6443
6444 RETURN VALUE
6445 The result code associated with performing the operation
6446
6447 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
6448 page fault
6449 VOS_STATUS_SUCCESS: Everything is good :)
6450
6451 Other return values are possible coming from the called functions.
6452 Please check API for additional info.
6453
6454 SIDE EFFECTS
6455
6456============================================================================*/
6457VOS_STATUS
6458WLANTL_STATxConn
6459(
6460 v_PVOID_t pvosGCtx,
6461 v_U8_t ucSTAId,
6462 vos_pkt_t** pvosDataBuff
6463)
6464{
6465 v_U16_t usPktLen;
6466 VOS_STATUS vosStatus;
6467 v_MACADDR_t vDestMacAddr;
6468 vos_pkt_t* vosDataBuff = NULL;
6469 WLANTL_CbType* pTLCb = NULL;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306470 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07006471 WLANTL_MetaInfoType tlMetaInfo;
6472 v_U8_t ucTypeSubtype = 0;
6473 v_U8_t ucTid;
6474 v_U8_t extraHeadSpace = 0;
6475 v_U8_t ucWDSEnabled = 0;
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07006476 v_U8_t ucAC, ucACMask, i;
Gopichand Nakkala8b54e912013-03-11 10:44:21 +05306477 v_U8_t txFlag = HAL_TX_NO_ENCRYPTION_MASK;
Jeff Johnson295189b2012-06-20 16:38:30 -07006478 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
6479
6480 /*------------------------------------------------------------------------
6481 Sanity check
6482 Extract TL control block
6483 ------------------------------------------------------------------------*/
6484 pTLCb = VOS_GET_TL_CB(pvosGCtx);
6485 if ( NULL == pTLCb )
6486 {
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07006487 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6488 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_STATxConn");
Jeff Johnson295189b2012-06-20 16:38:30 -07006489 *pvosDataBuff = NULL;
6490 return VOS_STATUS_E_FAULT;
6491 }
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306492 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
6493
6494 if ( NULL == pClientSTA )
6495 {
6496 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6497 "WLAN TL:Client Memory was not allocated on %s", __func__));
6498 return VOS_STATUS_E_FAILURE;
6499 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006500
6501 /*-------------------------------------------------------------------
6502 Disable AC temporary - if successfull retrieve re-enable
6503 The order is justified because of the possible scenario
6504 - TL tryes to fetch packet for AC and it returns NULL
6505 - TL analyzes the data it has received to see if there are
6506 any more pkts available for AC -> if not TL will disable AC
6507 - however it is possible that while analyzing results TL got
6508 preempted by a pending indication where the mask was again set
6509 TL will not check again and as a result when it resumes
6510 execution it will disable AC
6511 To prevent this the AC will be disabled here and if retrieve
6512 is successfull it will be re-enabled
6513 -------------------------------------------------------------------*/
6514
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07006515
6516 //LTI:pTLCb->atlSTAClients[ucSTAId].
6517 //LTI: aucACMask[pTLCb->atlSTAClients[ucSTAId].ucCurrentAC] = 0;
6518
6519 /*------------------------------------------------------------------------
6520 Fetch packet from HDD
6521 ------------------------------------------------------------------------*/
Sunil Ravid5406f22013-01-22 00:18:31 -08006522#ifdef FEATURE_WLAN_TDLS
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306523 if ((WLAN_STA_SOFTAP != pClientSTA->wSTADesc.wSTAType) &&
Sunil Ravid5406f22013-01-22 00:18:31 -08006524 (!vos_concurrent_sessions_running()) &&
6525 !pTLCb->ucTdlsPeerCount)
6526 {
6527#else
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306528 if ((WLAN_STA_SOFTAP != pClientSTA->wSTADesc.wSTAType) &&
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07006529 (!vos_concurrent_sessions_running()))
6530 {
Sunil Ravid5406f22013-01-22 00:18:31 -08006531#endif
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306532 ucAC = pClientSTA->ucCurrentAC;
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07006533
6534 /*-------------------------------------------------------------------
6535 Disable AC temporary - if successfull retrieve re-enable
6536 The order is justified because of the possible scenario
6537 - TL tryes to fetch packet for AC and it returns NULL
6538 - TL analyzes the data it has received to see if there are
6539 any more pkts available for AC -> if not TL will disable AC
6540 - however it is possible that while analyzing results TL got
6541 preempted by a pending indication where the mask was again set
6542 TL will not check again and as a result when it resumes
6543 execution it will disable AC
6544 To prevent this the AC will be disabled here and if retrieve
6545 is successfull it will be re-enabled
6546 -------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306547 pClientSTA->aucACMask[ucAC] = 0;
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07006548 }
6549 else
6550 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306551 //softap case
6552 ucAC = pTLCb->uCurServedAC;
6553 pClientSTA->aucACMask[ucAC] = 0;
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07006554 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006555
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306556 /*You make an initial assumption that HDD has no more data and if the
Jeff Johnson295189b2012-06-20 16:38:30 -07006557 assumption was wrong you reset the flags to their original state
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306558 This will prevent from exposing a race condition between checking with HDD
Jeff Johnson295189b2012-06-20 16:38:30 -07006559 for packets and setting the flags to false*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306560 //LTI: vos_atomic_set_U8( &pTLCb->atlSTAClients[ucSTAId].ucPktPending, 0);
6561 //LTI: pTLCb->atlSTAClients[ucSTAId].ucNoMoreData = 1;
6562 vos_atomic_set_U8( &pClientSTA->ucPktPending, 0);
6563 WLAN_TL_AC_ARRAY_2_MASK( pClientSTA, ucACMask, i);
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306564 /*You make an initial assumption that HDD has no more data and if the
6565 assumption was wrong you reset the flags to their original state
6566 This will prevent from exposing a race condition between checking with HDD
6567 for packets and setting the flags to false*/
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07006568 if ( 0 == ucACMask )
6569 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306570 pClientSTA->ucNoMoreData = 1;
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07006571 }
6572 else
6573 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306574 vos_atomic_set_U8( &pClientSTA->ucPktPending, 1);
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07006575 }
6576
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07006577
Madan Mohan Koyyalamudid93f4942012-10-05 15:05:40 -07006578 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07006579 "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 +05306580 ucAC, ucACMask, pClientSTA->ucPktPending);
Jeff Johnson295189b2012-06-20 16:38:30 -07006581
6582 /*------------------------------------------------------------------------
6583 Fetch tx packet from HDD
6584 ------------------------------------------------------------------------*/
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07006585//LTI
6586#if 0
Jeff Johnson295189b2012-06-20 16:38:30 -07006587 if (WLAN_STA_SOFTAP != pTLCb->atlSTAClients[ucSTAId].wSTADesc.wSTAType &&
6588 (!vos_concurrent_sessions_running()))
6589 {
Jeff Johnson295189b2012-06-20 16:38:30 -07006590 // don't set 0.
6591 //vos_atomic_set_U8( &pTLCb->atlSTAClients[ucSTAId].ucPktPending, 0);
6592 vosStatus = pTLCb->atlSTAClients[ucSTAId].pfnSTAFetchPkt( pvosGCtx,
6593 &ucSTAId,
6594 pTLCb->atlSTAClients[ucSTAId].ucCurrentAC,
6595 &vosDataBuff, &tlMetaInfo );
Jeff Johnson295189b2012-06-20 16:38:30 -07006596 }
6597 else
6598 {
6599 //softap case
6600 WLANTL_ACEnumType ucAC = pTLCb->uCurServedAC;
6601 vosStatus = pTLCb->atlSTAClients[ucSTAId].pfnSTAFetchPkt( pvosGCtx,
6602 &ucSTAId,
6603 ucAC,
6604 &vosDataBuff, &tlMetaInfo );
6605 }
6606#endif
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07006607
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306608 vosStatus = pClientSTA->pfnSTAFetchPkt( pvosGCtx,
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07006609 &ucSTAId,
6610 ucAC,
6611 &vosDataBuff, &tlMetaInfo );
Jeff Johnson295189b2012-06-20 16:38:30 -07006612
6613 if (( VOS_STATUS_SUCCESS != vosStatus ) || ( NULL == vosDataBuff ))
6614 {
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07006615 TLLOG1(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -07006616 "WLAN TL:No more data at HDD status %d", vosStatus));
6617 *pvosDataBuff = NULL;
6618
6619 /*--------------------------------------------------------------------
6620 Reset AC for the serviced station to the highest priority AC
6621 -> due to no more data at the station
6622 Even if this AC is not supported by the station, correction will be
6623 made in the main TL loop
6624 --------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306625 pClientSTA->ucCurrentAC = WLANTL_AC_VO;
6626 pClientSTA->ucCurrentWeight = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07006627
Madan Mohan Koyyalamudid8000342012-11-08 14:55:26 -08006628 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07006629 "WLAN TL: WLANTL_STATxConn no more packets in HDD for AC: %d AC Mask: %d",
6630 ucAC, ucACMask);
6631
Jeff Johnson295189b2012-06-20 16:38:30 -07006632 return vosStatus;
6633 }
6634
6635 /*There are still packets in HDD - set back the pending packets and
6636 the no more data assumption*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306637 vos_atomic_set_U8( &pClientSTA->ucPktPending, 1);
6638 pClientSTA->ucNoMoreData = 0;
6639 pClientSTA->aucACMask[ucAC] = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07006640
Jeff Johnson295189b2012-06-20 16:38:30 -07006641#ifdef WLAN_PERF
6642 vos_pkt_set_user_data_ptr( vosDataBuff, VOS_PKT_USER_DATA_ID_BAL,
6643 (v_PVOID_t)0);
6644
6645#endif /*WLAN_PERF*/
6646
6647
6648#ifdef FEATURE_WLAN_WAPI
6649 /*------------------------------------------------------------------------
6650 If the packet is neither an Eapol packet nor a WAI packet then drop it
6651 ------------------------------------------------------------------------*/
6652 if ( 0 == tlMetaInfo.ucIsEapol && 0 == tlMetaInfo.ucIsWai )
6653 {
Madan Mohan Koyyalamudid93f4942012-10-05 15:05:40 -07006654 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -07006655 "WLAN TL:Only EAPOL or WAI packets allowed before authentication"));
6656
6657 /* Fail tx for packet */
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306658 pClientSTA->pfnSTATxComp( pvosGCtx, vosDataBuff,
Jeff Johnson295189b2012-06-20 16:38:30 -07006659 VOS_STATUS_E_BADMSG);
6660 vosDataBuff = NULL;
6661 *pvosDataBuff = NULL;
6662 return VOS_STATUS_SUCCESS;
6663 }
6664#else
6665 if ( 0 == tlMetaInfo.ucIsEapol )
6666 {
6667 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
6668 "WLAN TL:Received non EAPOL packet before authentication"));
6669
6670 /* Fail tx for packet */
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306671 pClientSTA->pfnSTATxComp( pvosGCtx, vosDataBuff,
Jeff Johnson295189b2012-06-20 16:38:30 -07006672 VOS_STATUS_E_BADMSG);
6673 vosDataBuff = NULL;
6674 *pvosDataBuff = NULL;
6675 return VOS_STATUS_SUCCESS;
6676 }
6677#endif /* FEATURE_WLAN_WAPI */
6678
6679 /*-------------------------------------------------------------------------
6680 Check TID
6681 -------------------------------------------------------------------------*/
6682 ucTid = tlMetaInfo.ucTID;
6683
6684 /*Make sure TID is valid*/
6685 if ( WLANTL_TID_INVALID(ucTid))
6686 {
6687 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6688 "WLAN TL:Invalid TID sent in meta info %d - defaulting to 0 (BE)",
6689 ucTid));
6690 ucTid = 0;
6691 }
6692
6693 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
6694 "WLAN TL:Attaching BD header to pkt on WLANTL_STATxConn"));
6695
6696#ifdef FEATURE_WLAN_WAPI
6697 /*------------------------------------------------------------------------
6698 Translate 802.3 frame to 802.11 if Frame translation is enabled or if
6699 frame is a WAI frame.
6700 ------------------------------------------------------------------------*/
6701 if ( ( 1 == tlMetaInfo.ucIsWai ) ||
6702 ( 0 == tlMetaInfo.ucDisableFrmXtl ) )
6703#else
6704 /*------------------------------------------------------------------------
6705 Translate 802.3 frame to 802.11 if Frame translation is enabled
6706 ------------------------------------------------------------------------*/
6707 if ( ( 0 == tlMetaInfo.ucDisableFrmXtl ) &&
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306708 ( 0 != pClientSTA->wSTADesc.ucSwFrameTXXlation) )
Jeff Johnson295189b2012-06-20 16:38:30 -07006709#endif //#ifdef FEATURE_WLAN_WAPI
6710 {
Kiran Venkatappacab0d352012-12-17 13:09:22 -08006711 vosStatus = WLANTL_Translate8023To80211Header( vosDataBuff, &vosStatus,
6712 pTLCb, &ucSTAId,
Ravi Joshid0699502013-07-08 15:48:47 -07006713 &tlMetaInfo, &ucWDSEnabled,
6714 &extraHeadSpace);
Jeff Johnson295189b2012-06-20 16:38:30 -07006715 if ( VOS_STATUS_SUCCESS != vosStatus )
6716 {
6717 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6718 "WLAN TL:Error when translating header WLANTL_STATxConn"));
6719
6720 return vosStatus;
6721 }
6722
6723 tlMetaInfo.ucDisableFrmXtl = 1;
6724 }
6725
6726 /*-------------------------------------------------------------------------
6727 Call HAL to fill BD header
6728 -------------------------------------------------------------------------*/
6729 ucTypeSubtype |= (WLANTL_80211_DATA_TYPE << 4);
6730
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306731 if ( pClientSTA->wSTADesc.ucQosEnabled )
Jeff Johnson295189b2012-06-20 16:38:30 -07006732 {
6733 ucTypeSubtype |= (WLANTL_80211_DATA_QOS_SUBTYPE);
6734 }
6735
Gopichand Nakkala8b54e912013-03-11 10:44:21 +05306736#ifdef FEATURE_WLAN_WAPI
6737 /* TL State does not transition to AUTHENTICATED till GTK is installed, So in
6738 * case of WPA where GTK handshake is done after the 4 way handshake, the
6739 * unicast 2/2 EAPOL packet from the STA->AP has to be encrypted even before
6740 * the TL is in authenticated state. Since the PTK has been installed
6741 * already (after the 4 way handshake) we make sure that all traffic
6742 * is encrypted henceforth.(Note: TL is still not in AUTHENTICATED state so
6743 * we will only allow EAPOL data or WAI in case of WAPI)
6744 */
6745 if (tlMetaInfo.ucIsEapol && pClientSTA->ptkInstalled)
6746 {
6747 txFlag = 0;
6748 }
6749#else
6750 if (pClientSTA->ptkInstalled)
6751 {
6752 txFlag = 0;
6753 }
6754#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006755
6756 vosStatus = (VOS_STATUS)WDA_DS_BuildTxPacketInfo( pvosGCtx, vosDataBuff , &vDestMacAddr,
6757 tlMetaInfo.ucDisableFrmXtl, &usPktLen,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306758 pClientSTA->wSTADesc.ucQosEnabled, ucWDSEnabled,
Jeff Johnson295189b2012-06-20 16:38:30 -07006759 extraHeadSpace,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306760 ucTypeSubtype, &pClientSTA->wSTADesc.vSelfMACAddress,
Gopichand Nakkala8b54e912013-03-11 10:44:21 +05306761 ucTid, txFlag,
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -07006762 tlMetaInfo.usTimeStamp, tlMetaInfo.ucIsEapol || tlMetaInfo.ucIsWai, tlMetaInfo.ucUP );
Jeff Johnson295189b2012-06-20 16:38:30 -07006763
6764 if ( VOS_STATUS_SUCCESS != vosStatus )
6765 {
6766 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6767 "WLAN TL:Failed while attempting to fill BD %d", vosStatus));
6768 *pvosDataBuff = NULL;
6769 return vosStatus;
6770 }
6771
6772 /*-----------------------------------------------------------------------
6773 Update tx counter for BA session query for tx side
6774 !1 - should this be done for EAPOL frames?
6775 -----------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306776 pClientSTA->auTxCount[ucTid]++;
Jeff Johnson295189b2012-06-20 16:38:30 -07006777
6778 vos_pkt_set_user_data_ptr( vosDataBuff, VOS_PKT_USER_DATA_ID_TL,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306779 (v_PVOID_t)pClientSTA->pfnSTATxComp );
Jeff Johnson295189b2012-06-20 16:38:30 -07006780
6781 /*------------------------------------------------------------------------
6782 Save data to input pointer for TL core
6783 ------------------------------------------------------------------------*/
6784 *pvosDataBuff = vosDataBuff;
6785 /*security frames cannot be delayed*/
6786 pTLCb->bUrgent = TRUE;
6787
Jeff Johnson295189b2012-06-20 16:38:30 -07006788 /* TX Statistics */
6789 if (!(tlMetaInfo.ucBcast || tlMetaInfo.ucMcast))
6790 {
6791 /* This is TX UC frame */
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306792 pClientSTA->trafficStatistics.txUCFcnt++;
6793 pClientSTA->trafficStatistics.txUCBcnt += usPktLen;
Jeff Johnson295189b2012-06-20 16:38:30 -07006794 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006795
6796 return VOS_STATUS_SUCCESS;
6797}/* WLANTL_STATxConn */
6798
6799
6800/*==========================================================================
6801 FUNCTION WLANTL_STATxAuth
6802
6803 DESCRIPTION
6804 Transmit in authenticated state - all data allowed
6805
6806 DEPENDENCIES
6807 The STA must be registered with TL before this function can be called.
6808
6809 PARAMETERS
6810
6811 IN
6812 pvosGCtx: pointer to the global vos context; a handle to TL's
6813 control block can be extracted from its context
6814 ucSTAId: identifier of the station being processed
6815 vosDataBuff: pointer to the tx vos buffer
6816
6817 RETURN VALUE
6818 The result code associated with performing the operation
6819
6820 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
6821 page fault
6822 VOS_STATUS_SUCCESS: Everything is good :)
6823
6824 Other return values are possible coming from the called functions.
6825 Please check API for additional info.
6826
6827 SIDE EFFECTS
6828
6829============================================================================*/
6830VOS_STATUS
6831WLANTL_STATxAuth
6832(
6833 v_PVOID_t pvosGCtx,
6834 v_U8_t ucSTAId,
6835 vos_pkt_t** pvosDataBuff
6836)
6837{
6838 v_U16_t usPktLen;
6839 VOS_STATUS vosStatus;
6840 v_MACADDR_t vDestMacAddr;
6841 vos_pkt_t* vosDataBuff = NULL;
6842 WLANTL_CbType* pTLCb = NULL;
6843 WLANTL_MetaInfoType tlMetaInfo;
6844 v_U8_t ucTypeSubtype = 0;
6845 WLANTL_ACEnumType ucAC;
6846 WLANTL_ACEnumType ucNextAC;
6847 v_U8_t ucTid;
6848 v_U8_t ucSwFrmXtl = 0;
6849 v_U8_t extraHeadSpace = 0;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306850 WLANTL_STAClientType *pStaClient = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07006851 v_U8_t ucWDSEnabled = 0;
6852 v_U8_t ucTxFlag = 0;
6853 v_U8_t ucACMask, i;
6854 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
6855
6856 /*------------------------------------------------------------------------
6857 Sanity check
6858 Extract TL control block
6859 ------------------------------------------------------------------------*/
6860 pTLCb = VOS_GET_TL_CB(pvosGCtx);
6861 if (( NULL == pTLCb ) || ( NULL == pvosDataBuff ))
6862 {
6863 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05306864 "WLAN TL:Invalid input params on WLANTL_STATxAuth TL %x DB %p",
Jeff Johnson295189b2012-06-20 16:38:30 -07006865 pTLCb, pvosDataBuff));
6866 if (NULL != pvosDataBuff)
6867 {
6868 *pvosDataBuff = NULL;
6869 }
6870 if(NULL != pTLCb)
6871 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306872 if ( NULL == pTLCb->atlSTAClients[ucSTAId] )
6873 {
6874 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6875 "WLAN TL:Client Memory was not allocated on %s", __func__));
6876 return VOS_STATUS_E_FAILURE;
6877 }
6878 pTLCb->atlSTAClients[ucSTAId]->ucNoMoreData = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07006879 }
6880 return VOS_STATUS_E_FAULT;
6881 }
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306882 pStaClient = pTLCb->atlSTAClients[ucSTAId];
Jeff Johnson295189b2012-06-20 16:38:30 -07006883
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306884 if ( NULL == pStaClient )
6885 {
6886 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6887 "WLAN TL:Client Memory was not allocated on %s", __func__));
6888 return VOS_STATUS_E_FAILURE;
6889 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006890
6891 vos_mem_zero(&tlMetaInfo, sizeof(tlMetaInfo));
6892 /*------------------------------------------------------------------------
6893 Fetch packet from HDD
6894 ------------------------------------------------------------------------*/
Sunil Ravid5406f22013-01-22 00:18:31 -08006895#ifdef FEATURE_WLAN_TDLS
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306896 if ((WLAN_STA_SOFTAP != pStaClient->wSTADesc.wSTAType) &&
Sunil Ravid5406f22013-01-22 00:18:31 -08006897 (!vos_concurrent_sessions_running()) &&
6898 !pTLCb->ucTdlsPeerCount)
6899 {
6900#else
Jeff Johnson295189b2012-06-20 16:38:30 -07006901 if ((WLAN_STA_SOFTAP != pStaClient->wSTADesc.wSTAType) &&
6902 (!vos_concurrent_sessions_running()))
6903 {
6904#endif
6905 ucAC = pStaClient->ucCurrentAC;
6906
6907 /*-------------------------------------------------------------------
6908 Disable AC temporary - if successfull retrieve re-enable
6909 The order is justified because of the possible scenario
6910 - TL tryes to fetch packet for AC and it returns NULL
6911 - TL analyzes the data it has received to see if there are
6912 any more pkts available for AC -> if not TL will disable AC
6913 - however it is possible that while analyzing results TL got
6914 preempted by a pending indication where the mask was again set
6915 TL will not check again and as a result when it resumes
6916 execution it will disable AC
6917 To prevent this the AC will be disabled here and if retrieve
6918 is successfull it will be re-enabled
6919 -------------------------------------------------------------------*/
6920 pStaClient->aucACMask[pStaClient->ucCurrentAC] = 0;
6921
6922 // don't reset it, as other AC queues in HDD may have packets
6923 //vos_atomic_set_U8( &pStaClient->ucPktPending, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07006924 }
6925 else
6926 {
6927 //softap case
6928 ucAC = pTLCb->uCurServedAC;
6929 pStaClient->aucACMask[ucAC] = 0;
6930
6931 //vos_atomic_set_U8( &pStaClient->ucPktPending, 0);
6932 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006933
6934 WLAN_TL_AC_ARRAY_2_MASK( pStaClient, ucACMask, i);
Jeff Johnson295189b2012-06-20 16:38:30 -07006935 /*You make an initial assumption that HDD has no more data and if the
6936 assumption was wrong you reset the flags to their original state
6937 This will prevent from exposing a race condition between checking with HDD
6938 for packets and setting the flags to false*/
6939 if ( 0 == ucACMask )
6940 {
6941 vos_atomic_set_U8( &pStaClient->ucPktPending, 0);
6942 pStaClient->ucNoMoreData = 1;
6943 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006944
6945 vosStatus = pStaClient->pfnSTAFetchPkt( pvosGCtx,
6946 &ucSTAId,
6947 ucAC,
6948 &vosDataBuff, &tlMetaInfo );
6949
6950
6951 if (( VOS_STATUS_SUCCESS != vosStatus ) || ( NULL == vosDataBuff ))
6952 {
6953
6954 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
6955 "WLAN TL:Failed while attempting to fetch pkt from HDD %d",
6956 vosStatus);
6957 *pvosDataBuff = NULL;
6958 /*--------------------------------------------------------------------
6959 Reset AC for the serviced station to the highest priority AC
6960 -> due to no more data at the station
6961 Even if this AC is not supported by the station, correction will be
6962 made in the main TL loop
6963 --------------------------------------------------------------------*/
6964 pStaClient->ucCurrentAC = WLANTL_AC_VO;
6965 pStaClient->ucCurrentWeight = 0;
6966
6967 return vosStatus;
6968 }
6969
Jeff Johnsone7245742012-09-05 17:12:55 -07006970 WLANTL_StatHandleTXFrame(pvosGCtx, ucSTAId, vosDataBuff, NULL, &tlMetaInfo);
Jeff Johnsone7245742012-09-05 17:12:55 -07006971
Jeff Johnson295189b2012-06-20 16:38:30 -07006972 /*There are still packets in HDD - set back the pending packets and
6973 the no more data assumption*/
6974 vos_atomic_set_U8( &pStaClient->ucPktPending, 1);
6975 pStaClient->ucNoMoreData = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07006976
Jeff Johnson295189b2012-06-20 16:38:30 -07006977 if (WLAN_STA_SOFTAP != pStaClient->wSTADesc.wSTAType)
6978 {
Jeff Johnson295189b2012-06-20 16:38:30 -07006979 // don't need to set it, as we don't reset it in this function.
6980 //vos_atomic_set_U8( &pTLCb->atlSTAClients[ucSTAId].ucPktPending, 1);
Jeff Johnson295189b2012-06-20 16:38:30 -07006981 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006982
6983#ifdef WLAN_PERF
6984 vos_pkt_set_user_data_ptr( vosDataBuff, VOS_PKT_USER_DATA_ID_BAL,
6985 (v_PVOID_t)0);
6986#endif /*WLAN_PERF*/
6987
6988 /*-------------------------------------------------------------------------
6989 Check TID
6990 -------------------------------------------------------------------------*/
6991 ucTid = tlMetaInfo.ucTID;
6992
6993 /*Make sure TID is valid*/
6994 if ( WLANTL_TID_INVALID(ucTid))
6995 {
6996 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6997 "WLAN TL:Invalid TID sent in meta info %d - defaulting to 0 (BE)",
6998 ucTid));
6999 ucTid = 0;
7000 }
7001
7002 /*Save for UAPSD timer consideration*/
7003 pStaClient->ucServicedAC = ucAC;
7004
7005 if ( ucAC == pStaClient->ucCurrentAC )
7006 {
7007 pStaClient->aucACMask[pStaClient->ucCurrentAC] = 1;
7008 pStaClient->ucCurrentWeight--;
7009 }
7010 else
7011 {
7012 pStaClient->ucCurrentAC = ucAC;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307013 pStaClient->ucCurrentWeight = pTLCb->tlConfigInfo.ucAcWeights[ucAC] - 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07007014
7015 pStaClient->aucACMask[pStaClient->ucCurrentAC] = 1;
7016
7017 }
7018
Jeff Johnson295189b2012-06-20 16:38:30 -07007019 if (WLAN_STA_SOFTAP != pStaClient->wSTADesc.wSTAType)
7020 {
Jeff Johnson295189b2012-06-20 16:38:30 -07007021 if ( 0 == pStaClient->ucCurrentWeight )
7022 {
7023 WLANTL_ACEnumType tempAC = ucAC;
7024 /*-----------------------------------------------------------------------
7025 Choose next AC - !!! optimize me
7026 -----------------------------------------------------------------------*/
7027 while ( 0 != ucACMask )
7028 {
7029 ucNextAC = (WLANTL_ACEnumType)(( tempAC - 1 ) & WLANTL_MASK_AC);
7030 if ( 0 != pStaClient->aucACMask[ucNextAC] )
7031 {
7032 pStaClient->ucCurrentAC = ucNextAC;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307033 pStaClient->ucCurrentWeight = pTLCb->tlConfigInfo.ucAcWeights[ucNextAC];
Jeff Johnson295189b2012-06-20 16:38:30 -07007034
7035 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
7036 "WLAN TL: Changing serviced AC to: %d with Weight: %d",
7037 pStaClient->ucCurrentAC ,
7038 pStaClient->ucCurrentWeight));
7039 break;
7040 }
7041 tempAC = ucNextAC;
7042 }
7043 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007044 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007045
7046 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
7047 "WLAN TL:Attaching BD header to pkt on WLANTL_STATxAuth"));
7048
7049 /*------------------------------------------------------------------------
7050 Translate 802.3 frame to 802.11
7051 ------------------------------------------------------------------------*/
7052 if ( 0 == tlMetaInfo.ucDisableFrmXtl )
7053 {
7054 /* Needs frame translation */
7055 // if the client has not enabled SW-only frame translation
7056 // and if the frame is a unicast frame
7057 // (HW frame translation does not support multiple broadcast domains
7058 // so we use SW frame translation for broadcast/multicast frames)
7059#ifdef FEATURE_WLAN_WAPI
7060 // and if the frame is not a WAPI frame
7061#endif
7062 // then use HW_based frame translation
7063
7064 if ( ( 0 == pStaClient->wSTADesc.ucSwFrameTXXlation ) &&
7065 ( 0 == tlMetaInfo.ucBcast ) &&
7066 ( 0 == tlMetaInfo.ucMcast )
7067#ifdef FEATURE_WLAN_WAPI
7068 && ( tlMetaInfo.ucIsWai != 1 )
7069#endif
7070 )
7071 {
7072#ifdef WLAN_PERF
7073 v_U32_t uFastFwdOK = 0;
7074
7075 /* HW based translation. See if the frame could be fast forwarded */
7076 WDA_TLI_FastHwFwdDataFrame( pvosGCtx, vosDataBuff , &vosStatus,
7077 &uFastFwdOK, &tlMetaInfo, &pStaClient->wSTADesc);
7078
7079 if( VOS_STATUS_SUCCESS == vosStatus )
7080 {
7081 if(uFastFwdOK)
7082 {
7083 /* Packet could be fast forwarded now */
7084 vos_pkt_set_user_data_ptr( vosDataBuff, VOS_PKT_USER_DATA_ID_TL,
7085 (v_PVOID_t)pStaClient->pfnSTATxComp );
7086
7087 *pvosDataBuff = vosDataBuff;
7088
7089 /* TODO: Do we really need to update WLANTL_HSHandleTXFrame()
7090 stats for every pkt? */
7091 pStaClient->auTxCount[tlMetaInfo.ucTID]++;
7092 return vosStatus;
7093 }
7094 /* can't be fast forwarded, fall through normal (slow) path. */
7095 }
7096 else
7097 {
7098
7099 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7100 "WLAN TL:Failed while attempting to fastFwd BD %d", vosStatus));
7101 *pvosDataBuff = NULL;
7102 return vosStatus;
7103 }
7104#endif /*WLAN_PERF*/
7105 }
7106 else
7107 {
7108 /* SW based translation */
7109
7110#ifdef FEATURE_WLAN_WAPI
7111 gUcIsWai = tlMetaInfo.ucIsWai,
7112#endif
7113
Kiran Venkatappacab0d352012-12-17 13:09:22 -08007114 vosStatus = WLANTL_Translate8023To80211Header( vosDataBuff, &vosStatus,
7115 pTLCb, &ucSTAId,
Ravi Joshid0699502013-07-08 15:48:47 -07007116 &tlMetaInfo, &ucWDSEnabled,
7117 &extraHeadSpace);
Jeff Johnson295189b2012-06-20 16:38:30 -07007118 if ( VOS_STATUS_SUCCESS != vosStatus )
7119 {
7120 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7121 "WLAN TL:Error when translating header WLANTL_STATxAuth"));
7122 return vosStatus;
7123 }
7124
7125 TLLOG4(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_LOW,
7126 "WLAN TL software translation success \n"));
7127 ucSwFrmXtl = 1;
7128 tlMetaInfo.ucDisableFrmXtl = 1;
7129 }
7130 }
Gopichand Nakkala574f6d12013-06-27 19:38:43 +05307131#ifdef FEATURE_WLAN_TDLS
7132 /*In case of TDLS, if the packet is destined to TDLS STA ucSTAId may
7133 change. so update the pStaClient accordingly */
7134 pStaClient = pTLCb->atlSTAClients[ucSTAId];
Jeff Johnson295189b2012-06-20 16:38:30 -07007135
Gopichand Nakkala574f6d12013-06-27 19:38:43 +05307136 if ( NULL == pStaClient )
7137 {
7138 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7139 "pStaClient is NULL %s", __func__));
7140 return VOS_STATUS_E_FAILURE;
7141 }
7142#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007143 /*-------------------------------------------------------------------------
7144 Call HAL to fill BD header
7145 -------------------------------------------------------------------------*/
7146 ucTypeSubtype |= (WLANTL_80211_DATA_TYPE << 4);
7147
7148 if ( pStaClient->wSTADesc.ucQosEnabled )
7149 {
7150 ucTypeSubtype |= (WLANTL_80211_DATA_QOS_SUBTYPE);
7151 }
7152
7153 ucTxFlag = (0 != pStaClient->wUAPSDInfo[ucAC].ucSet)?
7154 HAL_TRIGGER_ENABLED_AC_MASK:0;
7155
7156#ifdef FEATURE_WLAN_WAPI
7157 if ( pStaClient->wSTADesc.ucIsWapiSta == 1 )
7158 {
7159#ifdef LIBRA_WAPI_SUPPORT
7160 ucTxFlag = ucTxFlag | HAL_WAPI_STA_MASK;
7161#endif //LIBRA_WAPI_SUPPORT
7162 if ( tlMetaInfo.ucIsWai == 1 )
7163 {
7164 ucTxFlag = ucTxFlag | HAL_TX_NO_ENCRYPTION_MASK;
7165 }
7166 }
7167#endif /* FEATURE_WLAN_WAPI */
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007168#ifdef FEATURE_WLAN_TDLS
7169 if ( pStaClient->wSTADesc.wSTAType == WLAN_STA_TDLS )
7170 {
7171 ucTxFlag = ucTxFlag | HAL_TDLS_PEER_STA_MASK;
7172 }
7173#endif /* FEATURE_WLAN_TDLS */
Jeff Johnson295189b2012-06-20 16:38:30 -07007174
7175 vosStatus = (VOS_STATUS)WDA_DS_BuildTxPacketInfo( pvosGCtx,
7176 vosDataBuff , &vDestMacAddr,
7177 tlMetaInfo.ucDisableFrmXtl, &usPktLen,
7178 pStaClient->wSTADesc.ucQosEnabled, ucWDSEnabled,
7179 extraHeadSpace,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307180 ucTypeSubtype, &pStaClient->wSTADesc.vSelfMACAddress,
Jeff Johnson295189b2012-06-20 16:38:30 -07007181 ucTid, ucTxFlag, tlMetaInfo.usTimeStamp,
7182 tlMetaInfo.ucIsEapol, tlMetaInfo.ucUP );
7183
7184 if(!VOS_IS_STATUS_SUCCESS(vosStatus))
7185 {
7186 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7187 "Fill TX BD Error status %d", vosStatus));
7188
7189 return vosStatus;
7190 }
7191
Jeff Johnson295189b2012-06-20 16:38:30 -07007192 /* TX Statistics */
7193 if (!(tlMetaInfo.ucBcast || tlMetaInfo.ucMcast))
7194 {
7195 /* This is TX UC frame */
7196 pStaClient->trafficStatistics.txUCFcnt++;
7197 pStaClient->trafficStatistics.txUCBcnt += usPktLen;
7198 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007199
Kiran Venkatappacab0d352012-12-17 13:09:22 -08007200#ifndef FEATURE_WLAN_TDLS
Jeff Johnson295189b2012-06-20 16:38:30 -07007201 /*-----------------------------------------------------------------------
7202 Update tx counter for BA session query for tx side
7203 -----------------------------------------------------------------------*/
7204 pStaClient->auTxCount[ucTid]++;
Kiran Venkatappacab0d352012-12-17 13:09:22 -08007205#else
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307206 pTLCb->atlSTAClients[ucSTAId]->auTxCount[ucTid]++;
Kiran Venkatappacab0d352012-12-17 13:09:22 -08007207#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007208
7209 /* This code is to send traffic with lower priority AC when we does not
7210 get admitted to send it. Today HAL does not downgrade AC so this code
7211 does not get executed.(In other words, HAL doesnÂ’t change tid. The if
7212 statement is always false.)
7213 NOTE: In the case of LA downgrade occurs in HDD (that was the change
7214 Phani made during WMM-AC plugfest). If WM & BMP also took this approach,
7215 then there will be no need for any AC downgrade logic in TL/WDI. */
7216#if 0
7217 if (( ucTid != tlMetaInfo.ucTID ) &&
7218 ( 0 != pStaClient->wSTADesc.ucQosEnabled ) &&
7219 ( 0 != ucSwFrmXtl ))
7220 {
7221 /*---------------------------------------------------------------------
7222 !! FIX me: Once downgrading is clear put in the proper change
7223 ---------------------------------------------------------------------*/
7224 ucQCOffset = WLANHAL_TX_BD_HEADER_SIZE + WLANTL_802_11_HEADER_LEN;
7225
7226 //!!!Fix this replace peek with extract
7227 vos_pkt_peek_data( vosDataBuff, ucQCOffset,(v_PVOID_t)&pucQosCtrl,
7228 sizeof(*pucQosCtrl));
7229 *pucQosCtrl = ucTid; //? proper byte order
7230 }
7231#endif
7232
7233 if ( VOS_STATUS_SUCCESS != vosStatus )
7234 {
7235 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7236 "WLAN TL:Failed while attempting to fill BD %d", vosStatus));
7237 *pvosDataBuff = NULL;
7238 return vosStatus;
7239 }
7240
7241 vos_pkt_set_user_data_ptr( vosDataBuff, VOS_PKT_USER_DATA_ID_TL,
7242 (v_PVOID_t)pStaClient->pfnSTATxComp );
7243
7244 *pvosDataBuff = vosDataBuff;
7245
7246 /*BE & BK can be delayed, VO and VI not frames cannot be delayed*/
7247 if ( pStaClient->ucServicedAC > WLANTL_AC_BE )
7248 {
7249 pTLCb->bUrgent= TRUE;
7250 }
7251
7252 return VOS_STATUS_SUCCESS;
7253}/* WLANTL_STATxAuth */
7254
7255/*==========================================================================
7256 FUNCTION WLANTL_STATxDisc
7257
7258 DESCRIPTION
7259 Transmit in disconnected state - no data allowed
7260
7261 DEPENDENCIES
7262 The STA must be registered with TL before this function can be called.
7263
7264 PARAMETERS
7265
7266 IN
7267 pvosGCtx: pointer to the global vos context; a handle to TL's
7268 control block can be extracted from its context
7269 ucSTAId: identifier of the station being processed
7270 vosDataBuff: pointer to the tx vos buffer
7271
7272 RETURN VALUE
7273 The result code associated with performing the operation
7274
7275 VOS_STATUS_SUCCESS: Everything is good :)
7276
7277 SIDE EFFECTS
7278
7279============================================================================*/
7280VOS_STATUS
7281WLANTL_STATxDisc
7282(
7283 v_PVOID_t pvosGCtx,
7284 v_U8_t ucSTAId,
7285 vos_pkt_t** pvosDataBuff
7286)
7287{
7288 WLANTL_CbType* pTLCb = NULL;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307289 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07007290 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
7291
Jeff Johnson295189b2012-06-20 16:38:30 -07007292 /*------------------------------------------------------------------------
7293 Sanity check
7294 Extract TL control block
7295 ------------------------------------------------------------------------*/
7296 pTLCb = VOS_GET_TL_CB(pvosGCtx);
7297 if ( NULL == pTLCb )
7298 {
7299 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7300 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_STATxAuth"));
7301 *pvosDataBuff = NULL;
7302 return VOS_STATUS_E_FAULT;
7303 }
7304
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307305 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
7306
7307 if ( NULL == pClientSTA )
7308 {
7309 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7310 "WLAN TL:Client Memory was not allocated on %s", __func__));
7311 return VOS_STATUS_E_FAILURE;
7312 }
7313
Jeff Johnson295189b2012-06-20 16:38:30 -07007314 /*------------------------------------------------------------------------
7315 Error
7316 ------------------------------------------------------------------------*/
7317 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
7318 "WLAN TL:Packet should not be transmitted in state disconnected ignoring"
7319 " request"));
7320
7321 *pvosDataBuff = NULL;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307322 pClientSTA->ucNoMoreData = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07007323
7324 //Should not be anything pending in disconnect state
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307325 vos_atomic_set_U8( &pClientSTA->ucPktPending, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07007326
7327 return VOS_STATUS_SUCCESS;
7328}/* WLANTL_STATxDisc */
7329
7330/*==========================================================================
7331 FUNCTION WLANTL_STARxConn
7332
7333 DESCRIPTION
7334 Receive in connected state - only EAPOL
7335
7336 DEPENDENCIES
7337 The STA must be registered with TL before this function can be called.
7338
7339 PARAMETERS
7340
7341 IN
7342 pvosGCtx: pointer to the global vos context; a handle to TL's
7343 control block can be extracted from its context
7344 ucSTAId: identifier of the station being processed
7345 vosDataBuff: pointer to the tx/rx vos buffer
7346
7347 RETURN VALUE
7348 The result code associated with performing the operation
7349
7350 VOS_STATUS_E_INVAL: invalid input parameters
7351 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
7352 page fault
7353 VOS_STATUS_SUCCESS: Everything is good :)
7354
7355 SIDE EFFECTS
7356
7357============================================================================*/
7358VOS_STATUS
7359WLANTL_STARxConn
7360(
7361 v_PVOID_t pvosGCtx,
7362 v_U8_t ucSTAId,
7363 vos_pkt_t** pvosDataBuff
7364)
7365{
7366 WLANTL_CbType* pTLCb = NULL;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307367 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07007368 v_U16_t usEtherType = 0;
7369 v_U16_t usPktLen;
7370 v_U8_t ucMPDUHOffset;
7371 v_U16_t usMPDUDOffset;
7372 v_U16_t usMPDULen;
7373 v_U8_t ucMPDUHLen;
7374 v_U16_t usActualHLen = 0;
7375 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
7376 vos_pkt_t* vosDataBuff;
7377 v_PVOID_t aucBDHeader;
7378 v_U8_t ucTid;
7379 WLANTL_RxMetaInfoType wRxMetaInfo;
7380 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
7381
7382 /*------------------------------------------------------------------------
7383 Sanity check
7384 ------------------------------------------------------------------------*/
7385 if (( NULL == pvosDataBuff ) || ( NULL == ( vosDataBuff = *pvosDataBuff )))
7386 {
7387 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7388 "WLAN TL:Invalid parameter sent on WLANTL_STARxConn"));
7389 return VOS_STATUS_E_INVAL;
7390 }
7391
7392 /*------------------------------------------------------------------------
7393 Extract TL control block
7394 ------------------------------------------------------------------------*/
7395 pTLCb = VOS_GET_TL_CB(pvosGCtx);
7396 if ( NULL == pTLCb )
7397 {
7398 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7399 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_ChangeSTAState"));
7400 return VOS_STATUS_E_FAULT;
7401 }
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307402 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
7403
7404 if ( NULL == pClientSTA )
7405 {
7406 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7407 "WLAN TL:Client Memory was not allocated on %s", __func__));
7408 return VOS_STATUS_E_FAILURE;
7409 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007410
7411 /*------------------------------------------------------------------------
7412 Extract BD header and check if valid
7413 ------------------------------------------------------------------------*/
7414 vosStatus = WDA_DS_PeekRxPacketInfo( vosDataBuff, (v_PVOID_t)&aucBDHeader, 0/*Swap BD*/ );
7415
7416 if ( NULL == aucBDHeader )
7417 {
7418 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7419 "WLAN TL:Cannot extract BD header"));
7420 VOS_ASSERT( 0 );
7421 return VOS_STATUS_E_FAULT;
7422 }
7423
7424
7425 ucMPDUHOffset = (v_U8_t)WDA_GET_RX_MPDU_HEADER_OFFSET(aucBDHeader);
7426 usMPDUDOffset = (v_U16_t)WDA_GET_RX_MPDU_DATA_OFFSET(aucBDHeader);
7427 usMPDULen = (v_U16_t)WDA_GET_RX_MPDU_LEN(aucBDHeader);
7428 ucMPDUHLen = (v_U8_t)WDA_GET_RX_MPDU_HEADER_LEN(aucBDHeader);
7429 ucTid = (v_U8_t)WDA_GET_RX_TID(aucBDHeader);
7430
7431 vos_pkt_get_packet_length( vosDataBuff, &usPktLen);
7432
7433 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
7434 "WLAN TL:BD header processing data: HO %d DO %d Len %d HLen %d",
7435 ucMPDUHOffset, usMPDUDOffset, usMPDULen, ucMPDUHLen));
7436
7437 /*It will cut out the 802.11 header if not used*/
7438 if ( VOS_STATUS_SUCCESS != WDA_DS_TrimRxPacketInfo( vosDataBuff ) )
7439 {
7440 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
7441 "WLAN TL:BD header corrupted - dropping packet"));
7442 /* Drop packet */
7443 vos_pkt_return_packet(vosDataBuff);
7444 return VOS_STATUS_SUCCESS;
7445 }
7446
7447 vosStatus = WLANTL_GetEtherType(aucBDHeader,vosDataBuff,ucMPDUHLen,&usEtherType);
7448
7449 if( VOS_IS_STATUS_SUCCESS(vosStatus) )
7450 {
7451#ifdef FEATURE_WLAN_WAPI
7452 /* If frame is neither an EAPOL frame nor a WAI frame then we drop the frame*/
7453 /* TODO: Do we need a check to see if we are in WAPI mode? If not is it possible */
7454 /* that we get an EAPOL packet in WAPI mode or vice versa? */
7455 if ( WLANTL_LLC_8021X_TYPE != usEtherType && WLANTL_LLC_WAI_TYPE != usEtherType )
7456 {
Sunil Ravid5406f22013-01-22 00:18:31 -08007457 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07007458 "WLAN TL:RX Frame not EAPOL or WAI EtherType %d - dropping", usEtherType );
Jeff Johnson295189b2012-06-20 16:38:30 -07007459 /* Drop packet */
7460 vos_pkt_return_packet(vosDataBuff);
7461 }
7462#else
7463 if ( WLANTL_LLC_8021X_TYPE != usEtherType )
7464 {
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07007465 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7466 "WLAN TL:RX Frame not EAPOL EtherType %d - dropping", usEtherType);
Jeff Johnson295189b2012-06-20 16:38:30 -07007467 /* Drop packet */
7468 vos_pkt_return_packet(vosDataBuff);
7469 }
7470#endif /* FEATURE_WLAN_WAPI */
7471 else /* Frame is an EAPOL frame or a WAI frame*/
7472 {
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07007473
Madan Mohan Koyyalamudid8000342012-11-08 14:55:26 -08007474 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07007475 "WLAN TL:RX Frame EAPOL EtherType %d - processing", usEtherType);
7476
Jeff Johnson295189b2012-06-20 16:38:30 -07007477 if (( 0 == WDA_GET_RX_FT_DONE(aucBDHeader) ) &&
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307478 ( 0 != pClientSTA->wSTADesc.ucSwFrameRXXlation))
Jeff Johnson295189b2012-06-20 16:38:30 -07007479 {
7480 if (usMPDUDOffset > ucMPDUHOffset)
7481 {
7482 usActualHLen = usMPDUDOffset - ucMPDUHOffset;
7483 }
7484
7485 vosStatus = WLANTL_Translate80211To8023Header( vosDataBuff, &vosStatus, usActualHLen,
7486 ucMPDUHLen, pTLCb, ucSTAId);
7487
7488 if ( VOS_STATUS_SUCCESS != vosStatus )
7489 {
7490 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7491 "WLAN TL:Failed to translate from 802.11 to 802.3 - dropping"));
7492 /* Drop packet */
7493 vos_pkt_return_packet(vosDataBuff);
7494 return vosStatus;
7495 }
7496 }
7497 /*-------------------------------------------------------------------
7498 Increment receive counter
7499 -------------------------------------------------------------------*/
Madan Mohan Koyyalamudic0e5bd82012-09-18 17:12:27 -07007500 if ( !WLANTL_TID_INVALID( ucTid) )
7501 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307502 pClientSTA->auRxCount[ucTid]++;
Madan Mohan Koyyalamudic0e5bd82012-09-18 17:12:27 -07007503 }
7504 else
7505 {
7506 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7507 "WLAN TL:Invalid tid %d (Station ID %d) on %s",
7508 ucTid, ucSTAId, __func__));
7509 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007510
7511 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
7512 "WLAN TL:Sending EAPoL frame to station %d AC %d", ucSTAId, ucTid));
7513
7514 /*-------------------------------------------------------------------
7515 !!!Assuming TID = UP mapping
7516 -------------------------------------------------------------------*/
7517 wRxMetaInfo.ucUP = ucTid;
7518
Jeff Johnson295189b2012-06-20 16:38:30 -07007519 TLLOG4(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_LOW,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007520 "WLAN TL %s:Sending data chain to station \n", __func__));
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307521 if ( WLAN_STA_SOFTAP == pClientSTA->wSTADesc.wSTAType )
Jeff Johnson295189b2012-06-20 16:38:30 -07007522 {
7523 wRxMetaInfo.ucDesSTAId = WLAN_RX_SAP_SELF_STA_ID;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307524 pClientSTA->pfnSTARx( pvosGCtx, vosDataBuff, ucSTAId,
Jeff Johnson295189b2012-06-20 16:38:30 -07007525 &wRxMetaInfo );
7526 }
7527 else
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307528 pClientSTA->pfnSTARx( pvosGCtx, vosDataBuff, ucSTAId,
Jeff Johnson295189b2012-06-20 16:38:30 -07007529 &wRxMetaInfo );
7530 }/*EAPOL frame or WAI frame*/
7531 }/*vos status success*/
7532
7533 return VOS_STATUS_SUCCESS;
7534}/* WLANTL_STARxConn */
7535
Jeff Johnson295189b2012-06-20 16:38:30 -07007536/*==========================================================================
7537 FUNCTION WLANTL_FwdPktToHDD
7538
7539 DESCRIPTION
7540 Determine the Destation Station ID and route the Frame to Upper Layer
7541
7542 DEPENDENCIES
7543
7544 PARAMETERS
7545
7546 IN
7547 pvosGCtx: pointer to the global vos context; a handle to TL's
7548 control block can be extracted from its context
7549 ucSTAId: identifier of the station being processed
7550 vosDataBuff: pointer to the rx vos buffer
7551
7552 RETURN VALUE
7553 The result code associated with performing the operation
7554
7555 VOS_STATUS_E_INVAL: invalid input parameters
7556 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
7557 page fault
7558 VOS_STATUS_SUCCESS: Everything is good :)
7559
7560 SIDE EFFECTS
7561
7562============================================================================*/
7563
7564VOS_STATUS
7565WLANTL_FwdPktToHDD
7566(
7567 v_PVOID_t pvosGCtx,
7568 vos_pkt_t* pvosDataBuff,
7569 v_U8_t ucSTAId
7570)
7571{
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307572 v_MACADDR_t DestMacAddress;
7573 v_MACADDR_t *pDestMacAddress = &DestMacAddress;
7574 v_SIZE_t usMacAddSize = VOS_MAC_ADDR_SIZE;
Jeff Johnson295189b2012-06-20 16:38:30 -07007575 WLANTL_CbType* pTLCb = NULL;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307576 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07007577 vos_pkt_t* vosDataBuff ;
7578 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307579 v_U32_t STAMetaInfo;
7580 vos_pkt_t* vosNextDataBuff ;
7581 v_U8_t ucDesSTAId;
Jeff Johnson295189b2012-06-20 16:38:30 -07007582 WLANTL_RxMetaInfoType wRxMetaInfo;
7583
Jeff Johnson295189b2012-06-20 16:38:30 -07007584 /*------------------------------------------------------------------------
7585 Sanity check
7586 ------------------------------------------------------------------------*/
7587 if (( NULL == pvosDataBuff ) || ( NULL == ( vosDataBuff = pvosDataBuff )))
7588 {
7589 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7590 "WLAN TL:Invalid parameter sent on WLANTL_FwdPktToHdd"));
7591 return VOS_STATUS_E_INVAL;
7592 }
7593
7594 /*------------------------------------------------------------------------
7595 Extract TL control block
7596 ------------------------------------------------------------------------*/
7597 pTLCb = VOS_GET_TL_CB(pvosGCtx);
7598 if ( NULL == pTLCb )
7599 {
7600 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7601 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_FwdPktToHdd"));
7602 return VOS_STATUS_E_FAULT;
7603 }
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307604
Tushnim Bhattacharyya5dd94562013-03-20 20:15:03 -07007605 if(WLANTL_STA_ID_INVALID(ucSTAId))
7606 {
7607 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,"ucSTAId %d is not valid",
7608 ucSTAId));
7609 return VOS_STATUS_E_INVAL;
7610 }
7611
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307612 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
7613
7614 if ( NULL == pClientSTA )
7615 {
7616 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7617 "WLAN TL:Client Memory was not allocated on %s", __func__));
7618 return VOS_STATUS_E_FAILURE;
7619 }
7620
Jeff Johnson295189b2012-06-20 16:38:30 -07007621 /* This the change required for SoftAp to handle Reordered Buffer. Since a STA
7622 may have packets destined to multiple destinations we have to process each packet
7623 at a time and determine its Destination. So the Voschain provided by Reorder code
7624 is unchain and forwarded to Upper Layer after Determining the Destination */
7625
7626 vosDataBuff = pvosDataBuff;
7627 while (vosDataBuff != NULL)
7628 {
7629 vos_pkt_walk_packet_chain( vosDataBuff, &vosNextDataBuff, 1/*true*/ );
7630 vos_pkt_get_user_data_ptr( vosDataBuff, VOS_PKT_USER_DATA_ID_TL,
7631 (v_PVOID_t *)&STAMetaInfo );
7632 wRxMetaInfo.ucUP = (v_U8_t)(STAMetaInfo & WLANTL_AC_MASK);
Gopichand Nakkala976e3252013-01-03 15:45:56 -08007633 ucDesSTAId = (v_U8_t)((STAMetaInfo) >> WLANTL_STAID_OFFSET);
Jeff Johnson295189b2012-06-20 16:38:30 -07007634
7635 vosStatus = vos_pkt_extract_data( vosDataBuff, 0, (v_VOID_t *)pDestMacAddress, &usMacAddSize);
7636 if ( VOS_STATUS_SUCCESS != vosStatus )
7637 {
7638 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7639 "WLAN TL: recv corrupted data packet\n"));
7640 vos_pkt_return_packet(vosDataBuff);
7641 return vosStatus;
7642 }
7643
7644 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",
7645 pDestMacAddress->bytes[0], pDestMacAddress->bytes[1], pDestMacAddress->bytes[2],
7646 pDestMacAddress->bytes[3], pDestMacAddress->bytes[4], pDestMacAddress->bytes[5]));
7647
7648 if (vos_is_macaddr_broadcast( pDestMacAddress ) || vos_is_macaddr_group(pDestMacAddress))
7649 {
7650 // destination is mc/bc station
7651 ucDesSTAId = WLAN_RX_BCMC_STA_ID;
7652 TLLOG4(VOS_TRACE( VOS_MODULE_ID_HDD_SOFTAP, VOS_TRACE_LEVEL_INFO_LOW,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007653 "%s: BC/MC packet, id %d\n", __func__, WLAN_RX_BCMC_STA_ID));
Jeff Johnson295189b2012-06-20 16:38:30 -07007654 }
7655 else
7656 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307657 if (vos_is_macaddr_equal(pDestMacAddress, &pClientSTA->wSTADesc.vSelfMACAddress))
Jeff Johnson295189b2012-06-20 16:38:30 -07007658 {
7659 // destination is AP itself
7660 ucDesSTAId = WLAN_RX_SAP_SELF_STA_ID;
7661 TLLOG4(VOS_TRACE( VOS_MODULE_ID_HDD_SOFTAP, VOS_TRACE_LEVEL_INFO_LOW,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007662 "%s: packet to AP itself, id %d\n", __func__, WLAN_RX_SAP_SELF_STA_ID));
Jeff Johnson295189b2012-06-20 16:38:30 -07007663 }
Madan Mohan Koyylamudi64258222013-01-30 14:35:10 +05307664 else if (( WLAN_MAX_STA_COUNT <= ucDesSTAId ) || (NULL != pTLCb->atlSTAClients[ucDesSTAId] && pTLCb->atlSTAClients[ucDesSTAId]->ucExists == 0))
Jeff Johnson295189b2012-06-20 16:38:30 -07007665 {
7666 // destination station is something else
7667 TLLOG4(VOS_TRACE( VOS_MODULE_ID_HDD_SOFTAP, VOS_TRACE_LEVEL_INFO_LOW,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007668 "%s: get an station index larger than WLAN_MAX_STA_COUNT %d\n", __func__, ucDesSTAId));
Jeff Johnson295189b2012-06-20 16:38:30 -07007669 ucDesSTAId = WLAN_RX_SAP_SELF_STA_ID;
7670 }
7671
7672
7673 //loopback unicast station comes here
7674 }
7675
7676 wRxMetaInfo.ucUP = (v_U8_t)(STAMetaInfo & WLANTL_AC_MASK);
7677 wRxMetaInfo.ucDesSTAId = ucDesSTAId;
7678
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307679 vosStatus = pClientSTA->pfnSTARx( pvosGCtx, vosDataBuff, ucDesSTAId,
Jeff Johnson295189b2012-06-20 16:38:30 -07007680 &wRxMetaInfo );
7681 if ( VOS_STATUS_SUCCESS != vosStatus )
7682 {
7683 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7684 "WLAN TL: failed to send pkt to HDD \n"));
7685 vos_pkt_return_packet(vosDataBuff);
7686 return vosStatus;
7687 }
7688 vosDataBuff = vosNextDataBuff;
7689 }
7690 return VOS_STATUS_SUCCESS;
7691}
Jeff Johnson295189b2012-06-20 16:38:30 -07007692
7693/*==========================================================================
7694 FUNCTION WLANTL_STARxAuth
7695
7696 DESCRIPTION
7697 Receive in authenticated state - all data allowed
7698
7699 DEPENDENCIES
7700 The STA must be registered with TL before this function can be called.
7701
7702 PARAMETERS
7703
7704 IN
7705 pvosGCtx: pointer to the global vos context; a handle to TL's
7706 control block can be extracted from its context
7707 ucSTAId: identifier of the station being processed
7708 vosDataBuff: pointer to the rx vos buffer
7709
7710 RETURN VALUE
7711 The result code associated with performing the operation
7712
7713 VOS_STATUS_E_INVAL: invalid input parameters
7714 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
7715 page fault
7716 VOS_STATUS_SUCCESS: Everything is good :)
7717
7718 SIDE EFFECTS
7719
7720============================================================================*/
7721VOS_STATUS
7722WLANTL_STARxAuth
7723(
7724 v_PVOID_t pvosGCtx,
7725 v_U8_t ucSTAId,
7726 vos_pkt_t** pvosDataBuff
7727)
7728{
7729 WLANTL_CbType* pTLCb = NULL;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307730 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07007731 v_U8_t ucAsf; /* AMSDU sub frame */
7732 v_U16_t usMPDUDOffset;
7733 v_U8_t ucMPDUHOffset;
7734 v_U16_t usMPDULen;
7735 v_U8_t ucMPDUHLen;
7736 v_U16_t usActualHLen = 0;
7737 v_U8_t ucTid;
7738#ifdef FEATURE_WLAN_WAPI
Jeff Johnsone0343db2013-04-03 16:39:24 -07007739 v_U16_t usEtherType = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07007740#endif
7741 v_U16_t usPktLen;
7742 vos_pkt_t* vosDataBuff ;
7743 v_PVOID_t aucBDHeader;
7744 VOS_STATUS vosStatus;
7745 WLANTL_RxMetaInfoType wRxMetaInfo;
Madan Mohan Koyyalamudidfd6aa82012-10-18 20:18:43 -07007746 static v_U8_t ucPMPDUHLen;
Gopichand Nakkala976e3252013-01-03 15:45:56 -08007747 v_U32_t* STAMetaInfoPtr;
Jeff Johnson295189b2012-06-20 16:38:30 -07007748 v_U8_t ucEsf=0; /* first subframe of AMSDU flag */
7749 v_U64_t ullcurrentReplayCounter=0; /*current replay counter*/
7750 v_U64_t ullpreviousReplayCounter=0; /*previous replay counter*/
7751 v_U16_t ucUnicastBroadcastType=0; /*It denotes whether received frame is UC or BC*/
Madan Mohan Koyyalamudi4fe30172012-10-18 20:13:40 -07007752 struct _BARFrmStruct *pBarFrame = NULL;
7753
Jeff Johnson295189b2012-06-20 16:38:30 -07007754 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
7755
7756 /*------------------------------------------------------------------------
7757 Sanity check
7758 ------------------------------------------------------------------------*/
7759 if (( NULL == pvosDataBuff ) || ( NULL == ( vosDataBuff = *pvosDataBuff )))
7760 {
7761 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7762 "WLAN TL:Invalid parameter sent on WLANTL_STARxAuth"));
7763 return VOS_STATUS_E_INVAL;
7764 }
7765
7766 /*------------------------------------------------------------------------
7767 Extract TL control block
7768 ------------------------------------------------------------------------*/
7769 pTLCb = VOS_GET_TL_CB(pvosGCtx);
7770 if ( NULL == pTLCb )
7771 {
7772 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7773 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_STARxAuth"));
7774 return VOS_STATUS_E_FAULT;
7775 }
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307776 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
7777
7778 if ( NULL == pClientSTA )
7779 {
7780 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7781 "WLAN TL:Client Memory was not allocated on %s", __func__));
7782 return VOS_STATUS_E_FAILURE;
7783 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007784
7785 /*------------------------------------------------------------------------
7786 Extract BD header and check if valid
7787 ------------------------------------------------------------------------*/
7788 WDA_DS_PeekRxPacketInfo( vosDataBuff, (v_PVOID_t)&aucBDHeader, 0 );
7789
7790 ucMPDUHOffset = (v_U8_t)WDA_GET_RX_MPDU_HEADER_OFFSET(aucBDHeader);
7791 usMPDUDOffset = (v_U16_t)WDA_GET_RX_MPDU_DATA_OFFSET(aucBDHeader);
7792 usMPDULen = (v_U16_t)WDA_GET_RX_MPDU_LEN(aucBDHeader);
7793 ucMPDUHLen = (v_U8_t)WDA_GET_RX_MPDU_HEADER_LEN(aucBDHeader);
7794 ucTid = (v_U8_t)WDA_GET_RX_TID(aucBDHeader);
7795
Madan Mohan Koyyalamudi4fe30172012-10-18 20:13:40 -07007796 /* Fix for a hardware bug.
7797 * H/W does not update the tid field in BD header for BAR frames.
7798 * Fix is to read the tid field from MAC header of BAR frame */
7799 if( (WDA_GET_RX_TYPE(aucBDHeader) == SIR_MAC_CTRL_FRAME) &&
7800 (WDA_GET_RX_SUBTYPE(aucBDHeader) == SIR_MAC_CTRL_BAR))
7801 {
7802 pBarFrame = (struct _BARFrmStruct *)(WDA_GET_RX_MAC_HEADER(aucBDHeader));
7803 ucTid = pBarFrame->barControl.numTID;
7804 }
7805
Jeff Johnson295189b2012-06-20 16:38:30 -07007806 /*Host based replay check is needed for unicast data frames*/
7807 ucUnicastBroadcastType = (v_U16_t)WDA_IS_RX_BCAST(aucBDHeader);
Jeff Johnson295189b2012-06-20 16:38:30 -07007808 if(0 != ucMPDUHLen)
7809 {
7810 ucPMPDUHLen = ucMPDUHLen;
7811 }
7812
7813 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
7814 "WLAN TL:BD header processing data: HO %d DO %d Len %d HLen %d"
7815 " Tid %d BD %d",
7816 ucMPDUHOffset, usMPDUDOffset, usMPDULen, ucMPDUHLen, ucTid,
7817 WLANHAL_RX_BD_HEADER_SIZE));
7818
7819 vos_pkt_get_packet_length( vosDataBuff, &usPktLen);
7820
7821 if ( VOS_STATUS_SUCCESS != WDA_DS_TrimRxPacketInfo( vosDataBuff ) )
7822 {
7823 if((WDA_GET_RX_ASF(aucBDHeader) && !WDA_GET_RX_ESF(aucBDHeader)))
7824 {
7825 /* AMSDU case, ucMPDUHOffset = 0
7826 * it should be hancdled seperatly */
7827 if(( usMPDUDOffset > ucMPDUHOffset ) &&
7828 ( usMPDULen >= ucMPDUHLen ) && ( usPktLen >= usMPDULen ) &&
7829 ( !WLANTL_TID_INVALID(ucTid) ))
7830 {
7831 ucMPDUHOffset = usMPDUDOffset - WLANTL_MPDU_HEADER_LEN;
7832 }
7833 else
7834 {
7835 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
7836 "WLAN TL:BD header corrupted - dropping packet"));
7837 /* Drop packet */
7838 vos_pkt_return_packet(vosDataBuff);
7839 return VOS_STATUS_SUCCESS;
7840 }
7841 }
7842 else
7843 {
7844 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
7845 "WLAN TL:BD header corrupted - dropping packet"));
7846 /* Drop packet */
7847 vos_pkt_return_packet(vosDataBuff);
7848 return VOS_STATUS_SUCCESS;
7849 }
7850 }
7851
7852#ifdef FEATURE_WLAN_WAPI
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307853 if ( pClientSTA->wSTADesc.ucIsWapiSta )
Jeff Johnson295189b2012-06-20 16:38:30 -07007854 {
7855 vosStatus = WLANTL_GetEtherType(aucBDHeader, vosDataBuff, ucMPDUHLen, &usEtherType);
7856 if( VOS_IS_STATUS_SUCCESS(vosStatus) )
7857 {
7858 if ( WLANTL_LLC_WAI_TYPE == usEtherType )
7859 {
7860 if ( !( WLANHAL_RX_IS_UNPROTECTED_WPI_FRAME(aucBDHeader)) )
7861 {
7862 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7863 "WLAN TL:WAI frame was received encrypted - dropping"));
7864 /* Drop packet */
7865 /*Temporary fix added to fix wapi rekey issue*/
7866 //vos_pkt_return_packet(vosDataBuff);
7867 //return vosStatus; //returning success
7868 }
7869 }
7870 else
7871 {
7872 if ( WLANHAL_RX_IS_UNPROTECTED_WPI_FRAME(aucBDHeader) )
7873 {
7874 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7875 "WLAN TL:Non-WAI frame was received unencrypted - dropping"));
7876 /* Drop packet */
7877 vos_pkt_return_packet(vosDataBuff);
7878 return vosStatus; //returning success
7879 }
7880 }
7881 }
7882 else //could not extract EtherType - this should not happen
7883 {
7884 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007885 "WLAN TL:Could not extract EtherType"));
7886 //Packet is already freed
Jeff Johnson295189b2012-06-20 16:38:30 -07007887 return vosStatus; //returning failure
Jeff Johnson295189b2012-06-20 16:38:30 -07007888 }
7889 }
7890#endif /* FEATURE_WLAN_WAPI */
7891
7892 /*----------------------------------------------------------------------
7893 Increment receive counter
7894 !! not sure this is the best place to increase this - pkt might be
7895 dropped below or delayed in TL's queues
7896 - will leave it here for now
7897 ------------------------------------------------------------------------*/
Madan Mohan Koyyalamudic0e5bd82012-09-18 17:12:27 -07007898 if ( !WLANTL_TID_INVALID( ucTid) )
7899 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307900 pClientSTA->auRxCount[ucTid]++;
Madan Mohan Koyyalamudic0e5bd82012-09-18 17:12:27 -07007901 }
7902 else
7903 {
7904 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7905 "WLAN TL:Invalid tid %d (Station ID %d) on %s",
7906 ucTid, ucSTAId, __func__));
7907 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007908
7909 /*------------------------------------------------------------------------
7910 Check if AMSDU and send for processing if so
7911 ------------------------------------------------------------------------*/
7912 ucAsf = (v_U8_t)WDA_GET_RX_ASF(aucBDHeader);
7913
7914 if ( 0 != ucAsf )
7915 {
7916 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
7917 "WLAN TL:Packet is AMSDU sub frame - sending for completion"));
7918 vosStatus = WLANTL_AMSDUProcess( pvosGCtx, &vosDataBuff, aucBDHeader, ucSTAId,
7919 ucMPDUHLen, usMPDULen );
7920 if(NULL == vosDataBuff)
7921 {
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007922 //Packet is already freed
Jeff Johnson295189b2012-06-20 16:38:30 -07007923 return VOS_STATUS_SUCCESS;
7924 }
7925 }
7926 /* After AMSDU header handled
7927 * AMSDU frame just same with normal frames */
7928 /*-------------------------------------------------------------------
7929 Translating header if necesary
7930 !! Fix me: rmv comments below
7931 ----------------------------------------------------------------------*/
7932 if (( 0 == WDA_GET_RX_FT_DONE(aucBDHeader) ) &&
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307933 ( 0 != pClientSTA->wSTADesc.ucSwFrameRXXlation) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07007934 ( WLANTL_IS_DATA_FRAME(WDA_GET_RX_TYPE_SUBTYPE(aucBDHeader)) ))
7935 {
7936 if(0 == ucMPDUHLen)
7937 {
7938 ucMPDUHLen = ucPMPDUHLen;
7939 }
7940 if (usMPDUDOffset > ucMPDUHOffset)
7941 {
7942 usActualHLen = usMPDUDOffset - ucMPDUHOffset;
7943 }
7944 vosStatus = WLANTL_Translate80211To8023Header( vosDataBuff, &vosStatus, usActualHLen,
7945 ucMPDUHLen, pTLCb, ucSTAId);
7946
7947 if ( VOS_STATUS_SUCCESS != vosStatus )
7948 {
7949 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7950 "WLAN TL:Failed to translate from 802.11 to 802.3 - dropping"));
7951 /* Drop packet */
7952 vos_pkt_return_packet(vosDataBuff);
7953 return vosStatus;
7954 }
7955 }
7956 /* Softap requires additional Info such as Destination STAID and Access
7957 Category. Voschain or Buffer returned by BA would be unchain and this
7958 Meta Data would help in routing the packets to appropriate Destination */
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307959 if( WLAN_STA_SOFTAP == pClientSTA->wSTADesc.wSTAType)
Jeff Johnson295189b2012-06-20 16:38:30 -07007960 {
Gopichand Nakkala976e3252013-01-03 15:45:56 -08007961 STAMetaInfoPtr = (v_U32_t *)(ucTid | (WDA_GET_RX_ADDR3_IDX(aucBDHeader) << WLANTL_STAID_OFFSET));
Jeff Johnson295189b2012-06-20 16:38:30 -07007962 vos_pkt_set_user_data_ptr( vosDataBuff, VOS_PKT_USER_DATA_ID_TL,
7963 (v_PVOID_t)STAMetaInfoPtr);
7964 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007965
7966 /*------------------------------------------------------------------------
7967 Check to see if re-ordering session is in place
7968 ------------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307969 if ( 0 != pClientSTA->atlBAReorderInfo[ucTid].ucExists )
Jeff Johnson295189b2012-06-20 16:38:30 -07007970 {
7971 WLANTL_MSDUReorder( pTLCb, &vosDataBuff, aucBDHeader, ucSTAId, ucTid );
7972 }
7973
Jeff Johnson295189b2012-06-20 16:38:30 -07007974if(0 == ucUnicastBroadcastType
7975#ifdef FEATURE_ON_CHIP_REORDERING
7976 && (WLANHAL_IsOnChipReorderingEnabledForTID(pvosGCtx, ucSTAId, ucTid) != TRUE)
7977#endif
7978)
7979{
7980 /* replay check code : check whether replay check is needed or not */
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307981 if(VOS_TRUE == pClientSTA->ucIsReplayCheckValid)
Jeff Johnson295189b2012-06-20 16:38:30 -07007982 {
7983 /* replay check is needed for the station */
7984
7985 /* check whether frame is AMSDU frame */
7986 if ( 0 != ucAsf )
7987 {
7988 /* Since virgo can't send AMSDU frames this leg of the code
7989 was not tested properly, it needs to be tested properly*/
7990 /* Frame is AMSDU frame. As per 802.11n only first
7991 subframe will have replay counter */
7992 ucEsf = WDA_GET_RX_ESF( aucBDHeader );
7993 if( 0 != ucEsf )
7994 {
7995 v_BOOL_t status;
7996 /* Getting 48-bit replay counter from the RX BD */
7997 ullcurrentReplayCounter = WDA_DS_GetReplayCounter(aucBDHeader);
7998
7999 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
8000 "WLAN TL: AMSDU currentReplayCounter [0x%llX]\n",ullcurrentReplayCounter);
8001
8002 /* Getting 48-bit previous replay counter from TL control block */
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308003 ullpreviousReplayCounter = pClientSTA->ullReplayCounter[ucTid];
Jeff Johnson295189b2012-06-20 16:38:30 -07008004
8005 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
8006 "WLAN TL: AMSDU previousReplayCounter [0x%llX]\n",ullpreviousReplayCounter);
8007
8008 /* It is first subframe of AMSDU thus it
8009 conatains replay counter perform the
8010 replay check for this first subframe*/
8011 status = WLANTL_IsReplayPacket( ullcurrentReplayCounter, ullpreviousReplayCounter);
8012 if(VOS_FALSE == status)
8013 {
8014 /* Not a replay paket, update previous replay counter in TL CB */
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308015 pClientSTA->ullReplayCounter[ucTid] = ullcurrentReplayCounter;
Jeff Johnson295189b2012-06-20 16:38:30 -07008016 }
8017 else
8018 {
8019 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8020 "WLAN TL: AMSDU Drop the replay packet with PN : [0x%llX]\n",ullcurrentReplayCounter);
8021
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308022 pClientSTA->ulTotalReplayPacketsDetected++;
Jeff Johnson295189b2012-06-20 16:38:30 -07008023 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8024 "WLAN TL: AMSDU total dropped replay packets on STA ID %X is [0x%lX]\n",
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308025 ucSTAId, pClientSTA->ulTotalReplayPacketsDetected);
Jeff Johnson295189b2012-06-20 16:38:30 -07008026
8027 /* Drop the packet */
8028 vos_pkt_return_packet(vosDataBuff);
8029 return VOS_STATUS_SUCCESS;
8030 }
8031 }
8032 }
8033 else
8034 {
8035 v_BOOL_t status;
8036
8037 /* Getting 48-bit replay counter from the RX BD */
8038 ullcurrentReplayCounter = WDA_DS_GetReplayCounter(aucBDHeader);
8039
8040 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
8041 "WLAN TL: Non-AMSDU currentReplayCounter [0x%llX]\n",ullcurrentReplayCounter);
8042
8043 /* Getting 48-bit previous replay counter from TL control block */
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308044 ullpreviousReplayCounter = pClientSTA->ullReplayCounter[ucTid];
Jeff Johnson295189b2012-06-20 16:38:30 -07008045
8046 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
8047 "WLAN TL: Non-AMSDU previousReplayCounter [0x%llX]\n",ullpreviousReplayCounter);
8048
8049 /* It is not AMSDU frame so perform
8050 reaply check for each packet, as
8051 each packet contains valid replay counter*/
8052 status = WLANTL_IsReplayPacket( ullcurrentReplayCounter, ullpreviousReplayCounter);
8053 if(VOS_FALSE == status)
8054 {
8055 /* Not a replay paket, update previous replay counter in TL CB */
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308056 pClientSTA->ullReplayCounter[ucTid] = ullcurrentReplayCounter;
Jeff Johnson295189b2012-06-20 16:38:30 -07008057 }
8058 else
8059 {
8060 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8061 "WLAN TL: Non-AMSDU Drop the replay packet with PN : [0x%llX]\n",ullcurrentReplayCounter);
8062
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308063 pClientSTA->ulTotalReplayPacketsDetected++;
Jeff Johnson295189b2012-06-20 16:38:30 -07008064 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8065 "WLAN TL: Non-AMSDU total dropped replay packets on STA ID %X is [0x%lX]\n",
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308066 ucSTAId, pClientSTA->ulTotalReplayPacketsDetected);
Jeff Johnson295189b2012-06-20 16:38:30 -07008067
8068 /* Repaly packet, drop the packet */
8069 vos_pkt_return_packet(vosDataBuff);
8070 return VOS_STATUS_SUCCESS;
8071 }
8072 }
8073 }
8074}
8075/*It is a broadast packet DPU has already done replay check for
8076 broadcast packets no need to do replay check of these packets*/
Jeff Johnson295189b2012-06-20 16:38:30 -07008077
8078 if ( NULL != vosDataBuff )
8079 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308080 if( WLAN_STA_SOFTAP == pClientSTA->wSTADesc.wSTAType)
Jeff Johnson295189b2012-06-20 16:38:30 -07008081 {
8082 WLANTL_FwdPktToHDD( pvosGCtx, vosDataBuff, ucSTAId );
8083 }
8084 else
Jeff Johnson295189b2012-06-20 16:38:30 -07008085 {
8086 wRxMetaInfo.ucUP = ucTid;
Shailender Karmuchi13c0d082013-03-26 14:41:39 -07008087 wRxMetaInfo.rssiAvg = pClientSTA->rssiAvg;
Gopichand Nakkala4a2fc1a2013-05-17 16:59:39 +05308088#ifdef FEATURE_WLAN_TDLS
8089 if (WLAN_STA_TDLS == pClientSTA->wSTADesc.wSTAType)
8090 {
8091 wRxMetaInfo.isStaTdls = TRUE;
8092 }
8093 else
8094 {
8095 wRxMetaInfo.isStaTdls = FALSE;
8096 }
8097#endif
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308098 pClientSTA->pfnSTARx( pvosGCtx, vosDataBuff, ucSTAId,
Jeff Johnson295189b2012-06-20 16:38:30 -07008099 &wRxMetaInfo );
8100 }
8101 }/* if not NULL */
8102
8103 return VOS_STATUS_SUCCESS;
8104}/* WLANTL_STARxAuth */
8105
8106
8107/*==========================================================================
8108 FUNCTION WLANTL_STARxDisc
8109
8110 DESCRIPTION
8111 Receive in disconnected state - no data allowed
8112
8113 DEPENDENCIES
8114 The STA must be registered with TL before this function can be called.
8115
8116 PARAMETERS
8117
8118 IN
8119 pvosGCtx: pointer to the global vos context; a handle to TL's
8120 control block can be extracted from its context
8121 ucSTAId: identifier of the station being processed
8122 vosDataBuff: pointer to the rx vos buffer
8123
8124 RETURN VALUE
8125 The result code associated with performing the operation
8126
8127 VOS_STATUS_SUCCESS: Everything is good :)
8128
8129 SIDE EFFECTS
8130
8131============================================================================*/
8132VOS_STATUS
8133WLANTL_STARxDisc
8134(
8135 v_PVOID_t pvosGCtx,
8136 v_U8_t ucSTAId,
8137 vos_pkt_t** pvosDataBuff
8138)
8139{
8140 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
8141
8142 /*------------------------------------------------------------------------
8143 Sanity check
8144 ------------------------------------------------------------------------*/
8145 if (( NULL == pvosDataBuff ) || ( NULL == *pvosDataBuff ))
8146 {
8147 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8148 "WLAN TL:Invalid parameter sent on WLANTL_STARxDisc"));
8149 return VOS_STATUS_E_INVAL;
8150 }
8151
8152 /*------------------------------------------------------------------------
8153 Error - drop packet
8154 ------------------------------------------------------------------------*/
8155 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8156 "WLAN TL:Packet should not be received in state disconnected"
8157 " - dropping"));
8158 vos_pkt_return_packet(*pvosDataBuff);
8159 *pvosDataBuff = NULL;
8160
8161 return VOS_STATUS_SUCCESS;
8162}/* WLANTL_STARxDisc */
8163
8164/*==========================================================================
8165 Processing main loops for MAIN and TX threads
8166 ==========================================================================*/
8167
8168/*==========================================================================
8169 FUNCTION WLANTL_McProcessMsg
8170
8171 DESCRIPTION
8172 Called by VOSS when a message was serialized for TL through the
8173 main thread/task.
8174
8175 DEPENDENCIES
8176 The TL must be initialized before this function can be called.
8177
8178 PARAMETERS
8179
8180 IN
8181 pvosGCtx: pointer to the global vos context; a handle to TL's
8182 control block can be extracted from its context
8183 message: type and content of the message
8184
8185
8186 RETURN VALUE
8187 The result code associated with performing the operation
8188
8189 VOS_STATUS_E_INVAL: invalid input parameters
8190 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
8191 page fault
8192 VOS_STATUS_SUCCESS: Everything is good :)
8193
8194 SIDE EFFECTS
8195
8196============================================================================*/
8197VOS_STATUS
8198WLANTL_McProcessMsg
8199(
8200 v_PVOID_t pvosGCtx,
8201 vos_msg_t* message
8202)
8203{
8204 WLANTL_CbType* pTLCb = NULL;
8205 tAddBAInd* ptAddBaInd = NULL;
8206 tDelBAInd* ptDelBaInd = NULL;
8207 tAddBARsp* ptAddBaRsp = NULL;
8208 vos_msg_t vosMessage;
8209 VOS_STATUS vosStatus;
8210 tpFlushACRsp FlushACRspPtr;
8211 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
8212
8213 /*------------------------------------------------------------------------
8214 Sanity check
8215 ------------------------------------------------------------------------*/
8216 if ( NULL == message )
8217 {
8218 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8219 "WLAN TL:Invalid parameter sent on WLANTL_ProcessMainMessage"));
8220 return VOS_STATUS_E_INVAL;
8221 }
8222
8223 /*------------------------------------------------------------------------
8224 Extract TL control block
8225 ------------------------------------------------------------------------*/
8226 pTLCb = VOS_GET_TL_CB(pvosGCtx);
8227 if ( NULL == pTLCb )
8228 {
8229 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8230 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_ProcessMainMessage"));
8231 return VOS_STATUS_E_FAULT;
8232 }
8233
8234 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
8235 "WLAN TL:Received message: %d through main flow", message->type));
8236
8237 switch( message->type )
8238 {
8239 case WDA_TL_FLUSH_AC_RSP:
8240 // Extract the message from the message body
8241 FlushACRspPtr = (tpFlushACRsp)(message->bodyptr);
8242 // Make sure the call back function is not null.
Tushnim Bhattacharyya5dd94562013-03-20 20:15:03 -07008243 if ( NULL == pTLCb->tlBAPClient.pfnFlushOpCompleteCb )
8244 {
8245 VOS_ASSERT(0);
8246 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8247 "WLAN TL:Invalid TL pointer pfnFlushOpCompleteCb"));
8248 return VOS_STATUS_E_FAULT;
8249 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008250
8251 TLLOG2(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
8252 "Received message: Flush complete received by TL"));
8253
8254 // Since we have the response back from HAL, just call the BAP client
8255 // registered call back from TL. There is only 1 possible
8256 // BAP client. So directly reference tlBAPClient
8257 pTLCb->tlBAPClient.pfnFlushOpCompleteCb( pvosGCtx,
8258 FlushACRspPtr->ucSTAId,
8259 FlushACRspPtr->ucTid, FlushACRspPtr->status );
8260
8261 // Free the PAL memory, we are done with it.
8262 TLLOG2(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
8263 "Flush complete received by TL: Freeing %p", FlushACRspPtr));
8264 vos_mem_free((v_VOID_t *)FlushACRspPtr);
8265 break;
8266
8267 case WDA_HDD_ADDBA_REQ:
8268 ptAddBaInd = (tAddBAInd*)(message->bodyptr);
8269 vosStatus = WLANTL_BaSessionAdd( pvosGCtx,
8270 ptAddBaInd->baSession.baSessionID,
8271 ptAddBaInd->baSession.STAID,
8272 ptAddBaInd->baSession.baTID,
8273 (v_U32_t)ptAddBaInd->baSession.baBufferSize,
8274 ptAddBaInd->baSession.winSize,
8275 ptAddBaInd->baSession.SSN);
8276 ptAddBaRsp = vos_mem_malloc(sizeof(*ptAddBaRsp));
8277
8278 if ( NULL == ptAddBaRsp )
8279 {
8280 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8281 "WLAN TL: fatal failure, cannot allocate BA Rsp structure"));
8282 VOS_ASSERT(0);
8283 return VOS_STATUS_E_NOMEM;
8284 }
8285
8286 if ( VOS_STATUS_SUCCESS == vosStatus )
8287 {
8288 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
8289 "WLAN TL: Sending success indication to HAL for ADD BA"));
8290 /*Send success*/
8291 ptAddBaRsp->mesgType = WDA_HDD_ADDBA_RSP;
8292 vosMessage.type = WDA_HDD_ADDBA_RSP;
8293 }
8294 else
8295 {
8296 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
8297 "WLAN TL: Sending failure indication to HAL for ADD BA"));
8298
8299 /*Send failure*/
8300 ptAddBaRsp->mesgType = WDA_BA_FAIL_IND;
8301 vosMessage.type = WDA_BA_FAIL_IND;
8302 }
8303
8304 ptAddBaRsp->mesgLen = sizeof(tAddBARsp);
8305 ptAddBaRsp->baSessionID = ptAddBaInd->baSession.baSessionID;
8306 /* This is default, reply win size has to be handled BA module, FIX THIS */
8307 ptAddBaRsp->replyWinSize = WLANTL_MAX_WINSIZE;
8308 vosMessage.bodyptr = ptAddBaRsp;
8309
8310 vos_mq_post_message( VOS_MQ_ID_WDA, &vosMessage );
8311 WLANTL_McFreeMsg (pvosGCtx, message);
8312 break;
8313 case WDA_DELETEBA_IND:
8314 ptDelBaInd = (tDelBAInd*)(message->bodyptr);
8315 vosStatus = WLANTL_BaSessionDel(pvosGCtx,
8316 ptDelBaInd->staIdx,
8317 ptDelBaInd->baTID);
8318
8319 if ( VOS_STATUS_SUCCESS != vosStatus )
8320 {
8321 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8322 "WLAN TL: Failed to del BA session STA:%d TID:%d Status :%d",
8323 ptDelBaInd->staIdx,
8324 ptDelBaInd->baTID,
8325 vosStatus));
8326 }
8327 WLANTL_McFreeMsg (pvosGCtx, message);
8328 break;
8329 default:
8330 /*no processing for now*/
8331 break;
8332 }
8333
8334 return VOS_STATUS_SUCCESS;
8335}/* WLANTL_ProcessMainMessage */
8336
8337/*==========================================================================
8338 FUNCTION WLANTL_McFreeMsg
8339
8340 DESCRIPTION
8341 Called by VOSS to free a given TL message on the Main thread when there
8342 are messages pending in the queue when the whole system is been reset.
8343 For now, TL does not allocate any body so this function shout translate
8344 into a NOOP
8345
8346 DEPENDENCIES
8347 The TL must be initialized before this function can be called.
8348
8349 PARAMETERS
8350
8351 IN
8352 pvosGCtx: pointer to the global vos context; a handle to TL's
8353 control block can be extracted from its context
8354 message: type and content of the message
8355
8356
8357 RETURN VALUE
8358 The result code associated with performing the operation
8359
8360 VOS_STATUS_SUCCESS: Everything is good :)
8361
8362 SIDE EFFECTS
8363
8364============================================================================*/
8365VOS_STATUS
8366WLANTL_McFreeMsg
8367(
8368 v_PVOID_t pvosGCtx,
8369 vos_msg_t* message
8370)
8371{
8372 WLANTL_CbType* pTLCb = NULL;
8373 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
8374
8375 /*------------------------------------------------------------------------
8376 Sanity check
8377 ------------------------------------------------------------------------*/
8378 if ( NULL == message )
8379 {
8380 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8381 "WLAN TL:Invalid parameter sent on WLANTL_McFreeMsg"));
8382 return VOS_STATUS_E_INVAL;
8383 }
8384
8385 /*------------------------------------------------------------------------
8386 Extract TL control block
8387 ------------------------------------------------------------------------*/
8388 pTLCb = VOS_GET_TL_CB(pvosGCtx);
8389 if ( NULL == pTLCb )
8390 {
8391 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8392 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_McFreeMsg"));
8393 return VOS_STATUS_E_FAULT;
8394 }
8395
8396 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
8397 "WLAN TL:Received message: %d through main free", message->type));
8398
8399 switch( message->type )
8400 {
8401 case WDA_HDD_ADDBA_REQ:
8402 case WDA_DELETEBA_IND:
8403 /*vos free body pointer*/
8404 vos_mem_free(message->bodyptr);
8405 message->bodyptr = NULL;
8406 break;
8407 default:
8408 /*no processing for now*/
8409 break;
8410 }
8411
8412 return VOS_STATUS_SUCCESS;
8413}/*WLANTL_McFreeMsg*/
8414
8415/*==========================================================================
8416 FUNCTION WLANTL_TxProcessMsg
8417
8418 DESCRIPTION
8419 Called by VOSS when a message was serialized for TL through the
8420 tx thread/task.
8421
8422 DEPENDENCIES
8423 The TL must be initialized before this function can be called.
8424
8425 PARAMETERS
8426
8427 IN
8428 pvosGCtx: pointer to the global vos context; a handle to TL's
8429 control block can be extracted from its context
8430 message: type and content of the message
8431
8432
8433 RETURN VALUE
8434 The result code associated with performing the operation
8435
8436 VOS_STATUS_E_INVAL: invalid input parameters
8437 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
8438 page fault
8439 VOS_STATUS_SUCCESS: Everything is good :)
8440
8441 Other values can be returned as a result of a function call, please check
8442 corresponding API for more info.
8443 SIDE EFFECTS
8444
8445============================================================================*/
8446VOS_STATUS
8447WLANTL_TxProcessMsg
8448(
8449 v_PVOID_t pvosGCtx,
8450 vos_msg_t* message
8451)
8452{
8453 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
8454 v_U32_t uData;
8455 v_U8_t ucSTAId;
8456 v_U8_t ucUcastSig;
8457 v_U8_t ucBcastSig;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308458 WLANTL_CbType* pTLCb = NULL;
8459 WLANTL_STAClientType* pClientSTA = NULL;
8460 WLANTL_ACEnumType ucAC;
Jeff Johnson295189b2012-06-20 16:38:30 -07008461 void (*callbackRoutine) (void *callbackContext);
8462 void *callbackContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07008463 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
8464
8465 /*------------------------------------------------------------------------
8466 Sanity check
8467 ------------------------------------------------------------------------*/
8468 if ( NULL == message )
8469 {
8470 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8471 "WLAN TL:Invalid parameter sent on WLANTL_ProcessTxMessage"));
8472 return VOS_STATUS_E_INVAL;
8473 }
8474
8475 /*------------------------------------------------------------------------
8476 Process message
8477 ------------------------------------------------------------------------*/
8478 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
8479 "WLAN TL:Received message: %d through tx flow", message->type));
8480
8481 switch( message->type )
8482 {
8483 case WLANTL_TX_SIG_SUSPEND:
8484 vosStatus = WLANTL_SuspendCB( pvosGCtx,
8485 (WLANTL_SuspendCBType)message->bodyptr,
8486 message->reserved);
8487 break;
8488 case WLANTL_TX_RES_NEEDED:
8489 vosStatus = WLANTL_GetTxResourcesCB( pvosGCtx );
8490 break;
8491
8492 case WLANTL_TX_FWD_CACHED:
8493 /*---------------------------------------------------------------------
8494 The data sent with the message has the following structure:
8495 | 00 | ucBcastSignature | ucUcastSignature | ucSTAID |
8496 each field above is one byte
8497 ---------------------------------------------------------------------*/
8498 uData = (v_U32_t)message->bodyptr;
8499 ucSTAId = ( uData & 0x000000FF);
8500 ucUcastSig = ( uData & 0x0000FF00)>>8;
8501 ucBcastSig = (v_U8_t)(( uData & 0x00FF0000)>>16);
8502 vosStatus = WLANTL_ForwardSTAFrames( pvosGCtx, ucSTAId,
8503 ucUcastSig, ucBcastSig);
8504 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008505 case WLANTL_TX_STAID_AC_IND:
8506 pTLCb = VOS_GET_TL_CB(pvosGCtx);
8507 if ( NULL == pTLCb )
8508 {
8509 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8510 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_STAPktPending"));
8511 return VOS_STATUS_E_FAULT;
8512 }
8513
8514 ucAC = message->bodyval & WLANTL_AC_MASK;
Gopichand Nakkala976e3252013-01-03 15:45:56 -08008515 ucSTAId = (v_U8_t)(message->bodyval >> WLANTL_STAID_OFFSET);
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308516 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
Jeff Johnson295189b2012-06-20 16:38:30 -07008517
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308518 if ( NULL == pClientSTA )
8519 {
8520 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8521 "WLAN TL:Client Memory was not allocated on %s", __func__));
8522 return VOS_STATUS_E_FAILURE;
8523 }
8524
8525 pClientSTA->aucACMask[ucAC] = 1;
8526
8527 vos_atomic_set_U8( &pClientSTA->ucPktPending, 1);
Jeff Johnson295189b2012-06-20 16:38:30 -07008528 vosStatus = WDA_DS_StartXmit(pvosGCtx);
8529 break;
Jeff Johnson017fdc32013-02-27 09:22:30 -08008530
Jeff Johnson295189b2012-06-20 16:38:30 -07008531 case WDA_DS_TX_START_XMIT:
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05308532 WLANTL_ClearTxXmitPending(pvosGCtx);
8533 vosStatus = WDA_DS_TxFrames( pvosGCtx );
Jeff Johnson295189b2012-06-20 16:38:30 -07008534 break;
8535
8536 case WDA_DS_FINISH_ULA:
Tushnim Bhattacharyya39a8f182013-02-20 18:10:30 -08008537 callbackContext = (void *)message->bodyval;
8538 callbackRoutine = message->bodyptr;
8539 callbackRoutine(callbackContext);
Jeff Johnson295189b2012-06-20 16:38:30 -07008540 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008541
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05308542 case WLANTL_TX_SNAPSHOT:
8543 /*Dumping TL State and then continuing to print
8544 the DXE Dump*/
8545 WLANTL_TxThreadDebugHandler(pvosGCtx);
8546 WDA_TransportChannelDebug(NULL, VOS_TRUE, VOS_FALSE);
8547 break;
8548
Jeff Johnson295189b2012-06-20 16:38:30 -07008549 default:
8550 /*no processing for now*/
8551 break;
8552 }
8553
8554 return vosStatus;
8555}/* WLANTL_TxProcessMsg */
8556
8557/*==========================================================================
8558 FUNCTION WLANTL_McFreeMsg
8559
8560 DESCRIPTION
8561 Called by VOSS to free a given TL message on the Main thread when there
8562 are messages pending in the queue when the whole system is been reset.
8563 For now, TL does not allocate any body so this function shout translate
8564 into a NOOP
8565
8566 DEPENDENCIES
8567 The TL must be initialized before this function can be called.
8568
8569 PARAMETERS
8570
8571 IN
8572 pvosGCtx: pointer to the global vos context; a handle to TL's
8573 control block can be extracted from its context
8574 message: type and content of the message
8575
8576
8577 RETURN VALUE
8578 The result code associated with performing the operation
8579
8580 VOS_STATUS_SUCCESS: Everything is good :)
8581
8582 SIDE EFFECTS
8583
8584============================================================================*/
8585VOS_STATUS
8586WLANTL_TxFreeMsg
8587(
8588 v_PVOID_t pvosGCtx,
8589 vos_msg_t* message
8590)
8591{
8592 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
8593
8594 /*Nothing to do for now!!!*/
8595 return VOS_STATUS_SUCCESS;
8596}/*WLANTL_TxFreeMsg*/
8597
Jeff Johnson295189b2012-06-20 16:38:30 -07008598/*==========================================================================
8599
8600 FUNCTION WLANTL_TxFCFrame
8601
8602 DESCRIPTION
8603 Internal utility function to send FC frame. Enable
8604 or disable LWM mode based on the information.
8605
8606 DEPENDENCIES
8607 TL must be initiailized before this function gets called.
8608 FW sends up special flow control frame.
8609
8610 PARAMETERS
8611
8612 IN
8613 pvosGCtx: pointer to the global vos context; a handle to TL's
8614 control block can be extracted from its context
8615
8616 RETURN VALUE
8617 The result code associated with performing the operation
8618
8619 VOS_STATUS_E_INVAL: Input pointers are NULL.
8620 VOS_STATUS_E_FAULT: Something is wrong.
8621 VOS_STATUS_SUCCESS: Everything is good.
8622
8623 SIDE EFFECTS
8624 Newly formed FC frame is generated and waits to be transmitted. Previously unsent frame will
8625 be released.
8626
8627============================================================================*/
8628VOS_STATUS
8629WLANTL_TxFCFrame
8630(
8631 v_PVOID_t pvosGCtx
8632)
8633{
8634#if 0
8635 WLANTL_CbType* pTLCb = NULL;
8636 VOS_STATUS vosStatus;
8637 tpHalFcTxBd pvFcTxBd = NULL;
8638 vos_pkt_t * pPacket = NULL;
8639 v_U8_t ucSTAId = 0;
8640 v_U8_t ucBitCheck = 1;
8641
8642 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008643 "WLAN TL: Send FC frame %s", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07008644
8645 /*------------------------------------------------------------------------
8646 Sanity check
8647 ------------------------------------------------------------------------*/
8648 if ( NULL == pvosGCtx )
8649 {
8650 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008651 "WLAN TL:Invalid parameter %s", __func__));
Jeff Johnson295189b2012-06-20 16:38:30 -07008652 return VOS_STATUS_E_INVAL;
8653 }
8654 /*------------------------------------------------------------------------
8655 Extract TL control block
8656 ------------------------------------------------------------------------*/
8657 pTLCb = VOS_GET_TL_CB(pvosGCtx);
8658
8659 if (NULL == pTLCb)
8660 {
8661 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008662 "WLAN TL:Invalid pointer in %s \n", __func__));
Jeff Johnson295189b2012-06-20 16:38:30 -07008663 return VOS_STATUS_E_INVAL;
8664 }
8665
8666 //Get one voss packet
8667 vosStatus = vos_pkt_get_packet( &pPacket, VOS_PKT_TYPE_TX_802_11_MGMT, sizeof(tHalFcTxBd), 1,
8668 VOS_FALSE, NULL, NULL );
8669
8670 if ( VOS_STATUS_SUCCESS != vosStatus )
8671 {
8672 return VOS_STATUS_E_INVAL;
8673 }
8674
8675 vosStatus = vos_pkt_reserve_head( pPacket, (void *)&pvFcTxBd, sizeof(tHalFcTxBd));
8676
8677 if( VOS_STATUS_SUCCESS != vosStatus )
8678 {
8679 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008680 "%s: failed to reserve FC TX BD %d\n",__func__, sizeof(tHalFcTxBd)));
Jeff Johnson295189b2012-06-20 16:38:30 -07008681 vos_pkt_return_packet( pPacket );
8682 return VOS_STATUS_E_FAULT;
8683 }
8684
8685 //Generate most recent tlFCInfo. Most fields are correct.
8686 pTLCb->tlFCInfo.fcSTAThreshEnabledMask = 0;
8687 pTLCb->tlFCInfo.fcSTATxMoreDataMask = 0;
8688 for( ucSTAId = 0, ucBitCheck = 1 ; ucSTAId < WLAN_MAX_STA_COUNT; ucBitCheck <<= 1, ucSTAId ++)
8689 {
8690 if (0 == pTLCb->atlSTAClients[ucSTAId].ucExists)
8691 {
8692 continue;
8693 }
8694
8695 if (pTLCb->atlSTAClients[ucSTAId].ucPktPending)
8696 {
8697 pTLCb->tlFCInfo.fcSTATxMoreDataMask |= ucBitCheck;
8698 }
8699
8700 if ( (pTLCb->atlSTAClients[ucSTAId].ucLwmModeEnabled) &&
8701 (pTLCb->atlSTAClients[ucSTAId].bmuMemConsumed > pTLCb->atlSTAClients[ucSTAId].uLwmThreshold))
8702 {
8703 pTLCb->tlFCInfo.fcSTAThreshEnabledMask |= ucBitCheck;
8704
8705 pTLCb->tlFCInfo.fcSTAThresh[ucSTAId] = (tANI_U8)pTLCb->atlSTAClients[ucSTAId].uLwmThreshold;
8706
8707 pTLCb->atlSTAClients[ucSTAId].ucLwmEventReported = FALSE;
8708 }
8709
8710 }
8711
8712 //request immediate feedback
8713 pTLCb->tlFCInfo.fcConfig |= 0x4;
8714
8715 //fill in BD to sent
8716 vosStatus = WLANHAL_FillFcTxBd(pvosGCtx, &pTLCb->tlFCInfo, (void *)pvFcTxBd);
8717
8718 if( VOS_STATUS_SUCCESS != vosStatus )
8719 {
8720 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008721 "%s: Fill FC TX BD unsuccessful\n", __func__));
Jeff Johnson295189b2012-06-20 16:38:30 -07008722 vos_pkt_return_packet( pPacket );
8723 return VOS_STATUS_E_FAULT;
8724 }
8725
8726 if (NULL != pTLCb->vosTxFCBuf)
8727 {
8728 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008729 "%s: Previous FC TX BD not sent\n", __func__));
Jeff Johnson295189b2012-06-20 16:38:30 -07008730 vos_pkt_return_packet(pTLCb->vosTxFCBuf);
8731 }
8732
8733 pTLCb->vosTxFCBuf = pPacket;
8734
8735 vos_pkt_set_user_data_ptr( pPacket, VOS_PKT_USER_DATA_ID_TL,
8736 (v_PVOID_t)WLANTL_TxCompDefaultCb);
8737 vosStatus = WDA_DS_StartXmit(pvosGCtx);
8738
8739 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008740 "WLAN TL: send FC frame leave %s", __func__));
Jeff Johnson295189b2012-06-20 16:38:30 -07008741#endif
8742 return VOS_STATUS_SUCCESS;
8743}
8744
Jeff Johnson295189b2012-06-20 16:38:30 -07008745
8746/*==========================================================================
8747 FUNCTION WLANTL_GetTxResourcesCB
8748
8749 DESCRIPTION
8750 Processing function for Resource needed signal. A request will be issued
8751 to BAL to get more tx resources.
8752
8753 DEPENDENCIES
8754 The TL must be initialized before this function can be called.
8755
8756 PARAMETERS
8757
8758 IN
8759 pvosGCtx: pointer to the global vos context; a handle to TL's
8760 control block can be extracted from its context
8761
8762
8763 RETURN VALUE
8764 The result code associated with performing the operation
8765
8766 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
8767 page fault
8768 VOS_STATUS_SUCCESS: Everything is good :)
8769
8770 Other values can be returned as a result of a function call, please check
8771 corresponding API for more info.
8772 SIDE EFFECTS
8773
8774============================================================================*/
8775VOS_STATUS
8776WLANTL_GetTxResourcesCB
8777(
8778 v_PVOID_t pvosGCtx
8779)
8780{
8781 WLANTL_CbType* pTLCb = NULL;
8782 v_U32_t uResCount = WDA_TLI_MIN_RES_DATA;
8783 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
8784 v_U8_t ucMgmt = 0;
8785 v_U8_t ucBAP = 0;
8786 v_U8_t ucData = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07008787#ifdef WLAN_SOFTAP_FLOWCTRL_EN
8788 tBssSystemRole systemRole;
8789 tpAniSirGlobal pMac;
8790#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07008791 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
8792 /*------------------------------------------------------------------------
8793 Extract TL control block
8794 ------------------------------------------------------------------------*/
8795 pTLCb = VOS_GET_TL_CB(pvosGCtx);
8796 if ( NULL == pTLCb )
8797 {
8798 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8799 "WLAN TL:Invalid TL pointer from pvosGCtx on"
8800 " WLANTL_ProcessTxMessage"));
8801 return VOS_STATUS_E_FAULT;
8802 }
8803
8804 /*------------------------------------------------------------------------
8805 Get tx resources from BAL
8806 ------------------------------------------------------------------------*/
8807 vosStatus = WDA_DS_GetTxResources( pvosGCtx, &uResCount );
8808
8809 if ( (VOS_STATUS_SUCCESS != vosStatus) && (VOS_STATUS_E_RESOURCES != vosStatus))
8810 {
8811 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8812 "WLAN TL:TL failed to get resources from BAL, Err: %d",
8813 vosStatus));
8814 return vosStatus;
8815 }
8816
8817 /* Currently only Linux BAL returns the E_RESOURCES error code when it is running
8818 out of BD/PDUs. To make use of this interrupt for throughput enhancement, similar
8819 changes should be done in BAL code of AMSS and WM */
8820 if (VOS_STATUS_E_RESOURCES == vosStatus)
8821 {
8822#ifdef VOLANS_PERF
8823 WLANHAL_EnableIdleBdPduInterrupt(pvosGCtx, (tANI_U8)bdPduInterruptGetThreshold);
8824 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
8825 "WLAN TL: Enabling Idle BD/PDU interrupt, Current resources = %d", uResCount);
8826#else
8827 return VOS_STATUS_E_FAILURE;
8828#endif
8829 }
8830
8831 pTLCb->uResCount = uResCount;
8832
8833
Jeff Johnson295189b2012-06-20 16:38:30 -07008834#ifdef WLAN_SOFTAP_FLOWCTRL_EN
8835 /* FIXME: disabled since creating issues in power-save, needs to be addressed */
8836 pTLCb->sendFCFrame ++;
8837 pMac = vos_get_context(VOS_MODULE_ID_WDA, pvosGCtx);
8838 systemRole = wdaGetGlobalSystemRole(pMac);
8839 if (eSYSTEM_AP_ROLE == systemRole)
8840 {
8841 if (pTLCb->sendFCFrame % 16 == 0)
8842 {
8843 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
8844 "Transmit FC"));
8845 WLANTL_TxFCFrame (pvosGCtx);
8846 }
8847 }
8848#endif //WLAN_SOFTAP_FLOWCTRL_EN
Jeff Johnson295189b2012-06-20 16:38:30 -07008849
8850 ucData = ( pTLCb->uResCount >= WDA_TLI_MIN_RES_DATA );
8851 ucBAP = ( pTLCb->uResCount >= WDA_TLI_MIN_RES_BAP ) &&
8852 ( NULL != pTLCb->tlBAPClient.vosPendingDataBuff );
8853 ucMgmt = ( pTLCb->uResCount >= WDA_TLI_MIN_RES_MF ) &&
8854 ( NULL != pTLCb->tlMgmtFrmClient.vosPendingDataBuff );
8855
8856 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
8857 "WLAN TL: Eval Resume tx Res: %d DATA: %d BAP: %d MGMT: %d",
8858 pTLCb->uResCount, ucData, ucBAP, ucMgmt));
8859
8860 if (( 0 == pTLCb->ucTxSuspended ) &&
8861 (( 0 != ucData ) || ( 0 != ucMgmt ) || ( 0 != ucBAP ) ) )
8862 {
8863 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
8864 "Issuing Xmit start request to BAL for avail res SYNC"));
8865 vosStatus =WDA_DS_StartXmit(pvosGCtx);
8866 }
8867 return vosStatus;
8868}/*WLANTL_GetTxResourcesCB*/
8869
8870/*==========================================================================
8871 Utility functions
8872 ==========================================================================*/
8873
8874/*==========================================================================
8875 FUNCTION WLANTL_Translate8023To80211Header
8876
8877 DESCRIPTION
8878 Inline function for translating and 802.11 header into an 802.3 header.
8879
8880 DEPENDENCIES
8881
8882
8883 PARAMETERS
8884
8885 IN
8886 pTLCb: TL control block
Kiran Venkatappaa044eb92012-12-17 15:48:49 -08008887 IN/OUT
8888 ucStaId: station ID. Incase of TDLS, this returns actual TDLS
8889 station ID used
Jeff Johnson295189b2012-06-20 16:38:30 -07008890
8891 IN/OUT
8892 vosDataBuff: vos data buffer, will contain the new header on output
8893
8894 OUT
8895 pvosStatus: status of the operation
8896
8897 RETURN VALUE
8898
8899 VOS_STATUS_SUCCESS: Everything is good :)
8900
8901 Other error codes might be returned from the vos api used in the function
8902 please check those return values.
8903
8904 SIDE EFFECTS
8905
8906============================================================================*/
Kiran Venkatappacab0d352012-12-17 13:09:22 -08008907VOS_STATUS
8908WLANTL_Translate8023To80211Header
8909(
8910 vos_pkt_t* vosDataBuff,
8911 VOS_STATUS* pvosStatus,
8912 WLANTL_CbType* pTLCb,
8913 v_U8_t *pucStaId,
Ravi Joshid0699502013-07-08 15:48:47 -07008914 WLANTL_MetaInfoType *tlMetaInfo,
Kiran Venkatappacab0d352012-12-17 13:09:22 -08008915 v_U8_t *ucWDSEnabled,
8916 v_U8_t *extraHeadSpace
8917)
Jeff Johnson295189b2012-06-20 16:38:30 -07008918{
8919 WLANTL_8023HeaderType w8023Header;
8920 WLANTL_80211HeaderType *pw80211Header; // Allocate an aligned BD and then fill it.
8921 VOS_STATUS vosStatus;
8922 v_U8_t MandatoryucHeaderSize = WLAN80211_MANDATORY_HEADER_SIZE;
8923 v_U8_t ucHeaderSize = 0;
8924 v_VOID_t *ppvBDHeader = NULL;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308925 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07008926 v_U8_t ucQoSOffset = WLAN80211_MANDATORY_HEADER_SIZE;
Kiran Venkatappacab0d352012-12-17 13:09:22 -08008927 v_U8_t ucStaId;
Jeff Johnson295189b2012-06-20 16:38:30 -07008928
8929 *ucWDSEnabled = 0; // default WDS off.
8930 vosStatus = vos_pkt_pop_head( vosDataBuff, &w8023Header,
8931 sizeof(w8023Header));
8932
8933 if ( VOS_STATUS_SUCCESS != vosStatus )
8934 {
8935 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8936 "WLAN TL: Packet pop header fails on WLANTL_Translate8023To80211Header"));
8937 return vosStatus;
8938 }
8939
Kiran Venkatappacab0d352012-12-17 13:09:22 -08008940 if( NULL == pucStaId )
8941 {
8942 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8943 "WLAN TL: Invalid pointer for StaId"));
8944 return VOS_STATUS_E_INVAL;
8945 }
8946 ucStaId = *pucStaId;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308947 pClientSTA = pTLCb->atlSTAClients[ucStaId];
8948
8949 if ( NULL == pClientSTA )
8950 {
8951 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8952 "WLAN TL:Client Memory was not allocated on %s", __func__));
8953 return VOS_STATUS_E_FAILURE;
8954 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008955
Kiran Venkatappaa044eb92012-12-17 15:48:49 -08008956#ifdef FEATURE_WLAN_TDLS
8957
Madan Mohan Koyylamudi64258222013-01-30 14:35:10 +05308958 if ( WLAN_STA_INFRA == pTLCb->atlSTAClients[ucStaId]->wSTADesc.wSTAType
8959 && pTLCb->ucTdlsPeerCount )
Kiran Venkatappacab0d352012-12-17 13:09:22 -08008960 {
8961 v_U8_t ucIndex = 0;
8962 for ( ucIndex = 0; ucIndex < WLAN_MAX_STA_COUNT ; ucIndex++)
8963 {
Madan Mohan Koyylamudi64258222013-01-30 14:35:10 +05308964 if ( ucIndex != ucStaId && pTLCb->atlSTAClients[ucIndex] && pTLCb->atlSTAClients[ucIndex]->ucExists &&
Gopichand Nakkala471708b2013-06-04 20:03:01 +05308965 (pTLCb->atlSTAClients[ucIndex]->tlState == WLANTL_STA_AUTHENTICATED) &&
8966 (!pTLCb->atlSTAClients[ucIndex]->ucTxSuspended) &&
Madan Mohan Koyylamudi64258222013-01-30 14:35:10 +05308967 vos_mem_compare( (void*)pTLCb->atlSTAClients[ucIndex]->wSTADesc.vSTAMACAddress.bytes,
Kiran Venkatappacab0d352012-12-17 13:09:22 -08008968 (void*)w8023Header.vDA, 6) )
8969 {
8970 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_LOW,
8971 "WLAN TL: Got a TDLS station. Using that index"));
8972 ucStaId = ucIndex;
8973 *pucStaId = ucStaId;
Madan Mohan Koyylamudi64258222013-01-30 14:35:10 +05308974 pClientSTA = pTLCb->atlSTAClients[ucStaId];
8975 if ( NULL == pClientSTA )
8976 {
8977 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8978 "WLAN TL:Client Memory was not allocated on %s", __func__));
8979 return VOS_STATUS_E_FAILURE;
8980 }
Kiran Venkatappacab0d352012-12-17 13:09:22 -08008981 break;
8982 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008983 }
Kiran Venkatappacab0d352012-12-17 13:09:22 -08008984 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008985#endif
8986
Jeff Johnson295189b2012-06-20 16:38:30 -07008987
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308988 if ( 0 != pClientSTA->wSTADesc.ucAddRmvLLC )
Jeff Johnson295189b2012-06-20 16:38:30 -07008989 {
8990 /* Push the length */
8991 vosStatus = vos_pkt_push_head(vosDataBuff,
8992 &w8023Header.usLenType, sizeof(w8023Header.usLenType));
8993
8994 if ( VOS_STATUS_SUCCESS != vosStatus )
8995 {
8996 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8997 "WLAN TL: Packet push ether type fails on"
8998 " WLANTL_Translate8023To80211Header"));
8999 return vosStatus;
9000 }
9001
9002#ifdef BTAMP_TEST
9003 // The STA side will execute this, a hack to test BTAMP by using the
9004 // infra setup. On real BTAMP this will come from BAP itself.
9005 {
9006 static v_U8_t WLANTL_BT_AMP_LLC_HEADER[] = {0xAA, 0xAA, 0x03, 0x00, 0x19, 0x58 };
9007 vosStatus = vos_pkt_push_head(vosDataBuff, WLANTL_BT_AMP_LLC_HEADER,
9008 sizeof(WLANTL_BT_AMP_LLC_HEADER));
9009
9010 if ( VOS_STATUS_SUCCESS != vosStatus )
9011 {
9012 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9013 "WLAN TL: Packet push LLC header fails on"
9014 " WLANTL_Translate8023To80211Header"));
9015 return vosStatus;
9016 }
9017 }
9018#else
9019 vosStatus = vos_pkt_push_head(vosDataBuff, WLANTL_LLC_HEADER,
9020 sizeof(WLANTL_LLC_HEADER));
9021
9022 if ( VOS_STATUS_SUCCESS != vosStatus )
9023 {
9024 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9025 "WLAN TL: Packet push LLC header fails on"
9026 " WLANTL_Translate8023To80211Header"));
9027 return vosStatus;
9028 }
9029#endif
9030 }/*If add LLC is enabled*/
9031 else
9032 {
9033 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
9034 "WLAN TL: STA Client registered to not remove LLC"
9035 " WLANTL_Translate8023To80211Header"));
9036 }
9037
9038#ifdef BTAMP_TEST
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309039 pClientSTA->wSTADesc.wSTAType = WLAN_STA_BT_AMP;
Jeff Johnson295189b2012-06-20 16:38:30 -07009040#endif
9041
9042 // Find the space required for the 802.11 header format
9043 // based on the frame control fields.
9044 ucHeaderSize = MandatoryucHeaderSize;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309045 if (pClientSTA->wSTADesc.ucQosEnabled)
Jeff Johnson295189b2012-06-20 16:38:30 -07009046 {
9047 ucHeaderSize += sizeof(pw80211Header->usQosCtrl);
9048 }
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309049 if (pClientSTA->wSTADesc.wSTAType == WLAN_STA_BT_AMP)
Jeff Johnson295189b2012-06-20 16:38:30 -07009050 {
9051 ucHeaderSize += sizeof(pw80211Header->optvA4);
Jeff Johnson295189b2012-06-20 16:38:30 -07009052 ucQoSOffset += sizeof(pw80211Header->optvA4);
Jeff Johnson295189b2012-06-20 16:38:30 -07009053 }
9054
9055 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
9056 " WLANTL_Translate8023To80211Header : Header size = %d ", ucHeaderSize));
9057
9058 vos_pkt_reserve_head( vosDataBuff, &ppvBDHeader, ucHeaderSize );
9059 if ( NULL == ppvBDHeader )
9060 {
9061 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9062 "WLAN TL:VOSS packet corrupted "));
9063 *pvosStatus = VOS_STATUS_E_INVAL;
9064 return *pvosStatus;
9065 }
9066
Jeff Johnson295189b2012-06-20 16:38:30 -07009067
9068 // OK now we have the space. Fill the 80211 header
9069 /* Fill A2 */
9070 pw80211Header = (WLANTL_80211HeaderType *)(ppvBDHeader);
9071 // only clear the required space.
9072 vos_mem_set( pw80211Header, ucHeaderSize, 0 );
9073 vos_mem_copy( pw80211Header->vA2, w8023Header.vSA, VOS_MAC_ADDR_SIZE);
9074
9075
9076#ifdef FEATURE_WLAN_WAPI
Gopichand Nakkala8b54e912013-03-11 10:44:21 +05309077 if (( WLANTL_STA_AUTHENTICATED == pClientSTA->tlState ||
9078 pClientSTA->ptkInstalled ) && gUcIsWai != 1)
Jeff Johnson295189b2012-06-20 16:38:30 -07009079#else
Gopichand Nakkala8b54e912013-03-11 10:44:21 +05309080 if ( WLANTL_STA_AUTHENTICATED == pClientSTA->tlState ||
9081 pClientSTA->ptkInstalled )
Jeff Johnson295189b2012-06-20 16:38:30 -07009082#endif
9083 {
9084 pw80211Header->wFrmCtrl.wep =
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309085 pClientSTA->wSTADesc.ucProtectedFrame;
Jeff Johnson295189b2012-06-20 16:38:30 -07009086 }
9087
9088 pw80211Header->usDurationId = 0;
9089 pw80211Header->usSeqCtrl = 0;
9090
9091 pw80211Header->wFrmCtrl.type = WLANTL_80211_DATA_TYPE;
9092
9093
9094
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309095 if(pClientSTA->wSTADesc.ucQosEnabled)
Jeff Johnson295189b2012-06-20 16:38:30 -07009096 {
9097 pw80211Header->wFrmCtrl.subType = WLANTL_80211_DATA_QOS_SUBTYPE;
9098
Ravi Joshid0699502013-07-08 15:48:47 -07009099 *((v_U16_t *)((v_U8_t *)ppvBDHeader + ucQoSOffset)) = tlMetaInfo->ucUP;
Jeff Johnson295189b2012-06-20 16:38:30 -07009100
9101 }
9102 else
9103 {
9104 pw80211Header->wFrmCtrl.subType = 0;
9105
9106 // NO NO NO - there is not enough memory allocated to write the QOS ctrl
9107 // field, it will overwrite the first 2 bytes of the data packet(LLC header)
9108 // pw80211Header->usQosCtrl = 0;
9109 }
9110
9111
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309112 switch( pClientSTA->wSTADesc.wSTAType )
Jeff Johnson295189b2012-06-20 16:38:30 -07009113 {
Ravi Joshid0699502013-07-08 15:48:47 -07009114 case WLAN_STA_IBSS:
Jeff Johnson295189b2012-06-20 16:38:30 -07009115 pw80211Header->wFrmCtrl.toDS = 0;
9116 pw80211Header->wFrmCtrl.fromDS = 0;
Ravi Joshid0699502013-07-08 15:48:47 -07009117
9118 /*
9119 * If the frame is a multicast frame, then, the Address1
9120 * should be the destination address filled in the packet. Which is
9121 * the multicast address. Otherwise, set it to BSSID
9122 */
9123 if (0 == tlMetaInfo->ucBcast && 1 == tlMetaInfo->ucMcast)
9124 {
9125 vos_copy_macaddr( (v_MACADDR_t*)&pw80211Header->vA1,
9126 (v_MACADDR_t*)&w8023Header.vDA);
9127 }
9128 else
9129 {
9130 vos_copy_macaddr( (v_MACADDR_t*)&pw80211Header->vA1,
9131 &pClientSTA->wSTADesc.vSTAMACAddress);
9132 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009133 vos_mem_copy( pw80211Header->vA3,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309134 &pClientSTA->wSTADesc.vBSSIDforIBSS ,
Jeff Johnson295189b2012-06-20 16:38:30 -07009135 VOS_MAC_ADDR_SIZE);
9136 break;
9137
Ravi Joshid0699502013-07-08 15:48:47 -07009138 case WLAN_STA_BT_AMP:
Jeff Johnson295189b2012-06-20 16:38:30 -07009139 *ucWDSEnabled = 1; // WDS on.
9140 pw80211Header->wFrmCtrl.toDS = 1;
9141 pw80211Header->wFrmCtrl.fromDS = 1;
9142 vos_copy_macaddr( (v_MACADDR_t*)&pw80211Header->vA1,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309143 &pClientSTA->wSTADesc.vSTAMACAddress);
Jeff Johnson295189b2012-06-20 16:38:30 -07009144 vos_mem_copy( pw80211Header->vA2,
Ravi Joshid0699502013-07-08 15:48:47 -07009145 w8023Header.vSA, VOS_MAC_ADDR_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -07009146 vos_copy_macaddr( (v_MACADDR_t*)&pw80211Header->vA3,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309147 &pClientSTA->wSTADesc.vSTAMACAddress);
Jeff Johnson295189b2012-06-20 16:38:30 -07009148 /* fill the optional A4 header */
9149 vos_mem_copy( pw80211Header->optvA4,
Ravi Joshid0699502013-07-08 15:48:47 -07009150 w8023Header.vSA, VOS_MAC_ADDR_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -07009151 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
Ravi Joshid0699502013-07-08 15:48:47 -07009152 "BTAMP CASE NOW ---------staid=%d\n",
9153 ucStaId));
Jeff Johnson295189b2012-06-20 16:38:30 -07009154 break;
9155
Ravi Joshid0699502013-07-08 15:48:47 -07009156 case WLAN_STA_SOFTAP:
Jeff Johnson295189b2012-06-20 16:38:30 -07009157 *ucWDSEnabled = 0; // WDS off.
9158 pw80211Header->wFrmCtrl.toDS = 0;
9159 pw80211Header->wFrmCtrl.fromDS = 1;
9160 /*Copy the DA to A1*/
9161 vos_mem_copy( pw80211Header->vA1, w8023Header.vDA , VOS_MAC_ADDR_SIZE);
9162 vos_copy_macaddr( (v_MACADDR_t*)&pw80211Header->vA2,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309163 &pClientSTA->wSTADesc.vSelfMACAddress);
Jeff Johnson295189b2012-06-20 16:38:30 -07009164 vos_mem_copy( pw80211Header->vA3,
Ravi Joshid0699502013-07-08 15:48:47 -07009165 w8023Header.vSA, VOS_MAC_ADDR_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -07009166 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
Ravi Joshid0699502013-07-08 15:48:47 -07009167 "sw 802 to 80211 softap case ---------staid=%d\n",
9168 ucStaId));
Jeff Johnson295189b2012-06-20 16:38:30 -07009169 break;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08009170#ifdef FEATURE_WLAN_TDLS
Ravi Joshid0699502013-07-08 15:48:47 -07009171 case WLAN_STA_TDLS:
Mohit Khanna698ba2a2012-12-04 15:08:18 -08009172 pw80211Header->wFrmCtrl.toDS = 0;
9173 pw80211Header->wFrmCtrl.fromDS = 0;
9174 /*Fix me*/
9175 vos_copy_macaddr( (v_MACADDR_t*)&pw80211Header->vA1,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309176 &pClientSTA->wSTADesc.vSTAMACAddress);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08009177 vos_mem_copy( pw80211Header->vA3,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309178 &pClientSTA->wSTADesc.vBSSIDforIBSS ,
Mohit Khanna698ba2a2012-12-04 15:08:18 -08009179 VOS_MAC_ADDR_SIZE);
9180 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
Ravi Joshid0699502013-07-08 15:48:47 -07009181 ("TL:TDLS CASE NOW ---------staid=%d\n"), ucStaId);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08009182 break;
9183#endif
Ravi Joshid0699502013-07-08 15:48:47 -07009184 case WLAN_STA_INFRA:
9185 default:
Jeff Johnson295189b2012-06-20 16:38:30 -07009186 pw80211Header->wFrmCtrl.toDS = 1;
9187 pw80211Header->wFrmCtrl.fromDS = 0;
9188 vos_copy_macaddr( (v_MACADDR_t*)&pw80211Header->vA1,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309189 &pClientSTA->wSTADesc.vSTAMACAddress);
Jeff Johnson295189b2012-06-20 16:38:30 -07009190 vos_mem_copy( pw80211Header->vA3, w8023Header.vDA , VOS_MAC_ADDR_SIZE);
9191 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
Ravi Joshid0699502013-07-08 15:48:47 -07009192 "REGULAR INFRA LINK CASE---------staid=%d\n",
9193 ucStaId));
Jeff Johnson295189b2012-06-20 16:38:30 -07009194 break;
9195 }
9196 // OK now we have the space. Fill the 80211 header
9197 /* Fill A2 */
9198 pw80211Header = (WLANTL_80211HeaderType *)(ppvBDHeader);
9199 return VOS_STATUS_SUCCESS;
9200}/*WLANTL_Translate8023To80211Header*/
9201
9202
9203/*=============================================================================
9204 BEGIN LOG FUNCTION !!! Remove me or clean me
9205=============================================================================*/
Ravi Kumar Vaishnavb7652402013-01-18 19:05:15 -08009206#if 0 //def WLANTL_DEBUG
Jeff Johnson295189b2012-06-20 16:38:30 -07009207
9208#define WLANTL_DEBUG_FRAME_BYTE_PER_LINE 16
9209#define WLANTL_DEBUG_FRAME_BYTE_PER_BYTE 4
9210
9211static v_VOID_t WLANTL_DebugFrame
9212(
9213 v_PVOID_t dataPointer,
9214 v_U32_t dataSize
9215)
9216{
9217 v_U8_t lineBuffer[WLANTL_DEBUG_FRAME_BYTE_PER_LINE];
9218 v_U32_t numLines;
9219 v_U32_t numBytes;
9220 v_U32_t idx;
9221 v_U8_t *linePointer;
9222
9223 numLines = dataSize / WLANTL_DEBUG_FRAME_BYTE_PER_LINE;
9224 numBytes = dataSize % WLANTL_DEBUG_FRAME_BYTE_PER_LINE;
9225 linePointer = (v_U8_t *)dataPointer;
9226
9227 TLLOGE(VOS_TRACE(VOS_MODULE_ID_SAL, VOS_TRACE_LEVEL_ERROR, "WLAN TL:Frame Debug Frame Size %d, Pointer 0x%p", dataSize, dataPointer));
9228 for(idx = 0; idx < numLines; idx++)
9229 {
9230 memset(lineBuffer, 0, WLANTL_DEBUG_FRAME_BYTE_PER_LINE);
9231 memcpy(lineBuffer, linePointer, WLANTL_DEBUG_FRAME_BYTE_PER_LINE);
9232 TLLOGE(VOS_TRACE(VOS_MODULE_ID_SAL, VOS_TRACE_LEVEL_ERROR,
9233 "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",
9234 lineBuffer[0], lineBuffer[1], lineBuffer[2], lineBuffer[3], lineBuffer[4], lineBuffer[5], lineBuffer[6], lineBuffer[7],
9235 lineBuffer[8], lineBuffer[9], lineBuffer[10], lineBuffer[11], lineBuffer[12], lineBuffer[13], lineBuffer[14], lineBuffer[15]));
9236 linePointer += WLANTL_DEBUG_FRAME_BYTE_PER_LINE;
9237 }
9238
9239 if(0 == numBytes)
9240 return;
9241
9242 memset(lineBuffer, 0, WLANTL_DEBUG_FRAME_BYTE_PER_LINE);
9243 memcpy(lineBuffer, linePointer, numBytes);
9244 for(idx = 0; idx < WLANTL_DEBUG_FRAME_BYTE_PER_LINE / WLANTL_DEBUG_FRAME_BYTE_PER_BYTE; idx++)
9245 {
9246 TLLOGE(VOS_TRACE(VOS_MODULE_ID_SAL, VOS_TRACE_LEVEL_ERROR, "WLAN TL:0x%2x 0x%2x 0x%2x 0x%2x",
9247 lineBuffer[idx * WLANTL_DEBUG_FRAME_BYTE_PER_BYTE], lineBuffer[1 + idx * WLANTL_DEBUG_FRAME_BYTE_PER_BYTE],
9248 lineBuffer[2 + idx * WLANTL_DEBUG_FRAME_BYTE_PER_BYTE], lineBuffer[3 + idx * WLANTL_DEBUG_FRAME_BYTE_PER_BYTE]));
9249 if(((idx + 1) * WLANTL_DEBUG_FRAME_BYTE_PER_BYTE) >= numBytes)
9250 break;
9251 }
9252
9253 return;
9254}
9255#endif
9256
9257/*=============================================================================
9258 END LOG FUNCTION
9259=============================================================================*/
9260
9261/*==========================================================================
9262 FUNCTION WLANTL_Translate80211To8023Header
9263
9264 DESCRIPTION
9265 Inline function for translating and 802.11 header into an 802.3 header.
9266
9267 DEPENDENCIES
9268
9269
9270 PARAMETERS
9271
9272 IN
9273 pTLCb: TL control block
9274 ucStaId: station ID
9275 ucHeaderLen: Length of the header from BD
9276 ucActualHLen: Length of header including padding or any other trailers
9277
9278 IN/OUT
9279 vosDataBuff: vos data buffer, will contain the new header on output
9280
9281 OUT
9282 pvosStatus: status of the operation
9283
9284 RETURN VALUE
9285
9286 The result code associated with performing the operation
9287 VOS_STATUS_SUCCESS: Everything is good :)
9288
9289 SIDE EFFECTS
9290
9291============================================================================*/
9292VOS_STATUS
9293WLANTL_Translate80211To8023Header
9294(
9295 vos_pkt_t* vosDataBuff,
9296 VOS_STATUS* pvosStatus,
9297 v_U16_t usActualHLen,
9298 v_U8_t ucHeaderLen,
9299 WLANTL_CbType* pTLCb,
9300 v_U8_t ucSTAId
9301)
9302{
9303 WLANTL_8023HeaderType w8023Header;
9304 WLANTL_80211HeaderType w80211Header;
9305 v_U8_t aucLLCHeader[WLANTL_LLC_HEADER_LEN];
9306 VOS_STATUS vosStatus;
9307 v_U16_t usDataStartOffset = 0;
9308 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
9309
9310 if ( sizeof(w80211Header) < ucHeaderLen )
9311 {
9312 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
9313 "Warning !: Check the header size for the Rx frame structure=%d received=%dn",
9314 sizeof(w80211Header), ucHeaderLen));
9315 ucHeaderLen = sizeof(w80211Header);
9316 }
9317
9318 // This will take care of headers of all sizes, 3 address, 3 addr QOS,
9319 // WDS non-QOS and WDS QoS etc. We have space for all in the 802.11 header structure.
9320 vosStatus = vos_pkt_pop_head( vosDataBuff, &w80211Header, ucHeaderLen);
9321
9322 if ( VOS_STATUS_SUCCESS != vosStatus )
9323 {
9324 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9325 "WLAN TL: Failed to pop 80211 header from packet %d",
9326 vosStatus));
9327
9328 return vosStatus;
9329 }
9330
9331 switch ( w80211Header.wFrmCtrl.fromDS )
9332 {
9333 case 0:
Jeff Johnson295189b2012-06-20 16:38:30 -07009334 if ( w80211Header.wFrmCtrl.toDS )
9335 {
9336 //SoftAP AP mode
9337 vos_mem_copy( w8023Header.vDA, w80211Header.vA3, VOS_MAC_ADDR_SIZE);
9338 vos_mem_copy( w8023Header.vSA, w80211Header.vA2, VOS_MAC_ADDR_SIZE);
9339 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
9340 "WLAN TL SoftAP: 802 3 DA %08x SA %08x \n",
9341 w8023Header.vDA, w8023Header.vSA));
9342 }
9343 else
9344 {
9345 /* IBSS */
9346 vos_mem_copy( w8023Header.vDA, w80211Header.vA1, VOS_MAC_ADDR_SIZE);
9347 vos_mem_copy( w8023Header.vSA, w80211Header.vA2, VOS_MAC_ADDR_SIZE);
9348 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009349 break;
9350 case 1:
9351 if ( w80211Header.wFrmCtrl.toDS )
9352 {
9353 /* BT-AMP case */
9354 vos_mem_copy( w8023Header.vDA, w80211Header.vA1, VOS_MAC_ADDR_SIZE);
9355 vos_mem_copy( w8023Header.vSA, w80211Header.vA2, VOS_MAC_ADDR_SIZE);
9356 }
9357 else
9358 { /* Infra */
9359 vos_mem_copy( w8023Header.vDA, w80211Header.vA1, VOS_MAC_ADDR_SIZE);
9360 vos_mem_copy( w8023Header.vSA, w80211Header.vA3, VOS_MAC_ADDR_SIZE);
9361 }
9362 break;
9363 }
9364
9365 if( usActualHLen > ucHeaderLen )
9366 {
9367 usDataStartOffset = usActualHLen - ucHeaderLen;
9368 }
9369
9370 if ( 0 < usDataStartOffset )
9371 {
9372 vosStatus = vos_pkt_trim_head( vosDataBuff, usDataStartOffset );
9373
9374 if ( VOS_STATUS_SUCCESS != vosStatus )
9375 {
9376 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9377 "WLAN TL: Failed to trim header from packet %d",
9378 vosStatus));
9379 return vosStatus;
9380 }
9381 }
9382
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309383 if ( NULL == pTLCb->atlSTAClients[ucSTAId] )
9384 {
9385 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9386 "WLAN TL:Client Memory was not allocated on %s", __func__));
9387 return VOS_STATUS_E_FAILURE;
9388 }
9389
9390 if ( 0 != pTLCb->atlSTAClients[ucSTAId]->wSTADesc.ucAddRmvLLC )
Jeff Johnson295189b2012-06-20 16:38:30 -07009391 {
9392 // Extract the LLC header
9393 vosStatus = vos_pkt_pop_head( vosDataBuff, aucLLCHeader,
9394 WLANTL_LLC_HEADER_LEN);
9395
9396 if ( VOS_STATUS_SUCCESS != vosStatus )
9397 {
9398 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9399 "WLAN TL: Failed to pop LLC header from packet %d",
9400 vosStatus));
9401
9402 return vosStatus;
9403 }
9404
9405 //Extract the length
9406 vos_mem_copy(&w8023Header.usLenType,
9407 &aucLLCHeader[WLANTL_LLC_HEADER_LEN - sizeof(w8023Header.usLenType)],
9408 sizeof(w8023Header.usLenType) );
9409 }
9410 else
9411 {
9412 vosStatus = vos_pkt_get_packet_length(vosDataBuff,
9413 &w8023Header.usLenType);
9414
9415 if ( VOS_STATUS_SUCCESS != vosStatus )
9416 {
9417 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9418 "WLAN TL: Failed to get packet length %d",
9419 vosStatus));
9420
9421 return vosStatus;
9422 }
9423
9424 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
9425 "WLAN TL: BTAMP len (ethertype) fld = %d",
9426 w8023Header.usLenType));
9427 w8023Header.usLenType = vos_cpu_to_be16(w8023Header.usLenType);
9428 }
9429
9430 vos_pkt_push_head(vosDataBuff, &w8023Header, sizeof(w8023Header));
9431
9432#ifdef BTAMP_TEST
9433 {
9434 // AP side will execute this.
9435 v_U8_t *temp_w8023Header = NULL;
9436 vosStatus = vos_pkt_peek_data( vosDataBuff, 0,
9437 &temp_w8023Header, sizeof(w8023Header) );
9438 }
9439#endif
9440#if 0 /*TL_DEBUG*/
9441 vos_pkt_get_packet_length(vosDataBuff, &usLen);
9442 vos_pkt_pop_head( vosDataBuff, aucData, usLen);
9443
9444 WLANTL_DebugFrame(aucData, usLen);
9445
9446 vos_pkt_push_head(vosDataBuff, aucData, usLen);
9447
9448#endif
9449
9450 *pvosStatus = VOS_STATUS_SUCCESS;
9451
9452 return VOS_STATUS_SUCCESS;
9453}/*WLANTL_Translate80211To8023Header*/
9454
Madan Mohan Koyyalamudia148e1e2012-11-30 14:52:59 -08009455/*==========================================================================
9456 FUNCTION WLANTL_FindFrameTypeBcMcUc
9457
9458 DESCRIPTION
9459 Utility function to find whether received frame is broadcast, multicast
9460 or unicast.
9461
9462 DEPENDENCIES
9463 The STA must be registered with TL before this function can be called.
9464
9465 PARAMETERS
9466
9467 IN
9468 pTLCb: pointer to the TL's control block
9469 ucSTAId: identifier of the station being processed
9470 vosDataBuff: pointer to the vos buffer
9471
9472 IN/OUT
9473 pucBcMcUc: pointer to buffer, will contain frame type on return
9474
9475 RETURN VALUE
9476 The result code associated with performing the operation
9477
9478 VOS_STATUS_E_INVAL: invalid input parameters
9479 VOS_STATUS_E_BADMSG: failed to extract info from data buffer
9480 VOS_STATUS_SUCCESS: success
9481
9482 SIDE EFFECTS
9483 None.
9484============================================================================*/
9485VOS_STATUS
9486WLANTL_FindFrameTypeBcMcUc
9487(
9488 WLANTL_CbType *pTLCb,
9489 v_U8_t ucSTAId,
9490 vos_pkt_t *vosDataBuff,
9491 v_U8_t *pucBcMcUc
9492)
9493{
9494 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
9495 v_PVOID_t aucBDHeader;
9496 v_PVOID_t pvPeekData;
9497 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
9498
9499 /*------------------------------------------------------------------------
9500 Sanity check
9501 ------------------------------------------------------------------------*/
9502 if ((NULL == pTLCb) ||
9503 (NULL == vosDataBuff) ||
9504 (NULL == pucBcMcUc))
9505 {
9506 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9507 "WLAN TL:Invalid parameter in WLANTL_FindFrameTypeBcMcUc"));
9508 return VOS_STATUS_E_INVAL;
9509 }
9510
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309511 if ( NULL == pTLCb->atlSTAClients[ucSTAId] )
9512 {
9513 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9514 "WLAN TL:Client Memory was not allocated on %s", __func__));
9515 return VOS_STATUS_E_FAILURE;
9516 }
9517
Madan Mohan Koyyalamudia148e1e2012-11-30 14:52:59 -08009518 /*------------------------------------------------------------------------
9519 Extract BD header and check if valid
9520 ------------------------------------------------------------------------*/
9521 vosStatus = WDA_DS_PeekRxPacketInfo(vosDataBuff, (v_PVOID_t)&aucBDHeader, 0/*Swap BD*/ );
9522
9523 if (NULL == aucBDHeader)
9524 {
9525 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9526 "WLAN TL:WLANTL_FindFrameTypeBcMcUc - Cannot extract BD header"));
9527 VOS_ASSERT(0);
9528 return VOS_STATUS_E_BADMSG;
9529 }
9530
9531 if ((0 == WDA_GET_RX_FT_DONE(aucBDHeader)) &&
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309532 (0 != pTLCb->atlSTAClients[ucSTAId]->wSTADesc.ucSwFrameRXXlation))
Madan Mohan Koyyalamudia148e1e2012-11-30 14:52:59 -08009533 {
9534 /* Its an 802.11 frame, extract MAC address 1 */
9535 TLLOG2(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
9536 "WLAN TL:WLANTL_FindFrameTypeBcMcUc - 802.11 frame, peeking Addr1"));
9537 vosStatus = vos_pkt_peek_data(vosDataBuff, WLANTL_MAC_ADDR_ALIGN(1),
9538 (v_PVOID_t)&pvPeekData, VOS_MAC_ADDR_SIZE);
9539 }
9540 else
9541 {
9542 /* Its an 802.3 frame, extract Destination MAC address */
9543 TLLOG2(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
9544 "WLAN TL:WLANTL_FindFrameTypeBcMcUc - 802.3 frame, peeking DA"));
9545 vosStatus = vos_pkt_peek_data(vosDataBuff, WLANTL_MAC_ADDR_ALIGN(0),
9546 (v_PVOID_t)&pvPeekData, VOS_MAC_ADDR_SIZE);
9547 }
9548
9549 if (VOS_STATUS_SUCCESS != vosStatus)
9550 {
9551 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9552 "WLAN TL:WLANTL_FindFrameTypeBcMcUc - Failed to peek MAC address"));
9553 return vosStatus;
9554 }
9555
9556 if (((tANI_U8 *)pvPeekData)[0] == 0xff)
9557 {
9558 *pucBcMcUc = WLANTL_FRAME_TYPE_BCAST;
9559 }
9560 else
9561 {
9562 if ((((tANI_U8 *)pvPeekData)[0] & 0x01) == 0x01)
9563 *pucBcMcUc = WLANTL_FRAME_TYPE_MCAST;
9564 else
9565 *pucBcMcUc = WLANTL_FRAME_TYPE_UCAST;
9566 }
9567
9568 TLLOG2(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
9569 "WLAN TL:WLANTL_FindFrameTypeBcMcUc - Addr1Byte1 is: %x",
9570 ((tANI_U8 *)pvPeekData)[0]));
9571
9572 return VOS_STATUS_SUCCESS;
9573}
9574
Jeff Johnson295189b2012-06-20 16:38:30 -07009575#if 0
9576#ifdef WLAN_PERF
9577/*==========================================================================
9578 FUNCTION WLANTL_FastHwFwdDataFrame
9579
9580 DESCRIPTION
9581 Fast path function to quickly forward a data frame if HAL determines BD
9582 signature computed here matches the signature inside current VOSS packet.
9583 If there is a match, HAL and TL fills in the swapped packet length into
9584 BD header and DxE header, respectively. Otherwise, packet goes back to
9585 normal (slow) path and a new BD signature would be tagged into BD in this
9586 VOSS packet later by the WLANHAL_FillTxBd() function.
9587
9588 DEPENDENCIES
9589
9590 PARAMETERS
9591
9592 IN
9593 pvosGCtx VOS context
9594 vosDataBuff Ptr to VOSS packet
9595 pMetaInfo For getting frame's TID
9596 pStaInfo For checking STA type
9597
9598 OUT
9599 pvosStatus returned status
9600 puFastFwdOK Flag to indicate whether frame could be fast forwarded
9601
9602 RETURN VALUE
9603 No return.
9604
9605 SIDE EFFECTS
9606
9607============================================================================*/
9608static void
9609WLANTL_FastHwFwdDataFrame
9610(
9611 v_PVOID_t pvosGCtx,
9612 vos_pkt_t* vosDataBuff,
9613 VOS_STATUS* pvosStatus,
9614 v_U32_t* puFastFwdOK,
9615 WLANTL_MetaInfoType* pMetaInfo,
9616 WLAN_STADescType* pStaInfo
9617
9618)
9619{
9620 v_PVOID_t pvPeekData;
9621 v_U8_t ucDxEBDWLANHeaderLen = WLANTL_BD_HEADER_LEN(0) + sizeof(WLANBAL_sDXEHeaderType);
9622 v_U8_t ucIsUnicast;
9623 WLANBAL_sDXEHeaderType *pDxEHeader;
9624 v_PVOID_t pvBDHeader;
9625 v_PVOID_t pucBuffPtr;
9626 v_U16_t usPktLen;
9627
9628 /*-----------------------------------------------------------------------
9629 Extract packet length
9630 -----------------------------------------------------------------------*/
9631
9632 vos_pkt_get_packet_length( vosDataBuff, &usPktLen);
9633
9634 /*-----------------------------------------------------------------------
9635 Extract MAC address
9636 -----------------------------------------------------------------------*/
9637 *pvosStatus = vos_pkt_peek_data( vosDataBuff,
9638 WLANTL_MAC_ADDR_ALIGN(0),
9639 (v_PVOID_t)&pvPeekData,
9640 VOS_MAC_ADDR_SIZE );
9641
9642 if ( VOS_STATUS_SUCCESS != *pvosStatus )
9643 {
9644 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9645 "WLAN TL:Failed while attempting to extract MAC Addr %d",
9646 *pvosStatus));
9647 *pvosStatus = VOS_STATUS_E_INVAL;
9648 return;
9649 }
9650
9651 /*-----------------------------------------------------------------------
9652 Reserve head room for DxE header, BD, and WLAN header
9653 -----------------------------------------------------------------------*/
9654
9655 vos_pkt_reserve_head( vosDataBuff, &pucBuffPtr,
9656 ucDxEBDWLANHeaderLen );
9657 if ( NULL == pucBuffPtr )
9658 {
9659 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9660 "WLAN TL:No enough space in VOSS packet %p for DxE/BD/WLAN header", vosDataBuff));
9661 *pvosStatus = VOS_STATUS_E_INVAL;
9662 return;
9663 }
9664 pDxEHeader = (WLANBAL_sDXEHeaderType *)pucBuffPtr;
9665 pvBDHeader = (v_PVOID_t) &pDxEHeader[1];
9666
9667 /* UMA Tx acceleration is enabled.
9668 * UMA would help convert frames to 802.11, fill partial BD fields and
9669 * construct LLC header. To further accelerate this kind of frames,
9670 * HAL would attempt to reuse the BD descriptor if the BD signature
9671 * matches to the saved BD descriptor.
9672 */
9673 if(pStaInfo->wSTAType == WLAN_STA_IBSS)
9674 ucIsUnicast = !(((tANI_U8 *)pvPeekData)[0] & 0x01);
9675 else
9676 ucIsUnicast = 1;
9677
9678 *puFastFwdOK = (v_U32_t) WLANHAL_TxBdFastFwd(pvosGCtx, pvPeekData, pMetaInfo->ucTID, ucIsUnicast, pvBDHeader, usPktLen );
9679
9680 /* Can't be fast forwarded. Trim the VOS head back to original location. */
9681 if(! *puFastFwdOK){
9682 vos_pkt_trim_head(vosDataBuff, ucDxEBDWLANHeaderLen);
9683 }else{
9684 /* could be fast forwarded. Now notify BAL DxE header filling could be completely skipped
9685 */
9686 v_U32_t uPacketSize = WLANTL_BD_HEADER_LEN(0) + usPktLen;
9687 vos_pkt_set_user_data_ptr( vosDataBuff, VOS_PKT_USER_DATA_ID_BAL,
9688 (v_PVOID_t)uPacketSize);
9689 pDxEHeader->size = SWAP_ENDIAN_UINT32(uPacketSize);
9690 }
9691 *pvosStatus = VOS_STATUS_SUCCESS;
9692 return;
9693}
9694#endif /*WLAN_PERF*/
9695#endif
9696
9697#if 0
9698/*==========================================================================
9699 FUNCTION WLANTL_PrepareBDHeader
9700
9701 DESCRIPTION
9702 Inline function for preparing BD header before HAL processing.
9703
9704 DEPENDENCIES
9705 Just notify HAL that suspend in TL is complete.
9706
9707 PARAMETERS
9708
9709 IN
9710 vosDataBuff: vos data buffer
9711 ucDisableFrmXtl: is frame xtl disabled
9712
9713 OUT
9714 ppvBDHeader: it will contain the BD header
9715 pvDestMacAdddr: it will contain the destination MAC address
9716 pvosStatus: status of the combined processing
9717 pusPktLen: packet len.
9718
9719 RETURN VALUE
9720 No return.
9721
9722 SIDE EFFECTS
9723
9724============================================================================*/
9725void
9726WLANTL_PrepareBDHeader
9727(
9728 vos_pkt_t* vosDataBuff,
9729 v_PVOID_t* ppvBDHeader,
9730 v_MACADDR_t* pvDestMacAdddr,
9731 v_U8_t ucDisableFrmXtl,
9732 VOS_STATUS* pvosStatus,
9733 v_U16_t* pusPktLen,
9734 v_U8_t ucQosEnabled,
9735 v_U8_t ucWDSEnabled,
9736 v_U8_t extraHeadSpace
9737)
9738{
9739 v_U8_t ucHeaderOffset;
9740 v_U8_t ucHeaderLen;
Jeff Johnson295189b2012-06-20 16:38:30 -07009741 v_U8_t ucBDHeaderLen = WLANTL_BD_HEADER_LEN(ucDisableFrmXtl);
9742
9743 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
9744 /*-------------------------------------------------------------------------
9745 Get header pointer from VOSS
9746 !!! make sure reserve head zeros out the memory
9747 -------------------------------------------------------------------------*/
9748 vos_pkt_get_packet_length( vosDataBuff, pusPktLen);
9749
9750 if ( WLANTL_MAC_HEADER_LEN(ucDisableFrmXtl) > *pusPktLen )
9751 {
9752 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9753 "WLAN TL: Length of the packet smaller than expected network"
9754 " header %d", *pusPktLen ));
9755
9756 *pvosStatus = VOS_STATUS_E_INVAL;
9757 return;
9758 }
9759
9760 vos_pkt_reserve_head( vosDataBuff, ppvBDHeader,
9761 ucBDHeaderLen );
9762 if ( NULL == *ppvBDHeader )
9763 {
9764 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9765 "WLAN TL:VOSS packet corrupted on Attach BD header"));
9766 *pvosStatus = VOS_STATUS_E_INVAL;
9767 return;
9768 }
9769
9770 /*-----------------------------------------------------------------------
9771 Extract MAC address
9772 -----------------------------------------------------------------------*/
Jeff Johnson295189b2012-06-20 16:38:30 -07009773 {
9774 v_SIZE_t usMacAddrSize = VOS_MAC_ADDR_SIZE;
9775 *pvosStatus = vos_pkt_extract_data( vosDataBuff,
9776 ucBDHeaderLen +
9777 WLANTL_MAC_ADDR_ALIGN(ucDisableFrmXtl),
9778 (v_PVOID_t)pvDestMacAdddr,
9779 &usMacAddrSize );
9780 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009781 if ( VOS_STATUS_SUCCESS != *pvosStatus )
9782 {
9783 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9784 "WLAN TL:Failed while attempting to extract MAC Addr %d",
9785 *pvosStatus));
9786 }
9787 else
9788 {
9789 /*---------------------------------------------------------------------
9790 Fill MPDU info fields:
9791 - MPDU data start offset
9792 - MPDU header start offset
9793 - MPDU header length
9794 - MPDU length - this is a 16b field - needs swapping
9795 --------------------------------------------------------------------*/
9796 ucHeaderOffset = ucBDHeaderLen;
9797 ucHeaderLen = WLANTL_MAC_HEADER_LEN(ucDisableFrmXtl);
9798
9799 if ( 0 != ucDisableFrmXtl )
9800 {
9801 if ( 0 != ucQosEnabled )
9802 {
9803 ucHeaderLen += WLANTL_802_11_HEADER_QOS_CTL;
9804 }
9805
9806 // Similar to Qos we need something for WDS format !
9807 if ( ucWDSEnabled != 0 )
9808 {
9809 // If we have frame translation enabled
9810 ucHeaderLen += WLANTL_802_11_HEADER_ADDR4_LEN;
9811 }
9812 if ( extraHeadSpace != 0 )
9813 {
9814 // Decrease the packet length with the extra padding after the header
9815 *pusPktLen = *pusPktLen - extraHeadSpace;
9816 }
9817 }
9818
9819 WLANHAL_TX_BD_SET_MPDU_HEADER_LEN( *ppvBDHeader, ucHeaderLen);
9820 WLANHAL_TX_BD_SET_MPDU_HEADER_OFFSET( *ppvBDHeader, ucHeaderOffset);
9821 WLANHAL_TX_BD_SET_MPDU_DATA_OFFSET( *ppvBDHeader,
9822 ucHeaderOffset + ucHeaderLen + extraHeadSpace);
9823 WLANHAL_TX_BD_SET_MPDU_LEN( *ppvBDHeader, *pusPktLen);
9824
9825 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
9826 "WLAN TL: VALUES ARE HLen=%x Hoff=%x doff=%x len=%x ex=%d",
9827 ucHeaderLen, ucHeaderOffset,
9828 (ucHeaderOffset + ucHeaderLen + extraHeadSpace),
9829 *pusPktLen, extraHeadSpace));
9830 }/* if peek MAC success*/
9831
9832}/* WLANTL_PrepareBDHeader */
9833#endif
9834
Jeff Johnson295189b2012-06-20 16:38:30 -07009835//THIS IS A HACK AND NEEDS TO BE FIXED FOR CONCURRENCY
9836/*==========================================================================
9837 FUNCTION WLAN_TLGetNextTxIds
9838
9839 DESCRIPTION
9840 Gets the next station and next AC in the list that should be served by the TL.
9841
9842 Multiple Station Scheduling and TL queue management.
9843
9844 4 HDD BC/MC data packet queue status is specified as Station 0's status. Weights used
9845 in WFQ algorith are initialized in WLANTL_OPEN and contained in tlConfigInfo field.
9846 Each station has fields of ucPktPending and AC mask to tell whether a AC has traffic
9847 or not.
9848
9849 Stations are served in a round-robin fashion from highest priority to lowest priority.
9850 The number of round-robin times of each prioirty equals to the WFQ weights and differetiates
9851 the traffic of different prioirty. As such, stations can not provide low priority packets if
9852 high priority packets are all served.
9853
9854 DEPENDENCIES
9855
9856 PARAMETERS
9857
9858 IN
9859 pvosGCtx: pointer to the global vos context; a handle to TL's
9860 control block can be extracted from its context
9861
9862 OUT
9863 pucSTAId: Station ID
9864
9865 RETURN VALUE
9866 The result code associated with performing the operation
9867
9868 VOS_STATUS_SUCCESS: Everything is good
9869
9870 SIDE EFFECTS
9871
9872 TL context contains currently served station ID in ucCurrentSTA field, currently served AC
9873 in uCurServedAC field, and unserved weights of current AC in uCurLeftWeight.
9874 When existing from the function, these three fields are changed accordingly.
9875
9876============================================================================*/
9877VOS_STATUS
9878WLAN_TLAPGetNextTxIds
9879(
9880 v_PVOID_t pvosGCtx,
9881 v_U8_t* pucSTAId
9882)
9883{
9884 WLANTL_CbType* pTLCb;
9885 v_U8_t ucACFilter = 1;
9886 v_U8_t ucNextSTA ;
9887 v_BOOL_t isServed = TRUE; //current round has find a packet or not
9888 v_U8_t ucACLoopNum = WLANTL_AC_VO + 1; //number of loop to go
9889 v_U8_t uFlowMask; // TX FlowMask from WDA
9890 uint8 ucACMask;
Gopichand Nakkala96237bc2013-01-04 12:20:29 -08009891 uint8 i = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07009892 /*------------------------------------------------------------------------
9893 Extract TL control block
9894 ------------------------------------------------------------------------*/
9895 //ENTER();
9896
9897 pTLCb = VOS_GET_TL_CB(pvosGCtx);
9898 if ( NULL == pTLCb )
9899 {
9900 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9901 "WLAN TL:Invalid TL pointer from pvosGCtx on WLAN_TLAPGetNextTxIds"));
9902 return VOS_STATUS_E_FAULT;
9903 }
9904
9905 if ( VOS_STATUS_SUCCESS != WDA_DS_GetTxFlowMask( pvosGCtx, &uFlowMask ) )
9906 {
9907 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9908 "WLAN TL:Failed to retrieve Flow control mask from WDA"));
9909 return VOS_STATUS_E_FAULT;
9910 }
9911
9912 ucNextSTA = pTLCb->ucCurrentSTA;
9913
9914 ++ucNextSTA;
9915
9916 if ( WLAN_MAX_STA_COUNT <= ucNextSTA )
9917 {
9918 //one round is done.
9919 ucNextSTA = 0;
9920 pTLCb->ucCurLeftWeight--;
9921 isServed = FALSE;
9922 if ( 0 == pTLCb->ucCurLeftWeight )
9923 {
9924 //current prioirty is done
9925 if ( WLANTL_AC_BK == (WLANTL_ACEnumType)pTLCb->uCurServedAC )
9926 {
9927 //end of current VO, VI, BE, BK loop. Reset priority.
9928 pTLCb->uCurServedAC = WLANTL_AC_VO;
9929 }
9930 else
9931 {
9932 pTLCb->uCurServedAC --;
9933 }
9934
9935 pTLCb->ucCurLeftWeight = pTLCb->tlConfigInfo.ucAcWeights[pTLCb->uCurServedAC];
9936
9937 } // (0 == pTLCb->ucCurLeftWeight)
9938 } //( WLAN_MAX_STA_COUNT == ucNextSTA )
9939
9940 //decide how many loops to go. if current loop is partial, do one extra to make sure
9941 //we cover every station
9942 if ((1 == pTLCb->ucCurLeftWeight) && (ucNextSTA != 0))
9943 {
9944 ucACLoopNum ++; // now is 5 loops
9945 }
9946
9947 /* Start with highest priority. ucNextSTA, pTLCb->uCurServedAC, pTLCb->ucCurLeftWeight
9948 all have previous values.*/
9949 for (; ucACLoopNum > 0; ucACLoopNum--)
9950 {
9951
9952 ucACFilter = 1 << pTLCb->uCurServedAC;
9953
9954 // pTLCb->ucCurLeftWeight keeps previous results.
9955 for (; (pTLCb->ucCurLeftWeight > 0) && (uFlowMask & ucACFilter); pTLCb->ucCurLeftWeight-- )
9956 {
9957
9958 for ( ; ucNextSTA < WLAN_MAX_STA_COUNT; ucNextSTA ++ )
9959 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309960 if(NULL == pTLCb->atlSTAClients[ucNextSTA])
9961 {
9962 continue;
9963 }
9964 WLAN_TL_AC_ARRAY_2_MASK (pTLCb->atlSTAClients[ucNextSTA], ucACMask, i);
Jeff Johnson295189b2012-06-20 16:38:30 -07009965
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309966 if ( (0 == pTLCb->atlSTAClients[ucNextSTA]->ucExists) ||
9967 ((0 == pTLCb->atlSTAClients[ucNextSTA]->ucPktPending) && !(ucACMask)) ||
Jeff Johnson295189b2012-06-20 16:38:30 -07009968 (0 == (ucACMask & ucACFilter)) )
9969
9970 {
Tushnim Bhattacharyya39a8f182013-02-20 18:10:30 -08009971 //current station does not exist or have any packet to serve.
9972 continue;
9973 }
9974
9975 if (WLANTL_STA_AUTHENTICATED != pTLCb->atlSTAClients[ucNextSTA]->tlState)
9976 {
9977 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
9978 "%s Sta %d not in auth state so skipping it.",
9979 __func__, ucNextSTA));
Jeff Johnson295189b2012-06-20 16:38:30 -07009980 continue;
9981 }
9982
9983 //go to next station if current station can't send due to flow control
9984 //Station is allowed to send when it is not in LWM mode. When station is in LWM mode,
9985 //station is allowed to send only after FW reports FW memory is below threshold and on-fly
9986 //packets are less then allowed value
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309987 if ( (TRUE == pTLCb->atlSTAClients[ucNextSTA]->ucLwmModeEnabled) &&
9988 ((FALSE == pTLCb->atlSTAClients[ucNextSTA]->ucLwmEventReported) ||
9989 (0 < pTLCb->atlSTAClients[ucNextSTA]->uBuffThresholdMax))
Jeff Johnson295189b2012-06-20 16:38:30 -07009990 )
9991 {
9992 continue;
9993 }
9994
9995
9996 // Find a station. Weight is updated already.
9997 *pucSTAId = ucNextSTA;
9998 pTLCb->ucCurrentSTA = ucNextSTA;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309999 pTLCb->atlSTAClients[*pucSTAId]->ucCurrentAC = pTLCb->uCurServedAC;
Jeff Johnson295189b2012-06-20 16:38:30 -070010000
10001 TLLOG4(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_LOW,
10002 " TL serve one station AC: %d W: %d StaId: %d",
10003 pTLCb->uCurServedAC, pTLCb->ucCurLeftWeight, pTLCb->ucCurrentSTA ));
10004
10005 return VOS_STATUS_SUCCESS;
10006 } //STA loop
10007
10008 ucNextSTA = 0;
10009 if ( FALSE == isServed )
10010 {
10011 //current loop finds no packet.no need to repeat for the same priority
10012 break;
10013 }
10014 //current loop is partial loop. go for one more loop.
10015 isServed = FALSE;
10016
10017 } //Weight loop
10018
10019 if (WLANTL_AC_BK == pTLCb->uCurServedAC)
10020 {
10021 pTLCb->uCurServedAC = WLANTL_AC_VO;
10022 }
10023 else
10024 {
10025 pTLCb->uCurServedAC--;
10026 }
10027 pTLCb->ucCurLeftWeight = pTLCb->tlConfigInfo.ucAcWeights[pTLCb->uCurServedAC];
10028
10029 }// AC loop
10030
10031 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
10032 " TL can't find one station to serve \n" ));
10033
10034 pTLCb->uCurServedAC = WLANTL_AC_BK;
10035 pTLCb->ucCurLeftWeight = 1;
10036 //invalid number will be captured by caller
10037 pTLCb->ucCurrentSTA = WLAN_MAX_STA_COUNT;
10038
10039 *pucSTAId = pTLCb->ucCurrentSTA;
Jeff Johnson295189b2012-06-20 16:38:30 -070010040 return VOS_STATUS_E_FAULT;
10041}
10042
10043
10044/*==========================================================================
10045 FUNCTION WLAN_TLGetNextTxIds
10046
10047 DESCRIPTION
10048 Gets the next station and next AC in the list
10049
10050 DEPENDENCIES
10051
10052 PARAMETERS
10053
10054 IN
10055 pvosGCtx: pointer to the global vos context; a handle to TL's
10056 control block can be extracted from its context
10057
10058 OUT
10059 pucSTAId: Station ID
10060
10061
10062 RETURN VALUE
10063 The result code associated with performing the operation
10064
10065 VOS_STATUS_SUCCESS: Everything is good :)
10066
10067 SIDE EFFECTS
10068
10069============================================================================*/
10070VOS_STATUS
10071WLAN_TLGetNextTxIds
10072(
10073 v_PVOID_t pvosGCtx,
10074 v_U8_t* pucSTAId
10075)
10076{
10077 WLANTL_CbType* pTLCb;
10078 v_U8_t ucNextAC;
10079 v_U8_t ucNextSTA;
10080 v_U8_t ucCount;
10081 v_U8_t uFlowMask; // TX FlowMask from WDA
10082 v_U8_t ucACMask = 0;
10083 v_U8_t i = 0;
10084
10085 tBssSystemRole systemRole; //RG HACK to be removed
10086 tpAniSirGlobal pMac;
10087
10088 pMac = vos_get_context(VOS_MODULE_ID_PE, pvosGCtx);
10089 if ( NULL == pMac )
10090 {
10091 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070010092 "%s: Invalid pMac", __func__));
Jeff Johnson295189b2012-06-20 16:38:30 -070010093 return VOS_STATUS_E_FAULT;
10094 }
10095
10096 systemRole = wdaGetGlobalSystemRole(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -070010097
Jeff Johnson295189b2012-06-20 16:38:30 -070010098 /*------------------------------------------------------------------------
10099 Extract TL control block
10100 ------------------------------------------------------------------------*/
10101 pTLCb = VOS_GET_TL_CB(pvosGCtx);
10102 if ( NULL == pTLCb )
10103 {
10104 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
10105 "WLAN TL:Invalid TL pointer from pvosGCtx on WLAN_TLGetNextTxIds"));
10106 return VOS_STATUS_E_FAULT;
10107 }
10108
Sunil Ravid5406f22013-01-22 00:18:31 -080010109#ifdef FEATURE_WLAN_TDLS
10110 if ((eSYSTEM_AP_ROLE == systemRole) || (vos_concurrent_sessions_running()) || pTLCb->ucTdlsPeerCount)
10111#else
10112 if ((eSYSTEM_AP_ROLE == systemRole) || (vos_concurrent_sessions_running()))
10113#endif
10114 {
10115 return WLAN_TLAPGetNextTxIds(pvosGCtx,pucSTAId);
10116 }
10117
10118
Jeff Johnson295189b2012-06-20 16:38:30 -070010119 if ( VOS_STATUS_SUCCESS != WDA_DS_GetTxFlowMask( pvosGCtx, &uFlowMask ) )
10120 {
10121 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
10122 "WLAN TL:Failed to retrieve Flow control mask from WDA"));
10123 return VOS_STATUS_E_FAULT;
10124 }
10125
10126 /*STA id - no priority yet implemented */
10127 /*-----------------------------------------------------------------------
10128 Choose the next STA for tx - for now go in a round robin fashion
10129 through all the stations that have pending packets
10130 -------------------------------------------------------------------------*/
10131 ucNextSTA = pTLCb->ucCurrentSTA;
10132
10133 pTLCb->ucCurrentSTA = WLAN_MAX_STA_COUNT;
10134 for ( ucCount = 0;
10135 ucCount < WLAN_MAX_STA_COUNT;
10136 ucCount++ )
10137 {
10138 ucNextSTA = ( (ucNextSTA+1) >= WLAN_MAX_STA_COUNT )?0:(ucNextSTA+1);
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053010139 if(NULL == pTLCb->atlSTAClients[ucNextSTA])
10140 {
10141 continue;
10142 }
10143 if (( pTLCb->atlSTAClients[ucNextSTA]->ucExists ) &&
10144 ( pTLCb->atlSTAClients[ucNextSTA]->ucPktPending ))
Jeff Johnson295189b2012-06-20 16:38:30 -070010145 {
Tushnim Bhattacharyya39a8f182013-02-20 18:10:30 -080010146 if (WLANTL_STA_AUTHENTICATED == pTLCb->atlSTAClients[ucNextSTA]->tlState)
10147 {
10148 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
10149 "STA ID: %d on WLAN_TLGetNextTxIds", *pucSTAId));
10150 pTLCb->ucCurrentSTA = ucNextSTA;
10151 break;
Tushnim Bhattacharyya5dd94562013-03-20 20:15:03 -070010152 }
10153 else
10154 {
Tushnim Bhattacharyya39a8f182013-02-20 18:10:30 -080010155 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
10156 "%s Sta %d is not in auth state, skipping this sta.",
10157 __func__, ucNextSTA));
Tushnim Bhattacharyya5dd94562013-03-20 20:15:03 -070010158 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010159 }
10160 }
10161
10162 *pucSTAId = pTLCb->ucCurrentSTA;
10163
10164 if ( WLANTL_STA_ID_INVALID( *pucSTAId ) )
10165 {
10166 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
10167 "WLAN TL:No station registered with TL at this point"));
10168
10169 return VOS_STATUS_E_FAULT;
10170
10171 }
10172
10173 /*Convert the array to a mask for easier operation*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053010174 WLAN_TL_AC_ARRAY_2_MASK( pTLCb->atlSTAClients[*pucSTAId], ucACMask, i);
Jeff Johnson295189b2012-06-20 16:38:30 -070010175
10176 if ( 0 == ucACMask )
10177 {
10178 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
10179 "WLAN TL: Mask 0 "
10180 "STA ID: %d on WLAN_TLGetNextTxIds", *pucSTAId));
10181
10182 /*setting STA id to invalid if mask is 0*/
10183 *pucSTAId = WLAN_MAX_STA_COUNT;
10184
10185 return VOS_STATUS_E_FAULT;
10186 }
10187
10188 /*-----------------------------------------------------------------------
10189 AC is updated whenever a packet is fetched from HDD -> the current
10190 weight of such an AC cannot be 0 -> in this case TL is expected to
10191 exit this function at this point during the main Tx loop
10192 -----------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053010193 if ( 0 < pTLCb->atlSTAClients[*pucSTAId]->ucCurrentWeight )
Jeff Johnson295189b2012-06-20 16:38:30 -070010194 {
10195 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
10196 "WLAN TL: Maintaining serviced AC to: %d for Weight: %d",
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053010197 pTLCb->atlSTAClients[*pucSTAId]->ucCurrentAC ,
10198 pTLCb->atlSTAClients[*pucSTAId]->ucCurrentWeight));
Jeff Johnson295189b2012-06-20 16:38:30 -070010199 return VOS_STATUS_SUCCESS;
10200 }
10201
10202 /*-----------------------------------------------------------------------
10203 Choose highest priority AC - !!! optimize me
10204 -----------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053010205 ucNextAC = pTLCb->atlSTAClients[*pucSTAId]->ucCurrentAC;
Jeff Johnson295189b2012-06-20 16:38:30 -070010206 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
10207 "Next AC: %d", ucNextAC));
10208
10209 while ( 0 != ucACMask )
10210 {
10211 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
10212 " AC Mask: %d Next: %d Res : %d",
10213 ucACMask, ( 1 << ucNextAC ), ( ucACMask & ( 1 << ucNextAC ))));
10214
10215 if ( 0 != ( ucACMask & ( 1 << ucNextAC ) & uFlowMask ))
10216 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053010217 pTLCb->atlSTAClients[*pucSTAId]->ucCurrentAC =
Jeff Johnson295189b2012-06-20 16:38:30 -070010218 (WLANTL_ACEnumType)ucNextAC;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053010219 pTLCb->atlSTAClients[*pucSTAId]->ucCurrentWeight =
Jeff Johnson295189b2012-06-20 16:38:30 -070010220 pTLCb->tlConfigInfo.ucAcWeights[ucNextAC];
10221
10222 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
10223 "WLAN TL: Switching serviced AC to: %d with Weight: %d",
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053010224 pTLCb->atlSTAClients[*pucSTAId]->ucCurrentAC ,
10225 pTLCb->atlSTAClients[*pucSTAId]->ucCurrentWeight));
Jeff Johnson295189b2012-06-20 16:38:30 -070010226 break;
10227 }
10228
10229 ucNextAC = ( ucNextAC - 1 ) & WLANTL_MASK_AC;
10230
10231 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
10232 "Next AC %d", ucNextAC));
10233
10234 }
10235
10236 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
10237 " C AC: %d C W: %d",
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053010238 pTLCb->atlSTAClients[*pucSTAId]->ucCurrentAC,
10239 pTLCb->atlSTAClients[*pucSTAId]->ucCurrentWeight));
Jeff Johnson295189b2012-06-20 16:38:30 -070010240
10241 return VOS_STATUS_SUCCESS;
10242}/* WLAN_TLGetNextTxIds */
10243
Jeff Johnson295189b2012-06-20 16:38:30 -070010244
10245
10246/*==========================================================================
10247 DEFAULT HANDLERS: Registered at initialization with TL
10248 ==========================================================================*/
10249
10250/*==========================================================================
10251
10252 FUNCTION WLANTL_MgmtFrmRxDefaultCb
10253
10254 DESCRIPTION
10255 Default Mgmt Frm rx callback: asserts all the time. If this function gets
10256 called it means there is no registered rx cb pointer for Mgmt Frm.
10257
10258 DEPENDENCIES
10259
10260 PARAMETERS
10261 Not used.
10262
10263 RETURN VALUE
10264
10265 VOS_STATUS_E_FAILURE: Always FAILURE.
10266
10267============================================================================*/
10268VOS_STATUS
10269WLANTL_MgmtFrmRxDefaultCb
10270(
10271 v_PVOID_t pvosGCtx,
10272 v_PVOID_t vosBuff
10273)
10274{
10275 if ( NULL != vosBuff )
10276 {
10277 TLLOGP(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_FATAL,
10278 "WLAN TL:Fatal failure: No registered Mgmt Frm client on pkt RX"));
10279 /* Drop packet */
10280 vos_pkt_return_packet((vos_pkt_t *)vosBuff);
10281 }
10282
Jeff Johnson295189b2012-06-20 16:38:30 -070010283 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
10284 "WLAN TL: No registered Mgmt Frm client on pkt RX. Load/Unload in progress, Ignore"));
Jeff Johnson295189b2012-06-20 16:38:30 -070010285
10286 return VOS_STATUS_E_FAILURE;
10287}/*WLANTL_MgmtFrmRxDefaultCb*/
10288
10289/*==========================================================================
10290
10291 FUNCTION WLANTL_STARxDefaultCb
10292
10293 DESCRIPTION
10294 Default BAP rx callback: asserts all the time. If this function gets
10295 called it means there is no registered rx cb pointer for BAP.
10296
10297 DEPENDENCIES
10298
10299 PARAMETERS
10300 Not used.
10301
10302 RETURN VALUE
10303
10304 VOS_STATUS_E_FAILURE: Always FAILURE.
10305
10306============================================================================*/
10307VOS_STATUS
10308WLANTL_BAPRxDefaultCb
10309(
10310 v_PVOID_t pvosGCtx,
10311 vos_pkt_t* vosDataBuff,
10312 WLANTL_BAPFrameEnumType frameType
10313)
10314{
10315 TLLOGP(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_FATAL,
10316 "WLAN TL:Fatal failure: No registered BAP client on BAP pkt RX"));
10317#ifndef BTAMP_TEST
10318 VOS_ASSERT(0);
10319#endif
10320 return VOS_STATUS_E_FAILURE;
10321}/*WLANTL_MgmtFrmRxDefaultCb*/
10322
10323/*==========================================================================
10324
10325 FUNCTION WLANTL_STARxDefaultCb
10326
10327 DESCRIPTION
10328 Default STA rx callback: asserts all the time. If this function gets
10329 called it means there is no registered rx cb pointer for station.
10330 (Mem corruption most likely, it should never happen)
10331
10332 DEPENDENCIES
10333
10334 PARAMETERS
10335 Not used.
10336
10337 RETURN VALUE
10338
10339 VOS_STATUS_E_FAILURE: Always FAILURE.
10340
10341============================================================================*/
10342VOS_STATUS
10343WLANTL_STARxDefaultCb
10344(
10345 v_PVOID_t pvosGCtx,
10346 vos_pkt_t* vosDataBuff,
10347 v_U8_t ucSTAId,
10348 WLANTL_RxMetaInfoType* pRxMetaInfo
10349)
10350{
10351 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
10352 "WLAN TL: No registered STA client rx cb for STAID: %d dropping pkt",
10353 ucSTAId));
10354 vos_pkt_return_packet(vosDataBuff);
10355 return VOS_STATUS_E_FAILURE;
10356}/*WLANTL_MgmtFrmRxDefaultCb*/
10357
10358
10359/*==========================================================================
10360
10361 FUNCTION WLANTL_STAFetchPktDefaultCb
10362
10363 DESCRIPTION
10364 Default fetch callback: asserts all the time. If this function gets
10365 called it means there is no registered fetch cb pointer for station.
10366 (Mem corruption most likely, it should never happen)
10367
10368 DEPENDENCIES
10369
10370 PARAMETERS
10371 Not used.
10372
10373 RETURN VALUE
10374
10375 VOS_STATUS_E_FAILURE: Always FAILURE.
10376
10377============================================================================*/
10378VOS_STATUS
10379WLANTL_STAFetchPktDefaultCb
10380(
10381 v_PVOID_t pvosGCtx,
10382 v_U8_t* pucSTAId,
10383 WLANTL_ACEnumType ucAC,
10384 vos_pkt_t** vosDataBuff,
10385 WLANTL_MetaInfoType* tlMetaInfo
10386)
10387{
10388 TLLOGP(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_FATAL,
10389 "WLAN TL:Fatal failure: No registered STA client on data pkt RX"));
10390 VOS_ASSERT(0);
10391 return VOS_STATUS_E_FAILURE;
10392}/*WLANTL_MgmtFrmRxDefaultCb*/
10393
10394/*==========================================================================
10395
10396 FUNCTION WLANTL_TxCompDefaultCb
10397
10398 DESCRIPTION
10399 Default tx complete handler. It will release the completed pkt to
10400 prevent memory leaks.
10401
10402 PARAMETERS
10403
10404 IN
10405 pvosGCtx: pointer to the global vos context; a handle to
10406 TL/HAL/PE/BAP/HDD control block can be extracted from
10407 its context
10408 vosDataBuff: pointer to the VOSS data buffer that was transmitted
10409 wTxSTAtus: status of the transmission
10410
10411
10412 RETURN VALUE
10413 The result code associated with performing the operation; please
10414 check vos_pkt_return_packet for possible error codes.
10415
10416 Please check vos_pkt_return_packet API for possible return values.
10417
10418============================================================================*/
10419VOS_STATUS
10420WLANTL_TxCompDefaultCb
10421(
10422 v_PVOID_t pvosGCtx,
10423 vos_pkt_t* vosDataBuff,
10424 VOS_STATUS wTxSTAtus
10425)
10426{
10427 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
10428 "WLAN TL:TXComp not registered, releasing pkt to prevent mem leak"));
10429 return vos_pkt_return_packet(vosDataBuff);
10430}/*WLANTL_TxCompDefaultCb*/
10431
10432
10433/*==========================================================================
10434 Cleanup functions
10435 ==========================================================================*/
10436
10437/*==========================================================================
10438
10439 FUNCTION WLANTL_CleanCB
10440
10441 DESCRIPTION
10442 Cleans TL control block
10443
10444 DEPENDENCIES
10445
10446 PARAMETERS
10447
10448 IN
10449 pTLCb: pointer to TL's control block
10450 ucEmpty: set if TL has to clean up the queues and release pedning pkts
10451
10452 RETURN VALUE
10453 The result code associated with performing the operation
10454
10455 VOS_STATUS_E_INVAL: invalid input parameters
10456 VOS_STATUS_SUCCESS: Everything is good :)
10457
10458 SIDE EFFECTS
10459
10460============================================================================*/
10461VOS_STATUS
10462WLANTL_CleanCB
10463(
10464 WLANTL_CbType* pTLCb,
10465 v_U8_t ucEmpty
10466)
10467{
10468 v_U8_t ucIndex;
10469 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
10470
10471 /*-------------------------------------------------------------------------
10472 Sanity check
10473 -------------------------------------------------------------------------*/
10474 if ( NULL == pTLCb )
10475 {
10476 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
10477 "WLAN TL:Invalid parameter sent on WLANTL_CleanCB"));
10478 return VOS_STATUS_E_INVAL;
10479 }
10480
10481 /* number of packets sent to BAL waiting for tx complete confirmation */
10482 pTLCb->usPendingTxCompleteCount = 0;
10483
10484 /* global suspend flag */
10485 vos_atomic_set_U8( &pTLCb->ucTxSuspended, 1);
10486
10487 /* resource flag */
10488 pTLCb->uResCount = 0;
10489
10490
10491 /*-------------------------------------------------------------------------
10492 Client stations
10493 -------------------------------------------------------------------------*/
10494 for ( ucIndex = 0; ucIndex < WLAN_MAX_STA_COUNT ; ucIndex++)
10495 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053010496 if(NULL != pTLCb->atlSTAClients[ucIndex])
10497 {
10498 WLANTL_CleanSTA( pTLCb->atlSTAClients[ucIndex], ucEmpty);
10499 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010500 }
10501
10502 /*-------------------------------------------------------------------------
10503 Management Frame client
10504 -------------------------------------------------------------------------*/
10505 pTLCb->tlMgmtFrmClient.ucExists = 0;
10506
10507 if ( ( 0 != ucEmpty) &&
10508 ( NULL != pTLCb->tlMgmtFrmClient.vosPendingDataBuff ))
10509 {
10510 vos_pkt_return_packet(pTLCb->tlMgmtFrmClient.vosPendingDataBuff);
10511 }
10512
10513 pTLCb->tlMgmtFrmClient.vosPendingDataBuff = NULL;
10514
10515 /* set to a default cb in order to prevent constant checking for NULL */
10516 pTLCb->tlMgmtFrmClient.pfnTlMgmtFrmRx = WLANTL_MgmtFrmRxDefaultCb;
10517
10518 /*-------------------------------------------------------------------------
10519 BT AMP client
10520 -------------------------------------------------------------------------*/
10521 pTLCb->tlBAPClient.ucExists = 0;
10522
10523 if (( 0 != ucEmpty) &&
10524 ( NULL != pTLCb->tlBAPClient.vosPendingDataBuff ))
10525 {
10526 vos_pkt_return_packet(pTLCb->tlBAPClient.vosPendingDataBuff);
10527 }
10528
10529 if (( 0 != ucEmpty) &&
10530 ( NULL != pTLCb->vosDummyBuf ))
10531 {
10532 vos_pkt_return_packet(pTLCb->vosDummyBuf);
10533 }
10534
10535 pTLCb->tlBAPClient.vosPendingDataBuff = NULL;
10536
10537 pTLCb->vosDummyBuf = NULL;
10538 pTLCb->vosTempBuf = NULL;
10539 pTLCb->ucCachedSTAId = WLAN_MAX_STA_COUNT;
10540
10541 /* set to a default cb in order to prevent constant checking for NULL */
10542 pTLCb->tlBAPClient.pfnTlBAPRx = WLANTL_BAPRxDefaultCb;
10543
10544 pTLCb->ucRegisteredStaId = WLAN_MAX_STA_COUNT;
10545
10546 return VOS_STATUS_SUCCESS;
10547
10548}/* WLANTL_CleanCB*/
10549
10550/*==========================================================================
10551
10552 FUNCTION WLANTL_CleanSTA
10553
10554 DESCRIPTION
10555 Cleans a station control block.
10556
10557 DEPENDENCIES
10558
10559 PARAMETERS
10560
10561 IN
10562 pvosGCtx: pointer to the global vos context; a handle to TL's
10563 control block can be extracted from its context
10564 ucEmpty: if set the queues and pending pkts will be emptyed
10565
10566 RETURN VALUE
10567 The result code associated with performing the operation
10568
10569 VOS_STATUS_E_INVAL: invalid input parameters
10570 VOS_STATUS_SUCCESS: Everything is good :)
10571
10572 SIDE EFFECTS
10573
10574============================================================================*/
10575VOS_STATUS
10576WLANTL_CleanSTA
10577(
10578 WLANTL_STAClientType* ptlSTAClient,
10579 v_U8_t ucEmpty
10580)
10581{
10582 v_U8_t ucIndex;
10583 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
10584
10585 /*-------------------------------------------------------------------------
10586 Sanity check
10587 -------------------------------------------------------------------------*/
10588 if ( NULL == ptlSTAClient )
10589 {
10590 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
10591 "WLAN TL:Invalid parameter sent on WLANTL_CleanSTA"));
10592 return VOS_STATUS_E_INVAL;
10593 }
10594
10595 /*------------------------------------------------------------------------
10596 Clear station from TL
10597 ------------------------------------------------------------------------*/
10598 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
10599 "WLAN TL: Clearing STA Client ID: %d, Empty flag: %d",
10600 ptlSTAClient->wSTADesc.ucSTAId, ucEmpty ));
10601
10602 ptlSTAClient->pfnSTARx = WLANTL_STARxDefaultCb;
10603 ptlSTAClient->pfnSTATxComp = WLANTL_TxCompDefaultCb;
10604 ptlSTAClient->pfnSTAFetchPkt = WLANTL_STAFetchPktDefaultCb;
10605
10606 ptlSTAClient->tlState = WLANTL_STA_INIT;
10607 ptlSTAClient->tlPri = WLANTL_STA_PRI_NORMAL;
10608
10609 vos_zero_macaddr( &ptlSTAClient->wSTADesc.vSTAMACAddress );
10610 vos_zero_macaddr( &ptlSTAClient->wSTADesc.vBSSIDforIBSS );
10611 vos_zero_macaddr( &ptlSTAClient->wSTADesc.vSelfMACAddress );
10612
10613 ptlSTAClient->wSTADesc.ucSTAId = 0;
10614 ptlSTAClient->wSTADesc.wSTAType = WLAN_STA_MAX;
10615
10616 ptlSTAClient->wSTADesc.ucQosEnabled = 0;
10617 ptlSTAClient->wSTADesc.ucAddRmvLLC = 0;
10618 ptlSTAClient->wSTADesc.ucSwFrameTXXlation = 0;
10619 ptlSTAClient->wSTADesc.ucSwFrameRXXlation = 0;
10620 ptlSTAClient->wSTADesc.ucProtectedFrame = 0;
10621
10622 /*-------------------------------------------------------------------------
10623 AMSDU information for the STA
10624 -------------------------------------------------------------------------*/
10625 if ( ( 0 != ucEmpty ) &&
10626 ( NULL != ptlSTAClient->vosAMSDUChainRoot ))
10627 {
Madan Mohan Koyyalamudic0e5bd82012-09-18 17:12:27 -070010628 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_FATAL,
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +053010629 "WLAN TL:Non NULL vosAMSDUChainRoot (=%p) on WLANTL_CleanSTA,"
Madan Mohan Koyyalamudic0e5bd82012-09-18 17:12:27 -070010630 "suspecting a memory corruption"));
10631
Jeff Johnson295189b2012-06-20 16:38:30 -070010632 }
10633
10634 ptlSTAClient->vosAMSDUChain = NULL;
10635 ptlSTAClient->vosAMSDUChainRoot = NULL;
10636
10637 vos_mem_zero( (v_PVOID_t)ptlSTAClient->aucMPDUHeader,
10638 WLANTL_MPDU_HEADER_LEN);
10639 ptlSTAClient->ucMPDUHeaderLen = 0;
10640
10641 /*-------------------------------------------------------------------------
10642 Reordering information for the STA
10643 -------------------------------------------------------------------------*/
10644 for ( ucIndex = 0; ucIndex < WLAN_MAX_TID ; ucIndex++)
10645 {
10646 if(0 == ptlSTAClient->atlBAReorderInfo[ucIndex].ucExists)
10647 {
10648 continue;
10649 }
10650 if(NULL != ptlSTAClient->atlBAReorderInfo[ucIndex].reorderBuffer)
10651 {
10652 ptlSTAClient->atlBAReorderInfo[ucIndex].reorderBuffer->isAvailable = VOS_TRUE;
10653 memset(&ptlSTAClient->atlBAReorderInfo[ucIndex].reorderBuffer->arrayBuffer[0], 0, WLANTL_MAX_WINSIZE * sizeof(v_PVOID_t));
10654 }
10655 vos_timer_destroy(&ptlSTAClient->atlBAReorderInfo[ucIndex].agingTimer);
10656 memset(&ptlSTAClient->atlBAReorderInfo[ucIndex], 0, sizeof(WLANTL_BAReorderType));
10657 }
10658
10659 /*-------------------------------------------------------------------------
10660 QOS information for the STA
10661 -------------------------------------------------------------------------*/
10662 ptlSTAClient->ucCurrentAC = WLANTL_AC_VO;
10663 ptlSTAClient->ucCurrentWeight = 0;
10664 ptlSTAClient->ucServicedAC = WLANTL_AC_BK;
10665
10666 vos_mem_zero( ptlSTAClient->aucACMask, sizeof(ptlSTAClient->aucACMask));
10667 vos_mem_zero( &ptlSTAClient->wUAPSDInfo, sizeof(ptlSTAClient->wUAPSDInfo));
10668
10669
10670 /*--------------------------------------------------------------------
10671 Stats info
10672 --------------------------------------------------------------------*/
10673 vos_mem_zero( ptlSTAClient->auRxCount,
10674 sizeof(ptlSTAClient->auRxCount[0])* WLAN_MAX_TID);
10675 vos_mem_zero( ptlSTAClient->auTxCount,
10676 sizeof(ptlSTAClient->auTxCount[0])* WLAN_MAX_TID);
10677 ptlSTAClient->rssiAvg = 0;
10678
10679 /*Tx not suspended and station fully registered*/
10680 vos_atomic_set_U8( &ptlSTAClient->ucTxSuspended, 0);
10681 vos_atomic_set_U8( &ptlSTAClient->ucNoMoreData, 1);
10682
10683 if ( 0 == ucEmpty )
10684 {
10685 ptlSTAClient->wSTADesc.ucUcastSig = WLAN_TL_INVALID_U_SIG;
10686 ptlSTAClient->wSTADesc.ucBcastSig = WLAN_TL_INVALID_B_SIG;
10687 }
10688
10689 ptlSTAClient->ucExists = 0;
10690
10691 /*--------------------------------------------------------------------
10692 Statistics info
10693 --------------------------------------------------------------------*/
10694 memset(&ptlSTAClient->trafficStatistics,
10695 0,
10696 sizeof(WLANTL_TRANSFER_STA_TYPE));
10697
10698 /*fix me!!: add new values from the TL Cb for cleanup */
10699 return VOS_STATUS_SUCCESS;
10700}/* WLANTL_CleanSTA */
10701
10702
10703/*==========================================================================
10704 FUNCTION WLANTL_EnableUAPSDForAC
10705
10706 DESCRIPTION
10707 Called by HDD to enable UAPSD. TL in turn calls WDA API to enable the
10708 logic in FW/SLM to start sending trigger frames. Previously TL had the
10709 trigger frame logic which later moved down to FW. Hence
10710 HDD -> TL -> WDA -> FW call flow.
10711
10712 DEPENDENCIES
10713 The TL must be initialized before this function can be called.
10714
10715 PARAMETERS
10716
10717 IN
10718 pvosGCtx: pointer to the global vos context; a handle to TL's
10719 control block can be extracted from its context
10720 ucSTAId: station Id
10721 ucAC: AC for which U-APSD is being enabled
10722 ucTid: TID for which U-APSD is setup
10723 ucUP: used to place in the trigger frame generation
10724 ucServiceInt: service interval used by TL to send trigger frames
10725 ucSuspendInt: suspend interval used by TL to determine that an
10726 app is idle and should start sending trigg frms less often
10727 wTSDir: direction of TSpec
10728
10729 RETURN VALUE
10730 The result code associated with performing the operation
10731
10732 VOS_STATUS_SUCCESS: Everything is good :)
10733
10734 SIDE EFFECTS
10735
10736============================================================================*/
10737VOS_STATUS
10738WLANTL_EnableUAPSDForAC
10739(
10740 v_PVOID_t pvosGCtx,
10741 v_U8_t ucSTAId,
10742 WLANTL_ACEnumType ucAC,
10743 v_U8_t ucTid,
10744 v_U8_t ucUP,
10745 v_U32_t uServiceInt,
10746 v_U32_t uSuspendInt,
10747 WLANTL_TSDirType wTSDir
10748)
10749{
10750
10751 WLANTL_CbType* pTLCb = NULL;
10752 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
10753 tUapsdInfo halUAPSDInfo;
10754 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
10755
10756 /*------------------------------------------------------------------------
10757 Sanity check
10758 Extract TL control block
10759 ------------------------------------------------------------------------*/
10760 pTLCb = VOS_GET_TL_CB(pvosGCtx);
10761 if (( NULL == pTLCb ) || WLANTL_STA_ID_INVALID( ucSTAId )
Gopichand Nakkala574f6d12013-06-27 19:38:43 +053010762 || WLANTL_AC_INVALID(ucAC))
Jeff Johnson295189b2012-06-20 16:38:30 -070010763 {
10764 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
10765 "WLAN TL:Invalid input params on WLANTL_EnableUAPSDForAC"
Gopichand Nakkala574f6d12013-06-27 19:38:43 +053010766 " TL: %p STA: %d AC: %d",
10767 pTLCb, ucSTAId, ucAC));
Jeff Johnson295189b2012-06-20 16:38:30 -070010768 return VOS_STATUS_E_FAULT;
10769 }
10770
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053010771 if ( NULL == pTLCb->atlSTAClients[ucSTAId] )
10772 {
10773 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
10774 "WLAN TL:Client Memory was not allocated on %s", __func__));
10775 return VOS_STATUS_E_FAILURE;
10776 }
10777
Jeff Johnson295189b2012-06-20 16:38:30 -070010778 /*Set this flag in order to remember that this is a trigger enabled AC*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053010779 pTLCb->atlSTAClients[ucSTAId]->wUAPSDInfo[ucAC].ucSet = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -070010780
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053010781#ifdef FEATURE_WLAN_TDLS
10782 if(pTLCb->atlSTAClients[ucSTAId]->wSTADesc.wSTAType != WLAN_STA_TDLS)
10783#endif
10784 {
10785 if( 0 == uServiceInt )
10786 {
10787 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
10788 "WLAN TL:Invalid input params on WLANTL_EnableUAPSDForAC"
10789 " SI: %d", uServiceInt ));
10790 return VOS_STATUS_E_FAULT;
10791 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010792
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053010793 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
10794 "WLAN TL:Enabling U-APSD in FW for STA: %d AC: %d SI: %d SPI: %d "
10795 "DI: %d",
10796 ucSTAId, ucAC, uServiceInt, uSuspendInt,
10797 pTLCb->tlConfigInfo.uDelayedTriggerFrmInt));
Jeff Johnson295189b2012-06-20 16:38:30 -070010798
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053010799 /*Save all info for HAL*/
10800 halUAPSDInfo.staidx = ucSTAId;
10801 halUAPSDInfo.ac = ucAC;
10802 halUAPSDInfo.up = ucUP;
10803 halUAPSDInfo.srvInterval = uServiceInt;
10804 halUAPSDInfo.susInterval = uSuspendInt;
10805 halUAPSDInfo.delayInterval = pTLCb->tlConfigInfo.uDelayedTriggerFrmInt;
10806
10807 /*Notify HAL*/
10808 vosStatus = WDA_EnableUapsdAcParams(pvosGCtx, ucSTAId, &halUAPSDInfo);
10809 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010810 return vosStatus;
10811
10812}/*WLANTL_EnableUAPSDForAC*/
10813
10814
10815/*==========================================================================
10816 FUNCTION WLANTL_DisableUAPSDForAC
10817
10818 DESCRIPTION
10819 Called by HDD to disable UAPSD. TL in turn calls WDA API to disable the
10820 logic in FW/SLM to stop sending trigger frames. Previously TL had the
10821 trigger frame logic which later moved down to FW. Hence
10822 HDD -> TL -> WDA -> FW call flow.
10823
10824 DEPENDENCIES
10825 The TL must be initialized before this function can be called.
10826
10827 PARAMETERS
10828
10829 IN
10830 pvosGCtx: pointer to the global vos context; a handle to TL's
10831 control block can be extracted from its context
10832 ucSTAId: station Id
10833 ucAC: AC for which U-APSD is being enabled
10834
10835
10836 RETURN VALUE
10837 The result code associated with performing the operation
10838
10839 VOS_STATUS_SUCCESS: Everything is good :)
10840
10841 SIDE EFFECTS
10842
10843============================================================================*/
10844VOS_STATUS
10845WLANTL_DisableUAPSDForAC
10846(
10847 v_PVOID_t pvosGCtx,
10848 v_U8_t ucSTAId,
10849 WLANTL_ACEnumType ucAC
10850)
10851{
10852 WLANTL_CbType* pTLCb;
10853 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
10854
10855 /*------------------------------------------------------------------------
10856 Sanity check
10857 Extract TL control block
10858 ------------------------------------------------------------------------*/
10859 pTLCb = VOS_GET_TL_CB(pvosGCtx);
10860 if (( NULL == pTLCb ) || WLANTL_STA_ID_INVALID( ucSTAId )
10861 || WLANTL_AC_INVALID(ucAC) )
10862 {
10863 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
10864 "WLAN TL:Invalid input params on WLANTL_DisableUAPSDForAC"
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +053010865 " TL: %p STA: %d AC: %d", pTLCb, ucSTAId, ucAC ));
Jeff Johnson295189b2012-06-20 16:38:30 -070010866 return VOS_STATUS_E_FAULT;
10867 }
10868
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053010869 if ( NULL == pTLCb->atlSTAClients[ucSTAId] )
10870 {
10871 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
10872 "WLAN TL:Client Memory was not allocated on %s", __func__));
10873 return VOS_STATUS_E_FAILURE;
10874 }
10875
Jeff Johnson295189b2012-06-20 16:38:30 -070010876 /*Reset this flag as this is no longer a trigger enabled AC*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053010877 pTLCb->atlSTAClients[ucSTAId]->wUAPSDInfo[ucAC].ucSet = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -070010878
10879 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
10880 "WLAN TL:Disabling U-APSD in FW for STA: %d AC: %d ",
10881 ucSTAId, ucAC));
10882
10883 /*Notify HAL*/
10884 WDA_DisableUapsdAcParams(pvosGCtx, ucSTAId, ucAC);
10885
10886 return VOS_STATUS_SUCCESS;
10887}/* WLANTL_DisableUAPSDForAC */
10888
10889#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
10890/*==========================================================================
10891 FUNCTION WLANTL_RegRSSIIndicationCB
10892
10893 DESCRIPTION Registration function to get notification if RSSI cross
10894 threshold.
10895 Client should register threshold, direction, and notification
10896 callback function pointer
10897
10898 DEPENDENCIES NONE
10899
10900 PARAMETERS in pAdapter - Global handle
10901 in rssiValue - RSSI threshold value
10902 in triggerEvent - Cross direction should be notified
10903 UP, DOWN, and CROSS
10904 in crossCBFunction - Notification CB Function
10905 in usrCtxt - user context
10906
10907 RETURN VALUE VOS_STATUS
10908
10909 SIDE EFFECTS NONE
10910
10911============================================================================*/
10912VOS_STATUS WLANTL_RegRSSIIndicationCB
10913(
10914 v_PVOID_t pAdapter,
10915 v_S7_t rssiValue,
10916 v_U8_t triggerEvent,
10917 WLANTL_RSSICrossThresholdCBType crossCBFunction,
10918 VOS_MODULE_ID moduleID,
10919 v_PVOID_t usrCtxt
10920)
10921{
10922 VOS_STATUS status = VOS_STATUS_SUCCESS;
10923
10924 status = WLANTL_HSRegRSSIIndicationCB(pAdapter,
10925 rssiValue,
10926 triggerEvent,
10927 crossCBFunction,
10928 moduleID,
10929 usrCtxt);
10930
10931 return status;
10932}
10933
10934/*==========================================================================
10935 FUNCTION WLANTL_DeregRSSIIndicationCB
10936
10937 DESCRIPTION Remove specific threshold from list
10938
10939 DEPENDENCIES NONE
10940
10941 PARAMETERS in pAdapter - Global handle
10942 in rssiValue - RSSI threshold value
10943 in triggerEvent - Cross direction should be notified
10944 UP, DOWN, and CROSS
10945
10946 RETURN VALUE VOS_STATUS
10947
10948 SIDE EFFECTS NONE
10949
10950============================================================================*/
10951VOS_STATUS WLANTL_DeregRSSIIndicationCB
10952(
10953 v_PVOID_t pAdapter,
10954 v_S7_t rssiValue,
10955 v_U8_t triggerEvent,
10956 WLANTL_RSSICrossThresholdCBType crossCBFunction,
10957 VOS_MODULE_ID moduleID
10958)
10959{
10960 VOS_STATUS status = VOS_STATUS_SUCCESS;
10961
10962 status = WLANTL_HSDeregRSSIIndicationCB(pAdapter,
10963 rssiValue,
10964 triggerEvent,
10965 crossCBFunction,
10966 moduleID);
10967 return status;
10968}
10969
10970/*==========================================================================
10971 FUNCTION WLANTL_SetAlpha
10972
10973 DESCRIPTION ALPLA is weight value to calculate AVG RSSI
10974 avgRSSI = (ALPHA * historyRSSI) + ((10 - ALPHA) * newRSSI)
10975 avgRSSI has (ALPHA * 10)% of history RSSI weight and
10976 (10 - ALPHA)% of newRSSI weight
10977 This portion is dynamically configurable.
10978 Default is ?
10979
10980 DEPENDENCIES NONE
10981
10982 PARAMETERS in pAdapter - Global handle
10983 in valueAlpah - ALPHA
10984
10985 RETURN VALUE VOS_STATUS
10986
10987 SIDE EFFECTS NONE
10988
10989============================================================================*/
10990VOS_STATUS WLANTL_SetAlpha
10991(
10992 v_PVOID_t pAdapter,
10993 v_U8_t valueAlpha
10994)
10995{
10996 VOS_STATUS status = VOS_STATUS_SUCCESS;
10997
10998 status = WLANTL_HSSetAlpha(pAdapter, valueAlpha);
10999 return status;
11000}
11001
11002/*==========================================================================
11003
11004 FUNCTION
11005
11006 DESCRIPTION
11007
11008 PARAMETERS
11009
11010 RETURN VALUE
11011
11012============================================================================*/
11013VOS_STATUS WLANTL_BMPSRSSIRegionChangedNotification
11014(
11015 v_PVOID_t pAdapter,
11016 tpSirRSSINotification pRSSINotification
11017)
11018{
11019 VOS_STATUS status = VOS_STATUS_SUCCESS;
11020
11021 status = WLANTL_HSBMPSRSSIRegionChangedNotification(pAdapter, pRSSINotification);
11022 return status;
11023}
11024
11025/*==========================================================================
11026 FUNCTION WLANTL_RegGetTrafficStatus
11027
11028 DESCRIPTION Registration function for traffic status monitoring
11029 During measure period count data frames.
11030 If frame count is larger then IDLE threshold set as traffic ON
11031 or OFF.
11032 And traffic status is changed send report to client with
11033 registered callback function
11034
11035 DEPENDENCIES NONE
11036
11037 PARAMETERS in pAdapter - Global handle
11038 in idleThreshold - Traffic on or off threshold
11039 in measurePeriod - Traffic state check period
11040 in trfficStatusCB - traffic status changed notification
11041 CB function
11042 in usrCtxt - user context
11043
11044 RETURN VALUE VOS_STATUS
11045
11046 SIDE EFFECTS NONE
11047
11048============================================================================*/
11049VOS_STATUS WLANTL_RegGetTrafficStatus
11050(
11051 v_PVOID_t pAdapter,
11052 v_U32_t idleThreshold,
11053 v_U32_t measurePeriod,
11054 WLANTL_TrafficStatusChangedCBType trfficStatusCB,
11055 v_PVOID_t usrCtxt
11056)
11057{
11058 VOS_STATUS status = VOS_STATUS_SUCCESS;
11059
11060 status = WLANTL_HSRegGetTrafficStatus(pAdapter,
11061 idleThreshold,
11062 measurePeriod,
11063 trfficStatusCB,
11064 usrCtxt);
11065 return status;
11066}
11067#endif
11068/*==========================================================================
11069 FUNCTION WLANTL_GetStatistics
11070
11071 DESCRIPTION Get traffic statistics for identified station
11072
11073 DEPENDENCIES NONE
11074
11075 PARAMETERS in pAdapter - Global handle
11076 in statType - specific statistics field to reset
11077 out statBuffer - traffic statistics buffer
11078
11079 RETURN VALUE VOS_STATUS
11080
11081 SIDE EFFECTS NONE
11082
11083============================================================================*/
11084VOS_STATUS WLANTL_GetStatistics
11085(
11086 v_PVOID_t pAdapter,
11087 WLANTL_TRANSFER_STA_TYPE *statBuffer,
11088 v_U8_t STAid
11089)
11090{
11091 WLANTL_CbType *pTLCb = VOS_GET_TL_CB(pAdapter);
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053011092 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070011093 VOS_STATUS status = VOS_STATUS_SUCCESS;
11094 WLANTL_TRANSFER_STA_TYPE *statistics = NULL;
11095
11096 /*------------------------------------------------------------------------
11097 Sanity check
11098 Extract TL control block
11099 ------------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053011100 if ( NULL == pTLCb )
Jeff Johnson295189b2012-06-20 16:38:30 -070011101 {
11102 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11103 "WLAN TL:Invalid TL pointer on WLANTL_GetStatistics"));
11104 return VOS_STATUS_E_FAULT;
11105 }
11106
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053011107 pClientSTA = pTLCb->atlSTAClients[STAid];
11108
11109 if ( NULL == pClientSTA )
11110 {
11111 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11112 "WLAN TL:Client Memory was not allocated on %s", __func__));
11113 return VOS_STATUS_E_FAILURE;
11114 }
11115
11116 if(0 == pClientSTA->ucExists)
Jeff Johnson295189b2012-06-20 16:38:30 -070011117 {
11118 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11119 "WLAN TL: %d STA ID does not exist", STAid));
11120 return VOS_STATUS_E_INVAL;
11121 }
11122
11123 if(NULL == statBuffer)
11124 {
11125 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11126 "WLAN TL:Invalid TL statistics buffer pointer on WLANTL_GetStatistics"));
11127 return VOS_STATUS_E_INVAL;
11128 }
11129
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053011130 statistics = &pClientSTA->trafficStatistics;
Jeff Johnson295189b2012-06-20 16:38:30 -070011131 memcpy(statBuffer, statistics, sizeof(WLANTL_TRANSFER_STA_TYPE));
11132
11133 return status;
11134}
11135
11136/*==========================================================================
11137 FUNCTION WLANTL_ResetStatistics
11138
11139 DESCRIPTION Reset statistics structure for identified station ID
11140 Reset means set values as 0
11141
11142 DEPENDENCIES NONE
11143
11144 PARAMETERS in pAdapter - Global handle
11145 in statType - specific statistics field to reset
11146
11147 RETURN VALUE VOS_STATUS
11148
11149 SIDE EFFECTS NONE
11150
11151============================================================================*/
11152VOS_STATUS WLANTL_ResetStatistics
11153(
11154 v_PVOID_t pAdapter,
11155 v_U8_t STAid
11156)
11157{
11158 WLANTL_CbType *pTLCb = VOS_GET_TL_CB(pAdapter);
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053011159 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070011160 VOS_STATUS status = VOS_STATUS_SUCCESS;
11161 WLANTL_TRANSFER_STA_TYPE *statistics = NULL;
11162
11163 /*------------------------------------------------------------------------
11164 Sanity check
11165 Extract TL control block
11166 ------------------------------------------------------------------------*/
11167 if (NULL == pTLCb)
11168 {
11169 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11170 "WLAN TL:Invalid TL pointer on WLANTL_GetStatistics"));
11171 return VOS_STATUS_E_FAULT;
11172 }
11173
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053011174 pClientSTA = pTLCb->atlSTAClients[STAid];
11175
11176 if ( NULL == pClientSTA )
11177 {
11178 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11179 "WLAN TL:Client Memory was not allocated on %s", __func__));
11180 return VOS_STATUS_E_FAILURE;
11181 }
11182
11183 if(0 == pClientSTA->ucExists)
Jeff Johnson295189b2012-06-20 16:38:30 -070011184 {
11185 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11186 "WLAN TL: %d STA ID does not exist", STAid));
11187 return VOS_STATUS_E_INVAL;
11188 }
11189
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053011190 statistics = &pClientSTA->trafficStatistics;
Jeff Johnson295189b2012-06-20 16:38:30 -070011191 vos_mem_zero((v_VOID_t *)statistics, sizeof(WLANTL_TRANSFER_STA_TYPE));
11192
11193 return status;
11194}
11195
11196/*==========================================================================
11197 FUNCTION WLANTL_GetSpecStatistic
11198
11199 DESCRIPTION Get specific field within statistics structure for
11200 identified station ID
11201
11202 DEPENDENCIES NONE
11203
11204 PARAMETERS in pAdapter - Global handle
11205 in statType - specific statistics field to reset
11206 in STAid - Station ID
11207 out buffer - Statistic value
11208
11209 RETURN VALUE VOS_STATUS
11210
11211 SIDE EFFECTS NONE
11212
11213============================================================================*/
11214VOS_STATUS WLANTL_GetSpecStatistic
11215(
11216 v_PVOID_t pAdapter,
11217 WLANTL_TRANSFER_STATIC_TYPE statType,
11218 v_U32_t *buffer,
11219 v_U8_t STAid
11220)
11221{
11222 WLANTL_CbType *pTLCb = VOS_GET_TL_CB(pAdapter);
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053011223 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070011224 VOS_STATUS status = VOS_STATUS_SUCCESS;
11225 WLANTL_TRANSFER_STA_TYPE *statistics = NULL;
11226
11227 /*------------------------------------------------------------------------
11228 Sanity check
11229 Extract TL control block
11230 ------------------------------------------------------------------------*/
11231 if (NULL == pTLCb)
11232 {
11233 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11234 "WLAN TL:Invalid TL pointer on WLANTL_GetStatistics"));
11235 return VOS_STATUS_E_FAULT;
11236 }
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053011237 pClientSTA = pTLCb->atlSTAClients[STAid];
Jeff Johnson295189b2012-06-20 16:38:30 -070011238
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053011239 if ( NULL == pClientSTA )
11240 {
11241 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11242 "WLAN TL:Client Memory was not allocated on %s", __func__));
11243 return VOS_STATUS_E_FAILURE;
11244 }
11245
11246 if(0 == pClientSTA->ucExists)
Jeff Johnson295189b2012-06-20 16:38:30 -070011247 {
11248 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11249 "WLAN TL: %d STA ID does not exist", STAid));
11250 return VOS_STATUS_E_INVAL;
11251 }
11252
11253 if(NULL == buffer)
11254 {
11255 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11256 "WLAN TL:Invalid TL statistic buffer pointer on WLANTL_GetStatistics"));
11257 return VOS_STATUS_E_INVAL;
11258 }
11259
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053011260 statistics = &pClientSTA->trafficStatistics;
Jeff Johnson295189b2012-06-20 16:38:30 -070011261 switch(statType)
11262 {
11263 case WLANTL_STATIC_TX_UC_FCNT:
11264 *buffer = statistics->txUCFcnt;
11265 break;
11266
11267 case WLANTL_STATIC_TX_MC_FCNT:
11268 *buffer = statistics->txMCFcnt;
11269 break;
11270
11271 case WLANTL_STATIC_TX_BC_FCNT:
11272 *buffer = statistics->txBCFcnt;
11273 break;
11274
11275 case WLANTL_STATIC_TX_UC_BCNT:
11276 *buffer = statistics->txUCBcnt;
11277 break;
11278
11279 case WLANTL_STATIC_TX_MC_BCNT:
11280 *buffer = statistics->txMCBcnt;
11281 break;
11282
11283 case WLANTL_STATIC_TX_BC_BCNT:
11284 *buffer = statistics->txBCBcnt;
11285 break;
11286
11287 case WLANTL_STATIC_RX_UC_FCNT:
11288 *buffer = statistics->rxUCFcnt;
11289 break;
11290
11291 case WLANTL_STATIC_RX_MC_FCNT:
11292 *buffer = statistics->rxMCFcnt;
11293 break;
11294
11295 case WLANTL_STATIC_RX_BC_FCNT:
11296 *buffer = statistics->rxBCFcnt;
11297 break;
11298
11299 case WLANTL_STATIC_RX_UC_BCNT:
11300 *buffer = statistics->rxUCBcnt;
11301 break;
11302
11303 case WLANTL_STATIC_RX_MC_BCNT:
11304 *buffer = statistics->rxMCBcnt;
11305 break;
11306
11307 case WLANTL_STATIC_RX_BC_BCNT:
11308 *buffer = statistics->rxBCBcnt;
11309 break;
11310
11311 case WLANTL_STATIC_RX_BCNT:
11312 *buffer = statistics->rxBcnt;
11313 break;
11314
11315 case WLANTL_STATIC_RX_BCNT_CRC_OK:
11316 *buffer = statistics->rxBcntCRCok;
11317 break;
11318
11319 case WLANTL_STATIC_RX_RATE:
11320 *buffer = statistics->rxRate;
11321 break;
11322
11323 default:
11324 *buffer = 0;
11325 status = VOS_STATUS_E_INVAL;
11326 break;
11327 }
11328
11329
11330 return status;
11331}
11332
11333/*==========================================================================
11334 FUNCTION WLANTL_ResetSpecStatistic
11335
11336 DESCRIPTION Reset specific field within statistics structure for
11337 identified station ID
11338 Reset means set as 0
11339
11340 DEPENDENCIES NONE
11341
11342 PARAMETERS in pAdapter - Global handle
11343 in statType - specific statistics field to reset
11344 in STAid - Station ID
11345
11346 RETURN VALUE VOS_STATUS
11347
11348 SIDE EFFECTS NONE
11349
11350============================================================================*/
11351VOS_STATUS WLANTL_ResetSpecStatistic
11352(
11353 v_PVOID_t pAdapter,
11354 WLANTL_TRANSFER_STATIC_TYPE statType,
11355 v_U8_t STAid
11356)
11357{
11358 WLANTL_CbType *pTLCb = VOS_GET_TL_CB(pAdapter);
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053011359 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070011360 VOS_STATUS status = VOS_STATUS_SUCCESS;
11361 WLANTL_TRANSFER_STA_TYPE *statistics = NULL;
11362
11363 /*------------------------------------------------------------------------
11364 Sanity check
11365 Extract TL control block
11366 ------------------------------------------------------------------------*/
11367 if (NULL == pTLCb)
11368 {
11369 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11370 "WLAN TL:Invalid TL pointer on WLANTL_GetStatistics"));
11371 return VOS_STATUS_E_FAULT;
11372 }
11373
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053011374 pClientSTA = pTLCb->atlSTAClients[STAid];
11375
11376 if ( NULL == pClientSTA )
11377 {
11378 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11379 "WLAN TL:Client Memory was not allocated on %s", __func__));
11380 return VOS_STATUS_E_FAILURE;
11381 }
11382
11383 if(0 == pClientSTA->ucExists)
Jeff Johnson295189b2012-06-20 16:38:30 -070011384 {
11385 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11386 "WLAN TL: %d STA ID does not exist", STAid));
11387 return VOS_STATUS_E_INVAL;
11388 }
11389
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053011390 statistics = &pClientSTA->trafficStatistics;
Jeff Johnson295189b2012-06-20 16:38:30 -070011391 switch(statType)
11392 {
11393 case WLANTL_STATIC_TX_UC_FCNT:
11394 statistics->txUCFcnt = 0;
11395 break;
11396
11397 case WLANTL_STATIC_TX_MC_FCNT:
11398 statistics->txMCFcnt = 0;
11399 break;
11400
11401 case WLANTL_STATIC_TX_BC_FCNT:
11402 statistics->txBCFcnt = 0;
11403 break;
11404
11405 case WLANTL_STATIC_TX_UC_BCNT:
11406 statistics->txUCBcnt = 0;
11407 break;
11408
11409 case WLANTL_STATIC_TX_MC_BCNT:
11410 statistics->txMCBcnt = 0;
11411 break;
11412
11413 case WLANTL_STATIC_TX_BC_BCNT:
11414 statistics->txBCBcnt = 0;
11415 break;
11416
11417 case WLANTL_STATIC_RX_UC_FCNT:
11418 statistics->rxUCFcnt = 0;
11419 break;
11420
11421 case WLANTL_STATIC_RX_MC_FCNT:
11422 statistics->rxMCFcnt = 0;
11423 break;
11424
11425 case WLANTL_STATIC_RX_BC_FCNT:
11426 statistics->rxBCFcnt = 0;
11427 break;
11428
11429 case WLANTL_STATIC_RX_UC_BCNT:
11430 statistics->rxUCBcnt = 0;
11431 break;
11432
11433 case WLANTL_STATIC_RX_MC_BCNT:
11434 statistics->rxMCBcnt = 0;
11435 break;
11436
11437 case WLANTL_STATIC_RX_BC_BCNT:
11438 statistics->rxBCBcnt = 0;
11439 break;
11440
11441 case WLANTL_STATIC_RX_BCNT:
11442 statistics->rxBcnt = 0;
11443 break;
11444
11445 case WLANTL_STATIC_RX_BCNT_CRC_OK:
11446 statistics->rxBcntCRCok = 0;
11447 break;
11448
11449 case WLANTL_STATIC_RX_RATE:
11450 statistics->rxRate = 0;
11451 break;
11452
11453 default:
11454 status = VOS_STATUS_E_INVAL;
11455 break;
11456 }
11457
11458 return status;
11459}
11460
11461
11462/*==========================================================================
11463
11464 FUNCTION
11465
11466 DESCRIPTION Read RSSI value out of a RX BD
11467
11468 PARAMETERS: Caller must validate all parameters
11469
11470 RETURN VALUE
11471
11472============================================================================*/
11473VOS_STATUS WLANTL_ReadRSSI
11474(
11475 v_PVOID_t pAdapter,
11476 v_PVOID_t pBDHeader,
11477 v_U8_t STAid
11478)
11479{
11480 WLANTL_CbType *tlCtxt = VOS_GET_TL_CB(pAdapter);
11481 v_S7_t currentRSSI, currentRSSI0, currentRSSI1;
11482
11483
11484 if(NULL == tlCtxt)
11485 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070011486 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR, "%s Invalid TL handle", __func__));
Jeff Johnson295189b2012-06-20 16:38:30 -070011487 return VOS_STATUS_E_INVAL;
11488 }
11489
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053011490 if ( NULL == tlCtxt->atlSTAClients[STAid] )
11491 {
11492 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11493 "WLAN TL:Client Memory was not allocated on %s", __func__));
11494 return VOS_STATUS_E_FAILURE;
11495 }
11496
Jeff Johnson295189b2012-06-20 16:38:30 -070011497 currentRSSI0 = WLANTL_GETRSSI0(pBDHeader);
11498 currentRSSI1 = WLANTL_GETRSSI1(pBDHeader);
11499 currentRSSI = (currentRSSI0 > currentRSSI1) ? currentRSSI0 : currentRSSI1;
11500
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053011501 tlCtxt->atlSTAClients[STAid]->rssiAvg = currentRSSI;
Jeff Johnson295189b2012-06-20 16:38:30 -070011502
11503 return VOS_STATUS_SUCCESS;
11504}
11505
11506
11507/*
11508 DESCRIPTION
11509 TL returns the weight currently maintained in TL.
11510 IN
11511 pvosGCtx: pointer to the global vos context; a handle to TL's
11512 or SME's control block can be extracted from its context
11513
11514 OUT
11515 pACWeights: Caller allocated memory for filling in weights
11516
11517 RETURN VALUE VOS_STATUS
11518*/
11519VOS_STATUS
11520WLANTL_GetACWeights
11521(
11522 v_PVOID_t pvosGCtx,
11523 v_U8_t* pACWeights
11524)
11525{
11526 WLANTL_CbType* pTLCb = NULL;
11527 v_U8_t ucIndex;
11528 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
11529
11530 /*------------------------------------------------------------------------
11531 Sanity check
11532 ------------------------------------------------------------------------*/
11533 if ( NULL == pACWeights )
11534 {
11535 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11536 "WLAN TL:Invalid parameter sent on WLANTL_GetACWeights"));
11537 return VOS_STATUS_E_INVAL;
11538 }
11539
11540 /*------------------------------------------------------------------------
11541 Extract TL control block and check existance
11542 ------------------------------------------------------------------------*/
11543 pTLCb = VOS_GET_TL_CB(pvosGCtx);
11544 if ( NULL == pTLCb )
11545 {
11546 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11547 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_GetACWeights"));
11548 return VOS_STATUS_E_FAULT;
11549 }
11550 for ( ucIndex = 0; ucIndex < WLANTL_MAX_AC ; ucIndex++)
11551 {
11552 pACWeights[ucIndex] = pTLCb->tlConfigInfo.ucAcWeights[ucIndex];
11553 }
11554
11555 return VOS_STATUS_SUCCESS;
11556}
11557
11558
11559
11560/*
11561 DESCRIPTION
11562 Change the weight currently maintained by TL.
11563 IN
11564 pvosGCtx: pointer to the global vos context; a handle to TL's
11565 or SME's control block can be extracted from its context
11566 pACWeights: Caller allocated memory contain the weights to use
11567
11568
11569 RETURN VALUE VOS_STATUS
11570*/
11571VOS_STATUS
11572WLANTL_SetACWeights
11573(
11574 v_PVOID_t pvosGCtx,
11575 v_U8_t* pACWeights
11576)
11577{
11578 WLANTL_CbType* pTLCb = NULL;
11579 v_U8_t ucIndex;
11580 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
11581
11582 /*------------------------------------------------------------------------
11583 Sanity check
11584 ------------------------------------------------------------------------*/
11585 if ( NULL == pACWeights )
11586 {
11587 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11588 "WLAN TL:Invalid parameter sent on WLANTL_GetACWeights"));
11589 return VOS_STATUS_E_INVAL;
11590 }
11591
11592 /*------------------------------------------------------------------------
11593 Extract TL control block and check existance
11594 ------------------------------------------------------------------------*/
11595 pTLCb = VOS_GET_TL_CB(pvosGCtx);
11596 if ( NULL == pTLCb )
11597 {
11598 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11599 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_GetACWeights"));
11600 return VOS_STATUS_E_FAULT;
11601 }
11602 for ( ucIndex = 0; ucIndex < WLANTL_MAX_AC ; ucIndex++)
11603 {
11604 pTLCb->tlConfigInfo.ucAcWeights[ucIndex] = pACWeights[ucIndex];
11605 }
11606
11607 return VOS_STATUS_SUCCESS;
11608}
11609
11610
11611/*==========================================================================
11612
11613 FUNCTION
11614
11615 DESCRIPTION
11616
11617 PARAMETERS
11618
11619 RETURN VALUE
11620
11621============================================================================*/
11622void WLANTL_PowerStateChangedCB
11623(
11624 v_PVOID_t pAdapter,
11625 tPmcState newState
11626)
11627{
11628 WLANTL_CbType *tlCtxt = VOS_GET_TL_CB(pAdapter);
11629
11630 if (NULL == tlCtxt)
11631 {
11632 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +053011633 "%s: Invalid TL Control Block", __func__ );
Jeff Johnson295189b2012-06-20 16:38:30 -070011634 return;
11635 }
11636
11637 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO, "Power state changed, new state is %d", newState );
11638 switch(newState)
11639 {
11640 case FULL_POWER:
11641 tlCtxt->isBMPS = VOS_FALSE;
11642 break;
11643
11644 case BMPS:
11645#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
11646 WLANTL_SetFWRSSIThresholds(pAdapter);
11647#endif
11648
11649 tlCtxt->isBMPS = VOS_TRUE;
11650 break;
11651
11652 case IMPS:
11653 case LOW_POWER:
11654 case REQUEST_BMPS:
11655 case REQUEST_FULL_POWER:
11656 case REQUEST_IMPS:
11657 case STOPPED:
11658 case REQUEST_START_UAPSD:
11659 case REQUEST_STOP_UAPSD:
11660 case UAPSD:
11661 case REQUEST_STANDBY:
11662 case STANDBY:
11663 case REQUEST_ENTER_WOWL:
11664 case REQUEST_EXIT_WOWL:
11665 case WOWL:
11666 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN, "Not handle this events %d", newState ));
11667 break;
11668
11669 default:
11670 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR, "Not a valid event %d", newState ));
11671 break;
11672 }
11673
11674 return;
11675}
11676/*==========================================================================
11677 FUNCTION WLANTL_GetEtherType
11678
11679 DESCRIPTION Extract Ether type information from the BD
11680
11681 DEPENDENCIES NONE
11682
11683 PARAMETERS in aucBDHeader - BD header
11684 in vosDataBuff - data buffer
11685 in ucMPDUHLen - MPDU header length
11686 out pUsEtherType - pointer to Ethertype
11687
11688 RETURN VALUE VOS_STATUS_SUCCESS : if the EtherType is successfully extracted
11689 VOS_STATUS_FAILURE : if the EtherType extraction failed and
11690 the packet was dropped
11691
11692 SIDE EFFECTS NONE
11693
11694============================================================================*/
11695static VOS_STATUS WLANTL_GetEtherType
11696(
11697 v_U8_t * aucBDHeader,
11698 vos_pkt_t * vosDataBuff,
11699 v_U8_t ucMPDUHLen,
11700 v_U16_t * pUsEtherType
11701)
11702{
11703 v_U8_t ucOffset;
11704 v_U16_t usEtherType = *pUsEtherType;
11705 v_SIZE_t usLLCSize = sizeof(usEtherType);
11706 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
11707
11708 /*------------------------------------------------------------------------
11709 Check if LLC is present - if not, TL is unable to determine type
11710 ------------------------------------------------------------------------*/
11711 if ( VOS_FALSE == WDA_IS_RX_LLC_PRESENT( aucBDHeader ) )
11712 {
11713 ucOffset = WLANTL_802_3_HEADER_LEN - sizeof(usEtherType);
11714 }
11715 else
11716 {
11717 ucOffset = ucMPDUHLen + WLANTL_LLC_PROTO_TYPE_OFFSET;
11718 }
11719
11720 /*------------------------------------------------------------------------
11721 Extract LLC type
11722 ------------------------------------------------------------------------*/
11723 vosStatus = vos_pkt_extract_data( vosDataBuff, ucOffset,
11724 (v_PVOID_t)&usEtherType, &usLLCSize);
11725
11726 if (( VOS_STATUS_SUCCESS != vosStatus ) ||
11727 ( sizeof(usEtherType) != usLLCSize ))
11728
11729 {
11730 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11731 "WLAN TL:Error extracting Ether type from data packet"));
11732 /* Drop packet */
11733 vos_pkt_return_packet(vosDataBuff);
11734 vosStatus = VOS_STATUS_E_FAILURE;
11735 }
11736 else
11737 {
11738 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
11739 "WLAN TL:Ether type retrieved before endianess conv: %d",
11740 usEtherType));
11741
11742 usEtherType = vos_be16_to_cpu(usEtherType);
11743 *pUsEtherType = usEtherType;
11744
11745 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
11746 "WLAN TL:Ether type retrieved: %d", usEtherType));
11747 }
11748
11749 return vosStatus;
11750}
11751
Jeff Johnson295189b2012-06-20 16:38:30 -070011752/*==========================================================================
11753 FUNCTION WLANTL_GetSoftAPStatistics
11754
11755 DESCRIPTION Collect the cumulative statistics for all Softap stations
11756
11757 DEPENDENCIES NONE
11758
11759 PARAMETERS in pvosGCtx - Pointer to the global vos context
11760 bReset - If set TL statistics will be cleared after reading
11761 out statsSum - pointer to collected statistics
11762
11763 RETURN VALUE VOS_STATUS_SUCCESS : if the Statistics are successfully extracted
11764
11765 SIDE EFFECTS NONE
11766
11767============================================================================*/
11768VOS_STATUS WLANTL_GetSoftAPStatistics(v_PVOID_t pAdapter, WLANTL_TRANSFER_STA_TYPE *statsSum, v_BOOL_t bReset)
11769{
11770 v_U8_t i = 0;
11771 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
11772 WLANTL_CbType *pTLCb = VOS_GET_TL_CB(pAdapter);
11773 WLANTL_TRANSFER_STA_TYPE statBufferTemp;
11774 vos_mem_zero((v_VOID_t *)&statBufferTemp, sizeof(WLANTL_TRANSFER_STA_TYPE));
11775 vos_mem_zero((v_VOID_t *)statsSum, sizeof(WLANTL_TRANSFER_STA_TYPE));
11776
11777
11778 if ( NULL == pTLCb )
11779 {
11780 return VOS_STATUS_E_FAULT;
11781 }
11782
11783 // Sum up all the statistics for stations of Soft AP from TL
11784 for (i = 0; i < WLAN_MAX_STA_COUNT; i++)
11785 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053011786 if ( NULL == pTLCb->atlSTAClients[i])
11787 {
11788 continue;
11789 }
11790 if (pTLCb->atlSTAClients[i]->wSTADesc.wSTAType == WLAN_STA_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -070011791 {
11792 vosStatus = WLANTL_GetStatistics(pAdapter, &statBufferTemp, i);// Can include staId 1 because statistics not collected for it
11793
11794 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
11795 return VOS_STATUS_E_FAULT;
11796
11797 // Add to the counters
11798 statsSum->txUCFcnt += statBufferTemp.txUCFcnt;
11799 statsSum->txMCFcnt += statBufferTemp.txMCFcnt;
11800 statsSum->txBCFcnt += statBufferTemp.txBCFcnt;
11801 statsSum->txUCBcnt += statBufferTemp.txUCBcnt;
11802 statsSum->txMCBcnt += statBufferTemp.txMCBcnt;
11803 statsSum->txBCBcnt += statBufferTemp.txBCBcnt;
11804 statsSum->rxUCFcnt += statBufferTemp.rxUCFcnt;
11805 statsSum->rxMCFcnt += statBufferTemp.rxMCFcnt;
11806 statsSum->rxBCFcnt += statBufferTemp.rxBCFcnt;
11807 statsSum->rxUCBcnt += statBufferTemp.rxUCBcnt;
11808 statsSum->rxMCBcnt += statBufferTemp.rxMCBcnt;
11809 statsSum->rxBCBcnt += statBufferTemp.rxBCBcnt;
11810
11811 if (bReset)
11812 {
11813 vosStatus = WLANTL_ResetStatistics(pAdapter, i);
11814 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
11815 return VOS_STATUS_E_FAULT;
11816 }
11817 }
11818 }
11819
11820 return vosStatus;
11821}
Mohit Khanna698ba2a2012-12-04 15:08:18 -080011822#ifdef FEATURE_WLAN_TDLS_INTERNAL
11823/*==========================================================================
11824 FUNCTION WLANTL_GetEtherType_2
11825
11826 DESCRIPTION Extract Ether type information from the BD
11827
11828 DEPENDENCIES NONE
11829
11830 PARAMETERS in aucBDHeader - BD header
11831 in vosDataBuff - data buffer
11832 in ucMPDUHLen - MPDU header length
11833 out pUsEtherType - pointer to Ethertype
11834
11835 RETURN VALUE VOS_STATUS_SUCCESS : if the EtherType is successfully extracted
11836 VOS_STATUS_FAILURE : if the EtherType extraction failed and
11837 the packet was dropped
11838
11839 SIDE EFFECTS NONE
11840
11841============================================================================*/
11842static VOS_STATUS WLANTL_GetEtherType_2
11843(
11844 v_U8_t * aucBDHeader,
11845 vos_pkt_t * vosDataBuff,
11846 v_U8_t ucMPDUHLen,
11847 v_U16_t * pUsEtherType
11848)
11849{
11850 v_U8_t ucOffset;
11851 v_U16_t usEtherType = *pUsEtherType;
11852 v_SIZE_t usLLCSize = sizeof(usEtherType);
11853 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
11854 //v_U8_t ucLLCHeader;
11855 v_U8_t ucMPDUHOffset ;
11856 /*------------------------------------------------------------------------
11857 Check if LLC is present - if not, TL is unable to determine type
11858 ------------------------------------------------------------------------*/
11859 //ucMPDUHOffset = (v_U8_t)WLANHAL_RX_BD_GET_MPDU_H_OFFSET(aucBDHeader) ;
11860 //ucLLCHeader = (v_U8_t)WLANHAL_RX_BD_GET_LLC(aucBDHeader);
11861 ucMPDUHOffset = (v_U8_t)WDA_GET_RX_MPDU_HEADER_OFFSET(aucBDHeader);
11862
11863 if ( VOS_TRUE == WDA_IS_RX_LLC_PRESENT(aucBDHeader) )
11864 {
11865 ucOffset = ucMPDUHOffset + WLANTL_802_3_HEADER_LEN - sizeof(usEtherType);
11866 }
11867 else
11868 {
11869 ucOffset = WLANHAL_RX_BD_HEADER_SIZE + ucMPDUHLen
11870 + WLANTL_LLC_PROTO_TYPE_OFFSET;
11871 }
11872
11873 /*------------------------------------------------------------------------
11874 Extract LLC type
11875 ------------------------------------------------------------------------*/
11876 vosStatus = vos_pkt_extract_data( vosDataBuff, ucOffset,
11877 (v_PVOID_t)&usEtherType, &usLLCSize);
11878
11879 /* TODO: Do it in better way */
11880 if(vos_be16_to_cpu(usEtherType) == 0x890d)
11881 {
11882 VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11883 ("TDLS frame llc %x \n"), vos_be16_to_cpu(usEtherType)) ;
11884 }
11885
11886 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
11887 "WLAN TL:Ether type retrieved before endianess conv: %d",
11888 usEtherType);
11889
11890 usEtherType = vos_be16_to_cpu(usEtherType);
11891 *pUsEtherType = usEtherType;
11892
11893 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
11894 "WLAN TL:Ether type retrieved: %d", usEtherType);
11895
11896 return vosStatus;
11897}
11898#endif /* FEATURE_WLAN_TDLS */
11899
Jeff Johnson295189b2012-06-20 16:38:30 -070011900/*===============================================================================
11901 FUNCTION WLANTL_IsReplayPacket
11902
11903 DESCRIPTION This function does replay check for valid stations
11904
11905 DEPENDENCIES Validity of replay check must be done before the function
11906 is called
11907
11908 PARAMETERS currentReplayCounter current replay counter taken from RX BD
11909 previousReplayCounter previous replay counter taken from TL CB
11910
11911 RETRUN VOS_TRUE packet is a replay packet
11912 VOS_FALSE packet is not a replay packet
11913
11914 SIDE EFFECTS none
11915 ===============================================================================*/
11916v_BOOL_t
11917WLANTL_IsReplayPacket
11918(
11919 v_U64_t ullcurrentReplayCounter,
11920 v_U64_t ullpreviousReplayCounter
11921)
11922{
11923 /* Do the replay check by comparing previous received replay counter with
11924 current received replay counter*/
11925 if(ullpreviousReplayCounter < ullcurrentReplayCounter)
11926 {
11927 /* Valid packet not replay */
11928 return VOS_FALSE;
11929 }
11930 else
11931 {
11932
11933 /* Current packet number is less than or equal to previuos received
11934 packet no, this means current packet is replay packet */
11935 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11936 "WLAN TL: Replay packet found with replay counter :[0x%llX]",ullcurrentReplayCounter);
11937
11938 return VOS_TRUE;
11939 }
11940}
11941
11942#if 0
11943/*===============================================================================
11944 FUNCTION WLANTL_GetReplayCounterFromRxBD
11945
11946 DESCRIPTION This function extracts 48-bit replay packet number from RX BD
11947
11948 DEPENDENCIES Validity of replay check must be done before the function
11949 is called
11950
11951 PARAMETERS pucRxHeader pointer to RX BD header
11952
11953 RETRUN v_U64_t Packet number extarcted from RX BD
11954
11955 SIDE EFFECTS none
11956 ===============================================================================*/
11957v_U64_t
11958WLANTL_GetReplayCounterFromRxBD
11959(
11960 v_U8_t *pucRxBDHeader
11961)
11962{
11963/* 48-bit replay counter is created as follows
11964 from RX BD 6 byte PMI command:
11965 Addr : AES/TKIP
11966 0x38 : pn3/tsc3
11967 0x39 : pn2/tsc2
11968 0x3a : pn1/tsc1
11969 0x3b : pn0/tsc0
11970
11971 0x3c : pn5/tsc5
11972 0x3d : pn4/tsc4 */
11973
11974#ifdef ANI_BIG_BYTE_ENDIAN
11975 v_U64_t ullcurrentReplayCounter = 0;
11976 /* Getting 48-bit replay counter from the RX BD */
11977 ullcurrentReplayCounter = WLANHAL_RX_BD_GET_PMICMD_20TO23(pucRxBDHeader);
11978 ullcurrentReplayCounter <<= 16;
11979 ullcurrentReplayCounter |= (( WLANHAL_RX_BD_GET_PMICMD_24TO25(pucRxBDHeader) & 0xFFFF0000) >> 16);
11980 return ullcurrentReplayCounter;
11981#else
11982 v_U64_t ullcurrentReplayCounter = 0;
11983 /* Getting 48-bit replay counter from the RX BD */
11984 ullcurrentReplayCounter = (WLANHAL_RX_BD_GET_PMICMD_24TO25(pucRxBDHeader) & 0x0000FFFF);
11985 ullcurrentReplayCounter <<= 32;
11986 ullcurrentReplayCounter |= WLANHAL_RX_BD_GET_PMICMD_20TO23(pucRxBDHeader);
11987 return ullcurrentReplayCounter;
11988#endif
11989}
11990#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070011991
11992/*===============================================================================
11993 FUNCTION WLANTL_PostResNeeded
11994
11995 DESCRIPTION This function posts message to TL to reserve BD/PDU memory
11996
11997 DEPENDENCIES None
11998
11999 PARAMETERS pvosGCtx
12000
12001 RETURN None
12002
12003 SIDE EFFECTS none
12004 ===============================================================================*/
12005
12006void WLANTL_PostResNeeded(v_PVOID_t pvosGCtx)
12007{
12008 vos_msg_t vosMsg;
12009
12010 vosMsg.reserved = 0;
12011 vosMsg.bodyptr = NULL;
12012 vosMsg.type = WLANTL_TX_RES_NEEDED;
12013 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
12014 "WLAN TL: BD/PDU available interrupt received, Posting message to TL");
12015 if(!VOS_IS_STATUS_SUCCESS(vos_tx_mq_serialize( VOS_MQ_ID_TL, &vosMsg)))
12016 {
12017 VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070012018 " %s fails to post message", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070012019 }
12020}
12021
12022/*===============================================================================
12023 FUNCTION WLANTL_UpdateRssiBmps
12024
12025 DESCRIPTION This function updates the TL's RSSI (in BMPS mode)
12026
12027 DEPENDENCIES None
12028
12029 PARAMETERS
12030
12031 pvosGCtx VOS context VOS Global context
12032 staId Station ID Station ID
12033 rssi RSSI (BMPS mode) RSSI in BMPS mode
12034
12035 RETURN None
12036
12037 SIDE EFFECTS none
12038 ===============================================================================*/
12039
12040void WLANTL_UpdateRssiBmps(v_PVOID_t pvosGCtx, v_U8_t staId, v_S7_t rssi)
12041{
12042 WLANTL_CbType* pTLCb = VOS_GET_TL_CB(pvosGCtx);
12043
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053012044 if (NULL != pTLCb && NULL != pTLCb->atlSTAClients[staId])
Jeff Johnson295189b2012-06-20 16:38:30 -070012045 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053012046 pTLCb->atlSTAClients[staId]->rssiAvgBmps = rssi;
Jeff Johnson295189b2012-06-20 16:38:30 -070012047 }
12048}
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053012049
12050/*===============================================================================
12051 FUNCTION WLANTL_UpdateLinkCapacity
12052
12053 DESCRIPTION This function updates the STA's Link Capacity in TL
12054
12055 DEPENDENCIES None
12056
12057 PARAMETERS
12058
12059 pvosGCtx VOS context VOS Global context
12060 staId Station ID Station ID
12061 linkCapacity linkCapacity Link Capacity
12062
12063 RETURN None
12064
12065 SIDE EFFECTS none
12066 ===============================================================================*/
12067
12068void WLANTL_UpdateLinkCapacity(v_PVOID_t pvosGCtx, v_U8_t staId, v_U32_t linkCapacity)
12069{
12070 WLANTL_CbType* pTLCb = VOS_GET_TL_CB(pvosGCtx);
12071
12072 if (NULL != pTLCb && NULL != pTLCb->atlSTAClients[staId])
12073 {
12074 pTLCb->atlSTAClients[staId]->linkCapacity = linkCapacity;
12075 }
12076}
12077
12078
12079/*===========================================================================
12080
12081 FUNCTION WLANTL_GetSTALinkCapacity
12082
12083 DESCRIPTION
12084
12085 Returns Link Capacity of a particular STA.
12086
12087 DEPENDENCIES
12088
12089 A station must have been registered before its state can be retrieved.
12090
12091
12092 PARAMETERS
12093
12094 IN
12095 pvosGCtx: pointer to the global vos context; a handle to TL's
12096 control block can be extracted from its context
12097 ucSTAId: identifier of the station
12098
12099 OUT
12100 plinkCapacity: the current link capacity the connection to
12101 the given station
12102
12103
12104 RETURN VALUE
12105
12106 The result code associated with performing the operation
12107
12108 VOS_STATUS_E_INVAL: Input parameters are invalid
12109 VOS_STATUS_E_FAULT: Station ID is outside array boundaries or pointer to
12110 TL cb is NULL ; access would cause a page fault
12111 VOS_STATUS_E_EXISTS: Station was not registered
12112 VOS_STATUS_SUCCESS: Everything is good :)
12113
12114 SIDE EFFECTS
12115
12116============================================================================*/
12117VOS_STATUS
12118WLANTL_GetSTALinkCapacity
12119(
12120 v_PVOID_t pvosGCtx,
12121 v_U8_t ucSTAId,
12122 v_U32_t *plinkCapacity
12123)
12124{
12125 WLANTL_CbType* pTLCb = NULL;
12126 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
12127
12128 /*------------------------------------------------------------------------
12129 Sanity check
12130 ------------------------------------------------------------------------*/
12131 if ( NULL == plinkCapacity )
12132 {
12133 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
12134 FL("WLAN TL:Invalid parameter")));
12135 return VOS_STATUS_E_INVAL;
12136 }
12137
12138 if ( WLANTL_STA_ID_INVALID( ucSTAId ) )
12139 {
12140 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
12141 FL("WLAN TL:Invalid station id")));
12142 return VOS_STATUS_E_FAULT;
12143 }
12144
12145 /*------------------------------------------------------------------------
12146 Extract TL control block and check existance
12147 ------------------------------------------------------------------------*/
12148 pTLCb = VOS_GET_TL_CB(pvosGCtx);
12149 if ( NULL == pTLCb )
12150 {
12151 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
12152 FL("WLAN TL:Invalid TL pointer from pvosGCtx")));
12153 return VOS_STATUS_E_FAULT;
12154 }
12155
12156 if ( NULL == pTLCb->atlSTAClients[ucSTAId] )
12157 {
12158 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
12159 FL("WLAN TL:Client Memory was not allocated")));
12160 return VOS_STATUS_E_FAILURE;
12161 }
12162
12163 if ( 0 == pTLCb->atlSTAClients[ucSTAId]->ucExists )
12164 {
12165 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
12166 FL("WLAN TL:Station was not previously registered")));
12167 return VOS_STATUS_E_EXISTS;
12168 }
12169
12170 /*------------------------------------------------------------------------
12171 Get STA state
12172 ------------------------------------------------------------------------*/
12173 *plinkCapacity = pTLCb->atlSTAClients[ucSTAId]->linkCapacity;
12174
12175 return VOS_STATUS_SUCCESS;
12176}/* WLANTL_GetSTALinkCapacity */