blob: eebc2d3b744a53a4f6ca24b88a66644056b45665 [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Sravan Kumar Kairam18017eb2017-01-03 14:58:13 +05302 * Copyright (c) 2012-2017 The Linux Foundation. All rights reserved.
Kiet Lam1ed83fc2014-02-19 01:15:45 -08003 *
4 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
5 *
6 *
7 * Permission to use, copy, modify, and/or distribute this software for
8 * any purpose with or without fee is hereby granted, provided that the
9 * above copyright notice and this permission notice appear in all
10 * copies.
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
13 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
14 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
15 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
16 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
17 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
18 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19 * PERFORMANCE OF THIS SOFTWARE.
20 */
21
22/*
Kiet Lama7f454d2014-07-24 12:04:06 -070023 * This file was originally distributed by Qualcomm Atheros, Inc.
24 * under proprietary terms before Copyright ownership was assigned
25 * to the Linux Foundation.
Gopichand Nakkala92f07d82013-01-08 21:16:34 -080026 */
Kiet Lam1ed83fc2014-02-19 01:15:45 -080027
28
Kiet Lama7f454d2014-07-24 12:04:06 -070029
30
Jeff Johnson295189b2012-06-20 16:38:30 -070031/*===========================================================================
32
33
34 W L A N _ Q C T _ T L . C
35
36 OVERVIEW:
37
38 This software unit holds the implementation of the WLAN Transport Layer.
39
40 The functions externalized by this module are to be called ONLY by other
41 WLAN modules that properly register with the Transport Layer initially.
42
43 DEPENDENCIES:
44
45 Are listed for each API below.
46
47
Jeff Johnson295189b2012-06-20 16:38:30 -070048===========================================================================*/
49
50/*===========================================================================
51
52 EDIT HISTORY FOR FILE
53
54
55 This section contains comments describing changes made to the module.
56 Notice that changes are listed in reverse chronological order.
57
58
59 $Header$$DateTime$$Author$
60
61
62 when who what, where, why
63---------- --- --------------------------------------------------------
Abhishek Singh00b71972016-01-07 10:51:04 +0530642013-08-19 rajekuma Added RMC support
Jeff Johnson295189b2012-06-20 16:38:30 -0700652010-07-13 c_shinde Fixed an issue where WAPI rekeying was failing because
66 WAI frame sent out during rekeying had the protected bit
67 set to 1.
682010-05-06 rnair Changed name of variable from usLlcType to usEtherType
69 Changed function name from GetLLCType to GetEtherType
70 Fixed 802.3 to 802.11 frame translation issue where two
71 bytes of the LLC header was getting overwritten in the
72 non-Qos path
732010-05-06 rnair RxAuth path fix for modifying the header before ether
74 type is retreived (Detected while testing rekeying
75 in WAPI Volans)
762010-02-19 bad Fixed 802.11 to 802.3 ft issues with WAPI
772010-02-19 rnair WAPI: If frame is a WAI frame in TxConn and TxAuth, TL
78 does frame translation.
792010-02-01 rnair WAPI: Fixed a bug where the value of ucIsWapiSta was not
80 being set in the TL control block in the RegisterSTA func.
812010-01-08 lti Added TL Data Caching
822009-11-04 rnair WAPI: Moving common functionality to a seperate function
83 called WLANTL_GetLLCType
842009-10-15 rnair WAPI: Featurizing WAPI code
852009-10-09 rnair WAPI: Modifications to authenticated state handling of Rx data
862009-10-06 rnair Adding support for WAPI
872009-09-22 lti Add deregistration API for management client
882009-07-16 rnair Temporary fix to let TL fetch packets when multiple
89 peers exist in an IBSS
902009-06-10 lti Fix for checking TID value of meta info on TX - prevent
91 memory overwrite
92 Fix for properly checking the sta id for resuming trigger
93 frame generation
942009-05-14 lti Fix for sending out trigger frames
952009-05-15 lti Addr3 filtering
962009-04-13 lti Assert if packet larger then allowed
97 Drop packet that fails flatten
982009-04-02 lti Performance fixes for TL
992009-02-19 lti Added fix for LLC management on Rx Connect
1002009-01-16 lti Replaced peek data with extract data for non BD opertions
101 Extracted frame control in Tl and pass to HAL for frame
102 type evaluation
1032009-02-02 sch Add handoff support
1042008-12-09 lti Fixes for AMSS compilation
105 Removed assert on receive when there is no station
1062008-12-02 lti Fix fo trigger frame generation
1072008-10-31 lti Fix fo TL tx suspend
1082008-10-01 lti Merged in fixes from reordering
109 Disabled part of UAPSD functionality in TL
110 (will be re-enabled once UAPSD is tested)
111 Fix for UAPSD multiple enable
1122008-08-10 lti Fixes following UAPSD testing
113 Fixed infinite loop on mask computation when STA no reg
1142008-08-06 lti Fixes after QOS unit testing
1152008-08-06 lti Added QOS support
1162008-07-23 lti Fix for vos packet draining
1172008-07-17 lti Fix for data type value
118 Added frame translation code in TL
119 Avoid returning failure to PE in case previous frame is
120 still pending; fail previous and cache new one for tx
121 Get frames returning boolean true if more frames are pending
1222008-07-03 lti Fixes following pre-integration testing
1232008-06-26 lti Fixes following unit testing
124 Added alloc and free for TL context
125 Using atomic set u8 instead of u32
1262008-05-16 lti Created module
127
128===========================================================================*/
129
130/*----------------------------------------------------------------------------
131 * Include Files
132 * -------------------------------------------------------------------------*/
133#include "wlan_qct_tl.h"
134#include "wlan_qct_wda.h"
135#include "wlan_qct_tli.h"
136#include "wlan_qct_tli_ba.h"
137#include "wlan_qct_tl_hosupport.h"
Katya Nigam42e16e82014-02-04 16:28:55 +0530138#include "vos_types.h"
139#include "vos_trace.h"
140#include "wlan_qct_tl_trace.h"
Jeff Johnson295189b2012-06-20 16:38:30 -0700141#include "tlDebug.h"
Hanumantha Reddy Pothulaee001fc2015-05-26 15:21:53 +0530142#include "cfgApi.h"
Jeff Johnson295189b2012-06-20 16:38:30 -0700143#ifdef FEATURE_WLAN_WAPI
144/*Included to access WDI_RxBdType */
145#include "wlan_qct_wdi_bd.h"
146#endif
147/*Enables debugging behavior in TL*/
148#define TL_DEBUG
Hoonki Lee14621352013-04-16 17:51:19 -0700149/*Enables debugging FC control frame in TL*/
150//#define TL_DEBUG_FC
Jeff Johnson295189b2012-06-20 16:38:30 -0700151//#define WLAN_SOFTAP_FLOWCTRL_EN
Jeff Johnson295189b2012-06-20 16:38:30 -0700152//#define BTAMP_TEST
Hoonki Lee14621352013-04-16 17:51:19 -0700153#ifdef TL_DEBUG_FC
154#include <wlan_qct_pal_status.h>
155#include <wlan_qct_pal_device.h> // wpalReadRegister
156#endif
157
Jeff Johnson295189b2012-06-20 16:38:30 -0700158/*----------------------------------------------------------------------------
159 * Preprocessor Definitions and Constants
160 * -------------------------------------------------------------------------*/
161/*LLC header value*/
162static v_U8_t WLANTL_LLC_HEADER[] = {0xAA, 0xAA, 0x03, 0x00, 0x00, 0x00 };
163
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800164#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -0700165/*Aironet SNAP header value*/
166static v_U8_t WLANTL_AIRONET_SNAP_HEADER[] = {0xAA, 0xAA, 0x03, 0x00, 0x40, 0x96, 0x00, 0x00 };
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800167#endif //FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -0700168
169/*BT-AMP packet LLC OUI value*/
170const v_U8_t WLANTL_BT_AMP_OUI[] = {0x00, 0x19, 0x58 };
171
Dino Mycle3b9536d2014-07-09 22:05:24 +0530172#ifdef WLAN_FEATURE_LINK_LAYER_STATS
173extern const v_U8_t WLANTL_TID_2_AC[WLAN_MAX_TID];
174
175#endif
176
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530177#define WLANTL_MAX_SNR_DATA_SAMPLES 20
Jeff Johnson295189b2012-06-20 16:38:30 -0700178
179#ifdef VOLANS_PERF
180#define WLANTL_BD_PDU_INTERRUPT_ENABLE_THRESHOLD 120
181#define WLANTL_BD_PDU_INTERRUPT_GET_THRESHOLD 120
182
183/* TL BD/PDU threshold to enable interrupt */
184int bdPduInterruptEnableThreshold = WLANTL_BD_PDU_INTERRUPT_ENABLE_THRESHOLD;
185int bdPduInterruptGetThreshold = WLANTL_BD_PDU_INTERRUPT_GET_THRESHOLD;
186#endif /* VOLANS_PERF */
187
188/*-----------------------------------*
189 | Type(2b) | Sub-type(4b) |
190 *-----------------------------------*/
191#define WLANTL_IS_DATA_FRAME(_type_sub) \
192 ( WLANTL_DATA_FRAME_TYPE == ( (_type_sub) & 0x30 ))
193
194#define WLANTL_IS_QOS_DATA_FRAME(_type_sub) \
195 (( WLANTL_DATA_FRAME_TYPE == ( (_type_sub) & 0x30 )) && \
196 ( WLANTL_80211_DATA_QOS_SUBTYPE == ( (_type_sub) & 0xF )))
197
198#define WLANTL_IS_MGMT_FRAME(_type_sub) \
199 ( WLANTL_MGMT_FRAME_TYPE == ( (_type_sub) & 0x30 ))
200
Dino Mycle3b9536d2014-07-09 22:05:24 +0530201#define WLANTL_IS_MGMT_ACTION_FRAME(_type_sub) \
202 (( WLANTL_MGMT_FRAME_TYPE == ( (_type_sub) & 0x30 )) && \
203 ( ( WLANTL_80211_MGMT_ACTION_SUBTYPE == ( (_type_sub) & 0xF )) || \
204 ( WLANTL_80211_MGMT_ACTION_NO_ACK_SUBTYPE == ( (_type_sub) & 0xF ))))
205
Siddharth Bhal4551b102014-10-09 21:36:36 +0530206#define WLANTL_IS_PROBE_REQ(_type_sub) \
207 ( WLANTL_MGMT_PROBE_REQ_FRAME_TYPE == ( (_type_sub) & 0x3F ))
208
Jeff Johnson295189b2012-06-20 16:38:30 -0700209#define WLANTL_IS_CTRL_FRAME(_type_sub) \
210 ( WLANTL_CTRL_FRAME_TYPE == ( (_type_sub) & 0x30 ))
211
Mohit Khanna698ba2a2012-12-04 15:08:18 -0800212#ifdef FEATURE_WLAN_TDLS
213#define WLANTL_IS_TDLS_FRAME(_eth_type) \
214 ( WLANTL_LLC_TDLS_TYPE == ( _eth_type))
215#endif
216
Jeff Johnson295189b2012-06-20 16:38:30 -0700217/*MAX Allowed len processed by TL - MAx MTU + 802.3 header + BD+DXE+XTL*/
Madan Mohan Koyyalamudia53c4dc2012-11-13 10:35:42 -0800218#define WLANTL_MAX_ALLOWED_LEN (1514 + 100)
Jeff Johnson295189b2012-06-20 16:38:30 -0700219
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +0530220#define WLANTL_DATA_FLOW_MASK 0x0F
Jeff Johnson295189b2012-06-20 16:38:30 -0700221
Jeff Johnson295189b2012-06-20 16:38:30 -0700222//some flow_control define
223//LWM mode will be enabled for this station if the egress/ingress falls below this ratio
224#define WLANTL_LWM_EGRESS_INGRESS_THRESHOLD (0.75)
225
226//Get enough sample to do the LWM related calculation
227#define WLANTL_LWM_INGRESS_SAMPLE_THRESHOLD (64)
228
229//Maximal on-fly packet per station in LWM mode
230#define WLANTL_STA_BMU_THRESHOLD_MAX (256)
231
232#define WLANTL_AC_MASK (0x7)
Gopichand Nakkala976e3252013-01-03 15:45:56 -0800233#define WLANTL_STAID_OFFSET (0x6)
Jeff Johnson295189b2012-06-20 16:38:30 -0700234
235/* UINT32 type endian swap */
236#define SWAP_ENDIAN_UINT32(a) ((a) = ((a) >> 0x18 ) |(((a) & 0xFF0000) >> 0x08) | \
237 (((a) & 0xFF00) << 0x08) | (((a) & 0xFF) << 0x18))
238
Madan Mohan Koyyalamudi43acf032013-09-27 04:33:28 +0530239/* Maximum value of SNR that can be calculated by the HW */
240#define WLANTL_MAX_HW_SNR 35
Jeff Johnson295189b2012-06-20 16:38:30 -0700241
Hanumantha Reddy Pothulae5ab23d2015-09-14 18:08:24 +0530242#define DISABLE_ARP_TOGGLE 0
243#define ENABLE_ARP_TOGGLE 1
244#define SEND_ARP_ON_WQ5 2
245
Sravan Kumar Kairamb0edc612016-10-26 13:55:24 +0530246#define WLANTL_RATE_RATIO_THRESHOLD 2
Sravan Kumar Kairam416a0c22017-01-02 22:58:09 +0530247#define WLANTL_PER_THRESHOLD 5
248#define WLANTL_QUEUE_THRESHOLD 60
Sravan Kumar Kairamb0edc612016-10-26 13:55:24 +0530249#define WLANTL_GOOD_STA_WEIGHT 1
Sravan Kumar Kairamd482a2b2017-02-09 17:44:58 +0530250#define WLANTL_WEIGHT_THRESHOLD 50
Sravan Kumar Kairamb0edc612016-10-26 13:55:24 +0530251
Jeff Johnson295189b2012-06-20 16:38:30 -0700252/*----------------------------------------------------------------------------
253 * Type Declarations
254 * -------------------------------------------------------------------------*/
255#define TL_LITTLE_BIT_ENDIAN
256
257typedef struct
258{
259
Jeff Johnson295189b2012-06-20 16:38:30 -0700260
261 v_U8_t protVer :2;
262 v_U8_t type :2;
263 v_U8_t subType :4;
264
265 v_U8_t toDS :1;
266 v_U8_t fromDS :1;
267 v_U8_t moreFrag :1;
268 v_U8_t retry :1;
269 v_U8_t powerMgmt :1;
270 v_U8_t moreData :1;
271 v_U8_t wep :1;
272 v_U8_t order :1;
273
Jeff Johnson295189b2012-06-20 16:38:30 -0700274
275} WLANTL_MACFCType;
276
277/* 802.11 header */
278typedef struct
279{
280 /* Frame control field */
281 WLANTL_MACFCType wFrmCtrl;
282
283 /* Duration ID */
284 v_U16_t usDurationId;
285
286 /* Address 1 field */
287 v_U8_t vA1[VOS_MAC_ADDR_SIZE];
288
289 /* Address 2 field */
290 v_U8_t vA2[VOS_MAC_ADDR_SIZE];
291
292 /* Address 3 field */
293 v_U8_t vA3[VOS_MAC_ADDR_SIZE];
294
295 /* Sequence control field */
296 v_U16_t usSeqCtrl;
297
298 // Find the size of the mandatory header size.
299#define WLAN80211_MANDATORY_HEADER_SIZE \
300 (sizeof(WLANTL_MACFCType) + sizeof(v_U16_t) + \
301 (3 * (sizeof(v_U8_t) * VOS_MAC_ADDR_SIZE)) + \
302 sizeof(v_U16_t))
303
304 /* Optional A4 address */
305 v_U8_t optvA4[VOS_MAC_ADDR_SIZE];
306
307 /* Optional QOS control field */
308 v_U16_t usQosCtrl;
309}WLANTL_80211HeaderType;
310
311/* 802.3 header */
312typedef struct
313{
314 /* Destination address field */
315 v_U8_t vDA[VOS_MAC_ADDR_SIZE];
316
317 /* Source address field */
318 v_U8_t vSA[VOS_MAC_ADDR_SIZE];
319
320 /* Length field */
321 v_U16_t usLenType;
322}WLANTL_8023HeaderType;
323
324/*----------------------------------------------------------------------------
325 * Global Data Definitions
326 * -------------------------------------------------------------------------*/
327#define WLAN_TL_INVALID_U_SIG 255
328#define WLAN_TL_INVALID_B_SIG 255
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +0530329#define ENTER() VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO, "Enter:%s", __func__)
330
Jeff Johnson295189b2012-06-20 16:38:30 -0700331#define WLAN_TL_AC_ARRAY_2_MASK( _pSTA, _ucACMask, i ) \
332 do\
333 {\
334 _ucACMask = 0; \
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +0530335 for ( i = 0; i < WLANTL_NUM_TX_QUEUES; i++ ) \
Jeff Johnson295189b2012-06-20 16:38:30 -0700336 { \
337 if ( 0 != (_pSTA)->aucACMask[i] ) \
338 { \
339 _ucACMask |= ( 1 << i ); \
340 } \
341 } \
342 } while (0);
343
Kapil Guptad90b3862016-06-25 00:42:49 +0530344
345/* Following is the copy of g11bRateInfo to understand rate index at TL */
346#define WLANTL_MAX_RATE_NUM 137
347typedef struct
348{
349 uint32 phyRate; //unit in Mega bits per sec X 10
350 uint32 tputRate; //unit in Mega bits per sec X 10
351 uint32 tputBpms; //unit in Bytes per msec = (tputRateX1024x1024)/(8x10X1000) ~= (tputRate*13)
352 uint32 tputBpus; //unit in Bytes per usec: round off to integral value
353}WLANTL_RateInfo;
354
355WLANTL_RateInfo gTLRateInfo[WLANTL_MAX_RATE_NUM] = {
356 //11b rates
357 { 10, 9, 117, 0}, //index 0
358 { 20, 17, 221, 0}, //index 1
359 { 55, 41, 533, 0}, //index 2
360 { 110, 68, 884, 0}, //index 3
361
362 //11b short preamble
363 { 10, 10, 130, 0}, //index 4
364 { 20, 18, 234, 0}, //index 5
365 { 55, 44, 572, 0}, //index 6
366 { 110, 77, 1001, 0}, //index 7
367
368 //11ag
369 { 60, 50, 650, 1}, //index 8
370 { 90, 70, 910, 1}, //index 9
371 { 120, 100, 1300, 1}, //index 10
372 { 180, 150, 1950, 2}, //index 11
373 { 240, 190, 2470, 2}, //index 12
374 { 360, 280, 3640, 4}, //index 13
375 { 480, 350, 4550, 5}, //index 14
376 { 540, 380, 4940, 6}, //index 15
377
378 //11n SIMO
379 { 65, 54, 702, 1}, //index 16
380 { 130, 108, 1404, 1}, //index 17
381 { 195, 161, 2093, 2}, //index 18
382 { 260, 217, 2821, 3}, //index 19
383 { 390, 326, 4238, 4}, //index 20
384 { 520, 435, 5655, 6}, //index 21
385 { 585, 492, 6396, 6}, //index 22
386 { 650, 548, 7124, 7}, //index 23
387
388 //11n SIMO SGI
389 { 72, 59, 767, 1}, //index 24
390 { 144, 118, 1534, 2}, //index 25
391 { 217, 180, 2340, 2}, //index 26
392 { 289, 243, 3159, 3}, //index 27
393 { 434, 363, 4719, 5}, //index 28
394 { 578, 486, 6318, 6}, //index 29
395 { 650, 548, 7124, 7}, //index 30
396 { 722, 606, 7878, 8}, //index 31
397
398 //11n GF SIMO
399 { 65, 54, 702, 1}, //index 32
400 { 130, 108, 1404, 1}, //index 33
401 { 195, 161, 2093, 2}, //index 34
402 { 260, 217, 2821, 3}, //index 35
403 { 390, 326, 4238, 4}, //index 36
404 { 520, 435, 5655, 6}, //index 37
405 { 585, 492, 6396, 6}, //index 38
406 { 650, 548, 7124, 7}, //index 39
407
408 //11n SIMO CB MCS 0 - 7
409 { 135, 110, 1430, 1}, //index 40
410 { 270, 223, 2899, 3}, //index 41
411 { 405, 337, 4381, 4}, //index 42
412 { 540, 454, 5902, 6}, //index 43
413 { 810, 679, 8827, 9}, //index 44
414 { 1080, 909, 11817, 12}, //index 45
415 { 1215, 1022, 13286, 13}, //index 46
416 { 1350, 1137, 14781, 15}, //index 47
417
418 //11n SIMO CB SGI MCS 0 - 7
419 { 150, 121, 1573, 2}, //index 48
420 { 300, 249, 3237, 3}, //index 49
421 { 450, 378, 4914, 5}, //index 50
422 { 600, 503, 6539, 7}, //index 51
423 { 900, 758, 9854, 10}, //index 52
424 { 1200, 1010, 13130, 13}, //index 53
425 { 1350, 1137, 14781, 15}, //index 54
426 { 1500, 1262, 16406, 16}, //index 55
427
428 //11n SIMO GF CB MCS 0 - 7
429 { 135, 110, 1430, 1}, //index 56
430 { 270, 223, 2899, 3}, //index 57
431 { 405, 337, 4381, 4}, //index 58
432 { 540, 454, 5902, 6}, //index 59
433 { 810, 679, 8827, 9}, //index 60
434 { 1080, 909, 11817, 12}, //index 61
435 { 1215, 1022, 13286, 13}, //index 62
436 { 1350, 1137, 14781, 15}, //index 63
437
438 //11AC
439 { 1350, 675, 8775, 9}, //reserved 64
440 { 1350, 675, 8775, 9}, //reserved 65
441 { 65, 45, 585, 1}, //index 66
442 { 130, 91, 1183, 1}, //index 67
443 { 195, 136, 1768, 2}, //index 68
444 { 260, 182, 2366, 2}, //index 69
445 { 390, 273, 3549, 4}, //index 70
446 { 520, 364, 4732, 5}, //index 71
447 { 585, 409, 5317, 5}, //index 72
448 { 650, 455, 5915, 6}, //index 73
449 { 780, 546, 7098, 7}, //index 74
450 { 1350, 675, 8775, 9}, //reserved 75
451 { 1350, 675, 8775, 9}, //reserved 76
452 { 1350, 675, 8775, 9}, //reserved 77
453 { 1350, 675, 8775, 9}, //index 78
454 { 1350, 675, 8775, 9}, //index 79
455 { 1350, 675, 8775, 9}, //index 80
456 { 1350, 675, 8775, 9}, //index 81
457 { 1350, 675, 8775, 9}, //index 82
458 { 1350, 675, 8775, 9}, //index 83
459 { 655, 458, 5954, 6}, //index 84
460 { 722, 505, 6565, 7}, //index 85
461 { 866, 606, 7878, 8}, //index 86
462 { 1350, 675, 8775, 9}, //reserved 87
463 { 1350, 675, 8775, 9}, //reserved 88
464 { 1350, 675, 8775, 9}, //reserved 89
465 { 135, 94, 1222, 1}, //index 90
466 { 270, 189, 2457, 2}, //index 91
467 { 405, 283, 3679, 4}, //index 92
468 { 540, 378, 4914, 5}, //index 93
469 { 810, 567, 7371, 7}, //index 94
470 { 1080, 756, 9828, 10}, //index 95
471 { 1215, 850, 11050, 11}, //index 96
472 { 1350, 675, 8775, 9}, //index 97
473 { 1350, 675, 8775, 9}, //index 98
474 { 1620, 810, 10530, 11}, //index 99
475 { 1800, 900, 11700, 12}, //index 100
476 { 1350, 675, 8775, 9}, //reserved 101
477 { 1350, 675, 8775, 9}, //index 102
478 { 1350, 675, 8775, 9}, //index 103
479 { 1350, 675, 8775, 9}, //index 104
480 { 1350, 675, 8775, 9}, //index 105
481 { 1350, 675, 8775, 9}, //index 106
482 { 1200, 840, 10920, 11}, //index 107
483 { 1350, 675, 8775, 9}, //index 108
484 { 1500, 750, 9750, 10}, //index 109
485 { 1350, 675, 8775, 9}, //index 110
486 { 1800, 900, 11700, 12}, //index 111
487 { 2000, 1000, 13000, 13}, //index 112
488 { 1350, 675, 8775, 9}, //index 113
489 { 292, 204, 2652, 3}, //index 114
490 { 585, 409, 5317, 5}, //index 115
491 { 877, 613, 7969, 8}, //index 116
492 { 1170, 819, 10647, 11}, //index 117
493 { 1755, 877, 11401, 11}, //index 118
494 { 2340, 1170, 15210, 15}, //index 119
495 { 2632, 1316, 17108, 17}, //index 120
496 { 2925, 1462, 19006, 19}, //index 121
497 { 1350, 675, 8775, 9}, //index 122
498 { 3510, 1755, 22815, 23}, //index 123
499 { 3900, 1950, 25350, 25}, //index 124
500 { 1350, 675, 8775, 9}, //reserved 125
501 { 1350, 675, 8775, 9}, //index 126
502 { 1350, 675, 8775, 9}, //index 127
503 { 1350, 675, 8775, 9}, //index 128
504 { 1350, 675, 8775, 9}, //index 129
505 { 1350, 675, 8775, 9}, //index 130
506 { 1350, 675, 8775, 9}, //index 131
507 { 2925, 1462, 19006, 19}, //index 132
508 { 3250, 1625, 21125, 21}, //index 133
509 { 1350, 675, 8775, 9}, //index 134
510 { 3900, 1950, 25350, 25}, //index 135
511 { 4333, 2166, 28158, 28} //index 136
512 };
513
514
515
Jeff Johnson295189b2012-06-20 16:38:30 -0700516/*----------------------------------------------------------------------------
517 * Static Variable Definitions
518 * -------------------------------------------------------------------------*/
519
520/*----------------------------------------------------------------------------
521 * Static Function Declarations and Definitions
522 * -------------------------------------------------------------------------*/
523
524static VOS_STATUS
525WLANTL_GetEtherType
526(
527 v_U8_t * aucBDHeader,
528 vos_pkt_t * vosDataBuff,
529 v_U8_t ucMPDUHLen,
530 v_U16_t * usEtherType
531);
532
Jeff Johnson295189b2012-06-20 16:38:30 -0700533
534/*----------------------------------------------------------------------------
535 * Externalized Function Definitions
536* -------------------------------------------------------------------------*/
537
538/*----------------------------------------------------------------------------
539 * Function Declarations and Documentation
540 * -------------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +0530541/*==========================================================================
542
543 FUNCTION WLANTL_FreeClientMemory
544
545 DESCRIPTION
546 It frees up the memory allocated to all the STA clients in TLCB block
547 Can be called inside Close, Stop or when some FAULT occurs
548
549 DEPENDENCIES
550
551 PARAMETERS
552
553 IN
554 pClientSTA: Pointer to the global client pointer array
555
556 RETURN VALUE
557
558 SIDE EFFECTS
559
560============================================================================*/
561void WLANTL_FreeClientMemory
562(WLANTL_STAClientType* pClientSTA[WLAN_MAX_STA_COUNT])
563{
564 v_U32_t i = 0;
565 for(i =0; i < WLAN_MAX_STA_COUNT; i++)
566 {
567 if( NULL != pClientSTA[i] )
568 {
569 vos_mem_free(pClientSTA[i]);
570 }
571 pClientSTA[i] = NULL;
572 }
573 return;
574}
Jeff Johnson295189b2012-06-20 16:38:30 -0700575
576/*==========================================================================
577
578 FUNCTION WLANTL_Open
579
580 DESCRIPTION
581 Called by HDD at driver initialization. TL will initialize all its
582 internal resources and will wait for the call to start to register
583 with the other modules.
584
585 DEPENDENCIES
586
587 PARAMETERS
588
589 IN
590 pvosGCtx: pointer to the global vos context; a handle to TL's
591 control block can be extracted from its context
592 pTLConfig: TL Configuration
593
594 RETURN VALUE
595 The result code associated with performing the operation
596
597 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a page
598 fault
599 VOS_STATUS_SUCCESS: Everything is good :)
600
601 SIDE EFFECTS
602
603============================================================================*/
604VOS_STATUS
605WLANTL_Open
606(
607 v_PVOID_t pvosGCtx,
608 WLANTL_ConfigInfoType* pTLConfig
609)
610{
611 WLANTL_CbType* pTLCb = NULL;
612 v_U8_t ucIndex;
613 tHalHandle smeContext;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +0530614 v_U32_t i = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700615#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
616 VOS_STATUS status = VOS_STATUS_SUCCESS;
617#endif
618 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
619
620 /*------------------------------------------------------------------------
621 Sanity check
622 Extract TL control block
623 ------------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +0530624 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -0700625 vos_alloc_context( pvosGCtx, VOS_MODULE_ID_TL,
626 (void*)&pTLCb, sizeof(WLANTL_CbType));
627
628 pTLCb = VOS_GET_TL_CB(pvosGCtx);
629 if (( NULL == pTLCb ) || ( NULL == pTLConfig ) )
630 {
Madan Mohan Koyyalamudic0e5bd82012-09-18 17:12:27 -0700631 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_FATAL,
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +0530632 "WLAN TL: Invalid input pointer on WLANTL_Open TL %p Config %p", pTLCb, pTLConfig ));
Jeff Johnson295189b2012-06-20 16:38:30 -0700633 return VOS_STATUS_E_FAULT;
634 }
635
Madan Mohan Koyyalamudic0e5bd82012-09-18 17:12:27 -0700636 /* Set the default log level to VOS_TRACE_LEVEL_ERROR */
637 vos_trace_setLevel(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR);
638
Jeff Johnson295189b2012-06-20 16:38:30 -0700639 smeContext = vos_get_context(VOS_MODULE_ID_SME, pvosGCtx);
640 if ( NULL == smeContext )
641 {
642 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700643 "%s: Invalid smeContext", __func__));
Jeff Johnson295189b2012-06-20 16:38:30 -0700644 return VOS_STATUS_E_FAULT;
645 }
646
647 /* Zero out the memory so we are OK, when CleanCB is called.*/
648 vos_mem_zero((v_VOID_t *)pTLCb, sizeof(WLANTL_CbType));
649
650 /*------------------------------------------------------------------------
651 Clean up TL control block, initialize all values
652 ------------------------------------------------------------------------*/
653 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
654 "WLAN TL:WLANTL_Open"));
655
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +0530656 for ( i =0; i<WLAN_MAX_STA_COUNT; i++ )
Jeff Johnson295189b2012-06-20 16:38:30 -0700657 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +0530658 if ( i < WLAN_NON32_STA_COUNT )
659 {
660 pTLCb->atlSTAClients[i] = vos_mem_malloc(sizeof(WLANTL_STAClientType));
661 /* Allocating memory for LEGACY STA COUNT so as to avoid regression issues. */
662 if ( NULL == pTLCb->atlSTAClients[i] )
663 {
664 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR, "WLAN TL: StaClient allocation failed"));
665 WLANTL_FreeClientMemory(pTLCb->atlSTAClients);
666 vos_free_context(pvosGCtx, VOS_MODULE_ID_TL, pTLCb);
667 return VOS_STATUS_E_FAULT;
668 }
669 vos_mem_zero((v_VOID_t *) pTLCb->atlSTAClients[i], sizeof(WLANTL_STAClientType));
670 }
671 else
672 {
673 pTLCb->atlSTAClients[i] = NULL;
674 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700675 }
676
Sushant Kaushikf4a27972015-04-16 16:48:00 +0530677 pTLCb->reorderBufferPool = vos_mem_vmalloc(sizeof(WLANTL_REORDER_BUFFER_T) * WLANTL_MAX_BA_SESSION);
Jeff Johnson295189b2012-06-20 16:38:30 -0700678 if (NULL == pTLCb->reorderBufferPool)
679 {
Arif Hussainf2b00992013-11-17 21:46:15 -0800680 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR, "WLAN TL: Reorder buffer allocation failed"));
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +0530681 WLANTL_FreeClientMemory(pTLCb->atlSTAClients);
Jeff Johnson295189b2012-06-20 16:38:30 -0700682 vos_free_context(pvosGCtx, VOS_MODULE_ID_TL, pTLCb);
683 return VOS_STATUS_E_FAULT;
Jeff Johnson295189b2012-06-20 16:38:30 -0700684 }
685
686 vos_mem_zero((v_VOID_t *)pTLCb->reorderBufferPool, sizeof(WLANTL_REORDER_BUFFER_T) * WLANTL_MAX_BA_SESSION);
687
688 WLANTL_CleanCB(pTLCb, 0 /*do not empty*/);
689
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +0530690 for ( ucIndex = 0; ucIndex < WLANTL_NUM_TX_QUEUES ; ucIndex++)
Jeff Johnson295189b2012-06-20 16:38:30 -0700691 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +0530692 pTLCb->tlConfigInfo.ucAcWeights[ucIndex] = pTLConfig->ucAcWeights[ucIndex];
Jeff Johnson295189b2012-06-20 16:38:30 -0700693 }
694
Dhanashri Atred8c20a32014-01-03 17:20:55 -0800695 for ( ucIndex = 0; ucIndex < WLANTL_MAX_AC ; ucIndex++)
696 {
697 pTLCb->tlConfigInfo.ucReorderAgingTime[ucIndex] = pTLConfig->ucReorderAgingTime[ucIndex];
698 }
699
Jeff Johnson295189b2012-06-20 16:38:30 -0700700 // scheduling init to be the last one of previous round
701 pTLCb->uCurServedAC = WLANTL_AC_BK;
702 pTLCb->ucCurLeftWeight = 1;
703 pTLCb->ucCurrentSTA = WLAN_MAX_STA_COUNT-1;
704
Sravan Kumar Kairam60b8cf02016-12-12 16:22:09 +0530705 vos_timer_init(&pTLCb->tx_frames_timer, VOS_TIMER_TYPE_SW,
706 WLANTL_SampleTx, (void *)pTLCb);
Jeff Johnson295189b2012-06-20 16:38:30 -0700707#if 0
708 //flow control field init
709 vos_mem_zero(&pTLCb->tlFCInfo, sizeof(tFcTxParams_type));
710 //bit 0: set (Bd/pdu count) bit 1: set (request station PS change notification)
711 pTLCb->tlFCInfo.fcConfig = 0x1;
712#endif
713
714 pTLCb->vosTxFCBuf = NULL;
715 pTLCb->tlConfigInfo.uMinFramesProcThres =
716 pTLConfig->uMinFramesProcThres;
Jeff Johnson295189b2012-06-20 16:38:30 -0700717
Sunil Ravid5406f22013-01-22 00:18:31 -0800718#ifdef FEATURE_WLAN_TDLS
719 pTLCb->ucTdlsPeerCount = 0;
720#endif
721
Jeff Johnson295189b2012-06-20 16:38:30 -0700722 pTLCb->tlConfigInfo.uDelayedTriggerFrmInt =
723 pTLConfig->uDelayedTriggerFrmInt;
724
725 /*------------------------------------------------------------------------
726 Allocate internal resources
727 ------------------------------------------------------------------------*/
728 vos_pkt_get_packet(&pTLCb->vosDummyBuf, VOS_PKT_TYPE_RX_RAW, 1, 1,
729 1/*true*/,NULL, NULL);
730
731 WLANTL_InitBAReorderBuffer(pvosGCtx);
732#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
733 /* Initialize Handoff support modue
734 * RSSI measure and Traffic state monitoring */
735 status = WLANTL_HSInit(pvosGCtx);
736 if(!VOS_IS_STATUS_SUCCESS(status))
737 {
738 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
739 "Handoff support module init fail"));
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +0530740 WLANTL_FreeClientMemory(pTLCb->atlSTAClients);
Sushant Kaushikf4a27972015-04-16 16:48:00 +0530741 vos_mem_vfree(pTLCb->reorderBufferPool);
Jeff Johnson295189b2012-06-20 16:38:30 -0700742 vos_free_context(pvosGCtx, VOS_MODULE_ID_TL, pTLCb);
743 return status;
744 }
745#endif
746
Abhishek Singh00b71972016-01-07 10:51:04 +0530747#ifdef WLAN_FEATURE_RMC
748 status = WLANTL_RmcInit(pvosGCtx);
749 if (!VOS_IS_STATUS_SUCCESS(status))
750 {
751 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
752 "RMC module init fail"));
753 return status;
754 }
755#endif
756
Jeff Johnson295189b2012-06-20 16:38:30 -0700757 pTLCb->isBMPS = VOS_FALSE;
758 pmcRegisterDeviceStateUpdateInd( smeContext,
759 WLANTL_PowerStateChangedCB, pvosGCtx );
760
761 return VOS_STATUS_SUCCESS;
762}/* WLANTL_Open */
763
764/*==========================================================================
765
766 FUNCTION WLANTL_Start
767
768 DESCRIPTION
769 Called by HDD as part of the overall start procedure. TL will use this
770 call to register with BAL as a transport layer entity.
771
772 DEPENDENCIES
773
774 PARAMETERS
775
776 IN
777 pvosGCtx: pointer to the global vos context; a handle to TL's
778 control block can be extracted from its context
779
780 RETURN VALUE
781 The result code associated with performing the operation
782
783 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a page
784 fault
785 VOS_STATUS_SUCCESS: Everything is good :)
786
787 Other codes can be returned as a result of a BAL failure; see BAL API
788 for more info
789
790 SIDE EFFECTS
791
792============================================================================*/
793VOS_STATUS
794WLANTL_Start
795(
796 v_PVOID_t pvosGCtx
797)
798{
799 WLANTL_CbType* pTLCb = NULL;
800 v_U32_t uResCount = WDA_TLI_MIN_RES_DATA;
801 VOS_STATUS vosStatus;
802 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
803
804 /*------------------------------------------------------------------------
805 Sanity check
806 Extract TL control block
807 ------------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +0530808 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -0700809 pTLCb = VOS_GET_TL_CB(pvosGCtx);
810 if ( NULL == pTLCb )
811 {
812 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
813 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_Start"));
814 return VOS_STATUS_E_FAULT;
815 }
816
817 /*------------------------------------------------------------------------
818 Register with WDA as transport layer client
819 Request resources for tx from bus
820 ------------------------------------------------------------------------*/
821 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
822 "WLAN TL:WLAN TL:WLANTL_Start"));
823
Katya Nigam42e16e82014-02-04 16:28:55 +0530824 tlTraceInit();
Jeff Johnson295189b2012-06-20 16:38:30 -0700825 vosStatus = WDA_DS_Register( pvosGCtx,
826 WLANTL_TxComp,
827 WLANTL_RxFrames,
828 WLANTL_GetFrames,
829 WLANTL_ResourceCB,
830 WDA_TLI_MIN_RES_DATA,
831 pvosGCtx,
832 &uResCount );
833
834 if ( VOS_STATUS_SUCCESS != vosStatus )
835 {
836 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
837 "WLAN TL:TL failed to register with BAL/WDA, Err: %d",
838 vosStatus));
839 return vosStatus;
840 }
841
842 /* Enable transmission */
843 vos_atomic_set_U8( &pTLCb->ucTxSuspended, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700844 pTLCb->uResCount = uResCount;
Sravan Kumar Kairam60b8cf02016-12-12 16:22:09 +0530845
846 vos_timer_start(&pTLCb->tx_frames_timer, WLANTL_SAMPLE_INTERVAL);
847
Jeff Johnson295189b2012-06-20 16:38:30 -0700848 return VOS_STATUS_SUCCESS;
849}/* WLANTL_Start */
850
851/*==========================================================================
852
853 FUNCTION WLANTL_Stop
854
855 DESCRIPTION
856 Called by HDD to stop operation in TL, before close. TL will suspend all
857 frame transfer operation and will wait for the close request to clean up
858 its resources.
859
860 DEPENDENCIES
861
862 PARAMETERS
863
864 IN
865 pvosGCtx: pointer to the global vos context; a handle to TL's
866 control block can be extracted from its context
867
868 RETURN VALUE
869 The result code associated with performing the operation
870
871 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a page
872 fault
873 VOS_STATUS_SUCCESS: Everything is good :)
874
875 SIDE EFFECTS
876
877============================================================================*/
878VOS_STATUS
879WLANTL_Stop
880(
881 v_PVOID_t pvosGCtx
882)
883{
884 WLANTL_CbType* pTLCb = NULL;
885 v_U8_t ucIndex;
886 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
887
888 /*------------------------------------------------------------------------
889 Sanity check
890 Extract TL control block
891 ------------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +0530892 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -0700893 pTLCb = VOS_GET_TL_CB(pvosGCtx);
894 if ( NULL == pTLCb )
895 {
896 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
897 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_ChangeSTAState"));
898 return VOS_STATUS_E_FAULT;
899 }
900
901 /*------------------------------------------------------------------------
902 Stop TL and empty Station list
903 ------------------------------------------------------------------------*/
904 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
905 "WLAN TL:WLANTL_Stop"));
906
907 /* Disable transmission */
908 vos_atomic_set_U8( &pTLCb->ucTxSuspended, 1);
909
910 if ( NULL != pTLCb->tlMgmtFrmClient.vosPendingDataBuff )
911 {
912 vos_pkt_return_packet(pTLCb->tlMgmtFrmClient.vosPendingDataBuff);
913 pTLCb->tlMgmtFrmClient.vosPendingDataBuff = NULL;
914 }
915
916 if ( NULL != pTLCb->tlBAPClient.vosPendingDataBuff )
917 {
918 vos_pkt_return_packet(pTLCb->tlBAPClient.vosPendingDataBuff);
919 pTLCb->tlBAPClient.vosPendingDataBuff = NULL;
920 }
921
922#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
923 if(VOS_STATUS_SUCCESS != WLANTL_HSStop(pvosGCtx))
924 {
925 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
926 "Handoff Support module stop fail"));
927 }
928#endif
929
Sravan Kumar Kairam60b8cf02016-12-12 16:22:09 +0530930 if (VOS_TIMER_STATE_STOPPED !=
931 vos_timer_getCurrentState(&pTLCb->tx_frames_timer))
932 vos_timer_stop(&pTLCb->tx_frames_timer);
933
Jeff Johnson295189b2012-06-20 16:38:30 -0700934 /*-------------------------------------------------------------------------
935 Clean client stations
936 -------------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +0530937 for ( ucIndex = 0; ucIndex < WLAN_MAX_STA_COUNT; ucIndex++)
Jeff Johnson295189b2012-06-20 16:38:30 -0700938 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +0530939 if ( NULL != pTLCb->atlSTAClients[ucIndex] )
940 {
941 WLANTL_CleanSTA(pTLCb->atlSTAClients[ucIndex], 1 /*empty all queues*/);
942 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700943 }
944
945
946 return VOS_STATUS_SUCCESS;
947}/* WLANTL_Stop */
948
949/*==========================================================================
950
951 FUNCTION WLANTL_Close
952
953 DESCRIPTION
954 Called by HDD during general driver close procedure. TL will clean up
955 all the internal resources.
956
957 DEPENDENCIES
958
959 PARAMETERS
960
961 IN
962 pvosGCtx: pointer to the global vos context; a handle to TL's
963 control block can be extracted from its context
964
965 RETURN VALUE
966 The result code associated with performing the operation
967
968 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a page
969 fault
970 VOS_STATUS_SUCCESS: Everything is good :)
971
972 SIDE EFFECTS
973
974============================================================================*/
975VOS_STATUS
976WLANTL_Close
977(
978 v_PVOID_t pvosGCtx
979)
980{
981 WLANTL_CbType* pTLCb = NULL;
982 tHalHandle smeContext;
983 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
984
985 /*------------------------------------------------------------------------
986 Sanity check
987 Extract TL control block
988 ------------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +0530989 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -0700990 pTLCb = VOS_GET_TL_CB(pvosGCtx);
991 if ( NULL == pTLCb )
992 {
993 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
994 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_ChangeSTAState"));
995 return VOS_STATUS_E_FAULT;
996 }
997 /*------------------------------------------------------------------------
998 Deregister from PMC
999 ------------------------------------------------------------------------*/
1000 smeContext = vos_get_context(VOS_MODULE_ID_SME, pvosGCtx);
1001 if ( NULL == smeContext )
1002 {
1003 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001004 "%s: Invalid smeContext", __func__));
Jeff Johnson295189b2012-06-20 16:38:30 -07001005 // continue so that we can cleanup as much as possible
1006 }
1007 else
1008 {
1009 pmcDeregisterDeviceStateUpdateInd( smeContext, WLANTL_PowerStateChangedCB );
1010 }
1011
1012#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
1013 if(VOS_STATUS_SUCCESS != WLANTL_HSDeInit(pvosGCtx))
1014 {
1015 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
1016 "Handoff Support module DeInit fail"));
1017 }
1018#endif
1019
Abhishek Singh00b71972016-01-07 10:51:04 +05301020#ifdef WLAN_FEATURE_RMC
1021 if(VOS_STATUS_SUCCESS != WLANTL_RmcDeInit(pvosGCtx))
1022 {
1023 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
1024 "RMC module DeInit fail"));
1025 }
1026#endif
1027
Sravan Kumar Kairam60b8cf02016-12-12 16:22:09 +05301028 if (VOS_TIMER_STATE_RUNNING ==
1029 vos_timer_getCurrentState(&pTLCb->tx_frames_timer)) {
1030 vos_timer_stop(&pTLCb->tx_frames_timer);
1031 }
1032 if (!VOS_IS_STATUS_SUCCESS(vos_timer_destroy(&pTLCb->tx_frames_timer))) {
1033 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1034 "%s: Cannot deallocate TX frames sample timer", __func__));
1035 }
1036
Jeff Johnson295189b2012-06-20 16:38:30 -07001037 /*------------------------------------------------------------------------
1038 Cleanup TL control block.
1039 ------------------------------------------------------------------------*/
1040 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
1041 "WLAN TL: WLANTL_Close"));
1042 WLANTL_CleanCB(pTLCb, 1 /* empty queues/lists/pkts if any*/);
1043
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301044 WLANTL_FreeClientMemory(pTLCb->atlSTAClients);
1045
Sushant Kaushikf4a27972015-04-16 16:48:00 +05301046 vos_mem_vfree(pTLCb->reorderBufferPool);
Jeff Johnson295189b2012-06-20 16:38:30 -07001047
1048 /*------------------------------------------------------------------------
1049 Free TL context from VOSS global
1050 ------------------------------------------------------------------------*/
1051 vos_free_context(pvosGCtx, VOS_MODULE_ID_TL, pTLCb);
1052 return VOS_STATUS_SUCCESS;
1053}/* WLANTL_Close */
1054
1055/*----------------------------------------------------------------------------
1056 INTERACTION WITH HDD
1057 ---------------------------------------------------------------------------*/
1058/*==========================================================================
1059
1060 FUNCTION WLANTL_ConfigureSwFrameTXXlationForAll
1061
1062 DESCRIPTION
1063 Function to disable/enable frame translation for all association stations.
1064
1065 DEPENDENCIES
1066
1067 PARAMETERS
1068 IN
1069 pvosGCtx: VOS context
1070 EnableFrameXlation TRUE means enable SW translation for all stations.
1071 .
1072
1073 RETURN VALUE
1074
1075 void.
1076
1077============================================================================*/
1078void
1079WLANTL_ConfigureSwFrameTXXlationForAll
1080(
1081 v_PVOID_t pvosGCtx,
1082 v_BOOL_t enableFrameXlation
1083)
1084{
1085 v_U8_t ucIndex;
1086 /*------------------------------------------------------------------------
1087 Extract TL control block
1088 ------------------------------------------------------------------------*/
1089 WLANTL_CbType* pTLCb = VOS_GET_TL_CB(pvosGCtx);
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301090 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07001091 if ( NULL == pTLCb )
1092 {
1093 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1094 "WLAN TL:Invalid TL pointer from pvosGCtx on "
1095 "WLANTL_ConfigureSwFrameTXXlationForAll"));
1096 return;
1097 }
1098
1099 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
1100 "WLANTL_ConfigureSwFrameTXXlationForAll: Configure SW frameXlation %d",
1101 enableFrameXlation));
1102
1103 for ( ucIndex = 0; ucIndex < WLAN_MAX_TID; ucIndex++)
1104 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301105 pClientSTA = pTLCb->atlSTAClients[ucIndex];
1106 if ( NULL != pClientSTA && 0 != pClientSTA->ucExists )
Jeff Johnson295189b2012-06-20 16:38:30 -07001107 {
1108#ifdef WLAN_SOFTAP_VSTA_FEATURE
1109 // if this station was not allocated resources to perform HW-based
1110 // TX frame translation then force SW-based TX frame translation
1111 // otherwise use the frame translation supplied by the client
1112 if (!WDA_IsHwFrameTxTranslationCapable(pvosGCtx, ucIndex))
1113 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301114 pClientSTA->wSTADesc.ucSwFrameTXXlation = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07001115 }
1116 else
1117#endif
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301118 pClientSTA->wSTADesc.ucSwFrameTXXlation = enableFrameXlation;
Jeff Johnson295189b2012-06-20 16:38:30 -07001119 }
1120 }
1121}
1122
1123/*===========================================================================
1124
1125 FUNCTION WLANTL_StartForwarding
1126
1127 DESCRIPTION
1128
1129 This function is used to ask serialization through TX thread of the
1130 cached frame forwarding (if statation has been registered in the mean while)
1131 or flushing (if station has not been registered by the time)
1132
1133 In case of forwarding, upper layer is only required to call WLANTL_RegisterSTAClient()
1134 and doesn't need to call this function explicitly. TL will handle this inside
1135 WLANTL_RegisterSTAClient().
1136
1137 In case of flushing, upper layer is required to call this function explicitly
1138
1139 DEPENDENCIES
1140
1141 TL must have been initialized before this gets called.
1142
1143
1144 PARAMETERS
1145
1146 ucSTAId: station id
1147
1148 RETURN VALUE
1149
1150 The result code associated with performing the operation
1151 Please check return values of vos_tx_mq_serialize.
1152
1153 SIDE EFFECTS
1154 If TL was asked to perform WLANTL_CacheSTAFrame() in WLANTL_RxFrames(),
1155 either WLANTL_RegisterSTAClient() or this function must be called
1156 within reasonable time. Otherwise, TL will keep cached vos buffer until
1157 one of this function is called, and may end up with system buffer exhasution.
1158
1159 It's an upper layer's responsibility to call this function in case of
1160 flushing
1161
1162============================================================================*/
1163
1164VOS_STATUS
1165WLANTL_StartForwarding
1166(
1167 v_U8_t ucSTAId,
1168 v_U8_t ucUcastSig,
1169 v_U8_t ucBcastSig
1170)
1171{
1172 vos_msg_t sMessage;
1173 v_U32_t uData;
1174 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
1175
1176 /* Signal the OS to serialize our event */
1177 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
1178 "Serializing TL Start Forwarding Cached for control STA %d",
1179 ucSTAId );
1180
1181 vos_mem_zero( &sMessage, sizeof(vos_msg_t) );
1182
1183 uData = ucSTAId | (ucUcastSig << 8 ) | (ucBcastSig << 16);
Jeff Johnsond86c05a2013-11-10 18:50:34 -08001184 sMessage.bodyval = uData;
Katya Nigam664f5032014-05-05 12:24:32 +05301185 sMessage.type = WLANTL_RX_FWD_CACHED;
Jeff Johnson295189b2012-06-20 16:38:30 -07001186
Katya Nigam664f5032014-05-05 12:24:32 +05301187 return vos_rx_mq_serialize(VOS_MQ_ID_TL, &sMessage);
Jeff Johnson295189b2012-06-20 16:38:30 -07001188
1189} /* WLANTL_StartForwarding() */
1190
1191/*===========================================================================
1192
Katya Nigam63902932014-06-26 19:04:23 +05301193 FUNCTION WLANTL_EnableCaching
1194
1195 DESCRIPTION
1196
1197 This function is used to enable caching only when assoc/reassoc req is send.
1198 that is cache packets only for such STA ID.
1199
1200
1201 DEPENDENCIES
1202
1203 TL must have been initialized before this gets called.
1204
1205
1206 PARAMETERS
1207
1208 staId: station id
1209
1210 RETURN VALUE
1211
1212 none
1213
1214============================================================================*/
1215void WLANTL_EnableCaching(v_U8_t staId)
1216{
1217 v_PVOID_t pvosGCtx= vos_get_global_context(VOS_MODULE_ID_TL,NULL);
1218 WLANTL_CbType* pTLCb = VOS_GET_TL_CB(pvosGCtx);
1219 if ( NULL == pTLCb )
1220 {
1221 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1222 "WLAN TL:Invalid TL pointer from pvosGCtx on "
1223 "WLANTL_EnableCaching"));
1224 return;
1225 }
1226 pTLCb->atlSTAClients[staId]->enableCaching = 1;
1227}
1228
1229/*===========================================================================
1230
Jeff Johnson295189b2012-06-20 16:38:30 -07001231 FUNCTION WLANTL_AssocFailed
1232
1233 DESCRIPTION
1234
1235 This function is used by PE to notify TL that cache needs to flushed'
1236 when association is not successfully completed
1237
1238 Internally, TL post a message to TX_Thread to serialize the request to
1239 keep lock-free mechanism.
1240
1241
1242 DEPENDENCIES
1243
1244 TL must have been initialized before this gets called.
1245
1246
1247 PARAMETERS
1248
1249 ucSTAId: station id
1250
1251 RETURN VALUE
1252
1253 none
1254
1255 SIDE EFFECTS
1256 There may be race condition that PE call this API and send another association
1257 request immediately with same staId before TX_thread can process the message.
1258
1259 To avoid this, we might need PE to wait for TX_thread process the message,
1260 but this is not currently implemented.
1261
1262============================================================================*/
1263void WLANTL_AssocFailed(v_U8_t staId)
1264{
1265 // flushing frames and forwarding frames uses the same message
1266 // the only difference is what happens when the message is processed
1267 // if the STA exist, the frames will be forwarded
1268 // and if it doesn't exist, the frames will be flushed
1269 // in this case we know it won't exist so the DPU index signature values don't matter
Mihir Sheteae6f02b2014-04-11 19:49:21 +05301270 MTRACE(vos_trace(VOS_MODULE_ID_TL, TRACE_CODE_TL_ASSOC_FAILED,
1271 staId, 0));
1272
Jeff Johnson295189b2012-06-20 16:38:30 -07001273 if(!VOS_IS_STATUS_SUCCESS(WLANTL_StartForwarding(staId,0,0)))
1274 {
1275 VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Mihir Sheteb7337272014-04-11 15:53:08 +05301276 " %s fails to start forwarding (staId %d)", __func__, staId);
Jeff Johnson295189b2012-06-20 16:38:30 -07001277 }
1278}
Nirav Shah4f765af2015-01-21 19:51:30 +05301279
Nirav Shah4b53d4b2015-05-08 05:35:00 -07001280 /*===========================================================================
Jeff Johnson295189b2012-06-20 16:38:30 -07001281
1282 FUNCTION WLANTL_Finish_ULA
1283
1284 DESCRIPTION
1285 This function is used by HDD to notify TL to finish Upper layer authentication
1286 incase the last EAPOL packet is pending in the TL queue.
1287 To avoid the race condition between sme set key and the last EAPOL packet
1288 the HDD module calls this function just before calling the sme_RoamSetKey.
1289
1290 DEPENDENCIES
1291
1292 TL must have been initialized before this gets called.
Nirav Shah4f765af2015-01-21 19:51:30 +05301293
Jeff Johnson295189b2012-06-20 16:38:30 -07001294 PARAMETERS
1295
Nirav Shah4b53d4b2015-05-08 05:35:00 -07001296 callbackRoutine: HDD Callback function.
1297 callbackContext : HDD userdata context.
Nirav Shah4f765af2015-01-21 19:51:30 +05301298
Jeff Johnson295189b2012-06-20 16:38:30 -07001299 RETURN VALUE
1300
1301 VOS_STATUS_SUCCESS/VOS_STATUS_FAILURE
Nirav Shah4f765af2015-01-21 19:51:30 +05301302
Jeff Johnson295189b2012-06-20 16:38:30 -07001303 SIDE EFFECTS
Nirav Shah4f765af2015-01-21 19:51:30 +05301304
Jeff Johnson295189b2012-06-20 16:38:30 -07001305============================================================================*/
1306
1307VOS_STATUS WLANTL_Finish_ULA( void (*callbackRoutine) (void *callbackContext),
Nirav Shah4b53d4b2015-05-08 05:35:00 -07001308 void *callbackContext)
Jeff Johnson295189b2012-06-20 16:38:30 -07001309{
Nirav Shah4b53d4b2015-05-08 05:35:00 -07001310 return WDA_DS_FinishULA( callbackRoutine, callbackContext);
Nirav Shah4f765af2015-01-21 19:51:30 +05301311}
Jeff Johnson295189b2012-06-20 16:38:30 -07001312
Nirav Shah4b53d4b2015-05-08 05:35:00 -07001313
Jeff Johnson295189b2012-06-20 16:38:30 -07001314/*===========================================================================
1315
1316 FUNCTION WLANTL_RegisterSTAClient
1317
1318 DESCRIPTION
1319
1320 This function is used by HDD to register as a client for data services
1321 with TL. HDD will call this API for each new station that it adds,
1322 thus having the flexibility of registering different callback for each
1323 STA it services.
1324
1325 DEPENDENCIES
1326
1327 TL must have been initialized before this gets called.
1328
1329 Restriction:
1330 Main thread will have higher priority that Tx and Rx threads thus
1331 guaranteeing that a station will be added before any data can be
1332 received for it. (This enables TL to be lock free)
1333
1334 PARAMETERS
1335
1336 pvosGCtx: pointer to the global vos context; a handle to TL's
1337 control block can be extracted from its context
1338 pfnStARx: function pointer to the receive packet handler from HDD
1339 pfnSTATxComp: function pointer to the transmit complete confirmation
1340 handler from HDD
1341 pfnSTAFetchPkt: function pointer to the packet retrieval routine in HDD
1342 wSTADescType: STA Descriptor, contains information related to the
1343 new added STA
1344
1345 RETURN VALUE
1346
1347 The result code associated with performing the operation
1348
1349 VOS_STATUS_E_INVAL: Input parameters are invalid
1350 VOS_STATUS_E_FAULT: Station ID is outside array boundaries or pointer to
1351 TL cb is NULL ; access would cause a page fault
1352 VOS_STATUS_E_EXISTS: Station was already registered
1353 VOS_STATUS_SUCCESS: Everything is good :)
1354
1355 SIDE EFFECTS
1356
1357============================================================================*/
1358VOS_STATUS
1359WLANTL_RegisterSTAClient
1360(
1361 v_PVOID_t pvosGCtx,
1362 WLANTL_STARxCBType pfnSTARx,
1363 WLANTL_TxCompCBType pfnSTATxComp,
1364 WLANTL_STAFetchPktCBType pfnSTAFetchPkt,
1365 WLAN_STADescType* pwSTADescType,
1366 v_S7_t rssi
1367)
1368{
1369 WLANTL_CbType* pTLCb = NULL;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301370 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07001371 v_U8_t ucTid = 0;/*Local variable to clear previous replay counters of STA on all TIDs*/
Hanumantha Reddy Pothulaee001fc2015-05-26 15:21:53 +05301372 v_U32_t istoggleArpEnb = 0;
1373 tpAniSirGlobal pMac;
Jeff Johnson295189b2012-06-20 16:38:30 -07001374 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
1375
1376 /*------------------------------------------------------------------------
1377 Sanity check
1378 ------------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301379 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -07001380 if (( NULL == pwSTADescType ) || ( NULL == pfnSTARx ) ||
1381 ( NULL == pfnSTAFetchPkt ))
1382 {
1383 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1384 "WLAN TL:Invalid parameter sent on WLANTL_RegisterSTAClient"));
1385 return VOS_STATUS_E_INVAL;
1386 }
1387
1388 if ( WLANTL_STA_ID_INVALID( pwSTADescType->ucSTAId ) )
1389 {
1390 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1391 "WLAN TL:Invalid station id requested on WLANTL_RegisterSTAClient"));
1392 return VOS_STATUS_E_FAULT;
1393 }
1394
1395 /*------------------------------------------------------------------------
1396 Extract TL control block
1397 ------------------------------------------------------------------------*/
1398 pTLCb = VOS_GET_TL_CB(pvosGCtx);
1399 if ( NULL == pTLCb )
1400 {
1401 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1402 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_RegisterSTAClient"));
1403 return VOS_STATUS_E_FAULT;
1404 }
1405
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301406 //Code for checking and allocating memory for new STA
1407 if ( NULL == pTLCb->atlSTAClients[pwSTADescType->ucSTAId] ){
1408 pTLCb->atlSTAClients[pwSTADescType->ucSTAId] = vos_mem_malloc(sizeof(WLANTL_STAClientType));
1409 if ( NULL == pTLCb->atlSTAClients[pwSTADescType->ucSTAId] ){
1410 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1411 "WLAN TL: STA Client memory allocation failed in WLANTL_RegisterSTAClient"));
1412 return VOS_STATUS_E_FAILURE;
1413 }
1414 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
1415 "WLAN TL: STA Client memory allocation in WLANTL_RegisterSTAClient"));
1416 vos_mem_zero((v_VOID_t *) pTLCb->atlSTAClients[pwSTADescType->ucSTAId],sizeof(WLANTL_STAClientType));
1417 }
1418
1419 //Assigning the pointer to local variable for easy access in future
1420 pClientSTA = pTLCb->atlSTAClients[pwSTADescType->ucSTAId];
1421 if ( 0 != pClientSTA->ucExists )
Jeff Johnson295189b2012-06-20 16:38:30 -07001422 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301423 pClientSTA->ucExists++;
Jeff Johnson295189b2012-06-20 16:38:30 -07001424 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1425 "WLAN TL:Station was already registered on WLANTL_RegisterSTAClient"));
1426 return VOS_STATUS_E_EXISTS;
1427 }
1428
1429 /*------------------------------------------------------------------------
1430 Register station with TL
1431 ------------------------------------------------------------------------*/
Katya Nigam42e16e82014-02-04 16:28:55 +05301432 MTRACE(vos_trace(VOS_MODULE_ID_TL, TRACE_CODE_TL_REGISTER_STA_CLIENT,
1433 pwSTADescType->ucSTAId, (unsigned )
1434 (*(pwSTADescType->vSTAMACAddress.bytes+2)<<24 |
1435 *(pwSTADescType->vSTAMACAddress.bytes+3)<<16 |
1436 *(pwSTADescType->vSTAMACAddress.bytes+4)<<8 |
1437 *(pwSTADescType->vSTAMACAddress.bytes+5))));
1438
Jeff Johnson295189b2012-06-20 16:38:30 -07001439 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
1440 "WLAN TL:Registering STA Client ID: %d", pwSTADescType->ucSTAId ));
1441
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301442 pClientSTA->pfnSTARx = pfnSTARx;
1443 pClientSTA->pfnSTAFetchPkt = pfnSTAFetchPkt;
Jeff Johnson295189b2012-06-20 16:38:30 -07001444
1445 /* Only register if different from NULL - TL default Tx Comp Cb will
1446 release the vos packet */
1447 if ( NULL != pfnSTATxComp )
1448 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301449 pClientSTA->pfnSTATxComp = pfnSTATxComp;
Jeff Johnson295189b2012-06-20 16:38:30 -07001450 }
1451
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301452 pClientSTA->tlState = WLANTL_STA_INIT;
1453 pClientSTA->tlPri = WLANTL_STA_PRI_NORMAL;
1454 pClientSTA->wSTADesc.ucSTAId = pwSTADescType->ucSTAId;
Gopichand Nakkala8b54e912013-03-11 10:44:21 +05301455 pClientSTA->ptkInstalled = 0;
Bhargav Shahfbaeca22016-07-13 10:27:35 +05301456 pClientSTA->disassoc_progress = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001457
Hanumantha Reddy Pothulaee001fc2015-05-26 15:21:53 +05301458 pMac = vos_get_context(VOS_MODULE_ID_PE, pvosGCtx);
1459 if ( NULL != pMac )
1460 {
1461 wlan_cfgGetInt(pMac, WNI_CFG_TOGGLE_ARP_BDRATES, &istoggleArpEnb);
1462 }
Hanumantha Reddy Pothulae5ab23d2015-09-14 18:08:24 +05301463 pClientSTA->arpRate = istoggleArpEnb ? ENABLE_ARP_TOGGLE : DISABLE_ARP_TOGGLE;
1464 pClientSTA->arpOnWQ5 = istoggleArpEnb == SEND_ARP_ON_WQ5;
Hanumantha Reddy Pothulaee001fc2015-05-26 15:21:53 +05301465
Jeff Johnson295189b2012-06-20 16:38:30 -07001466 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
Hanumantha Reddy Pothulaee001fc2015-05-26 15:21:53 +05301467 "WLAN TL:Registering STA Client ID: %d with UC %d and BC %d toggleArp :%hhu",
1468 pwSTADescType->ucSTAId, pwSTADescType->ucUcastSig,
1469 pwSTADescType->ucBcastSig, pClientSTA->arpRate));
Jeff Johnson295189b2012-06-20 16:38:30 -07001470
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301471 pClientSTA->wSTADesc.wSTAType = pwSTADescType->wSTAType;
Jeff Johnson295189b2012-06-20 16:38:30 -07001472
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301473 pClientSTA->wSTADesc.ucQosEnabled = pwSTADescType->ucQosEnabled;
Jeff Johnson295189b2012-06-20 16:38:30 -07001474
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301475 pClientSTA->wSTADesc.ucAddRmvLLC = pwSTADescType->ucAddRmvLLC;
Jeff Johnson295189b2012-06-20 16:38:30 -07001476
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301477 pClientSTA->wSTADesc.ucProtectedFrame = pwSTADescType->ucProtectedFrame;
Jeff Johnson295189b2012-06-20 16:38:30 -07001478
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001479#ifdef FEATURE_WLAN_ESE
1480 pClientSTA->wSTADesc.ucIsEseSta = pwSTADescType->ucIsEseSta;
Jeff Johnson295189b2012-06-20 16:38:30 -07001481
1482 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001483 "WLAN TL:Registering STA Client ID: %d QoS %d Add LLC %d ProtFrame %d EseSta %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07001484 pwSTADescType->ucSTAId,
1485 pwSTADescType->ucQosEnabled,
1486 pwSTADescType->ucAddRmvLLC,
1487 pwSTADescType->ucProtectedFrame,
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001488 pwSTADescType->ucIsEseSta));
Jeff Johnson295189b2012-06-20 16:38:30 -07001489#else
1490
1491 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
1492 "WLAN TL:Registering STA Client ID: %d QoS %d Add LLC %d ProtFrame %d",
1493 pwSTADescType->ucSTAId,
1494 pwSTADescType->ucQosEnabled,
1495 pwSTADescType->ucAddRmvLLC,
1496 pwSTADescType->ucProtectedFrame));
1497
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001498#endif //FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07001499#ifdef WLAN_SOFTAP_VSTA_FEATURE
1500 // if this station was not allocated resources to perform HW-based
1501 // TX frame translation then force SW-based TX frame translation
1502 // otherwise use the frame translation supplied by the client
1503
1504 if (!WDA_IsHwFrameTxTranslationCapable(pvosGCtx, pwSTADescType->ucSTAId)
1505 || ( WLAN_STA_BT_AMP == pwSTADescType->wSTAType))
1506 {
1507 pwSTADescType->ucSwFrameTXXlation = 1;
1508 }
1509#endif
1510
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301511 pClientSTA->wSTADesc.ucSwFrameTXXlation = pwSTADescType->ucSwFrameTXXlation;
1512 pClientSTA->wSTADesc.ucSwFrameRXXlation = pwSTADescType->ucSwFrameRXXlation;
Jeff Johnson295189b2012-06-20 16:38:30 -07001513
1514#ifdef FEATURE_WLAN_WAPI
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301515 pClientSTA->wSTADesc.ucIsWapiSta = pwSTADescType->ucIsWapiSta;
Jeff Johnson295189b2012-06-20 16:38:30 -07001516#endif /* FEATURE_WLAN_WAPI */
1517
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301518 vos_copy_macaddr( &pClientSTA->wSTADesc.vSTAMACAddress, &pwSTADescType->vSTAMACAddress);
Jeff Johnson295189b2012-06-20 16:38:30 -07001519
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301520 vos_copy_macaddr( &pClientSTA->wSTADesc.vBSSIDforIBSS, &pwSTADescType->vBSSIDforIBSS);
Jeff Johnson295189b2012-06-20 16:38:30 -07001521
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301522 vos_copy_macaddr( &pClientSTA->wSTADesc.vSelfMACAddress, &pwSTADescType->vSelfMACAddress);
Jeff Johnson295189b2012-06-20 16:38:30 -07001523
Jeff Johnson295189b2012-06-20 16:38:30 -07001524 /* In volans release L replay check is done at TL */
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301525 pClientSTA->ucIsReplayCheckValid = pwSTADescType->ucIsReplayCheckValid;
1526 pClientSTA->ulTotalReplayPacketsDetected = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001527/*Clear replay counters of the STA on all TIDs*/
1528 for(ucTid = 0; ucTid < WLANTL_MAX_TID ; ucTid++)
1529 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301530 pClientSTA->ullReplayCounter[ucTid] = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001531 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001532
1533 /*--------------------------------------------------------------------
1534 Set the AC for the registered station to the highest priority AC
1535 Even if this AC is not supported by the station, correction will be
1536 made in the main TL loop after the supported mask is properly
1537 updated in the pending packets call
1538 --------------------------------------------------------------------*/
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05301539 pClientSTA->ucCurrentAC = WLANTL_AC_HIGH_PRIO;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301540 pClientSTA->ucCurrentWeight = 0;
1541 pClientSTA->ucServicedAC = WLANTL_AC_BK;
1542 pClientSTA->ucEapolPktPending = 0;
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -07001543
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301544 vos_mem_zero( pClientSTA->aucACMask, sizeof(pClientSTA->aucACMask));
Jeff Johnson295189b2012-06-20 16:38:30 -07001545
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301546 vos_mem_zero( &pClientSTA->wUAPSDInfo, sizeof(pClientSTA->wUAPSDInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -07001547
1548 /*--------------------------------------------------------------------
1549 Reordering info and AMSDU de-aggregation
1550 --------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301551 vos_mem_zero( pClientSTA->atlBAReorderInfo,
1552 sizeof(pClientSTA->atlBAReorderInfo[0])*
Jeff Johnson295189b2012-06-20 16:38:30 -07001553 WLAN_MAX_TID);
1554
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301555 vos_mem_zero( pClientSTA->aucMPDUHeader,
Jeff Johnson295189b2012-06-20 16:38:30 -07001556 WLANTL_MPDU_HEADER_LEN);
1557
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301558 pClientSTA->ucMPDUHeaderLen = 0;
1559 pClientSTA->vosAMSDUChain = NULL;
1560 pClientSTA->vosAMSDUChainRoot = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07001561
1562
Leo Chang6b6faaf2014-01-24 21:21:26 -08001563 /* Reorder LOCK
1564 * During handle normal RX frame within RX thread,
1565 * if MC thread try to preempt, ADDBA, DELBA, TIMER
1566 * Context should be protected from race */
1567 for (ucTid = 0; ucTid < WLAN_MAX_TID ; ucTid++)
1568 {
1569 if (!VOS_IS_STATUS_SUCCESS(
1570 vos_lock_init(&pClientSTA->atlBAReorderInfo[ucTid].reorderLock)))
1571 {
1572 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1573 "Lock Init Fail"));
1574 return VOS_STATUS_E_FAILURE;
1575 }
1576 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001577 /*--------------------------------------------------------------------
1578 Stats info
1579 --------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301580 vos_mem_zero( pClientSTA->auRxCount,
1581 sizeof(pClientSTA->auRxCount[0])*
Jeff Johnson295189b2012-06-20 16:38:30 -07001582 WLAN_MAX_TID);
1583
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301584 vos_mem_zero( pClientSTA->auTxCount,
1585 sizeof(pClientSTA->auRxCount[0])*
Jeff Johnson295189b2012-06-20 16:38:30 -07001586 WLAN_MAX_TID);
1587 /* Initial RSSI is always reported as zero because TL doesnt have enough
1588 data to calculate RSSI. So to avoid reporting zero, we are initializing
1589 RSSI with RSSI saved in BssDescription during scanning. */
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301590 pClientSTA->rssiAvg = rssi;
Bhargav Shah0b23d202015-07-10 17:14:34 +05301591 pClientSTA->rssiAvgBmps = rssi;
Shailender Karmuchi13c0d082013-03-26 14:41:39 -07001592#ifdef FEATURE_WLAN_TDLS
1593 if(WLAN_STA_TDLS == pClientSTA->wSTADesc.wSTAType)
1594 {
1595 /* If client is TDLS, use TDLS specific alpha */
1596 pClientSTA->rssiAlpha = WLANTL_HO_TDLS_ALPHA;
1597 }
1598 else
1599 {
1600 pClientSTA->rssiAlpha = WLANTL_HO_DEFAULT_ALPHA;
1601 }
1602#else
1603 pClientSTA->rssiAlpha = WLANTL_HO_DEFAULT_ALPHA;
1604#endif /* FEATURE_WLAN_TDLS */
Dino Mycle3b9536d2014-07-09 22:05:24 +05301605#ifdef WLAN_FEATURE_LINK_LAYER_STATS
1606 pClientSTA->rssiDataAlpha = WLANTL_HO_DEFAULT_ALPHA;
1607 pClientSTA->interfaceStats.accessCategoryStats[0].ac = WLANTL_AC_BK;
1608 pClientSTA->interfaceStats.accessCategoryStats[1].ac = WLANTL_AC_BE;
1609 pClientSTA->interfaceStats.accessCategoryStats[2].ac = WLANTL_AC_VI;
1610 pClientSTA->interfaceStats.accessCategoryStats[3].ac = WLANTL_AC_VO;
1611#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001612
1613 /*Tx not suspended and station fully registered*/
1614 vos_atomic_set_U8(
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301615 &pClientSTA->ucTxSuspended, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07001616
1617 /* Used until multiple station support will be added*/
1618 pTLCb->ucRegisteredStaId = pwSTADescType->ucSTAId;
1619
1620 /* Save the BAP station ID for future usage */
1621 if ( WLAN_STA_BT_AMP == pwSTADescType->wSTAType )
1622 {
1623 pTLCb->tlBAPClient.ucBAPSTAId = pwSTADescType->ucSTAId;
1624 }
1625
1626 /*------------------------------------------------------------------------
1627 Statistics info
1628 -----------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301629 memset(&pClientSTA->trafficStatistics,
Jeff Johnson295189b2012-06-20 16:38:30 -07001630 0, sizeof(WLANTL_TRANSFER_STA_TYPE));
1631
1632
1633 /*------------------------------------------------------------------------
1634 Start with the state suggested by client caller
1635 -----------------------------------------------------------------------*/
Madan Mohan Koyylamudi64258222013-01-30 14:35:10 +05301636 pClientSTA->tlState = pwSTADescType->ucInitState;
Jeff Johnson295189b2012-06-20 16:38:30 -07001637 /*-----------------------------------------------------------------------
1638 After all the init is complete we can mark the existance flag
1639 ----------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301640 pClientSTA->ucExists++;
Jeff Johnson295189b2012-06-20 16:38:30 -07001641
Jeff Johnson295189b2012-06-20 16:38:30 -07001642 //flow control fields init
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301643 pClientSTA->ucLwmModeEnabled = FALSE;
1644 pClientSTA->ucLwmEventReported = FALSE;
1645 pClientSTA->bmuMemConsumed = 0;
1646 pClientSTA->uIngress_length = 0;
1647 pClientSTA->uBuffThresholdMax = WLANTL_STA_BMU_THRESHOLD_MAX;
Jeff Johnson295189b2012-06-20 16:38:30 -07001648
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301649 pClientSTA->uLwmThreshold = WLANTL_STA_BMU_THRESHOLD_MAX / 3;
Jeff Johnson295189b2012-06-20 16:38:30 -07001650
1651 //@@@ HDDSOFTAP does not queue unregistered packet for now
1652 if ( WLAN_STA_SOFTAP != pwSTADescType->wSTAType )
1653 {
Jeff Johnson295189b2012-06-20 16:38:30 -07001654 /*------------------------------------------------------------------------
1655 Forward received frames while STA was not yet registered
1656 - ----------------------------------------------------------------------*/
1657 if(!VOS_IS_STATUS_SUCCESS(WLANTL_StartForwarding( pwSTADescType->ucSTAId,
1658 pwSTADescType->ucUcastSig,
1659 pwSTADescType->ucBcastSig)))
1660 {
1661 VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001662 " %s fails to start forwarding", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001663 }
Sunil Ravid5406f22013-01-22 00:18:31 -08001664#ifdef FEATURE_WLAN_TDLS
1665 if( WLAN_STA_TDLS == pwSTADescType->wSTAType )
1666 pTLCb->ucTdlsPeerCount++;
1667#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001668 }
Abhishek Singh00b71972016-01-07 10:51:04 +05301669#ifdef WLAN_FEATURE_RMC
1670 vos_lock_init(&pClientSTA->mcLock);
1671#endif /* WLAN_FEATURE_RMC */
1672
Jeff Johnson295189b2012-06-20 16:38:30 -07001673 return VOS_STATUS_SUCCESS;
1674}/* WLANTL_RegisterSTAClient */
1675
1676/*===========================================================================
1677
1678 FUNCTION WLANTL_ClearSTAClient
1679
1680 DESCRIPTION
1681
1682 HDD will call this API when it no longer needs data services for the
1683 particular station.
1684
1685 DEPENDENCIES
1686
1687 A station must have been registered before the clear registration is
1688 called.
1689
1690 PARAMETERS
1691
1692 pvosGCtx: pointer to the global vos context; a handle to TL's
1693 control block can be extracted from its context
1694 ucSTAId: identifier for the STA to be cleared
1695
1696 RETURN VALUE
1697
1698 The result code associated with performing the operation
1699
1700 VOS_STATUS_E_FAULT: Station ID is outside array boundaries or pointer to
1701 TL cb is NULL ; access would cause a page fault
1702 VOS_STATUS_E_EXISTS: Station was not registered
1703 VOS_STATUS_SUCCESS: Everything is good :)
1704
1705 SIDE EFFECTS
1706
1707============================================================================*/
1708VOS_STATUS
1709WLANTL_ClearSTAClient
1710(
1711 v_PVOID_t pvosGCtx,
1712 v_U8_t ucSTAId
1713)
1714{
1715 WLANTL_CbType* pTLCb = NULL;
1716 v_U8_t ucIndex;
1717 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
1718
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301719 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -07001720 /*------------------------------------------------------------------------
1721 Sanity check
1722 ------------------------------------------------------------------------*/
1723 if ( WLANTL_STA_ID_INVALID( ucSTAId ) )
1724 {
1725 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1726 "WLAN TL:Invalid station id requested on WLANTL_ClearSTAClient"));
1727 return VOS_STATUS_E_FAULT;
1728 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001729 /*------------------------------------------------------------------------
1730 Extract TL control block
1731 ------------------------------------------------------------------------*/
1732 pTLCb = VOS_GET_TL_CB(pvosGCtx);
1733 if ( NULL == pTLCb )
1734 {
1735 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1736 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_ClearSTAClient"));
1737 return VOS_STATUS_E_FAULT;
1738 }
1739
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301740 if ( NULL == pTLCb->atlSTAClients[ucSTAId] )
1741 {
1742 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1743 "WLAN TL:Client Memory was not allocated on %s", __func__));
1744 return VOS_STATUS_E_FAILURE;
1745 }
1746
1747 if ( 0 == pTLCb->atlSTAClients[ucSTAId]->ucExists )
Jeff Johnson295189b2012-06-20 16:38:30 -07001748 {
1749 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1750 "WLAN TL:Station was not previously registered on WLANTL_ClearSTAClient"));
Siddharth Bhalaef8ee12014-04-02 00:09:45 +05301751 /* Clean packets cached for the STA */
1752 WLANTL_StartForwarding(ucSTAId,0,0);
Jeff Johnson295189b2012-06-20 16:38:30 -07001753 return VOS_STATUS_E_EXISTS;
1754 }
1755
1756 /* Delete BA sessions on all TID's */
Leo Chang6b6faaf2014-01-24 21:21:26 -08001757 for (ucIndex = 0; ucIndex < WLAN_MAX_TID ; ucIndex++)
Jeff Johnson295189b2012-06-20 16:38:30 -07001758 {
Leo Chang6b6faaf2014-01-24 21:21:26 -08001759 WLANTL_BaSessionDel(pvosGCtx, ucSTAId, ucIndex);
1760 vos_lock_destroy(&pTLCb->atlSTAClients[ucSTAId]->atlBAReorderInfo[ucIndex].reorderLock);
Jeff Johnson295189b2012-06-20 16:38:30 -07001761 }
1762
Sunil Ravid5406f22013-01-22 00:18:31 -08001763#ifdef FEATURE_WLAN_TDLS
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301764 /* decrement ucTdlsPeerCount only if it is non-zero */
1765 if(WLAN_STA_TDLS == pTLCb->atlSTAClients[ucSTAId]->wSTADesc.wSTAType
Sunil Ravid5406f22013-01-22 00:18:31 -08001766 && pTLCb->ucTdlsPeerCount)
1767 pTLCb->ucTdlsPeerCount--;
1768#endif
1769
Jeff Johnson295189b2012-06-20 16:38:30 -07001770 /*------------------------------------------------------------------------
1771 Clear station
1772 ------------------------------------------------------------------------*/
1773 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
1774 "WLAN TL:Clearing STA Client ID: %d", ucSTAId ));
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301775 WLANTL_CleanSTA(pTLCb->atlSTAClients[ucSTAId], 1 /*empty packets*/);
Jeff Johnson295189b2012-06-20 16:38:30 -07001776
Abhishek Singh00b71972016-01-07 10:51:04 +05301777#ifdef WLAN_FEATURE_RMC
1778 /*--------------------------------------------------------------------
1779 Delete multicast entries for duplicate detection
1780 --------------------------------------------------------------------*/
1781 WLANTL_McastDeleteAllEntries(pTLCb->atlSTAClients[ucSTAId]);
1782
1783 vos_lock_destroy(&pTLCb->atlSTAClients[ucSTAId]->mcLock);
1784#endif /* WLAN_FEATURE_RMC */
1785
Jeff Johnson295189b2012-06-20 16:38:30 -07001786 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
1787 "WLAN TL:Clearing STA Reset History RSSI and Region number"));
1788 pTLCb->hoSupport.currentHOState.historyRSSI = 0;
1789 pTLCb->hoSupport.currentHOState.regionNumber = 0;
1790
1791 return VOS_STATUS_SUCCESS;
1792}/* WLANTL_ClearSTAClient */
1793
1794/*===========================================================================
1795
1796 FUNCTION WLANTL_ChangeSTAState
1797
1798 DESCRIPTION
1799
1800 HDD will make this notification whenever a change occurs in the
1801 connectivity state of a particular STA.
1802
1803 DEPENDENCIES
1804
1805 A station must have been registered before the change state can be
1806 called.
1807
1808 RESTRICTION: A station is being notified as authenticated before the
1809 keys are installed in HW. This way if a frame is received
1810 before the keys are installed DPU will drop that frame.
1811
1812 Main thread has higher priority that Tx and Rx threads thus guaranteeing
1813 the following:
1814 - a station will be in assoc state in TL before TL receives any data
1815 for it
1816
1817 PARAMETERS
1818
1819 pvosGCtx: pointer to the global vos context; a handle to TL's
1820 control block can be extracted from its context
1821 ucSTAId: identifier for the STA that is pending transmission
1822 tlSTAState: the new state of the connection to the given station
1823
1824
1825 RETURN VALUE
1826
1827 The result code associated with performing the operation
1828
1829 VOS_STATUS_E_INVAL: Input parameters are invalid
1830 VOS_STATUS_E_FAULT: Station ID is outside array boundaries or pointer to
1831 TL cb is NULL ; access would cause a page fault
1832 VOS_STATUS_E_EXISTS: Station was not registered
1833 VOS_STATUS_SUCCESS: Everything is good :)
1834
1835 SIDE EFFECTS
1836
1837============================================================================*/
1838VOS_STATUS
1839WLANTL_ChangeSTAState
1840(
1841 v_PVOID_t pvosGCtx,
1842 v_U8_t ucSTAId,
1843 WLANTL_STAStateType tlSTAState
1844)
1845{
1846 WLANTL_CbType* pTLCb = NULL;
1847 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
1848
1849 /*------------------------------------------------------------------------
1850 Sanity check
1851 ------------------------------------------------------------------------*/
1852 if ( tlSTAState >= WLANTL_STA_MAX_STATE )
1853 {
1854 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1855 "WLAN TL:Invalid parameter sent on WLANTL_ChangeSTAState"));
1856 return VOS_STATUS_E_INVAL;
1857 }
1858
1859 if ( WLANTL_STA_ID_INVALID( ucSTAId ) )
1860 {
1861 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1862 "WLAN TL:Invalid station id requested on WLANTL_ChangeSTAState"));
1863 return VOS_STATUS_E_FAULT;
1864 }
1865
1866 /*------------------------------------------------------------------------
1867 Extract TL control block and check existance
1868 ------------------------------------------------------------------------*/
1869 pTLCb = VOS_GET_TL_CB(pvosGCtx);
1870 if ( NULL == pTLCb )
1871 {
1872 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1873 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_ChangeSTAState"));
1874 return VOS_STATUS_E_FAULT;
1875 }
1876
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301877 if ( NULL == pTLCb->atlSTAClients[ucSTAId] )
1878 {
1879 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1880 "WLAN TL:Client Memory was not allocated on %s", __func__));
1881 return VOS_STATUS_E_FAILURE;
1882 }
1883
1884 if ( 0 == pTLCb->atlSTAClients[ucSTAId]->ucExists )
Jeff Johnson295189b2012-06-20 16:38:30 -07001885 {
1886 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1887 "WLAN TL:Station was not previously registered on WLANTL_ChangeSTAState"));
1888 return VOS_STATUS_E_EXISTS;
1889 }
1890
1891 /*------------------------------------------------------------------------
1892 Change STA state
1893 No need to lock this operation, see restrictions above
1894 ------------------------------------------------------------------------*/
1895 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
1896 "WLAN TL:Changing state for STA Client ID: %d from %d to %d",
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301897 ucSTAId, pTLCb->atlSTAClients[ucSTAId]->tlState, tlSTAState));
Jeff Johnson295189b2012-06-20 16:38:30 -07001898
Katya Nigam42e16e82014-02-04 16:28:55 +05301899 MTRACE(vos_trace(VOS_MODULE_ID_TL,
1900 TRACE_CODE_TL_STA_STATE, ucSTAId,tlSTAState ));
1901
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301902 pTLCb->atlSTAClients[ucSTAId]->tlState = tlSTAState;
Jeff Johnson295189b2012-06-20 16:38:30 -07001903
1904 return VOS_STATUS_SUCCESS;
1905}/* WLANTL_ChangeSTAState */
1906
1907/*===========================================================================
1908
Agarwal Ashish16020c42014-12-29 22:01:11 +05301909 FUNCTION WLANTL_UpdateTdlsSTAClient
1910
1911 DESCRIPTION
1912
1913 HDD will call this API when ENABLE_LINK happens and HDD want to
1914 register QoS or other params for TDLS peers.
1915
1916 DEPENDENCIES
1917
1918 A station must have been registered before the WMM/QOS registration is
1919 called.
1920
1921 PARAMETERS
1922
1923 pvosGCtx: pointer to the global vos context; a handle to TL's
1924 control block can be extracted from its context
1925 wSTADescType: STA Descriptor, contains information related to the
1926 new added STA
1927
1928 RETURN VALUE
1929
1930 The result code associated with performing the operation
1931
1932 VOS_STATUS_E_FAULT: Station ID is outside array boundaries or pointer to
1933 TL cb is NULL ; access would cause a page fault
1934 VOS_STATUS_E_EXISTS: Station was not registered
1935 VOS_STATUS_SUCCESS: Everything is good :)
1936
1937 SIDE EFFECTS
1938
1939============================================================================*/
1940
1941VOS_STATUS
1942WLANTL_UpdateTdlsSTAClient
1943(
1944 v_PVOID_t pvosGCtx,
1945 WLAN_STADescType* pwSTADescType
1946)
1947{
1948 WLANTL_CbType* pTLCb = NULL;
1949 WLANTL_STAClientType* pClientSTA = NULL;
1950 /*------------------------------------------------------------------------
1951 Extract TL control block
1952 ------------------------------------------------------------------------*/
1953 pTLCb = VOS_GET_TL_CB(pvosGCtx);
1954 if ( NULL == pTLCb || ( WLAN_MAX_STA_COUNT <= pwSTADescType->ucSTAId))
1955 {
1956 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1957 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_UpdateTdlsSTAClient"));
1958 return VOS_STATUS_E_FAULT;
1959 }
1960
1961 pClientSTA = pTLCb->atlSTAClients[pwSTADescType->ucSTAId];
1962 if ((NULL == pClientSTA) || 0 == pClientSTA->ucExists)
1963 {
1964 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1965 "WLAN TL:Station not exists"));
1966 return VOS_STATUS_E_FAILURE;
1967 }
1968
1969 pClientSTA->wSTADesc.ucQosEnabled = pwSTADescType->ucQosEnabled;
1970
Masti, Narayanraddic754cdc2015-12-24 18:22:36 +05301971 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
1972 "WLAN TL: %s: ucQosEnabled of pwSTADescType: %d"
1973 "pClientSTA->wSTADesc: %d",
1974 __func__, pwSTADescType->ucQosEnabled,
1975 pClientSTA->wSTADesc.ucQosEnabled));
1976
Agarwal Ashish16020c42014-12-29 22:01:11 +05301977 return VOS_STATUS_SUCCESS;
1978
1979}
1980
Katya Nigame7b69a82015-04-28 15:24:06 +05301981VOS_STATUS WLANTL_SetMonRxCbk(v_PVOID_t pvosGCtx, WLANTL_MonRxCBType pfnMonRx)
1982{
1983 WLANTL_CbType* pTLCb = NULL ;
1984 pTLCb = VOS_GET_TL_CB(pvosGCtx);
1985 if ( NULL == pTLCb )
1986 {
1987 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1988 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_RegisterSTAClient"));
1989 return VOS_STATUS_E_FAULT;
1990 }
1991 pTLCb->pfnMonRx = pfnMonRx;
1992 return VOS_STATUS_SUCCESS;
1993}
1994
1995void WLANTL_SetIsConversionReq(v_PVOID_t pvosGCtx, v_BOOL_t isConversionReq)
1996{
1997 WLANTL_CbType* pTLCb = NULL ;
1998 pTLCb = VOS_GET_TL_CB(pvosGCtx);
1999 if ( NULL == pTLCb )
2000 {
2001 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2002 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_RegisterSTAClient"));
2003 return;
2004 }
2005 pTLCb->isConversionReq = isConversionReq;
2006 return;
2007}
2008
Agarwal Ashish16020c42014-12-29 22:01:11 +05302009
2010/*===========================================================================
2011
Gopichand Nakkala8b54e912013-03-11 10:44:21 +05302012 FUNCTION WLANTL_STAPtkInstalled
2013
2014 DESCRIPTION
2015
2016 HDD will make this notification whenever PTK is installed for the STA
2017
2018 DEPENDENCIES
2019
2020 A station must have been registered before the change state can be
2021 called.
2022
2023 PARAMETERS
2024
2025 pvosGCtx: pointer to the global vos context; a handle to TL's
2026 control block can be extracted from its context
2027 ucSTAId: identifier for the STA for which Pairwise key is
2028 installed
2029
2030 RETURN VALUE
2031
2032 The result code associated with performing the operation
2033
2034 VOS_STATUS_E_FAULT: Station ID is outside array boundaries or pointer to
2035 TL cb is NULL ; access would cause a page fault
2036 VOS_STATUS_E_EXISTS: Station was not registered
2037 VOS_STATUS_SUCCESS: Everything is good :)
2038
2039 SIDE EFFECTS
2040
2041============================================================================*/
2042VOS_STATUS
2043WLANTL_STAPtkInstalled
2044(
2045 v_PVOID_t pvosGCtx,
2046 v_U8_t ucSTAId
2047)
2048{
2049 WLANTL_CbType* pTLCb = NULL;
2050 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
2051
2052 /*------------------------------------------------------------------------
2053 Sanity check
2054 ------------------------------------------------------------------------*/
2055
2056 if ( WLANTL_STA_ID_INVALID( ucSTAId ) )
2057 {
2058 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2059 "WLAN TL:Invalid station id requested on WLANTL_ChangeSTAState"));
2060 return VOS_STATUS_E_FAULT;
2061 }
2062
2063 /*------------------------------------------------------------------------
2064 Extract TL control block and check existance
2065 ------------------------------------------------------------------------*/
2066 pTLCb = VOS_GET_TL_CB(pvosGCtx);
2067 if ( NULL == pTLCb )
2068 {
2069 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2070 FL("WLAN TL:Invalid TL pointer from pvosGCtx")));
2071 return VOS_STATUS_E_FAULT;
2072 }
2073
2074 if ( NULL == pTLCb->atlSTAClients[ucSTAId] )
2075 {
2076 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2077 FL("WLAN TL:Client Memory was not allocated")));
2078 return VOS_STATUS_E_FAILURE;
2079 }
2080
2081 if ( 0 == pTLCb->atlSTAClients[ucSTAId]->ucExists )
2082 {
2083 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2084 FL("WLAN TL:Station was not previously registered")));
2085 return VOS_STATUS_E_EXISTS;
2086 }
2087
2088 pTLCb->atlSTAClients[ucSTAId]->ptkInstalled = 1;
2089
2090 return VOS_STATUS_SUCCESS;
2091}/* WLANTL_STAPtkInstalled */
2092
2093/*===========================================================================
2094
Madan Mohan Koyyalamudifc1d1fe2012-10-18 15:07:12 -07002095 FUNCTION WLANTL_GetSTAState
2096
2097 DESCRIPTION
2098
2099 Returns connectivity state of a particular STA.
2100
2101 DEPENDENCIES
2102
2103 A station must have been registered before its state can be retrieved.
2104
2105
2106 PARAMETERS
2107
2108 IN
2109 pvosGCtx: pointer to the global vos context; a handle to TL's
2110 control block can be extracted from its context
2111 ucSTAId: identifier of the station
2112
2113 OUT
2114 ptlSTAState: the current state of the connection to the given station
2115
2116
2117 RETURN VALUE
2118
2119 The result code associated with performing the operation
2120
2121 VOS_STATUS_E_INVAL: Input parameters are invalid
2122 VOS_STATUS_E_FAULT: Station ID is outside array boundaries or pointer to
2123 TL cb is NULL ; access would cause a page fault
2124 VOS_STATUS_E_EXISTS: Station was not registered
2125 VOS_STATUS_SUCCESS: Everything is good :)
2126
2127 SIDE EFFECTS
2128
2129============================================================================*/
2130VOS_STATUS
2131WLANTL_GetSTAState
2132(
2133 v_PVOID_t pvosGCtx,
2134 v_U8_t ucSTAId,
2135 WLANTL_STAStateType *ptlSTAState
2136)
2137{
2138 WLANTL_CbType* pTLCb = NULL;
2139 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
2140
2141 /*------------------------------------------------------------------------
2142 Sanity check
2143 ------------------------------------------------------------------------*/
2144 if ( NULL == ptlSTAState )
2145 {
2146 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2147 "WLAN TL:Invalid parameter sent on WLANTL_GetSTAState"));
2148 return VOS_STATUS_E_INVAL;
2149 }
2150
2151 if ( WLANTL_STA_ID_INVALID( ucSTAId ) )
2152 {
2153 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2154 "WLAN TL:Invalid station id requested on WLANTL_GetSTAState"));
2155 return VOS_STATUS_E_FAULT;
2156 }
2157
2158 /*------------------------------------------------------------------------
2159 Extract TL control block and check existance
2160 ------------------------------------------------------------------------*/
2161 pTLCb = VOS_GET_TL_CB(pvosGCtx);
2162 if ( NULL == pTLCb )
2163 {
2164 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2165 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_GetSTAState"));
2166 return VOS_STATUS_E_FAULT;
2167 }
2168
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302169 if ( NULL == pTLCb->atlSTAClients[ucSTAId] )
2170 {
2171 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2172 "WLAN TL:Client Memory was not allocated on %s", __func__));
2173 return VOS_STATUS_E_FAILURE;
2174 }
2175
2176 if ( 0 == pTLCb->atlSTAClients[ucSTAId]->ucExists )
Madan Mohan Koyyalamudifc1d1fe2012-10-18 15:07:12 -07002177 {
Sunil Ravid5406f22013-01-22 00:18:31 -08002178 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
Madan Mohan Koyyalamudifc1d1fe2012-10-18 15:07:12 -07002179 "WLAN TL:Station was not previously registered on WLANTL_GetSTAState"));
2180 return VOS_STATUS_E_EXISTS;
2181 }
2182
2183 /*------------------------------------------------------------------------
2184 Get STA state
2185 ------------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302186 *ptlSTAState = pTLCb->atlSTAClients[ucSTAId]->tlState;
Madan Mohan Koyyalamudifc1d1fe2012-10-18 15:07:12 -07002187
2188 return VOS_STATUS_SUCCESS;
2189}/* WLANTL_GetSTAState */
2190
Shailender Karmuchia734f332013-04-19 14:02:48 -07002191/*==========================================================================
2192 FUNCTION WLANTL_UpdateSTABssIdforIBSS
2193
2194 DESCRIPTION
2195 HDD will call this API to update the BSSID for this Station.
2196
2197 DEPENDENCIES
2198 The HDD Should registered the staID with TL before calling this function.
2199
2200 PARAMETERS
2201
2202 IN
2203 pvosGCtx: Pointer to the global vos context; a handle to TL's
2204 or WDA's control block can be extracted from its context
2205 IN
2206 ucSTAId The Station ID for Bssid to be updated
2207 IN
2208 pBssid BSSID to be updated
2209
2210 RETURN VALUE
2211 The result code associated with performing the operation
2212
2213 VOS_STATUS_E_INVAL: Input parameters are invalid
2214 VOS_STATUS_E_FAULT: Station ID is outside array boundaries or pointer to
2215 TL cb is NULL ; access would cause a page fault
2216 VOS_STATUS_E_EXISTS: Station was not registered
2217 VOS_STATUS_SUCCESS: Everything is good :)
2218
2219 SIDE EFFECTS
2220============================================================================*/
2221
2222
2223VOS_STATUS
2224WLANTL_UpdateSTABssIdforIBSS
2225(
2226 v_PVOID_t pvosGCtx,
2227 v_U8_t ucSTAId,
2228 v_U8_t *pBssid
2229)
2230{
2231 WLANTL_CbType* pTLCb = NULL;
2232 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
2233
2234 /*------------------------------------------------------------------------
2235 Sanity check
2236 ------------------------------------------------------------------------*/
2237 if ( WLANTL_STA_ID_INVALID( ucSTAId ) )
2238 {
2239 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2240 "WLAN TL:Invalid station id requested %s", __func__));
2241 return VOS_STATUS_E_FAULT;
2242 }
2243
2244 /*------------------------------------------------------------------------
2245 Extract TL control block and check existance
2246 ------------------------------------------------------------------------*/
2247 pTLCb = VOS_GET_TL_CB(pvosGCtx);
2248 if ( NULL == pTLCb )
2249 {
2250 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2251 "WLAN TL:Invalid TL pointer from pvosGCtx %s", __func__));
2252 return VOS_STATUS_E_FAULT;
2253 }
2254
2255 if ( NULL == pTLCb->atlSTAClients[ucSTAId] )
2256 {
2257 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2258 "WLAN TL:Client Memory was not allocated on %s", __func__));
2259 return VOS_STATUS_E_FAILURE;
2260 }
2261
2262 if ( 0 == pTLCb->atlSTAClients[ucSTAId]->ucExists )
2263 {
2264 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
2265 "WLAN TL:Station was not previously registered %s", __func__));
2266 return VOS_STATUS_E_EXISTS;
2267 }
2268
2269 /*------------------------------------------------------------------------
2270 Update the IBSS BSSID
2271 ------------------------------------------------------------------------*/
2272 vos_mem_copy( &pTLCb->atlSTAClients[ucSTAId]->wSTADesc.vBSSIDforIBSS,
2273 pBssid, sizeof(v_MACADDR_t));
2274
2275 return VOS_STATUS_SUCCESS;
2276}
2277
Madan Mohan Koyyalamudifc1d1fe2012-10-18 15:07:12 -07002278/*===========================================================================
2279
Jeff Johnson295189b2012-06-20 16:38:30 -07002280 FUNCTION WLANTL_STAPktPending
2281
2282 DESCRIPTION
2283
2284 HDD will call this API when a packet is pending transmission in its
2285 queues.
2286
2287 DEPENDENCIES
2288
2289 A station must have been registered before the packet pending
2290 notification can be sent.
2291
2292 RESTRICTION: TL will not count packets for pending notification.
2293 HDD is expected to send the notification only when
2294 non-empty event gets triggered. Worst case scenario
2295 is that TL might end up making a call when Hdds
2296 queues are actually empty.
2297
2298 PARAMETERS
2299
2300 pvosGCtx: pointer to the global vos context; a handle to TL's
2301 control block can be extracted from its context
2302 ucSTAId: identifier for the STA that is pending transmission
2303
2304 RETURN VALUE
2305
2306 The result code associated with performing the operation
2307
2308 VOS_STATUS_E_INVAL: Input parameters are invalid
2309 VOS_STATUS_E_FAULT: Station ID is outside array boundaries or pointer
2310 to TL cb is NULL ; access would cause a page fault
2311 VOS_STATUS_E_EXISTS: Station was not registered
2312 VOS_STATUS_SUCCESS: Everything is good :)
2313
2314 SIDE EFFECTS
2315
2316============================================================================*/
2317VOS_STATUS
2318WLANTL_STAPktPending
2319(
2320 v_PVOID_t pvosGCtx,
2321 v_U8_t ucSTAId,
2322 WLANTL_ACEnumType ucAc
2323)
2324{
2325 WLANTL_CbType* pTLCb = NULL;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302326 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002327 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
2328
2329 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
2330 "WLAN TL:Packet pending indication for STA: %d AC: %d", ucSTAId, ucAc);
2331
2332 /*------------------------------------------------------------------------
2333 Sanity check
2334 ------------------------------------------------------------------------*/
2335 if ( WLANTL_STA_ID_INVALID( ucSTAId ) )
2336 {
2337 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2338 "WLAN TL:Invalid station id requested on WLANTL_STAPktPending"));
2339 return VOS_STATUS_E_FAULT;
2340 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002341 /*------------------------------------------------------------------------
2342 Extract TL control block and check existance
2343 ------------------------------------------------------------------------*/
2344 pTLCb = VOS_GET_TL_CB(pvosGCtx);
2345 if ( NULL == pTLCb )
2346 {
2347 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2348 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_STAPktPending"));
2349 return VOS_STATUS_E_FAULT;
2350 }
2351
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302352 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
2353
2354 if ( NULL == pClientSTA )
2355 {
2356 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2357 "WLAN TL:Client Memory was not allocated on %s", __func__));
2358 return VOS_STATUS_E_FAILURE;
2359 }
2360
2361 if ( 0 == pClientSTA->ucExists )
Jeff Johnson295189b2012-06-20 16:38:30 -07002362 {
Katya Nigamb130d572014-11-24 16:38:16 +05302363 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07002364 "WLAN TL:Station was not previously registered on WLANTL_STAPktPending"));
2365 return VOS_STATUS_E_EXISTS;
2366 }
2367
2368 /*---------------------------------------------------------------------
2369 Temporary fix to enable TL to fetch packets when multiple peers join
2370 an IBSS. To fix CR177301. Needs to go away when the actual fix of
2371 going through all STA's in round robin fashion gets merged in from
2372 BT AMP branch.
2373 --------------------------------------------------------------------*/
2374 pTLCb->ucRegisteredStaId = ucSTAId;
2375
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302376 if( WLANTL_STA_CONNECTED == pClientSTA->tlState )
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -07002377 { /* EAPOL_HI_PRIORITY : need to find out whether EAPOL is pending before
2378 WLANTL_FetchPacket()/WLANTL_TxConn() is called.
2379 change STA_AUTHENTICATED != tlState to CONNECTED == tlState
2380 to make sure TL is indeed waiting for EAPOL.
2381 Just in the case when STA got disconnected shortly after connectection */
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302382 pClientSTA->ucEapolPktPending = 1;
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -07002383
Katya Nigam42e16e82014-02-04 16:28:55 +05302384 MTRACE(vos_trace(VOS_MODULE_ID_TL,
2385 TRACE_CODE_TL_EAPOL_PKT_PENDING, ucSTAId, ucAc));
2386
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -07002387 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07002388 "WLAN TL:Packet pending indication for STA: %d AC: %d State: %d",
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302389 ucSTAId, ucAc, pClientSTA->tlState);
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07002390 }
2391
Jeff Johnson295189b2012-06-20 16:38:30 -07002392 /*-----------------------------------------------------------------------
2393 Enable this AC in the AC mask in order for TL to start servicing it
2394 Set packet pending flag
2395 To avoid race condition, serialize the updation of AC and AC mask
2396 through WLANTL_TX_STAID_AC_IND message.
2397 -----------------------------------------------------------------------*/
Jeff Johnson295189b2012-06-20 16:38:30 -07002398
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302399 pClientSTA->aucACMask[ucAc] = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07002400
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302401 vos_atomic_set_U8( &pClientSTA->ucPktPending, 1);
Jeff Johnson295189b2012-06-20 16:38:30 -07002402
2403 /*------------------------------------------------------------------------
2404 Check if there are enough resources for transmission and tx is not
2405 suspended.
2406 ------------------------------------------------------------------------*/
Nirav Shah4b53d4b2015-05-08 05:35:00 -07002407 if (( pTLCb->uResCount >= WDA_TLI_MIN_RES_DATA ) &&
2408 ( 0 == pTLCb->ucTxSuspended ))
Jeff Johnson295189b2012-06-20 16:38:30 -07002409 {
Katya Nigam42e16e82014-02-04 16:28:55 +05302410
Jeff Johnson295189b2012-06-20 16:38:30 -07002411 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
2412 "Issuing Xmit start request to BAL"));
2413 WDA_DS_StartXmit(pvosGCtx);
2414 }
2415 else
2416 {
2417 /*---------------------------------------------------------------------
2418 No error code is sent because TL will resume tx autonomously if
2419 resources become available or tx gets resumed
2420 ---------------------------------------------------------------------*/
Madan Mohan Koyyalamudi179e6fe2012-10-15 15:31:08 -07002421 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
Jeff Johnson295189b2012-06-20 16:38:30 -07002422 "WLAN TL:Request to send but condition not met. Res: %d,Suspend: %d",
Madan Mohan Koyyalamudi48139e32012-10-11 14:43:56 -07002423 pTLCb->uResCount, pTLCb->ucTxSuspended );
Jeff Johnson295189b2012-06-20 16:38:30 -07002424 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002425 return VOS_STATUS_SUCCESS;
2426}/* WLANTL_STAPktPending */
2427
2428/*==========================================================================
2429
2430 FUNCTION WLANTL_SetSTAPriority
2431
2432 DESCRIPTION
2433
2434 TL exposes this API to allow upper layers a rough control over the
2435 priority of transmission for a given station when supporting multiple
2436 connections.
2437
2438 DEPENDENCIES
2439
2440 A station must have been registered before the change in priority can be
2441 called.
2442
2443 PARAMETERS
2444
2445 pvosGCtx: pointer to the global vos context; a handle to TL's
2446 control block can be extracted from its context
2447 ucSTAId: identifier for the STA that has to change priority
2448
2449 RETURN VALUE
2450
2451 The result code associated with performing the operation
2452
2453 VOS_STATUS_E_INVAL: Input parameters are invalid
2454 VOS_STATUS_E_FAULT: Station ID is outside array boundaries or pointer
2455 to TL cb is NULL ; access would cause a page fault
2456 VOS_STATUS_E_EXISTS: Station was not registered
2457 VOS_STATUS_SUCCESS: Everything is good :)
2458
2459 SIDE EFFECTS
2460
2461============================================================================*/
2462VOS_STATUS
2463WLANTL_SetSTAPriority
2464(
2465 v_PVOID_t pvosGCtx,
2466 v_U8_t ucSTAId,
2467 WLANTL_STAPriorityType tlSTAPri
2468)
2469{
2470 WLANTL_CbType* pTLCb = NULL;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302471 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002472 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
2473
2474 /*------------------------------------------------------------------------
2475 Sanity check
2476 ------------------------------------------------------------------------*/
2477 if ( WLANTL_STA_ID_INVALID( ucSTAId ) )
2478 {
2479 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2480 "WLAN TL:Invalid station id requested on WLANTL_SetSTAPriority"));
2481 return VOS_STATUS_E_FAULT;
2482 }
2483
2484 /*------------------------------------------------------------------------
2485 Extract TL control block
2486 ------------------------------------------------------------------------*/
2487 pTLCb = VOS_GET_TL_CB(pvosGCtx);
2488 if ( NULL == pTLCb )
2489 {
2490 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2491 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_SetSTAPriority"));
2492 return VOS_STATUS_E_FAULT;
2493 }
2494
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302495 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
2496
2497 if ( NULL == pClientSTA )
2498 {
2499 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2500 "WLAN TL:Client Memory was not allocated on %s", __func__));
2501 return VOS_STATUS_E_FAILURE;
2502 }
2503
2504 if ( 0 == pClientSTA->ucExists )
Jeff Johnson295189b2012-06-20 16:38:30 -07002505 {
2506 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2507 "WLAN TL:Station was not previously registered on WLANTL_SetSTAPriority"));
2508 return VOS_STATUS_E_EXISTS;
2509 }
2510
2511 /*------------------------------------------------------------------------
2512 Re-analize if lock is needed when adding multiple stations
2513 ------------------------------------------------------------------------*/
2514 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
2515 "WLAN TL:Changing state for STA Pri ID: %d from %d to %d",
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302516 ucSTAId, pClientSTA->tlPri, tlSTAPri));
2517 pClientSTA->tlPri = tlSTAPri;
Jeff Johnson295189b2012-06-20 16:38:30 -07002518
2519 return VOS_STATUS_SUCCESS;
2520}/* WLANTL_SetSTAPriority */
2521
2522
2523/*----------------------------------------------------------------------------
2524 INTERACTION WITH BAP
2525 ---------------------------------------------------------------------------*/
2526
2527/*==========================================================================
2528
2529 FUNCTION WLANTL_RegisterBAPClient
2530
2531 DESCRIPTION
2532 Called by SME to register itself as client for non-data BT-AMP packets.
2533
2534 DEPENDENCIES
2535 TL must be initialized before this function can be called.
2536
2537 PARAMETERS
2538
2539 IN
2540 pvosGCtx: pointer to the global vos context; a handle to TL's
2541 or SME's control block can be extracted from its context
2542 pfnTlBAPRxFrm: pointer to the receive processing routine for non-data
2543 BT-AMP packets
2544 pfnFlushOpCompleteCb:
2545 pointer to the call back function, for the Flush operation
2546 completion.
2547
2548
2549 RETURN VALUE
2550
2551 The result code associated with performing the operation
2552
2553 VOS_STATUS_E_INVAL: Input parameters are invalid
2554 VOS_STATUS_E_FAULT: Station ID is outside array boundaries or pointer
2555 to TL cb is NULL ; access would cause a page fault
2556 VOS_STATUS_E_EXISTS: BAL client was already registered
2557 VOS_STATUS_SUCCESS: Everything is good :)
2558
2559 SIDE EFFECTS
2560
2561============================================================================*/
2562VOS_STATUS
2563WLANTL_RegisterBAPClient
2564(
2565 v_PVOID_t pvosGCtx,
2566 WLANTL_BAPRxCBType pfnTlBAPRxFrm,
2567 WLANTL_FlushOpCompCBType pfnFlushOpCompleteCb
2568)
2569{
2570 WLANTL_CbType* pTLCb = NULL;
2571 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
2572
2573 /*------------------------------------------------------------------------
2574 Sanity check
2575 ------------------------------------------------------------------------*/
2576 if ( NULL == pfnTlBAPRxFrm )
2577 {
2578 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2579 "WLAN TL:Invalid parameter sent on WLANTL_RegisterBAPClient"));
2580 return VOS_STATUS_E_INVAL;
2581 }
2582
2583 if ( NULL == pfnFlushOpCompleteCb )
2584 {
2585 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2586 "Invalid Flush Complete Cb parameter sent on WLANTL_RegisterBAPClient"));
2587 return VOS_STATUS_E_INVAL;
2588 }
2589
2590 /*------------------------------------------------------------------------
2591 Extract TL control block
2592 ------------------------------------------------------------------------*/
2593 pTLCb = VOS_GET_TL_CB(pvosGCtx);
2594 if ( NULL == pTLCb )
2595 {
2596 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2597 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_RegisterBAPClient"));
2598 return VOS_STATUS_E_FAULT;
2599 }
2600
2601 /*------------------------------------------------------------------------
2602 Make sure this is the first registration attempt
2603 ------------------------------------------------------------------------*/
2604 if ( 0 != pTLCb->tlBAPClient.ucExists )
2605 {
2606 pTLCb->tlBAPClient.ucExists++;
2607 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2608 "WLAN TL:BAP client was already registered"));
2609 return VOS_STATUS_E_EXISTS;
2610 }
2611
2612 /*------------------------------------------------------------------------
2613 Register station with TL
2614 ------------------------------------------------------------------------*/
2615 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
2616 "WLAN TL:Registering BAP Client" ));
2617
2618 pTLCb->tlBAPClient.ucExists++;
2619
2620 if ( NULL != pfnTlBAPRxFrm )
2621 {
2622 pTLCb->tlBAPClient.pfnTlBAPRx = pfnTlBAPRxFrm;
2623 }
2624
2625 pTLCb->tlBAPClient.pfnFlushOpCompleteCb = pfnFlushOpCompleteCb;
2626
2627 pTLCb->tlBAPClient.vosPendingDataBuff = NULL;
2628
2629 return VOS_STATUS_SUCCESS;
2630}/* WLANTL_RegisterBAPClient */
2631
2632
2633/*==========================================================================
2634
2635 FUNCTION WLANTL_TxBAPFrm
2636
2637 DESCRIPTION
2638 BAP calls this when it wants to send a frame to the module
2639
2640 DEPENDENCIES
2641 BAP must be registered with TL before this function can be called.
2642
2643 RESTRICTION: BAP CANNOT push any packets to TL until it did not receive
2644 a tx complete from the previous packet, that means BAP
2645 sends one packet, wait for tx complete and then
2646 sends another one
2647
2648 If BAP sends another packet before TL manages to process the
2649 previously sent packet call will end in failure
2650
2651 PARAMETERS
2652
2653 IN
2654 pvosGCtx: pointer to the global vos context; a handle to TL's
2655 or BAP's control block can be extracted from its context
2656 vosDataBuff: pointer to the vOSS buffer containing the packet to be
2657 transmitted
2658 pMetaInfo: meta information about the packet
2659 pfnTlBAPTxComp: pointer to a transmit complete routine for notifying
2660 the result of the operation over the bus
2661
2662 RETURN VALUE
2663 The result code associated with performing the operation
2664
2665 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
2666 page fault
2667 VOS_STATUS_E_EXISTS: BAL client was not yet registered
2668 VOS_STATUS_E_BUSY: The previous BT-AMP packet was not yet transmitted
2669 VOS_STATUS_SUCCESS: Everything is good :)
2670
2671 Other failure messages may be returned from the BD header handling
2672 routines, please check apropriate API for more info.
2673
2674 SIDE EFFECTS
2675
2676============================================================================*/
2677VOS_STATUS
2678WLANTL_TxBAPFrm
2679(
2680 v_PVOID_t pvosGCtx,
2681 vos_pkt_t* vosDataBuff,
2682 WLANTL_MetaInfoType* pMetaInfo,
2683 WLANTL_TxCompCBType pfnTlBAPTxComp
2684)
2685{
2686 WLANTL_CbType* pTLCb = NULL;
2687 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
2688 v_MACADDR_t vDestMacAddr;
2689 v_U16_t usPktLen;
2690 v_U8_t ucStaId = 0;
2691 v_U8_t extraHeadSpace = 0;
2692 v_U8_t ucWDSEnabled = 0;
2693 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
2694
2695 /*------------------------------------------------------------------------
2696 Sanity check
2697 Extract TL control block
2698 ------------------------------------------------------------------------*/
2699 pTLCb = VOS_GET_TL_CB(pvosGCtx);
2700 if ( NULL == pTLCb )
2701 {
2702 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2703 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_TxBAPFrm"));
2704 return VOS_STATUS_E_FAULT;
2705 }
2706
2707 /*------------------------------------------------------------------------
2708 Ensure that BAP client was registered previously
2709 ------------------------------------------------------------------------*/
2710 if (( 0 == pTLCb->tlBAPClient.ucExists ) ||
2711 ( WLANTL_STA_ID_INVALID(pTLCb->tlBAPClient.ucBAPSTAId) ))
2712 {
2713 pTLCb->tlBAPClient.ucExists++;
2714 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2715 "WLAN TL:BAP client not register on WLANTL_TxBAPFrm"));
2716 return VOS_STATUS_E_EXISTS;
2717 }
2718
2719 /*------------------------------------------------------------------------
2720 Check if any BT-AMP Frm is pending
2721 ------------------------------------------------------------------------*/
2722 if ( NULL != pTLCb->tlBAPClient.vosPendingDataBuff )
2723 {
2724 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2725 "WLAN TL:BT-AMP Frame already pending tx in TL on WLANTL_TxBAPFrm"));
2726 return VOS_STATUS_E_BUSY;
2727 }
2728
2729 /*------------------------------------------------------------------------
2730 Save buffer and notify BAL; no lock is needed if the above restriction
2731 is met
2732 Save the tx complete fnct pointer as tl specific data in the vos buffer
2733 ------------------------------------------------------------------------*/
2734
2735 /*------------------------------------------------------------------------
2736 Translate 802.3 frame to 802.11
2737 ------------------------------------------------------------------------*/
2738 ucStaId = pTLCb->tlBAPClient.ucBAPSTAId;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302739 if ( NULL == pTLCb->atlSTAClients[ucStaId] )
2740 {
2741 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2742 "WLAN TL:Client Memory was not allocated on %s", __func__));
2743 return VOS_STATUS_E_FAILURE;
2744 }
2745 if (( 0 == pMetaInfo->ucDisableFrmXtl ) &&
2746 ( 0 != pTLCb->atlSTAClients[ucStaId]->wSTADesc.ucSwFrameTXXlation ))
Jeff Johnson295189b2012-06-20 16:38:30 -07002747 {
Kiran Venkatappacab0d352012-12-17 13:09:22 -08002748 vosStatus = WLANTL_Translate8023To80211Header( vosDataBuff, &vosStatus,
2749 pTLCb, &ucStaId,
Ravi Joshid0699502013-07-08 15:48:47 -07002750 pMetaInfo, &ucWDSEnabled,
2751 &extraHeadSpace);
Jeff Johnson295189b2012-06-20 16:38:30 -07002752
2753 if ( VOS_STATUS_SUCCESS != vosStatus )
2754 {
2755 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2756 "WLAN TL:Error when translating header WLANTL_TxBAPFrm"));
2757
2758 return vosStatus;
2759 }
2760
2761 pMetaInfo->ucDisableFrmXtl = 1;
2762 }
2763
2764 /*-------------------------------------------------------------------------
2765 Call HAL to fill BD header
2766 -------------------------------------------------------------------------*/
2767
2768 /* Adding Type, SubType which was missing for EAPOL from BAP */
2769 pMetaInfo->ucType |= (WLANTL_80211_DATA_TYPE << 4);
2770 pMetaInfo->ucType |= (WLANTL_80211_DATA_QOS_SUBTYPE);
2771
2772 vosStatus = WDA_DS_BuildTxPacketInfo( pvosGCtx, vosDataBuff ,
2773 &vDestMacAddr, pMetaInfo->ucDisableFrmXtl,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302774 &usPktLen, pTLCb->atlSTAClients[ucStaId]->wSTADesc.ucQosEnabled,
Jeff Johnson295189b2012-06-20 16:38:30 -07002775 ucWDSEnabled, extraHeadSpace, pMetaInfo->ucType,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302776 &pTLCb->atlSTAClients[ucStaId]->wSTADesc.vSelfMACAddress,
Jeff Johnson295189b2012-06-20 16:38:30 -07002777 pMetaInfo->ucTID, 0 /* No ACK */, pMetaInfo->usTimeStamp,
Ganesh Kondabattini10e67352015-03-16 17:41:57 +05302778 pMetaInfo->ucIsEapol || pMetaInfo->ucIsWai, pMetaInfo->ucUP,
2779 pMetaInfo->ucTxBdToken);
Jeff Johnson295189b2012-06-20 16:38:30 -07002780
2781 if ( VOS_STATUS_SUCCESS != vosStatus )
2782 {
2783 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2784 "WLAN TL:Failed while building TX header %d", vosStatus));
2785 return vosStatus;
2786 }
2787
2788 if ( NULL != pfnTlBAPTxComp )
2789 {
2790 vos_pkt_set_user_data_ptr( vosDataBuff, VOS_PKT_USER_DATA_ID_TL,
2791 (v_PVOID_t)pfnTlBAPTxComp);
2792 }
2793 else
2794 {
2795 vos_pkt_set_user_data_ptr( vosDataBuff, VOS_PKT_USER_DATA_ID_TL,
2796 (v_PVOID_t)WLANTL_TxCompDefaultCb);
2797
2798 }
2799
Arun Kumar Khandavalli0af8d3c2014-02-07 18:05:11 +05302800 vos_atomic_set( (uintptr_t*)&pTLCb->tlBAPClient.vosPendingDataBuff,
2801 (uintptr_t)vosDataBuff);
Jeff Johnson295189b2012-06-20 16:38:30 -07002802
2803 /*------------------------------------------------------------------------
2804 Check if thre are enough resources for transmission and tx is not
2805 suspended.
2806 ------------------------------------------------------------------------*/
2807 if (( pTLCb->uResCount >= WDA_TLI_MIN_RES_BAP ) &&
2808 ( 0 == pTLCb->ucTxSuspended ))
2809 {
2810 WDA_DS_StartXmit(pvosGCtx);
2811 }
2812 else
2813 {
2814 /*---------------------------------------------------------------------
2815 No error code is sent because TL will resume tx autonomously if
2816 resources become available or tx gets resumed
2817 ---------------------------------------------------------------------*/
2818 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
2819 "WLAN TL:Request to send from BAP but condition not met.Res: %d,"
2820 "Suspend: %d", pTLCb->uResCount, pTLCb->ucTxSuspended ));
2821 }
2822
2823 return VOS_STATUS_SUCCESS;
2824}/* WLANTL_TxBAPFrm */
2825
2826
2827/*----------------------------------------------------------------------------
2828 INTERACTION WITH SME
2829 ---------------------------------------------------------------------------*/
2830
2831/*==========================================================================
2832
2833 FUNCTION WLANTL_GetRssi
2834
2835 DESCRIPTION
2836 TL will extract the RSSI information from every data packet from the
2837 ongoing traffic and will store it. It will provide the result to SME
2838 upon request.
2839
2840 DEPENDENCIES
2841
2842 WARNING: the read and write of this value will not be protected
2843 by locks, therefore the information obtained after a read
2844 might not always be consistent.
2845
2846 PARAMETERS
2847
2848 IN
2849 pvosGCtx: pointer to the global vos context; a handle to TL's
2850 or SME's control block can be extracted from its context
2851 ucSTAId: station identifier for the requested value
2852
2853 OUT
2854 puRssi: the average value of the RSSI
2855
2856
2857 RETURN VALUE
2858 The result code associated with performing the operation
2859
2860 VOS_STATUS_E_INVAL: Input parameters are invalid
2861 VOS_STATUS_E_FAULT: Station ID is outside array boundaries or pointer
2862 to TL cb is NULL ; access would cause a page fault
2863 VOS_STATUS_E_EXISTS: STA was not yet registered
2864 VOS_STATUS_SUCCESS: Everything is good :)
2865
2866 SIDE EFFECTS
2867
2868============================================================================*/
2869VOS_STATUS
2870WLANTL_GetRssi
2871(
2872 v_PVOID_t pvosGCtx,
2873 v_U8_t ucSTAId,
2874 v_S7_t* pRssi
2875)
2876{
2877 WLANTL_CbType* pTLCb = NULL;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302878 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002879 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
2880
2881 /*------------------------------------------------------------------------
2882 Sanity check
2883 ------------------------------------------------------------------------*/
2884 if ( NULL == pRssi )
2885 {
2886 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2887 "WLAN TL:Invalid parameter sent on WLANTL_GetRssi"));
2888 return VOS_STATUS_E_INVAL;
2889 }
2890
2891 if ( WLANTL_STA_ID_INVALID( ucSTAId ) )
2892 {
2893 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2894 "WLAN TL:Invalid station id requested on WLANTL_GetRssi"));
2895 return VOS_STATUS_E_FAULT;
2896 }
2897
2898 /*------------------------------------------------------------------------
2899 Extract TL control block and check existance
2900 ------------------------------------------------------------------------*/
2901 pTLCb = VOS_GET_TL_CB(pvosGCtx);
2902 if ( NULL == pTLCb )
2903 {
2904 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2905 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_GetRssi"));
2906 return VOS_STATUS_E_FAULT;
2907 }
2908
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302909 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
2910
2911 if ( NULL == pClientSTA )
2912 {
2913 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2914 "WLAN TL:Client Memory was not allocated on %s", __func__));
2915 return VOS_STATUS_E_FAILURE;
2916 }
2917
2918 if ( 0 == pClientSTA->ucExists )
Jeff Johnson295189b2012-06-20 16:38:30 -07002919 {
2920 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2921 "WLAN TL:Station was not previously registered on WLANTL_GetRssi"));
2922 return VOS_STATUS_E_EXISTS;
2923 }
2924
2925 /*------------------------------------------------------------------------
2926 Copy will not be locked; please read restriction
2927 ------------------------------------------------------------------------*/
Katya Nigam5c2e5f62013-11-15 19:19:11 +05302928 if(pTLCb->isBMPS || IS_ACTIVEMODE_OFFLOAD_FEATURE_ENABLE)
Jeff Johnson295189b2012-06-20 16:38:30 -07002929 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302930 *pRssi = pClientSTA->rssiAvgBmps;
Jeff Johnson295189b2012-06-20 16:38:30 -07002931 /* Check If RSSI is zero because we are reading rssAvgBmps updated by HAL in
2932 previous GetStatsRequest. It may be updated as zero by Hal because EnterBmps
2933 might not have happend by that time. Hence reading the most recent Rssi
2934 calcluated by TL*/
2935 if(0 == *pRssi)
2936 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302937 *pRssi = pClientSTA->rssiAvg;
Jeff Johnson295189b2012-06-20 16:38:30 -07002938 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002939 }
2940 else
2941 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302942 *pRssi = pClientSTA->rssiAvg;
Jeff Johnson295189b2012-06-20 16:38:30 -07002943 }
2944
2945 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
Jeff Johnson32d95a32012-09-10 13:15:23 -07002946 "WLAN TL:WLANTL_GetRssi for STA: %d RSSI: %d%s",
2947 ucSTAId, *pRssi,
2948 pTLCb->isBMPS ? " in BMPS" : ""));
Jeff Johnson295189b2012-06-20 16:38:30 -07002949
2950 return VOS_STATUS_SUCCESS;
2951}/* WLANTL_GetRssi */
2952
2953/*==========================================================================
2954
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05302955 FUNCTION WLANTL_GetSnr
2956
2957 DESCRIPTION
2958 TL will extract the SNR information from every data packet from the
2959 ongoing traffic and will store it. It will provide the result to SME
2960 upon request.
2961
2962 DEPENDENCIES
2963
2964 WARNING: the read and write of this value will not be protected
2965 by locks, therefore the information obtained after a read
2966 might not always be consistent.
2967
2968 PARAMETERS
2969
2970 IN
2971 pvosGCtx: pointer to the global vos context; a handle to TL's
2972 or SME's control block can be extracted from its context
2973 ucSTAId: station identifier for the requested value
2974
2975 OUT
2976 pSnr: the average value of the SNR
2977
2978
2979 RETURN VALUE
2980 The result code associated with performing the operation
2981
2982 VOS_STATUS_E_INVAL: Input parameters are invalid
2983 VOS_STATUS_E_FAULT: Station ID is outside array boundaries or pointer
2984 to TL cb is NULL ; access would cause a page fault
2985 VOS_STATUS_E_EXISTS: STA was not yet registered
2986 VOS_STATUS_SUCCESS: Everything is good :)
2987
2988 SIDE EFFECTS
2989
2990============================================================================*/
2991VOS_STATUS
2992WLANTL_GetSnr
2993(
2994 tANI_U8 ucSTAId,
2995 tANI_S8* pSnr
2996)
2997{
2998 WLANTL_CbType* pTLCb = NULL;
2999 WLANTL_STAClientType* pClientSTA = NULL;
3000 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
3001
3002 /*------------------------------------------------------------------------
3003 Sanity check
3004 ------------------------------------------------------------------------*/
3005 if (NULL == pSnr)
3006 {
3007 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3008 "WLAN TL:Invalid parameter sent on %s", __func__));
3009 return VOS_STATUS_E_INVAL;
3010 }
3011
3012 if (WLANTL_STA_ID_INVALID(ucSTAId))
3013 {
3014 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3015 "WLAN TL:Invalid station id requested on %s", __func__));
3016 return VOS_STATUS_E_FAULT;
3017 }
3018
3019 /*------------------------------------------------------------------------
3020 Extract TL control block and check existance
3021 ------------------------------------------------------------------------*/
3022 pTLCb = VOS_GET_TL_CB(vos_get_global_context(VOS_MODULE_ID_TL, NULL));
3023 if (NULL == pTLCb)
3024 {
3025 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3026 "WLAN TL:Invalid TL pointer from pvosGCtx on %s", __func__));
3027 return VOS_STATUS_E_FAULT;
3028 }
3029
3030 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
3031
3032 if (NULL == pClientSTA)
3033 {
3034 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3035 "WLAN TL:Client Memory was not allocated on %s", __func__));
3036 return VOS_STATUS_E_FAILURE;
3037 }
3038
3039 if (0 == pClientSTA->ucExists)
3040 {
3041 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3042 "WLAN TL:Station was not previously registered on %s", __func__));
3043 return VOS_STATUS_E_EXISTS;
3044 }
3045
3046 /*------------------------------------------------------------------------
3047 Copy will not be locked; please read restriction
3048 ------------------------------------------------------------------------*/
3049 if (pTLCb->isBMPS)
3050 {
3051 *pSnr = pClientSTA->snrAvgBmps;
3052 }
3053 else
3054 {
3055 /* SNR is averaged over WLANTL_MAX_SNR_DATA_SAMPLES, if there are not enough
3056 * data samples (snridx) to calculate the average then return the
3057 * average for the window of prevoius 20 packets. And if there aren't
3058 * enough samples and the average for previous window of 20 packets is
3059 * not available then return a predefined value
3060 *
3061 * NOTE: the SNR_HACK_BMPS value is defined to 127, documents from HW
3062 * team reveal that the SNR value has a ceiling well below 127 dBm,
3063 * so if SNR has value of 127 the userspace applications can know that
3064 * the SNR has not been computed yet because enough data was not
3065 * available for SNR calculation
3066 */
3067 if (pClientSTA->snrIdx > (WLANTL_MAX_SNR_DATA_SAMPLES/2)
3068 || !(pClientSTA->prevSnrAvg))
3069 {
3070 *pSnr = pClientSTA->snrSum / pClientSTA->snrIdx;
3071 }
3072 else if (pClientSTA->prevSnrAvg)
3073 {
3074 *pSnr = pClientSTA->prevSnrAvg;
3075 }
3076 else
3077 {
3078 *pSnr = SNR_HACK_BMPS;
3079 }
3080 }
3081
3082 VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
3083 "WLAN TL:WLANTL_GetSnr for STA: %d SNR: %d%s",
3084 ucSTAId, *pSnr,
3085 pTLCb->isBMPS ? " in BMPS" : "");
3086
3087 return VOS_STATUS_SUCCESS;
3088}/* WLANTL_GetSnr */
3089/*==========================================================================
3090
Jeff Johnson295189b2012-06-20 16:38:30 -07003091 FUNCTION WLANTL_GetLinkQuality
3092
3093 DESCRIPTION
3094 TL will extract the SNR information from every data packet from the
3095 ongoing traffic and will store it. It will provide the result to SME
3096 upon request.
3097
3098 DEPENDENCIES
3099
3100 WARNING: the read and write of this value will not be protected
3101 by locks, therefore the information obtained after a read
3102 might not always be consistent.
3103
3104 PARAMETERS
3105
3106 IN
3107 pvosGCtx: pointer to the global vos context; a handle to TL's
3108 or SME's control block can be extracted from its context
3109 ucSTAId: station identifier for the requested value
3110
3111 OUT
3112 puLinkQuality: the average value of the SNR
3113
3114
3115 RETURN VALUE
3116 The result code associated with performing the operation
3117
3118 VOS_STATUS_E_INVAL: Input parameters are invalid
3119 VOS_STATUS_E_FAULT: Station ID is outside array boundaries or pointer
3120 to TL cb is NULL ; access would cause a page fault
3121 VOS_STATUS_E_EXISTS: STA was not yet registered
3122 VOS_STATUS_SUCCESS: Everything is good :)
3123
3124 SIDE EFFECTS
3125
3126============================================================================*/
3127VOS_STATUS
3128WLANTL_GetLinkQuality
3129(
3130 v_PVOID_t pvosGCtx,
3131 v_U8_t ucSTAId,
3132 v_U32_t* puLinkQuality
3133)
3134{
3135 WLANTL_CbType* pTLCb = NULL;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05303136 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07003137
3138 /*------------------------------------------------------------------------
3139 Sanity check
3140 ------------------------------------------------------------------------*/
3141 if ( NULL == puLinkQuality )
3142 {
3143 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3144 "Invalid parameter sent on WLANTL_GetLinkQuality"));
3145 return VOS_STATUS_E_INVAL;
3146 }
3147
3148 if ( WLANTL_STA_ID_INVALID( ucSTAId ) )
3149 {
3150 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3151 "Invalid station id requested on WLANTL_GetLinkQuality"));
3152 return VOS_STATUS_E_FAULT;
3153 }
3154
3155 /*------------------------------------------------------------------------
3156 Extract TL control block and check existance
3157 ------------------------------------------------------------------------*/
3158 pTLCb = VOS_GET_TL_CB(pvosGCtx);
3159 if ( NULL == pTLCb )
3160 {
3161 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3162 "Invalid TL pointer from pvosGCtx on WLANTL_GetLinkQuality"));
3163 return VOS_STATUS_E_FAULT;
3164 }
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05303165 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
Jeff Johnson295189b2012-06-20 16:38:30 -07003166
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05303167 if ( NULL == pClientSTA )
3168 {
3169 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3170 "WLAN TL:Client Memory was not allocated on %s", __func__));
3171 return VOS_STATUS_E_FAILURE;
3172 }
3173
3174 if ( 0 == pClientSTA->ucExists )
Jeff Johnson295189b2012-06-20 16:38:30 -07003175 {
3176 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3177 "Station was not previously registered on WLANTL_GetLinkQuality"));
3178 return VOS_STATUS_E_EXISTS;
3179 }
3180
3181 /*------------------------------------------------------------------------
3182 Copy will not be locked; please read restriction
3183 ------------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05303184 *puLinkQuality = pClientSTA->uLinkQualityAvg;
Jeff Johnson295189b2012-06-20 16:38:30 -07003185
3186 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
3187 "WLANTL_GetLinkQuality for STA: %d LinkQuality: %d", ucSTAId, *puLinkQuality));
3188
3189 return VOS_STATUS_SUCCESS;
3190}/* WLANTL_GetLinkQuality */
3191
3192/*==========================================================================
3193
3194 FUNCTION WLANTL_FlushStaTID
3195
3196 DESCRIPTION
3197 TL provides this API as an interface to SME (BAP) layer. TL inturn posts a
3198 message to HAL. This API is called by the SME inorder to perform a flush
3199 operation.
3200
3201 DEPENDENCIES
3202
3203 PARAMETERS
3204
3205 IN
3206 pvosGCtx: pointer to the global vos context; a handle to TL's
3207 or SME's control block can be extracted from its context
3208 ucSTAId: station identifier for the requested value
3209 ucTid: Tspec ID for the new BA session
3210
3211 OUT
3212 The response for this post is received in the main thread, via a response
3213 message from HAL to TL.
3214
3215 RETURN VALUE
3216 VOS_STATUS_SUCCESS: Everything is good :)
3217
3218 SIDE EFFECTS
3219============================================================================*/
3220VOS_STATUS
3221WLANTL_FlushStaTID
3222(
3223 v_PVOID_t pvosGCtx,
3224 v_U8_t ucSTAId,
3225 v_U8_t ucTid
3226)
3227{
3228 WLANTL_CbType* pTLCb = NULL;
3229 tpFlushACReq FlushACReqPtr = NULL;
3230 vos_msg_t vosMessage;
3231
3232
3233 if ( WLANTL_STA_ID_INVALID( ucSTAId ) )
3234 {
3235 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3236 "Invalid station id requested on WLANTL_FlushStaTID"));
3237 return VOS_STATUS_E_FAULT;
3238 }
3239
3240 /*------------------------------------------------------------------------
3241 Extract TL control block and check existance
3242 ------------------------------------------------------------------------*/
3243 pTLCb = VOS_GET_TL_CB(pvosGCtx);
3244 if ( NULL == pTLCb )
3245 {
3246 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3247 "Invalid TL pointer from pvosGCtx on WLANTL_FlushStaTID"));
3248 return VOS_STATUS_E_FAULT;
3249 }
3250
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05303251 if ( NULL == pTLCb->atlSTAClients[ucSTAId] )
3252 {
3253 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3254 "WLAN TL:Client Memory was not allocated on %s", __func__));
3255 return VOS_STATUS_E_FAILURE;
3256 }
3257
3258 if ( 0 == pTLCb->atlSTAClients[ucSTAId]->ucExists )
Jeff Johnson295189b2012-06-20 16:38:30 -07003259 {
3260 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3261 "Station was not previously registered on WLANTL_FlushStaTID"));
3262 return VOS_STATUS_E_EXISTS;
3263 }
3264
3265 /*------------------------------------------------------------------------
3266 We need to post a message with the STA, TID value to HAL. HAL performs the flush
3267 ------------------------------------------------------------------------*/
3268 FlushACReqPtr = vos_mem_malloc(sizeof(tFlushACReq));
3269
3270 if ( NULL == FlushACReqPtr )
3271 {
3272 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3273 "WLAN TL: fatal failure, cannot allocate Flush Req structure"));
3274 VOS_ASSERT(0);
3275 return VOS_STATUS_E_NOMEM;
3276 }
3277
3278 // Start constructing the message for HAL
3279 FlushACReqPtr->mesgType = SIR_TL_HAL_FLUSH_AC_REQ;
3280 FlushACReqPtr->mesgLen = sizeof(tFlushACReq);
3281 FlushACReqPtr->mesgLen = sizeof(tFlushACReq);
3282 FlushACReqPtr->ucSTAId = ucSTAId;
3283 FlushACReqPtr->ucTid = ucTid;
3284
3285 vosMessage.type = WDA_TL_FLUSH_AC_REQ;
3286 vosMessage.bodyptr = (void *)FlushACReqPtr;
3287
3288 vos_mq_post_message(VOS_MQ_ID_WDA, &vosMessage);
3289 return VOS_STATUS_SUCCESS;
3290}
3291
3292
3293/*----------------------------------------------------------------------------
3294 INTERACTION WITH PE
3295 ---------------------------------------------------------------------------*/
Siddharth Bhal4551b102014-10-09 21:36:36 +05303296/*==========================================================================
Jeff Johnson295189b2012-06-20 16:38:30 -07003297
Siddharth Bhal4551b102014-10-09 21:36:36 +05303298 FUNCTION WLANTL_updateSpoofMacAddr
3299
3300 DESCRIPTION
3301 Called by HDD to update macaddr
3302
3303 DEPENDENCIES
3304 TL must be initialized before this API can be called.
3305
3306 PARAMETERS
3307
3308 IN
3309 pvosGCtx: pointer to the global vos context; a handle to
3310 TL's control block can be extracted from its context
3311 spoofMacAddr: spoofed mac adderess
3312 selfMacAddr: self Mac Address
3313
3314 RETURN VALUE
3315 The result code associated with performing the operation
3316
3317 VOS_STATUS_E_INVAL: Input parameters are invalid
3318 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
3319 page fault
3320 VOS_STATUS_SUCCESS: Everything is good :)
3321
3322 SIDE EFFECTS
3323
3324============================================================================*/
3325VOS_STATUS
3326WLANTL_updateSpoofMacAddr
3327(
3328 v_PVOID_t pvosGCtx,
3329 v_MACADDR_t* spoofMacAddr,
3330 v_MACADDR_t* selfMacAddr
3331)
3332{
3333 WLANTL_CbType* pTLCb = NULL;
3334 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
3335
3336 /*------------------------------------------------------------------------
Siddharth Bhal4551b102014-10-09 21:36:36 +05303337 Extract TL control block
3338 ------------------------------------------------------------------------*/
3339 pTLCb = VOS_GET_TL_CB(pvosGCtx);
3340 if ( NULL == pTLCb )
3341 {
3342 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3343 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_ChangeSTAState");
3344 return VOS_STATUS_E_FAULT;
3345 }
3346
3347 vos_mem_copy(pTLCb->spoofMacAddr.selfMac.bytes, selfMacAddr,
3348 VOS_MAC_ADDRESS_LEN);
3349 vos_mem_copy(pTLCb->spoofMacAddr.spoofMac.bytes, spoofMacAddr,
3350 VOS_MAC_ADDRESS_LEN);
3351
3352 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_LOW,
3353 "TL: SelfSTA mac Addr for current Scan "MAC_ADDRESS_STR,
3354 MAC_ADDR_ARRAY(pTLCb->spoofMacAddr.selfMac.bytes));
3355
3356 return VOS_STATUS_SUCCESS;
3357}/* WLANTL_updateSpoofMacAddr */
Jeff Johnson295189b2012-06-20 16:38:30 -07003358/*==========================================================================
3359
3360 FUNCTION WLANTL_RegisterMgmtFrmClient
3361
3362 DESCRIPTION
3363 Called by PE to register as a client for management frames delivery.
3364
3365 DEPENDENCIES
3366 TL must be initialized before this API can be called.
3367
3368 PARAMETERS
3369
3370 IN
3371 pvosGCtx: pointer to the global vos context; a handle to
3372 TL's control block can be extracted from its context
3373 pfnTlMgmtFrmRx: pointer to the receive processing routine for
3374 management frames
3375
3376 RETURN VALUE
3377 The result code associated with performing the operation
3378
3379 VOS_STATUS_E_INVAL: Input parameters are invalid
3380 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
3381 page fault
3382 VOS_STATUS_E_EXISTS: Mgmt Frame client was already registered
3383 VOS_STATUS_SUCCESS: Everything is good :)
3384
3385 SIDE EFFECTS
3386
3387============================================================================*/
3388VOS_STATUS
3389WLANTL_RegisterMgmtFrmClient
3390(
3391 v_PVOID_t pvosGCtx,
3392 WLANTL_MgmtFrmRxCBType pfnTlMgmtFrmRx
3393)
3394{
3395 WLANTL_CbType* pTLCb = NULL;
3396 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
3397
3398 /*------------------------------------------------------------------------
3399 Sanity check
3400 ------------------------------------------------------------------------*/
3401 if ( NULL == pfnTlMgmtFrmRx )
3402 {
3403 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3404 "WLAN TL:Invalid parameter sent on WLANTL_RegisterMgmtFrmClient"));
3405 return VOS_STATUS_E_INVAL;
3406 }
3407
3408 /*------------------------------------------------------------------------
3409 Extract TL control block
3410 ------------------------------------------------------------------------*/
3411 pTLCb = VOS_GET_TL_CB(pvosGCtx);
3412 if ( NULL == pTLCb )
3413 {
3414 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3415 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_ChangeSTAState"));
3416 return VOS_STATUS_E_FAULT;
3417 }
3418
3419 /*------------------------------------------------------------------------
3420 Make sure this is the first registration attempt
3421 ------------------------------------------------------------------------*/
3422 if ( 0 != pTLCb->tlMgmtFrmClient.ucExists )
3423 {
3424 pTLCb->tlMgmtFrmClient.ucExists++;
3425 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3426 "WLAN TL:Management frame client was already registered"));
3427 return VOS_STATUS_E_EXISTS;
3428 }
3429
3430 /*------------------------------------------------------------------------
3431 Register station with TL
3432 ------------------------------------------------------------------------*/
3433 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
3434 "WLAN TL:Registering Management Frame Client" ));
3435
3436 pTLCb->tlMgmtFrmClient.ucExists++;
3437
3438 if ( NULL != pfnTlMgmtFrmRx )
3439 {
3440 pTLCb->tlMgmtFrmClient.pfnTlMgmtFrmRx = pfnTlMgmtFrmRx;
3441 }
3442
3443 pTLCb->tlMgmtFrmClient.vosPendingDataBuff = NULL;
3444
3445 return VOS_STATUS_SUCCESS;
3446}/* WLANTL_RegisterMgmtFrmClient */
3447
3448/*==========================================================================
3449
3450 FUNCTION WLANTL_DeRegisterMgmtFrmClient
3451
3452 DESCRIPTION
3453 Called by PE to deregister as a client for management frames delivery.
3454
3455 DEPENDENCIES
3456 TL must be initialized before this API can be called.
3457
3458 PARAMETERS
3459
3460 IN
3461 pvosGCtx: pointer to the global vos context; a handle to
3462 TL's control block can be extracted from its context
3463 RETURN VALUE
3464 The result code associated with performing the operation
3465
3466 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
3467 page fault
3468 VOS_STATUS_E_EXISTS: Mgmt Frame client was never registered
3469 VOS_STATUS_SUCCESS: Everything is good :)
3470
3471 SIDE EFFECTS
3472
3473============================================================================*/
3474VOS_STATUS
3475WLANTL_DeRegisterMgmtFrmClient
3476(
3477 v_PVOID_t pvosGCtx
3478)
3479{
3480 WLANTL_CbType* pTLCb = NULL;
3481 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
3482
3483 /*------------------------------------------------------------------------
3484 Extract TL control block
3485 ------------------------------------------------------------------------*/
3486 pTLCb = VOS_GET_TL_CB(pvosGCtx);
3487 if ( NULL == pTLCb )
3488 {
3489 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3490 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_ChangeSTAState"));
3491 return VOS_STATUS_E_FAULT;
3492 }
3493
3494 /*------------------------------------------------------------------------
3495 Make sure this is the first registration attempt
3496 ------------------------------------------------------------------------*/
3497 if ( 0 == pTLCb->tlMgmtFrmClient.ucExists )
3498 {
3499 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3500 "WLAN TL:Management frame client was never registered"));
3501 return VOS_STATUS_E_EXISTS;
3502 }
3503
3504 /*------------------------------------------------------------------------
3505 Clear registration with TL
3506 ------------------------------------------------------------------------*/
3507 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
3508 "WLAN TL:Deregistering Management Frame Client" ));
3509
3510 pTLCb->tlMgmtFrmClient.pfnTlMgmtFrmRx = WLANTL_MgmtFrmRxDefaultCb;
3511 if ( NULL != pTLCb->tlMgmtFrmClient.vosPendingDataBuff)
3512 {
3513 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
3514 "WLAN TL:Management cache buffer not empty on deregistering"
3515 " - dropping packet" ));
3516 vos_pkt_return_packet(pTLCb->tlMgmtFrmClient.vosPendingDataBuff);
3517
3518 pTLCb->tlMgmtFrmClient.vosPendingDataBuff = NULL;
3519 }
3520
3521 pTLCb->tlMgmtFrmClient.ucExists = 0;
3522
3523 return VOS_STATUS_SUCCESS;
3524}/* WLANTL_RegisterMgmtFrmClient */
3525
3526/*==========================================================================
3527
3528 FUNCTION WLANTL_TxMgmtFrm
3529
3530 DESCRIPTION
3531 Called by PE when it want to send out a management frame.
3532 HAL will also use this API for the few frames it sends out, they are not
3533 management frames howevere it is accepted that an exception will be
3534 allowed ONLY for the usage of HAL.
3535 Generic data frames SHOULD NOT travel through this function.
3536
3537 DEPENDENCIES
3538 TL must be initialized before this API can be called.
3539
3540 RESTRICTION: If PE sends another packet before TL manages to process the
3541 previously sent packet call will end in failure
3542
3543 Frames comming through here must be 802.11 frames, frame
3544 translation in UMA will be automatically disabled.
3545
3546 PARAMETERS
3547
3548 IN
3549 pvosGCtx: pointer to the global vos context;a handle to TL's
3550 control block can be extracted from its context
3551 vosFrmBuf: pointer to a vOSS buffer containing the management
3552 frame to be transmitted
3553 usFrmLen: the length of the frame to be transmitted; information
3554 is already included in the vOSS buffer
3555 wFrmType: the type of the frame being transmitted
3556 tid: tid used to transmit this frame
3557 pfnCompTxFunc: function pointer to the transmit complete routine
3558 pvBDHeader: pointer to the BD header, if NULL it means it was not
3559 yet constructed and it lies within TL's responsibility
3560 to do so; if not NULL it is expected that it was
3561 already packed inside the vos packet
3562 ucAckResponse: flag notifying it an interrupt is needed for the
3563 acknowledgement received when the frame is sent out
3564 the air and ; the interrupt will be processed by HAL,
3565 only one such frame can be pending in the system at
3566 one time.
3567
3568
3569 RETURN VALUE
3570 The result code associated with performing the operation
3571
3572 VOS_STATUS_E_INVAL: Input parameters are invalid
3573 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
3574 page fault
3575 VOS_STATUS_E_EXISTS: Mgmt Frame client was not yet registered
3576 VOS_STATUS_E_BUSY: The previous Mgmt packet was not yet transmitted
3577 VOS_STATUS_SUCCESS: Everything is good :)
3578
3579 Other failure messages may be returned from the BD header handling
3580 routines, please check apropriate API for more info.
3581
3582 SIDE EFFECTS
3583
3584============================================================================*/
3585VOS_STATUS
3586WLANTL_TxMgmtFrm
3587(
3588 v_PVOID_t pvosGCtx,
3589 vos_pkt_t* vosFrmBuf,
3590 v_U16_t usFrmLen,
3591 v_U8_t wFrmType,
3592 v_U8_t ucTid,
3593 WLANTL_TxCompCBType pfnCompTxFunc,
3594 v_PVOID_t pvBDHeader,
Ganesh Kondabattini10e67352015-03-16 17:41:57 +05303595 v_U32_t ucAckResponse,
3596 v_U32_t ucTxBdToken
Jeff Johnson295189b2012-06-20 16:38:30 -07003597)
3598{
3599 WLANTL_CbType* pTLCb = NULL;
3600 v_MACADDR_t vDestMacAddr;
3601 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
3602 v_U16_t usPktLen;
3603 v_U32_t usTimeStamp = 0;
3604 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
3605
3606 /*------------------------------------------------------------------------
3607 Sanity check
3608 ------------------------------------------------------------------------*/
3609 if ( NULL == vosFrmBuf )
3610 {
3611 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3612 "WLAN TL:Invalid parameter sent on WLANTL_TxMgmtFrm"));
3613 return VOS_STATUS_E_INVAL;
3614 }
3615
3616 /*------------------------------------------------------------------------
3617 Extract TL control block
3618 ------------------------------------------------------------------------*/
3619 pTLCb = VOS_GET_TL_CB(pvosGCtx);
3620 if ( NULL == pTLCb )
3621 {
3622 TLLOGP(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_FATAL,
3623 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_TxMgmtFrm"));
3624 return VOS_STATUS_E_FAULT;
3625 }
3626
3627 /*------------------------------------------------------------------------
3628 Ensure that management frame client was previously registered
3629 ------------------------------------------------------------------------*/
3630 if ( 0 == pTLCb->tlMgmtFrmClient.ucExists )
3631 {
3632 pTLCb->tlMgmtFrmClient.ucExists++;
3633 TLLOGP(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_FATAL,
3634 "WLAN TL:Management Frame client not register on WLANTL_TxMgmtFrm"));
3635 return VOS_STATUS_E_EXISTS;
3636 }
3637
3638 /*------------------------------------------------------------------------
3639 Check if any Mgmt Frm is pending
3640 ------------------------------------------------------------------------*/
3641 //vosTempBuff = pTLCb->tlMgmtFrmClient.vosPendingDataBuff;
3642 if ( NULL != pTLCb->tlMgmtFrmClient.vosPendingDataBuff )
3643 {
3644
3645 TLLOGP(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_FATAL,
3646 "WLAN TL:Management Frame already pending tx in TL: failing old one"));
3647
3648
3649 /*Failing the tx for the previous packet enqued by PE*/
Arun Kumar Khandavalli0af8d3c2014-02-07 18:05:11 +05303650 //vos_atomic_set( (uintptr_t*)&pTLCb->tlMgmtFrmClient.vosPendingDataBuff,
3651 // (uintptr_t)NULL);
Jeff Johnson295189b2012-06-20 16:38:30 -07003652
3653 //vos_pkt_get_user_data_ptr( vosTempBuff, VOS_PKT_USER_DATA_ID_TL,
3654 // (v_PVOID_t)&pfnTxComp);
3655
3656 /*it should never be NULL - default handler should be registered if none*/
3657 //if ( NULL == pfnTxComp )
3658 //{
3659 // VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3660 // "NULL pointer to Tx Complete on WLANTL_TxMgmtFrm");
3661 // VOS_ASSERT(0);
3662 // return VOS_STATUS_E_FAULT;
3663 //}
3664
3665 //pfnTxComp( pvosGCtx, vosTempBuff, VOS_STATUS_E_RESOURCES );
3666 //return VOS_STATUS_E_BUSY;
3667
3668
3669 //pfnCompTxFunc( pvosGCtx, vosFrmBuf, VOS_STATUS_E_RESOURCES);
3670 return VOS_STATUS_E_RESOURCES;
3671 }
3672
3673
3674 /*------------------------------------------------------------------------
3675 Check if BD header was build, if not construct
3676 ------------------------------------------------------------------------*/
3677 if ( NULL == pvBDHeader )
3678 {
3679 v_MACADDR_t* pvAddr2MacAddr;
3680 v_U8_t uQosHdr = VOS_FALSE;
3681
3682 /* Get address 2 of Mangement Frame to give to WLANHAL_FillTxBd */
3683 vosStatus = vos_pkt_peek_data( vosFrmBuf,
3684 WLANTL_MAC_ADDR_ALIGN(1) + VOS_MAC_ADDR_SIZE,
3685 (v_PVOID_t)&pvAddr2MacAddr, VOS_MAC_ADDR_SIZE);
3686
3687 if ( VOS_STATUS_SUCCESS != vosStatus )
3688 {
3689 TLLOGP(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_FATAL,
3690 "WLAN TL:Failed while attempting to get addr2 %d", vosStatus));
3691 return vosStatus;
3692 }
Gopichand Nakkala0f3eb5c2013-05-07 16:48:38 +05303693
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003694 /* ESE IAPP/TDLS Frame which are data frames but technically used
Jeff Johnson295189b2012-06-20 16:38:30 -07003695 * for management functionality comes through route.
3696 */
3697 if (WLANTL_IS_QOS_DATA_FRAME(wFrmType)) \
3698 {
3699 uQosHdr = VOS_TRUE;
3700 }
Siddharth Bhal4551b102014-10-09 21:36:36 +05303701
3702 if (WLANTL_IS_PROBE_REQ(wFrmType))
3703 {
3704 if (VOS_TRUE == vos_mem_compare((v_VOID_t*) pvAddr2MacAddr,
3705 (v_VOID_t*) &pTLCb->spoofMacAddr.spoofMac, VOS_MAC_ADDRESS_LEN))
3706 {
3707 pvAddr2MacAddr = (v_PVOID_t)pTLCb->spoofMacAddr.selfMac.bytes;
3708 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
3709 "TL: using self sta addr to get staidx for spoofed probe req "
3710 MAC_ADDRESS_STR, MAC_ADDR_ARRAY(pvAddr2MacAddr->bytes));
3711 }
3712 }
3713
Jeff Johnson295189b2012-06-20 16:38:30 -07003714 /*----------------------------------------------------------------------
3715 Call WDA to build TX header
3716 ----------------------------------------------------------------------*/
3717 vosStatus = WDA_DS_BuildTxPacketInfo( pvosGCtx, vosFrmBuf , &vDestMacAddr,
3718 1 /* always 802.11 frames*/, &usPktLen, uQosHdr /*qos not enabled !!!*/,
Siddharth Bhal4551b102014-10-09 21:36:36 +05303719 0 /* WDS off */, 0, wFrmType, pvAddr2MacAddr, ucTid,
Ganesh Kondabattini10e67352015-03-16 17:41:57 +05303720 ucAckResponse, usTimeStamp, 0, 0, ucTxBdToken);
Jeff Johnson295189b2012-06-20 16:38:30 -07003721
3722
3723 if ( !VOS_IS_STATUS_SUCCESS(vosStatus) )
3724 {
3725 TLLOGP(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_FATAL,
3726 "WLAN TL:Failed while attempting to build TX header %d", vosStatus));
3727 return vosStatus;
3728 }
3729 }/* if BD header not present */
3730
3731 /*------------------------------------------------------------------------
3732 Save buffer and notify BAL; no lock is needed if the above restriction
3733 is met
3734 Save the tx complete fnct pointer as tl specific data in the vos buffer
3735 ------------------------------------------------------------------------*/
3736 if ( NULL != pfnCompTxFunc )
3737 {
3738 vos_pkt_set_user_data_ptr( vosFrmBuf, VOS_PKT_USER_DATA_ID_TL,
3739 (v_PVOID_t)pfnCompTxFunc);
3740 }
3741 else
3742 {
3743 vos_pkt_set_user_data_ptr( vosFrmBuf, VOS_PKT_USER_DATA_ID_TL,
3744 (v_PVOID_t)WLANTL_TxCompDefaultCb);
3745
3746 }
Arun Kumar Khandavalli0af8d3c2014-02-07 18:05:11 +05303747 vos_atomic_set( (uintptr_t*)&pTLCb->tlMgmtFrmClient.vosPendingDataBuff,
3748 (uintptr_t)vosFrmBuf);
Jeff Johnson295189b2012-06-20 16:38:30 -07003749
3750 /*------------------------------------------------------------------------
3751 Check if thre are enough resources for transmission and tx is not
3752 suspended.
3753 ------------------------------------------------------------------------*/
3754 if ( pTLCb->uResCount >= WDA_TLI_MIN_RES_MF )
3755 {
3756 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
3757 "WLAN TL:Issuing Xmit start request to BAL for MGMT"));
3758 vosStatus = WDA_DS_StartXmit(pvosGCtx);
3759 if(VOS_STATUS_SUCCESS != vosStatus)
3760 {
3761 TLLOGP(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_FATAL,
3762 "WLAN TL:WDA_DS_StartXmit fails. vosStatus %d", vosStatus));
Arun Kumar Khandavalli0af8d3c2014-02-07 18:05:11 +05303763 vos_atomic_set( (uintptr_t*)&pTLCb->tlMgmtFrmClient.vosPendingDataBuff,0);
Jeff Johnson295189b2012-06-20 16:38:30 -07003764 }
3765 return vosStatus;
3766
3767 }
3768 else
3769 {
3770 /*---------------------------------------------------------------------
3771 No error code is sent because TL will resume tx autonomously if
3772 resources become available or tx gets resumed
3773 ---------------------------------------------------------------------*/
3774 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
3775 "WLAN TL:Request to send for Mgmt Frm but condition not met. Res: %d",
3776 pTLCb->uResCount));
3777 }
3778
3779 return VOS_STATUS_SUCCESS;
3780}/* WLANTL_TxMgmtFrm */
3781
3782/*----------------------------------------------------------------------------
3783 INTERACTION WITH HAL
3784 ---------------------------------------------------------------------------*/
3785
3786/*==========================================================================
3787
3788 FUNCTION WLANTL_ResetNotification
3789
3790 DESCRIPTION
3791 HAL notifies TL when the module is being reset.
3792 Currently not used.
3793
3794 DEPENDENCIES
3795
3796 PARAMETERS
3797
3798 IN
3799 pvosGCtx: pointer to the global vos context; a handle to TL's
3800 control block can be extracted from its context
3801
3802
3803 RETURN VALUE
3804 The result code associated with performing the operation
3805
3806 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
3807 page fault
3808 VOS_STATUS_SUCCESS: Everything is good :)
3809
3810 SIDE EFFECTS
3811
3812============================================================================*/
3813VOS_STATUS
3814WLANTL_ResetNotification
3815(
3816 v_PVOID_t pvosGCtx
3817)
3818{
3819 WLANTL_CbType* pTLCb = NULL;
3820 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
3821
3822 /*------------------------------------------------------------------------
3823 Sanity check
3824 Extract TL control block
3825 ------------------------------------------------------------------------*/
3826 pTLCb = VOS_GET_TL_CB(pvosGCtx);
3827 if ( NULL == pTLCb )
3828 {
3829 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3830 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_ResetNotification"));
3831 return VOS_STATUS_E_FAULT;
3832 }
3833
3834 WLANTL_CleanCB(pTLCb, 1 /*empty all queues and pending packets*/);
3835 return VOS_STATUS_SUCCESS;
3836}/* WLANTL_ResetNotification */
3837
3838/*==========================================================================
3839
3840 FUNCTION WLANTL_SuspendDataTx
3841
3842 DESCRIPTION
3843 HAL calls this API when it wishes to suspend transmission for a
3844 particular STA.
3845
3846 DEPENDENCIES
3847 The STA for which the request is made must be first registered with
3848 TL by HDD.
3849
3850 RESTRICTION: In case of a suspend, the flag write and read will not be
3851 locked: worst case scenario one more packet can get
3852 through before the flag gets updated (we can make this
3853 write atomic as well to guarantee consistency)
3854
3855 PARAMETERS
3856
3857 IN
3858 pvosGCtx: pointer to the global vos context; a handle to TL's
3859 control block can be extracted from its context
3860 pucSTAId: identifier of the station for which the request is made;
3861 a value of NULL assumes suspend on all active station
3862 pfnSuspendTxCB: pointer to the suspend result notification in case the
3863 call is asynchronous
3864
3865
3866 RETURN VALUE
3867 The result code associated with performing the operation
3868
3869 VOS_STATUS_E_FAULT: Station ID is outside array boundaries or pointer
3870 to TL cb is NULL ; access would cause a page fault
3871 VOS_STATUS_E_EXISTS: Station was not registered
3872 VOS_STATUS_SUCCESS: Everything is good :)
3873
3874 SIDE EFFECTS
3875
3876============================================================================*/
3877
3878VOS_STATUS
3879WLANTL_SuspendDataTx
3880(
3881 v_PVOID_t pvosGCtx,
3882 v_U8_t* pucSTAId,
3883 WLANTL_SuspendCBType pfnSuspendTx
3884)
3885{
3886 WLANTL_CbType* pTLCb = NULL;
3887 vos_msg_t vosMsg;
Jeff Johnson295189b2012-06-20 16:38:30 -07003888
3889 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
3890
3891 /*------------------------------------------------------------------------
3892 Sanity check
3893 Extract TL control block
3894 ------------------------------------------------------------------------*/
3895 pTLCb = VOS_GET_TL_CB(pvosGCtx);
Hoonki Lee14621352013-04-16 17:51:19 -07003896 if ( NULL == pTLCb )
Jeff Johnson295189b2012-06-20 16:38:30 -07003897 {
3898 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3899 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_SuspendDataTx"));
3900 return VOS_STATUS_E_FAULT;
3901 }
3902
3903 /*------------------------------------------------------------------------
3904 Check the type of request: generic suspend, or per station suspend
3905 ------------------------------------------------------------------------*/
Hoonki Lee14621352013-04-16 17:51:19 -07003906 if (NULL == pucSTAId)
Jeff Johnson295189b2012-06-20 16:38:30 -07003907 {
3908 /* General Suspend Request received */
3909 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
3910 "WLAN TL:General suspend requested"));
Hoonki Lee14621352013-04-16 17:51:19 -07003911 vos_atomic_set_U8( &pTLCb->ucTxSuspended, 1);
Jeff Johnson295189b2012-06-20 16:38:30 -07003912 vosMsg.reserved = WLAN_MAX_STA_COUNT;
3913 }
3914 else
3915 {
Hoonki Lee14621352013-04-16 17:51:19 -07003916 if ( WLANTL_STA_ID_INVALID( *pucSTAId ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07003917 {
Hoonki Lee14621352013-04-16 17:51:19 -07003918 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3919 "WLAN TL:Invalid station id %d requested on WLANTL_SuspendDataTx", *pucSTAId));
3920 return VOS_STATUS_E_FAULT;
3921 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003922
Gopichand Nakkalae5fef6c2013-06-19 18:04:23 +05303923 if ( NULL == pTLCb->atlSTAClients[*pucSTAId] )
3924 {
3925 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3926 "WLAN TL:Invalid pTLCb->atlSTAClients pointer for STA Id :%d on "
3927 "WLANTL_SuspendDataTx", *pucSTAId));
3928 return VOS_STATUS_E_FAULT;
3929 }
3930
3931 if ( 0 == pTLCb->atlSTAClients[*pucSTAId]->ucExists )
Hoonki Lee14621352013-04-16 17:51:19 -07003932 {
3933 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3934 "WLAN TL:Station %d was not previously registered on WLANTL_SuspendDataTx", *pucSTAId));
3935 return VOS_STATUS_E_EXISTS;
3936 }
3937
3938 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
3939 "WLAN TL:Suspend request for station: %d", *pucSTAId));
3940 vos_atomic_set_U8( &pTLCb->atlSTAClients[*pucSTAId]->ucTxSuspended, 1);
Jeff Johnson295189b2012-06-20 16:38:30 -07003941 vosMsg.reserved = *pucSTAId;
3942 }
3943
3944 /*------------------------------------------------------------------------
3945 Serialize request through TX thread
3946 ------------------------------------------------------------------------*/
3947 vosMsg.type = WLANTL_TX_SIG_SUSPEND;
3948 vosMsg.bodyptr = (v_PVOID_t)pfnSuspendTx;
3949
Katya Nigam42e16e82014-02-04 16:28:55 +05303950 MTRACE(vos_trace(VOS_MODULE_ID_TL, TRACE_CODE_TL_SUSPEND_DATA_TX,
3951 vosMsg.reserved , 0 ));
3952
Jeff Johnson295189b2012-06-20 16:38:30 -07003953 if(!VOS_IS_STATUS_SUCCESS(vos_tx_mq_serialize( VOS_MQ_ID_TL, &vosMsg)))
3954 {
3955 VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003956 " %s fails to post message", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003957 }
3958
3959 return VOS_STATUS_SUCCESS;
3960}/* WLANTL_SuspendDataTx */
3961
3962/*==========================================================================
3963
3964 FUNCTION WLANTL_ResumeDataTx
3965
3966 DESCRIPTION
3967 Called by HAL to resume data transmission for a given STA.
3968
3969 WARNING: If a station was individually suspended a global resume will
3970 not resume that station
3971
3972 DEPENDENCIES
3973
3974 PARAMETERS
3975
3976 IN
3977 pvosGCtx: pointer to the global vos context; a handle to TL's
3978 control block can be extracted from its context
3979 pucSTAId: identifier of the station which is being resumed; NULL
3980 translates into global resume
3981
3982 RETURN VALUE
3983 The result code associated with performing the operation
3984
3985 VOS_STATUS_E_FAULT: Station ID is outside array boundaries or pointer
3986 to TL cb is NULL ; access would cause a page fault
3987 VOS_STATUS_E_EXISTS: Station was not registered
3988 VOS_STATUS_SUCCESS: Everything is good :)
3989
3990 SIDE EFFECTS
3991
3992============================================================================*/
3993
3994VOS_STATUS
3995WLANTL_ResumeDataTx
3996(
3997 v_PVOID_t pvosGCtx,
3998 v_U8_t* pucSTAId
3999)
4000{
4001 WLANTL_CbType* pTLCb = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004002 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
4003
4004 /*------------------------------------------------------------------------
4005 Sanity check
4006 Extract TL control block
4007 ------------------------------------------------------------------------*/
4008 pTLCb = VOS_GET_TL_CB(pvosGCtx);
Hoonki Lee14621352013-04-16 17:51:19 -07004009 if ( NULL == pTLCb )
Jeff Johnson295189b2012-06-20 16:38:30 -07004010 {
4011 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
4012 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_ResumeDataTx"));
4013 return VOS_STATUS_E_FAULT;
4014 }
4015
Jeff Johnson295189b2012-06-20 16:38:30 -07004016 /*------------------------------------------------------------------------
4017 Check to see the type of resume
4018 ------------------------------------------------------------------------*/
Hoonki Lee14621352013-04-16 17:51:19 -07004019 if ( NULL == pucSTAId )
Jeff Johnson295189b2012-06-20 16:38:30 -07004020 {
Katya Nigam42e16e82014-02-04 16:28:55 +05304021 MTRACE(vos_trace(VOS_MODULE_ID_TL, TRACE_CODE_TL_RESUME_DATA_TX,
4022 41 , 0 ));
4023
Jeff Johnson295189b2012-06-20 16:38:30 -07004024 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
4025 "WLAN TL:General resume requested"));
4026 vos_atomic_set_U8( &pTLCb->ucTxSuspended, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004027 }
4028 else
4029 {
Katya Nigam42e16e82014-02-04 16:28:55 +05304030 MTRACE(vos_trace(VOS_MODULE_ID_TL, TRACE_CODE_TL_RESUME_DATA_TX,
4031 *pucSTAId , 0 ));
4032
Hoonki Lee14621352013-04-16 17:51:19 -07004033 if ( WLANTL_STA_ID_INVALID( *pucSTAId ))
Jeff Johnson295189b2012-06-20 16:38:30 -07004034 {
Hoonki Lee14621352013-04-16 17:51:19 -07004035 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
4036 "WLAN TL:Invalid station id %d requested on WLANTL_ResumeDataTx", *pucSTAId));
4037 return VOS_STATUS_E_FAULT;
4038 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004039
Gopichand Nakkalae5fef6c2013-06-19 18:04:23 +05304040 if ( NULL == pTLCb->atlSTAClients[*pucSTAId] )
4041 {
4042 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
4043 "WLAN TL:Invalid pTLCb->atlSTAClients pointer for STA Id :%d on "
4044 "WLANTL_ResumeDataTx", *pucSTAId));
4045 return VOS_STATUS_E_FAULT;
4046 }
4047
4048 if ( 0 == pTLCb->atlSTAClients[*pucSTAId]->ucExists )
Hoonki Lee14621352013-04-16 17:51:19 -07004049 {
4050 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
4051 "WLAN TL:Station %d was not previously registered on WLANTL_ResumeDataTx", *pucSTAId));
4052 return VOS_STATUS_E_EXISTS;
4053 }
4054
4055 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
4056 "WLAN TL:Resume request for station: %d", *pucSTAId));
4057 vos_atomic_set_U8( &pTLCb->atlSTAClients[*pucSTAId]->ucTxSuspended, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004058 }
4059
4060 /*------------------------------------------------------------------------
4061 Resuming transmission
4062 ------------------------------------------------------------------------*/
Hoonki Lee14621352013-04-16 17:51:19 -07004063 if (( pTLCb->uResCount >= WDA_TLI_MIN_RES_MF ) &&
4064 ( 0 == pTLCb->ucTxSuspended ))
Jeff Johnson295189b2012-06-20 16:38:30 -07004065 {
4066 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
4067 "WLAN TL:Resuming transmission"));
4068 return WDA_DS_StartXmit(pvosGCtx);
4069 }
4070
4071 return VOS_STATUS_SUCCESS;
4072}/* WLANTL_ResumeDataTx */
4073
4074/*==========================================================================
4075 FUNCTION WLANTL_SuspendCB
4076
4077 DESCRIPTION
4078 Callback function for serializing Suspend signal through Tx thread
4079
4080 DEPENDENCIES
4081 Just notify HAL that suspend in TL is complete.
4082
4083 PARAMETERS
4084
4085 IN
4086 pvosGCtx: pointer to the global vos context; a handle to TL's
4087 control block can be extracted from its context
4088 pUserData: user data sent with the callback
4089
4090 RETURN VALUE
4091 The result code associated with performing the operation
4092
4093 VOS_STATUS_E_INVAL: invalid input parameters
4094 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
4095 page fault
4096 VOS_STATUS_SUCCESS: Everything is good :)
4097
4098
4099 SIDE EFFECTS
4100
4101============================================================================*/
4102VOS_STATUS
4103WLANTL_SuspendCB
4104(
4105 v_PVOID_t pvosGCtx,
4106 WLANTL_SuspendCBType pfnSuspendCB,
4107 v_U16_t usReserved
4108)
4109{
4110 WLANTL_CbType* pTLCb = NULL;
4111 v_U8_t ucSTAId = (v_U8_t)usReserved;
4112 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
4113
4114 /*------------------------------------------------------------------------
4115 Sanity check
4116 ------------------------------------------------------------------------*/
4117 if ( NULL == pfnSuspendCB )
4118 {
4119 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
4120 "WLAN TL: No Call back processing requested WLANTL_SuspendCB"));
4121 return VOS_STATUS_SUCCESS;
4122 }
4123
4124 /*------------------------------------------------------------------------
4125 Extract TL control block
4126 ------------------------------------------------------------------------*/
4127 pTLCb = VOS_GET_TL_CB(pvosGCtx);
4128 if ( NULL == pTLCb )
4129 {
4130 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
4131 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_SuspendCB"));
4132 return VOS_STATUS_E_FAULT;
4133 }
4134
4135 if ( WLANTL_STA_ID_INVALID( ucSTAId ) )
4136 {
4137 pfnSuspendCB(pvosGCtx, NULL, VOS_STATUS_SUCCESS);
4138 }
4139 else
4140 {
4141 pfnSuspendCB(pvosGCtx, &ucSTAId, VOS_STATUS_SUCCESS);
4142 }
4143
4144 return VOS_STATUS_SUCCESS;
4145}/*WLANTL_SuspendCB*/
4146
4147
4148/*----------------------------------------------------------------------------
4149 CLIENT INDEPENDENT INTERFACE
4150 ---------------------------------------------------------------------------*/
4151
4152/*==========================================================================
4153
4154 FUNCTION WLANTL_GetTxPktCount
4155
4156 DESCRIPTION
4157 TL will provide the number of transmitted packets counted per
4158 STA per TID.
4159
4160 DEPENDENCIES
4161
4162 PARAMETERS
4163
4164 IN
4165 pvosGCtx: pointer to the global vos context; a handle to TL's
4166 control block can be extracted from its context
4167 ucSTAId: identifier of the station
4168 ucTid: identifier of the tspec
4169
4170 OUT
4171 puTxPktCount: the number of packets tx packet for this STA and TID
4172
4173 RETURN VALUE
4174 The result code associated with performing the operation
4175
4176 VOS_STATUS_E_INVAL: Input parameters are invalid
4177 VOS_STATUS_E_FAULT: Station ID is outside array boundaries or pointer
4178 to TL cb is NULL ; access would cause a page fault
4179 VOS_STATUS_E_EXISTS: Station was not registered
4180 VOS_STATUS_SUCCESS: Everything is good :)
4181
4182 SIDE EFFECTS
4183
4184============================================================================*/
4185VOS_STATUS
4186WLANTL_GetTxPktCount
4187(
4188 v_PVOID_t pvosGCtx,
4189 v_U8_t ucSTAId,
4190 v_U8_t ucTid,
4191 v_U32_t* puTxPktCount
4192)
4193{
4194 WLANTL_CbType* pTLCb = NULL;
4195 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
4196
4197 /*------------------------------------------------------------------------
4198 Sanity check
4199 ------------------------------------------------------------------------*/
4200 if ( NULL == puTxPktCount )
4201 {
4202 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
4203 "WLAN TL:Invalid parameter sent on WLANTL_GetTxPktCount"));
4204 return VOS_STATUS_E_INVAL;
4205 }
4206
4207 if ( WLANTL_STA_ID_INVALID( ucSTAId ) || WLANTL_TID_INVALID( ucTid) )
4208 {
4209 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
4210 "WLAN TL:Invalid station id %d/tid %d requested on WLANTL_GetTxPktCount",
4211 ucSTAId, ucTid));
4212 return VOS_STATUS_E_FAULT;
4213 }
4214
4215 /*------------------------------------------------------------------------
4216 Extract TL control block and check if station exists
4217 ------------------------------------------------------------------------*/
4218 pTLCb = VOS_GET_TL_CB(pvosGCtx);
4219 if ( NULL == pTLCb )
4220 {
4221 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
4222 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_GetTxPktCount"));
4223 return VOS_STATUS_E_FAULT;
4224 }
4225
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304226 if ( NULL == pTLCb->atlSTAClients[ucSTAId] )
4227 {
4228 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
4229 "WLAN TL:Client Memory was not allocated on %s", __func__));
4230 return VOS_STATUS_E_FAILURE;
4231 }
4232
4233 if ( 0 == pTLCb->atlSTAClients[ucSTAId]->ucExists )
Jeff Johnson295189b2012-06-20 16:38:30 -07004234 {
4235 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
4236 "WLAN TL:Station was not previously registered on WLANTL_GetTxPktCount %d",
4237 ucSTAId));
4238 return VOS_STATUS_E_EXISTS;
4239 }
4240
4241 /*------------------------------------------------------------------------
4242 Return data
4243 ------------------------------------------------------------------------*/
4244 //VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_MED,
4245 // "WLAN TL:Requested tx packet count for STA: %d, TID: %d",
4246 // ucSTAId, ucTid);
4247
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304248 *puTxPktCount = pTLCb->atlSTAClients[ucSTAId]->auTxCount[ucTid];
Jeff Johnson295189b2012-06-20 16:38:30 -07004249
4250 return VOS_STATUS_SUCCESS;
4251}/* WLANTL_GetTxPktCount */
4252
4253/*==========================================================================
4254
4255 FUNCTION WLANTL_GetRxPktCount
4256
4257 DESCRIPTION
4258 TL will provide the number of received packets counted per
4259 STA per TID.
4260
4261 DEPENDENCIES
4262
4263 PARAMETERS
4264
4265 IN
4266 pvosGCtx: pointer to the global vos context; a handle to TL's
4267 control block can be extracted from its context
4268 ucSTAId: identifier of the station
4269 ucTid: identifier of the tspec
4270
4271 OUT
4272 puTxPktCount: the number of packets rx packet for this STA and TID
4273
4274 RETURN VALUE
4275 The result code associated with performing the operation
4276
4277 VOS_STATUS_E_INVAL: Input parameters are invalid
4278 VOS_STATUS_E_FAULT: Station ID is outside array boundaries or pointer
4279 to TL cb is NULL ; access would cause a page fault
4280 VOS_STATUS_E_EXISTS: Station was not registered
4281 VOS_STATUS_SUCCESS: Everything is good :)
4282
4283 SIDE EFFECTS
4284
4285============================================================================*/
4286VOS_STATUS
4287WLANTL_GetRxPktCount
4288(
4289 v_PVOID_t pvosGCtx,
4290 v_U8_t ucSTAId,
4291 v_U8_t ucTid,
4292 v_U32_t* puRxPktCount
4293)
4294{
4295 WLANTL_CbType* pTLCb = NULL;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304296 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004297 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
4298
4299 /*------------------------------------------------------------------------
4300 Sanity check
4301 ------------------------------------------------------------------------*/
4302 if ( NULL == puRxPktCount )
4303 {
4304 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
4305 "WLAN TL:Invalid parameter sent on WLANTL_GetRxPktCount"));
4306 return VOS_STATUS_E_INVAL;
4307 }
4308
4309 if ( WLANTL_STA_ID_INVALID( ucSTAId ) || WLANTL_TID_INVALID( ucTid) )
4310 {
4311 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
4312 "WLAN TL:Invalid station id %d/tid %d requested on WLANTL_GetRxPktCount",
4313 ucSTAId, ucTid));
4314 return VOS_STATUS_E_FAULT;
4315 }
4316
4317 /*------------------------------------------------------------------------
4318 Extract TL control block and existance
4319 ------------------------------------------------------------------------*/
4320 pTLCb = VOS_GET_TL_CB(pvosGCtx);
4321 if ( NULL == pTLCb )
4322 {
4323 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
4324 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_GetRxPktCount"));
4325 return VOS_STATUS_E_FAULT;
4326 }
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304327 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
Jeff Johnson295189b2012-06-20 16:38:30 -07004328
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304329 if ( NULL == pClientSTA )
4330 {
4331 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
4332 "WLAN TL:Client Memory was not allocated on %s", __func__));
4333 return VOS_STATUS_E_FAILURE;
4334 }
4335
4336 if ( 0 == pClientSTA->ucExists )
Jeff Johnson295189b2012-06-20 16:38:30 -07004337 {
4338 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
4339 "WLAN TL:Station was not previously registered on WLANTL_GetRxPktCount"));
4340 return VOS_STATUS_E_EXISTS;
4341 }
4342
4343 /*------------------------------------------------------------------------
4344 Return data
4345 ------------------------------------------------------------------------*/
4346 TLLOG3(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_MED,
4347 "WLAN TL:Requested rx packet count for STA: %d, TID: %d",
4348 ucSTAId, ucTid));
4349
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304350 *puRxPktCount = pClientSTA->auRxCount[ucTid];
Jeff Johnson295189b2012-06-20 16:38:30 -07004351
4352 return VOS_STATUS_SUCCESS;
4353}/* WLANTL_GetRxPktCount */
4354
Jeff Johnson295189b2012-06-20 16:38:30 -07004355VOS_STATUS
4356WLANTL_TxFCFrame
4357(
4358 v_PVOID_t pvosGCtx
4359);
Karthick S79bbe822015-07-14 15:28:08 +05304360
4361/*==========================================================================
4362
4363 FUNCTION WLANTL_IsEAPOLPending
4364
4365 DESCRIPTION
4366
4367 HDD calls this function when hdd_tx_timeout occurs. This checks whether
4368 EAPOL is pending.
4369
4370 DEPENDENCIES
4371
4372 HDD must have registered with TL at least one STA before this function
4373 can be called.
4374
4375 PARAMETERS
4376
4377 IN
4378 pvosGCtx: pointer to the global vos context
4379
4380 RETURN VALUE
4381
4382 The result code associated with performing the operation
4383
4384 Success : Indicates EAPOL frame is pending and sta is in connected state
4385
4386 Failure : EAPOL frame is not pending
4387
4388 SIDE EFFECTS
4389============================================================================*/
4390VOS_STATUS
4391WLANTL_IsEAPOLPending
4392(
4393 v_PVOID_t pvosGCtx
4394)
4395{
4396 WLANTL_CbType* pTLCb = NULL;
4397 v_U32_t i = 0;
4398 /*------------------------------------------------------------------------
4399 Sanity check
4400 Extract TL control block
4401 ------------------------------------------------------------------------*/
4402 pTLCb = VOS_GET_TL_CB(pvosGCtx);
4403 if (NULL == pTLCb)
4404 {
4405 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
4406 "WLAN TL:Invalid TL pointer for pvosGCtx"));
4407 return VOS_STATUS_E_FAILURE;
4408 }
4409 /*---------------------------------------------------------------------
4410 Check to see if there was any EAPOL packet is pending
4411 *--------------------------------------------------------------------*/
4412 for ( i = 0; i < WLAN_MAX_STA_COUNT; i++)
4413 {
4414 if ((NULL != pTLCb->atlSTAClients[i]) &&
4415 (pTLCb->atlSTAClients[i]->ucExists) &&
4416 (0 == pTLCb->atlSTAClients[i]->ucTxSuspended) &&
4417 (WLANTL_STA_CONNECTED == pTLCb->atlSTAClients[i]->tlState) &&
4418 (pTLCb->atlSTAClients[i]->ucPktPending)
4419 )
4420 return VOS_STATUS_SUCCESS;
4421 }
4422 return VOS_STATUS_E_FAILURE;
4423}
4424
Jeff Johnson295189b2012-06-20 16:38:30 -07004425/*============================================================================
4426 TL INTERNAL API DEFINITION
4427============================================================================*/
4428
4429/*==========================================================================
4430
4431 FUNCTION WLANTL_GetFrames
4432
4433 DESCRIPTION
4434
4435 BAL calls this function at the request of the lower bus interface.
4436 When this request is being received TL will retrieve packets from HDD
4437 in accordance with the priority rules and the count supplied by BAL.
4438
4439 DEPENDENCIES
4440
4441 HDD must have registered with TL at least one STA before this function
4442 can be called.
4443
4444 PARAMETERS
4445
4446 IN
4447 pvosGCtx: pointer to the global vos context; a handle to TL's
4448 or BAL's control block can be extracted from its context
4449 uSize: maximum size accepted by the lower layer
4450 uFlowMask TX flow control mask for Prima. Each bit is defined as
4451 WDA_TXFlowEnumType
4452
4453 OUT
4454 vosDataBuff: it will contain a pointer to the first buffer supplied
4455 by TL, if there is more than one packet supplied, TL
4456 will chain them through vOSS buffers
4457
4458 RETURN VALUE
4459
4460 The result code associated with performing the operation
4461
4462 1 or more: number of required resources if there are still frames to fetch
4463 0 : error or HDD queues are drained
4464
4465 SIDE EFFECTS
4466
4467 NOTE
4468
4469 Featurized uFlowMask. If we want to remove featurization, we need to change
4470 BAL on Volans.
4471
4472============================================================================*/
4473v_U32_t
4474WLANTL_GetFrames
4475(
4476 v_PVOID_t pvosGCtx,
4477 vos_pkt_t **ppFrameDataBuff,
4478 v_U32_t uSize,
Jeff Johnson295189b2012-06-20 16:38:30 -07004479 v_U8_t uFlowMask,
Jeff Johnson295189b2012-06-20 16:38:30 -07004480 v_BOOL_t* pbUrgent
4481)
4482{
4483 vos_pkt_t** pvosDataBuff = (vos_pkt_t**)ppFrameDataBuff;
4484 WLANTL_CbType* pTLCb = NULL;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304485 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004486 v_U32_t uRemaining = uSize;
4487 vos_pkt_t* vosRoot;
4488 vos_pkt_t* vosTempBuf;
4489 WLANTL_STAFuncType pfnSTAFsm;
4490 v_U16_t usPktLen;
4491 v_U32_t uResLen;
4492 v_U8_t ucSTAId;
4493 v_U8_t ucAC;
4494 vos_pkt_t* vosDataBuff;
4495 v_U32_t uTotalPktLen;
4496 v_U32_t i=0;
Tushnim Bhattacharyya39a8f182013-02-20 18:10:30 -08004497 v_U32_t j=0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004498 v_U32_t ucResult = 0;
4499 VOS_STATUS vosStatus;
4500 WLANTL_STAEventType wSTAEvent;
4501 tBssSystemRole systemRole;
4502 tpAniSirGlobal pMac;
4503 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
4504
4505 /*------------------------------------------------------------------------
4506 Sanity check
4507 Extract TL control block
4508 ------------------------------------------------------------------------*/
4509 pTLCb = VOS_GET_TL_CB(pvosGCtx);
4510 if (( NULL == pTLCb ) || ( NULL == pvosDataBuff ))
4511 {
4512 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
4513 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_ChangeSTAState"));
4514 return ucResult;
4515 }
4516
4517 pMac = vos_get_context(VOS_MODULE_ID_PE, pvosGCtx);
4518 if ( NULL == pMac )
4519 {
4520 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004521 "%s: Invalid pMac", __func__));
Jeff Johnson295189b2012-06-20 16:38:30 -07004522 return ucResult;
4523 }
4524
4525 vosDataBuff = pTLCb->vosDummyBuf; /* Just to avoid checking for NULL at
4526 each iteration */
4527
Jeff Johnson295189b2012-06-20 16:38:30 -07004528 pTLCb->uResCount = uSize;
Jeff Johnson295189b2012-06-20 16:38:30 -07004529
4530 /*-----------------------------------------------------------------------
4531 Save the root as we will walk this chain as we fill it
4532 -----------------------------------------------------------------------*/
4533 vosRoot = vosDataBuff;
4534
4535 /*-----------------------------------------------------------------------
4536 There is still data - until FSM function says otherwise
4537 -----------------------------------------------------------------------*/
4538 pTLCb->bUrgent = FALSE;
4539
Jeff Johnson295189b2012-06-20 16:38:30 -07004540 while (( pTLCb->tlConfigInfo.uMinFramesProcThres < pTLCb->uResCount ) &&
4541 ( 0 < uRemaining ))
Jeff Johnson295189b2012-06-20 16:38:30 -07004542 {
4543 systemRole = wdaGetGlobalSystemRole(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -07004544#ifdef WLAN_SOFTAP_FLOWCTRL_EN
4545/* FIXME: The code has been disabled since it is creating issues in power save */
4546 if (eSYSTEM_AP_ROLE == systemRole)
4547 {
4548 if (pTLCb->done_once == 0 && NULL == pTLCb->vosTxFCBuf)
4549 {
4550 WLANTL_TxFCFrame (pvosGCtx);
4551 pTLCb->done_once ++;
4552 }
4553 }
4554 if ( NULL != pTLCb->vosTxFCBuf )
4555 {
4556 //there is flow control packet waiting to be sent
4557 WDA_TLI_PROCESS_FRAME_LEN( pTLCb->vosTxFCBuf, usPktLen, uResLen, uTotalPktLen);
4558
4559 if ( ( pTLCb->uResCount > uResLen ) &&
Jeff Johnson9b5dc4d2013-02-22 21:28:47 -08004560 ( uRemaining > uTotalPktLen ) &&
4561 ( uFlowMask & ( 1 << WDA_TXFLOW_FC ) ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07004562 {
4563 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
4564 "WLAN TL:Chaining FC frame first on GetFrame"));
4565
4566 vos_pkt_chain_packet( vosDataBuff, pTLCb->vosTxFCBuf, 1 /*true*/ );
4567
Arun Kumar Khandavalli0af8d3c2014-02-07 18:05:11 +05304568 vos_atomic_set( (uintptr_t*)&pTLCb->vosTxFCBuf, (uintptr_t) NULL);
Jeff Johnson295189b2012-06-20 16:38:30 -07004569
4570 /*FC frames cannot be delayed*/
4571 pTLCb->bUrgent = TRUE;
4572
4573 /*Update remaining len from SSC */
4574 uRemaining -= (usPktLen + WDA_DXE_HEADER_SIZE);
4575
4576 /*Update resource count */
4577 pTLCb->uResCount -= uResLen;
4578 }
4579 else
4580 {
4581 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004582 "WLAN TL:send fc out of source %s", __func__));
Jeff Johnson295189b2012-06-20 16:38:30 -07004583 ucResult = ( pTLCb->uResCount > uResLen )?VOS_TRUE:VOS_FALSE;
4584 break; /* Out of resources or reached max len */
4585 }
4586 }
4587 else
4588#endif //WLAN_SOFTAP_FLOWCTRL_EN
Jeff Johnson295189b2012-06-20 16:38:30 -07004589
Jeff Johnson9b5dc4d2013-02-22 21:28:47 -08004590 if (( NULL != pTLCb->tlMgmtFrmClient.vosPendingDataBuff ) &&
4591 ( uFlowMask & ( 1 << WDA_TXFLOW_MGMT ) ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07004592 {
4593 WDA_TLI_PROCESS_FRAME_LEN( pTLCb->tlMgmtFrmClient.vosPendingDataBuff,
4594 usPktLen, uResLen, uTotalPktLen);
4595
Manjunathappa Prakashfb585462013-12-23 19:07:07 -08004596 if (usPktLen > WLANTL_MAX_ALLOWED_LEN)
4597 {
4598 usPktLen = WLANTL_MAX_ALLOWED_LEN;
4599 VOS_ASSERT(0);
4600 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004601
4602 if ( ( pTLCb->uResCount > uResLen ) &&
Jeff Johnson9b5dc4d2013-02-22 21:28:47 -08004603 ( uRemaining > uTotalPktLen ) &&
4604 ( uFlowMask & ( 1 << WDA_TXFLOW_MGMT ) ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07004605 {
4606 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
4607 "WLAN TL:Chaining management frame on GetFrame"));
4608
4609 vos_pkt_chain_packet( vosDataBuff,
4610 pTLCb->tlMgmtFrmClient.vosPendingDataBuff,
4611 1 /*true*/ );
4612
Arun Kumar Khandavalli0af8d3c2014-02-07 18:05:11 +05304613 vos_atomic_set( (uintptr_t*)&pTLCb->tlMgmtFrmClient.
4614 vosPendingDataBuff, (uintptr_t)NULL);
Jeff Johnson295189b2012-06-20 16:38:30 -07004615
4616 /*management frames cannot be delayed*/
4617 pTLCb->bUrgent = TRUE;
4618
4619 /*Update remaining len from SSC */
4620 uRemaining -= (usPktLen + WDA_DXE_HEADER_SIZE);
4621
4622 /*Update resource count */
4623 pTLCb->uResCount -= uResLen;
4624 }
4625 else
4626 {
4627 ucResult = ( pTLCb->uResCount > uResLen )?VOS_TRUE:VOS_FALSE;
4628 break; /* Out of resources or reached max len */
4629 }
4630 }
4631 else if (( pTLCb->tlBAPClient.vosPendingDataBuff ) &&
4632 ( WDA_TLI_MIN_RES_BAP <= pTLCb->uResCount ) &&
Gopichand Nakkala7e48ca72012-12-31 14:15:07 -08004633 ( 0 == pTLCb->ucTxSuspended ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07004634 {
4635 WDA_TLI_PROCESS_FRAME_LEN( pTLCb->tlBAPClient.vosPendingDataBuff,
4636 usPktLen, uResLen, uTotalPktLen);
4637
Manjunathappa Prakashfb585462013-12-23 19:07:07 -08004638 if (usPktLen > WLANTL_MAX_ALLOWED_LEN)
4639 {
4640 usPktLen = WLANTL_MAX_ALLOWED_LEN;
4641 VOS_ASSERT(0);
4642 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004643
4644 if ( ( pTLCb->uResCount > (uResLen + WDA_TLI_MIN_RES_MF ) ) &&
4645 ( uRemaining > uTotalPktLen ))
4646 {
4647 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
4648 "WLAN TL:Chaining BT-AMP frame on GetFrame"));
4649
4650 vos_pkt_chain_packet( vosDataBuff,
4651 pTLCb->tlBAPClient.vosPendingDataBuff,
4652 1 /*true*/ );
4653
4654 /*BAP frames cannot be delayed*/
4655 pTLCb->bUrgent = TRUE;
4656
Arun Kumar Khandavalli0af8d3c2014-02-07 18:05:11 +05304657 vos_atomic_set( (uintptr_t*)&pTLCb->tlBAPClient.vosPendingDataBuff,
4658 (uintptr_t) NULL);
Jeff Johnson295189b2012-06-20 16:38:30 -07004659
4660 /*Update remaining len from SSC */
4661 uRemaining -= (usPktLen + WDA_DXE_HEADER_SIZE);
4662
4663 /*Update resource count */
4664 pTLCb->uResCount -= uResLen;
4665 }
4666 else
4667 {
Jeff Johnson295189b2012-06-20 16:38:30 -07004668 ucResult = uResLen + WDA_TLI_MIN_RES_MF;
Jeff Johnson295189b2012-06-20 16:38:30 -07004669 break; /* Out of resources or reached max len */
4670 }
4671 }
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -07004672 /* note: this feature implemented only after WLAN_INGETRATED_SOC */
4673 /* search 'EAPOL_HI_PRIORITY' will show EAPOL HI_PRIORITY change in TL and WDI
4674 by default, EAPOL will be treated as higher priority, which means
4675 use mgmt_pool and DXE_TX_HI prority channel.
4676 this is introduced to address EAPOL failure under high background traffic
4677 with multi-channel concurrent mode. But this change works in SCC or standalone, too.
4678 see CR#387009 and WCNSOS-8
4679 */
4680 else if (( WDA_TLI_MIN_RES_MF <= pTLCb->uResCount )&&
4681 ( 0 == pTLCb->ucTxSuspended ) &&
4682 ( uFlowMask & ( 1 << WDA_TXFLOW_MGMT ) )
4683 )
4684 {
4685 vosTempBuf = NULL;
4686 /*---------------------------------------------------------------------
4687 Check to see if there was any EAPOL packet is pending
4688 *--------------------------------------------------------------------*/
4689 for ( i = 0; i < WLAN_MAX_STA_COUNT; i++)
4690 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304691 if ((NULL != pTLCb->atlSTAClients[i]) &&
4692 (pTLCb->atlSTAClients[i]->ucExists) &&
4693 (0 == pTLCb->atlSTAClients[i]->ucTxSuspended) &&
Tushnim Bhattacharyya39a8f182013-02-20 18:10:30 -08004694 (WLANTL_STA_CONNECTED == pTLCb->atlSTAClients[i]->tlState) &&
4695 (pTLCb->atlSTAClients[i]->ucPktPending)
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -07004696 )
4697 break;
4698 }
4699
4700 if (i >= WLAN_MAX_STA_COUNT)
4701 {
4702 /* No More to Serve Exit Get Frames */
4703 break;
4704 }
4705 /* Serve EAPOL frame with HI_FLOW_MASK */
4706 ucSTAId = i;
4707
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304708 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
4709
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05304710 MTRACE(vos_trace(VOS_MODULE_ID_TL,
4711 TRACE_CODE_TL_GET_FRAMES_EAPOL, ucSTAId, pClientSTA->tlState));
4712
4713 if (pClientSTA->wSTADesc.wSTAType == WLAN_STA_INFRA)
4714 {
4715 if(0 != pClientSTA->aucACMask[WLANTL_AC_HIGH_PRIO])
4716 {
4717 pClientSTA->ucCurrentAC = WLANTL_AC_HIGH_PRIO;
4718 pTLCb->uCurServedAC = WLANTL_AC_HIGH_PRIO;
4719 }
4720 else
4721 break;
4722 }
4723 else
4724 {
4725 for (j = WLANTL_MAX_AC ; j > 0; j--)
4726 {
4727 if (0 != pClientSTA->aucACMask[j-1])
4728 {
4729 pClientSTA->ucCurrentAC = j-1;
4730 pTLCb->uCurServedAC = j-1;
4731 break;
4732 }
4733 }
4734 }
4735
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -07004736 wSTAEvent = WLANTL_TX_EVENT;
4737
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304738 pfnSTAFsm = tlSTAFsm[pClientSTA->tlState].
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -07004739 pfnSTATbl[wSTAEvent];
4740
4741 if ( NULL != pfnSTAFsm )
4742 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304743 pClientSTA->ucNoMoreData = 0;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004744 vosStatus = pfnSTAFsm( pvosGCtx, ucSTAId, &vosTempBuf, VOS_FALSE);
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -07004745
4746 if (( VOS_STATUS_SUCCESS != vosStatus ) &&
4747 ( NULL != vosTempBuf ))
4748 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304749 pClientSTA->pfnSTATxComp( pvosGCtx, vosTempBuf, vosStatus );
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -07004750 vosTempBuf = NULL;
4751 break;
4752 }/* status success*/
4753 }
4754
4755 if (NULL != vosTempBuf)
4756 {
4757 WDA_TLI_PROCESS_FRAME_LEN( vosTempBuf, usPktLen, uResLen, uTotalPktLen);
4758
Manjunathappa Prakashfb585462013-12-23 19:07:07 -08004759 if (usPktLen > WLANTL_MAX_ALLOWED_LEN)
4760 {
4761 usPktLen = WLANTL_MAX_ALLOWED_LEN;
4762 VOS_ASSERT(0);
4763 }
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -07004764
4765 TLLOG4(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_LOW,
4766 "WLAN TL:Resources needed by frame: %d", uResLen));
4767
4768 if ( ( pTLCb->uResCount >= (uResLen + WDA_TLI_MIN_RES_MF ) ) &&
4769 ( uRemaining > uTotalPktLen )
4770 )
4771 {
4772 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
4773 "WLAN TL:Chaining data frame on GetFrame"));
4774
4775 vos_pkt_chain_packet( vosDataBuff, vosTempBuf, 1 /*true*/ );
4776
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -07004777 /*EAPOL frame cannot be delayed*/
4778 pTLCb->bUrgent = TRUE;
4779
4780 vosTempBuf = NULL;
4781
4782 /*Update remaining len from SSC */
4783 uRemaining -= (usPktLen + WDA_DXE_HEADER_SIZE);
4784
4785 /*Update resource count */
4786 pTLCb->uResCount -= uResLen;
4787
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -07004788 //fow control update
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304789 pClientSTA->uIngress_length += uResLen;
4790 pClientSTA->uBuffThresholdMax = (pClientSTA->uBuffThresholdMax >= uResLen) ?
4791 (pClientSTA->uBuffThresholdMax - uResLen) : 0;
Tushnim Bhattacharyya39a8f182013-02-20 18:10:30 -08004792 pClientSTA->ucEapolPktPending = 0;
4793 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
4794 "WLAN TL:GetFrames STA: %d EAPOLPktPending %d",
4795 ucSTAId, pClientSTA->ucEapolPktPending);
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -07004796 }
4797 }
4798 else
4799 { // no EAPOL frames exit Get frames
Tushnim Bhattacharyya39a8f182013-02-20 18:10:30 -08004800 TLLOG2(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
4801 "WLAN TL:GetFrames STA: %d, no EAPOL frame, continue.",
4802 ucSTAId));
4803 continue;
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -07004804 }
4805 }
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -07004806
Jeff Johnson9b5dc4d2013-02-22 21:28:47 -08004807 else if (( WDA_TLI_MIN_RES_DATA <= pTLCb->uResCount ) &&
4808 ( 0 == pTLCb->ucTxSuspended ) &&
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05304809 ( uFlowMask & WLANTL_DATA_FLOW_MASK))
Jeff Johnson295189b2012-06-20 16:38:30 -07004810 {
4811 /*---------------------------------------------------------------------
4812 Check to see if there was any packet left behind previously due to
4813 size constraints
4814 ---------------------------------------------------------------------*/
4815 vosTempBuf = NULL;
4816
4817 if ( NULL != pTLCb->vosTempBuf )
4818 {
4819 vosTempBuf = pTLCb->vosTempBuf;
4820 pTLCb->vosTempBuf = NULL;
4821 ucSTAId = pTLCb->ucCachedSTAId;
4822 ucAC = pTLCb->ucCachedAC;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304823
4824 if ( NULL == pTLCb->atlSTAClients[ucSTAId] )
4825 {
4826 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
4827 "WLAN TL:Client Memory was not allocated on %s", __func__));
Madan Mohan Koyylamudi64258222013-01-30 14:35:10 +05304828 continue;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304829 }
4830
4831 pTLCb->atlSTAClients[ucSTAId]->ucNoMoreData = 0;
Madan Mohan Koyylamudi64258222013-01-30 14:35:10 +05304832 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
Jeff Johnson295189b2012-06-20 16:38:30 -07004833
4834 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
4835 "WLAN TL:Chaining cached data frame on GetFrame"));
4836 }
4837 else
4838 {
4839 WLAN_TLGetNextTxIds( pvosGCtx, &ucSTAId);
4840 if (ucSTAId >= WLAN_MAX_STA_COUNT)
4841 {
4842 /* Packets start coming in even after insmod Without *
4843 starting Hostapd or Interface being up *
4844 During which cases STAID is invaled and hence
4845 the check. HalMsg_ScnaComplete Triggers */
4846
4847 break;
4848 }
4849 /* ucCurrentAC should have correct AC to be served by calling
4850 WLAN_TLGetNextTxIds */
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304851 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304852 if ( NULL == pClientSTA )
4853 {
4854 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
4855 "WLAN TL:Client Memory was not allocated on %s", __func__));
Madan Mohan Koyylamudi64258222013-01-30 14:35:10 +05304856 continue;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304857 }
4858
4859 ucAC = pClientSTA->ucCurrentAC;
4860
4861 pClientSTA->ucNoMoreData = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07004862 TLLOG4(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_LOW,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004863 "WLAN TL: %s get one data frame, station ID %d ", __func__, ucSTAId));
Jeff Johnson295189b2012-06-20 16:38:30 -07004864 /*-------------------------------------------------------------------
4865 Check to see that STA is valid and tx is not suspended
4866 -------------------------------------------------------------------*/
4867 if ( ( ! WLANTL_STA_ID_INVALID( ucSTAId ) ) &&
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304868 ( 0 == pClientSTA->ucTxSuspended ) &&
4869 ( 0 == pClientSTA->fcStaTxDisabled) )
Jeff Johnson295189b2012-06-20 16:38:30 -07004870 {
4871 TLLOG4(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_LOW,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004872 "WLAN TL: %s sta id valid and not suspended ",__func__));
Jeff Johnson295189b2012-06-20 16:38:30 -07004873 wSTAEvent = WLANTL_TX_EVENT;
4874
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304875 pfnSTAFsm = tlSTAFsm[pClientSTA->tlState].
Jeff Johnson295189b2012-06-20 16:38:30 -07004876 pfnSTATbl[wSTAEvent];
4877
4878 if ( NULL != pfnSTAFsm )
4879 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304880 pClientSTA->ucNoMoreData = 0;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004881 vosStatus = pfnSTAFsm( pvosGCtx, ucSTAId, &vosTempBuf, VOS_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07004882
4883 if (( VOS_STATUS_SUCCESS != vosStatus ) &&
4884 ( NULL != vosTempBuf ))
4885 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304886 pClientSTA->pfnSTATxComp( pvosGCtx,
Jeff Johnson295189b2012-06-20 16:38:30 -07004887 vosTempBuf,
4888 vosStatus );
4889 vosTempBuf = NULL;
4890 }/* status success*/
4891 }/*NULL function state*/
4892 }/* valid STA id and ! suspended*/
4893 else
4894 {
4895 if ( ! WLANTL_STA_ID_INVALID( ucSTAId ) )
4896 {
4897 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
4898 "WLAN TL:Not fetching frame because suspended for sta ID %d",
4899 ucSTAId));
4900 }
4901 }
4902 }/* data */
4903
4904 if ( NULL != vosTempBuf )
4905 {
4906 WDA_TLI_PROCESS_FRAME_LEN( vosTempBuf, usPktLen, uResLen, uTotalPktLen);
4907
Manjunathappa Prakashfb585462013-12-23 19:07:07 -08004908 if (usPktLen > WLANTL_MAX_ALLOWED_LEN)
4909 {
4910 usPktLen = WLANTL_MAX_ALLOWED_LEN;
4911 VOS_ASSERT(0);
4912 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004913
4914 TLLOG4(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_LOW,
4915 "WLAN TL:Resources needed by frame: %d", uResLen));
4916
4917 if ( ( pTLCb->uResCount >= (uResLen + WDA_TLI_MIN_RES_BAP ) ) &&
Jeff Johnson9b5dc4d2013-02-22 21:28:47 -08004918 ( uRemaining > uTotalPktLen ) &&
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05304919 ( uFlowMask & WLANTL_DATA_FLOW_MASK ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07004920 {
4921 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
4922 "WLAN TL:Chaining data frame on GetFrame"));
4923
4924 vos_pkt_chain_packet( vosDataBuff, vosTempBuf, 1 /*true*/ );
4925 vosTempBuf = NULL;
4926
4927 /*Update remaining len from SSC */
4928 uRemaining -= (usPktLen + WDA_DXE_HEADER_SIZE);
4929
4930 /*Update resource count */
4931 pTLCb->uResCount -= uResLen;
4932
Jeff Johnson295189b2012-06-20 16:38:30 -07004933 //fow control update
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304934 pClientSTA->uIngress_length += uResLen;
4935 pClientSTA->uBuffThresholdMax = (pClientSTA->uBuffThresholdMax >= uResLen) ?
4936 (pClientSTA->uBuffThresholdMax - uResLen) : 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004937
Sravan Kumar Kairam60b8cf02016-12-12 16:22:09 +05304938 pClientSTA->tx_frames ++;
4939
Jeff Johnson295189b2012-06-20 16:38:30 -07004940 }
4941 else
4942 {
4943 /* Store this for later tx - already fetched from HDD */
4944 pTLCb->vosTempBuf = vosTempBuf;
4945 pTLCb->ucCachedSTAId = ucSTAId;
4946 pTLCb->ucCachedAC = ucAC;
Jeff Johnson295189b2012-06-20 16:38:30 -07004947 ucResult = uResLen + WDA_TLI_MIN_RES_BAP;
4948 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
4949 "min %d res required by TL.", ucResult ));
Jeff Johnson295189b2012-06-20 16:38:30 -07004950 break; /* Out of resources or reached max len */
4951 }
4952 }
4953 else
4954 {
4955 for ( i = 0; i < WLAN_MAX_STA_COUNT; i++)
4956 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304957 if (NULL != pTLCb->atlSTAClients[i] && (pTLCb->atlSTAClients[i]->ucExists) &&
Bhargav Shahfbaeca22016-07-13 10:27:35 +05304958 (pTLCb->atlSTAClients[i]->ucPktPending) &&
4959 (pTLCb->atlSTAClients[i]->disassoc_progress == VOS_FALSE))
Jeff Johnson295189b2012-06-20 16:38:30 -07004960 {
4961 /* There is station to be Served */
4962 break;
4963 }
4964 }
4965 if (i >= WLAN_MAX_STA_COUNT)
4966 {
4967 /* No More to Serve Exit Get Frames */
4968 break;
4969 }
4970 else
4971 {
4972 /* More to be Served */
4973 continue;
4974 }
4975 }
4976 }
4977 else
4978 {
4979 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
4980 "WLAN TL:Returning from GetFrame: resources = %d suspended = %d",
4981 pTLCb->uResCount, pTLCb->ucTxSuspended));
Jeff Johnson295189b2012-06-20 16:38:30 -07004982 /* TL is starving even when DXE is not in low resource condition
4983 Return min resource number required and Let DXE deceide what to do */
4984 if(( 0 == pTLCb->ucTxSuspended ) &&
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05304985 ( uFlowMask & WLANTL_DATA_FLOW_MASK ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07004986 {
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07004987 TLLOG1(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -07004988 "WLAN TL:Returning from GetFrame: resources = %d",
4989 pTLCb->uResCount));
4990 ucResult = WDA_TLI_MIN_RES_DATA;
4991 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004992 break; /*out of min data resources*/
4993 }
4994
4995 pTLCb->usPendingTxCompleteCount++;
4996 /* Move data buffer up one packet */
4997 vos_pkt_walk_packet_chain( vosDataBuff, &vosDataBuff, 0/*false*/ );
4998 }
4999
5000 /*----------------------------------------------------------------------
5001 Packet chain starts at root + 1
5002 ----------------------------------------------------------------------*/
5003 vos_pkt_walk_packet_chain( vosRoot, &vosDataBuff, 1/*true*/ );
5004
5005 *pvosDataBuff = vosDataBuff;
Manjunathappa Prakashfb585462013-12-23 19:07:07 -08005006 if (pbUrgent)
5007 {
5008 *pbUrgent = pTLCb->bUrgent;
5009 }
5010 else
5011 {
5012 VOS_ASSERT( pbUrgent );
5013 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005014 return ucResult;
5015}/* WLANTL_GetFrames */
5016
5017
5018/*==========================================================================
5019
5020 FUNCTION WLANTL_TxComp
5021
5022 DESCRIPTION
5023 It is being called by BAL upon asynchronous notification of the packet
5024 or packets being sent over the bus.
5025
5026 DEPENDENCIES
5027 Tx complete cannot be called without a previous transmit.
5028
5029 PARAMETERS
5030
5031 IN
5032 pvosGCtx: pointer to the global vos context; a handle to TL's
5033 or BAL's control block can be extracted from its context
5034 vosDataBuff: it will contain a pointer to the first buffer for which
5035 the BAL report is being made, if there is more then one
5036 packet they will be chained using vOSS buffers.
5037 wTxStatus: the status of the transmitted packet, see above chapter
5038 on HDD interaction for a list of possible values
5039
5040 RETURN VALUE
5041 The result code associated with performing the operation
5042
5043 VOS_STATUS_E_INVAL: Input parameters are invalid
5044 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
5045 page fault
5046 VOS_STATUS_E_EXISTS: Station was not registered
5047 VOS_STATUS_SUCCESS: Everything is good :)
5048
5049 SIDE EFFECTS
5050
5051============================================================================*/
5052VOS_STATUS
5053WLANTL_TxComp
5054(
5055 v_PVOID_t pvosGCtx,
5056 vos_pkt_t *pFrameDataBuff,
5057 VOS_STATUS wTxStatus
5058)
5059{
5060 vos_pkt_t* vosDataBuff = (vos_pkt_t*)pFrameDataBuff;
5061 WLANTL_CbType* pTLCb = NULL;
5062 WLANTL_TxCompCBType pfnTxComp = NULL;
5063 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07005064 vos_pkt_t* vosTempTx = NULL;
5065
5066 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
5067
5068 /*------------------------------------------------------------------------
5069 Sanity check
5070 ------------------------------------------------------------------------*/
5071 if ( NULL == vosDataBuff )
5072 {
5073 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
5074 "WLAN TL:Extraneous NULL data pointer on WLANTL_TxComp"));
5075 return VOS_STATUS_E_INVAL;
5076 }
5077
5078 /*------------------------------------------------------------------------
5079 Extract TL control block
5080 ------------------------------------------------------------------------*/
5081 pTLCb = VOS_GET_TL_CB(pvosGCtx);
5082 if ( NULL == pTLCb )
5083 {
5084 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
5085 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_TxComp"));
5086 return VOS_STATUS_E_FAULT;
5087 }
5088
5089 while ((0 < pTLCb->usPendingTxCompleteCount) &&
5090 ( VOS_STATUS_SUCCESS == vosStatus ) &&
5091 ( NULL != vosDataBuff))
5092 {
5093 vos_pkt_get_user_data_ptr( vosDataBuff, VOS_PKT_USER_DATA_ID_TL,
5094 (v_PVOID_t)&pfnTxComp);
5095
5096 /*it should never be NULL - default handler should be registered if none*/
5097 if ( NULL == pfnTxComp )
5098 {
5099 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
5100 "WLAN TL:NULL pointer to Tx Complete on WLANTL_TxComp"));
5101 VOS_ASSERT(0);
5102 return VOS_STATUS_E_FAULT;
5103 }
5104
5105 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05305106 "WLAN TL:Calling Tx complete for pkt %p in function %p",
Jeff Johnson295189b2012-06-20 16:38:30 -07005107 vosDataBuff, pfnTxComp));
5108
5109 vosTempTx = vosDataBuff;
5110 vosStatus = vos_pkt_walk_packet_chain( vosDataBuff,
5111 &vosDataBuff, 1/*true*/);
5112
5113 pfnTxComp( pvosGCtx, vosTempTx, wTxStatus );
5114
5115 pTLCb->usPendingTxCompleteCount--;
5116 }
5117
Jeff Johnson295189b2012-06-20 16:38:30 -07005118
5119 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
5120 "WLAN TL: current TL values are: resources = %d "
5121 "pTLCb->usPendingTxCompleteCount = %d",
5122 pTLCb->uResCount, pTLCb->usPendingTxCompleteCount));
5123
5124 return VOS_STATUS_SUCCESS;
5125}/* WLANTL_TxComp */
5126
5127/*==========================================================================
5128
5129 FUNCTION WLANTL_CacheSTAFrame
5130
5131 DESCRIPTION
5132 Internal utility function for for caching incoming data frames that do
5133 not have a registered station yet.
5134
5135 DEPENDENCIES
5136 TL must be initiailized before this function gets called.
5137 In order to benefit from thsi caching, the components must ensure that
5138 they will only register with TL at the moment when they are fully setup
5139 and ready to receive incoming data
5140
5141 PARAMETERS
5142
5143 IN
5144
5145 pTLCb: TL control block
5146 ucSTAId: station id
5147 vosTempBuff: the data packet
5148 uDPUSig: DPU signature of the incoming packet
5149 bBcast: true if packet had the MC/BC bit set
5150
5151 RETURN VALUE
5152 The result code associated with performing the operation
5153
5154 VOS_STATUS_E_FAULT: pointer to TL cb is NULL or STA Id invalid ; access
5155 would cause a page fault
5156 VOS_STATUS_SUCCESS: Everything is good :)
5157
5158 SIDE EFFECTS
5159
5160============================================================================*/
5161static VOS_STATUS
5162WLANTL_CacheSTAFrame
5163(
5164 WLANTL_CbType* pTLCb,
5165 v_U8_t ucSTAId,
5166 vos_pkt_t* vosTempBuff,
5167 v_U32_t uDPUSig,
5168 v_U8_t bBcast,
5169 v_U8_t ucFrmType
5170)
5171{
5172 v_U8_t ucUcastSig;
5173 v_U8_t ucBcastSig;
5174 v_BOOL_t bOldSTAPkt;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05305175 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005176 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
5177
5178 /*-------------------------------------------------------------------------
5179 Sanity check
5180 -------------------------------------------------------------------------*/
5181 if (( NULL == pTLCb ) || ( NULL == vosTempBuff ) )
5182 {
5183 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05305184 "WLAN TL: Invalid input pointer on WLANTL_CacheSTAFrame TL %p"
5185 " Packet %p", pTLCb, vosTempBuff ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005186 return VOS_STATUS_E_FAULT;
5187 }
5188
5189 if ( WLANTL_STA_ID_INVALID( ucSTAId ) )
5190 {
5191 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
5192 "WLAN TL:Invalid station id requested on WLANTL_CacheSTAFrame"));
5193 return VOS_STATUS_E_FAULT;
5194 }
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05305195 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
5196
5197 if ( NULL == pClientSTA )
5198 {
5199 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
5200 "WLAN TL:Client Memory was not allocated on %s", __func__));
5201 return VOS_STATUS_E_FAILURE;
5202 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005203
5204 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
5205 "WLAN TL:Attempting to cache pkt for STA %d, BD DPU Sig: %d with sig UC: %d, BC: %d",
5206 ucSTAId, uDPUSig,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05305207 pClientSTA->wSTADesc.ucUcastSig,
5208 pClientSTA->wSTADesc.ucBcastSig));
Jeff Johnson295189b2012-06-20 16:38:30 -07005209
5210 if(WLANTL_IS_CTRL_FRAME(ucFrmType))
5211 {
5212 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
5213 "WLAN TL: No need to cache CTRL frame. Dropping"));
5214 vos_pkt_return_packet(vosTempBuff);
5215 return VOS_STATUS_SUCCESS;
5216 }
5217
5218 /*-------------------------------------------------------------------------
5219 Check if the packet that we are trying to cache belongs to the old
5220 registered station (if any) or the new (potentially)upcoming station
5221
5222 - If the STA with this Id was never registered with TL - the signature
5223 will be invalid;
5224 - If the STA was previously registered TL will have cached the former
5225 set of DPU signatures
5226 -------------------------------------------------------------------------*/
5227 if ( bBcast )
5228 {
5229 ucBcastSig = (v_U8_t)uDPUSig;
5230 bOldSTAPkt = (( WLAN_TL_INVALID_B_SIG !=
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05305231 pClientSTA->wSTADesc.ucBcastSig ) &&
5232 ( ucBcastSig == pClientSTA->wSTADesc.ucBcastSig ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005233 }
5234 else
5235 {
5236 ucUcastSig = (v_U8_t)uDPUSig;
5237 bOldSTAPkt = (( WLAN_TL_INVALID_U_SIG !=
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05305238 pClientSTA->wSTADesc.ucUcastSig ) &&
5239 ( ucUcastSig == pClientSTA->wSTADesc.ucUcastSig ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005240 }
5241
5242 /*------------------------------------------------------------------------
5243 If the value of the DPU SIG matches the old, this packet will not
5244 be cached as it belonged to the former association
5245 In case the SIG does not match - this is a packet for a potentially new
5246 associated station
5247 -------------------------------------------------------------------------*/
Varun Reddy Yeturua39b9902013-01-18 15:48:32 -08005248 if ( bOldSTAPkt || bBcast )
Jeff Johnson295189b2012-06-20 16:38:30 -07005249 {
5250 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
5251 "WLAN TL:Data packet matches old sig for sig DPU: %d UC: %d, "
5252 "BC: %d - dropping",
5253 uDPUSig,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05305254 pClientSTA->wSTADesc.ucUcastSig,
5255 pClientSTA->wSTADesc.ucBcastSig));
Jeff Johnson295189b2012-06-20 16:38:30 -07005256 vos_pkt_return_packet(vosTempBuff);
5257 }
5258 else
5259 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05305260 if ( NULL == pClientSTA->vosBegCachedFrame )
Jeff Johnson295189b2012-06-20 16:38:30 -07005261 {
5262 /*this is the first frame that we are caching */
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05305263 pClientSTA->vosBegCachedFrame = vosTempBuff;
Mihir Sheteb7337272014-04-11 15:53:08 +05305264
5265 pClientSTA->tlCacheInfo.cacheInitTime = vos_timer_get_system_time();
5266 pClientSTA->tlCacheInfo.cacheDoneTime =
5267 pClientSTA->tlCacheInfo.cacheInitTime;
5268 pClientSTA->tlCacheInfo.cacheSize = 1;
5269
Mihir Sheteae6f02b2014-04-11 19:49:21 +05305270 MTRACE(vos_trace(VOS_MODULE_ID_TL, TRACE_CODE_TL_CACHE_FRAME,
5271 ucSTAId, pClientSTA->tlCacheInfo.cacheSize));
5272
Jeff Johnson295189b2012-06-20 16:38:30 -07005273 }
5274 else
5275 {
5276 /*this is a subsequent frame that we are caching: chain to the end */
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05305277 vos_pkt_chain_packet(pClientSTA->vosEndCachedFrame,
Jeff Johnson295189b2012-06-20 16:38:30 -07005278 vosTempBuff, VOS_TRUE);
Mihir Sheteb7337272014-04-11 15:53:08 +05305279
5280 pClientSTA->tlCacheInfo.cacheDoneTime = vos_timer_get_system_time();
5281 pClientSTA->tlCacheInfo.cacheSize ++;
5282
5283 if (pClientSTA->tlCacheInfo.cacheSize % WLANTL_CACHE_TRACE_WATERMARK == 0)
5284 {
5285 VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
5286 "%s: Cache High watermark for staid:%d (%d)",
5287 __func__,ucSTAId, pClientSTA->tlCacheInfo.cacheSize);
Mihir Sheteae6f02b2014-04-11 19:49:21 +05305288 MTRACE(vos_trace(VOS_MODULE_ID_TL, TRACE_CODE_TL_CACHE_FRAME,
5289 ucSTAId, pClientSTA->tlCacheInfo.cacheSize));
Mihir Sheteb7337272014-04-11 15:53:08 +05305290 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005291 }
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05305292 pClientSTA->vosEndCachedFrame = vosTempBuff;
Jeff Johnson295189b2012-06-20 16:38:30 -07005293 }/*else new packet*/
5294
5295 return VOS_STATUS_SUCCESS;
5296}/*WLANTL_CacheSTAFrame*/
5297
5298/*==========================================================================
5299
5300 FUNCTION WLANTL_FlushCachedFrames
5301
5302 DESCRIPTION
5303 Internal utility function used by TL to flush the station cache
5304
5305 DEPENDENCIES
5306 TL must be initiailized before this function gets called.
5307
5308 PARAMETERS
5309
5310 IN
5311
5312 vosDataBuff: it will contain a pointer to the first cached buffer
5313 received,
5314
5315 RETURN VALUE
5316 The result code associated with performing the operation
5317
5318 VOS_STATUS_SUCCESS: Everything is good :)
5319
5320 SIDE EFFECTS
5321
5322 NOTE
5323 This function doesn't re-initialize vosDataBuff to NULL. It's caller's
5324 responsibility to do so, if required, after this function call.
5325 Because of this restriction, we decide to make this function to static
5326 so that upper layer doesn't need to be aware of this restriction.
5327
5328============================================================================*/
5329static VOS_STATUS
5330WLANTL_FlushCachedFrames
5331(
5332 vos_pkt_t* vosDataBuff
5333)
5334{
5335 /*----------------------------------------------------------------------
5336 Return the entire chain to vos if there are indeed cache frames
5337 ----------------------------------------------------------------------*/
5338 if ( NULL != vosDataBuff )
5339 {
5340 vos_pkt_return_packet(vosDataBuff);
5341 }
5342
5343 return VOS_STATUS_SUCCESS;
5344}/*WLANTL_FlushCachedFrames*/
5345
5346/*==========================================================================
5347
5348 FUNCTION WLANTL_ForwardSTAFrames
5349
5350 DESCRIPTION
5351 Internal utility function for either forwarding cached data to the station after
5352 the station has been registered, or flushing cached data if the station has not
5353 been registered.
5354
5355
5356 DEPENDENCIES
5357 TL must be initiailized before this function gets called.
5358
5359 PARAMETERS
5360
5361 IN
5362
5363 pTLCb: TL control block
5364 ucSTAId: station id
5365
5366 RETURN VALUE
5367 The result code associated with performing the operation
5368
5369 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
5370 page fault
5371 VOS_STATUS_SUCCESS: Everything is good :)
5372
5373 SIDE EFFECTS
5374 This function doesn't re-initialize vosDataBuff to NULL. It's caller's
5375 responsibility to do so, if required, after this function call.
5376 Because of this restriction, we decide to make this function to static
5377 so that upper layer doesn't need to be aware of this restriction.
5378
5379============================================================================*/
5380static VOS_STATUS
5381WLANTL_ForwardSTAFrames
5382(
5383 void* pvosGCtx,
5384 v_U8_t ucSTAId,
5385 v_U8_t ucUcastSig,
5386 v_U8_t ucBcastSig
5387)
5388{
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05305389 WLANTL_CbType* pTLCb = NULL;
5390 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005391 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
5392
5393 /*-------------------------------------------------------------------------
5394 Sanity check
5395 -------------------------------------------------------------------------*/
5396 pTLCb = VOS_GET_TL_CB(pvosGCtx);
5397 if ( NULL == pTLCb )
5398 {
5399 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05305400 "WLAN TL: Invalid input pointer on WLANTL_ForwardSTAFrames TL %p",
Jeff Johnson295189b2012-06-20 16:38:30 -07005401 pTLCb ));
5402 return VOS_STATUS_E_FAULT;
5403 }
5404
5405 if ( WLANTL_STA_ID_INVALID( ucSTAId ) )
5406 {
5407 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
5408 "WLAN TL:Invalid station id requested on WLANTL_ForwardSTAFrames"));
5409 return VOS_STATUS_E_FAULT;
5410 }
5411
5412 //WLAN_TL_LOCK_STA_CACHE(pTLCb->atlSTAClients[ucSTAId]);
5413
5414 /*------------------------------------------------------------------------
5415 Check if station has not been registered in the mean while
5416 if not registered, flush cached frames.
5417 ------------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05305418 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
5419
5420 if ( NULL == pClientSTA )
5421 {
5422 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
5423 "WLAN TL:Client Memory was not allocated on %s", __func__));
5424 return VOS_STATUS_E_FAILURE;
5425 }
5426
5427 if ( 0 == pClientSTA->ucExists )
Jeff Johnson295189b2012-06-20 16:38:30 -07005428 {
5429 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
5430 "WLAN TL:Station has been deleted for STA %d - flushing cache", ucSTAId));
Mihir Sheteae6f02b2014-04-11 19:49:21 +05305431 MTRACE(vos_trace(VOS_MODULE_ID_TL, TRACE_CODE_TL_FLUSH_CACHED_FRAMES,
5432 ucSTAId, pClientSTA->tlCacheInfo.cacheSize));
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05305433 WLANTL_FlushCachedFrames(pClientSTA->vosBegCachedFrame);
Jeff Johnson295189b2012-06-20 16:38:30 -07005434 goto done;
5435 }
5436
5437 /*------------------------------------------------------------------------
5438 Forwarding cache frames received while the station was in the process
5439 of being registered with the rest of the SW components
5440
5441 Access to the cache must be locked; similarly updating the signature and
5442 the existence flag must be synchronized because these values are checked
5443 during cached
5444 ------------------------------------------------------------------------*/
5445 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
5446 "WLAN TL:Preparing to fwd packets for STA %d", ucSTAId));
5447
5448 /*-----------------------------------------------------------------------
5449 Save the new signature values
5450 ------------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05305451 pClientSTA->wSTADesc.ucUcastSig = ucUcastSig;
5452 pClientSTA->wSTADesc.ucBcastSig = ucBcastSig;
Jeff Johnson295189b2012-06-20 16:38:30 -07005453
5454 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
5455 "WLAN TL:Fwd-ing packets for STA %d UC %d BC %d",
5456 ucSTAId, ucUcastSig, ucBcastSig));
5457
5458 /*-------------------------------------------------------------------------
5459 Check to see if we have any cached data to forward
5460 -------------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05305461 if ( NULL != pClientSTA->vosBegCachedFrame )
Jeff Johnson295189b2012-06-20 16:38:30 -07005462 {
5463 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
5464 "WLAN TL: Fwd-ing Cached packets for station %d", ucSTAId ));
5465
5466 WLANTL_RxCachedFrames( pTLCb,
5467 ucSTAId,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05305468 pClientSTA->vosBegCachedFrame);
Jeff Johnson295189b2012-06-20 16:38:30 -07005469 }
5470 else
5471 {
5472 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
5473 "WLAN TL: NO cached packets for station %d", ucSTAId ));
5474 }
5475
5476done:
5477 /*-------------------------------------------------------------------------
5478 Clear the station cache
5479 -------------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05305480 pClientSTA->vosBegCachedFrame = NULL;
5481 pClientSTA->vosEndCachedFrame = NULL;
Mihir Sheteb7337272014-04-11 15:53:08 +05305482 pClientSTA->tlCacheInfo.cacheSize = 0;
5483 pClientSTA->tlCacheInfo.cacheClearTime = vos_timer_get_system_time();
Jeff Johnson295189b2012-06-20 16:38:30 -07005484
5485 /*-----------------------------------------------------------------------
5486 After all the init is complete we can mark the existance flag
5487 ----------------------------------------------------------------------*/
Katya Nigam63902932014-06-26 19:04:23 +05305488 pClientSTA->enableCaching = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005489
5490 //WLAN_TL_UNLOCK_STA_CACHE(pTLCb->atlSTAClients[ucSTAId]);
5491 return VOS_STATUS_SUCCESS;
5492
5493}/*WLANTL_ForwardSTAFrames*/
5494
5495
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005496#if defined(FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_ESE_UPLOAD)
Jeff Johnson295189b2012-06-20 16:38:30 -07005497/*==========================================================================
5498
5499 FUNCTION WLANTL_IsIAPPFrame
5500
5501 DESCRIPTION
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005502 Internal utility function for detecting incoming ESE IAPP frames
Jeff Johnson295189b2012-06-20 16:38:30 -07005503
5504 DEPENDENCIES
5505
5506 PARAMETERS
5507
5508 IN
5509
5510 pvBDHeader: pointer to the BD header
5511 vosTempBuff: the data packet
5512
5513 IN/OUT
5514 pFirstDataPktArrived: static from caller function; used for rssi
5515 computation
5516 RETURN VALUE
5517 The result code associated with performing the operation
5518
5519 VOS_TRUE: It is a IAPP frame
5520 VOS_FALSE: It is NOT IAPP frame
5521
5522 SIDE EFFECTS
5523
5524============================================================================*/
5525v_BOOL_t
5526WLANTL_IsIAPPFrame
5527(
5528 v_PVOID_t pvBDHeader,
5529 vos_pkt_t* vosTempBuff
5530)
5531{
5532 v_U16_t usMPDUDOffset;
5533 v_U8_t ucOffset;
5534 v_U8_t ucSnapHdr[WLANTL_LLC_SNAP_SIZE];
5535 v_SIZE_t usSnapHdrSize = WLANTL_LLC_SNAP_SIZE;
5536 VOS_STATUS vosStatus;
5537
5538 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
5539
5540 /*------------------------------------------------------------------------
5541 Check if OUI field is present.
5542 -------------------------------------------------------------------------*/
5543 if ( VOS_FALSE == WDA_IS_RX_LLC_PRESENT(pvBDHeader) )
5544 {
5545 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
5546 "WLAN TL:LLC header removed, cannot determine BT-AMP type -"
5547 "dropping pkt"));
5548 /* Drop packet */
5549 vos_pkt_return_packet(vosTempBuff);
5550 return VOS_TRUE;
5551 }
5552 usMPDUDOffset = (v_U8_t)WDA_GET_RX_MPDU_DATA_OFFSET(pvBDHeader);
5553 ucOffset = (v_U8_t)usMPDUDOffset + WLANTL_LLC_SNAP_OFFSET;
5554
5555 vosStatus = vos_pkt_extract_data( vosTempBuff, ucOffset,
5556 (v_PVOID_t)ucSnapHdr, &usSnapHdrSize);
5557
5558 if (( VOS_STATUS_SUCCESS != vosStatus))
5559 {
5560 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
5561 "Unable to extract Snap Hdr of data packet -"
5562 "dropping pkt"));
5563 return VOS_FALSE;
5564 }
5565
5566 /*------------------------------------------------------------------------
5567 Check if this is IAPP frame by matching Aironet Snap hdr.
5568 -------------------------------------------------------------------------*/
5569 // Compare returns 1 if values are same and 0
5570 // if not the same.
5571 if (( WLANTL_LLC_SNAP_SIZE != usSnapHdrSize ) ||
5572 ( 0 == vos_mem_compare(ucSnapHdr, (v_PVOID_t)WLANTL_AIRONET_SNAP_HEADER,
5573 WLANTL_LLC_SNAP_SIZE ) ))
5574 {
5575 return VOS_FALSE;
5576 }
5577
5578 return VOS_TRUE;
5579
5580}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005581#endif //FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07005582
5583/*==========================================================================
5584
5585 FUNCTION WLANTL_ProcessBAPFrame
5586
5587 DESCRIPTION
5588 Internal utility function for processing incoming BT-AMP frames
5589
5590 DEPENDENCIES
5591 TL must be initiailized before this function gets called.
5592 Bothe the BT-AMP station and the BAP Ctrl path must have been previously
5593 registered with TL.
5594
5595 PARAMETERS
5596
5597 IN
5598
5599 pvBDHeader: pointer to the BD header
5600 vosTempBuff: the data packet
5601 pTLCb: TL control block
5602 ucSTAId: station id
5603
5604 IN/OUT
5605 pFirstDataPktArrived: static from caller function; used for rssi
5606 computation
5607 RETURN VALUE
5608 The result code associated with performing the operation
5609
5610 VOS_STATUS_E_INVAL: Input parameters are invalid
5611 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
5612 page fault
5613 VOS_STATUS_SUCCESS: Everything is good :)
5614
5615 SIDE EFFECTS
5616
5617============================================================================*/
5618v_BOOL_t
5619WLANTL_ProcessBAPFrame
5620(
5621 v_PVOID_t pvBDHeader,
5622 vos_pkt_t* vosTempBuff,
5623 WLANTL_CbType* pTLCb,
5624 v_U8_t* pFirstDataPktArrived,
5625 v_U8_t ucSTAId
5626)
5627{
5628 v_U16_t usMPDUDOffset;
5629 v_U8_t ucOffset;
5630 v_U8_t ucOUI[WLANTL_LLC_OUI_SIZE];
5631 v_SIZE_t usOUISize = WLANTL_LLC_OUI_SIZE;
5632 VOS_STATUS vosStatus;
5633 v_U16_t usType;
5634 v_SIZE_t usTypeLen = sizeof(usType);
5635 v_U8_t ucMPDUHOffset;
5636 v_U8_t ucMPDUHLen = 0;
5637 v_U16_t usActualHLen = 0;
5638
5639 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
5640
5641 /*------------------------------------------------------------------------
5642 Extract OUI and type from LLC and validate; if non-data send to BAP
5643 -------------------------------------------------------------------------*/
5644 if ( VOS_FALSE == WDA_IS_RX_LLC_PRESENT(pvBDHeader) )
5645 {
5646 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
5647 "WLAN TL:LLC header removed, cannot determine BT-AMP type -"
5648 "dropping pkt"));
5649 /* Drop packet */
5650 vos_pkt_return_packet(vosTempBuff);
5651 return VOS_TRUE;
5652 }
5653
5654 usMPDUDOffset = (v_U8_t)WDA_GET_RX_MPDU_DATA_OFFSET(pvBDHeader);
5655 ucMPDUHOffset = (v_U8_t)WDA_GET_RX_MPDU_HEADER_OFFSET(pvBDHeader);
5656 ucMPDUHLen = (v_U8_t)WDA_GET_RX_MPDU_HEADER_LEN(pvBDHeader);
5657 ucOffset = (v_U8_t)usMPDUDOffset + WLANTL_LLC_OUI_OFFSET;
5658
5659 vosStatus = vos_pkt_extract_data( vosTempBuff, ucOffset,
5660 (v_PVOID_t)ucOUI, &usOUISize);
5661
5662#if 0
5663 // Compare returns 1 if values are same and 0
5664 // if not the same.
5665 if (( WLANTL_LLC_OUI_SIZE != usOUISize ) ||
5666 ( 0 == vos_mem_compare(ucOUI, (v_PVOID_t)WLANTL_BT_AMP_OUI,
5667 WLANTL_LLC_OUI_SIZE ) ))
5668 {
5669 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
5670 "LLC header points to diff OUI in BT-AMP station -"
5671 "dropping pkt"));
5672 /* Drop packet */
5673 vos_pkt_return_packet(vosTempBuff);
5674 return VOS_TRUE;
5675 }
5676#endif
5677 /*------------------------------------------------------------------------
5678 Extract LLC OUI and ensure that this is indeed a BT-AMP frame
5679 ------------------------------------------------------------------------*/
5680 vosStatus = vos_pkt_extract_data( vosTempBuff,
5681 ucOffset + WLANTL_LLC_OUI_SIZE,
5682 (v_PVOID_t)&usType, &usTypeLen);
5683
5684 if (( VOS_STATUS_SUCCESS != vosStatus) ||
5685 ( sizeof(usType) != usTypeLen ))
5686 {
5687 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
5688 "Unable to extract type on incoming BAP packet -"
5689 "dropping pkt"));
5690 /* Drop packet */
5691 vos_pkt_return_packet(vosTempBuff);
5692 return VOS_TRUE;
5693 }
5694
5695 /*------------------------------------------------------------------------
5696 Check if this is BT-AMP data or ctrl packet(RSN, LinkSvision, ActivityR)
5697 ------------------------------------------------------------------------*/
5698 usType = vos_be16_to_cpu(usType);
5699
5700 if (WLANTL_BAP_IS_NON_DATA_PKT_TYPE(usType))
5701 {
5702 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
5703 "WLAN TL:Non-data packet received over BT-AMP link: %d, => BAP",
5704 usType));
5705
5706 /*Flatten packet as BAP expects to be able to peek*/
5707 if ( VOS_STATUS_SUCCESS != vos_pkt_flatten_rx_pkt(&vosTempBuff))
5708 {
5709 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
5710 "WLAN TL:Cannot flatten BT-AMP packet - dropping"));
5711 /* Drop packet */
5712 vos_pkt_return_packet(vosTempBuff);
5713 return VOS_TRUE;
5714 }
5715
5716 /* Send packet to BAP client*/
Jeff Johnson295189b2012-06-20 16:38:30 -07005717 if ( VOS_STATUS_SUCCESS != WDA_DS_TrimRxPacketInfo( vosTempBuff ) )
5718 {
5719 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
5720 "WLAN TL:BD header corrupted - dropping packet"));
5721 /* Drop packet */
5722 vos_pkt_return_packet(vosTempBuff);
5723 return VOS_TRUE;
5724 }
5725
5726 if ( 0 == WDA_GET_RX_FT_DONE(pvBDHeader) )
5727 {
5728 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
5729 "Non-data packet received over BT-AMP link: Sending it for "
5730 "frame Translation"));
5731
5732 if (usMPDUDOffset > ucMPDUHOffset)
5733 {
5734 usActualHLen = usMPDUDOffset - ucMPDUHOffset;
5735 }
5736
5737 /* software frame translation for BTAMP WDS.*/
5738 WLANTL_Translate80211To8023Header( vosTempBuff, &vosStatus, usActualHLen,
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005739 ucMPDUHLen, pTLCb,ucSTAId, VOS_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07005740
5741 }
5742 if (pTLCb->tlBAPClient.pfnTlBAPRx)
5743 pTLCb->tlBAPClient.pfnTlBAPRx( vos_get_global_context(VOS_MODULE_ID_TL,pTLCb),
5744 vosTempBuff,
5745 (WLANTL_BAPFrameEnumType)usType );
Manjunathappa Prakashfb585462013-12-23 19:07:07 -08005746 else
5747 {
5748 VOS_ASSERT(0);
5749 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005750
5751 return VOS_TRUE;
5752 }
5753 else
5754 {
5755 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
5756 "WLAN TL: BAP DATA packet received over BT-AMP link: %d, => BAP",
5757 usType));
5758 /*!!!FIX ME!!*/
5759 #if 0
5760 /*--------------------------------------------------------------------
5761 For data packet collect phy stats RSSI and Link Quality
5762 Calculate the RSSI average and save it. Continuous average is done.
5763 --------------------------------------------------------------------*/
5764 if ( *pFirstDataPktArrived == 0)
5765 {
5766 pTLCb->atlSTAClients[ucSTAId].rssiAvg =
5767 WLANHAL_GET_RSSI_AVERAGE( pvBDHeader );
5768 pTLCb->atlSTAClients[ucSTAId].uLinkQualityAvg =
5769 WLANHAL_RX_BD_GET_SNR( pvBDHeader );
5770
5771 // Rcvd 1st pkt, start average from next time
5772 *pFirstDataPktArrived = 1;
5773 }
5774 else
5775 {
5776 pTLCb->atlSTAClients[ucSTAId].rssiAvg =
5777 (WLANHAL_GET_RSSI_AVERAGE( pvBDHeader ) +
5778 pTLCb->atlSTAClients[ucSTAId].rssiAvg)/2;
5779 pTLCb->atlSTAClients[ucSTAId].uLinkQualityAvg =
5780 (WLANHAL_RX_BD_GET_SNR( pvBDHeader ) +
5781 pTLCb->atlSTAClients[ucSTAId].uLinkQualityAvg)/2;
5782 }/*Else, first data packet*/
5783 #endif
5784 }/*BT-AMP data packet*/
5785
5786 return VOS_FALSE;
5787}/*WLANTL_ProcessBAPFrame*/
5788
Jeff Johnson295189b2012-06-20 16:38:30 -07005789
5790/*==========================================================================
5791
5792 FUNCTION WLANTL_ProcessFCFrame
5793
5794 DESCRIPTION
5795 Internal utility function for processing incoming Flow Control frames. Enable
5796 or disable LWM mode based on the information.
5797
5798 DEPENDENCIES
5799 TL must be initiailized before this function gets called.
5800 FW sends up special flow control frame.
5801
5802 PARAMETERS
5803
5804 IN
5805 pvosGCtx pointer to vos global context
5806 pvBDHeader: pointer to the BD header
5807 pTLCb: TL control block
5808 pvBDHeader pointer to BD header.
5809
5810 IN/OUT
5811 pFirstDataPktArrived: static from caller function; used for rssi
5812 computation
5813 RETURN VALUE
5814 The result code associated with performing the operation
5815
5816 VOS_STATUS_E_INVAL: Input frame are invalid
5817 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
5818 page fault
5819 VOS_STATUS_SUCCESS: Everything is good :)
5820
5821 SIDE EFFECTS
5822 The ingress and egress of each station will be updated. If needed, LWM mode will
5823 be enabled or disabled based on the flow control algorithm.
5824
5825============================================================================*/
5826v_BOOL_t
5827WLANTL_ProcessFCFrame
5828(
5829 v_PVOID_t pvosGCtx,
5830 vos_pkt_t* pvosDataBuff,
5831 v_PVOID_t pvBDHeader
5832)
5833{
5834#if 1 //enable processing of only fcStaTxDisabled bitmap for now. the else part is old better qos code.
5835 // need to revisit the old code for full implementation.
Hoonki Lee14621352013-04-16 17:51:19 -07005836 v_U8_t ucSTAId;
5837 v_U16_t ucStaValidBitmap;
5838 v_U16_t ucStaTxDisabledBitmap;
5839 WLANTL_CbType* pTLCb = NULL;
5840 #ifdef TL_DEBUG_FC
5841 v_U32_t rxTimeStamp;
5842 v_U32_t curTick;
5843 #endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005844 /*------------------------------------------------------------------------
Hoonki Lee14621352013-04-16 17:51:19 -07005845 Extract TL control block
Jeff Johnson295189b2012-06-20 16:38:30 -07005846 ------------------------------------------------------------------------*/
5847 pTLCb = VOS_GET_TL_CB(pvosGCtx);
5848 if ( NULL == pTLCb )
5849 {
5850 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
5851 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_SuspendDataTx"));
5852 return VOS_STATUS_E_FAULT;
5853 }
Hoonki Lee14621352013-04-16 17:51:19 -07005854 ucStaValidBitmap = WDA_GET_RX_FC_VALID_STA_MASK(pvBDHeader);
5855 ucStaTxDisabledBitmap = WDA_GET_RX_FC_STA_TX_DISABLED_BITMAP(pvBDHeader);
5856#ifdef TL_DEBUG_FC
5857 rxTimeStamp = WDA_GET_RX_TIMESTAMP(pvBDHeader);
5858 /* hard code of MTU_GLOBAL_TIMER_ADDR to calculate the time between generated and processed */
5859 wpalReadRegister(0x03081400+0x1D4, &curTick);
Jeff Johnson295189b2012-06-20 16:38:30 -07005860
Jeff Johnson295189b2012-06-20 16:38:30 -07005861 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Arif Hussainf2b00992013-11-17 21:46:15 -08005862 "%ld (%ld-%ld): Disabled %x Valid %x", curTick > rxTimeStamp ? curTick - rxTimeStamp : rxTimeStamp - (0xFFFFFFFF - curTick),
Hoonki Lee14621352013-04-16 17:51:19 -07005863 curTick, rxTimeStamp, ucStaTxDisabledBitmap, ucStaValidBitmap));
5864#endif
5865 for(ucSTAId = 0; ucStaValidBitmap != 0; ucStaValidBitmap >>=1, ucStaTxDisabledBitmap >>= 1, ucSTAId ++)
Jeff Johnson295189b2012-06-20 16:38:30 -07005866 {
Hoonki Lee14621352013-04-16 17:51:19 -07005867 if ( (0 == (ucStaValidBitmap & 0x1)) || (pTLCb->atlSTAClients[ucSTAId] && (0 == pTLCb->atlSTAClients[ucSTAId]->ucExists)) )
5868 continue;
5869
5870 if (ucStaTxDisabledBitmap & 0x1)
5871 {
5872 WLANTL_SuspendDataTx(pvosGCtx, &ucSTAId, NULL);
5873 }
5874 else
5875 {
5876 WLANTL_ResumeDataTx(pvosGCtx, &ucSTAId);
5877 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005878 }
5879
5880#else
5881 VOS_STATUS vosStatus;
5882 tpHalFcRxBd pvFcRxBd = NULL;
5883 v_U8_t ucBitCheck = 0x1;
5884 v_U8_t ucStaValid = 0;
5885 v_U8_t ucSTAId = 0;
5886
5887 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
5888 "Received FC Response");
5889 if ( (NULL == pTLCb) || (NULL == pvosDataBuff))
5890 {
5891 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Arif Hussainf2b00992013-11-17 21:46:15 -08005892 "WLAN TL:Invalid pointer in %s", __func__));
Jeff Johnson295189b2012-06-20 16:38:30 -07005893 return VOS_STATUS_E_FAULT;
5894 }
5895 vosStatus = vos_pkt_peek_data( pvosDataBuff, 0, (v_PVOID_t)&pvFcRxBd,
5896 sizeof(tHalFcRxBd));
5897
5898 if ( (VOS_STATUS_SUCCESS != vosStatus) || (NULL == pvFcRxBd) )
5899 {
5900 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
5901 "WLAN TL:wrong FC Rx packet"));
5902 return VOS_STATUS_E_INVAL;
5903 }
5904
5905 // need to swap bytes in the FC contents.
5906 WLANHAL_SwapFcRxBd(&pvFcRxBd->fcSTATxQLen[0]);
5907
5908 //logic to enable/disable LWM mode for each station
5909 for( ucStaValid = (v_U8_t)pvFcRxBd->fcSTAValidMask; ucStaValid; ucStaValid >>= 1, ucBitCheck <<= 1, ucSTAId ++)
5910 {
5911 if ( (0 == (ucStaValid & 0x1)) || (0 == pTLCb->atlSTAClients[ucSTAId].ucExists) )
5912 {
5913 continue;
5914 }
5915
5916 if ( pvFcRxBd->fcSTAThreshIndMask & ucBitCheck )
5917 {
5918 //LWM event is reported by FW. Able to fetch more packet
5919 if( pTLCb->atlSTAClients[ucSTAId].ucLwmModeEnabled )
5920 {
5921 //Now memory usage is below LWM. Station can send more packets.
5922 pTLCb->atlSTAClients[ucSTAId].ucLwmEventReported = TRUE;
5923 }
5924 else
5925 {
5926 TLLOG4(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_LOW,
Arif Hussainf2b00992013-11-17 21:46:15 -08005927 "WLAN TL: FW report LWM event but the station %d is not in LWM mode", ucSTAId));
Jeff Johnson295189b2012-06-20 16:38:30 -07005928 }
5929 }
5930
5931 //calculate uEgress_length/uIngress_length only after receiving enough packets
5932 if (WLANTL_LWM_INGRESS_SAMPLE_THRESHOLD <= pTLCb->atlSTAClients[ucSTAId].uIngress_length)
5933 {
5934 //check memory usage info to see whether LWM mode should be enabled for the station
5935 v_U32_t uEgress_length = pTLCb->atlSTAClients[ucSTAId].uIngress_length +
5936 pTLCb->atlSTAClients[ucSTAId].bmuMemConsumed - pvFcRxBd->fcSTATxQLen[ucSTAId];
5937
5938 //if ((float)uEgress_length/(float)pTLCb->atlSTAClients[ucSTAId].uIngress_length
5939 // <= WLANTL_LWM_EGRESS_INGRESS_THRESHOLD)
5940 if ( (pTLCb->atlSTAClients[ucSTAId].uIngress_length > uEgress_length) &&
5941 ((pTLCb->atlSTAClients[ucSTAId].uIngress_length - uEgress_length ) >=
5942 (pTLCb->atlSTAClients[ucSTAId].uIngress_length >> 2))
5943 )
5944 {
5945 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
Arif Hussainf2b00992013-11-17 21:46:15 -08005946 "WLAN TL:Enable LWM mode for station %d", ucSTAId));
Jeff Johnson295189b2012-06-20 16:38:30 -07005947 pTLCb->atlSTAClients[ucSTAId].ucLwmModeEnabled = TRUE;
5948 }
5949 else
5950 {
5951 if( pTLCb->atlSTAClients[ucSTAId].ucLwmModeEnabled )
5952 {
5953 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
Arif Hussainf2b00992013-11-17 21:46:15 -08005954 "WLAN TL:Disable LWM mode for station %d", ucSTAId));
Jeff Johnson295189b2012-06-20 16:38:30 -07005955 pTLCb->atlSTAClients[ucSTAId].ucLwmModeEnabled = FALSE;
5956 }
5957
5958 }
5959
5960 //remember memory usage in FW starting from this round
5961 pTLCb->atlSTAClients[ucSTAId].bmuMemConsumed = pvFcRxBd->fcSTATxQLen[ucSTAId];
5962 pTLCb->atlSTAClients[ucSTAId].uIngress_length = 0;
5963 } //(WLANTL_LWM_INGRESS_SAMPLE_THRESHOLD <= pTLCb->atlSTAClients[ucSTAId].uIngress_length)
5964
5965 if( pTLCb->atlSTAClients[ucSTAId].ucLwmModeEnabled )
5966 {
5967 //always update current maximum allowed memeory usage
5968 pTLCb->atlSTAClients[ucSTAId].uBuffThresholdMax = WLANTL_STA_BMU_THRESHOLD_MAX -
5969 pvFcRxBd->fcSTATxQLen[ucSTAId];
5970 }
5971
5972 }
5973#endif
5974
5975 return VOS_STATUS_SUCCESS;
5976}
Jeff Johnson295189b2012-06-20 16:38:30 -07005977
Sravan Kumar Kairamb0edc612016-10-26 13:55:24 +05305978/**
5979 * WLANTL_FlowControl() - TX Flow control
5980 * @pTLCb: TL context pointer
5981 * @pvosDataBuff: Firmware indication data buffer
5982 *
5983 * This function implenets the algorithm to flow control TX traffic in case
5984 * of SAP and SAP + STA concurrency.
5985 *
5986 * Algorithm goal is to fetch more packets from good peer than bad peer by
5987 * introducing weights for each station connected. Weight of each station is
5988 * calcutated by taking ratio of max RA rate of the peers to its rate. If the
5989 * ratio is less than two based on number of queued frames in the station BTQM
5990 * weight is modified. If the queued frames reaches the defined threshold weight
5991 * is assigned as four. Here weight is inversely proportional to the number of
5992 * packets fetch.
5993 *
5994 * Return true if flow controlled or false otherwise.
5995 */
5996static bool WLANTL_FlowControl(WLANTL_CbType* pTLCb, vos_pkt_t* pvosDataBuff)
5997{
5998 WLANTL_FlowControlInfo *fc_data = NULL;
5999 WLANTL_PerStaFlowControlParam *sta_fc_params = NULL;
6000 uint8_t num_stas;
6001 struct sk_buff *skb = NULL;
6002 uint16_t data_len;
6003 uint8_t *staid;
6004 uint16_t max_rate = 0;
6005 uint8_t i;
6006
6007 vos_pkt_get_packet_length(pvosDataBuff, &data_len);
6008 if (!data_len) {
6009 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6010 "%s: Null fw indication data", __func__));
6011 return false;
6012 }
6013
6014 vos_pkt_get_os_packet(pvosDataBuff, (v_VOID_t **)&skb, 0);
6015 fc_data = (WLANTL_FlowControlInfo *)skb->data;
6016 num_stas = fc_data->num_stas;
6017 if (!num_stas) {
6018 TLLOG1(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
6019 "%s: No connected stations", __func__));
6020 return true;
6021 }
6022
6023 /* Skip flow control for one connected station */
6024 if (1 == num_stas)
6025 return true;
6026
6027 staid = (uint8_t *)vos_mem_malloc(WLAN_MAX_STA_COUNT);
6028 if (!staid) {
6029 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6030 "%s: mem allocation failure", __func__));
6031 return false;
6032 }
6033 vos_mem_set((uint8_t *)staid, WLAN_MAX_STA_COUNT, 0);
6034
6035 sta_fc_params = (WLANTL_PerStaFlowControlParam *)(&fc_data->num_stas + 1);
6036
6037 for(i = 0; i < num_stas; i ++, sta_fc_params ++) {
6038 staid[i] = sta_fc_params->sta_id;
6039
6040 if (!pTLCb->atlSTAClients[staid[i]])
6041 continue;
6042
6043 pTLCb->atlSTAClients[staid[i]]->per = sta_fc_params->avg_per;
6044 pTLCb->atlSTAClients[staid[i]]->queue = sta_fc_params->queue_len;
6045 pTLCb->atlSTAClients[staid[i]]->trate = sta_fc_params->rate;
6046 max_rate = max_rate > pTLCb->atlSTAClients[staid[i]]->trate ?
6047 max_rate : pTLCb->atlSTAClients[staid[i]]->trate;
6048
6049 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
6050 "%s: sta_id:%d in:%d queue:%d avg_per:%d rate:%d", __func__,
6051 staid[i], pTLCb->atlSTAClients[staid[i]]->tx_samples_sum,
6052 pTLCb->atlSTAClients[staid[i]]->queue,
6053 pTLCb->atlSTAClients[staid[i]]->per,
6054 pTLCb->atlSTAClients[staid[i]]->trate));
6055 }
6056
6057 for (i = 0; i < num_stas; i++) {
6058 pTLCb->atlSTAClients[staid[i]]->weight =
6059 max_rate/pTLCb->atlSTAClients[staid[i]]->trate;
Sravan Kumar Kairamd482a2b2017-02-09 17:44:58 +05306060 if (pTLCb->atlSTAClients[staid[i]]->weight >=
6061 WLANTL_RATE_RATIO_THRESHOLD) {
6062 if (!pTLCb->atlSTAClients[staid[i]]->set_flag) {
Sravan Kumar Kairamb0edc612016-10-26 13:55:24 +05306063 vos_set_hdd_bad_sta(staid[i]);
6064 pTLCb->atlSTAClients[staid[i]]->set_flag = true;
Sravan Kumar Kairamd482a2b2017-02-09 17:44:58 +05306065 }
6066 /**
6067 * If station's link becomes very bad rssi below -90dbm then because
6068 * of high PER rate high number of packets are stuck in BTQM which is
6069 * affecting the good peers throughput. So throttle further the bad
6070 * link traffic.
6071 */
6072 if ((pTLCb->atlSTAClients[staid[i]]->weight >
6073 WLANTL_WEIGHT_THRESHOLD) &&
6074 (pTLCb->atlSTAClients[staid[i]]->queue >
6075 WLANTL_QUEUE_THRESHOLD))
6076 pTLCb->atlSTAClients[staid[i]]->weight *= 2;
Sravan Kumar Kairamb0edc612016-10-26 13:55:24 +05306077 }
6078 if (pTLCb->atlSTAClients[staid[i]]->weight <
6079 WLANTL_RATE_RATIO_THRESHOLD) {
Sravan Kumar Kairamd482a2b2017-02-09 17:44:58 +05306080 if (pTLCb->atlSTAClients[staid[i]]->per >= WLANTL_PER_THRESHOLD &&
Sravan Kumar Kairam416a0c22017-01-02 22:58:09 +05306081 pTLCb->atlSTAClients[staid[i]]->queue > WLANTL_QUEUE_THRESHOLD) {
6082 vos_set_hdd_bad_sta(staid[i]);
6083 pTLCb->atlSTAClients[staid[i]]->set_flag = true;
6084 }
6085 else if (pTLCb->atlSTAClients[staid[i]]->set_flag) {
Sravan Kumar Kairamb0edc612016-10-26 13:55:24 +05306086 vos_reset_hdd_bad_sta(staid[i]);
6087 pTLCb->atlSTAClients[staid[i]]->set_flag = false;
6088 }
6089 }
6090 }
6091 vos_mem_free(staid);
6092 return true;
6093}
Jeff Johnson295189b2012-06-20 16:38:30 -07006094
Sravan Kumar Kairam091e5b62017-01-23 14:14:20 +05306095/**
6096 * WLANTL_CacheEapol() - cache eapol frames
6097 * @pTLCb : pointer to TL context
6098 * @vosTempBuff: pointer to vos packet buff
6099 *
6100 * Return: None
6101 *
6102 */
6103static void WLANTL_CacheEapol(WLANTL_CbType* pTLCb, vos_pkt_t* vosTempBuff)
6104{
6105 if ((NULL == pTLCb) || (NULL == vosTempBuff))
6106 {
6107 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6108 "%s: Invalid input pointer", __func__));
6109 return;
6110 }
6111
6112 if (NULL == pTLCb->vosEapolCachedFrame) {
6113 TLLOG1(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
6114 "%s: Cache Eapol frame", __func__));
6115 pTLCb->vosEapolCachedFrame = vosTempBuff;
6116 }
6117}
6118
Jeff Johnson295189b2012-06-20 16:38:30 -07006119/*==========================================================================
6120
6121 FUNCTION WLANTL_RxFrames
6122
6123 DESCRIPTION
6124 Callback registered by TL and called by BAL when a packet is received
6125 over the bus. Upon the call of this function TL will make the necessary
6126 decision with regards to the forwarding or queuing of this packet and
6127 the layer it needs to be delivered to.
6128
6129 DEPENDENCIES
6130 TL must be initiailized before this function gets called.
6131 If the frame carried is a data frame then the station for which it is
6132 destined to must have been previously registered with TL.
6133
6134 PARAMETERS
6135
6136 IN
6137 pvosGCtx: pointer to the global vos context; a handle to TL's
6138 or BAL's control block can be extracted from its context
6139
6140 vosDataBuff: it will contain a pointer to the first buffer received,
6141 if there is more then one packet they will be chained
6142 using vOSS buffers.
6143
6144 RETURN VALUE
6145 The result code associated with performing the operation
6146
6147 VOS_STATUS_E_INVAL: Input parameters are invalid
6148 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
6149 page fault
6150 VOS_STATUS_SUCCESS: Everything is good :)
6151
6152 SIDE EFFECTS
6153
6154============================================================================*/
6155VOS_STATUS
6156WLANTL_RxFrames
6157(
6158 v_PVOID_t pvosGCtx,
6159 vos_pkt_t *pFrameDataBuff
6160)
6161{
6162 vos_pkt_t* vosDataBuff = (vos_pkt_t*)pFrameDataBuff;
6163 WLANTL_CbType* pTLCb = NULL;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306164 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07006165 WLANTL_STAFuncType pfnSTAFsm;
6166 vos_pkt_t* vosTempBuff;
6167 v_U8_t ucSTAId;
6168 VOS_STATUS vosStatus;
6169 v_U8_t ucFrmType;
6170 v_PVOID_t pvBDHeader = NULL;
6171 WLANTL_STAEventType wSTAEvent = WLANTL_RX_EVENT;
6172 v_U8_t ucTid = 0;
6173 v_BOOL_t broadcast = VOS_FALSE;
6174 v_BOOL_t selfBcastLoopback = VOS_FALSE;
Madan Mohan Koyyalamudidfd6aa82012-10-18 20:18:43 -07006175 static v_U8_t first_data_pkt_arrived;
Jeff Johnson295189b2012-06-20 16:38:30 -07006176 v_U32_t uDPUSig;
Jeff Johnson295189b2012-06-20 16:38:30 -07006177 v_U16_t usPktLen;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07006178 v_BOOL_t bForwardIAPPwithLLC = VOS_FALSE;
Dino Mycle3b9536d2014-07-09 22:05:24 +05306179#ifdef WLAN_FEATURE_LINK_LAYER_STATS
6180 v_S7_t currentAvgRSSI = 0;
6181 v_U8_t ac;
Dino Mycle3b9536d2014-07-09 22:05:24 +05306182#endif
Sravan Kumar Kairam091e5b62017-01-23 14:14:20 +05306183 uint16_t seq_no;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07006184
Jeff Johnson295189b2012-06-20 16:38:30 -07006185 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
6186
6187 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
6188 "WLAN TL:TL Receive Frames called"));
6189
6190 /*------------------------------------------------------------------------
6191 Sanity check
6192 ------------------------------------------------------------------------*/
6193 if ( NULL == vosDataBuff )
6194 {
6195 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6196 "WLAN TL:Invalid parameter sent on WLANTL_RxFrames"));
6197 return VOS_STATUS_E_INVAL;
6198 }
6199
Katya Nigam3802f202013-12-16 19:27:14 +05306200 /*------------------------------------------------------------------------
6201 Popolaute timestamp as the time when packet arrives
6202 ---------------------------------------------------------------------- */
6203 vosDataBuff->timestamp = vos_timer_get_system_ticks();
6204
Jeff Johnson295189b2012-06-20 16:38:30 -07006205 /*------------------------------------------------------------------------
6206 Extract TL control block
6207 ------------------------------------------------------------------------*/
6208 pTLCb = VOS_GET_TL_CB(pvosGCtx);
6209 if ( NULL == pTLCb )
6210 {
6211 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6212 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_ChangeSTAState"));
6213 return VOS_STATUS_E_FAULT;
6214 }
6215
6216 /*---------------------------------------------------------------------
6217 Save the initial buffer - this is the first received buffer
6218 ---------------------------------------------------------------------*/
6219 vosTempBuff = vosDataBuff;
6220
6221 while ( NULL != vosTempBuff )
6222 {
Madan Mohan Koyyalamudia148e1e2012-11-30 14:52:59 -08006223 broadcast = VOS_FALSE;
6224 selfBcastLoopback = VOS_FALSE;
6225
Jeff Johnson295189b2012-06-20 16:38:30 -07006226 vos_pkt_walk_packet_chain( vosDataBuff, &vosDataBuff, 1/*true*/ );
6227
Katya Nigame7b69a82015-04-28 15:24:06 +05306228 if( vos_get_conparam() == VOS_MONITOR_MODE )
6229 {
6230 if( pTLCb->isConversionReq )
6231 WLANTL_MonTranslate80211To8023Header(vosTempBuff, pTLCb);
6232
6233 pTLCb->pfnMonRx(pvosGCtx, vosTempBuff, pTLCb->isConversionReq);
6234 vosTempBuff = vosDataBuff;
6235 continue;
6236 }
6237
Jeff Johnson295189b2012-06-20 16:38:30 -07006238 /*---------------------------------------------------------------------
6239 Peek at BD header - do not remove
6240 !!! Optimize me: only part of header is needed; not entire one
6241 ---------------------------------------------------------------------*/
6242 vosStatus = WDA_DS_PeekRxPacketInfo( vosTempBuff, (v_PVOID_t)&pvBDHeader, 1/*Swap BD*/ );
6243
6244 if ( NULL == pvBDHeader )
6245 {
6246 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6247 "WLAN TL:Cannot extract BD header"));
6248 /* Drop packet */
6249 vos_pkt_return_packet(vosTempBuff);
6250 vosTempBuff = vosDataBuff;
6251 continue;
6252 }
6253
Jeff Johnson295189b2012-06-20 16:38:30 -07006254 /*---------------------------------------------------------------------
6255 Check if FC frame reported from FW
6256 ---------------------------------------------------------------------*/
6257 if(WDA_IS_RX_FC(pvBDHeader))
6258 {
6259 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
6260 "WLAN TL:receive one FC frame"));
6261
Sravan Kumar Kairamb0edc612016-10-26 13:55:24 +05306262 WLANTL_FlowControl(pTLCb, vosTempBuff);
6263
Jeff Johnson295189b2012-06-20 16:38:30 -07006264 /* Drop packet */
6265 vos_pkt_return_packet(vosTempBuff);
6266 vosTempBuff = vosDataBuff;
6267 continue;
6268 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006269
6270 /* AMSDU HW bug fix
6271 * After 2nd AMSDU subframe HW could not handle BD correctly
6272 * HAL workaround is needed */
6273 if(WDA_GET_RX_ASF(pvBDHeader))
6274 {
6275 WDA_DS_RxAmsduBdFix(pvosGCtx, pvBDHeader);
6276 }
6277
6278 /*---------------------------------------------------------------------
6279 Extract frame control field from 802.11 header if present
6280 (frame translation not done)
6281 ---------------------------------------------------------------------*/
6282
6283 vosStatus = WDA_DS_GetFrameTypeSubType( pvosGCtx, vosTempBuff,
6284 pvBDHeader, &ucFrmType );
6285 if ( VOS_STATUS_SUCCESS != vosStatus )
6286 {
6287 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6288 "WLAN TL:Cannot extract Frame Control Field"));
6289 /* Drop packet */
6290 vos_pkt_return_packet(vosTempBuff);
6291 vosTempBuff = vosDataBuff;
6292 continue;
6293 }
6294
Jeff Johnson295189b2012-06-20 16:38:30 -07006295 vos_pkt_get_packet_length(vosTempBuff, &usPktLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07006296
6297 /*---------------------------------------------------------------------
6298 Check if management and send to PE
6299 ---------------------------------------------------------------------*/
6300
Deepthi Gowrie89de132015-05-14 12:23:57 +05306301 if ( WLANTL_IS_MGMT_FRAME(ucFrmType))
Jeff Johnson295189b2012-06-20 16:38:30 -07006302 {
6303 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
6304 "WLAN TL:Sending packet to management client"));
6305 if ( VOS_STATUS_SUCCESS != vos_pkt_flatten_rx_pkt(&vosTempBuff))
6306 {
6307 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6308 "WLAN TL:Cannot flatten packet - dropping"));
6309 /* Drop packet */
6310 vos_pkt_return_packet(vosTempBuff);
6311 vosTempBuff = vosDataBuff;
6312 continue;
6313 }
6314 ucSTAId = (v_U8_t)WDA_GET_RX_STAID( pvBDHeader );
6315 /* Read RSSI and update */
6316 if(!WLANTL_STA_ID_INVALID(ucSTAId))
6317 {
6318#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
6319 /* Read RSSI and update */
6320 vosStatus = WLANTL_HSHandleRXFrame(pvosGCtx,
6321 WLANTL_MGMT_FRAME_TYPE,
6322 pvBDHeader,
6323 ucSTAId,
6324 VOS_FALSE,
6325 NULL);
6326#else
6327 vosStatus = WLANTL_ReadRSSI(pvosGCtx, pvBDHeader, ucSTAId);
6328#endif
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05306329 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
6330 {
6331 TLLOGW(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
6332 "Handle RX Management Frame fail within Handoff "
6333 "support module"));
6334 /* Do Not Drop packet at here
6335 * Revisit why HO module return fail
6336 * vos_pkt_return_packet(vosTempBuff);
6337 * vosTempBuff = vosDataBuff;
6338 * continue;
6339 */
6340 }
6341 vosStatus = WLANTL_ReadSNR(pvosGCtx, pvBDHeader, ucSTAId);
6342
6343 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
6344 {
6345 TLLOGW(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
6346 FL("Failed to Read SNR")));
6347 }
Dino Mycle3b9536d2014-07-09 22:05:24 +05306348#ifdef WLAN_FEATURE_LINK_LAYER_STATS
6349 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
6350 if ( NULL != pClientSTA)
6351 {
6352 pClientSTA->interfaceStats.mgmtRx++;
Dino Mycle3b9536d2014-07-09 22:05:24 +05306353 }
6354#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006355 }
6356
Jeff Johnson295189b2012-06-20 16:38:30 -07006357 pTLCb->tlMgmtFrmClient.pfnTlMgmtFrmRx( pvosGCtx, vosTempBuff);
6358 }
6359 else /* Data Frame */
6360 {
6361 ucSTAId = (v_U8_t)WDA_GET_RX_STAID( pvBDHeader );
6362 ucTid = (v_U8_t)WDA_GET_RX_TID( pvBDHeader );
Sravan Kumar Kairam091e5b62017-01-23 14:14:20 +05306363 uDPUSig = WDA_GET_RX_DPUSIG(pvBDHeader);
6364 seq_no = (uint16_t)WDA_GET_RX_REORDER_CUR_PKT_SEQ_NO(pvBDHeader);
Jeff Johnson295189b2012-06-20 16:38:30 -07006365
6366 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
6367 "WLAN TL:Data packet received for STA %d", ucSTAId));
6368
6369 /*------------------------------------------------------------------
6370 This should be corrected when multipe sta support is added !!!
6371 for now bcast frames will be sent to the last registered STA
6372 ------------------------------------------------------------------*/
6373 if ( WDA_IS_RX_BCAST(pvBDHeader))
6374 {
6375 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
6376 "WLAN TL:TL rx Bcast frame - sending to last registered station"));
6377 broadcast = VOS_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006378 /*-------------------------------------------------------------------
6379 If Addr1 is b/mcast, but Addr3 is our own self MAC, it is a b/mcast
6380 pkt we sent looping back to us. To be dropped if we are non BTAMP
6381 -------------------------------------------------------------------*/
6382 if( WLANHAL_RX_BD_ADDR3_SELF_IDX ==
6383 (v_U8_t)WDA_GET_RX_ADDR3_IDX( pvBDHeader ))
6384 {
6385 selfBcastLoopback = VOS_TRUE;
6386 }
6387 }/*if bcast*/
6388
Sravan Kumar Kairam091e5b62017-01-23 14:14:20 +05306389 /* Pre assoc cache eapol */
6390 if (pTLCb->preassoc_caching)
6391 {
6392 TLLOG1(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
6393 "WLAN TL:TL preassoc_caching is enabled seq No: %d", seq_no));
6394 WLANTL_CacheEapol(pTLCb, vosTempBuff);
6395 vosTempBuff = vosDataBuff;
6396 continue;
6397 }
6398
Sravan Kumar Kairam09a5e0b2016-05-03 13:17:42 +05306399 if (WLANTL_STA_ID_INVALID(ucSTAId))
Jeff Johnson295189b2012-06-20 16:38:30 -07006400 {
6401 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
Sravan Kumar Kairam09a5e0b2016-05-03 13:17:42 +05306402 "WLAN TL:STAId %d. Invalid STA ID dropping pkt",
6403 ucSTAId));
Jeff Johnson295189b2012-06-20 16:38:30 -07006404 /* Drop packet */
6405 vos_pkt_return_packet(vosTempBuff);
6406 vosTempBuff = vosDataBuff;
6407 continue;
6408 }
6409
Sravan Kumar Kairam09a5e0b2016-05-03 13:17:42 +05306410 if (WLANTL_TID_INVALID( ucTid)) {
6411 /* There is a possibility AP uses wrong TID. In that case to avoid
6412 dropping EAPOL packet in the driver use TID to zero.*/
6413 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
6414 "WLAN TL:Invalid Tid: %d Frame type: %d", ucTid, ucFrmType);
Paul Zhangda6dd252016-08-11 13:51:49 +08006415 WDA_GET_RX_TID( pvBDHeader ) = 0;
Sravan Kumar Kairam09a5e0b2016-05-03 13:17:42 +05306416 ucTid = 0;
6417 }
6418
jagadeesh99d8e632015-04-27 13:21:24 +05306419#ifdef WLAN_FEATURE_LINK_LAYER_STATS
6420 ac = WLANTL_TID_2_AC[ucTid];
6421#endif
6422
Jeff Johnson295189b2012-06-20 16:38:30 -07006423 /*----------------------------------------------------------------------
6424 No need to lock cache access because cache manipulation only happens
6425 in the transport thread/task context
6426 - These frames are to be forwarded to the station upon registration
6427 which happens in the main thread context
6428 The caching here can happen in either Tx or Rx thread depending
6429 on the current SSC scheduling
6430 - also we need to make sure that the frames in the cache are fwd-ed to
6431 the station before the new incoming ones
6432 -----------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306433 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
6434 if (NULL == pClientSTA)
6435 {
6436 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
6437 "WLAN TL:STA not allocated memory. Dropping packet"));
6438 vos_pkt_return_packet(vosTempBuff);
6439 vosTempBuff = vosDataBuff;
6440 continue;
6441 }
6442
Hoonki Lee5305c3a2013-04-29 23:28:59 -07006443#ifdef FEATURE_WLAN_TDLS
6444 if (( pClientSTA->ucExists ) &&
6445 (WLAN_STA_TDLS == pClientSTA->wSTADesc.wSTAType) &&
6446 (pClientSTA->ucTxSuspended))
6447 vos_atomic_set_U8( &pClientSTA->ucTxSuspended, 0 );
6448 else if ( !broadcast && (pClientSTA->ucExists == 0 ) )
6449 {
6450 tpSirMacMgmtHdr pMacHeader = WDA_GET_RX_MAC_HEADER( pvBDHeader );
6451
6452 /* from the direct peer while it is not registered to TL yet */
6453 if ( (pMacHeader->fc.fromDS == 0) &&
6454 (pMacHeader->fc.toDS == 0) )
6455 {
6456 v_U8_t ucAddr3STAId;
6457
6458 ucAddr3STAId = WDA_GET_RX_ADDR3_IDX(pvBDHeader);
6459
6460 if ( WLANTL_STA_ID_INVALID(ucAddr3STAId) )
6461 {
6462 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
6463 "WLAN TL:STA ID %d invalid - dropping pkt", ucAddr3STAId));
6464 /* Drop packet */
6465 vos_pkt_return_packet(vosTempBuff);
6466 vosTempBuff = vosDataBuff;
6467 continue;
6468 }
6469
6470 if (!(pTLCb->atlSTAClients[ucAddr3STAId] && pTLCb->atlSTAClients[ucAddr3STAId]->ucExists &&
6471 (WLAN_STA_INFRA == pTLCb->atlSTAClients[ucAddr3STAId]->wSTADesc.wSTAType) &&
6472 (WLANTL_STA_AUTHENTICATED == pTLCb->atlSTAClients[ucAddr3STAId]->tlState)))
6473 {
6474 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
Arif Hussainf2b00992013-11-17 21:46:15 -08006475 "%s: staId %d addr3Id %d tlState %d. Unkown Receiver/Transmitter Dropping packet", __func__,
Hoonki Lee5305c3a2013-04-29 23:28:59 -07006476 ucSTAId, ucAddr3STAId, pTLCb->atlSTAClients[ucAddr3STAId]->tlState));
6477 vos_pkt_return_packet(vosTempBuff);
6478 vosTempBuff = vosDataBuff;
6479 continue;
6480 }
6481 else
6482 {
6483 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
Arif Hussainf2b00992013-11-17 21:46:15 -08006484 "%s: staId %d doesn't exist, but mapped to AP staId %d", __func__,
Hoonki Lee5305c3a2013-04-29 23:28:59 -07006485 ucSTAId, ucAddr3STAId));
6486 ucSTAId = ucAddr3STAId;
6487 pClientSTA = pTLCb->atlSTAClients[ucAddr3STAId];
6488 }
6489 }
6490 }
6491#endif
6492
Katya Nigam63902932014-06-26 19:04:23 +05306493 if (( pClientSTA->enableCaching == 1 ) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07006494 /*Dont buffer Broadcast/Multicast frames. If AP transmits bursts of Broadcast/Multicast data frames,
6495 * libra buffers all Broadcast/Multicast packets after authentication with AP,
6496 * So it will lead to low resource condition in Rx Data Path.*/
Katya Nigam63902932014-06-26 19:04:23 +05306497 ( WDA_IS_RX_BCAST(pvBDHeader) == 0 ))
Jeff Johnson295189b2012-06-20 16:38:30 -07006498 {
Katya Nigam6201c3e2014-05-27 17:51:42 +05306499 if( WDA_IsSelfSTA(pvosGCtx,ucSTAId))
6500 {
6501 //drop packet for Self STA index
6502 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
6503 "%s: Packet dropped for Self STA with staId %d ", __func__, ucSTAId ));
6504
6505 vos_pkt_return_packet(vosTempBuff);
6506 vosTempBuff = vosDataBuff;
6507 continue;
6508 }
Sravan Kumar Kairam091e5b62017-01-23 14:14:20 +05306509 /* Station has not yet been registered with TL - cache the frame */
Hoonki Lee5305c3a2013-04-29 23:28:59 -07006510 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
Arif Hussainf2b00992013-11-17 21:46:15 -08006511 "%s: staId %d exist %d tlState %d cache rx frame", __func__, ucSTAId,
Hoonki Lee5305c3a2013-04-29 23:28:59 -07006512 pClientSTA->ucExists, pClientSTA->tlState));
Jeff Johnson295189b2012-06-20 16:38:30 -07006513 WLANTL_CacheSTAFrame( pTLCb, ucSTAId, vosTempBuff, uDPUSig, broadcast, ucFrmType);
6514 vosTempBuff = vosDataBuff;
6515 continue;
6516 }
6517
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08006518#ifdef FEATURE_WLAN_ESE_UPLOAD
6519 if ((pClientSTA->wSTADesc.ucIsEseSta)|| broadcast)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07006520 {
6521 /*--------------------------------------------------------------------
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08006522 Filter the IAPP frames for ESE connection;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07006523 if data it will return false and it
6524 will be routed through the regular data path
6525 --------------------------------------------------------------------*/
6526 if ( WLANTL_IsIAPPFrame(pvBDHeader,
6527 vosTempBuff))
6528 {
6529 bForwardIAPPwithLLC = VOS_TRUE;
6530 }
6531 }
6532#endif
6533
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08006534#if defined(FEATURE_WLAN_ESE) && !defined(FEATURE_WLAN_ESE_UPLOAD)
6535 if ((pClientSTA->wSTADesc.ucIsEseSta)|| broadcast)
Jeff Johnson295189b2012-06-20 16:38:30 -07006536 {
6537 /*--------------------------------------------------------------------
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08006538 Filter the IAPP frames for ESE connection;
Jeff Johnson295189b2012-06-20 16:38:30 -07006539 if data it will return false and it
6540 will be routed through the regular data path
6541 --------------------------------------------------------------------*/
6542 if ( WLANTL_IsIAPPFrame(pvBDHeader,
6543 vosTempBuff))
6544 {
6545 if ( VOS_STATUS_SUCCESS != vos_pkt_flatten_rx_pkt(&vosTempBuff))
6546 {
6547 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6548 "WLAN TL:Cannot flatten packet - dropping"));
6549 /* Drop packet */
6550 vos_pkt_return_packet(vosTempBuff);
6551 } else {
6552
6553 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08006554 "WLAN TL: Received ESE IAPP Frame"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006555
6556 pTLCb->tlMgmtFrmClient.pfnTlMgmtFrmRx( pvosGCtx, vosTempBuff);
6557 }
6558 vosTempBuff = vosDataBuff;
6559 continue;
6560 }
6561 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08006562#endif /* defined(FEATURE_WLAN_ESE) && !defined(FEATURE_WLAN_ESE_UPLOAD) */
Jeff Johnson295189b2012-06-20 16:38:30 -07006563
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306564 if ( WLAN_STA_BT_AMP == pClientSTA->wSTADesc.wSTAType )
Jeff Johnson295189b2012-06-20 16:38:30 -07006565 {
6566 /*--------------------------------------------------------------------
6567 Process the ctrl BAP frame; if data it will return false and it
6568 will be routed through the regular data path
6569 --------------------------------------------------------------------*/
6570 if ( WLANTL_ProcessBAPFrame( pvBDHeader,
6571 vosTempBuff,
6572 pTLCb,
6573 &first_data_pkt_arrived,
6574 ucSTAId))
6575 {
6576 vosTempBuff = vosDataBuff;
6577 continue;
6578 }
6579 }/*if BT-AMP station*/
6580 else if(selfBcastLoopback == VOS_TRUE)
6581 {
6582 /* Drop packet */
6583 vos_pkt_return_packet(vosTempBuff);
6584 vosTempBuff = vosDataBuff;
6585 continue;
6586 }
6587
6588 /*---------------------------------------------------------------------
6589 Data packet received, send to state machine
6590 ---------------------------------------------------------------------*/
6591 wSTAEvent = WLANTL_RX_EVENT;
6592
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306593 pfnSTAFsm = tlSTAFsm[pClientSTA->tlState].
Jeff Johnson295189b2012-06-20 16:38:30 -07006594 pfnSTATbl[wSTAEvent];
6595
6596 if ( NULL != pfnSTAFsm )
6597 {
6598#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
6599 /* Read RSSI and update */
6600 vosStatus = WLANTL_HSHandleRXFrame(pvosGCtx,
6601 WLANTL_DATA_FRAME_TYPE,
6602 pvBDHeader,
6603 ucSTAId,
6604 broadcast,
6605 vosTempBuff);
6606 broadcast = VOS_FALSE;
6607#else
6608 vosStatus = WLANTL_ReadRSSI(pvosGCtx, pvBDHeader, ucSTAId);
Kiet Lam47325522014-03-10 11:50:46 -07006609#endif
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05306610 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
Jeff Johnson295189b2012-06-20 16:38:30 -07006611 {
6612 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
6613 "Handle RX Data Frame fail within Handoff support module"));
6614 /* Do Not Drop packet at here
6615 * Revisit why HO module return fail
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05306616 * vos_pkt_return_packet(vosTempBuff);
6617 * vosTempBuff = vosDataBuff;
6618 * continue;
Jeff Johnson295189b2012-06-20 16:38:30 -07006619 */
6620 }
Dino Mycle3b9536d2014-07-09 22:05:24 +05306621#ifdef WLAN_FEATURE_LINK_LAYER_STATS
6622 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
6623 if ( NULL != pClientSTA)
6624 {
6625 tpSirMacMgmtHdr pMacHeader = WDA_GET_RX_MAC_HEADER( pvBDHeader );
Mahesh A Saptasagarbbdcf122014-10-28 20:57:11 +05306626 if (!IS_BROADCAST_ADD(pMacHeader->da) && IS_MULTICAST_ADD(pMacHeader->da))
Dino Mycle3b9536d2014-07-09 22:05:24 +05306627 {
6628 pClientSTA->interfaceStats.accessCategoryStats[ac].rxMcast++;
6629 }
6630
6631 WLANTL_HSGetDataRSSI(pvosGCtx, pvBDHeader, ucSTAId,
6632 &currentAvgRSSI);
6633 pClientSTA->interfaceStats.rssiData = currentAvgRSSI;
6634
6635 pClientSTA->interfaceStats.accessCategoryStats[ac].rxMpdu++;
6636 if (WDA_IS_RX_AN_AMPDU (pvBDHeader))
6637 {
6638 pClientSTA->interfaceStats.accessCategoryStats[ac].rxAmpdu++;
6639 }
6640 }
6641
6642
6643#endif
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05306644 vosStatus = WLANTL_ReadSNR(pvosGCtx, pvBDHeader, ucSTAId);
6645
6646 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
6647 {
6648 TLLOGW(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
6649 FL("Failed to Read SNR")));
6650 }
6651
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07006652 pfnSTAFsm( pvosGCtx, ucSTAId, &vosTempBuff, bForwardIAPPwithLLC);
Jeff Johnson295189b2012-06-20 16:38:30 -07006653 }
6654 else
6655 {
6656 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
6657 "WLAN TL:NULL state function, STA:%d, State: %d- dropping packet",
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306658 ucSTAId, pClientSTA->tlState));
Jeff Johnson295189b2012-06-20 16:38:30 -07006659 /* Drop packet */
6660 vos_pkt_return_packet(vosTempBuff);
6661 vosTempBuff = vosDataBuff;
6662 continue;
6663 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006664 }/* else data frame*/
6665
6666 vosTempBuff = vosDataBuff;
6667 }/*while chain*/
6668
6669 return VOS_STATUS_SUCCESS;
6670}/* WLANTL_RxFrames */
6671
Dino Mycle3b9536d2014-07-09 22:05:24 +05306672#ifdef WLAN_FEATURE_LINK_LAYER_STATS
6673/*==========================================================================
6674
6675 FUNCTION WLANTL_CollectInterfaceStats
6676
6677 DESCRIPTION
6678 Utility function used by TL to send the statitics
6679
6680 DEPENDENCIES
6681
6682
6683 PARAMETERS
6684
6685 IN
6686
6687 ucSTAId: station for which the statistics need to collected
6688
6689 vosDataBuff: it will contain the pointer to the corresponding
6690 structure
6691
6692 RETURN VALUE
6693 The result code associated with performing the operation
6694
6695 VOS_STATUS_E_INVAL: Input parameters are invalid
6696 VOS_STATUS_SUCCESS: Everything is good :)
6697
6698 SIDE EFFECTS
6699
6700============================================================================*/
6701VOS_STATUS
6702WLANTL_CollectInterfaceStats
6703(
6704 v_PVOID_t pvosGCtx,
6705 v_U8_t ucSTAId,
6706 WLANTL_InterfaceStatsType *vosDataBuff
6707)
6708{
6709 WLANTL_CbType* pTLCb = NULL;
6710 /*------------------------------------------------------------------------
6711 Sanity check
6712 ------------------------------------------------------------------------*/
6713 if ( WLANTL_STA_ID_INVALID( ucSTAId ) )
6714 {
6715 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6716 "WLAN TL:Invalid station id requested on WLANTL_CollectStats"));
6717 return VOS_STATUS_E_FAULT;
6718 }
6719 /*------------------------------------------------------------------------
6720 Extract TL control block
6721 ------------------------------------------------------------------------*/
6722 pTLCb = VOS_GET_TL_CB(pvosGCtx);
6723 if ( NULL == pTLCb )
6724 {
6725 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6726 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_CollectStats"));
6727 return VOS_STATUS_E_FAULT;
6728 }
6729
6730 if ( NULL == pTLCb->atlSTAClients[ucSTAId] )
6731 {
6732 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6733 "WLAN TL:Client Memory was not allocated on %s", __func__));
6734 return VOS_STATUS_E_FAILURE;
6735 }
Srinivas Dasari98947432014-11-07 19:41:24 +05306736 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
6737 "WLAN TL: collect WIFI_STATS_IFACE results"));
6738
Dino Mycle3b9536d2014-07-09 22:05:24 +05306739 vos_mem_copy(vosDataBuff, &pTLCb->atlSTAClients[ucSTAId]->interfaceStats,
6740 sizeof(WLANTL_InterfaceStatsType));
6741 return VOS_STATUS_SUCCESS;
6742}
6743
Srinivas Dasari98947432014-11-07 19:41:24 +05306744/*==========================================================================
6745
6746 FUNCTION WLANTL_ClearInterfaceStats
6747
6748 DESCRIPTION
6749 Utility function used by TL to clear the statitics
6750
6751 DEPENDENCIES
6752
6753
6754 PARAMETERS
6755
6756 IN
6757
6758 ucSTAId: station for which the statistics need to collected
6759
6760 RETURN VALUE
6761 The result code associated with performing the operation
6762
6763 VOS_STATUS_E_INVAL: Input parameters are invalid
6764 VOS_STATUS_SUCCESS: Everything is good :)
6765
6766 SIDE EFFECTS
6767
6768============================================================================*/
6769VOS_STATUS
6770WLANTL_ClearInterfaceStats
6771(
6772 v_PVOID_t pvosGCtx,
6773 v_U8_t ucSTAId,
6774 v_U8_t statsClearReqMask
6775)
6776{
6777 WLANTL_CbType* pTLCb = NULL;
6778 WLANTL_STAClientType* pClientSTA = NULL;
6779 /*------------------------------------------------------------------------
6780 Sanity check
6781 ------------------------------------------------------------------------*/
6782 if ( WLANTL_STA_ID_INVALID( ucSTAId ) )
6783 {
6784 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6785 "WLAN TL:Invalid station id requested on WLANTL_CollectStats"));
6786 return VOS_STATUS_E_FAULT;
6787 }
6788 /*------------------------------------------------------------------------
6789 Extract TL control block
6790 ------------------------------------------------------------------------*/
6791 pTLCb = VOS_GET_TL_CB(pvosGCtx);
6792 if ( NULL == pTLCb )
6793 {
6794 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
6795 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_CollectStats"));
6796 return VOS_STATUS_E_FAULT;
6797 }
6798
6799 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
6800 if ( NULL == pClientSTA )
6801 {
6802 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
6803 "WLAN TL:Client Memory was not allocated on %s", __func__));
6804 return VOS_STATUS_E_FAILURE;
6805 }
6806
6807 if ((statsClearReqMask & WIFI_STATS_IFACE_AC) ||
6808 (statsClearReqMask & WIFI_STATS_IFACE)) {
6809 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
6810 "WLAN TL:cleared WIFI_STATS_IFACE_AC results"));
6811 pClientSTA->interfaceStats.accessCategoryStats[0].rxMcast = 0;
6812 pClientSTA->interfaceStats.accessCategoryStats[1].rxMcast = 0;
6813 pClientSTA->interfaceStats.accessCategoryStats[2].rxMcast = 0;
6814 pClientSTA->interfaceStats.accessCategoryStats[3].rxMcast = 0;
6815
6816 pClientSTA->interfaceStats.accessCategoryStats[0].rxMpdu = 0;
6817 pClientSTA->interfaceStats.accessCategoryStats[1].rxMpdu = 0;
6818 pClientSTA->interfaceStats.accessCategoryStats[2].rxMpdu = 0;
6819 pClientSTA->interfaceStats.accessCategoryStats[3].rxMpdu = 0;
6820
6821 pClientSTA->interfaceStats.accessCategoryStats[0].rxAmpdu = 0;
6822 pClientSTA->interfaceStats.accessCategoryStats[1].rxAmpdu = 0;
6823 pClientSTA->interfaceStats.accessCategoryStats[2].rxAmpdu = 0;
6824 pClientSTA->interfaceStats.accessCategoryStats[3].rxAmpdu = 0;
6825 }
6826
6827 if (statsClearReqMask & WIFI_STATS_IFACE) {
6828 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
6829 "WLAN TL:cleared WIFI_STATS_IFACE results"));
6830 pClientSTA->interfaceStats.mgmtRx = 0;
6831 pClientSTA->interfaceStats.rssiData = 0;
6832 return VOS_STATUS_SUCCESS;
6833 }
6834
6835 return VOS_STATUS_SUCCESS;
6836}
6837
Dino Mycle3b9536d2014-07-09 22:05:24 +05306838#endif /* WLAN_FEATURE_LINK_LAYER_STATS */
Jeff Johnson295189b2012-06-20 16:38:30 -07006839
6840/*==========================================================================
6841
6842 FUNCTION WLANTL_RxCachedFrames
6843
6844 DESCRIPTION
6845 Utility function used by TL to forward the cached frames to a particular
6846 station;
6847
6848 DEPENDENCIES
6849 TL must be initiailized before this function gets called.
6850 If the frame carried is a data frame then the station for which it is
6851 destined to must have been previously registered with TL.
6852
6853 PARAMETERS
6854
6855 IN
6856 pTLCb: pointer to TL handle
6857
6858 ucSTAId: station for which we need to forward the packets
6859
6860 vosDataBuff: it will contain a pointer to the first cached buffer
6861 received, if there is more then one packet they will be
6862 chained using vOSS buffers.
6863
6864 RETURN VALUE
6865 The result code associated with performing the operation
6866
6867 VOS_STATUS_E_INVAL: Input parameters are invalid
6868 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
6869 page fault
6870 VOS_STATUS_SUCCESS: Everything is good :)
6871
6872 SIDE EFFECTS
6873
6874============================================================================*/
6875VOS_STATUS
6876WLANTL_RxCachedFrames
6877(
6878 WLANTL_CbType* pTLCb,
6879 v_U8_t ucSTAId,
6880 vos_pkt_t* vosDataBuff
6881)
6882{
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306883 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07006884 WLANTL_STAFuncType pfnSTAFsm;
6885 vos_pkt_t* vosTempBuff;
6886 VOS_STATUS vosStatus;
6887 v_PVOID_t pvBDHeader = NULL;
6888 WLANTL_STAEventType wSTAEvent = WLANTL_RX_EVENT;
6889 v_U8_t ucTid = 0;
6890 v_BOOL_t broadcast = VOS_FALSE;
6891 v_BOOL_t bSigMatch = VOS_FALSE;
6892 v_BOOL_t selfBcastLoopback = VOS_FALSE;
Madan Mohan Koyyalamudidfd6aa82012-10-18 20:18:43 -07006893 static v_U8_t first_data_pkt_arrived;
Jeff Johnson295189b2012-06-20 16:38:30 -07006894 v_U32_t uDPUSig;
6895 v_U8_t ucUcastSig;
6896 v_U8_t ucBcastSig;
6897 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
6898
6899 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
6900 "WLAN TL:TL Receive Cached Frames called"));
6901
6902 /*------------------------------------------------------------------------
6903 Sanity check
6904 ------------------------------------------------------------------------*/
6905 if ( NULL == vosDataBuff )
6906 {
6907 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6908 "WLAN TL:Invalid parameter sent on WLANTL_RxFrames"));
6909 return VOS_STATUS_E_INVAL;
6910 }
6911
Mihir Sheteae6f02b2014-04-11 19:49:21 +05306912 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
6913
6914 if ( NULL == pClientSTA )
6915 {
6916 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6917 "WLAN TL:Client Memory was not allocated on %s", __func__));
6918 return VOS_STATUS_E_FAILURE;
6919 }
6920
6921 MTRACE(vos_trace(VOS_MODULE_ID_TL, TRACE_CODE_TL_FORWARD_CACHED_FRAMES,
6922 ucSTAId, 1<<16 | pClientSTA->tlCacheInfo.cacheSize));
6923
Jeff Johnson295189b2012-06-20 16:38:30 -07006924 /*---------------------------------------------------------------------
6925 Save the initial buffer - this is the first received buffer
6926 ---------------------------------------------------------------------*/
6927 vosTempBuff = vosDataBuff;
6928
6929 while ( NULL != vosTempBuff )
6930 {
Madan Mohan Koyyalamudia148e1e2012-11-30 14:52:59 -08006931 broadcast = VOS_FALSE;
6932 selfBcastLoopback = VOS_FALSE;
6933
Jeff Johnson295189b2012-06-20 16:38:30 -07006934 vos_pkt_walk_packet_chain( vosDataBuff, &vosDataBuff, 1/*true*/ );
6935
6936 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
6937 "WLAN TL:Sending new cached packet to station %d", ucSTAId));
6938 /*---------------------------------------------------------------------
6939 Peek at BD header - do not remove
6940 !!! Optimize me: only part of header is needed; not entire one
6941 ---------------------------------------------------------------------*/
6942 vosStatus = WDA_DS_PeekRxPacketInfo( vosTempBuff, (v_PVOID_t)&pvBDHeader, 0 );
6943
6944 if ( NULL == pvBDHeader )
6945 {
6946 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6947 "WLAN TL:Cannot extract BD header"));
6948 /* Drop packet */
6949 vos_pkt_return_packet(vosTempBuff);
6950 vosTempBuff = vosDataBuff;
6951 continue;
6952 }
6953
6954 uDPUSig = WDA_GET_RX_DPUSIG( pvBDHeader );
6955
6956 /* AMSDU HW bug fix
6957 * After 2nd AMSDU subframe HW could not handle BD correctly
6958 * HAL workaround is needed */
6959 if(WDA_GET_RX_ASF(pvBDHeader))
6960 {
6961 WDA_DS_RxAmsduBdFix(vos_get_global_context(VOS_MODULE_ID_TL,pTLCb),
6962 pvBDHeader);
6963 }
6964
6965 ucTid = (v_U8_t)WDA_GET_RX_TID( pvBDHeader );
6966
6967 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
6968 "WLAN TL:Data packet cached for STA %d", ucSTAId);
6969
6970 /*------------------------------------------------------------------
6971 This should be corrected when multipe sta support is added !!!
6972 for now bcast frames will be sent to the last registered STA
6973 ------------------------------------------------------------------*/
6974 if ( WDA_IS_RX_BCAST(pvBDHeader))
6975 {
6976 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
6977 "WLAN TL:TL rx Bcast frame "));
6978 broadcast = VOS_TRUE;
6979
6980 /* If Addr1 is b/mcast, but Addr3 is our own self MAC, it is a b/mcast
6981 * pkt we sent looping back to us. To be dropped if we are non BTAMP
6982 */
6983 if( WLANHAL_RX_BD_ADDR3_SELF_IDX ==
6984 (v_U8_t)WDA_GET_RX_ADDR3_IDX( pvBDHeader ))
6985 {
6986 selfBcastLoopback = VOS_TRUE;
6987 }
6988 }/*if bcast*/
6989
6990 /*-------------------------------------------------------------------------
6991 Check if the packet that we cached matches the DPU signature of the
6992 newly added station
6993 -------------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306994 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
6995
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306996 if ( NULL == pClientSTA )
6997 {
6998 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6999 "WLAN TL:Client Memory was not allocated on %s", __func__));
7000 return VOS_STATUS_E_FAILURE;
7001 }
7002
Jeff Johnson295189b2012-06-20 16:38:30 -07007003 if ( broadcast )
7004 {
7005 ucBcastSig = (v_U8_t)uDPUSig;
7006 bSigMatch = (( WLAN_TL_INVALID_B_SIG !=
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307007 pClientSTA->wSTADesc.ucBcastSig ) &&
7008 ( ucBcastSig == pClientSTA->wSTADesc.ucBcastSig ));
Jeff Johnson295189b2012-06-20 16:38:30 -07007009 }
7010 else
7011 {
7012 ucUcastSig = (v_U8_t)uDPUSig;
7013 bSigMatch = (( WLAN_TL_INVALID_U_SIG !=
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307014 pClientSTA->wSTADesc.ucUcastSig ) &&
7015 ( ucUcastSig == pClientSTA->wSTADesc.ucUcastSig ));
Jeff Johnson295189b2012-06-20 16:38:30 -07007016 }
7017
7018 /*-------------------------------------------------------------------------
7019 If the packet doesn't match - drop it
7020 -------------------------------------------------------------------------*/
7021 if ( !bSigMatch )
7022 {
Rajesh Chauhana6b08f42013-06-18 19:01:26 -07007023 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_MED,
Jeff Johnson295189b2012-06-20 16:38:30 -07007024 "WLAN TL: Cached packet does not match DPU Sig of the new STA - drop "
7025 " DPU Sig %d UC %d BC %d B %d",
7026 uDPUSig,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307027 pClientSTA->wSTADesc.ucUcastSig,
Rajesh Chauhana6b08f42013-06-18 19:01:26 -07007028 pClientSTA->wSTADesc.ucBcastSig,
Jeff Johnson295189b2012-06-20 16:38:30 -07007029 broadcast));
7030
7031 /* Drop packet */
7032 vos_pkt_return_packet(vosTempBuff);
7033 vosTempBuff = vosDataBuff;
7034 continue;
7035
7036 }/*if signature mismatch*/
7037
7038 /*------------------------------------------------------------------------
7039 Check if BT-AMP frame:
7040 - additional processing needed in this case to separate BT-AMP date
7041 from BT-AMP Ctrl path
7042 ------------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307043 if ( WLAN_STA_BT_AMP == pClientSTA->wSTADesc.wSTAType )
Jeff Johnson295189b2012-06-20 16:38:30 -07007044 {
7045 /*--------------------------------------------------------------------
7046 Process the ctrl BAP frame; if data it will return false and it
7047 will be routed through the regular data path
7048 --------------------------------------------------------------------*/
7049 if ( WLANTL_ProcessBAPFrame( pvBDHeader,
7050 vosTempBuff,
7051 pTLCb,
7052 &first_data_pkt_arrived,
7053 ucSTAId))
7054 {
7055 vosTempBuff = vosDataBuff;
7056 continue;
7057 }
7058 }/*if BT-AMP station*/
7059 else if(selfBcastLoopback == VOS_TRUE)
7060 {
7061 /* Drop packet */
7062 vos_pkt_return_packet(vosTempBuff);
7063 vosTempBuff = vosDataBuff;
7064 continue;
7065 }
7066
7067 /*---------------------------------------------------------------------
7068 Data packet received, send to state machine
7069 ---------------------------------------------------------------------*/
7070 wSTAEvent = WLANTL_RX_EVENT;
7071
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307072 pfnSTAFsm = tlSTAFsm[pClientSTA->tlState].
Jeff Johnson295189b2012-06-20 16:38:30 -07007073 pfnSTATbl[wSTAEvent];
7074
7075 if ( NULL != pfnSTAFsm )
7076 {
7077#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
7078 /* Read RSSI and update */
7079 vosStatus = WLANTL_HSHandleRXFrame(vos_get_global_context(
7080 VOS_MODULE_ID_TL,pTLCb),
7081 WLANTL_DATA_FRAME_TYPE,
7082 pvBDHeader,
7083 ucSTAId,
7084 broadcast,
7085 vosTempBuff);
7086 broadcast = VOS_FALSE;
7087#else
7088 vosStatus = WLANTL_ReadRSSI(vos_get_global_context(VOS_MODULE_ID_TL,pTLCb), pvBDHeader, ucSTAId);
Kiet Lam47325522014-03-10 11:50:46 -07007089#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007090 if(!VOS_IS_STATUS_SUCCESS(vosStatus))
7091 {
7092 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7093 "Handle RX Data Frame fail within Handoff support module"));
7094 /* Do Not Drop packet at here
7095 * Revisit why HO module return fail
7096 vos_pkt_return_packet(vosTempBuff);
7097 vosTempBuff = vosDataBuff;
7098 continue;
7099 */
7100 }
7101 pfnSTAFsm( vos_get_global_context(VOS_MODULE_ID_TL,pTLCb), ucSTAId,
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07007102 &vosTempBuff, VOS_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07007103 }
7104 else
7105 {
7106 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7107 "WLAN TL:NULL state function, STA:%d, State: %d- dropping packet",
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307108 ucSTAId, pClientSTA->tlState));
Jeff Johnson295189b2012-06-20 16:38:30 -07007109 /* Drop packet */
7110 vos_pkt_return_packet(vosTempBuff);
7111 vosTempBuff = vosDataBuff;
7112 continue;
7113 }
7114
7115 vosTempBuff = vosDataBuff;
7116 }/*while chain*/
7117
7118 return VOS_STATUS_SUCCESS;
7119}/* WLANTL_RxCachedFrames */
7120
Sravan Kumar Kairam091e5b62017-01-23 14:14:20 +05307121/**
7122 * WLANTL_ForwardPkts() - forward cached eapol frames
7123 * @pvosGCtx: pointer to vos global context
7124 * @data: value to indicate either forward or flush
7125 *
7126 * Return: None
7127 *
7128 */
7129static VOS_STATUS WLANTL_ForwardPkts(void* pvosGCtx, uint32_t data)
7130{
7131 WLANTL_CbType* pTLCb = NULL;
7132
7133 pTLCb = VOS_GET_TL_CB(pvosGCtx);
7134 if (NULL == pTLCb) {
7135 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7136 "%s: Invalid input pointer", __func__));
7137 return VOS_STATUS_E_FAULT;
7138 }
7139
7140 if (!data) {
7141 TLLOG2(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
7142 "%s: Pre assoc fail flush cache", __func__));
7143 WLANTL_FlushCachedFrames(pTLCb->vosEapolCachedFrame);
7144 goto done;
7145 }
7146
7147 /* forward packets to HDD */
7148 if (NULL != pTLCb->vosEapolCachedFrame) {
7149 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
7150 "%s: forward pre assoc cached frames", __func__));
7151 WLANTL_MonTranslate80211To8023Header(pTLCb->vosEapolCachedFrame, pTLCb);
7152 pTLCb->pfnEapolFwd(pvosGCtx, pTLCb->vosEapolCachedFrame);
7153 }
7154
7155done:
7156 pTLCb->vosEapolCachedFrame = NULL;
7157 pTLCb->preassoc_caching = false;
7158
7159 return VOS_STATUS_SUCCESS;
7160}
7161
Jeff Johnson295189b2012-06-20 16:38:30 -07007162/*==========================================================================
Katya Nigam664f5032014-05-05 12:24:32 +05307163 FUNCTION WLANTL_RxProcessMsg
7164
7165 DESCRIPTION
7166 Called by VOSS when a message was serialized for TL through the
7167 rx thread/task.
7168
7169 DEPENDENCIES
7170 The TL must be initialized before this function can be called.
7171
7172 PARAMETERS
7173
7174 IN
7175 pvosGCtx: pointer to the global vos context; a handle to TL's
7176 control block can be extracted from its context
7177 message: type and content of the message
7178
7179
7180 RETURN VALUE
7181 The result code associated with performing the operation
7182
7183 VOS_STATUS_E_INVAL: invalid input parameters
7184 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
7185 page fault
7186 VOS_STATUS_SUCCESS: Everything is good :)
7187
7188 Other values can be returned as a result of a function call, please check
7189 corresponding API for more info.
7190 SIDE EFFECTS
7191
7192============================================================================*/
7193VOS_STATUS
7194WLANTL_RxProcessMsg
7195(
7196 v_PVOID_t pvosGCtx,
7197 vos_msg_t* message
7198)
7199{
7200 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
7201 v_U32_t uData;
7202 v_U8_t ucSTAId;
7203 v_U8_t ucUcastSig;
7204 v_U8_t ucBcastSig;
7205
7206 /*------------------------------------------------------------------------
7207 Sanity check
7208 ------------------------------------------------------------------------*/
7209 if ( NULL == message )
7210 {
7211 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7212 "WLAN TL:Invalid parameter sent on WLANTL_RxProcessMessage"));
7213 return VOS_STATUS_E_INVAL;
7214 }
7215
7216 /*------------------------------------------------------------------------
7217 Process message
7218 ------------------------------------------------------------------------*/
7219 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
7220 "WLAN TL:Received message: %d through rx flow", message->type));
7221
7222 switch( message->type )
7223 {
7224
7225 case WLANTL_RX_FWD_CACHED:
7226 /*---------------------------------------------------------------------
7227 The data sent with the message has the following structure:
7228 | 00 | ucBcastSignature | ucUcastSignature | ucSTAID |
7229 each field above is one byte
7230 ---------------------------------------------------------------------*/
7231 uData = message->bodyval;
7232 ucSTAId = ( uData & 0x000000FF);
7233 ucUcastSig = ( uData & 0x0000FF00)>>8;
7234 ucBcastSig = (v_U8_t)(( uData & 0x00FF0000)>>16);
7235 vosStatus = WLANTL_ForwardSTAFrames( pvosGCtx, ucSTAId,
7236 ucUcastSig, ucBcastSig);
7237 break;
7238
Sravan Kumar Kairam091e5b62017-01-23 14:14:20 +05307239 case WLANTL_RX_FWD_PRE_ASSOC_CACHED:
7240 uData = message->bodyval;
7241 vosStatus = WLANTL_ForwardPkts(pvosGCtx, uData);
7242 break;
7243
Katya Nigam664f5032014-05-05 12:24:32 +05307244 default:
7245 /*no processing for now*/
7246 break;
7247 }
7248
7249 return VOS_STATUS_SUCCESS;
7250}
7251
7252
7253/*==========================================================================
Jeff Johnson295189b2012-06-20 16:38:30 -07007254 FUNCTION WLANTL_ResourceCB
7255
7256 DESCRIPTION
7257 Called by the TL when it has packets available for transmission.
7258
7259 DEPENDENCIES
7260 The TL must be registered with BAL before this function can be called.
7261
7262 PARAMETERS
7263
7264 IN
7265 pvosGCtx: pointer to the global vos context; a handle to TL's
7266 or BAL's control block can be extracted from its context
7267
7268 RETURN VALUE
7269 The result code associated with performing the operation
7270
7271 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
7272 page fault
7273 VOS_STATUS_SUCCESS: Everything is good :)
7274
7275 SIDE EFFECTS
7276
7277============================================================================*/
7278VOS_STATUS
7279WLANTL_ResourceCB
7280(
7281 v_PVOID_t pvosGCtx,
7282 v_U32_t uCount
7283)
7284{
7285 WLANTL_CbType* pTLCb = NULL;
7286 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
7287
7288 /*------------------------------------------------------------------------
7289 Sanity check
7290 Extract TL control block
7291 ------------------------------------------------------------------------*/
7292 pTLCb = VOS_GET_TL_CB(pvosGCtx);
7293 if ( NULL == pTLCb )
7294 {
7295 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7296 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_ChangeSTAState"));
7297 return VOS_STATUS_E_FAULT;
7298 }
7299
7300 pTLCb->uResCount = uCount;
7301
7302
7303 /*-----------------------------------------------------------------------
7304 Resume Tx if enough res and not suspended
7305 -----------------------------------------------------------------------*/
7306 if (( pTLCb->uResCount >= WDA_TLI_MIN_RES_MF ) &&
7307 ( 0 == pTLCb->ucTxSuspended ))
7308 {
7309 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
7310 "WLAN TL:Issuing Xmit start request to BAL for avail res ASYNC"));
7311 return WDA_DS_StartXmit(pvosGCtx);
7312 }
7313
7314 return VOS_STATUS_SUCCESS;
7315}/* WLANTL_ResourceCB */
7316
7317
Gopichand Nakkala11acd112012-12-31 16:04:04 -08007318/*==========================================================================
7319 FUNCTION WLANTL_IsTxXmitPending
7320
7321 DESCRIPTION
7322 Called by the WDA when it wants to know whether WDA_DS_TX_START_XMIT msg
7323 is pending in TL msg queue
7324
7325 DEPENDENCIES
7326 The TL must be registered with WDA before this function can be called.
7327
7328 PARAMETERS
7329
7330 IN
7331 pvosGCtx: pointer to the global vos context; a handle to TL's
7332 or WDA's control block can be extracted from its context
7333
7334 RETURN VALUE
7335 The result code associated with performing the operation
7336
7337 0: No WDA_DS_TX_START_XMIT msg pending
7338 1: Msg WDA_DS_TX_START_XMIT already pending in TL msg queue
7339
7340 SIDE EFFECTS
7341
7342============================================================================*/
7343v_BOOL_t
7344WLANTL_IsTxXmitPending
7345(
7346 v_PVOID_t pvosGCtx
7347)
7348{
7349
7350 WLANTL_CbType* pTLCb = NULL;
7351 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
7352
7353 /*------------------------------------------------------------------------
7354 Sanity check
7355 Extract TL control block
7356 ------------------------------------------------------------------------*/
7357 pTLCb = VOS_GET_TL_CB(pvosGCtx);
7358 if ( NULL == pTLCb )
7359 {
7360 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_FATAL,
7361 "WLAN TL:Invalid TL pointer from pvosGCtx in WLANTL_IsTxXmitPending "));
7362 return FALSE;
7363 }
7364
7365 return pTLCb->isTxTranmitMsgPending;
7366
7367}/*WLANTL_IsTxXmitPending */
7368
7369/*==========================================================================
7370 FUNCTION WLANTL_SetTxXmitPending
7371
7372 DESCRIPTION
7373 Called by the WDA when it wants to indicate that WDA_DS_TX_START_XMIT msg
7374 is pending in TL msg queue
7375
7376 DEPENDENCIES
7377 The TL must be registered with WDA before this function can be called.
7378
7379 PARAMETERS
7380
7381 IN
7382 pvosGCtx: pointer to the global vos context; a handle to TL's
7383 or WDA's control block can be extracted from its context
7384
7385 RETURN VALUE None
7386
7387 SIDE EFFECTS
7388
7389============================================================================*/
7390
7391v_VOID_t
7392WLANTL_SetTxXmitPending
7393(
7394 v_PVOID_t pvosGCtx
7395)
7396{
7397
7398 WLANTL_CbType* pTLCb = NULL;
7399 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
7400
7401 /*------------------------------------------------------------------------
7402 Sanity check
7403 Extract TL control block
7404 ------------------------------------------------------------------------*/
7405 pTLCb = VOS_GET_TL_CB(pvosGCtx);
7406 if ( NULL == pTLCb )
7407 {
7408 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_FATAL,
7409 "WLAN TL:Invalid TL pointer from pvosGCtx in WLANTL_SetTxXmitPending"));
7410 return;
7411 }
7412
7413 pTLCb->isTxTranmitMsgPending = 1;
7414 return;
7415
7416}/*WLANTL_SetTxXmitPending */
7417
7418/*==========================================================================
7419 FUNCTION WLANTL_ClearTxXmitPending
7420
7421 DESCRIPTION
7422 Called by the WDA when it wants to indicate that no WDA_DS_TX_START_XMIT msg
7423 is pending in TL msg queue
7424
7425 DEPENDENCIES
7426 The TL must be registered with WDA before this function can be called.
7427
7428 PARAMETERS
7429
7430 IN
7431 pvosGCtx: pointer to the global vos context; a handle to TL's
7432 or WDA's control block can be extracted from its context
7433
7434 RETURN VALUE None
7435
7436 SIDE EFFECTS
7437
7438============================================================================*/
7439
7440v_VOID_t
7441WLANTL_ClearTxXmitPending
7442(
7443 v_PVOID_t pvosGCtx
7444)
7445{
7446
7447 WLANTL_CbType* pTLCb = NULL;
7448 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
7449
7450 /*------------------------------------------------------------------------
7451 Sanity check
7452 Extract TL control block
7453 ------------------------------------------------------------------------*/
7454 pTLCb = VOS_GET_TL_CB(pvosGCtx);
7455 if ( NULL == pTLCb )
7456 {
7457 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_FATAL,
7458 "WLAN TL:Invalid TL pointer from pvosGCtx in WLANTL_ClearTxXmitPending "));
7459 return;
7460 }
7461
7462 pTLCb->isTxTranmitMsgPending = 0;
7463 return;
7464}/*WLANTL_ClearTxXmitPending */
7465
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307466/*==========================================================================
7467 FUNCTION WLANTL_TxThreadDebugHandler
7468
7469 DESCRIPTION
7470 Printing TL Snapshot dump, processed under TxThread context, currently
7471 information regarding the global TlCb struture. Dumps information related
7472 to per active STA connection currently in use by TL.
7473
7474 DEPENDENCIES
7475 The TL must be initialized before this gets called.
7476
7477 PARAMETERS
7478
7479 IN
7480 pvosGCtx: pointer to the global vos context; a handle to TL's
7481 or WDA's control block can be extracted from its context
7482
7483 RETURN VALUE None
7484
7485 SIDE EFFECTS
7486
7487============================================================================*/
7488
7489v_VOID_t
7490WLANTL_TxThreadDebugHandler
7491(
7492 v_PVOID_t *pVosContext
7493)
7494{
7495 WLANTL_CbType* pTLCb = NULL;
7496 WLANTL_STAClientType* pClientSTA = NULL;
7497 int i = 0;
Mihir Shete5d148f12014-12-16 17:54:49 +05307498 v_U8_t uFlowMask; // TX FlowMask from WDA
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307499
7500 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_FATAL,
7501 "WLAN TL: %s Enter ", __func__));
7502
7503 pTLCb = VOS_GET_TL_CB(pVosContext);
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307504
7505 if ( NULL == pVosContext || NULL == pTLCb )
7506 {
7507 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7508 "Global VoS Context or TL Context are NULL"));
7509 return;
7510 }
7511
Mihir Shete5d148f12014-12-16 17:54:49 +05307512 if (VOS_STATUS_SUCCESS == WDA_DS_GetTxFlowMask(pVosContext, &uFlowMask))
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307513 {
7514 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Mihir Shete5d148f12014-12-16 17:54:49 +05307515 "WDA uTxFlowMask: 0x%x", uFlowMask));
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307516 }
Mihir Shete5d148f12014-12-16 17:54:49 +05307517
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307518 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7519 "************************TL DUMP INFORMATION**************"));
7520
7521 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7522 "uDelayedTriggerFrmInt:%d\tuMinFramesProcThres:%d",
7523 pTLCb->tlConfigInfo.uDelayedTriggerFrmInt,
7524 pTLCb->tlConfigInfo.uMinFramesProcThres));
7525
7526 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7527 "Management Frame Client exists: %d",
7528 pTLCb->tlMgmtFrmClient.ucExists));
7529 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7530 "usPendingTxCompleteCount: %d\tucTxSuspended: %d",
7531 pTLCb->usPendingTxCompleteCount,
7532 pTLCb->ucTxSuspended));
7533
7534 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7535 "uResCount: %d", pTLCb->uResCount));
7536
7537 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7538 "ucRegisteredStaId: %d\tucCurrentSTA: %d",
7539 pTLCb->ucRegisteredStaId, pTLCb->ucCurrentSTA));
7540
7541 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7542 "UrgentFrameProcessing: %s\tuFramesProcThres: %d",
7543 (pTLCb->bUrgent?"True":"False"), pTLCb->uFramesProcThres));
7544
7545 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7546 "isTxTranmitMsgPending: %d\t isBMPS: %s",
7547 pTLCb->isTxTranmitMsgPending, pTLCb->isBMPS?"True":"False"));
7548
7549#ifdef FEATURE_WLAN_TDLS
7550 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7551 "TDLS Peer Count: %d", pTLCb->ucTdlsPeerCount));
7552#endif
7553
Mukul Sharma252582d2015-10-23 16:47:36 +05307554 TLLOG1(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307555 "++++++++++++++++++++Registerd Client Information++++++++++"));
7556
7557 for ( i =0; i<WLAN_MAX_STA_COUNT; i++ )
7558 {
7559 pClientSTA = pTLCb->atlSTAClients[i];
7560 if( NULL == pClientSTA || 0 == pClientSTA->ucExists)
7561 {
7562 continue;
7563 }
7564
Mukul Sharma252582d2015-10-23 16:47:36 +05307565 TLLOG1(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307566 "######################STA Index: %d ############################",i));
Mukul Sharma252582d2015-10-23 16:47:36 +05307567 TLLOG1(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO, "WLAN_STADescType:"));
7568 TLLOG1(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307569 "STAId: %d\t STA MAC Address: %pM", pClientSTA->wSTADesc.ucSTAId,
7570 pClientSTA->wSTADesc.vSTAMACAddress.bytes));
Mukul Sharma252582d2015-10-23 16:47:36 +05307571 TLLOG1(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307572 "STA Type: %d\tProtectedFrame: %d",
7573 pClientSTA->wSTADesc.wSTAType, pClientSTA->wSTADesc.ucProtectedFrame));
Mukul Sharma252582d2015-10-23 16:47:36 +05307574 TLLOG1(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307575 "QoS: %d\tRxFrameTrans: %d\tTxFrameTrans: %d",
7576 pClientSTA->wSTADesc.ucQosEnabled, pClientSTA->wSTADesc.ucSwFrameRXXlation,
7577 pClientSTA->wSTADesc.ucSwFrameTXXlation));
Mukul Sharma252582d2015-10-23 16:47:36 +05307578 TLLOG1(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307579 "ucUcastSig: %d\tucBcastSig: %d", pClientSTA->wSTADesc.ucUcastSig,
7580 pClientSTA->wSTADesc.ucBcastSig));
7581
Mukul Sharma252582d2015-10-23 16:47:36 +05307582 TLLOG1(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307583 "ClientIndex: %d\t Exists: %d", i, pClientSTA->ucExists));
Mukul Sharma252582d2015-10-23 16:47:36 +05307584 TLLOG1(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307585 "TL State: %d\t TL Priority: %d", pClientSTA->tlState,
7586 pClientSTA->tlPri));
Mukul Sharma252582d2015-10-23 16:47:36 +05307587 TLLOG1(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307588 "ucTxSuspended: %d\tucPktPending: %d", pClientSTA->ucTxSuspended,
7589 pClientSTA->ucPktPending));
Mukul Sharma252582d2015-10-23 16:47:36 +05307590 TLLOG1(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307591 "ucEAPOLPktPending: %d\tucNoMoreData: %d",
7592 pClientSTA->ucEapolPktPending, pClientSTA->ucNoMoreData));
Mukul Sharma252582d2015-10-23 16:47:36 +05307593 TLLOG1(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Katya Nigam63902932014-06-26 19:04:23 +05307594 "enableCaching: %d\t fcStaTxDisabled: %d", pClientSTA->enableCaching,
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307595 pClientSTA->fcStaTxDisabled));
Mukul Sharma252582d2015-10-23 16:47:36 +05307596 TLLOG1(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307597 "ucCurrentAC: %d\tucServicedAC: %d", pClientSTA->ucCurrentAC,
7598 pClientSTA->ucServicedAC));
Mukul Sharma252582d2015-10-23 16:47:36 +05307599 TLLOG1(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307600 "TID: %d\tautTxCount[0]: %d\tauRxCount[0]: %d",0, pClientSTA->auTxCount[0],
7601 pClientSTA->auRxCount[0]));
Mukul Sharma252582d2015-10-23 16:47:36 +05307602 TLLOG1(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307603 "aucAcMask[0]: %d\taucAcMask[1]: %d\taucAcMask[2]: %d\taucAcMask[3]: %d\t",
7604 pClientSTA->aucACMask[0], pClientSTA->aucACMask[1],
7605 pClientSTA->aucACMask[2], pClientSTA->aucACMask[3]));
7606 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Mukul Sharma252582d2015-10-23 16:47:36 +05307607
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307608 "ucCurrentWeight: %d", pClientSTA->ucCurrentWeight));
7609
7610 if( WLAN_STA_SOFTAP == pClientSTA->wSTADesc.wSTAType)
7611 {
mukul sharma2cdb8ea2015-10-01 14:53:38 +05307612 TLLOG1(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307613 "TrafficStatistics for SOFTAP Station:"));
mukul sharma2cdb8ea2015-10-01 14:53:38 +05307614 TLLOG1(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307615 "RUF=%d\tRMF=%d\tRBF=%d", pClientSTA->trafficStatistics.rxUCFcnt,
7616 pClientSTA->trafficStatistics.rxMCFcnt,
7617 pClientSTA->trafficStatistics.rxBCFcnt));
mukul sharma2cdb8ea2015-10-01 14:53:38 +05307618 TLLOG1(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307619 "RUB=%d\tRMB=%d\tRBB=%d", pClientSTA->trafficStatistics.rxUCBcnt,
7620 pClientSTA->trafficStatistics.rxMCBcnt,
7621 pClientSTA->trafficStatistics.rxBCBcnt));
mukul sharma2cdb8ea2015-10-01 14:53:38 +05307622 TLLOG1(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307623 "TUF=%d\tTMF=%d\tTBF=%d", pClientSTA->trafficStatistics.txUCFcnt,
7624 pClientSTA->trafficStatistics.txMCFcnt,
7625 pClientSTA->trafficStatistics.txBCFcnt));
mukul sharma2cdb8ea2015-10-01 14:53:38 +05307626 TLLOG1(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307627 "TUB=%d\tTMB=%d\tTBB=%d", pClientSTA->trafficStatistics.txUCBcnt,
7628 pClientSTA->trafficStatistics.txMCBcnt,
7629 pClientSTA->trafficStatistics.txBCBcnt));
7630 }
mukul sharma2cdb8ea2015-10-01 14:53:38 +05307631
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307632 }
7633 return;
7634}
7635
7636/*==========================================================================
Mihir Shetefd62d9d2014-08-06 15:08:21 +05307637 FUNCTION WLANTL_FatalErrorHandler
7638
7639 DESCRIPTION
7640 Handle Fatal errors detected on the TX path.
7641 Currently issues SSR to recover from the error.
7642
7643 DEPENDENCIES
7644 The TL must be initialized before this gets called.
7645
7646 PARAMETERS
7647
7648 IN
7649 pvosGCtx: pointer to the global vos context; a handle to TL's
7650 or WDA's control block can be extracted from its context
7651
7652 RETURN VALUE None
7653
7654 SIDE EFFECTS
7655
7656============================================================================*/
7657v_VOID_t
7658WLANTL_FatalErrorHandler
7659(
7660 v_PVOID_t *pVosContext
7661)
7662{
7663
7664 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_FATAL,
7665 "WLAN TL: %s Enter ", __func__));
7666
7667 if ( NULL == pVosContext )
7668 {
7669 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7670 "%s: Global VoS Context or TL Context are NULL",
7671 __func__));
7672 return;
7673 }
7674
7675 /*
7676 * Issue SSR. vos_wlanRestart has tight checks to make sure that
7677 * we do not send an FIQ if previous FIQ is not processed
7678 */
7679 vos_wlanRestart();
7680}
7681
7682/*==========================================================================
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307683 FUNCTION WLANTL_TLDebugMessage
7684
7685 DESCRIPTION
7686 Post a TL Snapshot request, posts message in TxThread.
7687
7688 DEPENDENCIES
7689 The TL must be initialized before this gets called.
7690
7691 PARAMETERS
7692
7693 IN
7694 displaySnapshot Boolean showing whether to dump the snapshot or not.
7695
7696 RETURN VALUE None
7697
7698 SIDE EFFECTS
7699
7700============================================================================*/
7701
7702v_VOID_t
7703WLANTL_TLDebugMessage
7704(
Mihir Shete327c2ab2014-11-13 15:17:02 +05307705 v_U32_t debugFlags
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307706)
7707{
7708 vos_msg_t vosMsg;
7709 VOS_STATUS status;
7710
Mihir Shete327c2ab2014-11-13 15:17:02 +05307711 if(debugFlags & WLANTL_DEBUG_TX_SNAPSHOT)
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307712 {
7713 vosMsg.reserved = 0;
7714 vosMsg.bodyptr = NULL;
7715 vosMsg.type = WLANTL_TX_SNAPSHOT;
7716
7717 status = vos_tx_mq_serialize( VOS_MODULE_ID_TL, &vosMsg);
7718 if(status != VOS_STATUS_SUCCESS)
7719 {
7720 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR, "TX Msg Posting Failed with status: %d",status));
7721 return;
7722 }
7723 }
Mihir Shete327c2ab2014-11-13 15:17:02 +05307724 if (debugFlags & WLANTL_DEBUG_FW_CLEANUP)
7725 {
7726 vosMsg.reserved = 0;
7727 vosMsg.bodyptr = NULL;
7728 vosMsg.type = WLANTL_TX_FW_DEBUG;
7729
7730 status = vos_tx_mq_serialize( VOS_MODULE_ID_TL, &vosMsg);
7731 if(status != VOS_STATUS_SUCCESS)
7732 {
7733 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR, "TX Msg Posting Failed with status: %d",status));
7734 return;
7735 }
7736 }
Sravan Kumar Kairame9d186c2015-11-27 23:37:02 +05307737 if(debugFlags & WLANTL_DEBUG_KICKDXE)
7738 {
7739 vosMsg.reserved = 0;
7740 vosMsg.bodyptr = NULL;
7741 vosMsg.type = WLANTL_TX_KICKDXE;
7742
7743 status = vos_tx_mq_serialize( VOS_MODULE_ID_TL, &vosMsg);
7744 if(status != VOS_STATUS_SUCCESS)
7745 {
7746 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR, "TX Msg Posting Failed with status: %d",status));
7747 return;
7748 }
7749 }
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307750 return;
7751}
Jeff Johnson295189b2012-06-20 16:38:30 -07007752
Mihir Shetefd62d9d2014-08-06 15:08:21 +05307753/*==========================================================================
7754 FUNCTION WLANTL_FatalError
7755
7756 DESCRIPTION
7757 Fatal error reported in TX path, post an event to TX Thread for further
7758 handling
7759
7760 DEPENDENCIES
7761 The TL must be initialized before this gets called.
7762
7763 PARAMETERS
7764
7765 VOID
7766
7767 RETURN VALUE None
7768
7769 SIDE EFFECTS
7770
7771============================================================================*/
7772
7773v_VOID_t
7774WLANTL_FatalError
7775(
7776 v_VOID_t
7777)
7778{
7779 vos_msg_t vosMsg;
7780 VOS_STATUS status;
7781
7782 vosMsg.reserved = 0;
7783 vosMsg.bodyptr = NULL;
7784 vosMsg.type = WLANTL_TX_FATAL_ERROR;
7785
7786 status = vos_tx_mq_serialize( VOS_MODULE_ID_TL, &vosMsg);
7787 if(status != VOS_STATUS_SUCCESS)
7788 {
7789 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7790 "%s: TX Msg Posting Failed with status: %d",
7791 __func__,status));
7792 }
7793 return;
7794}
Jeff Johnson295189b2012-06-20 16:38:30 -07007795/*============================================================================
7796 TL STATE MACHINE
7797============================================================================*/
7798
7799/*==========================================================================
7800 FUNCTION WLANTL_STATxConn
7801
7802 DESCRIPTION
7803 Transmit in connected state - only EAPOL and WAI packets allowed
7804
7805 DEPENDENCIES
7806 The STA must be registered with TL before this function can be called.
7807
7808 PARAMETERS
7809
7810 IN
7811 pvosGCtx: pointer to the global vos context; a handle to TL's
7812 control block can be extracted from its context
7813 ucSTAId: identifier of the station being processed
7814 vosDataBuff: pointer to the tx vos buffer
7815
7816 RETURN VALUE
7817 The result code associated with performing the operation
7818
7819 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
7820 page fault
7821 VOS_STATUS_SUCCESS: Everything is good :)
7822
7823 Other return values are possible coming from the called functions.
7824 Please check API for additional info.
7825
7826 SIDE EFFECTS
7827
7828============================================================================*/
7829VOS_STATUS
7830WLANTL_STATxConn
7831(
7832 v_PVOID_t pvosGCtx,
7833 v_U8_t ucSTAId,
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07007834 vos_pkt_t** pvosDataBuff,
7835 v_BOOL_t bForwardIAPPwithLLC
Jeff Johnson295189b2012-06-20 16:38:30 -07007836)
7837{
7838 v_U16_t usPktLen;
7839 VOS_STATUS vosStatus;
7840 v_MACADDR_t vDestMacAddr;
7841 vos_pkt_t* vosDataBuff = NULL;
7842 WLANTL_CbType* pTLCb = NULL;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307843 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07007844 WLANTL_MetaInfoType tlMetaInfo;
7845 v_U8_t ucTypeSubtype = 0;
7846 v_U8_t ucTid;
7847 v_U8_t extraHeadSpace = 0;
7848 v_U8_t ucWDSEnabled = 0;
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07007849 v_U8_t ucAC, ucACMask, i;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05307850 v_U32_t txFlag = HAL_TX_NO_ENCRYPTION_MASK;
Jeff Johnson295189b2012-06-20 16:38:30 -07007851 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
7852
7853 /*------------------------------------------------------------------------
7854 Sanity check
7855 Extract TL control block
7856 ------------------------------------------------------------------------*/
7857 pTLCb = VOS_GET_TL_CB(pvosGCtx);
7858 if ( NULL == pTLCb )
7859 {
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07007860 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7861 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_STATxConn");
Jeff Johnson295189b2012-06-20 16:38:30 -07007862 *pvosDataBuff = NULL;
7863 return VOS_STATUS_E_FAULT;
7864 }
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307865 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
7866
7867 if ( NULL == pClientSTA )
7868 {
7869 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7870 "WLAN TL:Client Memory was not allocated on %s", __func__));
7871 return VOS_STATUS_E_FAILURE;
7872 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007873
7874 /*-------------------------------------------------------------------
7875 Disable AC temporary - if successfull retrieve re-enable
7876 The order is justified because of the possible scenario
7877 - TL tryes to fetch packet for AC and it returns NULL
7878 - TL analyzes the data it has received to see if there are
7879 any more pkts available for AC -> if not TL will disable AC
7880 - however it is possible that while analyzing results TL got
7881 preempted by a pending indication where the mask was again set
7882 TL will not check again and as a result when it resumes
7883 execution it will disable AC
7884 To prevent this the AC will be disabled here and if retrieve
7885 is successfull it will be re-enabled
7886 -------------------------------------------------------------------*/
7887
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07007888
7889 //LTI:pTLCb->atlSTAClients[ucSTAId].
7890 //LTI: aucACMask[pTLCb->atlSTAClients[ucSTAId].ucCurrentAC] = 0;
7891
7892 /*------------------------------------------------------------------------
7893 Fetch packet from HDD
7894 ------------------------------------------------------------------------*/
Sunil Ravid5406f22013-01-22 00:18:31 -08007895#ifdef FEATURE_WLAN_TDLS
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307896 if ((WLAN_STA_SOFTAP != pClientSTA->wSTADesc.wSTAType) &&
Agarwal Ashishcd86f7b2014-06-16 17:11:58 +05307897 !(vos_concurrent_open_sessions_running()) &&
Sunil Ravid5406f22013-01-22 00:18:31 -08007898 !pTLCb->ucTdlsPeerCount)
7899 {
7900#else
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307901 if ((WLAN_STA_SOFTAP != pClientSTA->wSTADesc.wSTAType) &&
Agarwal Ashishcd86f7b2014-06-16 17:11:58 +05307902 !(vos_concurrent_open_sessions_running()))
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07007903 {
Sunil Ravid5406f22013-01-22 00:18:31 -08007904#endif
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307905 ucAC = pClientSTA->ucCurrentAC;
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07007906
7907 /*-------------------------------------------------------------------
7908 Disable AC temporary - if successfull retrieve re-enable
7909 The order is justified because of the possible scenario
7910 - TL tryes to fetch packet for AC and it returns NULL
7911 - TL analyzes the data it has received to see if there are
7912 any more pkts available for AC -> if not TL will disable AC
7913 - however it is possible that while analyzing results TL got
7914 preempted by a pending indication where the mask was again set
7915 TL will not check again and as a result when it resumes
7916 execution it will disable AC
7917 To prevent this the AC will be disabled here and if retrieve
7918 is successfull it will be re-enabled
7919 -------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307920 pClientSTA->aucACMask[ucAC] = 0;
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07007921 }
7922 else
7923 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307924 //softap case
7925 ucAC = pTLCb->uCurServedAC;
7926 pClientSTA->aucACMask[ucAC] = 0;
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07007927 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007928
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307929 /*You make an initial assumption that HDD has no more data and if the
Jeff Johnson295189b2012-06-20 16:38:30 -07007930 assumption was wrong you reset the flags to their original state
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307931 This will prevent from exposing a race condition between checking with HDD
Jeff Johnson295189b2012-06-20 16:38:30 -07007932 for packets and setting the flags to false*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307933 //LTI: vos_atomic_set_U8( &pTLCb->atlSTAClients[ucSTAId].ucPktPending, 0);
7934 //LTI: pTLCb->atlSTAClients[ucSTAId].ucNoMoreData = 1;
7935 vos_atomic_set_U8( &pClientSTA->ucPktPending, 0);
7936 WLAN_TL_AC_ARRAY_2_MASK( pClientSTA, ucACMask, i);
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307937 /*You make an initial assumption that HDD has no more data and if the
7938 assumption was wrong you reset the flags to their original state
7939 This will prevent from exposing a race condition between checking with HDD
7940 for packets and setting the flags to false*/
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07007941 if ( 0 == ucACMask )
7942 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307943 pClientSTA->ucNoMoreData = 1;
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07007944 }
7945 else
7946 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307947 vos_atomic_set_U8( &pClientSTA->ucPktPending, 1);
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07007948 }
7949
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07007950
Madan Mohan Koyyalamudid93f4942012-10-05 15:05:40 -07007951 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07007952 "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 +05307953 ucAC, ucACMask, pClientSTA->ucPktPending);
Jeff Johnson295189b2012-06-20 16:38:30 -07007954
7955 /*------------------------------------------------------------------------
7956 Fetch tx packet from HDD
7957 ------------------------------------------------------------------------*/
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07007958
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307959 vosStatus = pClientSTA->pfnSTAFetchPkt( pvosGCtx,
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07007960 &ucSTAId,
7961 ucAC,
7962 &vosDataBuff, &tlMetaInfo );
Jeff Johnson295189b2012-06-20 16:38:30 -07007963
7964 if (( VOS_STATUS_SUCCESS != vosStatus ) || ( NULL == vosDataBuff ))
7965 {
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07007966 TLLOG1(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -07007967 "WLAN TL:No more data at HDD status %d", vosStatus));
7968 *pvosDataBuff = NULL;
7969
7970 /*--------------------------------------------------------------------
7971 Reset AC for the serviced station to the highest priority AC
7972 -> due to no more data at the station
7973 Even if this AC is not supported by the station, correction will be
7974 made in the main TL loop
7975 --------------------------------------------------------------------*/
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05307976 pClientSTA->ucCurrentAC = WLANTL_AC_HIGH_PRIO;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307977 pClientSTA->ucCurrentWeight = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07007978
Madan Mohan Koyyalamudid8000342012-11-08 14:55:26 -08007979 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07007980 "WLAN TL: WLANTL_STATxConn no more packets in HDD for AC: %d AC Mask: %d",
7981 ucAC, ucACMask);
7982
Jeff Johnson295189b2012-06-20 16:38:30 -07007983 return vosStatus;
7984 }
7985
7986 /*There are still packets in HDD - set back the pending packets and
7987 the no more data assumption*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307988 vos_atomic_set_U8( &pClientSTA->ucPktPending, 1);
7989 pClientSTA->ucNoMoreData = 0;
7990 pClientSTA->aucACMask[ucAC] = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07007991
Jeff Johnson295189b2012-06-20 16:38:30 -07007992#ifdef WLAN_PERF
7993 vos_pkt_set_user_data_ptr( vosDataBuff, VOS_PKT_USER_DATA_ID_BAL,
7994 (v_PVOID_t)0);
7995
7996#endif /*WLAN_PERF*/
7997
7998
7999#ifdef FEATURE_WLAN_WAPI
8000 /*------------------------------------------------------------------------
8001 If the packet is neither an Eapol packet nor a WAI packet then drop it
8002 ------------------------------------------------------------------------*/
8003 if ( 0 == tlMetaInfo.ucIsEapol && 0 == tlMetaInfo.ucIsWai )
8004 {
Madan Mohan Koyyalamudid93f4942012-10-05 15:05:40 -07008005 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -07008006 "WLAN TL:Only EAPOL or WAI packets allowed before authentication"));
8007
8008 /* Fail tx for packet */
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308009 pClientSTA->pfnSTATxComp( pvosGCtx, vosDataBuff,
Jeff Johnson295189b2012-06-20 16:38:30 -07008010 VOS_STATUS_E_BADMSG);
8011 vosDataBuff = NULL;
8012 *pvosDataBuff = NULL;
8013 return VOS_STATUS_SUCCESS;
8014 }
8015#else
8016 if ( 0 == tlMetaInfo.ucIsEapol )
8017 {
8018 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
8019 "WLAN TL:Received non EAPOL packet before authentication"));
8020
8021 /* Fail tx for packet */
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308022 pClientSTA->pfnSTATxComp( pvosGCtx, vosDataBuff,
Jeff Johnson295189b2012-06-20 16:38:30 -07008023 VOS_STATUS_E_BADMSG);
8024 vosDataBuff = NULL;
8025 *pvosDataBuff = NULL;
8026 return VOS_STATUS_SUCCESS;
8027 }
8028#endif /* FEATURE_WLAN_WAPI */
8029
8030 /*-------------------------------------------------------------------------
8031 Check TID
8032 -------------------------------------------------------------------------*/
8033 ucTid = tlMetaInfo.ucTID;
8034
8035 /*Make sure TID is valid*/
8036 if ( WLANTL_TID_INVALID(ucTid))
8037 {
Rajesh Chauhan2df40bf2013-08-22 11:26:12 -07008038 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
Jeff Johnson295189b2012-06-20 16:38:30 -07008039 "WLAN TL:Invalid TID sent in meta info %d - defaulting to 0 (BE)",
8040 ucTid));
8041 ucTid = 0;
8042 }
8043
8044 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
8045 "WLAN TL:Attaching BD header to pkt on WLANTL_STATxConn"));
8046
8047#ifdef FEATURE_WLAN_WAPI
8048 /*------------------------------------------------------------------------
8049 Translate 802.3 frame to 802.11 if Frame translation is enabled or if
8050 frame is a WAI frame.
8051 ------------------------------------------------------------------------*/
8052 if ( ( 1 == tlMetaInfo.ucIsWai ) ||
8053 ( 0 == tlMetaInfo.ucDisableFrmXtl ) )
8054#else
8055 /*------------------------------------------------------------------------
8056 Translate 802.3 frame to 802.11 if Frame translation is enabled
8057 ------------------------------------------------------------------------*/
8058 if ( ( 0 == tlMetaInfo.ucDisableFrmXtl ) &&
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308059 ( 0 != pClientSTA->wSTADesc.ucSwFrameTXXlation) )
Jeff Johnson295189b2012-06-20 16:38:30 -07008060#endif //#ifdef FEATURE_WLAN_WAPI
8061 {
Kiran Venkatappacab0d352012-12-17 13:09:22 -08008062 vosStatus = WLANTL_Translate8023To80211Header( vosDataBuff, &vosStatus,
8063 pTLCb, &ucSTAId,
Ravi Joshid0699502013-07-08 15:48:47 -07008064 &tlMetaInfo, &ucWDSEnabled,
8065 &extraHeadSpace);
Jeff Johnson295189b2012-06-20 16:38:30 -07008066 if ( VOS_STATUS_SUCCESS != vosStatus )
8067 {
8068 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8069 "WLAN TL:Error when translating header WLANTL_STATxConn"));
8070
8071 return vosStatus;
8072 }
8073
8074 tlMetaInfo.ucDisableFrmXtl = 1;
8075 }
8076
8077 /*-------------------------------------------------------------------------
8078 Call HAL to fill BD header
8079 -------------------------------------------------------------------------*/
8080 ucTypeSubtype |= (WLANTL_80211_DATA_TYPE << 4);
8081
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308082 if ( pClientSTA->wSTADesc.ucQosEnabled )
Jeff Johnson295189b2012-06-20 16:38:30 -07008083 {
8084 ucTypeSubtype |= (WLANTL_80211_DATA_QOS_SUBTYPE);
8085 }
8086
Gopichand Nakkala8b54e912013-03-11 10:44:21 +05308087#ifdef FEATURE_WLAN_WAPI
8088 /* TL State does not transition to AUTHENTICATED till GTK is installed, So in
8089 * case of WPA where GTK handshake is done after the 4 way handshake, the
8090 * unicast 2/2 EAPOL packet from the STA->AP has to be encrypted even before
8091 * the TL is in authenticated state. Since the PTK has been installed
8092 * already (after the 4 way handshake) we make sure that all traffic
8093 * is encrypted henceforth.(Note: TL is still not in AUTHENTICATED state so
8094 * we will only allow EAPOL data or WAI in case of WAPI)
8095 */
8096 if (tlMetaInfo.ucIsEapol && pClientSTA->ptkInstalled)
8097 {
8098 txFlag = 0;
8099 }
8100#else
8101 if (pClientSTA->ptkInstalled)
8102 {
8103 txFlag = 0;
8104 }
8105#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07008106
8107 vosStatus = (VOS_STATUS)WDA_DS_BuildTxPacketInfo( pvosGCtx, vosDataBuff , &vDestMacAddr,
8108 tlMetaInfo.ucDisableFrmXtl, &usPktLen,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308109 pClientSTA->wSTADesc.ucQosEnabled, ucWDSEnabled,
Jeff Johnson295189b2012-06-20 16:38:30 -07008110 extraHeadSpace,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308111 ucTypeSubtype, &pClientSTA->wSTADesc.vSelfMACAddress,
Gopichand Nakkala8b54e912013-03-11 10:44:21 +05308112 ucTid, txFlag,
Ganesh Kondabattini10e67352015-03-16 17:41:57 +05308113 tlMetaInfo.usTimeStamp, tlMetaInfo.ucIsEapol || tlMetaInfo.ucIsWai, tlMetaInfo.ucUP,
8114 tlMetaInfo.ucTxBdToken);
Jeff Johnson295189b2012-06-20 16:38:30 -07008115
8116 if ( VOS_STATUS_SUCCESS != vosStatus )
8117 {
8118 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8119 "WLAN TL:Failed while attempting to fill BD %d", vosStatus));
8120 *pvosDataBuff = NULL;
8121 return vosStatus;
8122 }
8123
8124 /*-----------------------------------------------------------------------
8125 Update tx counter for BA session query for tx side
8126 !1 - should this be done for EAPOL frames?
8127 -----------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308128 pClientSTA->auTxCount[ucTid]++;
Jeff Johnson295189b2012-06-20 16:38:30 -07008129
8130 vos_pkt_set_user_data_ptr( vosDataBuff, VOS_PKT_USER_DATA_ID_TL,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308131 (v_PVOID_t)pClientSTA->pfnSTATxComp );
Jeff Johnson295189b2012-06-20 16:38:30 -07008132
8133 /*------------------------------------------------------------------------
8134 Save data to input pointer for TL core
8135 ------------------------------------------------------------------------*/
8136 *pvosDataBuff = vosDataBuff;
8137 /*security frames cannot be delayed*/
8138 pTLCb->bUrgent = TRUE;
8139
Jeff Johnson295189b2012-06-20 16:38:30 -07008140 /* TX Statistics */
8141 if (!(tlMetaInfo.ucBcast || tlMetaInfo.ucMcast))
8142 {
8143 /* This is TX UC frame */
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308144 pClientSTA->trafficStatistics.txUCFcnt++;
8145 pClientSTA->trafficStatistics.txUCBcnt += usPktLen;
Jeff Johnson295189b2012-06-20 16:38:30 -07008146 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008147
8148 return VOS_STATUS_SUCCESS;
8149}/* WLANTL_STATxConn */
8150
8151
8152/*==========================================================================
8153 FUNCTION WLANTL_STATxAuth
8154
8155 DESCRIPTION
8156 Transmit in authenticated state - all data allowed
8157
8158 DEPENDENCIES
8159 The STA must be registered with TL before this function can be called.
8160
8161 PARAMETERS
8162
8163 IN
8164 pvosGCtx: pointer to the global vos context; a handle to TL's
8165 control block can be extracted from its context
8166 ucSTAId: identifier of the station being processed
8167 vosDataBuff: pointer to the tx vos buffer
8168
8169 RETURN VALUE
8170 The result code associated with performing the operation
8171
8172 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
8173 page fault
8174 VOS_STATUS_SUCCESS: Everything is good :)
8175
8176 Other return values are possible coming from the called functions.
8177 Please check API for additional info.
8178
8179 SIDE EFFECTS
8180
8181============================================================================*/
8182VOS_STATUS
8183WLANTL_STATxAuth
8184(
8185 v_PVOID_t pvosGCtx,
8186 v_U8_t ucSTAId,
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07008187 vos_pkt_t** pvosDataBuff,
8188 v_BOOL_t bForwardIAPPwithLLC
Jeff Johnson295189b2012-06-20 16:38:30 -07008189)
8190{
8191 v_U16_t usPktLen;
8192 VOS_STATUS vosStatus;
8193 v_MACADDR_t vDestMacAddr;
8194 vos_pkt_t* vosDataBuff = NULL;
8195 WLANTL_CbType* pTLCb = NULL;
8196 WLANTL_MetaInfoType tlMetaInfo;
8197 v_U8_t ucTypeSubtype = 0;
8198 WLANTL_ACEnumType ucAC;
8199 WLANTL_ACEnumType ucNextAC;
8200 v_U8_t ucTid;
8201 v_U8_t ucSwFrmXtl = 0;
8202 v_U8_t extraHeadSpace = 0;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308203 WLANTL_STAClientType *pStaClient = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07008204 v_U8_t ucWDSEnabled = 0;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05308205 v_U32_t ucTxFlag = 0;
Abhishek Singh45e68fe2014-12-11 12:55:59 +05308206 v_U8_t ucACMask, i;
Jeff Johnson295189b2012-06-20 16:38:30 -07008207 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
8208
8209 /*------------------------------------------------------------------------
8210 Sanity check
8211 Extract TL control block
8212 ------------------------------------------------------------------------*/
8213 pTLCb = VOS_GET_TL_CB(pvosGCtx);
8214 if (( NULL == pTLCb ) || ( NULL == pvosDataBuff ))
8215 {
8216 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson0298bd02013-11-14 19:58:38 -08008217 "WLAN TL:Invalid input params on WLANTL_STATxAuth TL %p DB %p",
Jeff Johnson295189b2012-06-20 16:38:30 -07008218 pTLCb, pvosDataBuff));
8219 if (NULL != pvosDataBuff)
8220 {
8221 *pvosDataBuff = NULL;
8222 }
8223 if(NULL != pTLCb)
8224 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308225 if ( NULL == pTLCb->atlSTAClients[ucSTAId] )
8226 {
8227 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8228 "WLAN TL:Client Memory was not allocated on %s", __func__));
8229 return VOS_STATUS_E_FAILURE;
8230 }
8231 pTLCb->atlSTAClients[ucSTAId]->ucNoMoreData = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07008232 }
8233 return VOS_STATUS_E_FAULT;
8234 }
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308235 pStaClient = pTLCb->atlSTAClients[ucSTAId];
Jeff Johnson295189b2012-06-20 16:38:30 -07008236
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308237 if ( NULL == pStaClient )
8238 {
8239 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8240 "WLAN TL:Client Memory was not allocated on %s", __func__));
8241 return VOS_STATUS_E_FAILURE;
8242 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008243
8244 vos_mem_zero(&tlMetaInfo, sizeof(tlMetaInfo));
8245 /*------------------------------------------------------------------------
8246 Fetch packet from HDD
8247 ------------------------------------------------------------------------*/
Sunil Ravid5406f22013-01-22 00:18:31 -08008248#ifdef FEATURE_WLAN_TDLS
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308249 if ((WLAN_STA_SOFTAP != pStaClient->wSTADesc.wSTAType) &&
Agarwal Ashishcd86f7b2014-06-16 17:11:58 +05308250 (!vos_concurrent_open_sessions_running()) &&
Sunil Ravid5406f22013-01-22 00:18:31 -08008251 !pTLCb->ucTdlsPeerCount)
8252 {
8253#else
Jeff Johnson295189b2012-06-20 16:38:30 -07008254 if ((WLAN_STA_SOFTAP != pStaClient->wSTADesc.wSTAType) &&
Agarwal Ashishcd86f7b2014-06-16 17:11:58 +05308255 (!vos_concurrent_open_sessions_running()))
Jeff Johnson295189b2012-06-20 16:38:30 -07008256 {
8257#endif
8258 ucAC = pStaClient->ucCurrentAC;
8259
8260 /*-------------------------------------------------------------------
8261 Disable AC temporary - if successfull retrieve re-enable
8262 The order is justified because of the possible scenario
8263 - TL tryes to fetch packet for AC and it returns NULL
8264 - TL analyzes the data it has received to see if there are
8265 any more pkts available for AC -> if not TL will disable AC
8266 - however it is possible that while analyzing results TL got
8267 preempted by a pending indication where the mask was again set
8268 TL will not check again and as a result when it resumes
8269 execution it will disable AC
8270 To prevent this the AC will be disabled here and if retrieve
8271 is successfull it will be re-enabled
8272 -------------------------------------------------------------------*/
8273 pStaClient->aucACMask[pStaClient->ucCurrentAC] = 0;
8274
8275 // don't reset it, as other AC queues in HDD may have packets
8276 //vos_atomic_set_U8( &pStaClient->ucPktPending, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07008277 }
8278 else
8279 {
8280 //softap case
8281 ucAC = pTLCb->uCurServedAC;
8282 pStaClient->aucACMask[ucAC] = 0;
8283
8284 //vos_atomic_set_U8( &pStaClient->ucPktPending, 0);
8285 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008286
8287 WLAN_TL_AC_ARRAY_2_MASK( pStaClient, ucACMask, i);
Jeff Johnson295189b2012-06-20 16:38:30 -07008288 /*You make an initial assumption that HDD has no more data and if the
8289 assumption was wrong you reset the flags to their original state
8290 This will prevent from exposing a race condition between checking with HDD
8291 for packets and setting the flags to false*/
8292 if ( 0 == ucACMask )
8293 {
8294 vos_atomic_set_U8( &pStaClient->ucPktPending, 0);
8295 pStaClient->ucNoMoreData = 1;
8296 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008297
8298 vosStatus = pStaClient->pfnSTAFetchPkt( pvosGCtx,
8299 &ucSTAId,
8300 ucAC,
8301 &vosDataBuff, &tlMetaInfo );
8302
8303
8304 if (( VOS_STATUS_SUCCESS != vosStatus ) || ( NULL == vosDataBuff ))
8305 {
8306
8307 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05308308 "WLAN TL:Failed while attempting to fetch pkt from HDD QId:%d status:%d",
8309 ucAC, vosStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07008310 *pvosDataBuff = NULL;
8311 /*--------------------------------------------------------------------
8312 Reset AC for the serviced station to the highest priority AC
8313 -> due to no more data at the station
8314 Even if this AC is not supported by the station, correction will be
8315 made in the main TL loop
8316 --------------------------------------------------------------------*/
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05308317 pStaClient->ucCurrentAC = WLANTL_AC_HIGH_PRIO;
Jeff Johnson295189b2012-06-20 16:38:30 -07008318 pStaClient->ucCurrentWeight = 0;
8319
8320 return vosStatus;
8321 }
8322
Jeff Johnsone7245742012-09-05 17:12:55 -07008323 WLANTL_StatHandleTXFrame(pvosGCtx, ucSTAId, vosDataBuff, NULL, &tlMetaInfo);
Jeff Johnsone7245742012-09-05 17:12:55 -07008324
Jeff Johnson295189b2012-06-20 16:38:30 -07008325 /*There are still packets in HDD - set back the pending packets and
8326 the no more data assumption*/
8327 vos_atomic_set_U8( &pStaClient->ucPktPending, 1);
8328 pStaClient->ucNoMoreData = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07008329
Jeff Johnson295189b2012-06-20 16:38:30 -07008330 if (WLAN_STA_SOFTAP != pStaClient->wSTADesc.wSTAType)
8331 {
Jeff Johnson295189b2012-06-20 16:38:30 -07008332 // don't need to set it, as we don't reset it in this function.
8333 //vos_atomic_set_U8( &pTLCb->atlSTAClients[ucSTAId].ucPktPending, 1);
Jeff Johnson295189b2012-06-20 16:38:30 -07008334 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008335
8336#ifdef WLAN_PERF
8337 vos_pkt_set_user_data_ptr( vosDataBuff, VOS_PKT_USER_DATA_ID_BAL,
8338 (v_PVOID_t)0);
8339#endif /*WLAN_PERF*/
8340
8341 /*-------------------------------------------------------------------------
8342 Check TID
8343 -------------------------------------------------------------------------*/
8344 ucTid = tlMetaInfo.ucTID;
8345
8346 /*Make sure TID is valid*/
8347 if ( WLANTL_TID_INVALID(ucTid))
8348 {
Rajesh Chauhan2df40bf2013-08-22 11:26:12 -07008349 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
Jeff Johnson295189b2012-06-20 16:38:30 -07008350 "WLAN TL:Invalid TID sent in meta info %d - defaulting to 0 (BE)",
8351 ucTid));
8352 ucTid = 0;
8353 }
8354
8355 /*Save for UAPSD timer consideration*/
8356 pStaClient->ucServicedAC = ucAC;
8357
8358 if ( ucAC == pStaClient->ucCurrentAC )
8359 {
8360 pStaClient->aucACMask[pStaClient->ucCurrentAC] = 1;
8361 pStaClient->ucCurrentWeight--;
8362 }
8363 else
8364 {
8365 pStaClient->ucCurrentAC = ucAC;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308366 pStaClient->ucCurrentWeight = pTLCb->tlConfigInfo.ucAcWeights[ucAC] - 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07008367
8368 pStaClient->aucACMask[pStaClient->ucCurrentAC] = 1;
8369
8370 }
8371
Jeff Johnson295189b2012-06-20 16:38:30 -07008372 if (WLAN_STA_SOFTAP != pStaClient->wSTADesc.wSTAType)
8373 {
Jeff Johnson295189b2012-06-20 16:38:30 -07008374 if ( 0 == pStaClient->ucCurrentWeight )
8375 {
8376 WLANTL_ACEnumType tempAC = ucAC;
8377 /*-----------------------------------------------------------------------
8378 Choose next AC - !!! optimize me
8379 -----------------------------------------------------------------------*/
8380 while ( 0 != ucACMask )
8381 {
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05308382 if(tempAC == WLANTL_AC_BK)
8383 ucNextAC = WLANTL_AC_HIGH_PRIO;
8384 else
8385 ucNextAC = (tempAC - 1);
8386
Jeff Johnson295189b2012-06-20 16:38:30 -07008387 if ( 0 != pStaClient->aucACMask[ucNextAC] )
8388 {
8389 pStaClient->ucCurrentAC = ucNextAC;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308390 pStaClient->ucCurrentWeight = pTLCb->tlConfigInfo.ucAcWeights[ucNextAC];
Jeff Johnson295189b2012-06-20 16:38:30 -07008391
8392 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
8393 "WLAN TL: Changing serviced AC to: %d with Weight: %d",
8394 pStaClient->ucCurrentAC ,
8395 pStaClient->ucCurrentWeight));
8396 break;
8397 }
8398 tempAC = ucNextAC;
8399 }
8400 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008401 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008402
8403 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
8404 "WLAN TL:Attaching BD header to pkt on WLANTL_STATxAuth"));
8405
8406 /*------------------------------------------------------------------------
8407 Translate 802.3 frame to 802.11
8408 ------------------------------------------------------------------------*/
8409 if ( 0 == tlMetaInfo.ucDisableFrmXtl )
8410 {
8411 /* Needs frame translation */
8412 // if the client has not enabled SW-only frame translation
8413 // and if the frame is a unicast frame
8414 // (HW frame translation does not support multiple broadcast domains
8415 // so we use SW frame translation for broadcast/multicast frames)
8416#ifdef FEATURE_WLAN_WAPI
8417 // and if the frame is not a WAPI frame
8418#endif
8419 // then use HW_based frame translation
8420
8421 if ( ( 0 == pStaClient->wSTADesc.ucSwFrameTXXlation ) &&
8422 ( 0 == tlMetaInfo.ucBcast ) &&
8423 ( 0 == tlMetaInfo.ucMcast )
8424#ifdef FEATURE_WLAN_WAPI
8425 && ( tlMetaInfo.ucIsWai != 1 )
8426#endif
8427 )
8428 {
8429#ifdef WLAN_PERF
8430 v_U32_t uFastFwdOK = 0;
8431
8432 /* HW based translation. See if the frame could be fast forwarded */
8433 WDA_TLI_FastHwFwdDataFrame( pvosGCtx, vosDataBuff , &vosStatus,
8434 &uFastFwdOK, &tlMetaInfo, &pStaClient->wSTADesc);
8435
8436 if( VOS_STATUS_SUCCESS == vosStatus )
8437 {
8438 if(uFastFwdOK)
8439 {
8440 /* Packet could be fast forwarded now */
8441 vos_pkt_set_user_data_ptr( vosDataBuff, VOS_PKT_USER_DATA_ID_TL,
8442 (v_PVOID_t)pStaClient->pfnSTATxComp );
8443
8444 *pvosDataBuff = vosDataBuff;
8445
8446 /* TODO: Do we really need to update WLANTL_HSHandleTXFrame()
8447 stats for every pkt? */
8448 pStaClient->auTxCount[tlMetaInfo.ucTID]++;
8449 return vosStatus;
8450 }
8451 /* can't be fast forwarded, fall through normal (slow) path. */
8452 }
8453 else
8454 {
8455
8456 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8457 "WLAN TL:Failed while attempting to fastFwd BD %d", vosStatus));
8458 *pvosDataBuff = NULL;
8459 return vosStatus;
8460 }
8461#endif /*WLAN_PERF*/
8462 }
8463 else
8464 {
8465 /* SW based translation */
8466
Kiran Venkatappacab0d352012-12-17 13:09:22 -08008467 vosStatus = WLANTL_Translate8023To80211Header( vosDataBuff, &vosStatus,
8468 pTLCb, &ucSTAId,
Ravi Joshid0699502013-07-08 15:48:47 -07008469 &tlMetaInfo, &ucWDSEnabled,
8470 &extraHeadSpace);
Jeff Johnson295189b2012-06-20 16:38:30 -07008471 if ( VOS_STATUS_SUCCESS != vosStatus )
8472 {
8473 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8474 "WLAN TL:Error when translating header WLANTL_STATxAuth"));
8475 return vosStatus;
8476 }
8477
8478 TLLOG4(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_LOW,
Arif Hussainf2b00992013-11-17 21:46:15 -08008479 "WLAN TL software translation success"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008480 ucSwFrmXtl = 1;
8481 tlMetaInfo.ucDisableFrmXtl = 1;
8482 }
8483 }
Gopichand Nakkala574f6d12013-06-27 19:38:43 +05308484#ifdef FEATURE_WLAN_TDLS
8485 /*In case of TDLS, if the packet is destined to TDLS STA ucSTAId may
8486 change. so update the pStaClient accordingly */
8487 pStaClient = pTLCb->atlSTAClients[ucSTAId];
Jeff Johnson295189b2012-06-20 16:38:30 -07008488
Gopichand Nakkala574f6d12013-06-27 19:38:43 +05308489 if ( NULL == pStaClient )
8490 {
8491 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8492 "pStaClient is NULL %s", __func__));
8493 return VOS_STATUS_E_FAILURE;
8494 }
8495#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07008496 /*-------------------------------------------------------------------------
8497 Call HAL to fill BD header
8498 -------------------------------------------------------------------------*/
8499 ucTypeSubtype |= (WLANTL_80211_DATA_TYPE << 4);
8500
8501 if ( pStaClient->wSTADesc.ucQosEnabled )
8502 {
8503 ucTypeSubtype |= (WLANTL_80211_DATA_QOS_SUBTYPE);
8504 }
8505
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05308506 /* ucAC now points to TL Q ID with a new queue added in TL,
8507 * hence look for the uapsd info for the correct AC that
8508 * this packet belongs to.
8509 */
8510 ucTxFlag = (0 != pStaClient->wUAPSDInfo[tlMetaInfo.ac].ucSet)?
Jeff Johnson295189b2012-06-20 16:38:30 -07008511 HAL_TRIGGER_ENABLED_AC_MASK:0;
8512
8513#ifdef FEATURE_WLAN_WAPI
8514 if ( pStaClient->wSTADesc.ucIsWapiSta == 1 )
8515 {
8516#ifdef LIBRA_WAPI_SUPPORT
8517 ucTxFlag = ucTxFlag | HAL_WAPI_STA_MASK;
8518#endif //LIBRA_WAPI_SUPPORT
8519 if ( tlMetaInfo.ucIsWai == 1 )
8520 {
8521 ucTxFlag = ucTxFlag | HAL_TX_NO_ENCRYPTION_MASK;
8522 }
8523 }
8524#endif /* FEATURE_WLAN_WAPI */
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008525#ifdef FEATURE_WLAN_TDLS
8526 if ( pStaClient->wSTADesc.wSTAType == WLAN_STA_TDLS )
8527 {
8528 ucTxFlag = ucTxFlag | HAL_TDLS_PEER_STA_MASK;
8529 }
8530#endif /* FEATURE_WLAN_TDLS */
Abhishek Singhfa011222014-04-14 10:57:08 +05308531 if( tlMetaInfo.ucIsArp )
8532 {
Hanumantha Reddy Pothulae5ab23d2015-09-14 18:08:24 +05308533 if (pStaClient->arpOnWQ5)
8534 {
8535 ucTxFlag |= HAL_USE_FW_IN_TX_PATH;
8536 }
Hanumantha Reddy Pothulaee001fc2015-05-26 15:21:53 +05308537 if (pStaClient->arpRate == 0)
8538 {
8539 ucTxFlag |= HAL_USE_BD_RATE_1_MASK;
8540 }
8541 else if (pStaClient->arpRate == 1 || pStaClient->arpRate == 3)
8542 {
8543 pStaClient->arpRate ^= 0x2;
8544 ucTxFlag |= HAL_USE_BD_RATE_1_MASK<<(pStaClient->arpRate-1);
8545 }
8546 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
8547 "arp pkt sending on BD rate: %hhu", pStaClient->arpRate));
Abhishek Singhfa011222014-04-14 10:57:08 +05308548 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008549
8550 vosStatus = (VOS_STATUS)WDA_DS_BuildTxPacketInfo( pvosGCtx,
8551 vosDataBuff , &vDestMacAddr,
8552 tlMetaInfo.ucDisableFrmXtl, &usPktLen,
8553 pStaClient->wSTADesc.ucQosEnabled, ucWDSEnabled,
8554 extraHeadSpace,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308555 ucTypeSubtype, &pStaClient->wSTADesc.vSelfMACAddress,
Jeff Johnson295189b2012-06-20 16:38:30 -07008556 ucTid, ucTxFlag, tlMetaInfo.usTimeStamp,
Ganesh Kondabattini10e67352015-03-16 17:41:57 +05308557 tlMetaInfo.ucIsEapol, tlMetaInfo.ucUP,
8558 tlMetaInfo.ucTxBdToken);
Jeff Johnson295189b2012-06-20 16:38:30 -07008559
8560 if(!VOS_IS_STATUS_SUCCESS(vosStatus))
8561 {
8562 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8563 "Fill TX BD Error status %d", vosStatus));
8564
8565 return vosStatus;
8566 }
8567
Jeff Johnson295189b2012-06-20 16:38:30 -07008568 /* TX Statistics */
8569 if (!(tlMetaInfo.ucBcast || tlMetaInfo.ucMcast))
8570 {
8571 /* This is TX UC frame */
8572 pStaClient->trafficStatistics.txUCFcnt++;
8573 pStaClient->trafficStatistics.txUCBcnt += usPktLen;
8574 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008575
Kiran Venkatappacab0d352012-12-17 13:09:22 -08008576#ifndef FEATURE_WLAN_TDLS
Jeff Johnson295189b2012-06-20 16:38:30 -07008577 /*-----------------------------------------------------------------------
8578 Update tx counter for BA session query for tx side
8579 -----------------------------------------------------------------------*/
8580 pStaClient->auTxCount[ucTid]++;
Kiran Venkatappacab0d352012-12-17 13:09:22 -08008581#else
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308582 pTLCb->atlSTAClients[ucSTAId]->auTxCount[ucTid]++;
Kiran Venkatappacab0d352012-12-17 13:09:22 -08008583#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07008584
8585 /* This code is to send traffic with lower priority AC when we does not
8586 get admitted to send it. Today HAL does not downgrade AC so this code
8587 does not get executed.(In other words, HAL doesnÂ’t change tid. The if
8588 statement is always false.)
8589 NOTE: In the case of LA downgrade occurs in HDD (that was the change
8590 Phani made during WMM-AC plugfest). If WM & BMP also took this approach,
8591 then there will be no need for any AC downgrade logic in TL/WDI. */
8592#if 0
8593 if (( ucTid != tlMetaInfo.ucTID ) &&
8594 ( 0 != pStaClient->wSTADesc.ucQosEnabled ) &&
8595 ( 0 != ucSwFrmXtl ))
8596 {
8597 /*---------------------------------------------------------------------
8598 !! FIX me: Once downgrading is clear put in the proper change
8599 ---------------------------------------------------------------------*/
8600 ucQCOffset = WLANHAL_TX_BD_HEADER_SIZE + WLANTL_802_11_HEADER_LEN;
8601
8602 //!!!Fix this replace peek with extract
8603 vos_pkt_peek_data( vosDataBuff, ucQCOffset,(v_PVOID_t)&pucQosCtrl,
8604 sizeof(*pucQosCtrl));
8605 *pucQosCtrl = ucTid; //? proper byte order
8606 }
8607#endif
8608
8609 if ( VOS_STATUS_SUCCESS != vosStatus )
8610 {
8611 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8612 "WLAN TL:Failed while attempting to fill BD %d", vosStatus));
8613 *pvosDataBuff = NULL;
8614 return vosStatus;
8615 }
8616
8617 vos_pkt_set_user_data_ptr( vosDataBuff, VOS_PKT_USER_DATA_ID_TL,
8618 (v_PVOID_t)pStaClient->pfnSTATxComp );
8619
8620 *pvosDataBuff = vosDataBuff;
8621
8622 /*BE & BK can be delayed, VO and VI not frames cannot be delayed*/
8623 if ( pStaClient->ucServicedAC > WLANTL_AC_BE )
8624 {
8625 pTLCb->bUrgent= TRUE;
8626 }
8627
8628 return VOS_STATUS_SUCCESS;
8629}/* WLANTL_STATxAuth */
8630
8631/*==========================================================================
8632 FUNCTION WLANTL_STATxDisc
8633
8634 DESCRIPTION
8635 Transmit in disconnected state - no data allowed
8636
8637 DEPENDENCIES
8638 The STA must be registered with TL before this function can be called.
8639
8640 PARAMETERS
8641
8642 IN
8643 pvosGCtx: pointer to the global vos context; a handle to TL's
8644 control block can be extracted from its context
8645 ucSTAId: identifier of the station being processed
8646 vosDataBuff: pointer to the tx vos buffer
8647
8648 RETURN VALUE
8649 The result code associated with performing the operation
8650
8651 VOS_STATUS_SUCCESS: Everything is good :)
8652
8653 SIDE EFFECTS
8654
8655============================================================================*/
8656VOS_STATUS
8657WLANTL_STATxDisc
8658(
8659 v_PVOID_t pvosGCtx,
8660 v_U8_t ucSTAId,
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07008661 vos_pkt_t** pvosDataBuff,
8662 v_BOOL_t bForwardIAPPwithLLC
Jeff Johnson295189b2012-06-20 16:38:30 -07008663)
8664{
8665 WLANTL_CbType* pTLCb = NULL;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308666 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07008667 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
8668
Jeff Johnson295189b2012-06-20 16:38:30 -07008669 /*------------------------------------------------------------------------
8670 Sanity check
8671 Extract TL control block
8672 ------------------------------------------------------------------------*/
8673 pTLCb = VOS_GET_TL_CB(pvosGCtx);
8674 if ( NULL == pTLCb )
8675 {
8676 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8677 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_STATxAuth"));
8678 *pvosDataBuff = NULL;
8679 return VOS_STATUS_E_FAULT;
8680 }
8681
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308682 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
8683
8684 if ( NULL == pClientSTA )
8685 {
8686 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8687 "WLAN TL:Client Memory was not allocated on %s", __func__));
8688 return VOS_STATUS_E_FAILURE;
8689 }
8690
Jeff Johnson295189b2012-06-20 16:38:30 -07008691 /*------------------------------------------------------------------------
8692 Error
8693 ------------------------------------------------------------------------*/
8694 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
8695 "WLAN TL:Packet should not be transmitted in state disconnected ignoring"
8696 " request"));
8697
8698 *pvosDataBuff = NULL;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308699 pClientSTA->ucNoMoreData = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07008700
8701 //Should not be anything pending in disconnect state
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308702 vos_atomic_set_U8( &pClientSTA->ucPktPending, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07008703
8704 return VOS_STATUS_SUCCESS;
8705}/* WLANTL_STATxDisc */
8706
8707/*==========================================================================
8708 FUNCTION WLANTL_STARxConn
8709
8710 DESCRIPTION
8711 Receive in connected state - only EAPOL
8712
8713 DEPENDENCIES
8714 The STA must be registered with TL before this function can be called.
8715
8716 PARAMETERS
8717
8718 IN
8719 pvosGCtx: pointer to the global vos context; a handle to TL's
8720 control block can be extracted from its context
8721 ucSTAId: identifier of the station being processed
8722 vosDataBuff: pointer to the tx/rx vos buffer
8723
8724 RETURN VALUE
8725 The result code associated with performing the operation
8726
8727 VOS_STATUS_E_INVAL: invalid input parameters
8728 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
8729 page fault
8730 VOS_STATUS_SUCCESS: Everything is good :)
8731
8732 SIDE EFFECTS
8733
8734============================================================================*/
8735VOS_STATUS
8736WLANTL_STARxConn
8737(
8738 v_PVOID_t pvosGCtx,
8739 v_U8_t ucSTAId,
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07008740 vos_pkt_t** pvosDataBuff,
8741 v_BOOL_t bForwardIAPPwithLLC
Jeff Johnson295189b2012-06-20 16:38:30 -07008742)
8743{
8744 WLANTL_CbType* pTLCb = NULL;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308745 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07008746 v_U16_t usEtherType = 0;
8747 v_U16_t usPktLen;
8748 v_U8_t ucMPDUHOffset;
8749 v_U16_t usMPDUDOffset;
8750 v_U16_t usMPDULen;
8751 v_U8_t ucMPDUHLen;
8752 v_U16_t usActualHLen = 0;
8753 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
8754 vos_pkt_t* vosDataBuff;
8755 v_PVOID_t aucBDHeader;
8756 v_U8_t ucTid;
8757 WLANTL_RxMetaInfoType wRxMetaInfo;
8758 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
8759
8760 /*------------------------------------------------------------------------
8761 Sanity check
8762 ------------------------------------------------------------------------*/
8763 if (( NULL == pvosDataBuff ) || ( NULL == ( vosDataBuff = *pvosDataBuff )))
8764 {
8765 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8766 "WLAN TL:Invalid parameter sent on WLANTL_STARxConn"));
8767 return VOS_STATUS_E_INVAL;
8768 }
8769
8770 /*------------------------------------------------------------------------
8771 Extract TL control block
8772 ------------------------------------------------------------------------*/
8773 pTLCb = VOS_GET_TL_CB(pvosGCtx);
8774 if ( NULL == pTLCb )
8775 {
8776 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8777 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_ChangeSTAState"));
8778 return VOS_STATUS_E_FAULT;
8779 }
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308780 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
8781
8782 if ( NULL == pClientSTA )
8783 {
8784 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8785 "WLAN TL:Client Memory was not allocated on %s", __func__));
8786 return VOS_STATUS_E_FAILURE;
8787 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008788
8789 /*------------------------------------------------------------------------
8790 Extract BD header and check if valid
8791 ------------------------------------------------------------------------*/
8792 vosStatus = WDA_DS_PeekRxPacketInfo( vosDataBuff, (v_PVOID_t)&aucBDHeader, 0/*Swap BD*/ );
8793
8794 if ( NULL == aucBDHeader )
8795 {
8796 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8797 "WLAN TL:Cannot extract BD header"));
8798 VOS_ASSERT( 0 );
8799 return VOS_STATUS_E_FAULT;
8800 }
8801
8802
8803 ucMPDUHOffset = (v_U8_t)WDA_GET_RX_MPDU_HEADER_OFFSET(aucBDHeader);
8804 usMPDUDOffset = (v_U16_t)WDA_GET_RX_MPDU_DATA_OFFSET(aucBDHeader);
8805 usMPDULen = (v_U16_t)WDA_GET_RX_MPDU_LEN(aucBDHeader);
8806 ucMPDUHLen = (v_U8_t)WDA_GET_RX_MPDU_HEADER_LEN(aucBDHeader);
8807 ucTid = (v_U8_t)WDA_GET_RX_TID(aucBDHeader);
8808
8809 vos_pkt_get_packet_length( vosDataBuff, &usPktLen);
8810
8811 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
8812 "WLAN TL:BD header processing data: HO %d DO %d Len %d HLen %d",
8813 ucMPDUHOffset, usMPDUDOffset, usMPDULen, ucMPDUHLen));
8814
8815 /*It will cut out the 802.11 header if not used*/
8816 if ( VOS_STATUS_SUCCESS != WDA_DS_TrimRxPacketInfo( vosDataBuff ) )
8817 {
8818 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
8819 "WLAN TL:BD header corrupted - dropping packet"));
8820 /* Drop packet */
8821 vos_pkt_return_packet(vosDataBuff);
8822 return VOS_STATUS_SUCCESS;
8823 }
8824
8825 vosStatus = WLANTL_GetEtherType(aucBDHeader,vosDataBuff,ucMPDUHLen,&usEtherType);
8826
8827 if( VOS_IS_STATUS_SUCCESS(vosStatus) )
8828 {
8829#ifdef FEATURE_WLAN_WAPI
8830 /* If frame is neither an EAPOL frame nor a WAI frame then we drop the frame*/
8831 /* TODO: Do we need a check to see if we are in WAPI mode? If not is it possible */
8832 /* that we get an EAPOL packet in WAPI mode or vice versa? */
8833 if ( WLANTL_LLC_8021X_TYPE != usEtherType && WLANTL_LLC_WAI_TYPE != usEtherType )
8834 {
Sunil Ravid5406f22013-01-22 00:18:31 -08008835 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07008836 "WLAN TL:RX Frame not EAPOL or WAI EtherType %d - dropping", usEtherType );
Jeff Johnson295189b2012-06-20 16:38:30 -07008837 /* Drop packet */
8838 vos_pkt_return_packet(vosDataBuff);
8839 }
8840#else
8841 if ( WLANTL_LLC_8021X_TYPE != usEtherType )
8842 {
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07008843 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8844 "WLAN TL:RX Frame not EAPOL EtherType %d - dropping", usEtherType);
Jeff Johnson295189b2012-06-20 16:38:30 -07008845 /* Drop packet */
8846 vos_pkt_return_packet(vosDataBuff);
8847 }
8848#endif /* FEATURE_WLAN_WAPI */
8849 else /* Frame is an EAPOL frame or a WAI frame*/
8850 {
Katya Nigam42e16e82014-02-04 16:28:55 +05308851 MTRACE(vos_trace(VOS_MODULE_ID_TL,
8852 TRACE_CODE_TL_RX_CONN_EAPOL, ucSTAId, usEtherType ));
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07008853
Madan Mohan Koyyalamudid8000342012-11-08 14:55:26 -08008854 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07008855 "WLAN TL:RX Frame EAPOL EtherType %d - processing", usEtherType);
8856
Jeff Johnson295189b2012-06-20 16:38:30 -07008857 if (( 0 == WDA_GET_RX_FT_DONE(aucBDHeader) ) &&
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308858 ( 0 != pClientSTA->wSTADesc.ucSwFrameRXXlation))
Jeff Johnson295189b2012-06-20 16:38:30 -07008859 {
8860 if (usMPDUDOffset > ucMPDUHOffset)
8861 {
8862 usActualHLen = usMPDUDOffset - ucMPDUHOffset;
8863 }
8864
8865 vosStatus = WLANTL_Translate80211To8023Header( vosDataBuff, &vosStatus, usActualHLen,
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07008866 ucMPDUHLen, pTLCb, ucSTAId, bForwardIAPPwithLLC);
Jeff Johnson295189b2012-06-20 16:38:30 -07008867
8868 if ( VOS_STATUS_SUCCESS != vosStatus )
8869 {
Kaushik, Sushante386ee12014-05-01 15:50:52 +05308870 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
Jeff Johnson295189b2012-06-20 16:38:30 -07008871 "WLAN TL:Failed to translate from 802.11 to 802.3 - dropping"));
8872 /* Drop packet */
8873 vos_pkt_return_packet(vosDataBuff);
8874 return vosStatus;
8875 }
8876 }
8877 /*-------------------------------------------------------------------
8878 Increment receive counter
8879 -------------------------------------------------------------------*/
Madan Mohan Koyyalamudic0e5bd82012-09-18 17:12:27 -07008880 if ( !WLANTL_TID_INVALID( ucTid) )
8881 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308882 pClientSTA->auRxCount[ucTid]++;
Madan Mohan Koyyalamudic0e5bd82012-09-18 17:12:27 -07008883 }
8884 else
8885 {
8886 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8887 "WLAN TL:Invalid tid %d (Station ID %d) on %s",
8888 ucTid, ucSTAId, __func__));
Hanumantha Reddy Pothula0de10802016-02-11 17:29:27 +05308889 vos_pkt_return_packet(vosDataBuff);
8890 return VOS_STATUS_E_FAILURE;
Madan Mohan Koyyalamudic0e5bd82012-09-18 17:12:27 -07008891 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008892
8893 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
8894 "WLAN TL:Sending EAPoL frame to station %d AC %d", ucSTAId, ucTid));
8895
8896 /*-------------------------------------------------------------------
8897 !!!Assuming TID = UP mapping
8898 -------------------------------------------------------------------*/
8899 wRxMetaInfo.ucUP = ucTid;
8900
Jeff Johnson295189b2012-06-20 16:38:30 -07008901 TLLOG4(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_LOW,
Arif Hussainf2b00992013-11-17 21:46:15 -08008902 "WLAN TL %s:Sending data chain to station", __func__));
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308903 if ( WLAN_STA_SOFTAP == pClientSTA->wSTADesc.wSTAType )
Jeff Johnson295189b2012-06-20 16:38:30 -07008904 {
8905 wRxMetaInfo.ucDesSTAId = WLAN_RX_SAP_SELF_STA_ID;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308906 pClientSTA->pfnSTARx( pvosGCtx, vosDataBuff, ucSTAId,
Jeff Johnson295189b2012-06-20 16:38:30 -07008907 &wRxMetaInfo );
8908 }
8909 else
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308910 pClientSTA->pfnSTARx( pvosGCtx, vosDataBuff, ucSTAId,
Jeff Johnson295189b2012-06-20 16:38:30 -07008911 &wRxMetaInfo );
8912 }/*EAPOL frame or WAI frame*/
8913 }/*vos status success*/
8914
8915 return VOS_STATUS_SUCCESS;
8916}/* WLANTL_STARxConn */
8917
Jeff Johnson295189b2012-06-20 16:38:30 -07008918/*==========================================================================
8919 FUNCTION WLANTL_FwdPktToHDD
8920
8921 DESCRIPTION
8922 Determine the Destation Station ID and route the Frame to Upper Layer
8923
8924 DEPENDENCIES
8925
8926 PARAMETERS
8927
8928 IN
8929 pvosGCtx: pointer to the global vos context; a handle to TL's
8930 control block can be extracted from its context
8931 ucSTAId: identifier of the station being processed
8932 vosDataBuff: pointer to the rx vos buffer
8933
8934 RETURN VALUE
8935 The result code associated with performing the operation
8936
8937 VOS_STATUS_E_INVAL: invalid input parameters
8938 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
8939 page fault
8940 VOS_STATUS_SUCCESS: Everything is good :)
8941
8942 SIDE EFFECTS
8943
8944============================================================================*/
8945
8946VOS_STATUS
8947WLANTL_FwdPktToHDD
8948(
8949 v_PVOID_t pvosGCtx,
8950 vos_pkt_t* pvosDataBuff,
8951 v_U8_t ucSTAId
8952)
8953{
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308954 v_MACADDR_t DestMacAddress;
8955 v_MACADDR_t *pDestMacAddress = &DestMacAddress;
8956 v_SIZE_t usMacAddSize = VOS_MAC_ADDR_SIZE;
Jeff Johnson295189b2012-06-20 16:38:30 -07008957 WLANTL_CbType* pTLCb = NULL;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308958 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07008959 vos_pkt_t* vosDataBuff ;
8960 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
Girish Gowli93e3edd2014-05-01 15:42:31 +05308961 v_U32_t* STAMetaInfoPtr;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308962 vos_pkt_t* vosNextDataBuff ;
8963 v_U8_t ucDesSTAId;
Jeff Johnson295189b2012-06-20 16:38:30 -07008964 WLANTL_RxMetaInfoType wRxMetaInfo;
8965
Jeff Johnson295189b2012-06-20 16:38:30 -07008966 /*------------------------------------------------------------------------
8967 Sanity check
8968 ------------------------------------------------------------------------*/
8969 if (( NULL == pvosDataBuff ) || ( NULL == ( vosDataBuff = pvosDataBuff )))
8970 {
8971 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8972 "WLAN TL:Invalid parameter sent on WLANTL_FwdPktToHdd"));
8973 return VOS_STATUS_E_INVAL;
8974 }
8975
8976 /*------------------------------------------------------------------------
8977 Extract TL control block
8978 ------------------------------------------------------------------------*/
8979 pTLCb = VOS_GET_TL_CB(pvosGCtx);
8980 if ( NULL == pTLCb )
8981 {
8982 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8983 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_FwdPktToHdd"));
8984 return VOS_STATUS_E_FAULT;
8985 }
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308986
Tushnim Bhattacharyya5dd94562013-03-20 20:15:03 -07008987 if(WLANTL_STA_ID_INVALID(ucSTAId))
8988 {
8989 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,"ucSTAId %d is not valid",
8990 ucSTAId));
8991 return VOS_STATUS_E_INVAL;
8992 }
8993
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308994 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
8995
8996 if ( NULL == pClientSTA )
8997 {
8998 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8999 "WLAN TL:Client Memory was not allocated on %s", __func__));
9000 return VOS_STATUS_E_FAILURE;
9001 }
9002
Jeff Johnson295189b2012-06-20 16:38:30 -07009003 /* This the change required for SoftAp to handle Reordered Buffer. Since a STA
9004 may have packets destined to multiple destinations we have to process each packet
9005 at a time and determine its Destination. So the Voschain provided by Reorder code
9006 is unchain and forwarded to Upper Layer after Determining the Destination */
9007
9008 vosDataBuff = pvosDataBuff;
9009 while (vosDataBuff != NULL)
9010 {
9011 vos_pkt_walk_packet_chain( vosDataBuff, &vosNextDataBuff, 1/*true*/ );
9012 vos_pkt_get_user_data_ptr( vosDataBuff, VOS_PKT_USER_DATA_ID_TL,
Girish Gowli93e3edd2014-05-01 15:42:31 +05309013 (v_PVOID_t *)&STAMetaInfoPtr );
9014 wRxMetaInfo.ucUP = (v_U8_t)((uintptr_t)STAMetaInfoPtr & WLANTL_AC_MASK);
9015 ucDesSTAId = (v_U8_t)(((uintptr_t)STAMetaInfoPtr) >> WLANTL_STAID_OFFSET);
Jeff Johnson295189b2012-06-20 16:38:30 -07009016
9017 vosStatus = vos_pkt_extract_data( vosDataBuff, 0, (v_VOID_t *)pDestMacAddress, &usMacAddSize);
9018 if ( VOS_STATUS_SUCCESS != vosStatus )
9019 {
9020 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Arif Hussainf2b00992013-11-17 21:46:15 -08009021 "WLAN TL: recv corrupted data packet"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009022 vos_pkt_return_packet(vosDataBuff);
9023 return vosStatus;
9024 }
9025
Arif Hussaina7c8e412013-11-20 11:06:42 -08009026 TLLOG4(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_LOW,
9027 "station mac "MAC_ADDRESS_STR,
9028 MAC_ADDR_ARRAY(pDestMacAddress->bytes)));
Jeff Johnson295189b2012-06-20 16:38:30 -07009029
9030 if (vos_is_macaddr_broadcast( pDestMacAddress ) || vos_is_macaddr_group(pDestMacAddress))
9031 {
9032 // destination is mc/bc station
9033 ucDesSTAId = WLAN_RX_BCMC_STA_ID;
9034 TLLOG4(VOS_TRACE( VOS_MODULE_ID_HDD_SOFTAP, VOS_TRACE_LEVEL_INFO_LOW,
Arif Hussainf2b00992013-11-17 21:46:15 -08009035 "%s: BC/MC packet, id %d", __func__, WLAN_RX_BCMC_STA_ID));
Jeff Johnson295189b2012-06-20 16:38:30 -07009036 }
9037 else
9038 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309039 if (vos_is_macaddr_equal(pDestMacAddress, &pClientSTA->wSTADesc.vSelfMACAddress))
Jeff Johnson295189b2012-06-20 16:38:30 -07009040 {
9041 // destination is AP itself
9042 ucDesSTAId = WLAN_RX_SAP_SELF_STA_ID;
9043 TLLOG4(VOS_TRACE( VOS_MODULE_ID_HDD_SOFTAP, VOS_TRACE_LEVEL_INFO_LOW,
Arif Hussainf2b00992013-11-17 21:46:15 -08009044 "%s: packet to AP itself, id %d", __func__, WLAN_RX_SAP_SELF_STA_ID));
Jeff Johnson295189b2012-06-20 16:38:30 -07009045 }
Madan Mohan Koyylamudi64258222013-01-30 14:35:10 +05309046 else if (( WLAN_MAX_STA_COUNT <= ucDesSTAId ) || (NULL != pTLCb->atlSTAClients[ucDesSTAId] && pTLCb->atlSTAClients[ucDesSTAId]->ucExists == 0))
Jeff Johnson295189b2012-06-20 16:38:30 -07009047 {
9048 // destination station is something else
9049 TLLOG4(VOS_TRACE( VOS_MODULE_ID_HDD_SOFTAP, VOS_TRACE_LEVEL_INFO_LOW,
Arif Hussainf2b00992013-11-17 21:46:15 -08009050 "%s: get an station index larger than WLAN_MAX_STA_COUNT %d", __func__, ucDesSTAId));
Jeff Johnson295189b2012-06-20 16:38:30 -07009051 ucDesSTAId = WLAN_RX_SAP_SELF_STA_ID;
9052 }
9053
9054
9055 //loopback unicast station comes here
9056 }
9057
Girish Gowli93e3edd2014-05-01 15:42:31 +05309058 wRxMetaInfo.ucUP = (v_U8_t)((uintptr_t)STAMetaInfoPtr & WLANTL_AC_MASK);
Jeff Johnson295189b2012-06-20 16:38:30 -07009059 wRxMetaInfo.ucDesSTAId = ucDesSTAId;
9060
Madan Mohan Koyyalamudi6c2977d2013-09-04 15:42:45 +05309061 vosStatus = pClientSTA->pfnSTARx( pvosGCtx, vosDataBuff, ucDesSTAId,
Jeff Johnson295189b2012-06-20 16:38:30 -07009062 &wRxMetaInfo );
Madan Mohan Koyyalamudi6c2977d2013-09-04 15:42:45 +05309063 if ( VOS_STATUS_SUCCESS != vosStatus )
9064 {
9065 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Arif Hussainf2b00992013-11-17 21:46:15 -08009066 "WLAN TL: failed to send pkt to HDD"));
Madan Mohan Koyyalamudi6c2977d2013-09-04 15:42:45 +05309067 vos_pkt_return_packet(vosDataBuff);
9068
9069 return vosStatus;
9070 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009071 vosDataBuff = vosNextDataBuff;
9072 }
9073 return VOS_STATUS_SUCCESS;
9074}
Jeff Johnson295189b2012-06-20 16:38:30 -07009075
Kapil Guptad90b3862016-06-25 00:42:49 +05309076#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
9077void WLANTL_StopRxRateMonitor(v_PVOID_t pvosGCtx)
9078{
9079 WLANTL_CbType *pTLCb = VOS_GET_TL_CB(pvosGCtx);
9080 if (!pTLCb)
9081 return;
9082 pTLCb->gDsRxRoamStats.running = eWLAN_PAL_FALSE;
9083}
9084
9085void WLANTL_StartRxRateMonitor(v_PVOID_t pvosGCtx, v_U8_t staId,
9086 v_U16_t minRate,
9087 v_U16_t maxRate, v_U8_t minPercentage,
9088 v_U16_t minPktRequired, void *hHal,
9089 v_U64_t timeToWait,
9090 void (*triggerRoamScanfn) (void *, v_U8_t))
9091{
9092
9093 WLANTL_CbType *pTLCb = VOS_GET_TL_CB(pvosGCtx);
9094 if (!pTLCb)
9095 return;
9096
9097 pTLCb->gDsRxRoamStats.running = eWLAN_PAL_TRUE;
9098 pTLCb->gDsRxRoamStats.index = 0;
9099 pTLCb->gDsRxRoamStats.lastTriggerTime = jiffies_to_msecs(jiffies);
9100 pTLCb->gDsRxRoamStats.maxRate = maxRate;
9101 pTLCb->gDsRxRoamStats.minRate = minRate;
9102 pTLCb->gDsRxRoamStats.staId = staId;
9103 pTLCb->gDsRxRoamStats.minPercentage = minPercentage;
9104 pTLCb->gDsRxRoamStats.timeToWait = timeToWait * 1000;
9105 pTLCb->gDsRxRoamStats.intialPktToStart = 0;
9106 pTLCb->gDsRxRoamStats.minPktRequired = minPktRequired;
9107 pTLCb->gDsRxRoamStats.triggerRoamScanfn = triggerRoamScanfn;
9108 pTLCb->gDsRxRoamStats.hHal = hHal;
9109 vos_mem_zero(pTLCb->gDsRxRoamStats.rxRoamStats, ROAM_MAX_INDEX_NUM *
9110 sizeof(WLANTL_RoamTrafficStatsType));
9111 VOS_TRACE(VOS_MODULE_ID_WDI, VOS_TRACE_LEVEL_DEBUG,
9112 "staId=%d, minRate=%d maxRate=%d minPercentage=%d minPktRequired=%d",
9113 staId, minRate, maxRate, minPercentage, minPktRequired);
9114}
9115
9116void static WLANTL_ClearAllRoamStats(WLANTL_CbType *pTLCb)
9117{
9118 pTLCb->gDsRxRoamStats.index = 0;
9119 pTLCb->gDsRxRoamStats.totalPkt = 0;
9120 pTLCb->gDsRxRoamStats.lowRatePkt = 0;
9121 pTLCb->gDsRxRoamStats.intialPktToStart = 0;
9122 vos_mem_zero(pTLCb->gDsRxRoamStats.rxRoamStats, ROAM_MAX_INDEX_NUM *
9123 sizeof(WLANTL_RoamTrafficStatsType));
9124}
9125
9126/*
9127 * WLANTL_ClearRoamStatsTillIndex : This API will clear older data
9128 * at the indexes.
9129 *
9130 * Since its a circular buffer we don't know if we are filling
9131 * data first time or some older data was already present at
9132 * the index. In that case we should clear the older data from
9133 * current index to new index and subtract this data from
9134 * global count as well before filling new one.
9135 */
9136static inline void WLANTL_ClearRoamStatsTillIndex(WLANTL_CbType *pTLCb,
9137 v_U8_t newIndex)
9138{
9139 while (pTLCb->gDsRxRoamStats.index < newIndex)
9140 {
9141 pTLCb->gDsRxRoamStats.index++;
9142 pTLCb->gDsRxRoamStats.totalPkt -=
9143 pTLCb->gDsRxRoamStats.
9144 rxRoamStats[pTLCb->gDsRxRoamStats.index].totalPktRcvd;
9145 pTLCb->gDsRxRoamStats.lowRatePkt -=
9146 pTLCb->gDsRxRoamStats.
9147 rxRoamStats[pTLCb->gDsRxRoamStats.index].lowRateRxPacketsRcvd;
9148 pTLCb->gDsRxRoamStats.
9149 rxRoamStats[pTLCb->gDsRxRoamStats.index].totalPktRcvd = 0;
9150 pTLCb->gDsRxRoamStats.
9151 rxRoamStats[pTLCb->gDsRxRoamStats.index].lowRateRxPacketsRcvd = 0;
9152 }
9153}
9154
9155
9156static void WLANTL_ClearOldPERStats(WLANTL_CbType *pTLCb, v_U8_t incrementCnt)
9157{
9158 v_U8_t newIndex;
9159
9160 newIndex = (pTLCb->gDsRxRoamStats.index + incrementCnt) %
9161 ROAM_MAX_INDEX_NUM;
9162
9163 /* We have crossed the max limit of buffer, clear the stats
9164 * till ROAM_MAX_INDEX_NUM and set index as 0 */
9165 if ((pTLCb->gDsRxRoamStats.index + incrementCnt) >=
9166 ROAM_MAX_INDEX_NUM)
9167 {
9168 WLANTL_ClearRoamStatsTillIndex(pTLCb, ROAM_MAX_INDEX_NUM - 1);
9169 pTLCb->gDsRxRoamStats.index = -1;
9170 }
9171 /* Clear the stats from current index till new index */
9172 WLANTL_ClearRoamStatsTillIndex(pTLCb, newIndex);
9173}
9174
9175/*
9176 * This API implements a circular buffer to store rate stats for a station to
9177 * trigger PER based roam scan.
9178 * API will start monitoring only if DUT gets continues packets which are below
9179 * configured rate. In the upper rates, this should have minimal effect on data
9180 * throughput.
9181 *
9182 * This API will store stats in a circular buffer of size ROAM_MAX_INDEX_NUM
9183 * where each index will have time duration of ROAM_PER_INDEX_TIME.
9184 * Using a buffer instead of counter will help to maintain stats of time
9185 * duration ROAM_PER_INDEX_TIME * ROAM_MAX_INDEX_NUM. Whenever host gets a new
9186 * packet, it will remove last ROAM_PER_INDEX_TIME duration of packets from
9187 * global entry and index entry and fill new data.
9188 *
9189 * Global stats of data also be maintained so that host need not to parse whole
9190 * buffer while checking the trigger condition
9191 * Each of the index will be having the packets stats at duration of
9192 * ROAM_PER_INDEX_TIME from the first packet which arrived in that.
9193 * Global index will be used to calculate new index position to fill once host
9194 * gets a packet.
9195 */
9196static void WLANTL_updatePERStats(WLANTL_CbType *pTLCb,
9197 v_U8_t rateIndex)
9198{
Sravan Kumar Kairamd634cc92016-08-26 16:36:09 +05309199 v_U8_t incrementCnt = 0;
Kapil Guptad90b3862016-06-25 00:42:49 +05309200 v_U64_t currentTime, timeDifference;
9201
9202 /*
9203 * Host will start monitoring Rx rates only if it gets
9204 * MIN_PKTS_TO_START_MONTIOR number of pkts continuously below min rate
9205 * This will make sure we never do this much processing in high
9206 * rates/throughput cases
9207 */
9208
9209 if(pTLCb->gDsRxRoamStats.intialPktToStart < MIN_PKTS_TO_START_MONTIOR)
9210 {
9211 if (gTLRateInfo[rateIndex].phyRate < pTLCb->gDsRxRoamStats.minRate)
9212 pTLCb->gDsRxRoamStats.intialPktToStart++;
9213 else
9214 pTLCb->gDsRxRoamStats.intialPktToStart = 0;
9215 return;
9216 }
9217
9218 currentTime = jiffies_to_msecs(jiffies);
9219 /*
9220 * scan was triggered in last timeToWait time duration
9221 * Wait for timeToWait before monitoring again.
9222 */
9223 if((currentTime - pTLCb->gDsRxRoamStats.lastTriggerTime) <
9224 pTLCb->gDsRxRoamStats.timeToWait)
9225 return;
9226
9227 /* paket above max rate, clear current stats and montior again */
9228 if (gTLRateInfo[rateIndex].phyRate >=
9229 pTLCb->gDsRxRoamStats.maxRate)
9230 {
9231 WLANTL_ClearAllRoamStats(pTLCb);
9232 /* Stop any PER based scan if going on */
9233 pTLCb->gDsRxRoamStats.
9234 triggerRoamScanfn(pTLCb->gDsRxRoamStats.hHal, 0);
9235 return;
9236 }
9237
9238 timeDifference = currentTime -
9239 pTLCb->gDsRxRoamStats.rxRoamStats[pTLCb->gDsRxRoamStats.index].time;
9240
9241 if (timeDifference)
Kapil Guptafe5d92a2016-07-12 18:05:24 +05309242 incrementCnt = do_div(timeDifference, ROAM_PER_INDEX_TIME);
Kapil Guptad90b3862016-06-25 00:42:49 +05309243
9244 /* More that ROAM_PER_INDEX_TIME has esclapsed,
9245 * fill data at new index */
9246 if (incrementCnt)
9247 {
9248 if (incrementCnt > ROAM_MAX_INDEX_NUM)
9249 {
9250 /*
9251 * Clear all stats, these are older than
9252 * ROAM_MAX_INDEX_NUM * ROAM_PER_INDEX_TIME (Max buffer time)
9253 */
9254 WLANTL_ClearAllRoamStats(pTLCb);
9255 pTLCb->gDsRxRoamStats.index = 0;
9256 }
9257 else
9258 WLANTL_ClearOldPERStats(pTLCb, incrementCnt);
9259
9260 pTLCb->gDsRxRoamStats.rxRoamStats
9261 [pTLCb->gDsRxRoamStats.index].time = currentTime;
9262 }
9263
9264 /* If pkt rate below minRate, increment low pkts counts */
9265 if (gTLRateInfo[rateIndex].phyRate <
9266 pTLCb->gDsRxRoamStats.minRate)
9267 {
9268 pTLCb->gDsRxRoamStats.
9269 rxRoamStats[pTLCb->gDsRxRoamStats.index].
9270 lowRateRxPacketsRcvd++;
9271 pTLCb->gDsRxRoamStats.lowRatePkt++;
9272 }
9273 /* Increment total pkts counts */
9274 pTLCb->gDsRxRoamStats.
9275 rxRoamStats[pTLCb->gDsRxRoamStats.index].totalPktRcvd++;
9276 pTLCb->gDsRxRoamStats.totalPkt++;
9277
9278 /* Check if we have reached threshold value to trigger a roam scan */
9279 if ((pTLCb->gDsRxRoamStats.totalPkt != 0) &&
9280 (pTLCb->gDsRxRoamStats.totalPkt >
9281 pTLCb->gDsRxRoamStats.minPktRequired)&&
Kapil Guptafe5d92a2016-07-12 18:05:24 +05309282 ((pTLCb->gDsRxRoamStats.lowRatePkt * 100) >
9283 (pTLCb->gDsRxRoamStats.totalPkt *
9284 pTLCb->gDsRxRoamStats.minPercentage)))
Kapil Guptad90b3862016-06-25 00:42:49 +05309285 {
9286 /* callback handler to trigger a roam scan */
9287 if (pTLCb->gDsRxRoamStats.triggerRoamScanfn)
9288 pTLCb->gDsRxRoamStats.
9289 triggerRoamScanfn(pTLCb->gDsRxRoamStats.hHal, 1);
9290
9291 VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_DEBUG,
9292 "PER Roam: triggerring roam scan totalPkt =%lu lowRatePkt %lu minPktRequired %u minPercentage %d",
9293 (long unsigned int) pTLCb->gDsRxRoamStats.totalPkt,
9294 (long unsigned int) pTLCb->gDsRxRoamStats.lowRatePkt,
9295 (unsigned int) pTLCb->gDsRxRoamStats.minPktRequired,
9296 pTLCb->gDsRxRoamStats.minPercentage);
9297
9298 WLANTL_ClearAllRoamStats(pTLCb);
9299 /* save current time as last trigger time */
9300 pTLCb->gDsRxRoamStats.lastTriggerTime = currentTime;
9301 }
9302}
9303#endif
9304
Jeff Johnson295189b2012-06-20 16:38:30 -07009305/*==========================================================================
9306 FUNCTION WLANTL_STARxAuth
9307
9308 DESCRIPTION
9309 Receive in authenticated state - all data allowed
9310
9311 DEPENDENCIES
9312 The STA must be registered with TL before this function can be called.
9313
9314 PARAMETERS
9315
9316 IN
9317 pvosGCtx: pointer to the global vos context; a handle to TL's
9318 control block can be extracted from its context
9319 ucSTAId: identifier of the station being processed
9320 vosDataBuff: pointer to the rx vos buffer
9321
9322 RETURN VALUE
9323 The result code associated with performing the operation
9324
9325 VOS_STATUS_E_INVAL: invalid input parameters
9326 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
9327 page fault
9328 VOS_STATUS_SUCCESS: Everything is good :)
9329
9330 SIDE EFFECTS
9331
9332============================================================================*/
9333VOS_STATUS
9334WLANTL_STARxAuth
9335(
9336 v_PVOID_t pvosGCtx,
9337 v_U8_t ucSTAId,
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009338 vos_pkt_t** pvosDataBuff,
9339 v_BOOL_t bForwardIAPPwithLLC
Jeff Johnson295189b2012-06-20 16:38:30 -07009340)
9341{
9342 WLANTL_CbType* pTLCb = NULL;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309343 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07009344 v_U8_t ucAsf; /* AMSDU sub frame */
9345 v_U16_t usMPDUDOffset;
9346 v_U8_t ucMPDUHOffset;
9347 v_U16_t usMPDULen;
9348 v_U8_t ucMPDUHLen;
9349 v_U16_t usActualHLen = 0;
9350 v_U8_t ucTid;
Kapil Guptad90b3862016-06-25 00:42:49 +05309351#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
9352 v_U8_t rxRate;
9353 v_U8_t type;
9354#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009355#ifdef FEATURE_WLAN_WAPI
Jeff Johnsone0343db2013-04-03 16:39:24 -07009356 v_U16_t usEtherType = 0;
Abhishek Singh3c47c6c2015-06-15 11:36:08 +05309357 tSirMacMgmtHdr *hdr;
Jeff Johnson295189b2012-06-20 16:38:30 -07009358#endif
9359 v_U16_t usPktLen;
9360 vos_pkt_t* vosDataBuff ;
9361 v_PVOID_t aucBDHeader;
9362 VOS_STATUS vosStatus;
9363 WLANTL_RxMetaInfoType wRxMetaInfo;
Madan Mohan Koyyalamudidfd6aa82012-10-18 20:18:43 -07009364 static v_U8_t ucPMPDUHLen;
Girish Gowli93e3edd2014-05-01 15:42:31 +05309365 v_U32_t* STAMetaInfoPtr;
Jeff Johnson295189b2012-06-20 16:38:30 -07009366 v_U8_t ucEsf=0; /* first subframe of AMSDU flag */
9367 v_U64_t ullcurrentReplayCounter=0; /*current replay counter*/
9368 v_U64_t ullpreviousReplayCounter=0; /*previous replay counter*/
9369 v_U16_t ucUnicastBroadcastType=0; /*It denotes whether received frame is UC or BC*/
Madan Mohan Koyyalamudi4fe30172012-10-18 20:13:40 -07009370 struct _BARFrmStruct *pBarFrame = NULL;
9371
Jeff Johnson295189b2012-06-20 16:38:30 -07009372 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
9373
9374 /*------------------------------------------------------------------------
9375 Sanity check
9376 ------------------------------------------------------------------------*/
9377 if (( NULL == pvosDataBuff ) || ( NULL == ( vosDataBuff = *pvosDataBuff )))
9378 {
9379 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9380 "WLAN TL:Invalid parameter sent on WLANTL_STARxAuth"));
9381 return VOS_STATUS_E_INVAL;
9382 }
9383
9384 /*------------------------------------------------------------------------
9385 Extract TL control block
9386 ------------------------------------------------------------------------*/
9387 pTLCb = VOS_GET_TL_CB(pvosGCtx);
9388 if ( NULL == pTLCb )
9389 {
9390 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9391 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_STARxAuth"));
9392 return VOS_STATUS_E_FAULT;
9393 }
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309394 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
9395
9396 if ( NULL == pClientSTA )
9397 {
9398 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9399 "WLAN TL:Client Memory was not allocated on %s", __func__));
9400 return VOS_STATUS_E_FAILURE;
9401 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009402
9403 /*------------------------------------------------------------------------
9404 Extract BD header and check if valid
9405 ------------------------------------------------------------------------*/
9406 WDA_DS_PeekRxPacketInfo( vosDataBuff, (v_PVOID_t)&aucBDHeader, 0 );
9407
9408 ucMPDUHOffset = (v_U8_t)WDA_GET_RX_MPDU_HEADER_OFFSET(aucBDHeader);
9409 usMPDUDOffset = (v_U16_t)WDA_GET_RX_MPDU_DATA_OFFSET(aucBDHeader);
9410 usMPDULen = (v_U16_t)WDA_GET_RX_MPDU_LEN(aucBDHeader);
9411 ucMPDUHLen = (v_U8_t)WDA_GET_RX_MPDU_HEADER_LEN(aucBDHeader);
9412 ucTid = (v_U8_t)WDA_GET_RX_TID(aucBDHeader);
Kapil Guptad90b3862016-06-25 00:42:49 +05309413#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
9414 rxRate = (v_U8_t)WDA_GET_RX_MAC_RATE_IDX(aucBDHeader);
9415 type = (v_U8_t)WDA_GET_RX_TYPE(aucBDHeader);
9416#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009417
Madan Mohan Koyyalamudi4fe30172012-10-18 20:13:40 -07009418 /* Fix for a hardware bug.
9419 * H/W does not update the tid field in BD header for BAR frames.
9420 * Fix is to read the tid field from MAC header of BAR frame */
9421 if( (WDA_GET_RX_TYPE(aucBDHeader) == SIR_MAC_CTRL_FRAME) &&
9422 (WDA_GET_RX_SUBTYPE(aucBDHeader) == SIR_MAC_CTRL_BAR))
9423 {
9424 pBarFrame = (struct _BARFrmStruct *)(WDA_GET_RX_MAC_HEADER(aucBDHeader));
9425 ucTid = pBarFrame->barControl.numTID;
9426 }
9427
Jeff Johnson295189b2012-06-20 16:38:30 -07009428 /*Host based replay check is needed for unicast data frames*/
9429 ucUnicastBroadcastType = (v_U16_t)WDA_IS_RX_BCAST(aucBDHeader);
Jeff Johnson295189b2012-06-20 16:38:30 -07009430 if(0 != ucMPDUHLen)
9431 {
9432 ucPMPDUHLen = ucMPDUHLen;
9433 }
9434
9435 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
9436 "WLAN TL:BD header processing data: HO %d DO %d Len %d HLen %d"
9437 " Tid %d BD %d",
9438 ucMPDUHOffset, usMPDUDOffset, usMPDULen, ucMPDUHLen, ucTid,
9439 WLANHAL_RX_BD_HEADER_SIZE));
9440
9441 vos_pkt_get_packet_length( vosDataBuff, &usPktLen);
9442
9443 if ( VOS_STATUS_SUCCESS != WDA_DS_TrimRxPacketInfo( vosDataBuff ) )
9444 {
9445 if((WDA_GET_RX_ASF(aucBDHeader) && !WDA_GET_RX_ESF(aucBDHeader)))
9446 {
9447 /* AMSDU case, ucMPDUHOffset = 0
9448 * it should be hancdled seperatly */
9449 if(( usMPDUDOffset > ucMPDUHOffset ) &&
9450 ( usMPDULen >= ucMPDUHLen ) && ( usPktLen >= usMPDULen ) &&
9451 ( !WLANTL_TID_INVALID(ucTid) ))
9452 {
9453 ucMPDUHOffset = usMPDUDOffset - WLANTL_MPDU_HEADER_LEN;
9454 }
9455 else
9456 {
9457 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
9458 "WLAN TL:BD header corrupted - dropping packet"));
9459 /* Drop packet */
9460 vos_pkt_return_packet(vosDataBuff);
9461 return VOS_STATUS_SUCCESS;
9462 }
9463 }
9464 else
9465 {
9466 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
9467 "WLAN TL:BD header corrupted - dropping packet"));
9468 /* Drop packet */
9469 vos_pkt_return_packet(vosDataBuff);
9470 return VOS_STATUS_SUCCESS;
9471 }
9472 }
9473
Abhishek Singh00b71972016-01-07 10:51:04 +05309474#ifdef WLAN_FEATURE_RMC
9475 if (pTLCb->multicastDuplicateDetectionEnabled &&
9476 (WLAN_STA_IBSS == pClientSTA->wSTADesc.wSTAType) &&
9477 WLANTL_IS_DATA_FRAME(WDA_GET_RX_TYPE_SUBTYPE(aucBDHeader)))
9478 {
9479 /*
9480 * Multicast duplicate detection is only for frames received in
9481 * IBSS mode.
9482 */
9483 if (VOS_TRUE == WLANTL_IsDuplicateMcastFrm(pClientSTA, vosDataBuff))
9484 {
9485 pTLCb->mcastDupCnt++;
9486 /* Duplicate multicast data packet, drop the packet */
9487 vos_pkt_return_packet(vosDataBuff);
9488 return VOS_STATUS_SUCCESS;
9489 }
9490 }
9491#endif /* WLAN_FEATURE_RMC */
9492
Jeff Johnson295189b2012-06-20 16:38:30 -07009493#ifdef FEATURE_WLAN_WAPI
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309494 if ( pClientSTA->wSTADesc.ucIsWapiSta )
Jeff Johnson295189b2012-06-20 16:38:30 -07009495 {
9496 vosStatus = WLANTL_GetEtherType(aucBDHeader, vosDataBuff, ucMPDUHLen, &usEtherType);
9497 if( VOS_IS_STATUS_SUCCESS(vosStatus) )
9498 {
9499 if ( WLANTL_LLC_WAI_TYPE == usEtherType )
Abhishek Singh3c47c6c2015-06-15 11:36:08 +05309500 {
9501 hdr = WDA_GET_RX_MAC_HEADER(aucBDHeader);
9502 if ( hdr->fc.wep )
Jeff Johnson295189b2012-06-20 16:38:30 -07009503 {
9504 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9505 "WLAN TL:WAI frame was received encrypted - dropping"));
9506 /* Drop packet */
9507 /*Temporary fix added to fix wapi rekey issue*/
Abhishek Singh3c47c6c2015-06-15 11:36:08 +05309508 vos_pkt_return_packet(vosDataBuff);
9509 return vosStatus; //returning success
Jeff Johnson295189b2012-06-20 16:38:30 -07009510 }
9511 }
9512 else
9513 {
9514 if ( WLANHAL_RX_IS_UNPROTECTED_WPI_FRAME(aucBDHeader) )
9515 {
9516 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9517 "WLAN TL:Non-WAI frame was received unencrypted - dropping"));
9518 /* Drop packet */
9519 vos_pkt_return_packet(vosDataBuff);
9520 return vosStatus; //returning success
9521 }
9522 }
9523 }
9524 else //could not extract EtherType - this should not happen
9525 {
9526 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009527 "WLAN TL:Could not extract EtherType"));
9528 //Packet is already freed
Jeff Johnson295189b2012-06-20 16:38:30 -07009529 return vosStatus; //returning failure
Jeff Johnson295189b2012-06-20 16:38:30 -07009530 }
9531 }
9532#endif /* FEATURE_WLAN_WAPI */
9533
9534 /*----------------------------------------------------------------------
9535 Increment receive counter
9536 !! not sure this is the best place to increase this - pkt might be
9537 dropped below or delayed in TL's queues
9538 - will leave it here for now
9539 ------------------------------------------------------------------------*/
Madan Mohan Koyyalamudic0e5bd82012-09-18 17:12:27 -07009540 if ( !WLANTL_TID_INVALID( ucTid) )
9541 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309542 pClientSTA->auRxCount[ucTid]++;
Madan Mohan Koyyalamudic0e5bd82012-09-18 17:12:27 -07009543 }
9544 else
9545 {
9546 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9547 "WLAN TL:Invalid tid %d (Station ID %d) on %s",
9548 ucTid, ucSTAId, __func__));
Hanumantha Reddy Pothula0de10802016-02-11 17:29:27 +05309549 vos_pkt_return_packet(vosDataBuff);
9550 return VOS_STATUS_E_FAILURE;
Madan Mohan Koyyalamudic0e5bd82012-09-18 17:12:27 -07009551 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009552
Kapil Guptad90b3862016-06-25 00:42:49 +05309553#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
9554 if (pTLCb->gDsRxRoamStats.running &&
9555 (ucSTAId == pTLCb->gDsRxRoamStats.staId) &&
9556 (rxRate < WLANTL_MAX_RATE_NUM) && (type == SIR_MAC_DATA_FRAME))
9557 {
9558 WLANTL_updatePERStats(pTLCb, rxRate);
9559 }
9560#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009561 /*------------------------------------------------------------------------
9562 Check if AMSDU and send for processing if so
9563 ------------------------------------------------------------------------*/
9564 ucAsf = (v_U8_t)WDA_GET_RX_ASF(aucBDHeader);
9565
9566 if ( 0 != ucAsf )
9567 {
9568 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
9569 "WLAN TL:Packet is AMSDU sub frame - sending for completion"));
9570 vosStatus = WLANTL_AMSDUProcess( pvosGCtx, &vosDataBuff, aucBDHeader, ucSTAId,
9571 ucMPDUHLen, usMPDULen );
9572 if(NULL == vosDataBuff)
9573 {
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009574 //Packet is already freed
Jeff Johnson295189b2012-06-20 16:38:30 -07009575 return VOS_STATUS_SUCCESS;
9576 }
9577 }
9578 /* After AMSDU header handled
9579 * AMSDU frame just same with normal frames */
9580 /*-------------------------------------------------------------------
9581 Translating header if necesary
9582 !! Fix me: rmv comments below
9583 ----------------------------------------------------------------------*/
9584 if (( 0 == WDA_GET_RX_FT_DONE(aucBDHeader) ) &&
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309585 ( 0 != pClientSTA->wSTADesc.ucSwFrameRXXlation) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07009586 ( WLANTL_IS_DATA_FRAME(WDA_GET_RX_TYPE_SUBTYPE(aucBDHeader)) ))
9587 {
9588 if(0 == ucMPDUHLen)
9589 {
9590 ucMPDUHLen = ucPMPDUHLen;
9591 }
9592 if (usMPDUDOffset > ucMPDUHOffset)
9593 {
9594 usActualHLen = usMPDUDOffset - ucMPDUHOffset;
9595 }
9596 vosStatus = WLANTL_Translate80211To8023Header( vosDataBuff, &vosStatus, usActualHLen,
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009597 ucMPDUHLen, pTLCb, ucSTAId, bForwardIAPPwithLLC);
Jeff Johnson295189b2012-06-20 16:38:30 -07009598
9599 if ( VOS_STATUS_SUCCESS != vosStatus )
9600 {
Kaushik, Sushante386ee12014-05-01 15:50:52 +05309601 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
Jeff Johnson295189b2012-06-20 16:38:30 -07009602 "WLAN TL:Failed to translate from 802.11 to 802.3 - dropping"));
9603 /* Drop packet */
9604 vos_pkt_return_packet(vosDataBuff);
9605 return vosStatus;
9606 }
9607 }
9608 /* Softap requires additional Info such as Destination STAID and Access
9609 Category. Voschain or Buffer returned by BA would be unchain and this
9610 Meta Data would help in routing the packets to appropriate Destination */
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309611 if( WLAN_STA_SOFTAP == pClientSTA->wSTADesc.wSTAType)
Jeff Johnson295189b2012-06-20 16:38:30 -07009612 {
Arun Kumar Khandavalli37cfc222014-01-09 22:32:40 +05309613 STAMetaInfoPtr = (v_U32_t *)(uintptr_t)(ucTid | (WDA_GET_RX_ADDR3_IDX(aucBDHeader) << WLANTL_STAID_OFFSET));
Jeff Johnson295189b2012-06-20 16:38:30 -07009614 vos_pkt_set_user_data_ptr( vosDataBuff, VOS_PKT_USER_DATA_ID_TL,
9615 (v_PVOID_t)STAMetaInfoPtr);
9616 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009617
9618 /*------------------------------------------------------------------------
9619 Check to see if re-ordering session is in place
9620 ------------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309621 if ( 0 != pClientSTA->atlBAReorderInfo[ucTid].ucExists )
Jeff Johnson295189b2012-06-20 16:38:30 -07009622 {
9623 WLANTL_MSDUReorder( pTLCb, &vosDataBuff, aucBDHeader, ucSTAId, ucTid );
9624 }
9625
Jeff Johnson295189b2012-06-20 16:38:30 -07009626if(0 == ucUnicastBroadcastType
9627#ifdef FEATURE_ON_CHIP_REORDERING
9628 && (WLANHAL_IsOnChipReorderingEnabledForTID(pvosGCtx, ucSTAId, ucTid) != TRUE)
9629#endif
9630)
9631{
9632 /* replay check code : check whether replay check is needed or not */
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309633 if(VOS_TRUE == pClientSTA->ucIsReplayCheckValid)
Jeff Johnson295189b2012-06-20 16:38:30 -07009634 {
9635 /* replay check is needed for the station */
9636
9637 /* check whether frame is AMSDU frame */
9638 if ( 0 != ucAsf )
9639 {
9640 /* Since virgo can't send AMSDU frames this leg of the code
9641 was not tested properly, it needs to be tested properly*/
9642 /* Frame is AMSDU frame. As per 802.11n only first
9643 subframe will have replay counter */
9644 ucEsf = WDA_GET_RX_ESF( aucBDHeader );
9645 if( 0 != ucEsf )
9646 {
9647 v_BOOL_t status;
9648 /* Getting 48-bit replay counter from the RX BD */
9649 ullcurrentReplayCounter = WDA_DS_GetReplayCounter(aucBDHeader);
9650
9651 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Arif Hussainf2b00992013-11-17 21:46:15 -08009652 "WLAN TL: AMSDU currentReplayCounter [0x%llX]",ullcurrentReplayCounter);
Jeff Johnson295189b2012-06-20 16:38:30 -07009653
9654 /* Getting 48-bit previous replay counter from TL control block */
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309655 ullpreviousReplayCounter = pClientSTA->ullReplayCounter[ucTid];
Jeff Johnson295189b2012-06-20 16:38:30 -07009656
9657 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Arif Hussainf2b00992013-11-17 21:46:15 -08009658 "WLAN TL: AMSDU previousReplayCounter [0x%llX]",ullpreviousReplayCounter);
Jeff Johnson295189b2012-06-20 16:38:30 -07009659
9660 /* It is first subframe of AMSDU thus it
9661 conatains replay counter perform the
9662 replay check for this first subframe*/
9663 status = WLANTL_IsReplayPacket( ullcurrentReplayCounter, ullpreviousReplayCounter);
9664 if(VOS_FALSE == status)
9665 {
9666 /* Not a replay paket, update previous replay counter in TL CB */
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309667 pClientSTA->ullReplayCounter[ucTid] = ullcurrentReplayCounter;
Jeff Johnson295189b2012-06-20 16:38:30 -07009668 }
9669 else
9670 {
9671 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Arif Hussainf2b00992013-11-17 21:46:15 -08009672 "WLAN TL: AMSDU Drop the replay packet with PN : [0x%llX]",ullcurrentReplayCounter);
Jeff Johnson295189b2012-06-20 16:38:30 -07009673
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309674 pClientSTA->ulTotalReplayPacketsDetected++;
Jeff Johnson295189b2012-06-20 16:38:30 -07009675 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Arif Hussainf2b00992013-11-17 21:46:15 -08009676 "WLAN TL: AMSDU total dropped replay packets on STA ID %X is [0x%X]",
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309677 ucSTAId, pClientSTA->ulTotalReplayPacketsDetected);
Jeff Johnson295189b2012-06-20 16:38:30 -07009678
9679 /* Drop the packet */
9680 vos_pkt_return_packet(vosDataBuff);
9681 return VOS_STATUS_SUCCESS;
9682 }
9683 }
9684 }
9685 else
9686 {
9687 v_BOOL_t status;
9688
9689 /* Getting 48-bit replay counter from the RX BD */
9690 ullcurrentReplayCounter = WDA_DS_GetReplayCounter(aucBDHeader);
9691
9692 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Arif Hussainf2b00992013-11-17 21:46:15 -08009693 "WLAN TL: Non-AMSDU currentReplayCounter [0x%llX]",ullcurrentReplayCounter);
Jeff Johnson295189b2012-06-20 16:38:30 -07009694
9695 /* Getting 48-bit previous replay counter from TL control block */
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309696 ullpreviousReplayCounter = pClientSTA->ullReplayCounter[ucTid];
Jeff Johnson295189b2012-06-20 16:38:30 -07009697
9698 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Arif Hussainf2b00992013-11-17 21:46:15 -08009699 "WLAN TL: Non-AMSDU previousReplayCounter [0x%llX]",ullpreviousReplayCounter);
Jeff Johnson295189b2012-06-20 16:38:30 -07009700
9701 /* It is not AMSDU frame so perform
9702 reaply check for each packet, as
9703 each packet contains valid replay counter*/
9704 status = WLANTL_IsReplayPacket( ullcurrentReplayCounter, ullpreviousReplayCounter);
9705 if(VOS_FALSE == status)
9706 {
9707 /* Not a replay paket, update previous replay counter in TL CB */
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309708 pClientSTA->ullReplayCounter[ucTid] = ullcurrentReplayCounter;
Jeff Johnson295189b2012-06-20 16:38:30 -07009709 }
9710 else
9711 {
9712 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Arif Hussainf2b00992013-11-17 21:46:15 -08009713 "WLAN TL: Non-AMSDU Drop the replay packet with PN : [0x%llX]",ullcurrentReplayCounter);
Jeff Johnson295189b2012-06-20 16:38:30 -07009714
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309715 pClientSTA->ulTotalReplayPacketsDetected++;
Jeff Johnson295189b2012-06-20 16:38:30 -07009716 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Arif Hussainf2b00992013-11-17 21:46:15 -08009717 "WLAN TL: Non-AMSDU total dropped replay packets on STA ID %X is [0x%X]",
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309718 ucSTAId, pClientSTA->ulTotalReplayPacketsDetected);
Jeff Johnson295189b2012-06-20 16:38:30 -07009719
9720 /* Repaly packet, drop the packet */
9721 vos_pkt_return_packet(vosDataBuff);
9722 return VOS_STATUS_SUCCESS;
9723 }
9724 }
9725 }
9726}
9727/*It is a broadast packet DPU has already done replay check for
9728 broadcast packets no need to do replay check of these packets*/
Jeff Johnson295189b2012-06-20 16:38:30 -07009729
9730 if ( NULL != vosDataBuff )
9731 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309732 if( WLAN_STA_SOFTAP == pClientSTA->wSTADesc.wSTAType)
Jeff Johnson295189b2012-06-20 16:38:30 -07009733 {
9734 WLANTL_FwdPktToHDD( pvosGCtx, vosDataBuff, ucSTAId );
9735 }
9736 else
Jeff Johnson295189b2012-06-20 16:38:30 -07009737 {
9738 wRxMetaInfo.ucUP = ucTid;
Shailender Karmuchi13c0d082013-03-26 14:41:39 -07009739 wRxMetaInfo.rssiAvg = pClientSTA->rssiAvg;
Gopichand Nakkala4a2fc1a2013-05-17 16:59:39 +05309740#ifdef FEATURE_WLAN_TDLS
9741 if (WLAN_STA_TDLS == pClientSTA->wSTADesc.wSTAType)
9742 {
9743 wRxMetaInfo.isStaTdls = TRUE;
9744 }
9745 else
9746 {
9747 wRxMetaInfo.isStaTdls = FALSE;
9748 }
9749#endif
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309750 pClientSTA->pfnSTARx( pvosGCtx, vosDataBuff, ucSTAId,
Jeff Johnson295189b2012-06-20 16:38:30 -07009751 &wRxMetaInfo );
9752 }
9753 }/* if not NULL */
9754
9755 return VOS_STATUS_SUCCESS;
9756}/* WLANTL_STARxAuth */
9757
9758
9759/*==========================================================================
9760 FUNCTION WLANTL_STARxDisc
9761
9762 DESCRIPTION
9763 Receive in disconnected state - no data allowed
9764
9765 DEPENDENCIES
9766 The STA must be registered with TL before this function can be called.
9767
9768 PARAMETERS
9769
9770 IN
9771 pvosGCtx: pointer to the global vos context; a handle to TL's
9772 control block can be extracted from its context
9773 ucSTAId: identifier of the station being processed
9774 vosDataBuff: pointer to the rx vos buffer
9775
9776 RETURN VALUE
9777 The result code associated with performing the operation
9778
9779 VOS_STATUS_SUCCESS: Everything is good :)
9780
9781 SIDE EFFECTS
9782
9783============================================================================*/
9784VOS_STATUS
9785WLANTL_STARxDisc
9786(
9787 v_PVOID_t pvosGCtx,
9788 v_U8_t ucSTAId,
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009789 vos_pkt_t** pvosDataBuff,
9790 v_BOOL_t bForwardIAPPwithLLC
Jeff Johnson295189b2012-06-20 16:38:30 -07009791)
9792{
9793 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
9794
9795 /*------------------------------------------------------------------------
9796 Sanity check
9797 ------------------------------------------------------------------------*/
9798 if (( NULL == pvosDataBuff ) || ( NULL == *pvosDataBuff ))
9799 {
9800 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9801 "WLAN TL:Invalid parameter sent on WLANTL_STARxDisc"));
9802 return VOS_STATUS_E_INVAL;
9803 }
9804
9805 /*------------------------------------------------------------------------
9806 Error - drop packet
9807 ------------------------------------------------------------------------*/
9808 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9809 "WLAN TL:Packet should not be received in state disconnected"
9810 " - dropping"));
9811 vos_pkt_return_packet(*pvosDataBuff);
9812 *pvosDataBuff = NULL;
9813
9814 return VOS_STATUS_SUCCESS;
9815}/* WLANTL_STARxDisc */
9816
9817/*==========================================================================
9818 Processing main loops for MAIN and TX threads
9819 ==========================================================================*/
9820
9821/*==========================================================================
9822 FUNCTION WLANTL_McProcessMsg
9823
9824 DESCRIPTION
9825 Called by VOSS when a message was serialized for TL through the
9826 main thread/task.
9827
9828 DEPENDENCIES
9829 The TL must be initialized before this function can be called.
9830
9831 PARAMETERS
9832
9833 IN
9834 pvosGCtx: pointer to the global vos context; a handle to TL's
9835 control block can be extracted from its context
9836 message: type and content of the message
9837
9838
9839 RETURN VALUE
9840 The result code associated with performing the operation
9841
9842 VOS_STATUS_E_INVAL: invalid input parameters
9843 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
9844 page fault
9845 VOS_STATUS_SUCCESS: Everything is good :)
9846
9847 SIDE EFFECTS
9848
9849============================================================================*/
9850VOS_STATUS
9851WLANTL_McProcessMsg
9852(
9853 v_PVOID_t pvosGCtx,
9854 vos_msg_t* message
9855)
9856{
9857 WLANTL_CbType* pTLCb = NULL;
9858 tAddBAInd* ptAddBaInd = NULL;
9859 tDelBAInd* ptDelBaInd = NULL;
9860 tAddBARsp* ptAddBaRsp = NULL;
9861 vos_msg_t vosMessage;
9862 VOS_STATUS vosStatus;
9863 tpFlushACRsp FlushACRspPtr;
9864 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
9865
9866 /*------------------------------------------------------------------------
9867 Sanity check
9868 ------------------------------------------------------------------------*/
9869 if ( NULL == message )
9870 {
9871 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9872 "WLAN TL:Invalid parameter sent on WLANTL_ProcessMainMessage"));
9873 return VOS_STATUS_E_INVAL;
9874 }
9875
9876 /*------------------------------------------------------------------------
9877 Extract TL control block
9878 ------------------------------------------------------------------------*/
9879 pTLCb = VOS_GET_TL_CB(pvosGCtx);
9880 if ( NULL == pTLCb )
9881 {
9882 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9883 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_ProcessMainMessage"));
9884 return VOS_STATUS_E_FAULT;
9885 }
9886
9887 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
9888 "WLAN TL:Received message: %d through main flow", message->type));
9889
9890 switch( message->type )
9891 {
9892 case WDA_TL_FLUSH_AC_RSP:
9893 // Extract the message from the message body
9894 FlushACRspPtr = (tpFlushACRsp)(message->bodyptr);
9895 // Make sure the call back function is not null.
Tushnim Bhattacharyya5dd94562013-03-20 20:15:03 -07009896 if ( NULL == pTLCb->tlBAPClient.pfnFlushOpCompleteCb )
9897 {
9898 VOS_ASSERT(0);
9899 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9900 "WLAN TL:Invalid TL pointer pfnFlushOpCompleteCb"));
9901 return VOS_STATUS_E_FAULT;
9902 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009903
9904 TLLOG2(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
9905 "Received message: Flush complete received by TL"));
9906
9907 // Since we have the response back from HAL, just call the BAP client
9908 // registered call back from TL. There is only 1 possible
9909 // BAP client. So directly reference tlBAPClient
9910 pTLCb->tlBAPClient.pfnFlushOpCompleteCb( pvosGCtx,
9911 FlushACRspPtr->ucSTAId,
9912 FlushACRspPtr->ucTid, FlushACRspPtr->status );
9913
9914 // Free the PAL memory, we are done with it.
9915 TLLOG2(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
9916 "Flush complete received by TL: Freeing %p", FlushACRspPtr));
9917 vos_mem_free((v_VOID_t *)FlushACRspPtr);
9918 break;
9919
9920 case WDA_HDD_ADDBA_REQ:
9921 ptAddBaInd = (tAddBAInd*)(message->bodyptr);
9922 vosStatus = WLANTL_BaSessionAdd( pvosGCtx,
9923 ptAddBaInd->baSession.baSessionID,
9924 ptAddBaInd->baSession.STAID,
9925 ptAddBaInd->baSession.baTID,
9926 (v_U32_t)ptAddBaInd->baSession.baBufferSize,
9927 ptAddBaInd->baSession.winSize,
9928 ptAddBaInd->baSession.SSN);
9929 ptAddBaRsp = vos_mem_malloc(sizeof(*ptAddBaRsp));
9930
9931 if ( NULL == ptAddBaRsp )
9932 {
9933 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9934 "WLAN TL: fatal failure, cannot allocate BA Rsp structure"));
9935 VOS_ASSERT(0);
9936 return VOS_STATUS_E_NOMEM;
9937 }
9938
9939 if ( VOS_STATUS_SUCCESS == vosStatus )
9940 {
9941 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
9942 "WLAN TL: Sending success indication to HAL for ADD BA"));
9943 /*Send success*/
9944 ptAddBaRsp->mesgType = WDA_HDD_ADDBA_RSP;
9945 vosMessage.type = WDA_HDD_ADDBA_RSP;
9946 }
9947 else
9948 {
9949 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
9950 "WLAN TL: Sending failure indication to HAL for ADD BA"));
9951
9952 /*Send failure*/
9953 ptAddBaRsp->mesgType = WDA_BA_FAIL_IND;
9954 vosMessage.type = WDA_BA_FAIL_IND;
9955 }
9956
9957 ptAddBaRsp->mesgLen = sizeof(tAddBARsp);
9958 ptAddBaRsp->baSessionID = ptAddBaInd->baSession.baSessionID;
9959 /* This is default, reply win size has to be handled BA module, FIX THIS */
9960 ptAddBaRsp->replyWinSize = WLANTL_MAX_WINSIZE;
9961 vosMessage.bodyptr = ptAddBaRsp;
9962
9963 vos_mq_post_message( VOS_MQ_ID_WDA, &vosMessage );
9964 WLANTL_McFreeMsg (pvosGCtx, message);
9965 break;
9966 case WDA_DELETEBA_IND:
9967 ptDelBaInd = (tDelBAInd*)(message->bodyptr);
9968 vosStatus = WLANTL_BaSessionDel(pvosGCtx,
9969 ptDelBaInd->staIdx,
9970 ptDelBaInd->baTID);
9971
9972 if ( VOS_STATUS_SUCCESS != vosStatus )
9973 {
9974 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9975 "WLAN TL: Failed to del BA session STA:%d TID:%d Status :%d",
9976 ptDelBaInd->staIdx,
9977 ptDelBaInd->baTID,
9978 vosStatus));
9979 }
9980 WLANTL_McFreeMsg (pvosGCtx, message);
9981 break;
9982 default:
9983 /*no processing for now*/
9984 break;
9985 }
9986
9987 return VOS_STATUS_SUCCESS;
9988}/* WLANTL_ProcessMainMessage */
9989
9990/*==========================================================================
9991 FUNCTION WLANTL_McFreeMsg
9992
9993 DESCRIPTION
9994 Called by VOSS to free a given TL message on the Main thread when there
9995 are messages pending in the queue when the whole system is been reset.
9996 For now, TL does not allocate any body so this function shout translate
9997 into a NOOP
9998
9999 DEPENDENCIES
10000 The TL must be initialized before this function can be called.
10001
10002 PARAMETERS
10003
10004 IN
10005 pvosGCtx: pointer to the global vos context; a handle to TL's
10006 control block can be extracted from its context
10007 message: type and content of the message
10008
10009
10010 RETURN VALUE
10011 The result code associated with performing the operation
10012
10013 VOS_STATUS_SUCCESS: Everything is good :)
10014
10015 SIDE EFFECTS
10016
10017============================================================================*/
10018VOS_STATUS
10019WLANTL_McFreeMsg
10020(
10021 v_PVOID_t pvosGCtx,
10022 vos_msg_t* message
10023)
10024{
10025 WLANTL_CbType* pTLCb = NULL;
10026 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
10027
10028 /*------------------------------------------------------------------------
10029 Sanity check
10030 ------------------------------------------------------------------------*/
10031 if ( NULL == message )
10032 {
10033 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
10034 "WLAN TL:Invalid parameter sent on WLANTL_McFreeMsg"));
10035 return VOS_STATUS_E_INVAL;
10036 }
10037
10038 /*------------------------------------------------------------------------
10039 Extract TL control block
10040 ------------------------------------------------------------------------*/
10041 pTLCb = VOS_GET_TL_CB(pvosGCtx);
10042 if ( NULL == pTLCb )
10043 {
10044 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
10045 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_McFreeMsg"));
10046 return VOS_STATUS_E_FAULT;
10047 }
10048
10049 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
10050 "WLAN TL:Received message: %d through main free", message->type));
10051
10052 switch( message->type )
10053 {
10054 case WDA_HDD_ADDBA_REQ:
10055 case WDA_DELETEBA_IND:
10056 /*vos free body pointer*/
10057 vos_mem_free(message->bodyptr);
10058 message->bodyptr = NULL;
10059 break;
10060 default:
10061 /*no processing for now*/
10062 break;
10063 }
10064
10065 return VOS_STATUS_SUCCESS;
10066}/*WLANTL_McFreeMsg*/
10067
10068/*==========================================================================
10069 FUNCTION WLANTL_TxProcessMsg
10070
10071 DESCRIPTION
10072 Called by VOSS when a message was serialized for TL through the
10073 tx thread/task.
10074
10075 DEPENDENCIES
10076 The TL must be initialized before this function can be called.
10077
10078 PARAMETERS
10079
10080 IN
10081 pvosGCtx: pointer to the global vos context; a handle to TL's
10082 control block can be extracted from its context
10083 message: type and content of the message
10084
10085
10086 RETURN VALUE
10087 The result code associated with performing the operation
10088
10089 VOS_STATUS_E_INVAL: invalid input parameters
10090 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
10091 page fault
10092 VOS_STATUS_SUCCESS: Everything is good :)
10093
10094 Other values can be returned as a result of a function call, please check
10095 corresponding API for more info.
10096 SIDE EFFECTS
10097
10098============================================================================*/
10099VOS_STATUS
10100WLANTL_TxProcessMsg
10101(
10102 v_PVOID_t pvosGCtx,
10103 vos_msg_t* message
10104)
10105{
10106 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070010107 void (*callbackRoutine) (void *callbackContext);
10108 void *callbackContext;
Jeff Johnson295189b2012-06-20 16:38:30 -070010109 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
10110
10111 /*------------------------------------------------------------------------
10112 Sanity check
10113 ------------------------------------------------------------------------*/
10114 if ( NULL == message )
10115 {
10116 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
10117 "WLAN TL:Invalid parameter sent on WLANTL_ProcessTxMessage"));
10118 return VOS_STATUS_E_INVAL;
10119 }
10120
10121 /*------------------------------------------------------------------------
10122 Process message
10123 ------------------------------------------------------------------------*/
10124 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
10125 "WLAN TL:Received message: %d through tx flow", message->type));
10126
10127 switch( message->type )
10128 {
10129 case WLANTL_TX_SIG_SUSPEND:
10130 vosStatus = WLANTL_SuspendCB( pvosGCtx,
10131 (WLANTL_SuspendCBType)message->bodyptr,
10132 message->reserved);
10133 break;
10134 case WLANTL_TX_RES_NEEDED:
10135 vosStatus = WLANTL_GetTxResourcesCB( pvosGCtx );
10136 break;
Katya Nigam664f5032014-05-05 12:24:32 +053010137
Jeff Johnson295189b2012-06-20 16:38:30 -070010138 case WDA_DS_TX_START_XMIT:
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +053010139 WLANTL_ClearTxXmitPending(pvosGCtx);
10140 vosStatus = WDA_DS_TxFrames( pvosGCtx );
Jeff Johnson295189b2012-06-20 16:38:30 -070010141 break;
10142
10143 case WDA_DS_FINISH_ULA:
Arun Kumar Khandavalli8d1979d2014-01-09 21:12:25 +053010144 callbackContext = message->bodyptr;
10145 callbackRoutine = message->callback;
10146 if ( NULL != callbackRoutine )
10147 {
10148 callbackRoutine(callbackContext);
10149 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010150 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010151
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +053010152 case WLANTL_TX_SNAPSHOT:
10153 /*Dumping TL State and then continuing to print
10154 the DXE Dump*/
10155 WLANTL_TxThreadDebugHandler(pvosGCtx);
10156 WDA_TransportChannelDebug(NULL, VOS_TRUE, VOS_FALSE);
10157 break;
10158
Mihir Shetefd62d9d2014-08-06 15:08:21 +053010159 case WLANTL_TX_FATAL_ERROR:
10160 WLANTL_FatalErrorHandler(pvosGCtx);
10161 break;
10162
Mihir Shete327c2ab2014-11-13 15:17:02 +053010163 case WLANTL_TX_FW_DEBUG:
Siddharth Bhal68115602015-01-18 20:44:55 +053010164 vos_fwDumpReq(274, 0, 0, 0, 0, 1); //Async event
Mihir Shete327c2ab2014-11-13 15:17:02 +053010165 break;
10166
Sravan Kumar Kairame9d186c2015-11-27 23:37:02 +053010167 case WLANTL_TX_KICKDXE:
10168 WDA_TransportKickDxe();
10169 break;
10170
Jeff Johnson295189b2012-06-20 16:38:30 -070010171 default:
10172 /*no processing for now*/
10173 break;
10174 }
10175
10176 return vosStatus;
10177}/* WLANTL_TxProcessMsg */
10178
10179/*==========================================================================
10180 FUNCTION WLANTL_McFreeMsg
10181
10182 DESCRIPTION
10183 Called by VOSS to free a given TL message on the Main thread when there
10184 are messages pending in the queue when the whole system is been reset.
10185 For now, TL does not allocate any body so this function shout translate
10186 into a NOOP
10187
10188 DEPENDENCIES
10189 The TL must be initialized before this function can be called.
10190
10191 PARAMETERS
10192
10193 IN
10194 pvosGCtx: pointer to the global vos context; a handle to TL's
10195 control block can be extracted from its context
10196 message: type and content of the message
10197
10198
10199 RETURN VALUE
10200 The result code associated with performing the operation
10201
10202 VOS_STATUS_SUCCESS: Everything is good :)
10203
10204 SIDE EFFECTS
10205
10206============================================================================*/
10207VOS_STATUS
10208WLANTL_TxFreeMsg
10209(
10210 v_PVOID_t pvosGCtx,
10211 vos_msg_t* message
10212)
10213{
10214 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
10215
10216 /*Nothing to do for now!!!*/
10217 return VOS_STATUS_SUCCESS;
10218}/*WLANTL_TxFreeMsg*/
10219
Jeff Johnson295189b2012-06-20 16:38:30 -070010220/*==========================================================================
10221
10222 FUNCTION WLANTL_TxFCFrame
10223
10224 DESCRIPTION
10225 Internal utility function to send FC frame. Enable
10226 or disable LWM mode based on the information.
10227
10228 DEPENDENCIES
10229 TL must be initiailized before this function gets called.
10230 FW sends up special flow control frame.
10231
10232 PARAMETERS
10233
10234 IN
10235 pvosGCtx: pointer to the global vos context; a handle to TL's
10236 control block can be extracted from its context
10237
10238 RETURN VALUE
10239 The result code associated with performing the operation
10240
10241 VOS_STATUS_E_INVAL: Input pointers are NULL.
10242 VOS_STATUS_E_FAULT: Something is wrong.
10243 VOS_STATUS_SUCCESS: Everything is good.
10244
10245 SIDE EFFECTS
10246 Newly formed FC frame is generated and waits to be transmitted. Previously unsent frame will
10247 be released.
10248
10249============================================================================*/
10250VOS_STATUS
10251WLANTL_TxFCFrame
10252(
10253 v_PVOID_t pvosGCtx
10254)
10255{
10256#if 0
10257 WLANTL_CbType* pTLCb = NULL;
10258 VOS_STATUS vosStatus;
10259 tpHalFcTxBd pvFcTxBd = NULL;
10260 vos_pkt_t * pPacket = NULL;
10261 v_U8_t ucSTAId = 0;
10262 v_U8_t ucBitCheck = 1;
10263
10264 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070010265 "WLAN TL: Send FC frame %s", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070010266
10267 /*------------------------------------------------------------------------
10268 Sanity check
10269 ------------------------------------------------------------------------*/
10270 if ( NULL == pvosGCtx )
10271 {
10272 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070010273 "WLAN TL:Invalid parameter %s", __func__));
Jeff Johnson295189b2012-06-20 16:38:30 -070010274 return VOS_STATUS_E_INVAL;
10275 }
10276 /*------------------------------------------------------------------------
10277 Extract TL control block
10278 ------------------------------------------------------------------------*/
10279 pTLCb = VOS_GET_TL_CB(pvosGCtx);
10280
10281 if (NULL == pTLCb)
10282 {
10283 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070010284 "WLAN TL:Invalid pointer in %s \n", __func__));
Jeff Johnson295189b2012-06-20 16:38:30 -070010285 return VOS_STATUS_E_INVAL;
10286 }
10287
10288 //Get one voss packet
10289 vosStatus = vos_pkt_get_packet( &pPacket, VOS_PKT_TYPE_TX_802_11_MGMT, sizeof(tHalFcTxBd), 1,
10290 VOS_FALSE, NULL, NULL );
10291
10292 if ( VOS_STATUS_SUCCESS != vosStatus )
10293 {
10294 return VOS_STATUS_E_INVAL;
10295 }
10296
10297 vosStatus = vos_pkt_reserve_head( pPacket, (void *)&pvFcTxBd, sizeof(tHalFcTxBd));
10298
10299 if( VOS_STATUS_SUCCESS != vosStatus )
10300 {
10301 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070010302 "%s: failed to reserve FC TX BD %d\n",__func__, sizeof(tHalFcTxBd)));
Jeff Johnson295189b2012-06-20 16:38:30 -070010303 vos_pkt_return_packet( pPacket );
10304 return VOS_STATUS_E_FAULT;
10305 }
10306
10307 //Generate most recent tlFCInfo. Most fields are correct.
10308 pTLCb->tlFCInfo.fcSTAThreshEnabledMask = 0;
10309 pTLCb->tlFCInfo.fcSTATxMoreDataMask = 0;
10310 for( ucSTAId = 0, ucBitCheck = 1 ; ucSTAId < WLAN_MAX_STA_COUNT; ucBitCheck <<= 1, ucSTAId ++)
10311 {
10312 if (0 == pTLCb->atlSTAClients[ucSTAId].ucExists)
10313 {
10314 continue;
10315 }
10316
10317 if (pTLCb->atlSTAClients[ucSTAId].ucPktPending)
10318 {
10319 pTLCb->tlFCInfo.fcSTATxMoreDataMask |= ucBitCheck;
10320 }
10321
10322 if ( (pTLCb->atlSTAClients[ucSTAId].ucLwmModeEnabled) &&
10323 (pTLCb->atlSTAClients[ucSTAId].bmuMemConsumed > pTLCb->atlSTAClients[ucSTAId].uLwmThreshold))
10324 {
10325 pTLCb->tlFCInfo.fcSTAThreshEnabledMask |= ucBitCheck;
10326
10327 pTLCb->tlFCInfo.fcSTAThresh[ucSTAId] = (tANI_U8)pTLCb->atlSTAClients[ucSTAId].uLwmThreshold;
10328
10329 pTLCb->atlSTAClients[ucSTAId].ucLwmEventReported = FALSE;
10330 }
10331
10332 }
10333
10334 //request immediate feedback
10335 pTLCb->tlFCInfo.fcConfig |= 0x4;
10336
10337 //fill in BD to sent
10338 vosStatus = WLANHAL_FillFcTxBd(pvosGCtx, &pTLCb->tlFCInfo, (void *)pvFcTxBd);
10339
10340 if( VOS_STATUS_SUCCESS != vosStatus )
10341 {
10342 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070010343 "%s: Fill FC TX BD unsuccessful\n", __func__));
Jeff Johnson295189b2012-06-20 16:38:30 -070010344 vos_pkt_return_packet( pPacket );
10345 return VOS_STATUS_E_FAULT;
10346 }
10347
10348 if (NULL != pTLCb->vosTxFCBuf)
10349 {
10350 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070010351 "%s: Previous FC TX BD not sent\n", __func__));
Jeff Johnson295189b2012-06-20 16:38:30 -070010352 vos_pkt_return_packet(pTLCb->vosTxFCBuf);
10353 }
10354
10355 pTLCb->vosTxFCBuf = pPacket;
10356
10357 vos_pkt_set_user_data_ptr( pPacket, VOS_PKT_USER_DATA_ID_TL,
10358 (v_PVOID_t)WLANTL_TxCompDefaultCb);
10359 vosStatus = WDA_DS_StartXmit(pvosGCtx);
10360
10361 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070010362 "WLAN TL: send FC frame leave %s", __func__));
Jeff Johnson295189b2012-06-20 16:38:30 -070010363#endif
10364 return VOS_STATUS_SUCCESS;
10365}
10366
Jeff Johnson295189b2012-06-20 16:38:30 -070010367
10368/*==========================================================================
10369 FUNCTION WLANTL_GetTxResourcesCB
10370
10371 DESCRIPTION
10372 Processing function for Resource needed signal. A request will be issued
10373 to BAL to get more tx resources.
10374
10375 DEPENDENCIES
10376 The TL must be initialized before this function can be called.
10377
10378 PARAMETERS
10379
10380 IN
10381 pvosGCtx: pointer to the global vos context; a handle to TL's
10382 control block can be extracted from its context
10383
10384
10385 RETURN VALUE
10386 The result code associated with performing the operation
10387
10388 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
10389 page fault
10390 VOS_STATUS_SUCCESS: Everything is good :)
10391
10392 Other values can be returned as a result of a function call, please check
10393 corresponding API for more info.
10394 SIDE EFFECTS
10395
10396============================================================================*/
10397VOS_STATUS
10398WLANTL_GetTxResourcesCB
10399(
10400 v_PVOID_t pvosGCtx
10401)
10402{
10403 WLANTL_CbType* pTLCb = NULL;
10404 v_U32_t uResCount = WDA_TLI_MIN_RES_DATA;
10405 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
10406 v_U8_t ucMgmt = 0;
10407 v_U8_t ucBAP = 0;
10408 v_U8_t ucData = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070010409#ifdef WLAN_SOFTAP_FLOWCTRL_EN
10410 tBssSystemRole systemRole;
10411 tpAniSirGlobal pMac;
10412#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010413 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
10414 /*------------------------------------------------------------------------
10415 Extract TL control block
10416 ------------------------------------------------------------------------*/
10417 pTLCb = VOS_GET_TL_CB(pvosGCtx);
10418 if ( NULL == pTLCb )
10419 {
10420 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
10421 "WLAN TL:Invalid TL pointer from pvosGCtx on"
10422 " WLANTL_ProcessTxMessage"));
10423 return VOS_STATUS_E_FAULT;
10424 }
10425
10426 /*------------------------------------------------------------------------
10427 Get tx resources from BAL
10428 ------------------------------------------------------------------------*/
10429 vosStatus = WDA_DS_GetTxResources( pvosGCtx, &uResCount );
10430
10431 if ( (VOS_STATUS_SUCCESS != vosStatus) && (VOS_STATUS_E_RESOURCES != vosStatus))
10432 {
10433 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
10434 "WLAN TL:TL failed to get resources from BAL, Err: %d",
10435 vosStatus));
10436 return vosStatus;
10437 }
10438
10439 /* Currently only Linux BAL returns the E_RESOURCES error code when it is running
10440 out of BD/PDUs. To make use of this interrupt for throughput enhancement, similar
10441 changes should be done in BAL code of AMSS and WM */
10442 if (VOS_STATUS_E_RESOURCES == vosStatus)
10443 {
10444#ifdef VOLANS_PERF
10445 WLANHAL_EnableIdleBdPduInterrupt(pvosGCtx, (tANI_U8)bdPduInterruptGetThreshold);
10446 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
10447 "WLAN TL: Enabling Idle BD/PDU interrupt, Current resources = %d", uResCount);
10448#else
10449 return VOS_STATUS_E_FAILURE;
10450#endif
10451 }
10452
10453 pTLCb->uResCount = uResCount;
10454
10455
Jeff Johnson295189b2012-06-20 16:38:30 -070010456#ifdef WLAN_SOFTAP_FLOWCTRL_EN
10457 /* FIXME: disabled since creating issues in power-save, needs to be addressed */
10458 pTLCb->sendFCFrame ++;
10459 pMac = vos_get_context(VOS_MODULE_ID_WDA, pvosGCtx);
10460 systemRole = wdaGetGlobalSystemRole(pMac);
10461 if (eSYSTEM_AP_ROLE == systemRole)
10462 {
10463 if (pTLCb->sendFCFrame % 16 == 0)
10464 {
10465 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
10466 "Transmit FC"));
10467 WLANTL_TxFCFrame (pvosGCtx);
10468 }
10469 }
10470#endif //WLAN_SOFTAP_FLOWCTRL_EN
Jeff Johnson295189b2012-06-20 16:38:30 -070010471
10472 ucData = ( pTLCb->uResCount >= WDA_TLI_MIN_RES_DATA );
10473 ucBAP = ( pTLCb->uResCount >= WDA_TLI_MIN_RES_BAP ) &&
10474 ( NULL != pTLCb->tlBAPClient.vosPendingDataBuff );
10475 ucMgmt = ( pTLCb->uResCount >= WDA_TLI_MIN_RES_MF ) &&
10476 ( NULL != pTLCb->tlMgmtFrmClient.vosPendingDataBuff );
10477
10478 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
10479 "WLAN TL: Eval Resume tx Res: %d DATA: %d BAP: %d MGMT: %d",
10480 pTLCb->uResCount, ucData, ucBAP, ucMgmt));
10481
10482 if (( 0 == pTLCb->ucTxSuspended ) &&
10483 (( 0 != ucData ) || ( 0 != ucMgmt ) || ( 0 != ucBAP ) ) )
10484 {
10485 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
10486 "Issuing Xmit start request to BAL for avail res SYNC"));
10487 vosStatus =WDA_DS_StartXmit(pvosGCtx);
10488 }
10489 return vosStatus;
10490}/*WLANTL_GetTxResourcesCB*/
10491
10492/*==========================================================================
10493 Utility functions
10494 ==========================================================================*/
10495
10496/*==========================================================================
10497 FUNCTION WLANTL_Translate8023To80211Header
10498
10499 DESCRIPTION
10500 Inline function for translating and 802.11 header into an 802.3 header.
10501
10502 DEPENDENCIES
10503
10504
10505 PARAMETERS
10506
10507 IN
10508 pTLCb: TL control block
Kiran Venkatappaa044eb92012-12-17 15:48:49 -080010509 IN/OUT
10510 ucStaId: station ID. Incase of TDLS, this returns actual TDLS
10511 station ID used
Jeff Johnson295189b2012-06-20 16:38:30 -070010512
10513 IN/OUT
10514 vosDataBuff: vos data buffer, will contain the new header on output
10515
10516 OUT
10517 pvosStatus: status of the operation
10518
10519 RETURN VALUE
10520
10521 VOS_STATUS_SUCCESS: Everything is good :)
10522
10523 Other error codes might be returned from the vos api used in the function
10524 please check those return values.
10525
10526 SIDE EFFECTS
10527
10528============================================================================*/
Kiran Venkatappacab0d352012-12-17 13:09:22 -080010529VOS_STATUS
10530WLANTL_Translate8023To80211Header
10531(
10532 vos_pkt_t* vosDataBuff,
10533 VOS_STATUS* pvosStatus,
10534 WLANTL_CbType* pTLCb,
10535 v_U8_t *pucStaId,
Ravi Joshid0699502013-07-08 15:48:47 -070010536 WLANTL_MetaInfoType *tlMetaInfo,
Kiran Venkatappacab0d352012-12-17 13:09:22 -080010537 v_U8_t *ucWDSEnabled,
10538 v_U8_t *extraHeadSpace
10539)
Jeff Johnson295189b2012-06-20 16:38:30 -070010540{
10541 WLANTL_8023HeaderType w8023Header;
10542 WLANTL_80211HeaderType *pw80211Header; // Allocate an aligned BD and then fill it.
10543 VOS_STATUS vosStatus;
10544 v_U8_t MandatoryucHeaderSize = WLAN80211_MANDATORY_HEADER_SIZE;
10545 v_U8_t ucHeaderSize = 0;
10546 v_VOID_t *ppvBDHeader = NULL;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053010547 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070010548 v_U8_t ucQoSOffset = WLAN80211_MANDATORY_HEADER_SIZE;
Kiran Venkatappacab0d352012-12-17 13:09:22 -080010549 v_U8_t ucStaId;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010550#ifdef FEATURE_WLAN_ESE_UPLOAD
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070010551 v_BOOL_t bIAPPTxwithLLC = VOS_FALSE;
10552 v_SIZE_t wIAPPSnapSize = WLANTL_LLC_HEADER_LEN;
10553 v_U8_t wIAPPSnap[WLANTL_LLC_HEADER_LEN] = {0};
10554#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010555 *ucWDSEnabled = 0; // default WDS off.
10556 vosStatus = vos_pkt_pop_head( vosDataBuff, &w8023Header,
10557 sizeof(w8023Header));
10558
10559 if ( VOS_STATUS_SUCCESS != vosStatus )
10560 {
10561 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
10562 "WLAN TL: Packet pop header fails on WLANTL_Translate8023To80211Header"));
10563 return vosStatus;
10564 }
10565
Kiran Venkatappacab0d352012-12-17 13:09:22 -080010566 if( NULL == pucStaId )
10567 {
10568 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
10569 "WLAN TL: Invalid pointer for StaId"));
10570 return VOS_STATUS_E_INVAL;
10571 }
10572 ucStaId = *pucStaId;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053010573 pClientSTA = pTLCb->atlSTAClients[ucStaId];
10574
10575 if ( NULL == pClientSTA )
10576 {
10577 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
10578 "WLAN TL:Client Memory was not allocated on %s", __func__));
10579 return VOS_STATUS_E_FAILURE;
10580 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080010581
Kiran Venkatappaa044eb92012-12-17 15:48:49 -080010582#ifdef FEATURE_WLAN_TDLS
10583
Madan Mohan Koyylamudi64258222013-01-30 14:35:10 +053010584 if ( WLAN_STA_INFRA == pTLCb->atlSTAClients[ucStaId]->wSTADesc.wSTAType
10585 && pTLCb->ucTdlsPeerCount )
Kiran Venkatappacab0d352012-12-17 13:09:22 -080010586 {
10587 v_U8_t ucIndex = 0;
10588 for ( ucIndex = 0; ucIndex < WLAN_MAX_STA_COUNT ; ucIndex++)
10589 {
Madan Mohan Koyylamudi64258222013-01-30 14:35:10 +053010590 if ( ucIndex != ucStaId && pTLCb->atlSTAClients[ucIndex] && pTLCb->atlSTAClients[ucIndex]->ucExists &&
Gopichand Nakkala471708b2013-06-04 20:03:01 +053010591 (pTLCb->atlSTAClients[ucIndex]->tlState == WLANTL_STA_AUTHENTICATED) &&
10592 (!pTLCb->atlSTAClients[ucIndex]->ucTxSuspended) &&
Madan Mohan Koyylamudi64258222013-01-30 14:35:10 +053010593 vos_mem_compare( (void*)pTLCb->atlSTAClients[ucIndex]->wSTADesc.vSTAMACAddress.bytes,
Kiran Venkatappacab0d352012-12-17 13:09:22 -080010594 (void*)w8023Header.vDA, 6) )
10595 {
10596 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_LOW,
10597 "WLAN TL: Got a TDLS station. Using that index"));
10598 ucStaId = ucIndex;
10599 *pucStaId = ucStaId;
Madan Mohan Koyylamudi64258222013-01-30 14:35:10 +053010600 pClientSTA = pTLCb->atlSTAClients[ucStaId];
10601 if ( NULL == pClientSTA )
10602 {
10603 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
10604 "WLAN TL:Client Memory was not allocated on %s", __func__));
10605 return VOS_STATUS_E_FAILURE;
10606 }
Kiran Venkatappacab0d352012-12-17 13:09:22 -080010607 break;
10608 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080010609 }
Kiran Venkatappacab0d352012-12-17 13:09:22 -080010610 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080010611#endif
10612
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010613#ifdef FEATURE_WLAN_ESE_UPLOAD
10614if ((0 == w8023Header.usLenType) && (pClientSTA->wSTADesc.ucIsEseSta))
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070010615{
10616 vos_pkt_extract_data(vosDataBuff,0,&wIAPPSnap[0],&wIAPPSnapSize);
10617 if (vos_mem_compare(wIAPPSnap,WLANTL_AIRONET_SNAP_HEADER,WLANTL_LLC_HEADER_LEN))
10618 {
10619 /*The SNAP and the protocol type are already in the data buffer.
10620 They are filled by the application (wpa_supplicant). So, Skip Adding LLC below.*/
10621 bIAPPTxwithLLC = VOS_TRUE;
10622 }
10623 else
10624 {
10625 bIAPPTxwithLLC = VOS_FALSE;
10626 }
10627}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010628#endif /* FEATURE_WLAN_ESE_UPLOAD */
Jeff Johnson295189b2012-06-20 16:38:30 -070010629
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070010630 if ((0 != pClientSTA->wSTADesc.ucAddRmvLLC)
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010631#ifdef FEATURE_WLAN_ESE_UPLOAD
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070010632 && (!bIAPPTxwithLLC)
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010633#endif /* FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070010634 )
Jeff Johnson295189b2012-06-20 16:38:30 -070010635 {
10636 /* Push the length */
10637 vosStatus = vos_pkt_push_head(vosDataBuff,
10638 &w8023Header.usLenType, sizeof(w8023Header.usLenType));
10639
10640 if ( VOS_STATUS_SUCCESS != vosStatus )
10641 {
10642 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
10643 "WLAN TL: Packet push ether type fails on"
10644 " WLANTL_Translate8023To80211Header"));
10645 return vosStatus;
10646 }
10647
10648#ifdef BTAMP_TEST
10649 // The STA side will execute this, a hack to test BTAMP by using the
10650 // infra setup. On real BTAMP this will come from BAP itself.
10651 {
10652 static v_U8_t WLANTL_BT_AMP_LLC_HEADER[] = {0xAA, 0xAA, 0x03, 0x00, 0x19, 0x58 };
10653 vosStatus = vos_pkt_push_head(vosDataBuff, WLANTL_BT_AMP_LLC_HEADER,
10654 sizeof(WLANTL_BT_AMP_LLC_HEADER));
10655
10656 if ( VOS_STATUS_SUCCESS != vosStatus )
10657 {
10658 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
10659 "WLAN TL: Packet push LLC header fails on"
10660 " WLANTL_Translate8023To80211Header"));
10661 return vosStatus;
10662 }
10663 }
10664#else
10665 vosStatus = vos_pkt_push_head(vosDataBuff, WLANTL_LLC_HEADER,
10666 sizeof(WLANTL_LLC_HEADER));
10667
10668 if ( VOS_STATUS_SUCCESS != vosStatus )
10669 {
10670 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
10671 "WLAN TL: Packet push LLC header fails on"
10672 " WLANTL_Translate8023To80211Header"));
10673 return vosStatus;
10674 }
10675#endif
10676 }/*If add LLC is enabled*/
10677 else
10678 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010679#ifdef FEATURE_WLAN_ESE_UPLOAD
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070010680 bIAPPTxwithLLC = VOS_FALSE; /*Reset the Flag here to start afresh with the next TX pkt*/
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010681#endif /* FEATURE_WLAN_ESE_UPLOAD */
Jeff Johnson295189b2012-06-20 16:38:30 -070010682 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
10683 "WLAN TL: STA Client registered to not remove LLC"
10684 " WLANTL_Translate8023To80211Header"));
10685 }
10686
10687#ifdef BTAMP_TEST
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053010688 pClientSTA->wSTADesc.wSTAType = WLAN_STA_BT_AMP;
Jeff Johnson295189b2012-06-20 16:38:30 -070010689#endif
10690
10691 // Find the space required for the 802.11 header format
10692 // based on the frame control fields.
10693 ucHeaderSize = MandatoryucHeaderSize;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053010694 if (pClientSTA->wSTADesc.ucQosEnabled)
Jeff Johnson295189b2012-06-20 16:38:30 -070010695 {
10696 ucHeaderSize += sizeof(pw80211Header->usQosCtrl);
10697 }
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053010698 if (pClientSTA->wSTADesc.wSTAType == WLAN_STA_BT_AMP)
Jeff Johnson295189b2012-06-20 16:38:30 -070010699 {
10700 ucHeaderSize += sizeof(pw80211Header->optvA4);
Jeff Johnson295189b2012-06-20 16:38:30 -070010701 ucQoSOffset += sizeof(pw80211Header->optvA4);
Jeff Johnson295189b2012-06-20 16:38:30 -070010702 }
10703
10704 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
10705 " WLANTL_Translate8023To80211Header : Header size = %d ", ucHeaderSize));
10706
10707 vos_pkt_reserve_head( vosDataBuff, &ppvBDHeader, ucHeaderSize );
10708 if ( NULL == ppvBDHeader )
10709 {
10710 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
10711 "WLAN TL:VOSS packet corrupted "));
10712 *pvosStatus = VOS_STATUS_E_INVAL;
10713 return *pvosStatus;
10714 }
10715
Jeff Johnson295189b2012-06-20 16:38:30 -070010716
10717 // OK now we have the space. Fill the 80211 header
10718 /* Fill A2 */
10719 pw80211Header = (WLANTL_80211HeaderType *)(ppvBDHeader);
10720 // only clear the required space.
10721 vos_mem_set( pw80211Header, ucHeaderSize, 0 );
10722 vos_mem_copy( pw80211Header->vA2, w8023Header.vSA, VOS_MAC_ADDR_SIZE);
10723
10724
10725#ifdef FEATURE_WLAN_WAPI
Gopichand Nakkala8b54e912013-03-11 10:44:21 +053010726 if (( WLANTL_STA_AUTHENTICATED == pClientSTA->tlState ||
Abhishek Singh8cecdaa2015-05-22 14:46:40 +053010727 pClientSTA->ptkInstalled ) && (tlMetaInfo->ucIsWai != 1))
Jeff Johnson295189b2012-06-20 16:38:30 -070010728#else
Gopichand Nakkala8b54e912013-03-11 10:44:21 +053010729 if ( WLANTL_STA_AUTHENTICATED == pClientSTA->tlState ||
10730 pClientSTA->ptkInstalled )
Jeff Johnson295189b2012-06-20 16:38:30 -070010731#endif
10732 {
10733 pw80211Header->wFrmCtrl.wep =
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053010734 pClientSTA->wSTADesc.ucProtectedFrame;
Jeff Johnson295189b2012-06-20 16:38:30 -070010735 }
10736
10737 pw80211Header->usDurationId = 0;
10738 pw80211Header->usSeqCtrl = 0;
10739
10740 pw80211Header->wFrmCtrl.type = WLANTL_80211_DATA_TYPE;
10741
10742
10743
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053010744 if(pClientSTA->wSTADesc.ucQosEnabled)
Jeff Johnson295189b2012-06-20 16:38:30 -070010745 {
10746 pw80211Header->wFrmCtrl.subType = WLANTL_80211_DATA_QOS_SUBTYPE;
10747
Ravi Joshid0699502013-07-08 15:48:47 -070010748 *((v_U16_t *)((v_U8_t *)ppvBDHeader + ucQoSOffset)) = tlMetaInfo->ucUP;
Jeff Johnson295189b2012-06-20 16:38:30 -070010749
10750 }
10751 else
10752 {
10753 pw80211Header->wFrmCtrl.subType = 0;
Agarwal Ashish8b343f12015-01-08 20:06:44 +053010754 tlMetaInfo->ucUP = 0;
10755 tlMetaInfo->ucTID = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070010756
10757 // NO NO NO - there is not enough memory allocated to write the QOS ctrl
10758 // field, it will overwrite the first 2 bytes of the data packet(LLC header)
10759 // pw80211Header->usQosCtrl = 0;
10760 }
10761
10762
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053010763 switch( pClientSTA->wSTADesc.wSTAType )
Jeff Johnson295189b2012-06-20 16:38:30 -070010764 {
Ravi Joshid0699502013-07-08 15:48:47 -070010765 case WLAN_STA_IBSS:
Jeff Johnson295189b2012-06-20 16:38:30 -070010766 pw80211Header->wFrmCtrl.toDS = 0;
10767 pw80211Header->wFrmCtrl.fromDS = 0;
Ravi Joshid0699502013-07-08 15:48:47 -070010768
Abhishek Singh45e68fe2014-12-11 12:55:59 +053010769 vos_copy_macaddr( (v_MACADDR_t*)&pw80211Header->vA1,
Ravi Joshid0699502013-07-08 15:48:47 -070010770 (v_MACADDR_t*)&w8023Header.vDA);
Jeff Johnson295189b2012-06-20 16:38:30 -070010771 vos_mem_copy( pw80211Header->vA3,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053010772 &pClientSTA->wSTADesc.vBSSIDforIBSS ,
Jeff Johnson295189b2012-06-20 16:38:30 -070010773 VOS_MAC_ADDR_SIZE);
10774 break;
10775
Ravi Joshid0699502013-07-08 15:48:47 -070010776 case WLAN_STA_BT_AMP:
Jeff Johnson295189b2012-06-20 16:38:30 -070010777 *ucWDSEnabled = 1; // WDS on.
10778 pw80211Header->wFrmCtrl.toDS = 1;
10779 pw80211Header->wFrmCtrl.fromDS = 1;
10780 vos_copy_macaddr( (v_MACADDR_t*)&pw80211Header->vA1,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053010781 &pClientSTA->wSTADesc.vSTAMACAddress);
Jeff Johnson295189b2012-06-20 16:38:30 -070010782 vos_mem_copy( pw80211Header->vA2,
Ravi Joshid0699502013-07-08 15:48:47 -070010783 w8023Header.vSA, VOS_MAC_ADDR_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -070010784 vos_copy_macaddr( (v_MACADDR_t*)&pw80211Header->vA3,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053010785 &pClientSTA->wSTADesc.vSTAMACAddress);
Jeff Johnson295189b2012-06-20 16:38:30 -070010786 /* fill the optional A4 header */
10787 vos_mem_copy( pw80211Header->optvA4,
Ravi Joshid0699502013-07-08 15:48:47 -070010788 w8023Header.vSA, VOS_MAC_ADDR_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -070010789 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
Arif Hussainf2b00992013-11-17 21:46:15 -080010790 "BTAMP CASE NOW ---------staid=%d",
Ravi Joshid0699502013-07-08 15:48:47 -070010791 ucStaId));
Jeff Johnson295189b2012-06-20 16:38:30 -070010792 break;
10793
Ravi Joshid0699502013-07-08 15:48:47 -070010794 case WLAN_STA_SOFTAP:
Jeff Johnson295189b2012-06-20 16:38:30 -070010795 *ucWDSEnabled = 0; // WDS off.
10796 pw80211Header->wFrmCtrl.toDS = 0;
10797 pw80211Header->wFrmCtrl.fromDS = 1;
10798 /*Copy the DA to A1*/
10799 vos_mem_copy( pw80211Header->vA1, w8023Header.vDA , VOS_MAC_ADDR_SIZE);
10800 vos_copy_macaddr( (v_MACADDR_t*)&pw80211Header->vA2,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053010801 &pClientSTA->wSTADesc.vSelfMACAddress);
Jeff Johnson295189b2012-06-20 16:38:30 -070010802 vos_mem_copy( pw80211Header->vA3,
Ravi Joshid0699502013-07-08 15:48:47 -070010803 w8023Header.vSA, VOS_MAC_ADDR_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -070010804 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
Arif Hussainf2b00992013-11-17 21:46:15 -080010805 "sw 802 to 80211 softap case ---------staid=%d",
Ravi Joshid0699502013-07-08 15:48:47 -070010806 ucStaId));
Jeff Johnson295189b2012-06-20 16:38:30 -070010807 break;
Mohit Khanna698ba2a2012-12-04 15:08:18 -080010808#ifdef FEATURE_WLAN_TDLS
Ravi Joshid0699502013-07-08 15:48:47 -070010809 case WLAN_STA_TDLS:
Mohit Khanna698ba2a2012-12-04 15:08:18 -080010810 pw80211Header->wFrmCtrl.toDS = 0;
10811 pw80211Header->wFrmCtrl.fromDS = 0;
10812 /*Fix me*/
10813 vos_copy_macaddr( (v_MACADDR_t*)&pw80211Header->vA1,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053010814 &pClientSTA->wSTADesc.vSTAMACAddress);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080010815 vos_mem_copy( pw80211Header->vA3,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053010816 &pClientSTA->wSTADesc.vBSSIDforIBSS ,
Mohit Khanna698ba2a2012-12-04 15:08:18 -080010817 VOS_MAC_ADDR_SIZE);
10818 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
Arif Hussainf2b00992013-11-17 21:46:15 -080010819 ("TL:TDLS CASE NOW ---------staid=%d"), ucStaId);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080010820 break;
10821#endif
Ravi Joshid0699502013-07-08 15:48:47 -070010822 case WLAN_STA_INFRA:
10823 default:
Jeff Johnson295189b2012-06-20 16:38:30 -070010824 pw80211Header->wFrmCtrl.toDS = 1;
10825 pw80211Header->wFrmCtrl.fromDS = 0;
10826 vos_copy_macaddr( (v_MACADDR_t*)&pw80211Header->vA1,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053010827 &pClientSTA->wSTADesc.vSTAMACAddress);
Jeff Johnson295189b2012-06-20 16:38:30 -070010828 vos_mem_copy( pw80211Header->vA3, w8023Header.vDA , VOS_MAC_ADDR_SIZE);
10829 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
Arif Hussainf2b00992013-11-17 21:46:15 -080010830 "REGULAR INFRA LINK CASE---------staid=%d",
Ravi Joshid0699502013-07-08 15:48:47 -070010831 ucStaId));
Jeff Johnson295189b2012-06-20 16:38:30 -070010832 break;
10833 }
10834 // OK now we have the space. Fill the 80211 header
10835 /* Fill A2 */
10836 pw80211Header = (WLANTL_80211HeaderType *)(ppvBDHeader);
10837 return VOS_STATUS_SUCCESS;
10838}/*WLANTL_Translate8023To80211Header*/
10839
10840
10841/*=============================================================================
10842 BEGIN LOG FUNCTION !!! Remove me or clean me
10843=============================================================================*/
Ravi Kumar Vaishnavb7652402013-01-18 19:05:15 -080010844#if 0 //def WLANTL_DEBUG
Jeff Johnson295189b2012-06-20 16:38:30 -070010845
10846#define WLANTL_DEBUG_FRAME_BYTE_PER_LINE 16
10847#define WLANTL_DEBUG_FRAME_BYTE_PER_BYTE 4
10848
10849static v_VOID_t WLANTL_DebugFrame
10850(
10851 v_PVOID_t dataPointer,
10852 v_U32_t dataSize
10853)
10854{
10855 v_U8_t lineBuffer[WLANTL_DEBUG_FRAME_BYTE_PER_LINE];
10856 v_U32_t numLines;
10857 v_U32_t numBytes;
10858 v_U32_t idx;
10859 v_U8_t *linePointer;
10860
10861 numLines = dataSize / WLANTL_DEBUG_FRAME_BYTE_PER_LINE;
10862 numBytes = dataSize % WLANTL_DEBUG_FRAME_BYTE_PER_LINE;
10863 linePointer = (v_U8_t *)dataPointer;
10864
10865 TLLOGE(VOS_TRACE(VOS_MODULE_ID_SAL, VOS_TRACE_LEVEL_ERROR, "WLAN TL:Frame Debug Frame Size %d, Pointer 0x%p", dataSize, dataPointer));
10866 for(idx = 0; idx < numLines; idx++)
10867 {
10868 memset(lineBuffer, 0, WLANTL_DEBUG_FRAME_BYTE_PER_LINE);
10869 memcpy(lineBuffer, linePointer, WLANTL_DEBUG_FRAME_BYTE_PER_LINE);
10870 TLLOGE(VOS_TRACE(VOS_MODULE_ID_SAL, VOS_TRACE_LEVEL_ERROR,
10871 "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",
10872 lineBuffer[0], lineBuffer[1], lineBuffer[2], lineBuffer[3], lineBuffer[4], lineBuffer[5], lineBuffer[6], lineBuffer[7],
10873 lineBuffer[8], lineBuffer[9], lineBuffer[10], lineBuffer[11], lineBuffer[12], lineBuffer[13], lineBuffer[14], lineBuffer[15]));
10874 linePointer += WLANTL_DEBUG_FRAME_BYTE_PER_LINE;
10875 }
10876
10877 if(0 == numBytes)
10878 return;
10879
10880 memset(lineBuffer, 0, WLANTL_DEBUG_FRAME_BYTE_PER_LINE);
10881 memcpy(lineBuffer, linePointer, numBytes);
10882 for(idx = 0; idx < WLANTL_DEBUG_FRAME_BYTE_PER_LINE / WLANTL_DEBUG_FRAME_BYTE_PER_BYTE; idx++)
10883 {
10884 TLLOGE(VOS_TRACE(VOS_MODULE_ID_SAL, VOS_TRACE_LEVEL_ERROR, "WLAN TL:0x%2x 0x%2x 0x%2x 0x%2x",
10885 lineBuffer[idx * WLANTL_DEBUG_FRAME_BYTE_PER_BYTE], lineBuffer[1 + idx * WLANTL_DEBUG_FRAME_BYTE_PER_BYTE],
10886 lineBuffer[2 + idx * WLANTL_DEBUG_FRAME_BYTE_PER_BYTE], lineBuffer[3 + idx * WLANTL_DEBUG_FRAME_BYTE_PER_BYTE]));
10887 if(((idx + 1) * WLANTL_DEBUG_FRAME_BYTE_PER_BYTE) >= numBytes)
10888 break;
10889 }
10890
10891 return;
10892}
10893#endif
10894
10895/*=============================================================================
10896 END LOG FUNCTION
10897=============================================================================*/
10898
10899/*==========================================================================
10900 FUNCTION WLANTL_Translate80211To8023Header
10901
10902 DESCRIPTION
10903 Inline function for translating and 802.11 header into an 802.3 header.
10904
10905 DEPENDENCIES
10906
10907
10908 PARAMETERS
10909
10910 IN
10911 pTLCb: TL control block
10912 ucStaId: station ID
10913 ucHeaderLen: Length of the header from BD
10914 ucActualHLen: Length of header including padding or any other trailers
10915
10916 IN/OUT
10917 vosDataBuff: vos data buffer, will contain the new header on output
10918
10919 OUT
10920 pvosStatus: status of the operation
10921
10922 RETURN VALUE
10923
10924 The result code associated with performing the operation
10925 VOS_STATUS_SUCCESS: Everything is good :)
10926
10927 SIDE EFFECTS
10928
10929============================================================================*/
10930VOS_STATUS
10931WLANTL_Translate80211To8023Header
10932(
10933 vos_pkt_t* vosDataBuff,
10934 VOS_STATUS* pvosStatus,
10935 v_U16_t usActualHLen,
10936 v_U8_t ucHeaderLen,
10937 WLANTL_CbType* pTLCb,
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070010938 v_U8_t ucSTAId,
10939 v_BOOL_t bForwardIAPPwithLLC
Jeff Johnson295189b2012-06-20 16:38:30 -070010940)
10941{
10942 WLANTL_8023HeaderType w8023Header;
10943 WLANTL_80211HeaderType w80211Header;
10944 v_U8_t aucLLCHeader[WLANTL_LLC_HEADER_LEN];
10945 VOS_STATUS vosStatus;
10946 v_U16_t usDataStartOffset = 0;
10947 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
10948
10949 if ( sizeof(w80211Header) < ucHeaderLen )
10950 {
10951 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
10952 "Warning !: Check the header size for the Rx frame structure=%d received=%dn",
10953 sizeof(w80211Header), ucHeaderLen));
10954 ucHeaderLen = sizeof(w80211Header);
10955 }
10956
10957 // This will take care of headers of all sizes, 3 address, 3 addr QOS,
10958 // WDS non-QOS and WDS QoS etc. We have space for all in the 802.11 header structure.
10959 vosStatus = vos_pkt_pop_head( vosDataBuff, &w80211Header, ucHeaderLen);
10960
10961 if ( VOS_STATUS_SUCCESS != vosStatus )
10962 {
10963 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
10964 "WLAN TL: Failed to pop 80211 header from packet %d",
10965 vosStatus));
10966
10967 return vosStatus;
10968 }
10969
10970 switch ( w80211Header.wFrmCtrl.fromDS )
10971 {
10972 case 0:
Jeff Johnson295189b2012-06-20 16:38:30 -070010973 if ( w80211Header.wFrmCtrl.toDS )
10974 {
10975 //SoftAP AP mode
10976 vos_mem_copy( w8023Header.vDA, w80211Header.vA3, VOS_MAC_ADDR_SIZE);
10977 vos_mem_copy( w8023Header.vSA, w80211Header.vA2, VOS_MAC_ADDR_SIZE);
10978 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
Arif Hussainf2b00992013-11-17 21:46:15 -080010979 "WLAN TL SoftAP: 802 3 DA %08x SA %08x",
Jeff Johnson295189b2012-06-20 16:38:30 -070010980 w8023Header.vDA, w8023Header.vSA));
10981 }
10982 else
10983 {
10984 /* IBSS */
10985 vos_mem_copy( w8023Header.vDA, w80211Header.vA1, VOS_MAC_ADDR_SIZE);
10986 vos_mem_copy( w8023Header.vSA, w80211Header.vA2, VOS_MAC_ADDR_SIZE);
10987 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010988 break;
10989 case 1:
10990 if ( w80211Header.wFrmCtrl.toDS )
10991 {
10992 /* BT-AMP case */
10993 vos_mem_copy( w8023Header.vDA, w80211Header.vA1, VOS_MAC_ADDR_SIZE);
10994 vos_mem_copy( w8023Header.vSA, w80211Header.vA2, VOS_MAC_ADDR_SIZE);
10995 }
10996 else
10997 { /* Infra */
10998 vos_mem_copy( w8023Header.vDA, w80211Header.vA1, VOS_MAC_ADDR_SIZE);
10999 vos_mem_copy( w8023Header.vSA, w80211Header.vA3, VOS_MAC_ADDR_SIZE);
11000 }
11001 break;
11002 }
11003
11004 if( usActualHLen > ucHeaderLen )
11005 {
11006 usDataStartOffset = usActualHLen - ucHeaderLen;
11007 }
11008
11009 if ( 0 < usDataStartOffset )
11010 {
11011 vosStatus = vos_pkt_trim_head( vosDataBuff, usDataStartOffset );
11012
11013 if ( VOS_STATUS_SUCCESS != vosStatus )
11014 {
11015 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11016 "WLAN TL: Failed to trim header from packet %d",
11017 vosStatus));
11018 return vosStatus;
11019 }
11020 }
11021
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053011022 if ( NULL == pTLCb->atlSTAClients[ucSTAId] )
11023 {
11024 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11025 "WLAN TL:Client Memory was not allocated on %s", __func__));
11026 return VOS_STATUS_E_FAILURE;
11027 }
11028
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070011029 if ( 0 != pTLCb->atlSTAClients[ucSTAId]->wSTADesc.ucAddRmvLLC
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080011030#ifdef FEATURE_WLAN_ESE_UPLOAD
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070011031 && (!bForwardIAPPwithLLC)
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080011032#endif /* FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070011033 )
Jeff Johnson295189b2012-06-20 16:38:30 -070011034 {
11035 // Extract the LLC header
11036 vosStatus = vos_pkt_pop_head( vosDataBuff, aucLLCHeader,
11037 WLANTL_LLC_HEADER_LEN);
11038
11039 if ( VOS_STATUS_SUCCESS != vosStatus )
11040 {
Kaushik, Sushante386ee12014-05-01 15:50:52 +053011041 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
Jeff Johnson295189b2012-06-20 16:38:30 -070011042 "WLAN TL: Failed to pop LLC header from packet %d",
11043 vosStatus));
11044
11045 return vosStatus;
11046 }
11047
11048 //Extract the length
11049 vos_mem_copy(&w8023Header.usLenType,
11050 &aucLLCHeader[WLANTL_LLC_HEADER_LEN - sizeof(w8023Header.usLenType)],
11051 sizeof(w8023Header.usLenType) );
11052 }
11053 else
11054 {
11055 vosStatus = vos_pkt_get_packet_length(vosDataBuff,
11056 &w8023Header.usLenType);
11057
11058 if ( VOS_STATUS_SUCCESS != vosStatus )
11059 {
11060 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11061 "WLAN TL: Failed to get packet length %d",
11062 vosStatus));
11063
11064 return vosStatus;
11065 }
11066
11067 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
11068 "WLAN TL: BTAMP len (ethertype) fld = %d",
11069 w8023Header.usLenType));
11070 w8023Header.usLenType = vos_cpu_to_be16(w8023Header.usLenType);
11071 }
11072
11073 vos_pkt_push_head(vosDataBuff, &w8023Header, sizeof(w8023Header));
11074
11075#ifdef BTAMP_TEST
11076 {
11077 // AP side will execute this.
11078 v_U8_t *temp_w8023Header = NULL;
11079 vosStatus = vos_pkt_peek_data( vosDataBuff, 0,
11080 &temp_w8023Header, sizeof(w8023Header) );
11081 }
11082#endif
11083#if 0 /*TL_DEBUG*/
11084 vos_pkt_get_packet_length(vosDataBuff, &usLen);
11085 vos_pkt_pop_head( vosDataBuff, aucData, usLen);
11086
11087 WLANTL_DebugFrame(aucData, usLen);
11088
11089 vos_pkt_push_head(vosDataBuff, aucData, usLen);
11090
11091#endif
11092
11093 *pvosStatus = VOS_STATUS_SUCCESS;
11094
11095 return VOS_STATUS_SUCCESS;
11096}/*WLANTL_Translate80211To8023Header*/
11097
Katya Nigame7b69a82015-04-28 15:24:06 +053011098VOS_STATUS
11099WLANTL_MonTranslate80211To8023Header
11100(
11101 vos_pkt_t* vosDataBuff,
11102 WLANTL_CbType* pTLCb
11103)
11104{
11105 v_U16_t usMPDUDOffset;
11106 v_U8_t ucMPDUHOffset;
11107 v_U8_t ucMPDUHLen;
11108 v_U16_t usActualHLen = 0;
11109 v_U16_t usDataStartOffset = 0;
11110 v_PVOID_t aucBDHeader;
11111 WLANTL_8023HeaderType w8023Header;
11112 WLANTL_80211HeaderType w80211Header;
11113 VOS_STATUS vosStatus;
11114 v_U8_t aucLLCHeader[WLANTL_LLC_HEADER_LEN];
11115
11116 WDA_DS_PeekRxPacketInfo( vosDataBuff, (v_PVOID_t)&aucBDHeader, 0 );
11117 ucMPDUHOffset = (v_U8_t)WDA_GET_RX_MPDU_HEADER_OFFSET(aucBDHeader);
11118 usMPDUDOffset = (v_U16_t)WDA_GET_RX_MPDU_DATA_OFFSET(aucBDHeader);
11119 ucMPDUHLen = (v_U8_t)WDA_GET_RX_MPDU_HEADER_LEN(aucBDHeader);
11120 if (usMPDUDOffset > ucMPDUHOffset)
11121 {
11122 usActualHLen = usMPDUDOffset - ucMPDUHOffset;
11123 }
11124
11125 if ( sizeof(w80211Header) < ucMPDUHLen )
11126 {
11127 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
11128 "Warning !: Check the header size for the Rx frame structure=%d received=%dn",
11129 sizeof(w80211Header), ucMPDUHLen));
11130 ucMPDUHLen = sizeof(w80211Header);
11131 }
11132
11133 vosStatus = vos_pkt_pop_head( vosDataBuff, &w80211Header, ucMPDUHLen);
11134 if ( VOS_STATUS_SUCCESS != vosStatus )
11135 {
11136 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11137 "WLAN TL: Failed to pop 80211 header from packet %d",
11138 vosStatus));
11139
11140 return vosStatus;
11141 }
11142 switch ( w80211Header.wFrmCtrl.fromDS )
11143 {
11144 case 0:
11145 if ( w80211Header.wFrmCtrl.toDS )
11146 {
11147 vos_mem_copy( w8023Header.vDA, w80211Header.vA3, VOS_MAC_ADDR_SIZE);
11148 vos_mem_copy( w8023Header.vSA, w80211Header.vA2, VOS_MAC_ADDR_SIZE);
11149 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
11150 "WLAN TL SoftAP: 802 3 DA %08x SA %08x",
11151 w8023Header.vDA, w8023Header.vSA));
11152 }
11153 else
11154 {
11155 vos_mem_copy( w8023Header.vDA, w80211Header.vA1, VOS_MAC_ADDR_SIZE);
11156 vos_mem_copy( w8023Header.vSA, w80211Header.vA2, VOS_MAC_ADDR_SIZE);
11157 }
11158 break;
11159 case 1:
11160 if ( w80211Header.wFrmCtrl.toDS )
11161 {
11162 vos_mem_copy( w8023Header.vDA, w80211Header.vA1, VOS_MAC_ADDR_SIZE);
11163 vos_mem_copy( w8023Header.vSA, w80211Header.vA2, VOS_MAC_ADDR_SIZE);
11164 }
11165 else
11166 {
11167 vos_mem_copy( w8023Header.vDA, w80211Header.vA1, VOS_MAC_ADDR_SIZE);
11168 vos_mem_copy( w8023Header.vSA, w80211Header.vA3, VOS_MAC_ADDR_SIZE);
11169 }
11170 break;
11171 }
11172 if( usActualHLen > ucMPDUHLen )
11173 {
11174 usDataStartOffset = usActualHLen - ucMPDUHLen;
11175 }
11176
11177 if ( 0 < usDataStartOffset )
11178 {
11179 vosStatus = vos_pkt_trim_head( vosDataBuff, usDataStartOffset );
11180
11181 if ( VOS_STATUS_SUCCESS != vosStatus )
11182 {
11183 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11184 "WLAN TL: Failed to trim header from packet %d",
11185 vosStatus));
11186 return vosStatus;
11187 }
11188 }
11189 // Extract the LLC header
11190 vosStatus = vos_pkt_pop_head( vosDataBuff, aucLLCHeader,
11191 WLANTL_LLC_HEADER_LEN);
11192
11193 if ( VOS_STATUS_SUCCESS != vosStatus )
11194 {
11195 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
11196 "WLAN TL: Failed to pop LLC header from packet %d",
11197 vosStatus));
11198
11199 return vosStatus;
11200 }
11201
11202 //Extract the length
11203 vos_mem_copy(&w8023Header.usLenType,
11204 &aucLLCHeader[WLANTL_LLC_HEADER_LEN - sizeof(w8023Header.usLenType)],
11205 sizeof(w8023Header.usLenType) );
11206
11207 vos_pkt_push_head(vosDataBuff, &w8023Header, sizeof(w8023Header));
11208 return VOS_STATUS_SUCCESS;
11209}
11210
Madan Mohan Koyyalamudia148e1e2012-11-30 14:52:59 -080011211/*==========================================================================
11212 FUNCTION WLANTL_FindFrameTypeBcMcUc
11213
11214 DESCRIPTION
11215 Utility function to find whether received frame is broadcast, multicast
11216 or unicast.
11217
11218 DEPENDENCIES
11219 The STA must be registered with TL before this function can be called.
11220
11221 PARAMETERS
11222
11223 IN
11224 pTLCb: pointer to the TL's control block
11225 ucSTAId: identifier of the station being processed
11226 vosDataBuff: pointer to the vos buffer
11227
11228 IN/OUT
11229 pucBcMcUc: pointer to buffer, will contain frame type on return
11230
11231 RETURN VALUE
11232 The result code associated with performing the operation
11233
11234 VOS_STATUS_E_INVAL: invalid input parameters
11235 VOS_STATUS_E_BADMSG: failed to extract info from data buffer
11236 VOS_STATUS_SUCCESS: success
11237
11238 SIDE EFFECTS
11239 None.
11240============================================================================*/
11241VOS_STATUS
11242WLANTL_FindFrameTypeBcMcUc
11243(
11244 WLANTL_CbType *pTLCb,
11245 v_U8_t ucSTAId,
11246 vos_pkt_t *vosDataBuff,
11247 v_U8_t *pucBcMcUc
11248)
11249{
11250 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
11251 v_PVOID_t aucBDHeader;
11252 v_PVOID_t pvPeekData;
11253 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
11254
11255 /*------------------------------------------------------------------------
11256 Sanity check
11257 ------------------------------------------------------------------------*/
11258 if ((NULL == pTLCb) ||
11259 (NULL == vosDataBuff) ||
11260 (NULL == pucBcMcUc))
11261 {
11262 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11263 "WLAN TL:Invalid parameter in WLANTL_FindFrameTypeBcMcUc"));
11264 return VOS_STATUS_E_INVAL;
11265 }
11266
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053011267 if ( NULL == pTLCb->atlSTAClients[ucSTAId] )
11268 {
11269 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11270 "WLAN TL:Client Memory was not allocated on %s", __func__));
11271 return VOS_STATUS_E_FAILURE;
11272 }
11273
Madan Mohan Koyyalamudia148e1e2012-11-30 14:52:59 -080011274 /*------------------------------------------------------------------------
11275 Extract BD header and check if valid
11276 ------------------------------------------------------------------------*/
11277 vosStatus = WDA_DS_PeekRxPacketInfo(vosDataBuff, (v_PVOID_t)&aucBDHeader, 0/*Swap BD*/ );
11278
11279 if (NULL == aucBDHeader)
11280 {
11281 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11282 "WLAN TL:WLANTL_FindFrameTypeBcMcUc - Cannot extract BD header"));
11283 VOS_ASSERT(0);
11284 return VOS_STATUS_E_BADMSG;
11285 }
11286
11287 if ((0 == WDA_GET_RX_FT_DONE(aucBDHeader)) &&
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053011288 (0 != pTLCb->atlSTAClients[ucSTAId]->wSTADesc.ucSwFrameRXXlation))
Madan Mohan Koyyalamudia148e1e2012-11-30 14:52:59 -080011289 {
11290 /* Its an 802.11 frame, extract MAC address 1 */
11291 TLLOG2(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
11292 "WLAN TL:WLANTL_FindFrameTypeBcMcUc - 802.11 frame, peeking Addr1"));
11293 vosStatus = vos_pkt_peek_data(vosDataBuff, WLANTL_MAC_ADDR_ALIGN(1),
11294 (v_PVOID_t)&pvPeekData, VOS_MAC_ADDR_SIZE);
11295 }
11296 else
11297 {
11298 /* Its an 802.3 frame, extract Destination MAC address */
11299 TLLOG2(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
11300 "WLAN TL:WLANTL_FindFrameTypeBcMcUc - 802.3 frame, peeking DA"));
11301 vosStatus = vos_pkt_peek_data(vosDataBuff, WLANTL_MAC_ADDR_ALIGN(0),
11302 (v_PVOID_t)&pvPeekData, VOS_MAC_ADDR_SIZE);
11303 }
11304
11305 if (VOS_STATUS_SUCCESS != vosStatus)
11306 {
11307 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11308 "WLAN TL:WLANTL_FindFrameTypeBcMcUc - Failed to peek MAC address"));
11309 return vosStatus;
11310 }
11311
11312 if (((tANI_U8 *)pvPeekData)[0] == 0xff)
11313 {
11314 *pucBcMcUc = WLANTL_FRAME_TYPE_BCAST;
11315 }
11316 else
11317 {
11318 if ((((tANI_U8 *)pvPeekData)[0] & 0x01) == 0x01)
11319 *pucBcMcUc = WLANTL_FRAME_TYPE_MCAST;
11320 else
11321 *pucBcMcUc = WLANTL_FRAME_TYPE_UCAST;
11322 }
11323
11324 TLLOG2(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
11325 "WLAN TL:WLANTL_FindFrameTypeBcMcUc - Addr1Byte1 is: %x",
11326 ((tANI_U8 *)pvPeekData)[0]));
11327
11328 return VOS_STATUS_SUCCESS;
11329}
11330
Jeff Johnson295189b2012-06-20 16:38:30 -070011331#if 0
11332#ifdef WLAN_PERF
11333/*==========================================================================
11334 FUNCTION WLANTL_FastHwFwdDataFrame
11335
11336 DESCRIPTION
11337 Fast path function to quickly forward a data frame if HAL determines BD
11338 signature computed here matches the signature inside current VOSS packet.
11339 If there is a match, HAL and TL fills in the swapped packet length into
11340 BD header and DxE header, respectively. Otherwise, packet goes back to
11341 normal (slow) path and a new BD signature would be tagged into BD in this
11342 VOSS packet later by the WLANHAL_FillTxBd() function.
11343
11344 DEPENDENCIES
11345
11346 PARAMETERS
11347
11348 IN
11349 pvosGCtx VOS context
11350 vosDataBuff Ptr to VOSS packet
11351 pMetaInfo For getting frame's TID
11352 pStaInfo For checking STA type
11353
11354 OUT
11355 pvosStatus returned status
11356 puFastFwdOK Flag to indicate whether frame could be fast forwarded
11357
11358 RETURN VALUE
11359 No return.
11360
11361 SIDE EFFECTS
11362
11363============================================================================*/
11364static void
11365WLANTL_FastHwFwdDataFrame
11366(
11367 v_PVOID_t pvosGCtx,
11368 vos_pkt_t* vosDataBuff,
11369 VOS_STATUS* pvosStatus,
11370 v_U32_t* puFastFwdOK,
11371 WLANTL_MetaInfoType* pMetaInfo,
11372 WLAN_STADescType* pStaInfo
11373
11374)
11375{
11376 v_PVOID_t pvPeekData;
11377 v_U8_t ucDxEBDWLANHeaderLen = WLANTL_BD_HEADER_LEN(0) + sizeof(WLANBAL_sDXEHeaderType);
11378 v_U8_t ucIsUnicast;
11379 WLANBAL_sDXEHeaderType *pDxEHeader;
11380 v_PVOID_t pvBDHeader;
11381 v_PVOID_t pucBuffPtr;
11382 v_U16_t usPktLen;
11383
11384 /*-----------------------------------------------------------------------
11385 Extract packet length
11386 -----------------------------------------------------------------------*/
11387
11388 vos_pkt_get_packet_length( vosDataBuff, &usPktLen);
11389
11390 /*-----------------------------------------------------------------------
11391 Extract MAC address
11392 -----------------------------------------------------------------------*/
11393 *pvosStatus = vos_pkt_peek_data( vosDataBuff,
11394 WLANTL_MAC_ADDR_ALIGN(0),
11395 (v_PVOID_t)&pvPeekData,
11396 VOS_MAC_ADDR_SIZE );
11397
11398 if ( VOS_STATUS_SUCCESS != *pvosStatus )
11399 {
11400 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11401 "WLAN TL:Failed while attempting to extract MAC Addr %d",
11402 *pvosStatus));
11403 *pvosStatus = VOS_STATUS_E_INVAL;
11404 return;
11405 }
11406
11407 /*-----------------------------------------------------------------------
11408 Reserve head room for DxE header, BD, and WLAN header
11409 -----------------------------------------------------------------------*/
11410
11411 vos_pkt_reserve_head( vosDataBuff, &pucBuffPtr,
11412 ucDxEBDWLANHeaderLen );
11413 if ( NULL == pucBuffPtr )
11414 {
11415 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11416 "WLAN TL:No enough space in VOSS packet %p for DxE/BD/WLAN header", vosDataBuff));
11417 *pvosStatus = VOS_STATUS_E_INVAL;
11418 return;
11419 }
11420 pDxEHeader = (WLANBAL_sDXEHeaderType *)pucBuffPtr;
11421 pvBDHeader = (v_PVOID_t) &pDxEHeader[1];
11422
11423 /* UMA Tx acceleration is enabled.
11424 * UMA would help convert frames to 802.11, fill partial BD fields and
11425 * construct LLC header. To further accelerate this kind of frames,
11426 * HAL would attempt to reuse the BD descriptor if the BD signature
11427 * matches to the saved BD descriptor.
11428 */
11429 if(pStaInfo->wSTAType == WLAN_STA_IBSS)
11430 ucIsUnicast = !(((tANI_U8 *)pvPeekData)[0] & 0x01);
11431 else
11432 ucIsUnicast = 1;
11433
11434 *puFastFwdOK = (v_U32_t) WLANHAL_TxBdFastFwd(pvosGCtx, pvPeekData, pMetaInfo->ucTID, ucIsUnicast, pvBDHeader, usPktLen );
11435
11436 /* Can't be fast forwarded. Trim the VOS head back to original location. */
11437 if(! *puFastFwdOK){
11438 vos_pkt_trim_head(vosDataBuff, ucDxEBDWLANHeaderLen);
11439 }else{
11440 /* could be fast forwarded. Now notify BAL DxE header filling could be completely skipped
11441 */
11442 v_U32_t uPacketSize = WLANTL_BD_HEADER_LEN(0) + usPktLen;
11443 vos_pkt_set_user_data_ptr( vosDataBuff, VOS_PKT_USER_DATA_ID_BAL,
11444 (v_PVOID_t)uPacketSize);
11445 pDxEHeader->size = SWAP_ENDIAN_UINT32(uPacketSize);
11446 }
11447 *pvosStatus = VOS_STATUS_SUCCESS;
11448 return;
11449}
11450#endif /*WLAN_PERF*/
11451#endif
11452
11453#if 0
11454/*==========================================================================
11455 FUNCTION WLANTL_PrepareBDHeader
11456
11457 DESCRIPTION
11458 Inline function for preparing BD header before HAL processing.
11459
11460 DEPENDENCIES
11461 Just notify HAL that suspend in TL is complete.
11462
11463 PARAMETERS
11464
11465 IN
11466 vosDataBuff: vos data buffer
11467 ucDisableFrmXtl: is frame xtl disabled
11468
11469 OUT
11470 ppvBDHeader: it will contain the BD header
11471 pvDestMacAdddr: it will contain the destination MAC address
11472 pvosStatus: status of the combined processing
11473 pusPktLen: packet len.
11474
11475 RETURN VALUE
11476 No return.
11477
11478 SIDE EFFECTS
11479
11480============================================================================*/
11481void
11482WLANTL_PrepareBDHeader
11483(
11484 vos_pkt_t* vosDataBuff,
11485 v_PVOID_t* ppvBDHeader,
11486 v_MACADDR_t* pvDestMacAdddr,
11487 v_U8_t ucDisableFrmXtl,
11488 VOS_STATUS* pvosStatus,
11489 v_U16_t* pusPktLen,
11490 v_U8_t ucQosEnabled,
11491 v_U8_t ucWDSEnabled,
11492 v_U8_t extraHeadSpace
11493)
11494{
11495 v_U8_t ucHeaderOffset;
11496 v_U8_t ucHeaderLen;
Jeff Johnson295189b2012-06-20 16:38:30 -070011497 v_U8_t ucBDHeaderLen = WLANTL_BD_HEADER_LEN(ucDisableFrmXtl);
11498
11499 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
11500 /*-------------------------------------------------------------------------
11501 Get header pointer from VOSS
11502 !!! make sure reserve head zeros out the memory
11503 -------------------------------------------------------------------------*/
11504 vos_pkt_get_packet_length( vosDataBuff, pusPktLen);
11505
11506 if ( WLANTL_MAC_HEADER_LEN(ucDisableFrmXtl) > *pusPktLen )
11507 {
11508 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11509 "WLAN TL: Length of the packet smaller than expected network"
11510 " header %d", *pusPktLen ));
11511
11512 *pvosStatus = VOS_STATUS_E_INVAL;
11513 return;
11514 }
11515
11516 vos_pkt_reserve_head( vosDataBuff, ppvBDHeader,
11517 ucBDHeaderLen );
11518 if ( NULL == *ppvBDHeader )
11519 {
11520 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11521 "WLAN TL:VOSS packet corrupted on Attach BD header"));
11522 *pvosStatus = VOS_STATUS_E_INVAL;
11523 return;
11524 }
11525
11526 /*-----------------------------------------------------------------------
11527 Extract MAC address
11528 -----------------------------------------------------------------------*/
Jeff Johnson295189b2012-06-20 16:38:30 -070011529 {
11530 v_SIZE_t usMacAddrSize = VOS_MAC_ADDR_SIZE;
11531 *pvosStatus = vos_pkt_extract_data( vosDataBuff,
11532 ucBDHeaderLen +
11533 WLANTL_MAC_ADDR_ALIGN(ucDisableFrmXtl),
11534 (v_PVOID_t)pvDestMacAdddr,
11535 &usMacAddrSize );
11536 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011537 if ( VOS_STATUS_SUCCESS != *pvosStatus )
11538 {
11539 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11540 "WLAN TL:Failed while attempting to extract MAC Addr %d",
11541 *pvosStatus));
11542 }
11543 else
11544 {
11545 /*---------------------------------------------------------------------
11546 Fill MPDU info fields:
11547 - MPDU data start offset
11548 - MPDU header start offset
11549 - MPDU header length
11550 - MPDU length - this is a 16b field - needs swapping
11551 --------------------------------------------------------------------*/
11552 ucHeaderOffset = ucBDHeaderLen;
11553 ucHeaderLen = WLANTL_MAC_HEADER_LEN(ucDisableFrmXtl);
11554
11555 if ( 0 != ucDisableFrmXtl )
11556 {
11557 if ( 0 != ucQosEnabled )
11558 {
11559 ucHeaderLen += WLANTL_802_11_HEADER_QOS_CTL;
11560 }
11561
11562 // Similar to Qos we need something for WDS format !
11563 if ( ucWDSEnabled != 0 )
11564 {
11565 // If we have frame translation enabled
11566 ucHeaderLen += WLANTL_802_11_HEADER_ADDR4_LEN;
11567 }
11568 if ( extraHeadSpace != 0 )
11569 {
11570 // Decrease the packet length with the extra padding after the header
11571 *pusPktLen = *pusPktLen - extraHeadSpace;
11572 }
11573 }
11574
11575 WLANHAL_TX_BD_SET_MPDU_HEADER_LEN( *ppvBDHeader, ucHeaderLen);
11576 WLANHAL_TX_BD_SET_MPDU_HEADER_OFFSET( *ppvBDHeader, ucHeaderOffset);
11577 WLANHAL_TX_BD_SET_MPDU_DATA_OFFSET( *ppvBDHeader,
11578 ucHeaderOffset + ucHeaderLen + extraHeadSpace);
11579 WLANHAL_TX_BD_SET_MPDU_LEN( *ppvBDHeader, *pusPktLen);
11580
11581 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
11582 "WLAN TL: VALUES ARE HLen=%x Hoff=%x doff=%x len=%x ex=%d",
11583 ucHeaderLen, ucHeaderOffset,
11584 (ucHeaderOffset + ucHeaderLen + extraHeadSpace),
11585 *pusPktLen, extraHeadSpace));
11586 }/* if peek MAC success*/
11587
11588}/* WLANTL_PrepareBDHeader */
11589#endif
11590
Jeff Johnson295189b2012-06-20 16:38:30 -070011591//THIS IS A HACK AND NEEDS TO BE FIXED FOR CONCURRENCY
11592/*==========================================================================
11593 FUNCTION WLAN_TLGetNextTxIds
11594
11595 DESCRIPTION
11596 Gets the next station and next AC in the list that should be served by the TL.
11597
11598 Multiple Station Scheduling and TL queue management.
11599
11600 4 HDD BC/MC data packet queue status is specified as Station 0's status. Weights used
11601 in WFQ algorith are initialized in WLANTL_OPEN and contained in tlConfigInfo field.
11602 Each station has fields of ucPktPending and AC mask to tell whether a AC has traffic
11603 or not.
11604
11605 Stations are served in a round-robin fashion from highest priority to lowest priority.
11606 The number of round-robin times of each prioirty equals to the WFQ weights and differetiates
11607 the traffic of different prioirty. As such, stations can not provide low priority packets if
11608 high priority packets are all served.
11609
11610 DEPENDENCIES
11611
11612 PARAMETERS
11613
11614 IN
11615 pvosGCtx: pointer to the global vos context; a handle to TL's
11616 control block can be extracted from its context
11617
11618 OUT
11619 pucSTAId: Station ID
11620
11621 RETURN VALUE
11622 The result code associated with performing the operation
11623
11624 VOS_STATUS_SUCCESS: Everything is good
11625
11626 SIDE EFFECTS
11627
11628 TL context contains currently served station ID in ucCurrentSTA field, currently served AC
11629 in uCurServedAC field, and unserved weights of current AC in uCurLeftWeight.
11630 When existing from the function, these three fields are changed accordingly.
11631
11632============================================================================*/
11633VOS_STATUS
11634WLAN_TLAPGetNextTxIds
11635(
11636 v_PVOID_t pvosGCtx,
11637 v_U8_t* pucSTAId
11638)
11639{
11640 WLANTL_CbType* pTLCb;
11641 v_U8_t ucACFilter = 1;
Sravan Kumar Kairamb0edc612016-10-26 13:55:24 +053011642 v_U8_t ucNextSTA, ucTempSTA;
Jeff Johnson295189b2012-06-20 16:38:30 -070011643 v_BOOL_t isServed = TRUE; //current round has find a packet or not
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +053011644 v_U8_t ucACLoopNum = WLANTL_AC_HIGH_PRIO + 1; //number of loop to go
Jeff Johnson295189b2012-06-20 16:38:30 -070011645 v_U8_t uFlowMask; // TX FlowMask from WDA
11646 uint8 ucACMask;
Sravan Kumar Kairamb0edc612016-10-26 13:55:24 +053011647 uint8 i = 0;
11648 uint8 j;
Sravan Kumar Kairam18017eb2017-01-03 14:58:13 +053011649 uint8 minWeightSta;
11650 uint32_t sta_bitmask = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070011651 /*------------------------------------------------------------------------
11652 Extract TL control block
11653 ------------------------------------------------------------------------*/
11654 //ENTER();
11655
11656 pTLCb = VOS_GET_TL_CB(pvosGCtx);
11657 if ( NULL == pTLCb )
11658 {
11659 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11660 "WLAN TL:Invalid TL pointer from pvosGCtx on WLAN_TLAPGetNextTxIds"));
11661 return VOS_STATUS_E_FAULT;
11662 }
11663
11664 if ( VOS_STATUS_SUCCESS != WDA_DS_GetTxFlowMask( pvosGCtx, &uFlowMask ) )
11665 {
11666 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11667 "WLAN TL:Failed to retrieve Flow control mask from WDA"));
11668 return VOS_STATUS_E_FAULT;
11669 }
11670
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +053011671 /* The flow mask does not differentiate between different ACs/Qs
11672 * since we use a single dxe channel for all ACs/Qs, hence it is
11673 * enough to check that there are dxe resources on data channel
11674 */
11675 uFlowMask &= WLANTL_DATA_FLOW_MASK;
11676
11677 if (0 == uFlowMask)
11678 {
11679 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11680 "WLAN TL: No resources to send packets"));
11681
11682 // Setting STA Id to invalid if mask is 0
11683 *pucSTAId = WLAN_MAX_STA_COUNT;
11684 return VOS_STATUS_E_FAULT;
11685 }
11686
Jeff Johnson295189b2012-06-20 16:38:30 -070011687 ucNextSTA = pTLCb->ucCurrentSTA;
11688
11689 ++ucNextSTA;
11690
11691 if ( WLAN_MAX_STA_COUNT <= ucNextSTA )
11692 {
11693 //one round is done.
11694 ucNextSTA = 0;
11695 pTLCb->ucCurLeftWeight--;
11696 isServed = FALSE;
11697 if ( 0 == pTLCb->ucCurLeftWeight )
11698 {
11699 //current prioirty is done
11700 if ( WLANTL_AC_BK == (WLANTL_ACEnumType)pTLCb->uCurServedAC )
11701 {
11702 //end of current VO, VI, BE, BK loop. Reset priority.
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +053011703 pTLCb->uCurServedAC = WLANTL_AC_HIGH_PRIO;
Jeff Johnson295189b2012-06-20 16:38:30 -070011704 }
11705 else
11706 {
11707 pTLCb->uCurServedAC --;
11708 }
11709
11710 pTLCb->ucCurLeftWeight = pTLCb->tlConfigInfo.ucAcWeights[pTLCb->uCurServedAC];
11711
11712 } // (0 == pTLCb->ucCurLeftWeight)
11713 } //( WLAN_MAX_STA_COUNT == ucNextSTA )
11714
Sravan Kumar Kairamb0edc612016-10-26 13:55:24 +053011715 ucTempSTA = ucNextSTA;
Sravan Kumar Kairam18017eb2017-01-03 14:58:13 +053011716 minWeightSta = ucNextSTA;
Sravan Kumar Kairamb0edc612016-10-26 13:55:24 +053011717
Jeff Johnson295189b2012-06-20 16:38:30 -070011718 //decide how many loops to go. if current loop is partial, do one extra to make sure
11719 //we cover every station
11720 if ((1 == pTLCb->ucCurLeftWeight) && (ucNextSTA != 0))
11721 {
11722 ucACLoopNum ++; // now is 5 loops
11723 }
11724
11725 /* Start with highest priority. ucNextSTA, pTLCb->uCurServedAC, pTLCb->ucCurLeftWeight
11726 all have previous values.*/
11727 for (; ucACLoopNum > 0; ucACLoopNum--)
11728 {
11729
11730 ucACFilter = 1 << pTLCb->uCurServedAC;
11731
11732 // pTLCb->ucCurLeftWeight keeps previous results.
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +053011733 for (; (pTLCb->ucCurLeftWeight > 0) ; pTLCb->ucCurLeftWeight-- )
Jeff Johnson295189b2012-06-20 16:38:30 -070011734 {
11735
11736 for ( ; ucNextSTA < WLAN_MAX_STA_COUNT; ucNextSTA ++ )
11737 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053011738 if(NULL == pTLCb->atlSTAClients[ucNextSTA])
11739 {
11740 continue;
11741 }
11742 WLAN_TL_AC_ARRAY_2_MASK (pTLCb->atlSTAClients[ucNextSTA], ucACMask, i);
Jeff Johnson295189b2012-06-20 16:38:30 -070011743
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053011744 if ( (0 == pTLCb->atlSTAClients[ucNextSTA]->ucExists) ||
11745 ((0 == pTLCb->atlSTAClients[ucNextSTA]->ucPktPending) && !(ucACMask)) ||
Jeff Johnson295189b2012-06-20 16:38:30 -070011746 (0 == (ucACMask & ucACFilter)) )
11747
11748 {
Tushnim Bhattacharyya39a8f182013-02-20 18:10:30 -080011749 //current station does not exist or have any packet to serve.
11750 continue;
11751 }
11752
Bhargav Shahfbaeca22016-07-13 10:27:35 +053011753 if ((WLANTL_STA_AUTHENTICATED != pTLCb->atlSTAClients[ucNextSTA]->tlState)
11754 || (pTLCb->atlSTAClients[ucNextSTA]->disassoc_progress == VOS_TRUE ))
Tushnim Bhattacharyya39a8f182013-02-20 18:10:30 -080011755 {
11756 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
11757 "%s Sta %d not in auth state so skipping it.",
11758 __func__, ucNextSTA));
Jeff Johnson295189b2012-06-20 16:38:30 -070011759 continue;
11760 }
11761
11762 //go to next station if current station can't send due to flow control
11763 //Station is allowed to send when it is not in LWM mode. When station is in LWM mode,
11764 //station is allowed to send only after FW reports FW memory is below threshold and on-fly
11765 //packets are less then allowed value
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053011766 if ( (TRUE == pTLCb->atlSTAClients[ucNextSTA]->ucLwmModeEnabled) &&
11767 ((FALSE == pTLCb->atlSTAClients[ucNextSTA]->ucLwmEventReported) ||
11768 (0 < pTLCb->atlSTAClients[ucNextSTA]->uBuffThresholdMax))
Jeff Johnson295189b2012-06-20 16:38:30 -070011769 )
11770 {
11771 continue;
11772 }
11773
Sravan Kumar Kairamb0edc612016-10-26 13:55:24 +053011774 /*
11775 * Initial weight is 0 is for all the stations. As part of FW TX stats
11776 * indication to host, good peer weight is updated to one and the
11777 * remaining peers weight is updated based on their RA rates and BTQM
11778 * queued frames length. TL skips fetching the packet until the station
11779 * has got chances equal to its weight.
11780 */
11781 if (pTLCb->atlSTAClients[ucNextSTA]->weight > WLANTL_GOOD_STA_WEIGHT) {
11782 if (pTLCb->atlSTAClients[ucNextSTA]->weight_count <=
Sravan Kumar Kairam18017eb2017-01-03 14:58:13 +053011783 pTLCb->atlSTAClients[ucNextSTA]->weight)
11784 {
11785 if (pTLCb->atlSTAClients[minWeightSta]->weight <= 1)
11786 minWeightSta = ucNextSTA;
11787 else if (pTLCb->atlSTAClients[ucNextSTA]->weight <
11788 pTLCb->atlSTAClients[minWeightSta]->weight) {
11789 minWeightSta = ucNextSTA;
11790 }
11791 sta_bitmask |= (1 << ucNextSTA);
Sravan Kumar Kairamb0edc612016-10-26 13:55:24 +053011792 pTLCb->atlSTAClients[ucNextSTA]->weight_count++;
11793 continue;
11794 }
11795 else
11796 pTLCb->atlSTAClients[ucNextSTA]->weight_count = 0;
11797 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011798
11799 // Find a station. Weight is updated already.
11800 *pucSTAId = ucNextSTA;
11801 pTLCb->ucCurrentSTA = ucNextSTA;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053011802 pTLCb->atlSTAClients[*pucSTAId]->ucCurrentAC = pTLCb->uCurServedAC;
Jeff Johnson295189b2012-06-20 16:38:30 -070011803
11804 TLLOG4(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_LOW,
11805 " TL serve one station AC: %d W: %d StaId: %d",
11806 pTLCb->uCurServedAC, pTLCb->ucCurLeftWeight, pTLCb->ucCurrentSTA ));
11807
11808 return VOS_STATUS_SUCCESS;
11809 } //STA loop
11810
Sravan Kumar Kairamb0edc612016-10-26 13:55:24 +053011811 for (j = 0; j < ucTempSTA; j++) {
11812 if (NULL == pTLCb->atlSTAClients[j])
11813 continue;
11814
11815 WLAN_TL_AC_ARRAY_2_MASK (pTLCb->atlSTAClients[j], ucACMask, i);
11816
11817 if ((0 == pTLCb->atlSTAClients[j]->ucExists) ||
11818 ((0 == pTLCb->atlSTAClients[j]->ucPktPending) && !(ucACMask)) ||
11819 (0 == (ucACMask & ucACFilter)))
11820 continue;
11821
11822 if ((WLANTL_STA_AUTHENTICATED != pTLCb->atlSTAClients[j]->tlState) ||
11823 (pTLCb->atlSTAClients[j]->disassoc_progress == VOS_TRUE)) {
11824 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
11825 "%s Sta %d not in auth state so skipping it.",
11826 __func__, ucNextSTA));
11827 continue;
11828 }
11829
11830 if ((TRUE == pTLCb->atlSTAClients[j]->ucLwmModeEnabled) &&
11831 ((FALSE == pTLCb->atlSTAClients[j]->ucLwmEventReported) ||
11832 (0 < pTLCb->atlSTAClients[j]->uBuffThresholdMax)))
11833 continue;
11834
11835 if (pTLCb->atlSTAClients[j]->weight > WLANTL_GOOD_STA_WEIGHT) {
11836 if (pTLCb->atlSTAClients[j]->weight_count <=
Sravan Kumar Kairam18017eb2017-01-03 14:58:13 +053011837 pTLCb->atlSTAClients[j]->weight)
11838 {
11839 if (pTLCb->atlSTAClients[minWeightSta]->weight <= 1)
11840 minWeightSta = j;
11841 else if (pTLCb->atlSTAClients[j]->weight <
11842 pTLCb->atlSTAClients[minWeightSta]->weight) {
11843 minWeightSta = j;
11844 }
11845 sta_bitmask |= (1 << j);
Sravan Kumar Kairamb0edc612016-10-26 13:55:24 +053011846 pTLCb->atlSTAClients[j]->weight_count++;
11847 continue;
11848 }
11849 else
11850 pTLCb->atlSTAClients[j]->weight_count = 0;
11851 }
11852
11853 *pucSTAId = j;
11854 pTLCb->ucCurrentSTA = j;
11855 pTLCb->atlSTAClients[*pucSTAId]->ucCurrentAC = pTLCb->uCurServedAC;
11856
11857 TLLOG4(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_LOW,
11858 " TL serve one station AC: %d W: %d StaId: %d",
11859 pTLCb->uCurServedAC, pTLCb->ucCurLeftWeight, pTLCb->ucCurrentSTA ));
11860 return VOS_STATUS_SUCCESS;
11861 }
11862
Sravan Kumar Kairam18017eb2017-01-03 14:58:13 +053011863 /* Fecth packet from the stations with minimum weight among them */
11864 if (pTLCb->atlSTAClients[minWeightSta] &&
11865 pTLCb->atlSTAClients[minWeightSta]->ucPktPending)
11866 {
11867 *pucSTAId = minWeightSta;
11868 pTLCb->ucCurrentSTA = minWeightSta;
11869 pTLCb->atlSTAClients[*pucSTAId]->ucCurrentAC = pTLCb->uCurServedAC;
11870
11871 for (j = 0; sta_bitmask != 0; sta_bitmask >>= 1, j++)
11872 {
11873 if (0 == (sta_bitmask & 0x1))
11874 continue;
11875
11876 if (minWeightSta == j)
11877 continue;
11878 /* To ensure fairness between stations */
11879 pTLCb->atlSTAClients[j]->weight_count +=
11880 pTLCb->atlSTAClients[minWeightSta]->weight -
11881 pTLCb->atlSTAClients[minWeightSta]->weight_count;
11882 }
11883 pTLCb->atlSTAClients[minWeightSta]->weight_count = 0;
11884
11885 TLLOG4(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_LOW,
11886 " TL serve one station AC: %d W: %d StaId: %d",
11887 pTLCb->uCurServedAC, pTLCb->ucCurLeftWeight, pTLCb->ucCurrentSTA ));
11888 return VOS_STATUS_SUCCESS;
11889 }
11890
Jeff Johnson295189b2012-06-20 16:38:30 -070011891 ucNextSTA = 0;
11892 if ( FALSE == isServed )
11893 {
11894 //current loop finds no packet.no need to repeat for the same priority
11895 break;
11896 }
11897 //current loop is partial loop. go for one more loop.
11898 isServed = FALSE;
11899
11900 } //Weight loop
11901
11902 if (WLANTL_AC_BK == pTLCb->uCurServedAC)
11903 {
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +053011904 pTLCb->uCurServedAC = WLANTL_AC_HIGH_PRIO;
Jeff Johnson295189b2012-06-20 16:38:30 -070011905 }
11906 else
11907 {
11908 pTLCb->uCurServedAC--;
11909 }
11910 pTLCb->ucCurLeftWeight = pTLCb->tlConfigInfo.ucAcWeights[pTLCb->uCurServedAC];
11911
11912 }// AC loop
11913
11914 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
Arif Hussainf2b00992013-11-17 21:46:15 -080011915 " TL can't find one station to serve" ));
Jeff Johnson295189b2012-06-20 16:38:30 -070011916
11917 pTLCb->uCurServedAC = WLANTL_AC_BK;
11918 pTLCb->ucCurLeftWeight = 1;
11919 //invalid number will be captured by caller
11920 pTLCb->ucCurrentSTA = WLAN_MAX_STA_COUNT;
11921
11922 *pucSTAId = pTLCb->ucCurrentSTA;
Jeff Johnson295189b2012-06-20 16:38:30 -070011923 return VOS_STATUS_E_FAULT;
11924}
11925
11926
11927/*==========================================================================
11928 FUNCTION WLAN_TLGetNextTxIds
11929
11930 DESCRIPTION
11931 Gets the next station and next AC in the list
11932
11933 DEPENDENCIES
11934
11935 PARAMETERS
11936
11937 IN
11938 pvosGCtx: pointer to the global vos context; a handle to TL's
11939 control block can be extracted from its context
11940
11941 OUT
11942 pucSTAId: Station ID
11943
11944
11945 RETURN VALUE
11946 The result code associated with performing the operation
11947
11948 VOS_STATUS_SUCCESS: Everything is good :)
11949
11950 SIDE EFFECTS
11951
11952============================================================================*/
11953VOS_STATUS
11954WLAN_TLGetNextTxIds
11955(
11956 v_PVOID_t pvosGCtx,
11957 v_U8_t* pucSTAId
11958)
11959{
11960 WLANTL_CbType* pTLCb;
11961 v_U8_t ucNextAC;
11962 v_U8_t ucNextSTA;
11963 v_U8_t ucCount;
11964 v_U8_t uFlowMask; // TX FlowMask from WDA
11965 v_U8_t ucACMask = 0;
11966 v_U8_t i = 0;
11967
11968 tBssSystemRole systemRole; //RG HACK to be removed
11969 tpAniSirGlobal pMac;
11970
11971 pMac = vos_get_context(VOS_MODULE_ID_PE, pvosGCtx);
11972 if ( NULL == pMac )
11973 {
11974 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070011975 "%s: Invalid pMac", __func__));
Jeff Johnson295189b2012-06-20 16:38:30 -070011976 return VOS_STATUS_E_FAULT;
11977 }
11978
11979 systemRole = wdaGetGlobalSystemRole(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -070011980
Jeff Johnson295189b2012-06-20 16:38:30 -070011981 /*------------------------------------------------------------------------
11982 Extract TL control block
11983 ------------------------------------------------------------------------*/
11984 pTLCb = VOS_GET_TL_CB(pvosGCtx);
11985 if ( NULL == pTLCb )
11986 {
11987 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11988 "WLAN TL:Invalid TL pointer from pvosGCtx on WLAN_TLGetNextTxIds"));
11989 return VOS_STATUS_E_FAULT;
11990 }
11991
Sunil Ravid5406f22013-01-22 00:18:31 -080011992#ifdef FEATURE_WLAN_TDLS
Agarwal Ashishcd86f7b2014-06-16 17:11:58 +053011993 if ((eSYSTEM_AP_ROLE == systemRole) ||
Katya Nigam1fd24402015-02-16 14:52:19 +053011994 (eSYSTEM_STA_IN_IBSS_ROLE == systemRole) ||
Agarwal Ashishcd86f7b2014-06-16 17:11:58 +053011995 (vos_concurrent_open_sessions_running()) || pTLCb->ucTdlsPeerCount)
Sunil Ravid5406f22013-01-22 00:18:31 -080011996#else
Agarwal Ashishcd86f7b2014-06-16 17:11:58 +053011997 if ((eSYSTEM_AP_ROLE == systemRole) ||
Katya Nigam1fd24402015-02-16 14:52:19 +053011998 (eSYSTEM_STA_IN_IBSS_ROLE == systemRole) ||
Agarwal Ashishcd86f7b2014-06-16 17:11:58 +053011999 (vos_concurrent_open_sessions_running()))
Sunil Ravid5406f22013-01-22 00:18:31 -080012000#endif
12001 {
12002 return WLAN_TLAPGetNextTxIds(pvosGCtx,pucSTAId);
12003 }
12004
12005
Jeff Johnson295189b2012-06-20 16:38:30 -070012006 if ( VOS_STATUS_SUCCESS != WDA_DS_GetTxFlowMask( pvosGCtx, &uFlowMask ) )
12007 {
12008 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
12009 "WLAN TL:Failed to retrieve Flow control mask from WDA"));
12010 return VOS_STATUS_E_FAULT;
12011 }
12012
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +053012013 /* The flow mask does not differentiate between different ACs/Qs
12014 * since we use a single dxe channel for all ACs/Qs, hence it is
12015 * enough to check that there are dxe resources on data channel
12016 */
12017 uFlowMask &= WLANTL_DATA_FLOW_MASK;
12018
12019 if (0 == uFlowMask)
12020 {
12021 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
12022 "WLAN TL: No resources to send packets"));
12023
12024 // Setting STA id to invalid if mask is 0
12025 *pucSTAId = WLAN_MAX_STA_COUNT;
12026 return VOS_STATUS_E_FAULT;
12027 }
12028
Jeff Johnson295189b2012-06-20 16:38:30 -070012029 /*STA id - no priority yet implemented */
12030 /*-----------------------------------------------------------------------
12031 Choose the next STA for tx - for now go in a round robin fashion
12032 through all the stations that have pending packets
12033 -------------------------------------------------------------------------*/
12034 ucNextSTA = pTLCb->ucCurrentSTA;
12035
12036 pTLCb->ucCurrentSTA = WLAN_MAX_STA_COUNT;
12037 for ( ucCount = 0;
12038 ucCount < WLAN_MAX_STA_COUNT;
12039 ucCount++ )
12040 {
12041 ucNextSTA = ( (ucNextSTA+1) >= WLAN_MAX_STA_COUNT )?0:(ucNextSTA+1);
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053012042 if(NULL == pTLCb->atlSTAClients[ucNextSTA])
12043 {
12044 continue;
12045 }
Sravan Kumar Kairamb0edc612016-10-26 13:55:24 +053012046
12047 if ((pTLCb->atlSTAClients[ucNextSTA]->weight > WLANTL_GOOD_STA_WEIGHT) &&
12048 (pTLCb->atlSTAClients[ucNextSTA]->ucPktPending)) {
12049 if (pTLCb->atlSTAClients[ucNextSTA]->weight_count <=
12050 pTLCb->atlSTAClients[ucNextSTA]->weight) {
12051 pTLCb->atlSTAClients[ucNextSTA]->weight_count++;
12052 continue;
12053 }
12054 else
12055 pTLCb->atlSTAClients[ucNextSTA]->weight_count = 0;
12056 }
12057
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053012058 if (( pTLCb->atlSTAClients[ucNextSTA]->ucExists ) &&
12059 ( pTLCb->atlSTAClients[ucNextSTA]->ucPktPending ))
Jeff Johnson295189b2012-06-20 16:38:30 -070012060 {
Tushnim Bhattacharyya39a8f182013-02-20 18:10:30 -080012061 if (WLANTL_STA_AUTHENTICATED == pTLCb->atlSTAClients[ucNextSTA]->tlState)
12062 {
12063 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
12064 "STA ID: %d on WLAN_TLGetNextTxIds", *pucSTAId));
12065 pTLCb->ucCurrentSTA = ucNextSTA;
12066 break;
Tushnim Bhattacharyya5dd94562013-03-20 20:15:03 -070012067 }
12068 else
12069 {
Tushnim Bhattacharyya39a8f182013-02-20 18:10:30 -080012070 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
12071 "%s Sta %d is not in auth state, skipping this sta.",
12072 __func__, ucNextSTA));
Tushnim Bhattacharyya5dd94562013-03-20 20:15:03 -070012073 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012074 }
12075 }
12076
12077 *pucSTAId = pTLCb->ucCurrentSTA;
12078
12079 if ( WLANTL_STA_ID_INVALID( *pucSTAId ) )
12080 {
12081 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
12082 "WLAN TL:No station registered with TL at this point"));
12083
12084 return VOS_STATUS_E_FAULT;
12085
12086 }
12087
12088 /*Convert the array to a mask for easier operation*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053012089 WLAN_TL_AC_ARRAY_2_MASK( pTLCb->atlSTAClients[*pucSTAId], ucACMask, i);
Jeff Johnson295189b2012-06-20 16:38:30 -070012090
12091 if ( 0 == ucACMask )
12092 {
12093 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
12094 "WLAN TL: Mask 0 "
12095 "STA ID: %d on WLAN_TLGetNextTxIds", *pucSTAId));
12096
12097 /*setting STA id to invalid if mask is 0*/
12098 *pucSTAId = WLAN_MAX_STA_COUNT;
12099
12100 return VOS_STATUS_E_FAULT;
12101 }
12102
12103 /*-----------------------------------------------------------------------
12104 AC is updated whenever a packet is fetched from HDD -> the current
12105 weight of such an AC cannot be 0 -> in this case TL is expected to
12106 exit this function at this point during the main Tx loop
12107 -----------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053012108 if ( 0 < pTLCb->atlSTAClients[*pucSTAId]->ucCurrentWeight )
Jeff Johnson295189b2012-06-20 16:38:30 -070012109 {
12110 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
12111 "WLAN TL: Maintaining serviced AC to: %d for Weight: %d",
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053012112 pTLCb->atlSTAClients[*pucSTAId]->ucCurrentAC ,
12113 pTLCb->atlSTAClients[*pucSTAId]->ucCurrentWeight));
Jeff Johnson295189b2012-06-20 16:38:30 -070012114 return VOS_STATUS_SUCCESS;
12115 }
12116
12117 /*-----------------------------------------------------------------------
12118 Choose highest priority AC - !!! optimize me
12119 -----------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053012120 ucNextAC = pTLCb->atlSTAClients[*pucSTAId]->ucCurrentAC;
Jeff Johnson295189b2012-06-20 16:38:30 -070012121 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
12122 "Next AC: %d", ucNextAC));
12123
12124 while ( 0 != ucACMask )
12125 {
12126 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
12127 " AC Mask: %d Next: %d Res : %d",
12128 ucACMask, ( 1 << ucNextAC ), ( ucACMask & ( 1 << ucNextAC ))));
12129
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +053012130 if ( 0 != ( ucACMask & ( 1 << ucNextAC )))
Jeff Johnson295189b2012-06-20 16:38:30 -070012131 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053012132 pTLCb->atlSTAClients[*pucSTAId]->ucCurrentAC =
Jeff Johnson295189b2012-06-20 16:38:30 -070012133 (WLANTL_ACEnumType)ucNextAC;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053012134 pTLCb->atlSTAClients[*pucSTAId]->ucCurrentWeight =
Jeff Johnson295189b2012-06-20 16:38:30 -070012135 pTLCb->tlConfigInfo.ucAcWeights[ucNextAC];
12136
12137 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
12138 "WLAN TL: Switching serviced AC to: %d with Weight: %d",
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053012139 pTLCb->atlSTAClients[*pucSTAId]->ucCurrentAC ,
12140 pTLCb->atlSTAClients[*pucSTAId]->ucCurrentWeight));
Jeff Johnson295189b2012-06-20 16:38:30 -070012141 break;
12142 }
12143
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +053012144 if (ucNextAC == WLANTL_AC_BK)
12145 ucNextAC = WLANTL_AC_HIGH_PRIO;
12146 else
12147 ucNextAC--;
Jeff Johnson295189b2012-06-20 16:38:30 -070012148
12149 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
12150 "Next AC %d", ucNextAC));
Jeff Johnson295189b2012-06-20 16:38:30 -070012151 }
12152
12153 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
12154 " C AC: %d C W: %d",
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053012155 pTLCb->atlSTAClients[*pucSTAId]->ucCurrentAC,
12156 pTLCb->atlSTAClients[*pucSTAId]->ucCurrentWeight));
Jeff Johnson295189b2012-06-20 16:38:30 -070012157
12158 return VOS_STATUS_SUCCESS;
12159}/* WLAN_TLGetNextTxIds */
12160
Jeff Johnson295189b2012-06-20 16:38:30 -070012161
12162
12163/*==========================================================================
12164 DEFAULT HANDLERS: Registered at initialization with TL
12165 ==========================================================================*/
12166
12167/*==========================================================================
12168
12169 FUNCTION WLANTL_MgmtFrmRxDefaultCb
12170
12171 DESCRIPTION
12172 Default Mgmt Frm rx callback: asserts all the time. If this function gets
12173 called it means there is no registered rx cb pointer for Mgmt Frm.
12174
12175 DEPENDENCIES
12176
12177 PARAMETERS
12178 Not used.
12179
12180 RETURN VALUE
12181
12182 VOS_STATUS_E_FAILURE: Always FAILURE.
12183
12184============================================================================*/
12185VOS_STATUS
12186WLANTL_MgmtFrmRxDefaultCb
12187(
12188 v_PVOID_t pvosGCtx,
12189 v_PVOID_t vosBuff
12190)
12191{
12192 if ( NULL != vosBuff )
12193 {
12194 TLLOGP(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_FATAL,
12195 "WLAN TL:Fatal failure: No registered Mgmt Frm client on pkt RX"));
12196 /* Drop packet */
12197 vos_pkt_return_packet((vos_pkt_t *)vosBuff);
12198 }
12199
Jeff Johnson295189b2012-06-20 16:38:30 -070012200 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
12201 "WLAN TL: No registered Mgmt Frm client on pkt RX. Load/Unload in progress, Ignore"));
Jeff Johnson295189b2012-06-20 16:38:30 -070012202
12203 return VOS_STATUS_E_FAILURE;
12204}/*WLANTL_MgmtFrmRxDefaultCb*/
12205
12206/*==========================================================================
12207
Madan Mohan Koyyalamudi6c2977d2013-09-04 15:42:45 +053012208 FUNCTION WLANTL_BAPRxDefaultCb
Jeff Johnson295189b2012-06-20 16:38:30 -070012209
12210 DESCRIPTION
12211 Default BAP rx callback: asserts all the time. If this function gets
12212 called it means there is no registered rx cb pointer for BAP.
12213
12214 DEPENDENCIES
12215
12216 PARAMETERS
12217 Not used.
12218
12219 RETURN VALUE
12220
12221 VOS_STATUS_E_FAILURE: Always FAILURE.
12222
12223============================================================================*/
12224VOS_STATUS
12225WLANTL_BAPRxDefaultCb
12226(
12227 v_PVOID_t pvosGCtx,
12228 vos_pkt_t* vosDataBuff,
12229 WLANTL_BAPFrameEnumType frameType
12230)
12231{
12232 TLLOGP(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_FATAL,
12233 "WLAN TL:Fatal failure: No registered BAP client on BAP pkt RX"));
12234#ifndef BTAMP_TEST
12235 VOS_ASSERT(0);
12236#endif
12237 return VOS_STATUS_E_FAILURE;
12238}/*WLANTL_MgmtFrmRxDefaultCb*/
12239
12240/*==========================================================================
12241
12242 FUNCTION WLANTL_STARxDefaultCb
12243
12244 DESCRIPTION
12245 Default STA rx callback: asserts all the time. If this function gets
12246 called it means there is no registered rx cb pointer for station.
12247 (Mem corruption most likely, it should never happen)
12248
12249 DEPENDENCIES
12250
12251 PARAMETERS
12252 Not used.
12253
12254 RETURN VALUE
12255
12256 VOS_STATUS_E_FAILURE: Always FAILURE.
12257
12258============================================================================*/
12259VOS_STATUS
12260WLANTL_STARxDefaultCb
12261(
12262 v_PVOID_t pvosGCtx,
12263 vos_pkt_t* vosDataBuff,
12264 v_U8_t ucSTAId,
12265 WLANTL_RxMetaInfoType* pRxMetaInfo
12266)
12267{
12268 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
12269 "WLAN TL: No registered STA client rx cb for STAID: %d dropping pkt",
12270 ucSTAId));
12271 vos_pkt_return_packet(vosDataBuff);
Madan Mohan Koyyalamudi6c2977d2013-09-04 15:42:45 +053012272 return VOS_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012273}/*WLANTL_MgmtFrmRxDefaultCb*/
12274
12275
12276/*==========================================================================
12277
12278 FUNCTION WLANTL_STAFetchPktDefaultCb
12279
12280 DESCRIPTION
12281 Default fetch callback: asserts all the time. If this function gets
12282 called it means there is no registered fetch cb pointer for station.
12283 (Mem corruption most likely, it should never happen)
12284
12285 DEPENDENCIES
12286
12287 PARAMETERS
12288 Not used.
12289
12290 RETURN VALUE
12291
12292 VOS_STATUS_E_FAILURE: Always FAILURE.
12293
12294============================================================================*/
12295VOS_STATUS
12296WLANTL_STAFetchPktDefaultCb
12297(
12298 v_PVOID_t pvosGCtx,
12299 v_U8_t* pucSTAId,
12300 WLANTL_ACEnumType ucAC,
12301 vos_pkt_t** vosDataBuff,
12302 WLANTL_MetaInfoType* tlMetaInfo
12303)
12304{
12305 TLLOGP(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_FATAL,
12306 "WLAN TL:Fatal failure: No registered STA client on data pkt RX"));
12307 VOS_ASSERT(0);
12308 return VOS_STATUS_E_FAILURE;
12309}/*WLANTL_MgmtFrmRxDefaultCb*/
12310
12311/*==========================================================================
12312
12313 FUNCTION WLANTL_TxCompDefaultCb
12314
12315 DESCRIPTION
12316 Default tx complete handler. It will release the completed pkt to
12317 prevent memory leaks.
12318
12319 PARAMETERS
12320
12321 IN
12322 pvosGCtx: pointer to the global vos context; a handle to
12323 TL/HAL/PE/BAP/HDD control block can be extracted from
12324 its context
12325 vosDataBuff: pointer to the VOSS data buffer that was transmitted
12326 wTxSTAtus: status of the transmission
12327
12328
12329 RETURN VALUE
12330 The result code associated with performing the operation; please
12331 check vos_pkt_return_packet for possible error codes.
12332
12333 Please check vos_pkt_return_packet API for possible return values.
12334
12335============================================================================*/
12336VOS_STATUS
12337WLANTL_TxCompDefaultCb
12338(
12339 v_PVOID_t pvosGCtx,
12340 vos_pkt_t* vosDataBuff,
12341 VOS_STATUS wTxSTAtus
12342)
12343{
12344 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
12345 "WLAN TL:TXComp not registered, releasing pkt to prevent mem leak"));
12346 return vos_pkt_return_packet(vosDataBuff);
12347}/*WLANTL_TxCompDefaultCb*/
12348
12349
12350/*==========================================================================
12351 Cleanup functions
12352 ==========================================================================*/
12353
12354/*==========================================================================
12355
12356 FUNCTION WLANTL_CleanCB
12357
12358 DESCRIPTION
12359 Cleans TL control block
12360
12361 DEPENDENCIES
12362
12363 PARAMETERS
12364
12365 IN
12366 pTLCb: pointer to TL's control block
12367 ucEmpty: set if TL has to clean up the queues and release pedning pkts
12368
12369 RETURN VALUE
12370 The result code associated with performing the operation
12371
12372 VOS_STATUS_E_INVAL: invalid input parameters
12373 VOS_STATUS_SUCCESS: Everything is good :)
12374
12375 SIDE EFFECTS
12376
12377============================================================================*/
12378VOS_STATUS
12379WLANTL_CleanCB
12380(
12381 WLANTL_CbType* pTLCb,
12382 v_U8_t ucEmpty
12383)
12384{
12385 v_U8_t ucIndex;
12386 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
12387
12388 /*-------------------------------------------------------------------------
12389 Sanity check
12390 -------------------------------------------------------------------------*/
12391 if ( NULL == pTLCb )
12392 {
12393 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
12394 "WLAN TL:Invalid parameter sent on WLANTL_CleanCB"));
12395 return VOS_STATUS_E_INVAL;
12396 }
12397
12398 /* number of packets sent to BAL waiting for tx complete confirmation */
12399 pTLCb->usPendingTxCompleteCount = 0;
12400
12401 /* global suspend flag */
12402 vos_atomic_set_U8( &pTLCb->ucTxSuspended, 1);
12403
12404 /* resource flag */
12405 pTLCb->uResCount = 0;
12406
12407
12408 /*-------------------------------------------------------------------------
12409 Client stations
12410 -------------------------------------------------------------------------*/
12411 for ( ucIndex = 0; ucIndex < WLAN_MAX_STA_COUNT ; ucIndex++)
12412 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053012413 if(NULL != pTLCb->atlSTAClients[ucIndex])
12414 {
12415 WLANTL_CleanSTA( pTLCb->atlSTAClients[ucIndex], ucEmpty);
12416 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012417 }
12418
12419 /*-------------------------------------------------------------------------
12420 Management Frame client
12421 -------------------------------------------------------------------------*/
12422 pTLCb->tlMgmtFrmClient.ucExists = 0;
12423
12424 if ( ( 0 != ucEmpty) &&
12425 ( NULL != pTLCb->tlMgmtFrmClient.vosPendingDataBuff ))
12426 {
12427 vos_pkt_return_packet(pTLCb->tlMgmtFrmClient.vosPendingDataBuff);
12428 }
12429
12430 pTLCb->tlMgmtFrmClient.vosPendingDataBuff = NULL;
12431
12432 /* set to a default cb in order to prevent constant checking for NULL */
12433 pTLCb->tlMgmtFrmClient.pfnTlMgmtFrmRx = WLANTL_MgmtFrmRxDefaultCb;
12434
12435 /*-------------------------------------------------------------------------
12436 BT AMP client
12437 -------------------------------------------------------------------------*/
12438 pTLCb->tlBAPClient.ucExists = 0;
12439
12440 if (( 0 != ucEmpty) &&
12441 ( NULL != pTLCb->tlBAPClient.vosPendingDataBuff ))
12442 {
12443 vos_pkt_return_packet(pTLCb->tlBAPClient.vosPendingDataBuff);
12444 }
12445
12446 if (( 0 != ucEmpty) &&
12447 ( NULL != pTLCb->vosDummyBuf ))
12448 {
12449 vos_pkt_return_packet(pTLCb->vosDummyBuf);
12450 }
12451
12452 pTLCb->tlBAPClient.vosPendingDataBuff = NULL;
12453
12454 pTLCb->vosDummyBuf = NULL;
12455 pTLCb->vosTempBuf = NULL;
12456 pTLCb->ucCachedSTAId = WLAN_MAX_STA_COUNT;
12457
12458 /* set to a default cb in order to prevent constant checking for NULL */
12459 pTLCb->tlBAPClient.pfnTlBAPRx = WLANTL_BAPRxDefaultCb;
12460
12461 pTLCb->ucRegisteredStaId = WLAN_MAX_STA_COUNT;
12462
12463 return VOS_STATUS_SUCCESS;
12464
12465}/* WLANTL_CleanCB*/
12466
12467/*==========================================================================
12468
12469 FUNCTION WLANTL_CleanSTA
12470
12471 DESCRIPTION
12472 Cleans a station control block.
12473
12474 DEPENDENCIES
12475
12476 PARAMETERS
12477
12478 IN
12479 pvosGCtx: pointer to the global vos context; a handle to TL's
12480 control block can be extracted from its context
12481 ucEmpty: if set the queues and pending pkts will be emptyed
12482
12483 RETURN VALUE
12484 The result code associated with performing the operation
12485
12486 VOS_STATUS_E_INVAL: invalid input parameters
12487 VOS_STATUS_SUCCESS: Everything is good :)
12488
12489 SIDE EFFECTS
12490
12491============================================================================*/
12492VOS_STATUS
12493WLANTL_CleanSTA
12494(
12495 WLANTL_STAClientType* ptlSTAClient,
12496 v_U8_t ucEmpty
12497)
12498{
12499 v_U8_t ucIndex;
12500 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
12501
12502 /*-------------------------------------------------------------------------
12503 Sanity check
12504 -------------------------------------------------------------------------*/
12505 if ( NULL == ptlSTAClient )
12506 {
12507 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
12508 "WLAN TL:Invalid parameter sent on WLANTL_CleanSTA"));
12509 return VOS_STATUS_E_INVAL;
12510 }
12511
12512 /*------------------------------------------------------------------------
12513 Clear station from TL
12514 ------------------------------------------------------------------------*/
12515 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
12516 "WLAN TL: Clearing STA Client ID: %d, Empty flag: %d",
12517 ptlSTAClient->wSTADesc.ucSTAId, ucEmpty ));
12518
12519 ptlSTAClient->pfnSTARx = WLANTL_STARxDefaultCb;
12520 ptlSTAClient->pfnSTATxComp = WLANTL_TxCompDefaultCb;
12521 ptlSTAClient->pfnSTAFetchPkt = WLANTL_STAFetchPktDefaultCb;
12522
12523 ptlSTAClient->tlState = WLANTL_STA_INIT;
12524 ptlSTAClient->tlPri = WLANTL_STA_PRI_NORMAL;
12525
12526 vos_zero_macaddr( &ptlSTAClient->wSTADesc.vSTAMACAddress );
12527 vos_zero_macaddr( &ptlSTAClient->wSTADesc.vBSSIDforIBSS );
12528 vos_zero_macaddr( &ptlSTAClient->wSTADesc.vSelfMACAddress );
12529
12530 ptlSTAClient->wSTADesc.ucSTAId = 0;
12531 ptlSTAClient->wSTADesc.wSTAType = WLAN_STA_MAX;
12532
12533 ptlSTAClient->wSTADesc.ucQosEnabled = 0;
12534 ptlSTAClient->wSTADesc.ucAddRmvLLC = 0;
12535 ptlSTAClient->wSTADesc.ucSwFrameTXXlation = 0;
12536 ptlSTAClient->wSTADesc.ucSwFrameRXXlation = 0;
12537 ptlSTAClient->wSTADesc.ucProtectedFrame = 0;
Bhargav Shahfbaeca22016-07-13 10:27:35 +053012538 ptlSTAClient->disassoc_progress = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070012539 /*-------------------------------------------------------------------------
12540 AMSDU information for the STA
12541 -------------------------------------------------------------------------*/
12542 if ( ( 0 != ucEmpty ) &&
12543 ( NULL != ptlSTAClient->vosAMSDUChainRoot ))
12544 {
Madan Mohan Koyyalamudic0e5bd82012-09-18 17:12:27 -070012545 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_FATAL,
Jeff Johnson0298bd02013-11-14 19:58:38 -080012546 "WLAN TL:Non NULL vosAMSDUChainRoot on WLANTL_CleanSTA, "
Madan Mohan Koyyalamudic0e5bd82012-09-18 17:12:27 -070012547 "suspecting a memory corruption"));
12548
Jeff Johnson295189b2012-06-20 16:38:30 -070012549 }
12550
12551 ptlSTAClient->vosAMSDUChain = NULL;
12552 ptlSTAClient->vosAMSDUChainRoot = NULL;
12553
12554 vos_mem_zero( (v_PVOID_t)ptlSTAClient->aucMPDUHeader,
12555 WLANTL_MPDU_HEADER_LEN);
12556 ptlSTAClient->ucMPDUHeaderLen = 0;
12557
12558 /*-------------------------------------------------------------------------
12559 Reordering information for the STA
12560 -------------------------------------------------------------------------*/
12561 for ( ucIndex = 0; ucIndex < WLAN_MAX_TID ; ucIndex++)
12562 {
12563 if(0 == ptlSTAClient->atlBAReorderInfo[ucIndex].ucExists)
12564 {
12565 continue;
12566 }
12567 if(NULL != ptlSTAClient->atlBAReorderInfo[ucIndex].reorderBuffer)
12568 {
12569 ptlSTAClient->atlBAReorderInfo[ucIndex].reorderBuffer->isAvailable = VOS_TRUE;
12570 memset(&ptlSTAClient->atlBAReorderInfo[ucIndex].reorderBuffer->arrayBuffer[0], 0, WLANTL_MAX_WINSIZE * sizeof(v_PVOID_t));
12571 }
12572 vos_timer_destroy(&ptlSTAClient->atlBAReorderInfo[ucIndex].agingTimer);
12573 memset(&ptlSTAClient->atlBAReorderInfo[ucIndex], 0, sizeof(WLANTL_BAReorderType));
12574 }
12575
12576 /*-------------------------------------------------------------------------
12577 QOS information for the STA
12578 -------------------------------------------------------------------------*/
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +053012579 ptlSTAClient->ucCurrentAC = WLANTL_AC_HIGH_PRIO;
Jeff Johnson295189b2012-06-20 16:38:30 -070012580 ptlSTAClient->ucCurrentWeight = 0;
12581 ptlSTAClient->ucServicedAC = WLANTL_AC_BK;
12582
12583 vos_mem_zero( ptlSTAClient->aucACMask, sizeof(ptlSTAClient->aucACMask));
12584 vos_mem_zero( &ptlSTAClient->wUAPSDInfo, sizeof(ptlSTAClient->wUAPSDInfo));
12585
12586
12587 /*--------------------------------------------------------------------
12588 Stats info
12589 --------------------------------------------------------------------*/
12590 vos_mem_zero( ptlSTAClient->auRxCount,
12591 sizeof(ptlSTAClient->auRxCount[0])* WLAN_MAX_TID);
12592 vos_mem_zero( ptlSTAClient->auTxCount,
12593 sizeof(ptlSTAClient->auTxCount[0])* WLAN_MAX_TID);
12594 ptlSTAClient->rssiAvg = 0;
12595
12596 /*Tx not suspended and station fully registered*/
12597 vos_atomic_set_U8( &ptlSTAClient->ucTxSuspended, 0);
12598 vos_atomic_set_U8( &ptlSTAClient->ucNoMoreData, 1);
12599
12600 if ( 0 == ucEmpty )
12601 {
12602 ptlSTAClient->wSTADesc.ucUcastSig = WLAN_TL_INVALID_U_SIG;
12603 ptlSTAClient->wSTADesc.ucBcastSig = WLAN_TL_INVALID_B_SIG;
12604 }
12605
12606 ptlSTAClient->ucExists = 0;
12607
12608 /*--------------------------------------------------------------------
12609 Statistics info
12610 --------------------------------------------------------------------*/
12611 memset(&ptlSTAClient->trafficStatistics,
12612 0,
12613 sizeof(WLANTL_TRANSFER_STA_TYPE));
12614
12615 /*fix me!!: add new values from the TL Cb for cleanup */
12616 return VOS_STATUS_SUCCESS;
12617}/* WLANTL_CleanSTA */
12618
12619
12620/*==========================================================================
12621 FUNCTION WLANTL_EnableUAPSDForAC
12622
12623 DESCRIPTION
12624 Called by HDD to enable UAPSD. TL in turn calls WDA API to enable the
12625 logic in FW/SLM to start sending trigger frames. Previously TL had the
12626 trigger frame logic which later moved down to FW. Hence
12627 HDD -> TL -> WDA -> FW call flow.
12628
12629 DEPENDENCIES
12630 The TL must be initialized before this function can be called.
12631
12632 PARAMETERS
12633
12634 IN
12635 pvosGCtx: pointer to the global vos context; a handle to TL's
12636 control block can be extracted from its context
12637 ucSTAId: station Id
12638 ucAC: AC for which U-APSD is being enabled
12639 ucTid: TID for which U-APSD is setup
12640 ucUP: used to place in the trigger frame generation
12641 ucServiceInt: service interval used by TL to send trigger frames
12642 ucSuspendInt: suspend interval used by TL to determine that an
12643 app is idle and should start sending trigg frms less often
12644 wTSDir: direction of TSpec
12645
12646 RETURN VALUE
12647 The result code associated with performing the operation
12648
12649 VOS_STATUS_SUCCESS: Everything is good :)
12650
12651 SIDE EFFECTS
12652
12653============================================================================*/
12654VOS_STATUS
12655WLANTL_EnableUAPSDForAC
12656(
12657 v_PVOID_t pvosGCtx,
12658 v_U8_t ucSTAId,
12659 WLANTL_ACEnumType ucAC,
12660 v_U8_t ucTid,
12661 v_U8_t ucUP,
12662 v_U32_t uServiceInt,
12663 v_U32_t uSuspendInt,
12664 WLANTL_TSDirType wTSDir
12665)
12666{
12667
12668 WLANTL_CbType* pTLCb = NULL;
12669 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
12670 tUapsdInfo halUAPSDInfo;
12671 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
12672
12673 /*------------------------------------------------------------------------
12674 Sanity check
12675 Extract TL control block
12676 ------------------------------------------------------------------------*/
12677 pTLCb = VOS_GET_TL_CB(pvosGCtx);
12678 if (( NULL == pTLCb ) || WLANTL_STA_ID_INVALID( ucSTAId )
Gopichand Nakkala574f6d12013-06-27 19:38:43 +053012679 || WLANTL_AC_INVALID(ucAC))
Jeff Johnson295189b2012-06-20 16:38:30 -070012680 {
12681 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
12682 "WLAN TL:Invalid input params on WLANTL_EnableUAPSDForAC"
Gopichand Nakkala574f6d12013-06-27 19:38:43 +053012683 " TL: %p STA: %d AC: %d",
12684 pTLCb, ucSTAId, ucAC));
Jeff Johnson295189b2012-06-20 16:38:30 -070012685 return VOS_STATUS_E_FAULT;
12686 }
12687
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053012688 if ( NULL == pTLCb->atlSTAClients[ucSTAId] )
12689 {
12690 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
12691 "WLAN TL:Client Memory was not allocated on %s", __func__));
12692 return VOS_STATUS_E_FAILURE;
12693 }
12694
Jeff Johnson295189b2012-06-20 16:38:30 -070012695 /*Set this flag in order to remember that this is a trigger enabled AC*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053012696 pTLCb->atlSTAClients[ucSTAId]->wUAPSDInfo[ucAC].ucSet = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -070012697
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053012698#ifdef FEATURE_WLAN_TDLS
12699 if(pTLCb->atlSTAClients[ucSTAId]->wSTADesc.wSTAType != WLAN_STA_TDLS)
12700#endif
12701 {
12702 if( 0 == uServiceInt )
12703 {
12704 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi198ade32013-09-29 03:52:25 +053012705 "WLAN TL:Input params on WLANTL_EnableUAPSDForAC"
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053012706 " SI: %d", uServiceInt ));
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053012707 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012708
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053012709 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
12710 "WLAN TL:Enabling U-APSD in FW for STA: %d AC: %d SI: %d SPI: %d "
12711 "DI: %d",
12712 ucSTAId, ucAC, uServiceInt, uSuspendInt,
12713 pTLCb->tlConfigInfo.uDelayedTriggerFrmInt));
Jeff Johnson295189b2012-06-20 16:38:30 -070012714
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053012715 /*Save all info for HAL*/
12716 halUAPSDInfo.staidx = ucSTAId;
12717 halUAPSDInfo.ac = ucAC;
12718 halUAPSDInfo.up = ucUP;
12719 halUAPSDInfo.srvInterval = uServiceInt;
12720 halUAPSDInfo.susInterval = uSuspendInt;
12721 halUAPSDInfo.delayInterval = pTLCb->tlConfigInfo.uDelayedTriggerFrmInt;
12722
12723 /*Notify HAL*/
12724 vosStatus = WDA_EnableUapsdAcParams(pvosGCtx, ucSTAId, &halUAPSDInfo);
12725 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012726 return vosStatus;
12727
12728}/*WLANTL_EnableUAPSDForAC*/
12729
12730
12731/*==========================================================================
12732 FUNCTION WLANTL_DisableUAPSDForAC
12733
12734 DESCRIPTION
12735 Called by HDD to disable UAPSD. TL in turn calls WDA API to disable the
12736 logic in FW/SLM to stop sending trigger frames. Previously TL had the
12737 trigger frame logic which later moved down to FW. Hence
12738 HDD -> TL -> WDA -> FW call flow.
12739
12740 DEPENDENCIES
12741 The TL must be initialized before this function can be called.
12742
12743 PARAMETERS
12744
12745 IN
12746 pvosGCtx: pointer to the global vos context; a handle to TL's
12747 control block can be extracted from its context
12748 ucSTAId: station Id
12749 ucAC: AC for which U-APSD is being enabled
12750
12751
12752 RETURN VALUE
12753 The result code associated with performing the operation
12754
12755 VOS_STATUS_SUCCESS: Everything is good :)
12756
12757 SIDE EFFECTS
12758
12759============================================================================*/
12760VOS_STATUS
12761WLANTL_DisableUAPSDForAC
12762(
12763 v_PVOID_t pvosGCtx,
12764 v_U8_t ucSTAId,
12765 WLANTL_ACEnumType ucAC
12766)
12767{
12768 WLANTL_CbType* pTLCb;
12769 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
12770
12771 /*------------------------------------------------------------------------
12772 Sanity check
12773 Extract TL control block
12774 ------------------------------------------------------------------------*/
12775 pTLCb = VOS_GET_TL_CB(pvosGCtx);
12776 if (( NULL == pTLCb ) || WLANTL_STA_ID_INVALID( ucSTAId )
12777 || WLANTL_AC_INVALID(ucAC) )
12778 {
12779 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
12780 "WLAN TL:Invalid input params on WLANTL_DisableUAPSDForAC"
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +053012781 " TL: %p STA: %d AC: %d", pTLCb, ucSTAId, ucAC ));
Jeff Johnson295189b2012-06-20 16:38:30 -070012782 return VOS_STATUS_E_FAULT;
12783 }
12784
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053012785 if ( NULL == pTLCb->atlSTAClients[ucSTAId] )
12786 {
12787 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
12788 "WLAN TL:Client Memory was not allocated on %s", __func__));
12789 return VOS_STATUS_E_FAILURE;
12790 }
12791
Jeff Johnson295189b2012-06-20 16:38:30 -070012792 /*Reset this flag as this is no longer a trigger enabled AC*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053012793 pTLCb->atlSTAClients[ucSTAId]->wUAPSDInfo[ucAC].ucSet = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -070012794
12795 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
12796 "WLAN TL:Disabling U-APSD in FW for STA: %d AC: %d ",
12797 ucSTAId, ucAC));
12798
12799 /*Notify HAL*/
12800 WDA_DisableUapsdAcParams(pvosGCtx, ucSTAId, ucAC);
12801
12802 return VOS_STATUS_SUCCESS;
12803}/* WLANTL_DisableUAPSDForAC */
12804
12805#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
12806/*==========================================================================
12807 FUNCTION WLANTL_RegRSSIIndicationCB
12808
12809 DESCRIPTION Registration function to get notification if RSSI cross
12810 threshold.
12811 Client should register threshold, direction, and notification
12812 callback function pointer
12813
12814 DEPENDENCIES NONE
12815
12816 PARAMETERS in pAdapter - Global handle
12817 in rssiValue - RSSI threshold value
12818 in triggerEvent - Cross direction should be notified
12819 UP, DOWN, and CROSS
12820 in crossCBFunction - Notification CB Function
12821 in usrCtxt - user context
12822
12823 RETURN VALUE VOS_STATUS
12824
12825 SIDE EFFECTS NONE
12826
12827============================================================================*/
12828VOS_STATUS WLANTL_RegRSSIIndicationCB
12829(
12830 v_PVOID_t pAdapter,
12831 v_S7_t rssiValue,
12832 v_U8_t triggerEvent,
12833 WLANTL_RSSICrossThresholdCBType crossCBFunction,
12834 VOS_MODULE_ID moduleID,
12835 v_PVOID_t usrCtxt
12836)
12837{
12838 VOS_STATUS status = VOS_STATUS_SUCCESS;
12839
12840 status = WLANTL_HSRegRSSIIndicationCB(pAdapter,
12841 rssiValue,
12842 triggerEvent,
12843 crossCBFunction,
12844 moduleID,
12845 usrCtxt);
12846
12847 return status;
12848}
12849
12850/*==========================================================================
12851 FUNCTION WLANTL_DeregRSSIIndicationCB
12852
12853 DESCRIPTION Remove specific threshold from list
12854
12855 DEPENDENCIES NONE
12856
12857 PARAMETERS in pAdapter - Global handle
12858 in rssiValue - RSSI threshold value
12859 in triggerEvent - Cross direction should be notified
12860 UP, DOWN, and CROSS
12861
12862 RETURN VALUE VOS_STATUS
12863
12864 SIDE EFFECTS NONE
12865
12866============================================================================*/
12867VOS_STATUS WLANTL_DeregRSSIIndicationCB
12868(
12869 v_PVOID_t pAdapter,
12870 v_S7_t rssiValue,
12871 v_U8_t triggerEvent,
12872 WLANTL_RSSICrossThresholdCBType crossCBFunction,
12873 VOS_MODULE_ID moduleID
12874)
12875{
12876 VOS_STATUS status = VOS_STATUS_SUCCESS;
12877
12878 status = WLANTL_HSDeregRSSIIndicationCB(pAdapter,
12879 rssiValue,
12880 triggerEvent,
12881 crossCBFunction,
12882 moduleID);
12883 return status;
12884}
12885
12886/*==========================================================================
12887 FUNCTION WLANTL_SetAlpha
12888
12889 DESCRIPTION ALPLA is weight value to calculate AVG RSSI
12890 avgRSSI = (ALPHA * historyRSSI) + ((10 - ALPHA) * newRSSI)
12891 avgRSSI has (ALPHA * 10)% of history RSSI weight and
12892 (10 - ALPHA)% of newRSSI weight
12893 This portion is dynamically configurable.
12894 Default is ?
12895
12896 DEPENDENCIES NONE
12897
12898 PARAMETERS in pAdapter - Global handle
12899 in valueAlpah - ALPHA
12900
12901 RETURN VALUE VOS_STATUS
12902
12903 SIDE EFFECTS NONE
12904
12905============================================================================*/
12906VOS_STATUS WLANTL_SetAlpha
12907(
12908 v_PVOID_t pAdapter,
12909 v_U8_t valueAlpha
12910)
12911{
12912 VOS_STATUS status = VOS_STATUS_SUCCESS;
12913
12914 status = WLANTL_HSSetAlpha(pAdapter, valueAlpha);
12915 return status;
12916}
12917
12918/*==========================================================================
12919
12920 FUNCTION
12921
12922 DESCRIPTION
12923
12924 PARAMETERS
12925
12926 RETURN VALUE
12927
12928============================================================================*/
12929VOS_STATUS WLANTL_BMPSRSSIRegionChangedNotification
12930(
12931 v_PVOID_t pAdapter,
12932 tpSirRSSINotification pRSSINotification
12933)
12934{
12935 VOS_STATUS status = VOS_STATUS_SUCCESS;
12936
12937 status = WLANTL_HSBMPSRSSIRegionChangedNotification(pAdapter, pRSSINotification);
12938 return status;
12939}
12940
12941/*==========================================================================
12942 FUNCTION WLANTL_RegGetTrafficStatus
12943
12944 DESCRIPTION Registration function for traffic status monitoring
12945 During measure period count data frames.
12946 If frame count is larger then IDLE threshold set as traffic ON
12947 or OFF.
12948 And traffic status is changed send report to client with
12949 registered callback function
12950
12951 DEPENDENCIES NONE
12952
12953 PARAMETERS in pAdapter - Global handle
12954 in idleThreshold - Traffic on or off threshold
12955 in measurePeriod - Traffic state check period
12956 in trfficStatusCB - traffic status changed notification
12957 CB function
12958 in usrCtxt - user context
12959
12960 RETURN VALUE VOS_STATUS
12961
12962 SIDE EFFECTS NONE
12963
12964============================================================================*/
12965VOS_STATUS WLANTL_RegGetTrafficStatus
12966(
12967 v_PVOID_t pAdapter,
12968 v_U32_t idleThreshold,
12969 v_U32_t measurePeriod,
12970 WLANTL_TrafficStatusChangedCBType trfficStatusCB,
12971 v_PVOID_t usrCtxt
12972)
12973{
12974 VOS_STATUS status = VOS_STATUS_SUCCESS;
12975
12976 status = WLANTL_HSRegGetTrafficStatus(pAdapter,
12977 idleThreshold,
12978 measurePeriod,
12979 trfficStatusCB,
12980 usrCtxt);
12981 return status;
12982}
12983#endif
12984/*==========================================================================
12985 FUNCTION WLANTL_GetStatistics
12986
12987 DESCRIPTION Get traffic statistics for identified station
12988
12989 DEPENDENCIES NONE
12990
12991 PARAMETERS in pAdapter - Global handle
12992 in statType - specific statistics field to reset
12993 out statBuffer - traffic statistics buffer
12994
12995 RETURN VALUE VOS_STATUS
12996
12997 SIDE EFFECTS NONE
12998
12999============================================================================*/
13000VOS_STATUS WLANTL_GetStatistics
13001(
13002 v_PVOID_t pAdapter,
13003 WLANTL_TRANSFER_STA_TYPE *statBuffer,
13004 v_U8_t STAid
13005)
13006{
13007 WLANTL_CbType *pTLCb = VOS_GET_TL_CB(pAdapter);
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053013008 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070013009 VOS_STATUS status = VOS_STATUS_SUCCESS;
13010 WLANTL_TRANSFER_STA_TYPE *statistics = NULL;
13011
13012 /*------------------------------------------------------------------------
13013 Sanity check
13014 Extract TL control block
13015 ------------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053013016 if ( NULL == pTLCb )
Jeff Johnson295189b2012-06-20 16:38:30 -070013017 {
13018 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
13019 "WLAN TL:Invalid TL pointer on WLANTL_GetStatistics"));
13020 return VOS_STATUS_E_FAULT;
13021 }
13022
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053013023 pClientSTA = pTLCb->atlSTAClients[STAid];
13024
13025 if ( NULL == pClientSTA )
13026 {
13027 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
13028 "WLAN TL:Client Memory was not allocated on %s", __func__));
13029 return VOS_STATUS_E_FAILURE;
13030 }
13031
13032 if(0 == pClientSTA->ucExists)
Jeff Johnson295189b2012-06-20 16:38:30 -070013033 {
13034 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
13035 "WLAN TL: %d STA ID does not exist", STAid));
13036 return VOS_STATUS_E_INVAL;
13037 }
13038
13039 if(NULL == statBuffer)
13040 {
13041 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
13042 "WLAN TL:Invalid TL statistics buffer pointer on WLANTL_GetStatistics"));
13043 return VOS_STATUS_E_INVAL;
13044 }
13045
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053013046 statistics = &pClientSTA->trafficStatistics;
Katya Nigam493ff652014-02-11 14:31:04 +053013047 vos_mem_copy(statBuffer, statistics, sizeof(WLANTL_TRANSFER_STA_TYPE));
Jeff Johnson295189b2012-06-20 16:38:30 -070013048
13049 return status;
13050}
13051
13052/*==========================================================================
13053 FUNCTION WLANTL_ResetStatistics
13054
13055 DESCRIPTION Reset statistics structure for identified station ID
13056 Reset means set values as 0
13057
13058 DEPENDENCIES NONE
13059
13060 PARAMETERS in pAdapter - Global handle
13061 in statType - specific statistics field to reset
13062
13063 RETURN VALUE VOS_STATUS
13064
13065 SIDE EFFECTS NONE
13066
13067============================================================================*/
13068VOS_STATUS WLANTL_ResetStatistics
13069(
13070 v_PVOID_t pAdapter,
13071 v_U8_t STAid
13072)
13073{
13074 WLANTL_CbType *pTLCb = VOS_GET_TL_CB(pAdapter);
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053013075 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070013076 VOS_STATUS status = VOS_STATUS_SUCCESS;
13077 WLANTL_TRANSFER_STA_TYPE *statistics = NULL;
13078
13079 /*------------------------------------------------------------------------
13080 Sanity check
13081 Extract TL control block
13082 ------------------------------------------------------------------------*/
13083 if (NULL == pTLCb)
13084 {
13085 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
13086 "WLAN TL:Invalid TL pointer on WLANTL_GetStatistics"));
13087 return VOS_STATUS_E_FAULT;
13088 }
13089
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053013090 pClientSTA = pTLCb->atlSTAClients[STAid];
13091
13092 if ( NULL == pClientSTA )
13093 {
13094 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
13095 "WLAN TL:Client Memory was not allocated on %s", __func__));
13096 return VOS_STATUS_E_FAILURE;
13097 }
13098
13099 if(0 == pClientSTA->ucExists)
Jeff Johnson295189b2012-06-20 16:38:30 -070013100 {
13101 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
13102 "WLAN TL: %d STA ID does not exist", STAid));
13103 return VOS_STATUS_E_INVAL;
13104 }
13105
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053013106 statistics = &pClientSTA->trafficStatistics;
Jeff Johnson295189b2012-06-20 16:38:30 -070013107 vos_mem_zero((v_VOID_t *)statistics, sizeof(WLANTL_TRANSFER_STA_TYPE));
13108
13109 return status;
13110}
13111
13112/*==========================================================================
13113 FUNCTION WLANTL_GetSpecStatistic
13114
13115 DESCRIPTION Get specific field within statistics structure for
13116 identified station ID
13117
13118 DEPENDENCIES NONE
13119
13120 PARAMETERS in pAdapter - Global handle
13121 in statType - specific statistics field to reset
13122 in STAid - Station ID
13123 out buffer - Statistic value
13124
13125 RETURN VALUE VOS_STATUS
13126
13127 SIDE EFFECTS NONE
13128
13129============================================================================*/
13130VOS_STATUS WLANTL_GetSpecStatistic
13131(
13132 v_PVOID_t pAdapter,
13133 WLANTL_TRANSFER_STATIC_TYPE statType,
13134 v_U32_t *buffer,
13135 v_U8_t STAid
13136)
13137{
13138 WLANTL_CbType *pTLCb = VOS_GET_TL_CB(pAdapter);
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053013139 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070013140 VOS_STATUS status = VOS_STATUS_SUCCESS;
13141 WLANTL_TRANSFER_STA_TYPE *statistics = NULL;
13142
13143 /*------------------------------------------------------------------------
13144 Sanity check
13145 Extract TL control block
13146 ------------------------------------------------------------------------*/
13147 if (NULL == pTLCb)
13148 {
13149 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
13150 "WLAN TL:Invalid TL pointer on WLANTL_GetStatistics"));
13151 return VOS_STATUS_E_FAULT;
13152 }
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053013153 pClientSTA = pTLCb->atlSTAClients[STAid];
Jeff Johnson295189b2012-06-20 16:38:30 -070013154
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053013155 if ( NULL == pClientSTA )
13156 {
13157 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
13158 "WLAN TL:Client Memory was not allocated on %s", __func__));
13159 return VOS_STATUS_E_FAILURE;
13160 }
13161
13162 if(0 == pClientSTA->ucExists)
Jeff Johnson295189b2012-06-20 16:38:30 -070013163 {
13164 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
13165 "WLAN TL: %d STA ID does not exist", STAid));
13166 return VOS_STATUS_E_INVAL;
13167 }
13168
13169 if(NULL == buffer)
13170 {
13171 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
13172 "WLAN TL:Invalid TL statistic buffer pointer on WLANTL_GetStatistics"));
13173 return VOS_STATUS_E_INVAL;
13174 }
13175
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053013176 statistics = &pClientSTA->trafficStatistics;
Jeff Johnson295189b2012-06-20 16:38:30 -070013177 switch(statType)
13178 {
13179 case WLANTL_STATIC_TX_UC_FCNT:
13180 *buffer = statistics->txUCFcnt;
13181 break;
13182
13183 case WLANTL_STATIC_TX_MC_FCNT:
13184 *buffer = statistics->txMCFcnt;
13185 break;
13186
13187 case WLANTL_STATIC_TX_BC_FCNT:
13188 *buffer = statistics->txBCFcnt;
13189 break;
13190
13191 case WLANTL_STATIC_TX_UC_BCNT:
13192 *buffer = statistics->txUCBcnt;
13193 break;
13194
13195 case WLANTL_STATIC_TX_MC_BCNT:
13196 *buffer = statistics->txMCBcnt;
13197 break;
13198
13199 case WLANTL_STATIC_TX_BC_BCNT:
13200 *buffer = statistics->txBCBcnt;
13201 break;
13202
13203 case WLANTL_STATIC_RX_UC_FCNT:
13204 *buffer = statistics->rxUCFcnt;
13205 break;
13206
13207 case WLANTL_STATIC_RX_MC_FCNT:
13208 *buffer = statistics->rxMCFcnt;
13209 break;
13210
13211 case WLANTL_STATIC_RX_BC_FCNT:
13212 *buffer = statistics->rxBCFcnt;
13213 break;
13214
13215 case WLANTL_STATIC_RX_UC_BCNT:
13216 *buffer = statistics->rxUCBcnt;
13217 break;
13218
13219 case WLANTL_STATIC_RX_MC_BCNT:
13220 *buffer = statistics->rxMCBcnt;
13221 break;
13222
13223 case WLANTL_STATIC_RX_BC_BCNT:
13224 *buffer = statistics->rxBCBcnt;
13225 break;
13226
13227 case WLANTL_STATIC_RX_BCNT:
13228 *buffer = statistics->rxBcnt;
13229 break;
13230
13231 case WLANTL_STATIC_RX_BCNT_CRC_OK:
13232 *buffer = statistics->rxBcntCRCok;
13233 break;
13234
13235 case WLANTL_STATIC_RX_RATE:
13236 *buffer = statistics->rxRate;
13237 break;
13238
13239 default:
13240 *buffer = 0;
13241 status = VOS_STATUS_E_INVAL;
13242 break;
13243 }
13244
13245
13246 return status;
13247}
13248
13249/*==========================================================================
13250 FUNCTION WLANTL_ResetSpecStatistic
13251
13252 DESCRIPTION Reset specific field within statistics structure for
13253 identified station ID
13254 Reset means set as 0
13255
13256 DEPENDENCIES NONE
13257
13258 PARAMETERS in pAdapter - Global handle
13259 in statType - specific statistics field to reset
13260 in STAid - Station ID
13261
13262 RETURN VALUE VOS_STATUS
13263
13264 SIDE EFFECTS NONE
13265
13266============================================================================*/
13267VOS_STATUS WLANTL_ResetSpecStatistic
13268(
13269 v_PVOID_t pAdapter,
13270 WLANTL_TRANSFER_STATIC_TYPE statType,
13271 v_U8_t STAid
13272)
13273{
13274 WLANTL_CbType *pTLCb = VOS_GET_TL_CB(pAdapter);
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053013275 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070013276 VOS_STATUS status = VOS_STATUS_SUCCESS;
13277 WLANTL_TRANSFER_STA_TYPE *statistics = NULL;
13278
13279 /*------------------------------------------------------------------------
13280 Sanity check
13281 Extract TL control block
13282 ------------------------------------------------------------------------*/
13283 if (NULL == pTLCb)
13284 {
13285 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
13286 "WLAN TL:Invalid TL pointer on WLANTL_GetStatistics"));
13287 return VOS_STATUS_E_FAULT;
13288 }
13289
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053013290 pClientSTA = pTLCb->atlSTAClients[STAid];
13291
13292 if ( NULL == pClientSTA )
13293 {
13294 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
13295 "WLAN TL:Client Memory was not allocated on %s", __func__));
13296 return VOS_STATUS_E_FAILURE;
13297 }
13298
13299 if(0 == pClientSTA->ucExists)
Jeff Johnson295189b2012-06-20 16:38:30 -070013300 {
13301 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
13302 "WLAN TL: %d STA ID does not exist", STAid));
13303 return VOS_STATUS_E_INVAL;
13304 }
13305
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053013306 statistics = &pClientSTA->trafficStatistics;
Jeff Johnson295189b2012-06-20 16:38:30 -070013307 switch(statType)
13308 {
13309 case WLANTL_STATIC_TX_UC_FCNT:
13310 statistics->txUCFcnt = 0;
13311 break;
13312
13313 case WLANTL_STATIC_TX_MC_FCNT:
13314 statistics->txMCFcnt = 0;
13315 break;
13316
13317 case WLANTL_STATIC_TX_BC_FCNT:
13318 statistics->txBCFcnt = 0;
13319 break;
13320
13321 case WLANTL_STATIC_TX_UC_BCNT:
13322 statistics->txUCBcnt = 0;
13323 break;
13324
13325 case WLANTL_STATIC_TX_MC_BCNT:
13326 statistics->txMCBcnt = 0;
13327 break;
13328
13329 case WLANTL_STATIC_TX_BC_BCNT:
13330 statistics->txBCBcnt = 0;
13331 break;
13332
13333 case WLANTL_STATIC_RX_UC_FCNT:
13334 statistics->rxUCFcnt = 0;
13335 break;
13336
13337 case WLANTL_STATIC_RX_MC_FCNT:
13338 statistics->rxMCFcnt = 0;
13339 break;
13340
13341 case WLANTL_STATIC_RX_BC_FCNT:
13342 statistics->rxBCFcnt = 0;
13343 break;
13344
13345 case WLANTL_STATIC_RX_UC_BCNT:
13346 statistics->rxUCBcnt = 0;
13347 break;
13348
13349 case WLANTL_STATIC_RX_MC_BCNT:
13350 statistics->rxMCBcnt = 0;
13351 break;
13352
13353 case WLANTL_STATIC_RX_BC_BCNT:
13354 statistics->rxBCBcnt = 0;
13355 break;
13356
13357 case WLANTL_STATIC_RX_BCNT:
13358 statistics->rxBcnt = 0;
13359 break;
13360
13361 case WLANTL_STATIC_RX_BCNT_CRC_OK:
13362 statistics->rxBcntCRCok = 0;
13363 break;
13364
13365 case WLANTL_STATIC_RX_RATE:
13366 statistics->rxRate = 0;
13367 break;
13368
13369 default:
13370 status = VOS_STATUS_E_INVAL;
13371 break;
13372 }
13373
13374 return status;
13375}
13376
13377
13378/*==========================================================================
13379
13380 FUNCTION
13381
13382 DESCRIPTION Read RSSI value out of a RX BD
13383
13384 PARAMETERS: Caller must validate all parameters
13385
13386 RETURN VALUE
13387
13388============================================================================*/
13389VOS_STATUS WLANTL_ReadRSSI
13390(
13391 v_PVOID_t pAdapter,
13392 v_PVOID_t pBDHeader,
13393 v_U8_t STAid
13394)
13395{
13396 WLANTL_CbType *tlCtxt = VOS_GET_TL_CB(pAdapter);
13397 v_S7_t currentRSSI, currentRSSI0, currentRSSI1;
13398
13399
13400 if(NULL == tlCtxt)
13401 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070013402 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR, "%s Invalid TL handle", __func__));
Jeff Johnson295189b2012-06-20 16:38:30 -070013403 return VOS_STATUS_E_INVAL;
13404 }
13405
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053013406 if ( NULL == tlCtxt->atlSTAClients[STAid] )
13407 {
13408 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
13409 "WLAN TL:Client Memory was not allocated on %s", __func__));
13410 return VOS_STATUS_E_FAILURE;
13411 }
13412
Jeff Johnson295189b2012-06-20 16:38:30 -070013413 currentRSSI0 = WLANTL_GETRSSI0(pBDHeader);
13414 currentRSSI1 = WLANTL_GETRSSI1(pBDHeader);
13415 currentRSSI = (currentRSSI0 > currentRSSI1) ? currentRSSI0 : currentRSSI1;
13416
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053013417 tlCtxt->atlSTAClients[STAid]->rssiAvg = currentRSSI;
Jeff Johnson295189b2012-06-20 16:38:30 -070013418
13419 return VOS_STATUS_SUCCESS;
13420}
13421
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053013422/*==========================================================================
13423
13424 FUNCTION
13425
13426 DESCRIPTION Read SNR value out of a RX BD
13427
13428 PARAMETERS: Caller must validate all parameters
13429
13430 RETURN VALUE
13431
13432============================================================================*/
13433VOS_STATUS WLANTL_ReadSNR
13434(
13435 v_PVOID_t pAdapter,
13436 v_PVOID_t pBDHeader,
13437 v_U8_t STAid
13438)
13439{
13440 WLANTL_CbType *tlCtxt = VOS_GET_TL_CB(pAdapter);
13441 v_S7_t currentSNR;
13442
13443
13444 if (NULL == tlCtxt)
13445 {
13446 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
13447 "%s Invalid TL handle", __func__));
13448 return VOS_STATUS_E_INVAL;
13449 }
13450
13451 if (NULL == tlCtxt->atlSTAClients[STAid])
13452 {
13453 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
13454 "WLAN TL:Client Memory was not allocated on %s", __func__));
13455 return VOS_STATUS_E_FAILURE;
13456 }
13457
13458 currentSNR = WLANTL_GETSNR(pBDHeader);
13459
Madan Mohan Koyyalamudi43acf032013-09-27 04:33:28 +053013460 /* SNR reported in the Buffer Descriptor is scaled up by 2(SNR*2),
13461 * Get the correct SNR value
13462 */
13463 currentSNR = currentSNR >> 1;
13464
13465 /* SNR reported by HW cannot be more than 35dB due to HW limitations */
13466 currentSNR = (WLANTL_MAX_HW_SNR > currentSNR ? currentSNR :
13467 WLANTL_MAX_HW_SNR);
13468
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053013469 TLLOG2(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
13470 "%s: snrsum: %d snridx: %d prevsnravg: %d",
13471 __func__,
13472 tlCtxt->atlSTAClients[STAid]->snrSum,
13473 tlCtxt->atlSTAClients[STAid]->snrIdx,
13474 tlCtxt->atlSTAClients[STAid]->prevSnrAvg));
13475
13476 /* The SNR returned for all purposes is the average SNR over
13477 * WLANTL_MAX_SNR_DATA_SMAPLES.When data samples
13478 * > WLANTL_MAX_SNR_DATA_SAMPLES are obtained,
13479 * store the average of the samples in prevSnrAvg
13480 * and start a new averaging window. The prevSnrAvg is used when
13481 * enough data samples are not available when applications
13482 * actually query for SNR.
13483 *
13484 * SEE: WLANTL_GetSnr()
13485 */
13486 if (tlCtxt->atlSTAClients[STAid]->snrIdx >= WLANTL_MAX_SNR_DATA_SAMPLES)
13487 {
13488 tlCtxt->atlSTAClients[STAid]->prevSnrAvg =
13489 tlCtxt->atlSTAClients[STAid]->snrSum /
13490 tlCtxt->atlSTAClients[STAid]->snrIdx;
13491 tlCtxt->atlSTAClients[STAid]->snrSum = 0;
13492 tlCtxt->atlSTAClients[STAid]->snrIdx = 0;
13493 }
13494 tlCtxt->atlSTAClients[STAid]->snrSum += currentSNR;
13495 tlCtxt->atlSTAClients[STAid]->snrIdx += 1;
13496
13497 return VOS_STATUS_SUCCESS;
13498}
Jeff Johnson295189b2012-06-20 16:38:30 -070013499
13500/*
13501 DESCRIPTION
13502 TL returns the weight currently maintained in TL.
13503 IN
13504 pvosGCtx: pointer to the global vos context; a handle to TL's
13505 or SME's control block can be extracted from its context
13506
13507 OUT
13508 pACWeights: Caller allocated memory for filling in weights
13509
13510 RETURN VALUE VOS_STATUS
13511*/
13512VOS_STATUS
13513WLANTL_GetACWeights
13514(
13515 v_PVOID_t pvosGCtx,
13516 v_U8_t* pACWeights
13517)
13518{
13519 WLANTL_CbType* pTLCb = NULL;
13520 v_U8_t ucIndex;
13521 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
13522
13523 /*------------------------------------------------------------------------
13524 Sanity check
13525 ------------------------------------------------------------------------*/
13526 if ( NULL == pACWeights )
13527 {
13528 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
13529 "WLAN TL:Invalid parameter sent on WLANTL_GetACWeights"));
13530 return VOS_STATUS_E_INVAL;
13531 }
13532
13533 /*------------------------------------------------------------------------
13534 Extract TL control block and check existance
13535 ------------------------------------------------------------------------*/
13536 pTLCb = VOS_GET_TL_CB(pvosGCtx);
13537 if ( NULL == pTLCb )
13538 {
13539 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
13540 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_GetACWeights"));
13541 return VOS_STATUS_E_FAULT;
13542 }
13543 for ( ucIndex = 0; ucIndex < WLANTL_MAX_AC ; ucIndex++)
13544 {
13545 pACWeights[ucIndex] = pTLCb->tlConfigInfo.ucAcWeights[ucIndex];
13546 }
13547
13548 return VOS_STATUS_SUCCESS;
13549}
13550
13551
13552
13553/*
13554 DESCRIPTION
13555 Change the weight currently maintained by TL.
13556 IN
13557 pvosGCtx: pointer to the global vos context; a handle to TL's
13558 or SME's control block can be extracted from its context
13559 pACWeights: Caller allocated memory contain the weights to use
13560
13561
13562 RETURN VALUE VOS_STATUS
13563*/
13564VOS_STATUS
13565WLANTL_SetACWeights
13566(
13567 v_PVOID_t pvosGCtx,
13568 v_U8_t* pACWeights
13569)
13570{
13571 WLANTL_CbType* pTLCb = NULL;
13572 v_U8_t ucIndex;
13573 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
13574
13575 /*------------------------------------------------------------------------
13576 Sanity check
13577 ------------------------------------------------------------------------*/
13578 if ( NULL == pACWeights )
13579 {
13580 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
13581 "WLAN TL:Invalid parameter sent on WLANTL_GetACWeights"));
13582 return VOS_STATUS_E_INVAL;
13583 }
13584
13585 /*------------------------------------------------------------------------
13586 Extract TL control block and check existance
13587 ------------------------------------------------------------------------*/
13588 pTLCb = VOS_GET_TL_CB(pvosGCtx);
13589 if ( NULL == pTLCb )
13590 {
13591 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
13592 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_GetACWeights"));
13593 return VOS_STATUS_E_FAULT;
13594 }
13595 for ( ucIndex = 0; ucIndex < WLANTL_MAX_AC ; ucIndex++)
13596 {
13597 pTLCb->tlConfigInfo.ucAcWeights[ucIndex] = pACWeights[ucIndex];
13598 }
13599
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +053013600 pTLCb->tlConfigInfo.ucAcWeights[WLANTL_AC_HIGH_PRIO] = pACWeights[WLANTL_AC_VO];
Jeff Johnson295189b2012-06-20 16:38:30 -070013601 return VOS_STATUS_SUCCESS;
13602}
13603
13604
13605/*==========================================================================
13606
13607 FUNCTION
13608
13609 DESCRIPTION
13610
13611 PARAMETERS
13612
13613 RETURN VALUE
13614
13615============================================================================*/
13616void WLANTL_PowerStateChangedCB
13617(
13618 v_PVOID_t pAdapter,
13619 tPmcState newState
13620)
13621{
13622 WLANTL_CbType *tlCtxt = VOS_GET_TL_CB(pAdapter);
13623
13624 if (NULL == tlCtxt)
13625 {
13626 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +053013627 "%s: Invalid TL Control Block", __func__ );
Jeff Johnson295189b2012-06-20 16:38:30 -070013628 return;
13629 }
13630
13631 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO, "Power state changed, new state is %d", newState );
13632 switch(newState)
13633 {
13634 case FULL_POWER:
13635 tlCtxt->isBMPS = VOS_FALSE;
13636 break;
13637
13638 case BMPS:
13639#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
13640 WLANTL_SetFWRSSIThresholds(pAdapter);
13641#endif
13642
13643 tlCtxt->isBMPS = VOS_TRUE;
13644 break;
13645
13646 case IMPS:
13647 case LOW_POWER:
13648 case REQUEST_BMPS:
13649 case REQUEST_FULL_POWER:
13650 case REQUEST_IMPS:
13651 case STOPPED:
13652 case REQUEST_START_UAPSD:
13653 case REQUEST_STOP_UAPSD:
13654 case UAPSD:
13655 case REQUEST_STANDBY:
13656 case STANDBY:
13657 case REQUEST_ENTER_WOWL:
13658 case REQUEST_EXIT_WOWL:
13659 case WOWL:
13660 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN, "Not handle this events %d", newState ));
13661 break;
13662
13663 default:
13664 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR, "Not a valid event %d", newState ));
13665 break;
13666 }
13667
13668 return;
13669}
13670/*==========================================================================
13671 FUNCTION WLANTL_GetEtherType
13672
13673 DESCRIPTION Extract Ether type information from the BD
13674
13675 DEPENDENCIES NONE
13676
13677 PARAMETERS in aucBDHeader - BD header
13678 in vosDataBuff - data buffer
13679 in ucMPDUHLen - MPDU header length
13680 out pUsEtherType - pointer to Ethertype
13681
13682 RETURN VALUE VOS_STATUS_SUCCESS : if the EtherType is successfully extracted
13683 VOS_STATUS_FAILURE : if the EtherType extraction failed and
13684 the packet was dropped
13685
13686 SIDE EFFECTS NONE
13687
13688============================================================================*/
13689static VOS_STATUS WLANTL_GetEtherType
13690(
13691 v_U8_t * aucBDHeader,
13692 vos_pkt_t * vosDataBuff,
13693 v_U8_t ucMPDUHLen,
13694 v_U16_t * pUsEtherType
13695)
13696{
13697 v_U8_t ucOffset;
13698 v_U16_t usEtherType = *pUsEtherType;
13699 v_SIZE_t usLLCSize = sizeof(usEtherType);
13700 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
13701
13702 /*------------------------------------------------------------------------
13703 Check if LLC is present - if not, TL is unable to determine type
13704 ------------------------------------------------------------------------*/
13705 if ( VOS_FALSE == WDA_IS_RX_LLC_PRESENT( aucBDHeader ) )
13706 {
13707 ucOffset = WLANTL_802_3_HEADER_LEN - sizeof(usEtherType);
13708 }
13709 else
13710 {
13711 ucOffset = ucMPDUHLen + WLANTL_LLC_PROTO_TYPE_OFFSET;
13712 }
13713
13714 /*------------------------------------------------------------------------
13715 Extract LLC type
13716 ------------------------------------------------------------------------*/
13717 vosStatus = vos_pkt_extract_data( vosDataBuff, ucOffset,
13718 (v_PVOID_t)&usEtherType, &usLLCSize);
13719
13720 if (( VOS_STATUS_SUCCESS != vosStatus ) ||
13721 ( sizeof(usEtherType) != usLLCSize ))
13722
13723 {
13724 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
13725 "WLAN TL:Error extracting Ether type from data packet"));
13726 /* Drop packet */
13727 vos_pkt_return_packet(vosDataBuff);
13728 vosStatus = VOS_STATUS_E_FAILURE;
13729 }
13730 else
13731 {
13732 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
13733 "WLAN TL:Ether type retrieved before endianess conv: %d",
13734 usEtherType));
13735
13736 usEtherType = vos_be16_to_cpu(usEtherType);
13737 *pUsEtherType = usEtherType;
13738
13739 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
13740 "WLAN TL:Ether type retrieved: %d", usEtherType));
13741 }
13742
13743 return vosStatus;
13744}
13745
Jeff Johnson295189b2012-06-20 16:38:30 -070013746/*==========================================================================
13747 FUNCTION WLANTL_GetSoftAPStatistics
13748
13749 DESCRIPTION Collect the cumulative statistics for all Softap stations
13750
13751 DEPENDENCIES NONE
13752
13753 PARAMETERS in pvosGCtx - Pointer to the global vos context
13754 bReset - If set TL statistics will be cleared after reading
13755 out statsSum - pointer to collected statistics
13756
13757 RETURN VALUE VOS_STATUS_SUCCESS : if the Statistics are successfully extracted
13758
13759 SIDE EFFECTS NONE
13760
13761============================================================================*/
13762VOS_STATUS WLANTL_GetSoftAPStatistics(v_PVOID_t pAdapter, WLANTL_TRANSFER_STA_TYPE *statsSum, v_BOOL_t bReset)
13763{
13764 v_U8_t i = 0;
13765 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
13766 WLANTL_CbType *pTLCb = VOS_GET_TL_CB(pAdapter);
13767 WLANTL_TRANSFER_STA_TYPE statBufferTemp;
13768 vos_mem_zero((v_VOID_t *)&statBufferTemp, sizeof(WLANTL_TRANSFER_STA_TYPE));
13769 vos_mem_zero((v_VOID_t *)statsSum, sizeof(WLANTL_TRANSFER_STA_TYPE));
13770
13771
13772 if ( NULL == pTLCb )
13773 {
13774 return VOS_STATUS_E_FAULT;
13775 }
13776
13777 // Sum up all the statistics for stations of Soft AP from TL
13778 for (i = 0; i < WLAN_MAX_STA_COUNT; i++)
13779 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053013780 if ( NULL == pTLCb->atlSTAClients[i])
13781 {
13782 continue;
13783 }
13784 if (pTLCb->atlSTAClients[i]->wSTADesc.wSTAType == WLAN_STA_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -070013785 {
13786 vosStatus = WLANTL_GetStatistics(pAdapter, &statBufferTemp, i);// Can include staId 1 because statistics not collected for it
13787
13788 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
13789 return VOS_STATUS_E_FAULT;
13790
13791 // Add to the counters
13792 statsSum->txUCFcnt += statBufferTemp.txUCFcnt;
13793 statsSum->txMCFcnt += statBufferTemp.txMCFcnt;
13794 statsSum->txBCFcnt += statBufferTemp.txBCFcnt;
13795 statsSum->txUCBcnt += statBufferTemp.txUCBcnt;
13796 statsSum->txMCBcnt += statBufferTemp.txMCBcnt;
13797 statsSum->txBCBcnt += statBufferTemp.txBCBcnt;
13798 statsSum->rxUCFcnt += statBufferTemp.rxUCFcnt;
13799 statsSum->rxMCFcnt += statBufferTemp.rxMCFcnt;
13800 statsSum->rxBCFcnt += statBufferTemp.rxBCFcnt;
13801 statsSum->rxUCBcnt += statBufferTemp.rxUCBcnt;
13802 statsSum->rxMCBcnt += statBufferTemp.rxMCBcnt;
13803 statsSum->rxBCBcnt += statBufferTemp.rxBCBcnt;
13804
13805 if (bReset)
13806 {
13807 vosStatus = WLANTL_ResetStatistics(pAdapter, i);
13808 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
13809 return VOS_STATUS_E_FAULT;
13810 }
13811 }
13812 }
13813
13814 return vosStatus;
13815}
Mohit Khanna698ba2a2012-12-04 15:08:18 -080013816
Jeff Johnson295189b2012-06-20 16:38:30 -070013817/*===============================================================================
13818 FUNCTION WLANTL_IsReplayPacket
13819
13820 DESCRIPTION This function does replay check for valid stations
13821
13822 DEPENDENCIES Validity of replay check must be done before the function
13823 is called
13824
13825 PARAMETERS currentReplayCounter current replay counter taken from RX BD
13826 previousReplayCounter previous replay counter taken from TL CB
13827
13828 RETRUN VOS_TRUE packet is a replay packet
13829 VOS_FALSE packet is not a replay packet
13830
13831 SIDE EFFECTS none
13832 ===============================================================================*/
13833v_BOOL_t
13834WLANTL_IsReplayPacket
13835(
13836 v_U64_t ullcurrentReplayCounter,
13837 v_U64_t ullpreviousReplayCounter
13838)
13839{
13840 /* Do the replay check by comparing previous received replay counter with
13841 current received replay counter*/
13842 if(ullpreviousReplayCounter < ullcurrentReplayCounter)
13843 {
13844 /* Valid packet not replay */
13845 return VOS_FALSE;
13846 }
13847 else
13848 {
13849
13850 /* Current packet number is less than or equal to previuos received
13851 packet no, this means current packet is replay packet */
13852 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
13853 "WLAN TL: Replay packet found with replay counter :[0x%llX]",ullcurrentReplayCounter);
13854
13855 return VOS_TRUE;
13856 }
13857}
13858
13859#if 0
13860/*===============================================================================
13861 FUNCTION WLANTL_GetReplayCounterFromRxBD
13862
13863 DESCRIPTION This function extracts 48-bit replay packet number from RX BD
13864
13865 DEPENDENCIES Validity of replay check must be done before the function
13866 is called
13867
13868 PARAMETERS pucRxHeader pointer to RX BD header
13869
13870 RETRUN v_U64_t Packet number extarcted from RX BD
13871
13872 SIDE EFFECTS none
13873 ===============================================================================*/
13874v_U64_t
13875WLANTL_GetReplayCounterFromRxBD
13876(
13877 v_U8_t *pucRxBDHeader
13878)
13879{
13880/* 48-bit replay counter is created as follows
13881 from RX BD 6 byte PMI command:
13882 Addr : AES/TKIP
13883 0x38 : pn3/tsc3
13884 0x39 : pn2/tsc2
13885 0x3a : pn1/tsc1
13886 0x3b : pn0/tsc0
13887
13888 0x3c : pn5/tsc5
13889 0x3d : pn4/tsc4 */
13890
13891#ifdef ANI_BIG_BYTE_ENDIAN
13892 v_U64_t ullcurrentReplayCounter = 0;
13893 /* Getting 48-bit replay counter from the RX BD */
13894 ullcurrentReplayCounter = WLANHAL_RX_BD_GET_PMICMD_20TO23(pucRxBDHeader);
13895 ullcurrentReplayCounter <<= 16;
13896 ullcurrentReplayCounter |= (( WLANHAL_RX_BD_GET_PMICMD_24TO25(pucRxBDHeader) & 0xFFFF0000) >> 16);
13897 return ullcurrentReplayCounter;
13898#else
13899 v_U64_t ullcurrentReplayCounter = 0;
13900 /* Getting 48-bit replay counter from the RX BD */
13901 ullcurrentReplayCounter = (WLANHAL_RX_BD_GET_PMICMD_24TO25(pucRxBDHeader) & 0x0000FFFF);
13902 ullcurrentReplayCounter <<= 32;
13903 ullcurrentReplayCounter |= WLANHAL_RX_BD_GET_PMICMD_20TO23(pucRxBDHeader);
13904 return ullcurrentReplayCounter;
13905#endif
13906}
13907#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070013908
13909/*===============================================================================
13910 FUNCTION WLANTL_PostResNeeded
13911
13912 DESCRIPTION This function posts message to TL to reserve BD/PDU memory
13913
13914 DEPENDENCIES None
13915
13916 PARAMETERS pvosGCtx
13917
13918 RETURN None
13919
13920 SIDE EFFECTS none
13921 ===============================================================================*/
13922
13923void WLANTL_PostResNeeded(v_PVOID_t pvosGCtx)
13924{
13925 vos_msg_t vosMsg;
13926
13927 vosMsg.reserved = 0;
13928 vosMsg.bodyptr = NULL;
13929 vosMsg.type = WLANTL_TX_RES_NEEDED;
13930 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
13931 "WLAN TL: BD/PDU available interrupt received, Posting message to TL");
13932 if(!VOS_IS_STATUS_SUCCESS(vos_tx_mq_serialize( VOS_MQ_ID_TL, &vosMsg)))
13933 {
13934 VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070013935 " %s fails to post message", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070013936 }
13937}
13938
13939/*===============================================================================
13940 FUNCTION WLANTL_UpdateRssiBmps
13941
13942 DESCRIPTION This function updates the TL's RSSI (in BMPS mode)
13943
13944 DEPENDENCIES None
13945
13946 PARAMETERS
13947
13948 pvosGCtx VOS context VOS Global context
13949 staId Station ID Station ID
13950 rssi RSSI (BMPS mode) RSSI in BMPS mode
13951
13952 RETURN None
13953
13954 SIDE EFFECTS none
13955 ===============================================================================*/
13956
13957void WLANTL_UpdateRssiBmps(v_PVOID_t pvosGCtx, v_U8_t staId, v_S7_t rssi)
13958{
13959 WLANTL_CbType* pTLCb = VOS_GET_TL_CB(pvosGCtx);
13960
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053013961 if (NULL != pTLCb && NULL != pTLCb->atlSTAClients[staId])
Jeff Johnson295189b2012-06-20 16:38:30 -070013962 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053013963 pTLCb->atlSTAClients[staId]->rssiAvgBmps = rssi;
Jeff Johnson295189b2012-06-20 16:38:30 -070013964 }
13965}
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053013966
13967/*===============================================================================
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053013968 FUNCTION WLANTL_UpdateSnrBmps
13969
13970 DESCRIPTION This function updates the TL's SNR (in BMPS mode)
13971
13972 DEPENDENCIES None
13973
13974 PARAMETERS
13975
13976 pvosGCtx VOS context VOS Global context
13977 staId Station ID Station ID
13978 snr SNR (BMPS mode) SNR in BMPS mode
13979
13980 RETURN None
13981
13982 SIDE EFFECTS none
13983 ===============================================================================*/
13984
13985void WLANTL_UpdateSnrBmps(v_PVOID_t pvosGCtx, v_U8_t staId, v_S7_t snr)
13986{
13987 WLANTL_CbType* pTLCb = VOS_GET_TL_CB(pvosGCtx);
13988
13989 if (NULL != pTLCb && NULL != pTLCb->atlSTAClients[staId])
13990 {
13991 pTLCb->atlSTAClients[staId]->snrAvgBmps = snr;
13992 }
13993}
13994
13995/*===============================================================================
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053013996 FUNCTION WLANTL_UpdateLinkCapacity
13997
13998 DESCRIPTION This function updates the STA's Link Capacity in TL
13999
14000 DEPENDENCIES None
14001
14002 PARAMETERS
14003
14004 pvosGCtx VOS context VOS Global context
14005 staId Station ID Station ID
14006 linkCapacity linkCapacity Link Capacity
14007
14008 RETURN None
14009
14010 SIDE EFFECTS none
14011 ===============================================================================*/
14012
14013void WLANTL_UpdateLinkCapacity(v_PVOID_t pvosGCtx, v_U8_t staId, v_U32_t linkCapacity)
14014{
14015 WLANTL_CbType* pTLCb = VOS_GET_TL_CB(pvosGCtx);
14016
14017 if (NULL != pTLCb && NULL != pTLCb->atlSTAClients[staId])
14018 {
14019 pTLCb->atlSTAClients[staId]->linkCapacity = linkCapacity;
14020 }
14021}
14022
14023
14024/*===========================================================================
14025
14026 FUNCTION WLANTL_GetSTALinkCapacity
14027
14028 DESCRIPTION
14029
14030 Returns Link Capacity of a particular STA.
14031
14032 DEPENDENCIES
14033
14034 A station must have been registered before its state can be retrieved.
14035
14036
14037 PARAMETERS
14038
14039 IN
14040 pvosGCtx: pointer to the global vos context; a handle to TL's
14041 control block can be extracted from its context
14042 ucSTAId: identifier of the station
14043
14044 OUT
14045 plinkCapacity: the current link capacity the connection to
14046 the given station
14047
14048
14049 RETURN VALUE
14050
14051 The result code associated with performing the operation
14052
14053 VOS_STATUS_E_INVAL: Input parameters are invalid
14054 VOS_STATUS_E_FAULT: Station ID is outside array boundaries or pointer to
14055 TL cb is NULL ; access would cause a page fault
14056 VOS_STATUS_E_EXISTS: Station was not registered
14057 VOS_STATUS_SUCCESS: Everything is good :)
14058
14059 SIDE EFFECTS
14060
14061============================================================================*/
14062VOS_STATUS
14063WLANTL_GetSTALinkCapacity
14064(
14065 v_PVOID_t pvosGCtx,
14066 v_U8_t ucSTAId,
14067 v_U32_t *plinkCapacity
14068)
14069{
14070 WLANTL_CbType* pTLCb = NULL;
14071 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
14072
14073 /*------------------------------------------------------------------------
14074 Sanity check
14075 ------------------------------------------------------------------------*/
14076 if ( NULL == plinkCapacity )
14077 {
14078 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
14079 FL("WLAN TL:Invalid parameter")));
14080 return VOS_STATUS_E_INVAL;
14081 }
14082
14083 if ( WLANTL_STA_ID_INVALID( ucSTAId ) )
14084 {
14085 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
14086 FL("WLAN TL:Invalid station id")));
14087 return VOS_STATUS_E_FAULT;
14088 }
14089
14090 /*------------------------------------------------------------------------
14091 Extract TL control block and check existance
14092 ------------------------------------------------------------------------*/
14093 pTLCb = VOS_GET_TL_CB(pvosGCtx);
14094 if ( NULL == pTLCb )
14095 {
14096 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
14097 FL("WLAN TL:Invalid TL pointer from pvosGCtx")));
14098 return VOS_STATUS_E_FAULT;
14099 }
14100
14101 if ( NULL == pTLCb->atlSTAClients[ucSTAId] )
14102 {
14103 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
14104 FL("WLAN TL:Client Memory was not allocated")));
14105 return VOS_STATUS_E_FAILURE;
14106 }
14107
14108 if ( 0 == pTLCb->atlSTAClients[ucSTAId]->ucExists )
14109 {
14110 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
14111 FL("WLAN TL:Station was not previously registered")));
14112 return VOS_STATUS_E_EXISTS;
14113 }
14114
14115 /*------------------------------------------------------------------------
14116 Get STA state
14117 ------------------------------------------------------------------------*/
14118 *plinkCapacity = pTLCb->atlSTAClients[ucSTAId]->linkCapacity;
14119
14120 return VOS_STATUS_SUCCESS;
14121}/* WLANTL_GetSTALinkCapacity */
Abhishek Singh00b71972016-01-07 10:51:04 +053014122
Sravan Kumar Kairam893801a2016-11-01 19:14:23 +053014123/*
14124 * WLANTL_ResetRxSSN - reset last rx ssn
14125 * @pvosGCtx: global vos context
14126 * @ucSTAId: station id
14127 *
14128 * This function resets the last ssn of all tids of the station
14129 * for whom BA reorder session exists.
14130 *
14131 * Return: none
14132 */
14133void WLANTL_ResetRxSSN(v_PVOID_t pvosGCtx, uint8_t ucSTAId)
14134{
14135 WLANTL_CbType* pTLCb = NULL;
14136 WLANTL_STAClientType* pClientSTA = NULL;
14137 uint8_t i;
14138
14139 if (WLANTL_STA_ID_INVALID(ucSTAId)) {
14140 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
14141 "WLAN TL:Invalid station id requested WLANTL_ResetRxSSN"));
14142 return;
14143 }
14144
14145 pTLCb = VOS_GET_TL_CB(pvosGCtx);
14146 if (NULL == pTLCb) {
14147 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
14148 "WLAN TL:Invalid TL pointer from pvosGCtx WLANTL_ResetRxSSN"));
14149 return;
14150 }
14151
14152 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
14153
14154 for (i = 0; i < WLAN_MAX_TID ; i++) {
14155 if (0 == pClientSTA->atlBAReorderInfo[i].ucExists) {
14156 continue;
14157 }
14158 TLLOG1(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
14159 "WLAN TL: Last RxSSN reset to zero for tid %d", i));
14160 pClientSTA->atlBAReorderInfo[i].LastSN = 0;
14161 }
14162}
Abhishek Singh00b71972016-01-07 10:51:04 +053014163
Sravan Kumar Kairama97e2372016-11-11 17:20:03 +053014164void WLANTL_SetDataPktFilter(v_PVOID_t pvosGCtx, uint8_t ucSTAId, bool flag)
14165{
14166 WLANTL_CbType* pTLCb = NULL;
14167 WLANTL_STAClientType* pClientSTA = NULL;
14168 uint8_t i;
14169
14170 if (WLANTL_STA_ID_INVALID(ucSTAId)) {
14171 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
14172 "%s: Invalid station id requested", __func__));
14173 return;
14174 }
14175
14176 pTLCb = VOS_GET_TL_CB(pvosGCtx);
14177 if (NULL == pTLCb) {
14178 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
14179 "%s: Invalid TL pointer from pvosGCtx", __func__));
14180 return;
14181 }
14182
14183 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
14184
14185 for (i = 0; i < WLAN_MAX_TID ; i++) {
14186 if (0 == pClientSTA->atlBAReorderInfo[i].ucExists)
14187 continue;
14188
14189 TLLOG1(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
14190 "WLAN TL: Last RxSSN reset to zero for tid %d", i));
14191 pClientSTA->atlBAReorderInfo[i].set_data_filter = flag;
14192 }
14193}
14194
Sravan Kumar Kairam60b8cf02016-12-12 16:22:09 +053014195/**
14196 * WLANTL_ShiftArrByOne() - utility function to shift array by one
14197 * @arr: pointer to array
14198 * @len: length of the array
14199 *
14200 * Caller responsibility to provide the correct length of the array
14201 * other may leads to bugs.
14202 *
14203 * Return: void
14204 */
14205static void WLANTL_ShiftArrByOne(uint32_t *arr, uint8_t len)
14206{
14207 int i;
14208 for (i = 0; i < len - 1; i ++)
14209 arr[i] = arr[i + 1];
14210 arr[i] = 0;
14211}
14212
14213/**
14214 * WLANTL_SampleTx() - collect tx samples
14215 * @data: TL context pointer
14216 *
14217 * This function records the last five tx bytes sent samples
14218 * collected after tx_bytes_timer expire.
14219 *
14220 * Return: void
14221 */
14222void WLANTL_SampleTx(void *data)
14223{
14224 WLANTL_CbType* pTLCb = (WLANTL_CbType *)data;
14225 WLANTL_STAClientType* pClientSTA = NULL;
14226 uint8_t count = pTLCb->sample_count;
14227 uint8_t i;
14228
14229 for ( i = 0; i < WLAN_MAX_STA_COUNT; i++) {
14230 if (NULL != pTLCb->atlSTAClients[i] &&
14231 pTLCb->atlSTAClients[i]->ucExists) {
14232 pClientSTA = pTLCb->atlSTAClients[i];
14233
14234 if (count > (WLANTL_SAMPLE_COUNT - 1)) {
14235 count = WLANTL_SAMPLE_COUNT - 1;
14236 pClientSTA->tx_samples_sum -= pClientSTA->tx_sample[0];
14237 WLANTL_ShiftArrByOne(pClientSTA->tx_sample, WLANTL_SAMPLE_COUNT);
14238 }
14239
14240 pClientSTA->tx_sample[count] = pClientSTA->tx_frames;
14241 pClientSTA->tx_samples_sum += pClientSTA->tx_sample[count];
14242 pClientSTA->tx_frames = 0;
14243 count++;
14244 pTLCb->sample_count = count;
14245 }
14246 }
14247
14248 vos_timer_start(&pTLCb->tx_frames_timer, WLANTL_SAMPLE_INTERVAL);
14249}
Sravan Kumar Kairam091e5b62017-01-23 14:14:20 +053014250
14251/**
14252 * WLANTL_EnablePreAssocCaching() - Enable caching EAPOL frames
14253 *
14254 * Return: None
14255 *
14256 */
14257void WLANTL_EnablePreAssocCaching(void)
14258{
14259 v_PVOID_t pvosGCtx= vos_get_global_context(VOS_MODULE_ID_TL,NULL);
14260 WLANTL_CbType* pTLCb = VOS_GET_TL_CB(pvosGCtx);
14261 if (NULL == pTLCb ) {
14262 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
14263 "%s: Invalid TL pointer for global context", __func__));
14264 return;
14265 }
14266
14267 pTLCb->vosEapolCachedFrame = NULL;
14268 pTLCb->preassoc_caching = true;
14269}
14270
14271/**
14272 * WLANTL_ForwardPreAssoc() - forward cached eapol frames
14273 * @flag: Value to forward or flush
14274 *
14275 * Return: vos status
14276 *
14277 */
14278static VOS_STATUS WLANTL_ForwardPreAssoc(bool flag)
14279{
14280 vos_msg_t sMessage;
14281
14282 VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
14283 " ---- Serializing TL for forwarding pre assoc cache frames");
14284
14285 vos_mem_zero( &sMessage, sizeof(vos_msg_t));
14286 sMessage.type = WLANTL_RX_FWD_PRE_ASSOC_CACHED;
14287 sMessage.bodyval = flag;
14288
14289 return vos_rx_mq_serialize(VOS_MQ_ID_TL, &sMessage);
14290}
14291
14292/**
14293 * WLANTL_PreAssocForward() - forward cached eapol frames
14294 * @flag: Value to forward or flush
14295 *
14296 * Return: None
14297 *
14298 */
14299void WLANTL_PreAssocForward(bool flag)
14300{
14301 if(!VOS_IS_STATUS_SUCCESS(WLANTL_ForwardPreAssoc(flag)))
14302 {
14303 VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
14304 " %s fails to forward packets", __func__);
14305 }
14306}
14307
14308/**
14309 * WLANTL_RegisterFwdEapol() - register call back to forward cached eapol frame
14310 * @pvosGCtx : pointer to vos global context
14311 * @pfnFwdEapol: call back function pointer
14312 *
14313 * Return: None
14314 *
14315 */
14316void WLANTL_RegisterFwdEapol(v_PVOID_t pvosGCtx,
14317 WLANTL_FwdEapolCBType pfnFwdEapol)
14318{
14319 WLANTL_CbType* pTLCb = NULL;
14320 pTLCb = VOS_GET_TL_CB(pvosGCtx);
14321
14322 pTLCb->pfnEapolFwd = pfnFwdEapol;
14323
14324}
14325
Abhishek Singh00b71972016-01-07 10:51:04 +053014326#ifdef WLAN_FEATURE_RMC
14327VOS_STATUS WLANTL_RmcInit
14328(
14329 v_PVOID_t pAdapter
14330)
14331{
14332 WLANTL_CbType *pTLCb = VOS_GET_TL_CB(pAdapter);
14333 VOS_STATUS status = VOS_STATUS_SUCCESS;
14334 tANI_U8 count;
14335
14336 /*sanity check*/
14337 if (NULL == pTLCb)
14338 {
14339 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
14340 "Invalid TL handle"));
14341 return VOS_STATUS_E_INVAL;
14342 }
14343
14344 for ( count = 0; count < WLANTL_RMC_HASH_TABLE_SIZE; count++ )
14345 {
14346 pTLCb->rmcSession[count] = NULL;
14347 }
14348
14349 vos_lock_init(&pTLCb->rmcLock);
14350
14351 pTLCb->multicastDuplicateDetectionEnabled = 1;
14352 pTLCb->rmcDataPathEnabled = 0;
14353
14354 return status;
14355}
14356
14357
14358VOS_STATUS WLANTL_RmcDeInit
14359(
14360 v_PVOID_t pAdapter
14361)
14362{
14363 WLANTL_CbType *pTLCb = VOS_GET_TL_CB(pAdapter);
14364 VOS_STATUS status = VOS_STATUS_SUCCESS;
14365 tANI_U8 count;
14366 WLANTL_RMC_SESSION *pNode;
14367 WLANTL_RMC_SESSION *pPrev;
14368
14369 /*sanity check*/
14370 if (NULL == pTLCb)
14371 {
14372 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
14373 "Invalid TL handle"));
14374 return VOS_STATUS_E_INVAL;
14375 }
14376
14377 for ( count = 0; count < WLANTL_RMC_HASH_TABLE_SIZE; count++ )
14378 {
14379 pNode = pTLCb->rmcSession[count];
14380 while (pNode)
14381 {
14382 pPrev = pNode;
14383 pNode = pNode->next;
14384 vos_mem_free((v_VOID_t * )pPrev);
14385 }
14386 }
14387
14388 vos_lock_destroy(&pTLCb->rmcLock);
14389
14390 return status;
14391}
14392
14393
14394tANI_U8 WLANTL_RmcHashRmcSession ( v_MACADDR_t *pMcastAddr )
14395{
14396 tANI_U32 sum;
14397 tANI_U8 hash;
14398
14399 sum = (pMcastAddr->bytes[0] + pMcastAddr->bytes[1] + pMcastAddr->bytes[2] +
14400 pMcastAddr->bytes[3] + pMcastAddr->bytes[4] + pMcastAddr->bytes[5]);
14401
14402 hash = (tANI_U8)(sum & ((WLANTL_RMC_HASH_TABLE_SIZE - 1)));
14403
14404 return hash;
14405}
14406
14407
14408WLANTL_RMC_SESSION* WLANTL_RmcLookUpRmcSession
14409(
14410 WLANTL_RMC_SESSION *rmcSession[],
14411 v_MACADDR_t *pMcastAddr
14412)
14413{
14414 WLANTL_RMC_SESSION *pNode;
14415 tANI_U8 index;
14416
14417 /*sanity check*/
14418 if (NULL == pMcastAddr)
14419 {
14420 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
14421 "Sanity check failed pMcastAddr %p", pMcastAddr));
14422 return NULL;
14423 }
14424
14425 index = WLANTL_RmcHashRmcSession(pMcastAddr);
14426 pNode = rmcSession[index];
14427 while ( pNode )
14428 {
14429 if (vos_is_macaddr_equal( &(pNode->rmcAddr), pMcastAddr))
14430 {
14431 return pNode;
14432 }
14433 pNode = pNode->next;
14434 }
14435
14436 return NULL;
14437}
14438
14439WLANTL_RMC_SESSION *WLANTL_RmcAddRmcSession
14440(
14441 WLANTL_RMC_SESSION *rmcSession[],
14442 v_MACADDR_t *pMcastAddr
14443)
14444{
14445 WLANTL_RMC_SESSION *pNode;
14446 tANI_U8 index;
14447
14448 index = WLANTL_RmcHashRmcSession(pMcastAddr);
14449 pNode = WLANTL_RmcLookUpRmcSession(rmcSession, pMcastAddr);
14450 if ( NULL != pNode )
14451 {
14452 /*already exists*/
14453 return NULL;
14454 }
14455 else
14456 {
14457 pNode = (WLANTL_RMC_SESSION *)vos_mem_malloc(sizeof(*pNode));
14458 if (pNode)
14459 {
14460 vos_mem_copy( &(pNode->rmcAddr), pMcastAddr,
14461 sizeof(pNode->rmcAddr) );
14462 pNode->next = rmcSession[index];
14463 rmcSession[index] = pNode;
14464 return pNode;
14465 }
14466 else
14467 {
14468 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14469 "%s: vos_mem_malloc failed can't enable RMC session",
14470 __func__);
14471 return NULL;
14472 }
14473 }
14474}
14475
14476tANI_U8
14477WLANTL_RmcDeleteRmcSession
14478(
14479 WLANTL_RMC_SESSION *rmcSession[],
14480 v_MACADDR_t *pMcastAddr
14481)
14482{
14483 WLANTL_RMC_SESSION *pHead;
14484 WLANTL_RMC_SESSION *pNode;
14485 WLANTL_RMC_SESSION *pPrev;
14486 tANI_U8 index;
14487
14488 index = WLANTL_RmcHashRmcSession(pMcastAddr);
14489 pHead = pNode = rmcSession[index];
14490 while (pNode)
14491 {
14492 if (vos_is_macaddr_equal( &(pNode->rmcAddr), pMcastAddr))
14493 {
14494 if (pHead == pNode)
14495 {
14496 rmcSession[index] = pNode->next;
14497 }
14498 else
14499 {
14500 pPrev->next = pNode->next;
14501 }
14502 vos_mem_free((v_VOID_t * )pNode);
14503 return 1;
14504 }
14505 pPrev = pNode;
14506 pNode = pNode->next;
14507 }
14508
14509 return 0;
14510}
14511
14512VOS_STATUS
14513WLANTL_ProcessRmcCommand
14514(
14515 WLANTL_CbType* pTLCb,
14516 v_MACADDR_t *pMcastAddr,
14517 tANI_U32 command
14518)
14519{
14520 VOS_STATUS status;
14521 tANI_U32 count;
14522 tANI_U32 rmcActive;
14523
14524 if (!VOS_IS_STATUS_SUCCESS(vos_lock_acquire( &(pTLCb->rmcLock))))
14525 {
14526 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
14527 "%s Get Lock Fail", __func__));
14528 return VOS_STATUS_E_FAILURE;
14529 }
14530
14531 /*add or delete node from active rmc hash table*/
14532 if (command)
14533 {
14534 /*add requested rmc session in active rmc session list*/
14535 if (WLANTL_RmcAddRmcSession(pTLCb->rmcSession, pMcastAddr))
14536 {
14537 TLLOGE( VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
14538 "RMC session " MAC_ADDRESS_STR " added in TL hash table",
14539 MAC_ADDR_ARRAY(pMcastAddr->bytes) ) );
14540 pTLCb->rmcDataPathEnabled = TRUE;
14541 status = VOS_STATUS_SUCCESS;
14542 }
14543 else
14544 {
14545 TLLOGE( VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
14546 "RMC session " MAC_ADDRESS_STR " already exists in TL hash"
14547 " table", MAC_ADDR_ARRAY(pMcastAddr->bytes) ) );
14548 status = VOS_STATUS_E_FAILURE;
14549 }
14550 }
14551 else
14552 {
14553 /*delete requested rmc session from active rmc session list*/
14554 if (WLANTL_RmcDeleteRmcSession(pTLCb->rmcSession, pMcastAddr))
14555 {
14556 TLLOGE( VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
14557 "RMC session " MAC_ADDRESS_STR " deleted from TL hash table",
14558 MAC_ADDR_ARRAY(pMcastAddr->bytes)) );
14559 status = VOS_STATUS_SUCCESS;
14560 rmcActive = FALSE;
14561 for ( count = 0; count < WLANTL_RMC_HASH_TABLE_SIZE; count++ )
14562 {
14563 if (pTLCb->rmcSession[count])
14564 {
14565 rmcActive = TRUE;
14566 break;
14567 }
14568 }
14569 if (TRUE == rmcActive)
14570 {
14571 pTLCb->rmcDataPathEnabled = TRUE;
14572 }
14573 else
14574 {
14575 pTLCb->rmcDataPathEnabled = FALSE;
14576 }
14577 }
14578 else
14579 {
14580 TLLOGE( VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
14581 "RMC session " MAC_ADDRESS_STR " doesn't exist in TL hash"
14582 " table", MAC_ADDR_ARRAY(pMcastAddr->bytes) ) );
14583 status = VOS_STATUS_E_FAILURE;
14584 }
14585 }
14586
14587 if (!VOS_IS_STATUS_SUCCESS(vos_lock_release(&(pTLCb->rmcLock))))
14588 {
14589 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
14590 "%s Release Lock Fail", __func__));
14591 return VOS_STATUS_E_FAILURE;
14592 }
14593
14594 return status;
14595}/* End of WLANTL_ProcessRmcCommand */
14596
14597VOS_STATUS
14598WLANTL_EnableRMC
14599(
14600 v_PVOID_t pvosGCtx,
14601 v_MACADDR_t *pMcastTransmitterAddr
14602)
14603{
14604 WLANTL_CbType* pTLCb;
14605 VOS_STATUS status;
14606
14607 /*sanity check*/
14608 if ( (NULL == pvosGCtx) || (NULL == pMcastTransmitterAddr) )
14609 {
14610 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
14611 "WLAN TL %s: Sanity check failed pvosGCtx %p aMcastAddr %p",
14612 __func__, pvosGCtx, pMcastTransmitterAddr));
14613 return VOS_STATUS_E_FAILURE;
14614 }
14615
14616 /*sanity check*/
14617 pTLCb = VOS_GET_TL_CB(pvosGCtx);
14618 if ( NULL == pTLCb )
14619 {
14620 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
14621 "WLAN TL %s: pTLCb is NULL", __func__));
14622 return VOS_STATUS_E_FAILURE;
14623 }
14624
14625 status = WLANTL_ProcessRmcCommand(pTLCb, pMcastTransmitterAddr , 1);
14626
14627 return status;
14628} /* End of WLANTL_EnableRMC */
14629
14630
14631VOS_STATUS
14632WLANTL_DisableRMC
14633(
14634 v_PVOID_t pvosGCtx,
14635 v_MACADDR_t *pMcastTransmitterAddr
14636)
14637{
14638 WLANTL_CbType* pTLCb;
14639 VOS_STATUS status;
14640
14641 /*Sanity check*/
14642 if ((NULL == pvosGCtx) || (NULL == pMcastTransmitterAddr))
14643 {
14644 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
14645 "WLAN TL %s: Sanity check failed pvosGCtx %p aMcastAddr %p",
14646 __func__, pvosGCtx, pMcastTransmitterAddr));
14647 return VOS_STATUS_E_FAILURE;
14648 }
14649
14650 /*Sanity check*/
14651 pTLCb = VOS_GET_TL_CB(pvosGCtx);
14652 if (NULL == pTLCb)
14653 {
14654 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
14655 "WLAN TL %s: pTLCb is NULL", __func__));
14656 return VOS_STATUS_E_FAILURE;
14657 }
14658
14659 status = WLANTL_ProcessRmcCommand(pTLCb, pMcastTransmitterAddr, 0);
14660
14661 return status;
14662} /* End of WLANTL_DisableRMC */
14663
14664
14665/*=============================================================================
14666 Duplicate Multicast Detection Functions
14667==============================================================================*/
14668
14669/*=============================================================================
14670 FUNCTION WLANTL_IsDuplicateMcastFrm
14671
14672 DESCRIPTION
14673 This function checks for duplicast multicast frames and drops them.
14674
14675 DEPENDENCIES
14676
14677 PARAMETERS
14678
14679 IN
14680
14681 pClientSTA : Pointer to WLANTL_STAClientType
14682 aucBDHeader : Pointer to BD header
14683
14684 RETURN VALUE
14685
14686 VOS_FALSE: This frame is not a duplicate
14687
14688 VOS_TRUE: This frame is a duplicate
14689
14690==============================================================================*/
14691v_U8_t
14692WLANTL_IsDuplicateMcastFrm
14693(
14694 WLANTL_STAClientType *pClientSTA,
14695 vos_pkt_t *vosDataBuff
14696)
14697{
14698 v_U8_t duplicate = VOS_FALSE;
14699 WLANTL_RMC_SESSION *pNode;
14700 v_U16_t usSeqCtrl;
14701 v_MACADDR_t mcastAddr;
14702 VOS_STATUS vosStatus;
14703 v_PVOID_t pvPeekData;
14704
14705 /* Get address 1 of Data Frame */
14706 vosStatus = vos_pkt_peek_data(vosDataBuff, WLANTL_MAC_ADDR_ALIGN(1),
14707 (v_PVOID_t)&pvPeekData, VOS_MAC_ADDR_SIZE);
14708
14709 if ( VOS_STATUS_SUCCESS != vosStatus )
14710 {
14711 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
14712 "WLAN TL: Failed to get Addr 1 of 80211 header from packet %d",
14713 vosStatus));
14714 return VOS_FALSE;
14715 }
14716
14717 /* Copy address 1 of Data Frame */
14718 vos_mem_copy(&mcastAddr.bytes, pvPeekData, VOS_MAC_ADDR_SIZE);
14719
14720 /*
14721 * We perform duplicate detection for only multicast data frames
14722 */
14723 if (vos_is_macaddr_group(&mcastAddr) &&
14724 !vos_is_macaddr_broadcast(&mcastAddr))
14725 {
14726 /* Get sequence control of Data Frame */
14727 vosStatus = vos_pkt_peek_data(vosDataBuff,
14728 (WLANTL_MAC_ADDR_ALIGN(1) + (3 * VOS_MAC_ADDR_SIZE)),
14729 (v_PVOID_t)&pvPeekData, sizeof(v_U16_t));
14730
14731 if ( VOS_STATUS_SUCCESS != vosStatus )
14732 {
14733 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
14734 "WLAN TL: Failed to get Sequence Control from packet %d",
14735 vosStatus));
14736 return VOS_FALSE;
14737 }
14738
14739 /* Copy sequence control from the Data Frame */
14740 usSeqCtrl = *(v_U16_t *)pvPeekData;
14741
14742 if (!VOS_IS_STATUS_SUCCESS(vos_lock_acquire(&(pClientSTA->mcLock))))
14743 {
14744 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
14745 "%s Get Lock Fail", __func__));
14746 return VOS_FALSE;
14747 }
14748
14749 pNode = WLANTL_RmcLookUpRmcSession(pClientSTA->mcastSession,
14750 &mcastAddr);
14751 if (NULL == pNode)
14752 {
14753 /* If the session does not exist, add it. */
14754 pNode = WLANTL_RmcAddRmcSession(pClientSTA->mcastSession,
14755 &mcastAddr);
14756 /* If we could not add a entry, skip duplicate detection */
14757 if (NULL == pNode)
14758 {
14759 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
14760 "%s Failed to add multicast session", __func__));
14761 if (!VOS_IS_STATUS_SUCCESS
14762 (vos_lock_release(&(pClientSTA->mcLock))))
14763 {
14764 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
14765 "%s Release Lock Fail", __func__));
14766 }
14767 return VOS_FALSE;
14768 }
14769 /* Initialize the sequence control value. */
14770 pNode->mcSeqCtl = usSeqCtrl;
14771 }
14772 else
14773 {
14774 /*
14775 * Check if the sequence number of this frame matches the last
14776 * we have seen.
14777 */
14778 if (pNode->mcSeqCtl == usSeqCtrl)
14779 {
14780 pNode->rxMCDupcnt++;
14781 TLLOG1(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
14782 "%s Rx Multicast Duplicate %d " MAC_ADDRESS_STR
14783 " (Seq %x)", __func__,
14784 pNode->rxMCDupcnt, MAC_ADDR_ARRAY(mcastAddr.bytes),
14785 usSeqCtrl));
14786 duplicate = VOS_TRUE;
14787 }
14788 else
14789 {
14790 /* Update the last seen sequence number */
14791 pNode->mcSeqCtl = usSeqCtrl;
14792 }
14793 }
14794
14795 if (!VOS_IS_STATUS_SUCCESS (vos_lock_release(&(pClientSTA->mcLock))))
14796 {
14797 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
14798 "%s Release Lock Fail", __func__));
14799 }
14800 }
14801
14802 return duplicate;
14803}
14804
14805/*=============================================================================
14806 FUNCTION WLANTL_McastDeleteAllEntries
14807
14808 DESCRIPTION
14809 This function removes all multicast entries used for duplicate detection
14810
14811 DEPENDENCIES
14812
14813 PARAMETERS
14814
14815 IN
14816
14817 pClientSTA : Pointer to WLANTL_STAClientType
14818
14819 RETURN VALUE
14820
14821 None
14822
14823==============================================================================*/
14824void
14825WLANTL_McastDeleteAllEntries(WLANTL_STAClientType * pClientSTA)
14826{
14827 WLANTL_RMC_SESSION *pNode, **head;
14828 int index;
14829
14830 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
14831 "%s Deleting all multicast entries", __func__));
14832
14833 if (!VOS_IS_STATUS_SUCCESS(vos_lock_acquire(&(pClientSTA->mcLock))))
14834 {
14835 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
14836 "%s Get Lock Fail", __func__));
14837 return;
14838 }
14839
14840 for (index = 0; index < WLANTL_RMC_HASH_TABLE_SIZE; index++)
14841 {
14842 head = &pClientSTA->mcastSession[index];
14843
14844 pNode = *head;
14845
14846 while (pNode)
14847 {
14848 *head = pNode->next;
14849 /* free the group entry */
14850 vos_mem_free(pNode);
14851 pNode = *head;
14852 }
14853 }
14854
14855 if (!VOS_IS_STATUS_SUCCESS (vos_lock_release(&(pClientSTA->mcLock))))
14856 {
14857 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
14858 "%s Release Lock Fail", __func__));
14859 }
14860}
14861
14862/*=============================================================================
14863 FUNCTION WLANTL_SetMcastDuplicateDetection
14864
14865 DESCRIPTION
14866 This function sets multicate duplicate detection operation.
14867 If enable is 1, the detection is enabled, else it is disabled.
14868
14869 DEPENDENCIES
14870
14871 PARAMETERS
14872
14873 IN
14874
14875 pvosGCtx : Pointer to VOS global context
14876 enable : Boolean to enable or disable
14877
14878 RETURN VALUE
14879 The result code associated with performing the operation
14880
14881 VOS_STATUS_E_FAULT: Sanity check on input failed
14882
14883 VOS_STATUS_SUCCESS: Everything is good :)
14884
14885 Other return values are possible coming from the called functions.
14886 Please check API for additional info.
14887
14888 SIDE EFFECTS
14889
14890==============================================================================*/
14891VOS_STATUS
14892WLANTL_SetMcastDuplicateDetection
14893(
14894 v_PVOID_t pvosGCtx,
14895 v_U8_t enable
14896)
14897{
14898 WLANTL_CbType* pTLCb;
14899
14900 /*Sanity check*/
14901 if (NULL == pvosGCtx)
14902 {
14903 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
14904 "WLAN TL %s: Sanity check failed pvosGCtx %p",
14905 __func__, pvosGCtx));
14906 return VOS_STATUS_E_FAILURE;
14907 }
14908
14909 /*Sanity check*/
14910 pTLCb = VOS_GET_TL_CB(pvosGCtx);
14911 if (NULL == pTLCb)
14912 {
14913 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
14914 "WLAN TL %s: pTLCb is NULL", __func__));
14915 return VOS_STATUS_E_FAILURE;
14916 }
14917
14918 switch (enable)
14919 {
14920 default:
14921 /*
14922 * Any value other than 0 or 1 is used to dump the
14923 * duplicate count.
14924 */
14925 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
14926 "WLAN TL %s: Multicast Duplicate Count %d",
14927 __func__, pTLCb->mcastDupCnt));
14928 break;
14929 case 0:
14930 case 1:
14931 pTLCb->multicastDuplicateDetectionEnabled = enable;
14932 break;
14933 }
14934
14935 return VOS_STATUS_SUCCESS;
14936}
14937
14938#endif /* WLAN_FEATURE_RMC */