blob: 2b0584f28299541e4102a7d229ce656d30a68fa9 [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Rajeev Kumar Sirasanagandla8701da32018-02-05 16:59:08 +05302 * Copyright (c) 2012-2018 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,
Jeff Johnsonddec6482017-09-19 08:33:57 -0700632 "WLAN TL: Invalid input pointer on WLANTL_Open TL %pK Config %pK", 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
Sravan Kumar Kairam715072e2017-03-10 17:12:43 +0530701 pTLCb->uCurServedAC = WLANTL_AC_VO;
702 pTLCb->ucCurLeftWeight = pTLCb->tlConfigInfo.ucAcWeights[pTLCb->uCurServedAC];
Jeff Johnson295189b2012-06-20 16:38:30 -0700703 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
Sravan Kumar Kairam56bb37a2017-12-29 17:15:19 +0530725 pTLCb->tlConfigInfo.ucIsReplayCheck =
726 pTLConfig->ucIsReplayCheck;
727
Jeff Johnson295189b2012-06-20 16:38:30 -0700728 /*------------------------------------------------------------------------
729 Allocate internal resources
730 ------------------------------------------------------------------------*/
731 vos_pkt_get_packet(&pTLCb->vosDummyBuf, VOS_PKT_TYPE_RX_RAW, 1, 1,
732 1/*true*/,NULL, NULL);
733
734 WLANTL_InitBAReorderBuffer(pvosGCtx);
735#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
736 /* Initialize Handoff support modue
737 * RSSI measure and Traffic state monitoring */
738 status = WLANTL_HSInit(pvosGCtx);
739 if(!VOS_IS_STATUS_SUCCESS(status))
740 {
741 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
742 "Handoff support module init fail"));
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +0530743 WLANTL_FreeClientMemory(pTLCb->atlSTAClients);
Sushant Kaushikf4a27972015-04-16 16:48:00 +0530744 vos_mem_vfree(pTLCb->reorderBufferPool);
Jeff Johnson295189b2012-06-20 16:38:30 -0700745 vos_free_context(pvosGCtx, VOS_MODULE_ID_TL, pTLCb);
746 return status;
747 }
748#endif
749
Abhishek Singh00b71972016-01-07 10:51:04 +0530750#ifdef WLAN_FEATURE_RMC
751 status = WLANTL_RmcInit(pvosGCtx);
752 if (!VOS_IS_STATUS_SUCCESS(status))
753 {
754 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
755 "RMC module init fail"));
756 return status;
757 }
758#endif
759
Jeff Johnson295189b2012-06-20 16:38:30 -0700760 pTLCb->isBMPS = VOS_FALSE;
761 pmcRegisterDeviceStateUpdateInd( smeContext,
762 WLANTL_PowerStateChangedCB, pvosGCtx );
763
764 return VOS_STATUS_SUCCESS;
765}/* WLANTL_Open */
766
767/*==========================================================================
768
769 FUNCTION WLANTL_Start
770
771 DESCRIPTION
772 Called by HDD as part of the overall start procedure. TL will use this
773 call to register with BAL as a transport layer entity.
774
775 DEPENDENCIES
776
777 PARAMETERS
778
779 IN
780 pvosGCtx: pointer to the global vos context; a handle to TL's
781 control block can be extracted from its context
782
783 RETURN VALUE
784 The result code associated with performing the operation
785
786 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a page
787 fault
788 VOS_STATUS_SUCCESS: Everything is good :)
789
790 Other codes can be returned as a result of a BAL failure; see BAL API
791 for more info
792
793 SIDE EFFECTS
794
795============================================================================*/
796VOS_STATUS
797WLANTL_Start
798(
799 v_PVOID_t pvosGCtx
800)
801{
802 WLANTL_CbType* pTLCb = NULL;
803 v_U32_t uResCount = WDA_TLI_MIN_RES_DATA;
804 VOS_STATUS vosStatus;
805 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
806
807 /*------------------------------------------------------------------------
808 Sanity check
809 Extract TL control block
810 ------------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +0530811 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -0700812 pTLCb = VOS_GET_TL_CB(pvosGCtx);
813 if ( NULL == pTLCb )
814 {
815 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
816 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_Start"));
817 return VOS_STATUS_E_FAULT;
818 }
819
820 /*------------------------------------------------------------------------
821 Register with WDA as transport layer client
822 Request resources for tx from bus
823 ------------------------------------------------------------------------*/
824 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
825 "WLAN TL:WLAN TL:WLANTL_Start"));
826
Katya Nigam42e16e82014-02-04 16:28:55 +0530827 tlTraceInit();
Jeff Johnson295189b2012-06-20 16:38:30 -0700828 vosStatus = WDA_DS_Register( pvosGCtx,
829 WLANTL_TxComp,
830 WLANTL_RxFrames,
831 WLANTL_GetFrames,
832 WLANTL_ResourceCB,
833 WDA_TLI_MIN_RES_DATA,
834 pvosGCtx,
835 &uResCount );
836
837 if ( VOS_STATUS_SUCCESS != vosStatus )
838 {
839 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
840 "WLAN TL:TL failed to register with BAL/WDA, Err: %d",
841 vosStatus));
842 return vosStatus;
843 }
844
845 /* Enable transmission */
846 vos_atomic_set_U8( &pTLCb->ucTxSuspended, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700847 pTLCb->uResCount = uResCount;
Sravan Kumar Kairam60b8cf02016-12-12 16:22:09 +0530848
Sravan Kumar Kairamc6c6a442018-03-27 16:59:13 +0530849 if (IS_FEATURE_SUPPORTED_BY_FW(SAP_BUFF_ALLOC))
850 vos_timer_start(&pTLCb->tx_frames_timer, WLANTL_SAMPLE_INTERVAL);
Sravan Kumar Kairam60b8cf02016-12-12 16:22:09 +0530851
Jeff Johnson295189b2012-06-20 16:38:30 -0700852 return VOS_STATUS_SUCCESS;
853}/* WLANTL_Start */
854
855/*==========================================================================
856
857 FUNCTION WLANTL_Stop
858
859 DESCRIPTION
860 Called by HDD to stop operation in TL, before close. TL will suspend all
861 frame transfer operation and will wait for the close request to clean up
862 its resources.
863
864 DEPENDENCIES
865
866 PARAMETERS
867
868 IN
869 pvosGCtx: pointer to the global vos context; a handle to TL's
870 control block can be extracted from its context
871
872 RETURN VALUE
873 The result code associated with performing the operation
874
875 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a page
876 fault
877 VOS_STATUS_SUCCESS: Everything is good :)
878
879 SIDE EFFECTS
880
881============================================================================*/
882VOS_STATUS
883WLANTL_Stop
884(
885 v_PVOID_t pvosGCtx
886)
887{
888 WLANTL_CbType* pTLCb = NULL;
889 v_U8_t ucIndex;
890 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
891
892 /*------------------------------------------------------------------------
893 Sanity check
894 Extract TL control block
895 ------------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +0530896 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -0700897 pTLCb = VOS_GET_TL_CB(pvosGCtx);
898 if ( NULL == pTLCb )
899 {
900 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
901 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_ChangeSTAState"));
902 return VOS_STATUS_E_FAULT;
903 }
904
905 /*------------------------------------------------------------------------
906 Stop TL and empty Station list
907 ------------------------------------------------------------------------*/
908 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
909 "WLAN TL:WLANTL_Stop"));
910
911 /* Disable transmission */
912 vos_atomic_set_U8( &pTLCb->ucTxSuspended, 1);
913
914 if ( NULL != pTLCb->tlMgmtFrmClient.vosPendingDataBuff )
915 {
916 vos_pkt_return_packet(pTLCb->tlMgmtFrmClient.vosPendingDataBuff);
917 pTLCb->tlMgmtFrmClient.vosPendingDataBuff = NULL;
918 }
919
920 if ( NULL != pTLCb->tlBAPClient.vosPendingDataBuff )
921 {
922 vos_pkt_return_packet(pTLCb->tlBAPClient.vosPendingDataBuff);
923 pTLCb->tlBAPClient.vosPendingDataBuff = NULL;
924 }
925
926#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
927 if(VOS_STATUS_SUCCESS != WLANTL_HSStop(pvosGCtx))
928 {
929 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
930 "Handoff Support module stop fail"));
931 }
932#endif
933
Sravan Kumar Kairam60b8cf02016-12-12 16:22:09 +0530934 if (VOS_TIMER_STATE_STOPPED !=
935 vos_timer_getCurrentState(&pTLCb->tx_frames_timer))
936 vos_timer_stop(&pTLCb->tx_frames_timer);
937
Jeff Johnson295189b2012-06-20 16:38:30 -0700938 /*-------------------------------------------------------------------------
939 Clean client stations
940 -------------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +0530941 for ( ucIndex = 0; ucIndex < WLAN_MAX_STA_COUNT; ucIndex++)
Jeff Johnson295189b2012-06-20 16:38:30 -0700942 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +0530943 if ( NULL != pTLCb->atlSTAClients[ucIndex] )
944 {
945 WLANTL_CleanSTA(pTLCb->atlSTAClients[ucIndex], 1 /*empty all queues*/);
946 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700947 }
948
949
950 return VOS_STATUS_SUCCESS;
951}/* WLANTL_Stop */
952
953/*==========================================================================
954
955 FUNCTION WLANTL_Close
956
957 DESCRIPTION
958 Called by HDD during general driver close procedure. TL will clean up
959 all the internal resources.
960
961 DEPENDENCIES
962
963 PARAMETERS
964
965 IN
966 pvosGCtx: pointer to the global vos context; a handle to TL's
967 control block can be extracted from its context
968
969 RETURN VALUE
970 The result code associated with performing the operation
971
972 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a page
973 fault
974 VOS_STATUS_SUCCESS: Everything is good :)
975
976 SIDE EFFECTS
977
978============================================================================*/
979VOS_STATUS
980WLANTL_Close
981(
982 v_PVOID_t pvosGCtx
983)
984{
985 WLANTL_CbType* pTLCb = NULL;
986 tHalHandle smeContext;
987 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
988
989 /*------------------------------------------------------------------------
990 Sanity check
991 Extract TL control block
992 ------------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +0530993 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -0700994 pTLCb = VOS_GET_TL_CB(pvosGCtx);
995 if ( NULL == pTLCb )
996 {
997 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
998 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_ChangeSTAState"));
999 return VOS_STATUS_E_FAULT;
1000 }
1001 /*------------------------------------------------------------------------
1002 Deregister from PMC
1003 ------------------------------------------------------------------------*/
1004 smeContext = vos_get_context(VOS_MODULE_ID_SME, pvosGCtx);
1005 if ( NULL == smeContext )
1006 {
1007 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001008 "%s: Invalid smeContext", __func__));
Jeff Johnson295189b2012-06-20 16:38:30 -07001009 // continue so that we can cleanup as much as possible
1010 }
1011 else
1012 {
1013 pmcDeregisterDeviceStateUpdateInd( smeContext, WLANTL_PowerStateChangedCB );
1014 }
1015
1016#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
1017 if(VOS_STATUS_SUCCESS != WLANTL_HSDeInit(pvosGCtx))
1018 {
1019 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
1020 "Handoff Support module DeInit fail"));
1021 }
1022#endif
1023
Abhishek Singh00b71972016-01-07 10:51:04 +05301024#ifdef WLAN_FEATURE_RMC
1025 if(VOS_STATUS_SUCCESS != WLANTL_RmcDeInit(pvosGCtx))
1026 {
1027 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
1028 "RMC module DeInit fail"));
1029 }
1030#endif
1031
Sravan Kumar Kairam60b8cf02016-12-12 16:22:09 +05301032 if (VOS_TIMER_STATE_RUNNING ==
1033 vos_timer_getCurrentState(&pTLCb->tx_frames_timer)) {
1034 vos_timer_stop(&pTLCb->tx_frames_timer);
1035 }
1036 if (!VOS_IS_STATUS_SUCCESS(vos_timer_destroy(&pTLCb->tx_frames_timer))) {
1037 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1038 "%s: Cannot deallocate TX frames sample timer", __func__));
1039 }
1040
Jeff Johnson295189b2012-06-20 16:38:30 -07001041 /*------------------------------------------------------------------------
1042 Cleanup TL control block.
1043 ------------------------------------------------------------------------*/
1044 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
1045 "WLAN TL: WLANTL_Close"));
1046 WLANTL_CleanCB(pTLCb, 1 /* empty queues/lists/pkts if any*/);
1047
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301048 WLANTL_FreeClientMemory(pTLCb->atlSTAClients);
1049
Sushant Kaushikf4a27972015-04-16 16:48:00 +05301050 vos_mem_vfree(pTLCb->reorderBufferPool);
Jeff Johnson295189b2012-06-20 16:38:30 -07001051
1052 /*------------------------------------------------------------------------
1053 Free TL context from VOSS global
1054 ------------------------------------------------------------------------*/
1055 vos_free_context(pvosGCtx, VOS_MODULE_ID_TL, pTLCb);
1056 return VOS_STATUS_SUCCESS;
1057}/* WLANTL_Close */
1058
1059/*----------------------------------------------------------------------------
1060 INTERACTION WITH HDD
1061 ---------------------------------------------------------------------------*/
1062/*==========================================================================
1063
1064 FUNCTION WLANTL_ConfigureSwFrameTXXlationForAll
1065
1066 DESCRIPTION
1067 Function to disable/enable frame translation for all association stations.
1068
1069 DEPENDENCIES
1070
1071 PARAMETERS
1072 IN
1073 pvosGCtx: VOS context
1074 EnableFrameXlation TRUE means enable SW translation for all stations.
1075 .
1076
1077 RETURN VALUE
1078
1079 void.
1080
1081============================================================================*/
1082void
1083WLANTL_ConfigureSwFrameTXXlationForAll
1084(
1085 v_PVOID_t pvosGCtx,
1086 v_BOOL_t enableFrameXlation
1087)
1088{
1089 v_U8_t ucIndex;
1090 /*------------------------------------------------------------------------
1091 Extract TL control block
1092 ------------------------------------------------------------------------*/
1093 WLANTL_CbType* pTLCb = VOS_GET_TL_CB(pvosGCtx);
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301094 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07001095 if ( NULL == pTLCb )
1096 {
1097 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1098 "WLAN TL:Invalid TL pointer from pvosGCtx on "
1099 "WLANTL_ConfigureSwFrameTXXlationForAll"));
1100 return;
1101 }
1102
1103 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
1104 "WLANTL_ConfigureSwFrameTXXlationForAll: Configure SW frameXlation %d",
1105 enableFrameXlation));
1106
1107 for ( ucIndex = 0; ucIndex < WLAN_MAX_TID; ucIndex++)
1108 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301109 pClientSTA = pTLCb->atlSTAClients[ucIndex];
1110 if ( NULL != pClientSTA && 0 != pClientSTA->ucExists )
Jeff Johnson295189b2012-06-20 16:38:30 -07001111 {
1112#ifdef WLAN_SOFTAP_VSTA_FEATURE
1113 // if this station was not allocated resources to perform HW-based
1114 // TX frame translation then force SW-based TX frame translation
1115 // otherwise use the frame translation supplied by the client
1116 if (!WDA_IsHwFrameTxTranslationCapable(pvosGCtx, ucIndex))
1117 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301118 pClientSTA->wSTADesc.ucSwFrameTXXlation = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07001119 }
1120 else
1121#endif
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301122 pClientSTA->wSTADesc.ucSwFrameTXXlation = enableFrameXlation;
Jeff Johnson295189b2012-06-20 16:38:30 -07001123 }
1124 }
1125}
1126
1127/*===========================================================================
1128
1129 FUNCTION WLANTL_StartForwarding
1130
1131 DESCRIPTION
1132
1133 This function is used to ask serialization through TX thread of the
1134 cached frame forwarding (if statation has been registered in the mean while)
1135 or flushing (if station has not been registered by the time)
1136
1137 In case of forwarding, upper layer is only required to call WLANTL_RegisterSTAClient()
1138 and doesn't need to call this function explicitly. TL will handle this inside
1139 WLANTL_RegisterSTAClient().
1140
1141 In case of flushing, upper layer is required to call this function explicitly
1142
1143 DEPENDENCIES
1144
1145 TL must have been initialized before this gets called.
1146
1147
1148 PARAMETERS
1149
1150 ucSTAId: station id
1151
1152 RETURN VALUE
1153
1154 The result code associated with performing the operation
1155 Please check return values of vos_tx_mq_serialize.
1156
1157 SIDE EFFECTS
1158 If TL was asked to perform WLANTL_CacheSTAFrame() in WLANTL_RxFrames(),
1159 either WLANTL_RegisterSTAClient() or this function must be called
1160 within reasonable time. Otherwise, TL will keep cached vos buffer until
1161 one of this function is called, and may end up with system buffer exhasution.
1162
1163 It's an upper layer's responsibility to call this function in case of
1164 flushing
1165
1166============================================================================*/
1167
1168VOS_STATUS
1169WLANTL_StartForwarding
1170(
1171 v_U8_t ucSTAId,
1172 v_U8_t ucUcastSig,
1173 v_U8_t ucBcastSig
1174)
1175{
1176 vos_msg_t sMessage;
1177 v_U32_t uData;
1178 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
1179
1180 /* Signal the OS to serialize our event */
1181 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
1182 "Serializing TL Start Forwarding Cached for control STA %d",
1183 ucSTAId );
1184
1185 vos_mem_zero( &sMessage, sizeof(vos_msg_t) );
1186
1187 uData = ucSTAId | (ucUcastSig << 8 ) | (ucBcastSig << 16);
Jeff Johnsond86c05a2013-11-10 18:50:34 -08001188 sMessage.bodyval = uData;
Katya Nigam664f5032014-05-05 12:24:32 +05301189 sMessage.type = WLANTL_RX_FWD_CACHED;
Jeff Johnson295189b2012-06-20 16:38:30 -07001190
Katya Nigam664f5032014-05-05 12:24:32 +05301191 return vos_rx_mq_serialize(VOS_MQ_ID_TL, &sMessage);
Jeff Johnson295189b2012-06-20 16:38:30 -07001192
1193} /* WLANTL_StartForwarding() */
1194
1195/*===========================================================================
1196
Katya Nigam63902932014-06-26 19:04:23 +05301197 FUNCTION WLANTL_EnableCaching
1198
1199 DESCRIPTION
1200
1201 This function is used to enable caching only when assoc/reassoc req is send.
1202 that is cache packets only for such STA ID.
1203
1204
1205 DEPENDENCIES
1206
1207 TL must have been initialized before this gets called.
1208
1209
1210 PARAMETERS
1211
1212 staId: station id
1213
1214 RETURN VALUE
1215
1216 none
1217
1218============================================================================*/
1219void WLANTL_EnableCaching(v_U8_t staId)
1220{
1221 v_PVOID_t pvosGCtx= vos_get_global_context(VOS_MODULE_ID_TL,NULL);
1222 WLANTL_CbType* pTLCb = VOS_GET_TL_CB(pvosGCtx);
1223 if ( NULL == pTLCb )
1224 {
1225 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1226 "WLAN TL:Invalid TL pointer from pvosGCtx on "
1227 "WLANTL_EnableCaching"));
1228 return;
1229 }
1230 pTLCb->atlSTAClients[staId]->enableCaching = 1;
1231}
1232
1233/*===========================================================================
1234
Jeff Johnson295189b2012-06-20 16:38:30 -07001235 FUNCTION WLANTL_AssocFailed
1236
1237 DESCRIPTION
1238
1239 This function is used by PE to notify TL that cache needs to flushed'
1240 when association is not successfully completed
1241
1242 Internally, TL post a message to TX_Thread to serialize the request to
1243 keep lock-free mechanism.
1244
1245
1246 DEPENDENCIES
1247
1248 TL must have been initialized before this gets called.
1249
1250
1251 PARAMETERS
1252
1253 ucSTAId: station id
1254
1255 RETURN VALUE
1256
1257 none
1258
1259 SIDE EFFECTS
1260 There may be race condition that PE call this API and send another association
1261 request immediately with same staId before TX_thread can process the message.
1262
1263 To avoid this, we might need PE to wait for TX_thread process the message,
1264 but this is not currently implemented.
1265
1266============================================================================*/
1267void WLANTL_AssocFailed(v_U8_t staId)
1268{
1269 // flushing frames and forwarding frames uses the same message
1270 // the only difference is what happens when the message is processed
1271 // if the STA exist, the frames will be forwarded
1272 // and if it doesn't exist, the frames will be flushed
1273 // 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 +05301274 MTRACE(vos_trace(VOS_MODULE_ID_TL, TRACE_CODE_TL_ASSOC_FAILED,
1275 staId, 0));
1276
Jeff Johnson295189b2012-06-20 16:38:30 -07001277 if(!VOS_IS_STATUS_SUCCESS(WLANTL_StartForwarding(staId,0,0)))
1278 {
1279 VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Mihir Sheteb7337272014-04-11 15:53:08 +05301280 " %s fails to start forwarding (staId %d)", __func__, staId);
Jeff Johnson295189b2012-06-20 16:38:30 -07001281 }
1282}
Nirav Shah4f765af2015-01-21 19:51:30 +05301283
Nirav Shah4b53d4b2015-05-08 05:35:00 -07001284 /*===========================================================================
Jeff Johnson295189b2012-06-20 16:38:30 -07001285
1286 FUNCTION WLANTL_Finish_ULA
1287
1288 DESCRIPTION
1289 This function is used by HDD to notify TL to finish Upper layer authentication
1290 incase the last EAPOL packet is pending in the TL queue.
1291 To avoid the race condition between sme set key and the last EAPOL packet
1292 the HDD module calls this function just before calling the sme_RoamSetKey.
1293
1294 DEPENDENCIES
1295
1296 TL must have been initialized before this gets called.
Nirav Shah4f765af2015-01-21 19:51:30 +05301297
Jeff Johnson295189b2012-06-20 16:38:30 -07001298 PARAMETERS
1299
Nirav Shah4b53d4b2015-05-08 05:35:00 -07001300 callbackRoutine: HDD Callback function.
1301 callbackContext : HDD userdata context.
Nirav Shah4f765af2015-01-21 19:51:30 +05301302
Jeff Johnson295189b2012-06-20 16:38:30 -07001303 RETURN VALUE
1304
1305 VOS_STATUS_SUCCESS/VOS_STATUS_FAILURE
Nirav Shah4f765af2015-01-21 19:51:30 +05301306
Jeff Johnson295189b2012-06-20 16:38:30 -07001307 SIDE EFFECTS
Nirav Shah4f765af2015-01-21 19:51:30 +05301308
Jeff Johnson295189b2012-06-20 16:38:30 -07001309============================================================================*/
1310
1311VOS_STATUS WLANTL_Finish_ULA( void (*callbackRoutine) (void *callbackContext),
Nirav Shah4b53d4b2015-05-08 05:35:00 -07001312 void *callbackContext)
Jeff Johnson295189b2012-06-20 16:38:30 -07001313{
Nirav Shah4b53d4b2015-05-08 05:35:00 -07001314 return WDA_DS_FinishULA( callbackRoutine, callbackContext);
Nirav Shah4f765af2015-01-21 19:51:30 +05301315}
Jeff Johnson295189b2012-06-20 16:38:30 -07001316
Nirav Shah4b53d4b2015-05-08 05:35:00 -07001317
Jeff Johnson295189b2012-06-20 16:38:30 -07001318/*===========================================================================
1319
1320 FUNCTION WLANTL_RegisterSTAClient
1321
1322 DESCRIPTION
1323
1324 This function is used by HDD to register as a client for data services
1325 with TL. HDD will call this API for each new station that it adds,
1326 thus having the flexibility of registering different callback for each
1327 STA it services.
1328
1329 DEPENDENCIES
1330
1331 TL must have been initialized before this gets called.
1332
1333 Restriction:
1334 Main thread will have higher priority that Tx and Rx threads thus
1335 guaranteeing that a station will be added before any data can be
1336 received for it. (This enables TL to be lock free)
1337
1338 PARAMETERS
1339
1340 pvosGCtx: pointer to the global vos context; a handle to TL's
1341 control block can be extracted from its context
1342 pfnStARx: function pointer to the receive packet handler from HDD
1343 pfnSTATxComp: function pointer to the transmit complete confirmation
1344 handler from HDD
1345 pfnSTAFetchPkt: function pointer to the packet retrieval routine in HDD
1346 wSTADescType: STA Descriptor, contains information related to the
1347 new added STA
1348
1349 RETURN VALUE
1350
1351 The result code associated with performing the operation
1352
1353 VOS_STATUS_E_INVAL: Input parameters are invalid
1354 VOS_STATUS_E_FAULT: Station ID is outside array boundaries or pointer to
1355 TL cb is NULL ; access would cause a page fault
1356 VOS_STATUS_E_EXISTS: Station was already registered
1357 VOS_STATUS_SUCCESS: Everything is good :)
1358
1359 SIDE EFFECTS
1360
1361============================================================================*/
1362VOS_STATUS
1363WLANTL_RegisterSTAClient
1364(
1365 v_PVOID_t pvosGCtx,
1366 WLANTL_STARxCBType pfnSTARx,
1367 WLANTL_TxCompCBType pfnSTATxComp,
1368 WLANTL_STAFetchPktCBType pfnSTAFetchPkt,
1369 WLAN_STADescType* pwSTADescType,
1370 v_S7_t rssi
1371)
1372{
1373 WLANTL_CbType* pTLCb = NULL;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301374 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07001375 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 +05301376 v_U32_t istoggleArpEnb = 0;
1377 tpAniSirGlobal pMac;
Jeff Johnson295189b2012-06-20 16:38:30 -07001378 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
1379
1380 /*------------------------------------------------------------------------
1381 Sanity check
1382 ------------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301383 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -07001384 if (( NULL == pwSTADescType ) || ( NULL == pfnSTARx ) ||
1385 ( NULL == pfnSTAFetchPkt ))
1386 {
1387 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1388 "WLAN TL:Invalid parameter sent on WLANTL_RegisterSTAClient"));
1389 return VOS_STATUS_E_INVAL;
1390 }
1391
1392 if ( WLANTL_STA_ID_INVALID( pwSTADescType->ucSTAId ) )
1393 {
1394 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1395 "WLAN TL:Invalid station id requested on WLANTL_RegisterSTAClient"));
1396 return VOS_STATUS_E_FAULT;
1397 }
1398
1399 /*------------------------------------------------------------------------
1400 Extract TL control block
1401 ------------------------------------------------------------------------*/
1402 pTLCb = VOS_GET_TL_CB(pvosGCtx);
1403 if ( NULL == pTLCb )
1404 {
1405 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1406 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_RegisterSTAClient"));
1407 return VOS_STATUS_E_FAULT;
1408 }
1409
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301410 //Code for checking and allocating memory for new STA
1411 if ( NULL == pTLCb->atlSTAClients[pwSTADescType->ucSTAId] ){
1412 pTLCb->atlSTAClients[pwSTADescType->ucSTAId] = vos_mem_malloc(sizeof(WLANTL_STAClientType));
1413 if ( NULL == pTLCb->atlSTAClients[pwSTADescType->ucSTAId] ){
1414 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1415 "WLAN TL: STA Client memory allocation failed in WLANTL_RegisterSTAClient"));
1416 return VOS_STATUS_E_FAILURE;
1417 }
1418 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
1419 "WLAN TL: STA Client memory allocation in WLANTL_RegisterSTAClient"));
1420 vos_mem_zero((v_VOID_t *) pTLCb->atlSTAClients[pwSTADescType->ucSTAId],sizeof(WLANTL_STAClientType));
1421 }
1422
1423 //Assigning the pointer to local variable for easy access in future
1424 pClientSTA = pTLCb->atlSTAClients[pwSTADescType->ucSTAId];
1425 if ( 0 != pClientSTA->ucExists )
Jeff Johnson295189b2012-06-20 16:38:30 -07001426 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301427 pClientSTA->ucExists++;
Jeff Johnson295189b2012-06-20 16:38:30 -07001428 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1429 "WLAN TL:Station was already registered on WLANTL_RegisterSTAClient"));
1430 return VOS_STATUS_E_EXISTS;
1431 }
1432
1433 /*------------------------------------------------------------------------
1434 Register station with TL
1435 ------------------------------------------------------------------------*/
Katya Nigam42e16e82014-02-04 16:28:55 +05301436 MTRACE(vos_trace(VOS_MODULE_ID_TL, TRACE_CODE_TL_REGISTER_STA_CLIENT,
1437 pwSTADescType->ucSTAId, (unsigned )
1438 (*(pwSTADescType->vSTAMACAddress.bytes+2)<<24 |
1439 *(pwSTADescType->vSTAMACAddress.bytes+3)<<16 |
1440 *(pwSTADescType->vSTAMACAddress.bytes+4)<<8 |
1441 *(pwSTADescType->vSTAMACAddress.bytes+5))));
1442
Jeff Johnson295189b2012-06-20 16:38:30 -07001443 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
1444 "WLAN TL:Registering STA Client ID: %d", pwSTADescType->ucSTAId ));
1445
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301446 pClientSTA->pfnSTARx = pfnSTARx;
1447 pClientSTA->pfnSTAFetchPkt = pfnSTAFetchPkt;
Jeff Johnson295189b2012-06-20 16:38:30 -07001448
1449 /* Only register if different from NULL - TL default Tx Comp Cb will
1450 release the vos packet */
1451 if ( NULL != pfnSTATxComp )
1452 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301453 pClientSTA->pfnSTATxComp = pfnSTATxComp;
Jeff Johnson295189b2012-06-20 16:38:30 -07001454 }
1455
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301456 pClientSTA->tlState = WLANTL_STA_INIT;
1457 pClientSTA->tlPri = WLANTL_STA_PRI_NORMAL;
1458 pClientSTA->wSTADesc.ucSTAId = pwSTADescType->ucSTAId;
Gopichand Nakkala8b54e912013-03-11 10:44:21 +05301459 pClientSTA->ptkInstalled = 0;
Bhargav Shahfbaeca22016-07-13 10:27:35 +05301460 pClientSTA->disassoc_progress = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001461
Hanumantha Reddy Pothulaee001fc2015-05-26 15:21:53 +05301462 pMac = vos_get_context(VOS_MODULE_ID_PE, pvosGCtx);
1463 if ( NULL != pMac )
1464 {
1465 wlan_cfgGetInt(pMac, WNI_CFG_TOGGLE_ARP_BDRATES, &istoggleArpEnb);
1466 }
Hanumantha Reddy Pothulae5ab23d2015-09-14 18:08:24 +05301467 pClientSTA->arpRate = istoggleArpEnb ? ENABLE_ARP_TOGGLE : DISABLE_ARP_TOGGLE;
1468 pClientSTA->arpOnWQ5 = istoggleArpEnb == SEND_ARP_ON_WQ5;
Hanumantha Reddy Pothulaee001fc2015-05-26 15:21:53 +05301469
Jeff Johnson295189b2012-06-20 16:38:30 -07001470 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
Hanumantha Reddy Pothulaee001fc2015-05-26 15:21:53 +05301471 "WLAN TL:Registering STA Client ID: %d with UC %d and BC %d toggleArp :%hhu",
1472 pwSTADescType->ucSTAId, pwSTADescType->ucUcastSig,
1473 pwSTADescType->ucBcastSig, pClientSTA->arpRate));
Jeff Johnson295189b2012-06-20 16:38:30 -07001474
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301475 pClientSTA->wSTADesc.wSTAType = pwSTADescType->wSTAType;
Jeff Johnson295189b2012-06-20 16:38:30 -07001476
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301477 pClientSTA->wSTADesc.ucQosEnabled = pwSTADescType->ucQosEnabled;
Jeff Johnson295189b2012-06-20 16:38:30 -07001478
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301479 pClientSTA->wSTADesc.ucAddRmvLLC = pwSTADescType->ucAddRmvLLC;
Jeff Johnson295189b2012-06-20 16:38:30 -07001480
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301481 pClientSTA->wSTADesc.ucProtectedFrame = pwSTADescType->ucProtectedFrame;
Jeff Johnson295189b2012-06-20 16:38:30 -07001482
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001483#ifdef FEATURE_WLAN_ESE
1484 pClientSTA->wSTADesc.ucIsEseSta = pwSTADescType->ucIsEseSta;
Jeff Johnson295189b2012-06-20 16:38:30 -07001485
1486 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001487 "WLAN TL:Registering STA Client ID: %d QoS %d Add LLC %d ProtFrame %d EseSta %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07001488 pwSTADescType->ucSTAId,
1489 pwSTADescType->ucQosEnabled,
1490 pwSTADescType->ucAddRmvLLC,
1491 pwSTADescType->ucProtectedFrame,
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001492 pwSTADescType->ucIsEseSta));
Jeff Johnson295189b2012-06-20 16:38:30 -07001493#else
1494
1495 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
1496 "WLAN TL:Registering STA Client ID: %d QoS %d Add LLC %d ProtFrame %d",
1497 pwSTADescType->ucSTAId,
1498 pwSTADescType->ucQosEnabled,
1499 pwSTADescType->ucAddRmvLLC,
1500 pwSTADescType->ucProtectedFrame));
1501
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001502#endif //FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07001503#ifdef WLAN_SOFTAP_VSTA_FEATURE
1504 // if this station was not allocated resources to perform HW-based
1505 // TX frame translation then force SW-based TX frame translation
1506 // otherwise use the frame translation supplied by the client
1507
1508 if (!WDA_IsHwFrameTxTranslationCapable(pvosGCtx, pwSTADescType->ucSTAId)
1509 || ( WLAN_STA_BT_AMP == pwSTADescType->wSTAType))
1510 {
1511 pwSTADescType->ucSwFrameTXXlation = 1;
1512 }
1513#endif
1514
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301515 pClientSTA->wSTADesc.ucSwFrameTXXlation = pwSTADescType->ucSwFrameTXXlation;
1516 pClientSTA->wSTADesc.ucSwFrameRXXlation = pwSTADescType->ucSwFrameRXXlation;
Jeff Johnson295189b2012-06-20 16:38:30 -07001517
1518#ifdef FEATURE_WLAN_WAPI
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301519 pClientSTA->wSTADesc.ucIsWapiSta = pwSTADescType->ucIsWapiSta;
Jeff Johnson295189b2012-06-20 16:38:30 -07001520#endif /* FEATURE_WLAN_WAPI */
1521
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301522 vos_copy_macaddr( &pClientSTA->wSTADesc.vSTAMACAddress, &pwSTADescType->vSTAMACAddress);
Jeff Johnson295189b2012-06-20 16:38:30 -07001523
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301524 vos_copy_macaddr( &pClientSTA->wSTADesc.vBSSIDforIBSS, &pwSTADescType->vBSSIDforIBSS);
Jeff Johnson295189b2012-06-20 16:38:30 -07001525
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301526 vos_copy_macaddr( &pClientSTA->wSTADesc.vSelfMACAddress, &pwSTADescType->vSelfMACAddress);
Jeff Johnson295189b2012-06-20 16:38:30 -07001527
Jeff Johnson295189b2012-06-20 16:38:30 -07001528 /* In volans release L replay check is done at TL */
Sravan Kumar Kairam56bb37a2017-12-29 17:15:19 +05301529 if (pTLCb->tlConfigInfo.ucIsReplayCheck)
1530 pClientSTA->ucIsReplayCheckValid = pwSTADescType->ucIsReplayCheckValid;
1531
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301532 pClientSTA->ulTotalReplayPacketsDetected = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001533/*Clear replay counters of the STA on all TIDs*/
1534 for(ucTid = 0; ucTid < WLANTL_MAX_TID ; ucTid++)
1535 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301536 pClientSTA->ullReplayCounter[ucTid] = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001537 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001538
1539 /*--------------------------------------------------------------------
1540 Set the AC for the registered station to the highest priority AC
1541 Even if this AC is not supported by the station, correction will be
1542 made in the main TL loop after the supported mask is properly
1543 updated in the pending packets call
1544 --------------------------------------------------------------------*/
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05301545 pClientSTA->ucCurrentAC = WLANTL_AC_HIGH_PRIO;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301546 pClientSTA->ucCurrentWeight = 0;
1547 pClientSTA->ucServicedAC = WLANTL_AC_BK;
1548 pClientSTA->ucEapolPktPending = 0;
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -07001549
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301550 vos_mem_zero( pClientSTA->aucACMask, sizeof(pClientSTA->aucACMask));
Jeff Johnson295189b2012-06-20 16:38:30 -07001551
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301552 vos_mem_zero( &pClientSTA->wUAPSDInfo, sizeof(pClientSTA->wUAPSDInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -07001553
1554 /*--------------------------------------------------------------------
1555 Reordering info and AMSDU de-aggregation
1556 --------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301557 vos_mem_zero( pClientSTA->atlBAReorderInfo,
1558 sizeof(pClientSTA->atlBAReorderInfo[0])*
Jeff Johnson295189b2012-06-20 16:38:30 -07001559 WLAN_MAX_TID);
1560
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301561 vos_mem_zero( pClientSTA->aucMPDUHeader,
Jeff Johnson295189b2012-06-20 16:38:30 -07001562 WLANTL_MPDU_HEADER_LEN);
1563
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301564 pClientSTA->ucMPDUHeaderLen = 0;
1565 pClientSTA->vosAMSDUChain = NULL;
1566 pClientSTA->vosAMSDUChainRoot = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07001567
1568
Leo Chang6b6faaf2014-01-24 21:21:26 -08001569 /* Reorder LOCK
1570 * During handle normal RX frame within RX thread,
1571 * if MC thread try to preempt, ADDBA, DELBA, TIMER
1572 * Context should be protected from race */
1573 for (ucTid = 0; ucTid < WLAN_MAX_TID ; ucTid++)
1574 {
1575 if (!VOS_IS_STATUS_SUCCESS(
1576 vos_lock_init(&pClientSTA->atlBAReorderInfo[ucTid].reorderLock)))
1577 {
1578 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1579 "Lock Init Fail"));
1580 return VOS_STATUS_E_FAILURE;
1581 }
1582 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001583 /*--------------------------------------------------------------------
1584 Stats info
1585 --------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301586 vos_mem_zero( pClientSTA->auRxCount,
1587 sizeof(pClientSTA->auRxCount[0])*
Jeff Johnson295189b2012-06-20 16:38:30 -07001588 WLAN_MAX_TID);
1589
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301590 vos_mem_zero( pClientSTA->auTxCount,
1591 sizeof(pClientSTA->auRxCount[0])*
Jeff Johnson295189b2012-06-20 16:38:30 -07001592 WLAN_MAX_TID);
1593 /* Initial RSSI is always reported as zero because TL doesnt have enough
1594 data to calculate RSSI. So to avoid reporting zero, we are initializing
1595 RSSI with RSSI saved in BssDescription during scanning. */
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301596 pClientSTA->rssiAvg = rssi;
Bhargav Shah0b23d202015-07-10 17:14:34 +05301597 pClientSTA->rssiAvgBmps = rssi;
Shailender Karmuchi13c0d082013-03-26 14:41:39 -07001598#ifdef FEATURE_WLAN_TDLS
1599 if(WLAN_STA_TDLS == pClientSTA->wSTADesc.wSTAType)
1600 {
1601 /* If client is TDLS, use TDLS specific alpha */
1602 pClientSTA->rssiAlpha = WLANTL_HO_TDLS_ALPHA;
1603 }
1604 else
1605 {
1606 pClientSTA->rssiAlpha = WLANTL_HO_DEFAULT_ALPHA;
1607 }
1608#else
1609 pClientSTA->rssiAlpha = WLANTL_HO_DEFAULT_ALPHA;
1610#endif /* FEATURE_WLAN_TDLS */
Dino Mycle3b9536d2014-07-09 22:05:24 +05301611#ifdef WLAN_FEATURE_LINK_LAYER_STATS
1612 pClientSTA->rssiDataAlpha = WLANTL_HO_DEFAULT_ALPHA;
1613 pClientSTA->interfaceStats.accessCategoryStats[0].ac = WLANTL_AC_BK;
1614 pClientSTA->interfaceStats.accessCategoryStats[1].ac = WLANTL_AC_BE;
1615 pClientSTA->interfaceStats.accessCategoryStats[2].ac = WLANTL_AC_VI;
1616 pClientSTA->interfaceStats.accessCategoryStats[3].ac = WLANTL_AC_VO;
1617#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001618
1619 /*Tx not suspended and station fully registered*/
1620 vos_atomic_set_U8(
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301621 &pClientSTA->ucTxSuspended, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07001622
1623 /* Used until multiple station support will be added*/
1624 pTLCb->ucRegisteredStaId = pwSTADescType->ucSTAId;
1625
1626 /* Save the BAP station ID for future usage */
1627 if ( WLAN_STA_BT_AMP == pwSTADescType->wSTAType )
1628 {
1629 pTLCb->tlBAPClient.ucBAPSTAId = pwSTADescType->ucSTAId;
1630 }
1631
1632 /*------------------------------------------------------------------------
1633 Statistics info
1634 -----------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301635 memset(&pClientSTA->trafficStatistics,
Jeff Johnson295189b2012-06-20 16:38:30 -07001636 0, sizeof(WLANTL_TRANSFER_STA_TYPE));
1637
1638
1639 /*------------------------------------------------------------------------
1640 Start with the state suggested by client caller
1641 -----------------------------------------------------------------------*/
Madan Mohan Koyylamudi64258222013-01-30 14:35:10 +05301642 pClientSTA->tlState = pwSTADescType->ucInitState;
Jeff Johnson295189b2012-06-20 16:38:30 -07001643 /*-----------------------------------------------------------------------
1644 After all the init is complete we can mark the existance flag
1645 ----------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301646 pClientSTA->ucExists++;
Jeff Johnson295189b2012-06-20 16:38:30 -07001647
Jeff Johnson295189b2012-06-20 16:38:30 -07001648 //flow control fields init
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301649 pClientSTA->ucLwmModeEnabled = FALSE;
1650 pClientSTA->ucLwmEventReported = FALSE;
1651 pClientSTA->bmuMemConsumed = 0;
1652 pClientSTA->uIngress_length = 0;
1653 pClientSTA->uBuffThresholdMax = WLANTL_STA_BMU_THRESHOLD_MAX;
Jeff Johnson295189b2012-06-20 16:38:30 -07001654
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301655 pClientSTA->uLwmThreshold = WLANTL_STA_BMU_THRESHOLD_MAX / 3;
Jeff Johnson295189b2012-06-20 16:38:30 -07001656
1657 //@@@ HDDSOFTAP does not queue unregistered packet for now
1658 if ( WLAN_STA_SOFTAP != pwSTADescType->wSTAType )
1659 {
Jeff Johnson295189b2012-06-20 16:38:30 -07001660 /*------------------------------------------------------------------------
1661 Forward received frames while STA was not yet registered
1662 - ----------------------------------------------------------------------*/
1663 if(!VOS_IS_STATUS_SUCCESS(WLANTL_StartForwarding( pwSTADescType->ucSTAId,
1664 pwSTADescType->ucUcastSig,
1665 pwSTADescType->ucBcastSig)))
1666 {
1667 VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001668 " %s fails to start forwarding", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001669 }
Sunil Ravid5406f22013-01-22 00:18:31 -08001670#ifdef FEATURE_WLAN_TDLS
1671 if( WLAN_STA_TDLS == pwSTADescType->wSTAType )
1672 pTLCb->ucTdlsPeerCount++;
1673#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001674 }
Abhishek Singh00b71972016-01-07 10:51:04 +05301675#ifdef WLAN_FEATURE_RMC
1676 vos_lock_init(&pClientSTA->mcLock);
1677#endif /* WLAN_FEATURE_RMC */
1678
Jeff Johnson295189b2012-06-20 16:38:30 -07001679 return VOS_STATUS_SUCCESS;
1680}/* WLANTL_RegisterSTAClient */
1681
1682/*===========================================================================
1683
1684 FUNCTION WLANTL_ClearSTAClient
1685
1686 DESCRIPTION
1687
1688 HDD will call this API when it no longer needs data services for the
1689 particular station.
1690
1691 DEPENDENCIES
1692
1693 A station must have been registered before the clear registration is
1694 called.
1695
1696 PARAMETERS
1697
1698 pvosGCtx: pointer to the global vos context; a handle to TL's
1699 control block can be extracted from its context
1700 ucSTAId: identifier for the STA to be cleared
1701
1702 RETURN VALUE
1703
1704 The result code associated with performing the operation
1705
1706 VOS_STATUS_E_FAULT: Station ID is outside array boundaries or pointer to
1707 TL cb is NULL ; access would cause a page fault
1708 VOS_STATUS_E_EXISTS: Station was not registered
1709 VOS_STATUS_SUCCESS: Everything is good :)
1710
1711 SIDE EFFECTS
1712
1713============================================================================*/
1714VOS_STATUS
1715WLANTL_ClearSTAClient
1716(
1717 v_PVOID_t pvosGCtx,
1718 v_U8_t ucSTAId
1719)
1720{
1721 WLANTL_CbType* pTLCb = NULL;
1722 v_U8_t ucIndex;
1723 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
1724
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301725 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -07001726 /*------------------------------------------------------------------------
1727 Sanity check
1728 ------------------------------------------------------------------------*/
1729 if ( WLANTL_STA_ID_INVALID( ucSTAId ) )
1730 {
1731 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1732 "WLAN TL:Invalid station id requested on WLANTL_ClearSTAClient"));
1733 return VOS_STATUS_E_FAULT;
1734 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001735 /*------------------------------------------------------------------------
1736 Extract TL control block
1737 ------------------------------------------------------------------------*/
1738 pTLCb = VOS_GET_TL_CB(pvosGCtx);
1739 if ( NULL == pTLCb )
1740 {
1741 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1742 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_ClearSTAClient"));
1743 return VOS_STATUS_E_FAULT;
1744 }
1745
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301746 if ( NULL == pTLCb->atlSTAClients[ucSTAId] )
1747 {
1748 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1749 "WLAN TL:Client Memory was not allocated on %s", __func__));
1750 return VOS_STATUS_E_FAILURE;
1751 }
1752
1753 if ( 0 == pTLCb->atlSTAClients[ucSTAId]->ucExists )
Jeff Johnson295189b2012-06-20 16:38:30 -07001754 {
1755 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1756 "WLAN TL:Station was not previously registered on WLANTL_ClearSTAClient"));
Siddharth Bhalaef8ee12014-04-02 00:09:45 +05301757 /* Clean packets cached for the STA */
1758 WLANTL_StartForwarding(ucSTAId,0,0);
Jeff Johnson295189b2012-06-20 16:38:30 -07001759 return VOS_STATUS_E_EXISTS;
1760 }
1761
1762 /* Delete BA sessions on all TID's */
Leo Chang6b6faaf2014-01-24 21:21:26 -08001763 for (ucIndex = 0; ucIndex < WLAN_MAX_TID ; ucIndex++)
Jeff Johnson295189b2012-06-20 16:38:30 -07001764 {
Leo Chang6b6faaf2014-01-24 21:21:26 -08001765 WLANTL_BaSessionDel(pvosGCtx, ucSTAId, ucIndex);
1766 vos_lock_destroy(&pTLCb->atlSTAClients[ucSTAId]->atlBAReorderInfo[ucIndex].reorderLock);
Jeff Johnson295189b2012-06-20 16:38:30 -07001767 }
1768
Sunil Ravid5406f22013-01-22 00:18:31 -08001769#ifdef FEATURE_WLAN_TDLS
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301770 /* decrement ucTdlsPeerCount only if it is non-zero */
1771 if(WLAN_STA_TDLS == pTLCb->atlSTAClients[ucSTAId]->wSTADesc.wSTAType
Sunil Ravid5406f22013-01-22 00:18:31 -08001772 && pTLCb->ucTdlsPeerCount)
1773 pTLCb->ucTdlsPeerCount--;
1774#endif
1775
Jeff Johnson295189b2012-06-20 16:38:30 -07001776 /*------------------------------------------------------------------------
1777 Clear station
1778 ------------------------------------------------------------------------*/
1779 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
1780 "WLAN TL:Clearing STA Client ID: %d", ucSTAId ));
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301781 WLANTL_CleanSTA(pTLCb->atlSTAClients[ucSTAId], 1 /*empty packets*/);
Jeff Johnson295189b2012-06-20 16:38:30 -07001782
Abhishek Singh00b71972016-01-07 10:51:04 +05301783#ifdef WLAN_FEATURE_RMC
1784 /*--------------------------------------------------------------------
1785 Delete multicast entries for duplicate detection
1786 --------------------------------------------------------------------*/
1787 WLANTL_McastDeleteAllEntries(pTLCb->atlSTAClients[ucSTAId]);
1788
1789 vos_lock_destroy(&pTLCb->atlSTAClients[ucSTAId]->mcLock);
1790#endif /* WLAN_FEATURE_RMC */
1791
Jeff Johnson295189b2012-06-20 16:38:30 -07001792 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
1793 "WLAN TL:Clearing STA Reset History RSSI and Region number"));
1794 pTLCb->hoSupport.currentHOState.historyRSSI = 0;
1795 pTLCb->hoSupport.currentHOState.regionNumber = 0;
1796
1797 return VOS_STATUS_SUCCESS;
1798}/* WLANTL_ClearSTAClient */
1799
1800/*===========================================================================
1801
1802 FUNCTION WLANTL_ChangeSTAState
1803
1804 DESCRIPTION
1805
1806 HDD will make this notification whenever a change occurs in the
1807 connectivity state of a particular STA.
1808
1809 DEPENDENCIES
1810
1811 A station must have been registered before the change state can be
1812 called.
1813
1814 RESTRICTION: A station is being notified as authenticated before the
1815 keys are installed in HW. This way if a frame is received
1816 before the keys are installed DPU will drop that frame.
1817
1818 Main thread has higher priority that Tx and Rx threads thus guaranteeing
1819 the following:
1820 - a station will be in assoc state in TL before TL receives any data
1821 for it
1822
1823 PARAMETERS
1824
1825 pvosGCtx: pointer to the global vos context; a handle to TL's
1826 control block can be extracted from its context
1827 ucSTAId: identifier for the STA that is pending transmission
1828 tlSTAState: the new state of the connection to the given station
1829
1830
1831 RETURN VALUE
1832
1833 The result code associated with performing the operation
1834
1835 VOS_STATUS_E_INVAL: Input parameters are invalid
1836 VOS_STATUS_E_FAULT: Station ID is outside array boundaries or pointer to
1837 TL cb is NULL ; access would cause a page fault
1838 VOS_STATUS_E_EXISTS: Station was not registered
1839 VOS_STATUS_SUCCESS: Everything is good :)
1840
1841 SIDE EFFECTS
1842
1843============================================================================*/
1844VOS_STATUS
1845WLANTL_ChangeSTAState
1846(
1847 v_PVOID_t pvosGCtx,
1848 v_U8_t ucSTAId,
1849 WLANTL_STAStateType tlSTAState
1850)
1851{
1852 WLANTL_CbType* pTLCb = NULL;
1853 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
1854
1855 /*------------------------------------------------------------------------
1856 Sanity check
1857 ------------------------------------------------------------------------*/
1858 if ( tlSTAState >= WLANTL_STA_MAX_STATE )
1859 {
1860 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1861 "WLAN TL:Invalid parameter sent on WLANTL_ChangeSTAState"));
1862 return VOS_STATUS_E_INVAL;
1863 }
1864
1865 if ( WLANTL_STA_ID_INVALID( ucSTAId ) )
1866 {
1867 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1868 "WLAN TL:Invalid station id requested on WLANTL_ChangeSTAState"));
1869 return VOS_STATUS_E_FAULT;
1870 }
1871
1872 /*------------------------------------------------------------------------
1873 Extract TL control block and check existance
1874 ------------------------------------------------------------------------*/
1875 pTLCb = VOS_GET_TL_CB(pvosGCtx);
1876 if ( NULL == pTLCb )
1877 {
1878 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1879 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_ChangeSTAState"));
1880 return VOS_STATUS_E_FAULT;
1881 }
1882
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301883 if ( NULL == pTLCb->atlSTAClients[ucSTAId] )
1884 {
1885 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1886 "WLAN TL:Client Memory was not allocated on %s", __func__));
1887 return VOS_STATUS_E_FAILURE;
1888 }
1889
1890 if ( 0 == pTLCb->atlSTAClients[ucSTAId]->ucExists )
Jeff Johnson295189b2012-06-20 16:38:30 -07001891 {
1892 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1893 "WLAN TL:Station was not previously registered on WLANTL_ChangeSTAState"));
1894 return VOS_STATUS_E_EXISTS;
1895 }
1896
1897 /*------------------------------------------------------------------------
1898 Change STA state
1899 No need to lock this operation, see restrictions above
1900 ------------------------------------------------------------------------*/
1901 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
1902 "WLAN TL:Changing state for STA Client ID: %d from %d to %d",
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301903 ucSTAId, pTLCb->atlSTAClients[ucSTAId]->tlState, tlSTAState));
Jeff Johnson295189b2012-06-20 16:38:30 -07001904
Katya Nigam42e16e82014-02-04 16:28:55 +05301905 MTRACE(vos_trace(VOS_MODULE_ID_TL,
1906 TRACE_CODE_TL_STA_STATE, ucSTAId,tlSTAState ));
1907
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301908 pTLCb->atlSTAClients[ucSTAId]->tlState = tlSTAState;
Jeff Johnson295189b2012-06-20 16:38:30 -07001909
1910 return VOS_STATUS_SUCCESS;
1911}/* WLANTL_ChangeSTAState */
1912
1913/*===========================================================================
1914
Agarwal Ashish16020c42014-12-29 22:01:11 +05301915 FUNCTION WLANTL_UpdateTdlsSTAClient
1916
1917 DESCRIPTION
1918
1919 HDD will call this API when ENABLE_LINK happens and HDD want to
1920 register QoS or other params for TDLS peers.
1921
1922 DEPENDENCIES
1923
1924 A station must have been registered before the WMM/QOS registration is
1925 called.
1926
1927 PARAMETERS
1928
1929 pvosGCtx: pointer to the global vos context; a handle to TL's
1930 control block can be extracted from its context
1931 wSTADescType: STA Descriptor, contains information related to the
1932 new added STA
1933
1934 RETURN VALUE
1935
1936 The result code associated with performing the operation
1937
1938 VOS_STATUS_E_FAULT: Station ID is outside array boundaries or pointer to
1939 TL cb is NULL ; access would cause a page fault
1940 VOS_STATUS_E_EXISTS: Station was not registered
1941 VOS_STATUS_SUCCESS: Everything is good :)
1942
1943 SIDE EFFECTS
1944
1945============================================================================*/
1946
1947VOS_STATUS
1948WLANTL_UpdateTdlsSTAClient
1949(
1950 v_PVOID_t pvosGCtx,
1951 WLAN_STADescType* pwSTADescType
1952)
1953{
1954 WLANTL_CbType* pTLCb = NULL;
1955 WLANTL_STAClientType* pClientSTA = NULL;
1956 /*------------------------------------------------------------------------
1957 Extract TL control block
1958 ------------------------------------------------------------------------*/
1959 pTLCb = VOS_GET_TL_CB(pvosGCtx);
1960 if ( NULL == pTLCb || ( WLAN_MAX_STA_COUNT <= pwSTADescType->ucSTAId))
1961 {
1962 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1963 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_UpdateTdlsSTAClient"));
1964 return VOS_STATUS_E_FAULT;
1965 }
1966
1967 pClientSTA = pTLCb->atlSTAClients[pwSTADescType->ucSTAId];
1968 if ((NULL == pClientSTA) || 0 == pClientSTA->ucExists)
1969 {
1970 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1971 "WLAN TL:Station not exists"));
1972 return VOS_STATUS_E_FAILURE;
1973 }
1974
1975 pClientSTA->wSTADesc.ucQosEnabled = pwSTADescType->ucQosEnabled;
1976
Masti, Narayanraddic754cdc2015-12-24 18:22:36 +05301977 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
1978 "WLAN TL: %s: ucQosEnabled of pwSTADescType: %d"
1979 "pClientSTA->wSTADesc: %d",
1980 __func__, pwSTADescType->ucQosEnabled,
1981 pClientSTA->wSTADesc.ucQosEnabled));
1982
Agarwal Ashish16020c42014-12-29 22:01:11 +05301983 return VOS_STATUS_SUCCESS;
1984
1985}
1986
Katya Nigame7b69a82015-04-28 15:24:06 +05301987VOS_STATUS WLANTL_SetMonRxCbk(v_PVOID_t pvosGCtx, WLANTL_MonRxCBType pfnMonRx)
1988{
1989 WLANTL_CbType* pTLCb = NULL ;
1990 pTLCb = VOS_GET_TL_CB(pvosGCtx);
1991 if ( NULL == pTLCb )
1992 {
1993 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1994 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_RegisterSTAClient"));
1995 return VOS_STATUS_E_FAULT;
1996 }
1997 pTLCb->pfnMonRx = pfnMonRx;
1998 return VOS_STATUS_SUCCESS;
1999}
2000
2001void WLANTL_SetIsConversionReq(v_PVOID_t pvosGCtx, v_BOOL_t isConversionReq)
2002{
2003 WLANTL_CbType* pTLCb = NULL ;
2004 pTLCb = VOS_GET_TL_CB(pvosGCtx);
2005 if ( NULL == pTLCb )
2006 {
2007 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2008 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_RegisterSTAClient"));
2009 return;
2010 }
2011 pTLCb->isConversionReq = isConversionReq;
2012 return;
2013}
2014
Agarwal Ashish16020c42014-12-29 22:01:11 +05302015
2016/*===========================================================================
2017
Gopichand Nakkala8b54e912013-03-11 10:44:21 +05302018 FUNCTION WLANTL_STAPtkInstalled
2019
2020 DESCRIPTION
2021
2022 HDD will make this notification whenever PTK is installed for the STA
2023
2024 DEPENDENCIES
2025
2026 A station must have been registered before the change state can be
2027 called.
2028
2029 PARAMETERS
2030
2031 pvosGCtx: pointer to the global vos context; a handle to TL's
2032 control block can be extracted from its context
2033 ucSTAId: identifier for the STA for which Pairwise key is
2034 installed
2035
2036 RETURN VALUE
2037
2038 The result code associated with performing the operation
2039
2040 VOS_STATUS_E_FAULT: Station ID is outside array boundaries or pointer to
2041 TL cb is NULL ; access would cause a page fault
2042 VOS_STATUS_E_EXISTS: Station was not registered
2043 VOS_STATUS_SUCCESS: Everything is good :)
2044
2045 SIDE EFFECTS
2046
2047============================================================================*/
2048VOS_STATUS
2049WLANTL_STAPtkInstalled
2050(
2051 v_PVOID_t pvosGCtx,
2052 v_U8_t ucSTAId
2053)
2054{
2055 WLANTL_CbType* pTLCb = NULL;
2056 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
2057
2058 /*------------------------------------------------------------------------
2059 Sanity check
2060 ------------------------------------------------------------------------*/
2061
2062 if ( WLANTL_STA_ID_INVALID( ucSTAId ) )
2063 {
2064 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2065 "WLAN TL:Invalid station id requested on WLANTL_ChangeSTAState"));
2066 return VOS_STATUS_E_FAULT;
2067 }
2068
2069 /*------------------------------------------------------------------------
2070 Extract TL control block and check existance
2071 ------------------------------------------------------------------------*/
2072 pTLCb = VOS_GET_TL_CB(pvosGCtx);
2073 if ( NULL == pTLCb )
2074 {
2075 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2076 FL("WLAN TL:Invalid TL pointer from pvosGCtx")));
2077 return VOS_STATUS_E_FAULT;
2078 }
2079
2080 if ( NULL == pTLCb->atlSTAClients[ucSTAId] )
2081 {
2082 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2083 FL("WLAN TL:Client Memory was not allocated")));
2084 return VOS_STATUS_E_FAILURE;
2085 }
2086
2087 if ( 0 == pTLCb->atlSTAClients[ucSTAId]->ucExists )
2088 {
2089 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2090 FL("WLAN TL:Station was not previously registered")));
2091 return VOS_STATUS_E_EXISTS;
2092 }
2093
2094 pTLCb->atlSTAClients[ucSTAId]->ptkInstalled = 1;
2095
2096 return VOS_STATUS_SUCCESS;
2097}/* WLANTL_STAPtkInstalled */
2098
2099/*===========================================================================
2100
Madan Mohan Koyyalamudifc1d1fe2012-10-18 15:07:12 -07002101 FUNCTION WLANTL_GetSTAState
2102
2103 DESCRIPTION
2104
2105 Returns connectivity state of a particular STA.
2106
2107 DEPENDENCIES
2108
2109 A station must have been registered before its state can be retrieved.
2110
2111
2112 PARAMETERS
2113
2114 IN
2115 pvosGCtx: pointer to the global vos context; a handle to TL's
2116 control block can be extracted from its context
2117 ucSTAId: identifier of the station
2118
2119 OUT
2120 ptlSTAState: the current state of the connection to the given station
2121
2122
2123 RETURN VALUE
2124
2125 The result code associated with performing the operation
2126
2127 VOS_STATUS_E_INVAL: Input parameters are invalid
2128 VOS_STATUS_E_FAULT: Station ID is outside array boundaries or pointer to
2129 TL cb is NULL ; access would cause a page fault
2130 VOS_STATUS_E_EXISTS: Station was not registered
2131 VOS_STATUS_SUCCESS: Everything is good :)
2132
2133 SIDE EFFECTS
2134
2135============================================================================*/
2136VOS_STATUS
2137WLANTL_GetSTAState
2138(
2139 v_PVOID_t pvosGCtx,
2140 v_U8_t ucSTAId,
2141 WLANTL_STAStateType *ptlSTAState
2142)
2143{
2144 WLANTL_CbType* pTLCb = NULL;
2145 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
2146
2147 /*------------------------------------------------------------------------
2148 Sanity check
2149 ------------------------------------------------------------------------*/
2150 if ( NULL == ptlSTAState )
2151 {
2152 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2153 "WLAN TL:Invalid parameter sent on WLANTL_GetSTAState"));
2154 return VOS_STATUS_E_INVAL;
2155 }
2156
2157 if ( WLANTL_STA_ID_INVALID( ucSTAId ) )
2158 {
2159 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2160 "WLAN TL:Invalid station id requested on WLANTL_GetSTAState"));
2161 return VOS_STATUS_E_FAULT;
2162 }
2163
2164 /*------------------------------------------------------------------------
2165 Extract TL control block and check existance
2166 ------------------------------------------------------------------------*/
2167 pTLCb = VOS_GET_TL_CB(pvosGCtx);
2168 if ( NULL == pTLCb )
2169 {
2170 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2171 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_GetSTAState"));
2172 return VOS_STATUS_E_FAULT;
2173 }
2174
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302175 if ( NULL == pTLCb->atlSTAClients[ucSTAId] )
2176 {
2177 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2178 "WLAN TL:Client Memory was not allocated on %s", __func__));
2179 return VOS_STATUS_E_FAILURE;
2180 }
2181
2182 if ( 0 == pTLCb->atlSTAClients[ucSTAId]->ucExists )
Madan Mohan Koyyalamudifc1d1fe2012-10-18 15:07:12 -07002183 {
Sunil Ravid5406f22013-01-22 00:18:31 -08002184 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
Madan Mohan Koyyalamudifc1d1fe2012-10-18 15:07:12 -07002185 "WLAN TL:Station was not previously registered on WLANTL_GetSTAState"));
2186 return VOS_STATUS_E_EXISTS;
2187 }
2188
2189 /*------------------------------------------------------------------------
2190 Get STA state
2191 ------------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302192 *ptlSTAState = pTLCb->atlSTAClients[ucSTAId]->tlState;
Madan Mohan Koyyalamudifc1d1fe2012-10-18 15:07:12 -07002193
2194 return VOS_STATUS_SUCCESS;
2195}/* WLANTL_GetSTAState */
2196
Shailender Karmuchia734f332013-04-19 14:02:48 -07002197/*==========================================================================
2198 FUNCTION WLANTL_UpdateSTABssIdforIBSS
2199
2200 DESCRIPTION
2201 HDD will call this API to update the BSSID for this Station.
2202
2203 DEPENDENCIES
2204 The HDD Should registered the staID with TL before calling this function.
2205
2206 PARAMETERS
2207
2208 IN
2209 pvosGCtx: Pointer to the global vos context; a handle to TL's
2210 or WDA's control block can be extracted from its context
2211 IN
2212 ucSTAId The Station ID for Bssid to be updated
2213 IN
2214 pBssid BSSID to be updated
2215
2216 RETURN VALUE
2217 The result code associated with performing the operation
2218
2219 VOS_STATUS_E_INVAL: Input parameters are invalid
2220 VOS_STATUS_E_FAULT: Station ID is outside array boundaries or pointer to
2221 TL cb is NULL ; access would cause a page fault
2222 VOS_STATUS_E_EXISTS: Station was not registered
2223 VOS_STATUS_SUCCESS: Everything is good :)
2224
2225 SIDE EFFECTS
2226============================================================================*/
2227
2228
2229VOS_STATUS
2230WLANTL_UpdateSTABssIdforIBSS
2231(
2232 v_PVOID_t pvosGCtx,
2233 v_U8_t ucSTAId,
2234 v_U8_t *pBssid
2235)
2236{
2237 WLANTL_CbType* pTLCb = NULL;
2238 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
2239
2240 /*------------------------------------------------------------------------
2241 Sanity check
2242 ------------------------------------------------------------------------*/
2243 if ( WLANTL_STA_ID_INVALID( ucSTAId ) )
2244 {
2245 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2246 "WLAN TL:Invalid station id requested %s", __func__));
2247 return VOS_STATUS_E_FAULT;
2248 }
2249
2250 /*------------------------------------------------------------------------
2251 Extract TL control block and check existance
2252 ------------------------------------------------------------------------*/
2253 pTLCb = VOS_GET_TL_CB(pvosGCtx);
2254 if ( NULL == pTLCb )
2255 {
2256 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2257 "WLAN TL:Invalid TL pointer from pvosGCtx %s", __func__));
2258 return VOS_STATUS_E_FAULT;
2259 }
2260
2261 if ( NULL == pTLCb->atlSTAClients[ucSTAId] )
2262 {
2263 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2264 "WLAN TL:Client Memory was not allocated on %s", __func__));
2265 return VOS_STATUS_E_FAILURE;
2266 }
2267
2268 if ( 0 == pTLCb->atlSTAClients[ucSTAId]->ucExists )
2269 {
2270 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
2271 "WLAN TL:Station was not previously registered %s", __func__));
2272 return VOS_STATUS_E_EXISTS;
2273 }
2274
2275 /*------------------------------------------------------------------------
2276 Update the IBSS BSSID
2277 ------------------------------------------------------------------------*/
2278 vos_mem_copy( &pTLCb->atlSTAClients[ucSTAId]->wSTADesc.vBSSIDforIBSS,
2279 pBssid, sizeof(v_MACADDR_t));
2280
2281 return VOS_STATUS_SUCCESS;
2282}
2283
Madan Mohan Koyyalamudifc1d1fe2012-10-18 15:07:12 -07002284/*===========================================================================
2285
Jeff Johnson295189b2012-06-20 16:38:30 -07002286 FUNCTION WLANTL_STAPktPending
2287
2288 DESCRIPTION
2289
2290 HDD will call this API when a packet is pending transmission in its
2291 queues.
2292
2293 DEPENDENCIES
2294
2295 A station must have been registered before the packet pending
2296 notification can be sent.
2297
2298 RESTRICTION: TL will not count packets for pending notification.
2299 HDD is expected to send the notification only when
2300 non-empty event gets triggered. Worst case scenario
2301 is that TL might end up making a call when Hdds
2302 queues are actually empty.
2303
2304 PARAMETERS
2305
2306 pvosGCtx: pointer to the global vos context; a handle to TL's
2307 control block can be extracted from its context
2308 ucSTAId: identifier for the STA that is pending transmission
2309
2310 RETURN VALUE
2311
2312 The result code associated with performing the operation
2313
2314 VOS_STATUS_E_INVAL: Input parameters are invalid
2315 VOS_STATUS_E_FAULT: Station ID is outside array boundaries or pointer
2316 to TL cb is NULL ; access would cause a page fault
2317 VOS_STATUS_E_EXISTS: Station was not registered
2318 VOS_STATUS_SUCCESS: Everything is good :)
2319
2320 SIDE EFFECTS
2321
2322============================================================================*/
2323VOS_STATUS
2324WLANTL_STAPktPending
2325(
2326 v_PVOID_t pvosGCtx,
2327 v_U8_t ucSTAId,
2328 WLANTL_ACEnumType ucAc
2329)
2330{
2331 WLANTL_CbType* pTLCb = NULL;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302332 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002333 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
2334
2335 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
2336 "WLAN TL:Packet pending indication for STA: %d AC: %d", ucSTAId, ucAc);
2337
2338 /*------------------------------------------------------------------------
2339 Sanity check
2340 ------------------------------------------------------------------------*/
2341 if ( WLANTL_STA_ID_INVALID( ucSTAId ) )
2342 {
2343 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2344 "WLAN TL:Invalid station id requested on WLANTL_STAPktPending"));
2345 return VOS_STATUS_E_FAULT;
2346 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002347 /*------------------------------------------------------------------------
2348 Extract TL control block and check existance
2349 ------------------------------------------------------------------------*/
2350 pTLCb = VOS_GET_TL_CB(pvosGCtx);
2351 if ( NULL == pTLCb )
2352 {
2353 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2354 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_STAPktPending"));
2355 return VOS_STATUS_E_FAULT;
2356 }
2357
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302358 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
2359
2360 if ( NULL == pClientSTA )
2361 {
2362 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2363 "WLAN TL:Client Memory was not allocated on %s", __func__));
2364 return VOS_STATUS_E_FAILURE;
2365 }
2366
2367 if ( 0 == pClientSTA->ucExists )
Jeff Johnson295189b2012-06-20 16:38:30 -07002368 {
Katya Nigamb130d572014-11-24 16:38:16 +05302369 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07002370 "WLAN TL:Station was not previously registered on WLANTL_STAPktPending"));
2371 return VOS_STATUS_E_EXISTS;
2372 }
2373
2374 /*---------------------------------------------------------------------
2375 Temporary fix to enable TL to fetch packets when multiple peers join
2376 an IBSS. To fix CR177301. Needs to go away when the actual fix of
2377 going through all STA's in round robin fashion gets merged in from
2378 BT AMP branch.
2379 --------------------------------------------------------------------*/
2380 pTLCb->ucRegisteredStaId = ucSTAId;
2381
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302382 if( WLANTL_STA_CONNECTED == pClientSTA->tlState )
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -07002383 { /* EAPOL_HI_PRIORITY : need to find out whether EAPOL is pending before
2384 WLANTL_FetchPacket()/WLANTL_TxConn() is called.
2385 change STA_AUTHENTICATED != tlState to CONNECTED == tlState
2386 to make sure TL is indeed waiting for EAPOL.
2387 Just in the case when STA got disconnected shortly after connectection */
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302388 pClientSTA->ucEapolPktPending = 1;
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -07002389
Katya Nigam42e16e82014-02-04 16:28:55 +05302390 MTRACE(vos_trace(VOS_MODULE_ID_TL,
2391 TRACE_CODE_TL_EAPOL_PKT_PENDING, ucSTAId, ucAc));
2392
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -07002393 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07002394 "WLAN TL:Packet pending indication for STA: %d AC: %d State: %d",
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302395 ucSTAId, ucAc, pClientSTA->tlState);
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07002396 }
2397
Jeff Johnson295189b2012-06-20 16:38:30 -07002398 /*-----------------------------------------------------------------------
2399 Enable this AC in the AC mask in order for TL to start servicing it
2400 Set packet pending flag
2401 To avoid race condition, serialize the updation of AC and AC mask
2402 through WLANTL_TX_STAID_AC_IND message.
2403 -----------------------------------------------------------------------*/
Jeff Johnson295189b2012-06-20 16:38:30 -07002404
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302405 pClientSTA->aucACMask[ucAc] = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07002406
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302407 vos_atomic_set_U8( &pClientSTA->ucPktPending, 1);
Jeff Johnson295189b2012-06-20 16:38:30 -07002408
2409 /*------------------------------------------------------------------------
2410 Check if there are enough resources for transmission and tx is not
2411 suspended.
2412 ------------------------------------------------------------------------*/
Nirav Shah4b53d4b2015-05-08 05:35:00 -07002413 if (( pTLCb->uResCount >= WDA_TLI_MIN_RES_DATA ) &&
2414 ( 0 == pTLCb->ucTxSuspended ))
Jeff Johnson295189b2012-06-20 16:38:30 -07002415 {
Katya Nigam42e16e82014-02-04 16:28:55 +05302416
Jeff Johnson295189b2012-06-20 16:38:30 -07002417 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
2418 "Issuing Xmit start request to BAL"));
2419 WDA_DS_StartXmit(pvosGCtx);
2420 }
2421 else
2422 {
2423 /*---------------------------------------------------------------------
2424 No error code is sent because TL will resume tx autonomously if
2425 resources become available or tx gets resumed
2426 ---------------------------------------------------------------------*/
Madan Mohan Koyyalamudi179e6fe2012-10-15 15:31:08 -07002427 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
Jeff Johnson295189b2012-06-20 16:38:30 -07002428 "WLAN TL:Request to send but condition not met. Res: %d,Suspend: %d",
Madan Mohan Koyyalamudi48139e32012-10-11 14:43:56 -07002429 pTLCb->uResCount, pTLCb->ucTxSuspended );
Jeff Johnson295189b2012-06-20 16:38:30 -07002430 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002431 return VOS_STATUS_SUCCESS;
2432}/* WLANTL_STAPktPending */
2433
2434/*==========================================================================
2435
2436 FUNCTION WLANTL_SetSTAPriority
2437
2438 DESCRIPTION
2439
2440 TL exposes this API to allow upper layers a rough control over the
2441 priority of transmission for a given station when supporting multiple
2442 connections.
2443
2444 DEPENDENCIES
2445
2446 A station must have been registered before the change in priority can be
2447 called.
2448
2449 PARAMETERS
2450
2451 pvosGCtx: pointer to the global vos context; a handle to TL's
2452 control block can be extracted from its context
2453 ucSTAId: identifier for the STA that has to change priority
2454
2455 RETURN VALUE
2456
2457 The result code associated with performing the operation
2458
2459 VOS_STATUS_E_INVAL: Input parameters are invalid
2460 VOS_STATUS_E_FAULT: Station ID is outside array boundaries or pointer
2461 to TL cb is NULL ; access would cause a page fault
2462 VOS_STATUS_E_EXISTS: Station was not registered
2463 VOS_STATUS_SUCCESS: Everything is good :)
2464
2465 SIDE EFFECTS
2466
2467============================================================================*/
2468VOS_STATUS
2469WLANTL_SetSTAPriority
2470(
2471 v_PVOID_t pvosGCtx,
2472 v_U8_t ucSTAId,
2473 WLANTL_STAPriorityType tlSTAPri
2474)
2475{
2476 WLANTL_CbType* pTLCb = NULL;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302477 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002478 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
2479
2480 /*------------------------------------------------------------------------
2481 Sanity check
2482 ------------------------------------------------------------------------*/
2483 if ( WLANTL_STA_ID_INVALID( ucSTAId ) )
2484 {
2485 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2486 "WLAN TL:Invalid station id requested on WLANTL_SetSTAPriority"));
2487 return VOS_STATUS_E_FAULT;
2488 }
2489
2490 /*------------------------------------------------------------------------
2491 Extract TL control block
2492 ------------------------------------------------------------------------*/
2493 pTLCb = VOS_GET_TL_CB(pvosGCtx);
2494 if ( NULL == pTLCb )
2495 {
2496 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2497 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_SetSTAPriority"));
2498 return VOS_STATUS_E_FAULT;
2499 }
2500
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302501 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
2502
2503 if ( NULL == pClientSTA )
2504 {
2505 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2506 "WLAN TL:Client Memory was not allocated on %s", __func__));
2507 return VOS_STATUS_E_FAILURE;
2508 }
2509
2510 if ( 0 == pClientSTA->ucExists )
Jeff Johnson295189b2012-06-20 16:38:30 -07002511 {
2512 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2513 "WLAN TL:Station was not previously registered on WLANTL_SetSTAPriority"));
2514 return VOS_STATUS_E_EXISTS;
2515 }
2516
2517 /*------------------------------------------------------------------------
2518 Re-analize if lock is needed when adding multiple stations
2519 ------------------------------------------------------------------------*/
2520 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
2521 "WLAN TL:Changing state for STA Pri ID: %d from %d to %d",
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302522 ucSTAId, pClientSTA->tlPri, tlSTAPri));
2523 pClientSTA->tlPri = tlSTAPri;
Jeff Johnson295189b2012-06-20 16:38:30 -07002524
2525 return VOS_STATUS_SUCCESS;
2526}/* WLANTL_SetSTAPriority */
2527
2528
2529/*----------------------------------------------------------------------------
2530 INTERACTION WITH BAP
2531 ---------------------------------------------------------------------------*/
2532
2533/*==========================================================================
2534
2535 FUNCTION WLANTL_RegisterBAPClient
2536
2537 DESCRIPTION
2538 Called by SME to register itself as client for non-data BT-AMP packets.
2539
2540 DEPENDENCIES
2541 TL must be initialized before this function can be called.
2542
2543 PARAMETERS
2544
2545 IN
2546 pvosGCtx: pointer to the global vos context; a handle to TL's
2547 or SME's control block can be extracted from its context
2548 pfnTlBAPRxFrm: pointer to the receive processing routine for non-data
2549 BT-AMP packets
2550 pfnFlushOpCompleteCb:
2551 pointer to the call back function, for the Flush operation
2552 completion.
2553
2554
2555 RETURN VALUE
2556
2557 The result code associated with performing the operation
2558
2559 VOS_STATUS_E_INVAL: Input parameters are invalid
2560 VOS_STATUS_E_FAULT: Station ID is outside array boundaries or pointer
2561 to TL cb is NULL ; access would cause a page fault
2562 VOS_STATUS_E_EXISTS: BAL client was already registered
2563 VOS_STATUS_SUCCESS: Everything is good :)
2564
2565 SIDE EFFECTS
2566
2567============================================================================*/
2568VOS_STATUS
2569WLANTL_RegisterBAPClient
2570(
2571 v_PVOID_t pvosGCtx,
2572 WLANTL_BAPRxCBType pfnTlBAPRxFrm,
2573 WLANTL_FlushOpCompCBType pfnFlushOpCompleteCb
2574)
2575{
2576 WLANTL_CbType* pTLCb = NULL;
2577 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
2578
2579 /*------------------------------------------------------------------------
2580 Sanity check
2581 ------------------------------------------------------------------------*/
2582 if ( NULL == pfnTlBAPRxFrm )
2583 {
2584 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2585 "WLAN TL:Invalid parameter sent on WLANTL_RegisterBAPClient"));
2586 return VOS_STATUS_E_INVAL;
2587 }
2588
2589 if ( NULL == pfnFlushOpCompleteCb )
2590 {
2591 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2592 "Invalid Flush Complete Cb parameter sent on WLANTL_RegisterBAPClient"));
2593 return VOS_STATUS_E_INVAL;
2594 }
2595
2596 /*------------------------------------------------------------------------
2597 Extract TL control block
2598 ------------------------------------------------------------------------*/
2599 pTLCb = VOS_GET_TL_CB(pvosGCtx);
2600 if ( NULL == pTLCb )
2601 {
2602 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2603 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_RegisterBAPClient"));
2604 return VOS_STATUS_E_FAULT;
2605 }
2606
2607 /*------------------------------------------------------------------------
2608 Make sure this is the first registration attempt
2609 ------------------------------------------------------------------------*/
2610 if ( 0 != pTLCb->tlBAPClient.ucExists )
2611 {
2612 pTLCb->tlBAPClient.ucExists++;
2613 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2614 "WLAN TL:BAP client was already registered"));
2615 return VOS_STATUS_E_EXISTS;
2616 }
2617
2618 /*------------------------------------------------------------------------
2619 Register station with TL
2620 ------------------------------------------------------------------------*/
2621 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
2622 "WLAN TL:Registering BAP Client" ));
2623
2624 pTLCb->tlBAPClient.ucExists++;
2625
2626 if ( NULL != pfnTlBAPRxFrm )
2627 {
2628 pTLCb->tlBAPClient.pfnTlBAPRx = pfnTlBAPRxFrm;
2629 }
2630
2631 pTLCb->tlBAPClient.pfnFlushOpCompleteCb = pfnFlushOpCompleteCb;
2632
2633 pTLCb->tlBAPClient.vosPendingDataBuff = NULL;
2634
2635 return VOS_STATUS_SUCCESS;
2636}/* WLANTL_RegisterBAPClient */
2637
2638
2639/*==========================================================================
2640
2641 FUNCTION WLANTL_TxBAPFrm
2642
2643 DESCRIPTION
2644 BAP calls this when it wants to send a frame to the module
2645
2646 DEPENDENCIES
2647 BAP must be registered with TL before this function can be called.
2648
2649 RESTRICTION: BAP CANNOT push any packets to TL until it did not receive
2650 a tx complete from the previous packet, that means BAP
2651 sends one packet, wait for tx complete and then
2652 sends another one
2653
2654 If BAP sends another packet before TL manages to process the
2655 previously sent packet call will end in failure
2656
2657 PARAMETERS
2658
2659 IN
2660 pvosGCtx: pointer to the global vos context; a handle to TL's
2661 or BAP's control block can be extracted from its context
2662 vosDataBuff: pointer to the vOSS buffer containing the packet to be
2663 transmitted
2664 pMetaInfo: meta information about the packet
2665 pfnTlBAPTxComp: pointer to a transmit complete routine for notifying
2666 the result of the operation over the bus
2667
2668 RETURN VALUE
2669 The result code associated with performing the operation
2670
2671 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
2672 page fault
2673 VOS_STATUS_E_EXISTS: BAL client was not yet registered
2674 VOS_STATUS_E_BUSY: The previous BT-AMP packet was not yet transmitted
2675 VOS_STATUS_SUCCESS: Everything is good :)
2676
2677 Other failure messages may be returned from the BD header handling
2678 routines, please check apropriate API for more info.
2679
2680 SIDE EFFECTS
2681
2682============================================================================*/
2683VOS_STATUS
2684WLANTL_TxBAPFrm
2685(
2686 v_PVOID_t pvosGCtx,
2687 vos_pkt_t* vosDataBuff,
2688 WLANTL_MetaInfoType* pMetaInfo,
2689 WLANTL_TxCompCBType pfnTlBAPTxComp
2690)
2691{
2692 WLANTL_CbType* pTLCb = NULL;
2693 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
2694 v_MACADDR_t vDestMacAddr;
2695 v_U16_t usPktLen;
2696 v_U8_t ucStaId = 0;
2697 v_U8_t extraHeadSpace = 0;
2698 v_U8_t ucWDSEnabled = 0;
2699 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
2700
2701 /*------------------------------------------------------------------------
2702 Sanity check
2703 Extract TL control block
2704 ------------------------------------------------------------------------*/
2705 pTLCb = VOS_GET_TL_CB(pvosGCtx);
2706 if ( NULL == pTLCb )
2707 {
2708 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2709 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_TxBAPFrm"));
2710 return VOS_STATUS_E_FAULT;
2711 }
2712
2713 /*------------------------------------------------------------------------
2714 Ensure that BAP client was registered previously
2715 ------------------------------------------------------------------------*/
2716 if (( 0 == pTLCb->tlBAPClient.ucExists ) ||
2717 ( WLANTL_STA_ID_INVALID(pTLCb->tlBAPClient.ucBAPSTAId) ))
2718 {
2719 pTLCb->tlBAPClient.ucExists++;
2720 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2721 "WLAN TL:BAP client not register on WLANTL_TxBAPFrm"));
2722 return VOS_STATUS_E_EXISTS;
2723 }
2724
2725 /*------------------------------------------------------------------------
2726 Check if any BT-AMP Frm is pending
2727 ------------------------------------------------------------------------*/
2728 if ( NULL != pTLCb->tlBAPClient.vosPendingDataBuff )
2729 {
2730 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2731 "WLAN TL:BT-AMP Frame already pending tx in TL on WLANTL_TxBAPFrm"));
2732 return VOS_STATUS_E_BUSY;
2733 }
2734
2735 /*------------------------------------------------------------------------
2736 Save buffer and notify BAL; no lock is needed if the above restriction
2737 is met
2738 Save the tx complete fnct pointer as tl specific data in the vos buffer
2739 ------------------------------------------------------------------------*/
2740
2741 /*------------------------------------------------------------------------
2742 Translate 802.3 frame to 802.11
2743 ------------------------------------------------------------------------*/
2744 ucStaId = pTLCb->tlBAPClient.ucBAPSTAId;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302745 if ( NULL == pTLCb->atlSTAClients[ucStaId] )
2746 {
2747 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2748 "WLAN TL:Client Memory was not allocated on %s", __func__));
2749 return VOS_STATUS_E_FAILURE;
2750 }
2751 if (( 0 == pMetaInfo->ucDisableFrmXtl ) &&
2752 ( 0 != pTLCb->atlSTAClients[ucStaId]->wSTADesc.ucSwFrameTXXlation ))
Jeff Johnson295189b2012-06-20 16:38:30 -07002753 {
Kiran Venkatappacab0d352012-12-17 13:09:22 -08002754 vosStatus = WLANTL_Translate8023To80211Header( vosDataBuff, &vosStatus,
2755 pTLCb, &ucStaId,
Ravi Joshid0699502013-07-08 15:48:47 -07002756 pMetaInfo, &ucWDSEnabled,
2757 &extraHeadSpace);
Jeff Johnson295189b2012-06-20 16:38:30 -07002758
2759 if ( VOS_STATUS_SUCCESS != vosStatus )
2760 {
2761 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2762 "WLAN TL:Error when translating header WLANTL_TxBAPFrm"));
2763
2764 return vosStatus;
2765 }
2766
2767 pMetaInfo->ucDisableFrmXtl = 1;
2768 }
2769
2770 /*-------------------------------------------------------------------------
2771 Call HAL to fill BD header
2772 -------------------------------------------------------------------------*/
2773
2774 /* Adding Type, SubType which was missing for EAPOL from BAP */
2775 pMetaInfo->ucType |= (WLANTL_80211_DATA_TYPE << 4);
2776 pMetaInfo->ucType |= (WLANTL_80211_DATA_QOS_SUBTYPE);
2777
2778 vosStatus = WDA_DS_BuildTxPacketInfo( pvosGCtx, vosDataBuff ,
2779 &vDestMacAddr, pMetaInfo->ucDisableFrmXtl,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302780 &usPktLen, pTLCb->atlSTAClients[ucStaId]->wSTADesc.ucQosEnabled,
Jeff Johnson295189b2012-06-20 16:38:30 -07002781 ucWDSEnabled, extraHeadSpace, pMetaInfo->ucType,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302782 &pTLCb->atlSTAClients[ucStaId]->wSTADesc.vSelfMACAddress,
Jeff Johnson295189b2012-06-20 16:38:30 -07002783 pMetaInfo->ucTID, 0 /* No ACK */, pMetaInfo->usTimeStamp,
Sravan Kumar Kairamd9e8cbb2017-01-17 12:17:28 +05302784 pMetaInfo->ucIsEapol || pMetaInfo->ucIsWai, pMetaInfo->ucIsArp,
2785 pMetaInfo->ucUP, pMetaInfo->ucTxBdToken);
Jeff Johnson295189b2012-06-20 16:38:30 -07002786
2787 if ( VOS_STATUS_SUCCESS != vosStatus )
2788 {
2789 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2790 "WLAN TL:Failed while building TX header %d", vosStatus));
2791 return vosStatus;
2792 }
2793
2794 if ( NULL != pfnTlBAPTxComp )
2795 {
2796 vos_pkt_set_user_data_ptr( vosDataBuff, VOS_PKT_USER_DATA_ID_TL,
2797 (v_PVOID_t)pfnTlBAPTxComp);
2798 }
2799 else
2800 {
2801 vos_pkt_set_user_data_ptr( vosDataBuff, VOS_PKT_USER_DATA_ID_TL,
2802 (v_PVOID_t)WLANTL_TxCompDefaultCb);
2803
2804 }
2805
Arun Kumar Khandavalli0af8d3c2014-02-07 18:05:11 +05302806 vos_atomic_set( (uintptr_t*)&pTLCb->tlBAPClient.vosPendingDataBuff,
2807 (uintptr_t)vosDataBuff);
Jeff Johnson295189b2012-06-20 16:38:30 -07002808
2809 /*------------------------------------------------------------------------
2810 Check if thre are enough resources for transmission and tx is not
2811 suspended.
2812 ------------------------------------------------------------------------*/
2813 if (( pTLCb->uResCount >= WDA_TLI_MIN_RES_BAP ) &&
2814 ( 0 == pTLCb->ucTxSuspended ))
2815 {
2816 WDA_DS_StartXmit(pvosGCtx);
2817 }
2818 else
2819 {
2820 /*---------------------------------------------------------------------
2821 No error code is sent because TL will resume tx autonomously if
2822 resources become available or tx gets resumed
2823 ---------------------------------------------------------------------*/
2824 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
2825 "WLAN TL:Request to send from BAP but condition not met.Res: %d,"
2826 "Suspend: %d", pTLCb->uResCount, pTLCb->ucTxSuspended ));
2827 }
2828
2829 return VOS_STATUS_SUCCESS;
2830}/* WLANTL_TxBAPFrm */
2831
2832
2833/*----------------------------------------------------------------------------
2834 INTERACTION WITH SME
2835 ---------------------------------------------------------------------------*/
2836
2837/*==========================================================================
2838
2839 FUNCTION WLANTL_GetRssi
2840
2841 DESCRIPTION
2842 TL will extract the RSSI information from every data packet from the
2843 ongoing traffic and will store it. It will provide the result to SME
2844 upon request.
2845
2846 DEPENDENCIES
2847
2848 WARNING: the read and write of this value will not be protected
2849 by locks, therefore the information obtained after a read
2850 might not always be consistent.
2851
2852 PARAMETERS
2853
2854 IN
2855 pvosGCtx: pointer to the global vos context; a handle to TL's
2856 or SME's control block can be extracted from its context
2857 ucSTAId: station identifier for the requested value
2858
2859 OUT
2860 puRssi: the average value of the RSSI
2861
2862
2863 RETURN VALUE
2864 The result code associated with performing the operation
2865
2866 VOS_STATUS_E_INVAL: Input parameters are invalid
2867 VOS_STATUS_E_FAULT: Station ID is outside array boundaries or pointer
2868 to TL cb is NULL ; access would cause a page fault
2869 VOS_STATUS_E_EXISTS: STA was not yet registered
2870 VOS_STATUS_SUCCESS: Everything is good :)
2871
2872 SIDE EFFECTS
2873
2874============================================================================*/
2875VOS_STATUS
2876WLANTL_GetRssi
2877(
2878 v_PVOID_t pvosGCtx,
2879 v_U8_t ucSTAId,
2880 v_S7_t* pRssi
2881)
2882{
2883 WLANTL_CbType* pTLCb = NULL;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302884 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002885 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
2886
2887 /*------------------------------------------------------------------------
2888 Sanity check
2889 ------------------------------------------------------------------------*/
2890 if ( NULL == pRssi )
2891 {
2892 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2893 "WLAN TL:Invalid parameter sent on WLANTL_GetRssi"));
2894 return VOS_STATUS_E_INVAL;
2895 }
2896
2897 if ( WLANTL_STA_ID_INVALID( ucSTAId ) )
2898 {
2899 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2900 "WLAN TL:Invalid station id requested on WLANTL_GetRssi"));
2901 return VOS_STATUS_E_FAULT;
2902 }
2903
2904 /*------------------------------------------------------------------------
2905 Extract TL control block and check existance
2906 ------------------------------------------------------------------------*/
2907 pTLCb = VOS_GET_TL_CB(pvosGCtx);
2908 if ( NULL == pTLCb )
2909 {
2910 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2911 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_GetRssi"));
2912 return VOS_STATUS_E_FAULT;
2913 }
2914
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302915 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
2916
2917 if ( NULL == pClientSTA )
2918 {
2919 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2920 "WLAN TL:Client Memory was not allocated on %s", __func__));
2921 return VOS_STATUS_E_FAILURE;
2922 }
2923
2924 if ( 0 == pClientSTA->ucExists )
Jeff Johnson295189b2012-06-20 16:38:30 -07002925 {
2926 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2927 "WLAN TL:Station was not previously registered on WLANTL_GetRssi"));
2928 return VOS_STATUS_E_EXISTS;
2929 }
2930
2931 /*------------------------------------------------------------------------
2932 Copy will not be locked; please read restriction
2933 ------------------------------------------------------------------------*/
Katya Nigam5c2e5f62013-11-15 19:19:11 +05302934 if(pTLCb->isBMPS || IS_ACTIVEMODE_OFFLOAD_FEATURE_ENABLE)
Jeff Johnson295189b2012-06-20 16:38:30 -07002935 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302936 *pRssi = pClientSTA->rssiAvgBmps;
Jeff Johnson295189b2012-06-20 16:38:30 -07002937 /* Check If RSSI is zero because we are reading rssAvgBmps updated by HAL in
2938 previous GetStatsRequest. It may be updated as zero by Hal because EnterBmps
2939 might not have happend by that time. Hence reading the most recent Rssi
2940 calcluated by TL*/
2941 if(0 == *pRssi)
2942 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302943 *pRssi = pClientSTA->rssiAvg;
Jeff Johnson295189b2012-06-20 16:38:30 -07002944 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002945 }
2946 else
2947 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302948 *pRssi = pClientSTA->rssiAvg;
Jeff Johnson295189b2012-06-20 16:38:30 -07002949 }
2950
2951 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
Jeff Johnson32d95a32012-09-10 13:15:23 -07002952 "WLAN TL:WLANTL_GetRssi for STA: %d RSSI: %d%s",
2953 ucSTAId, *pRssi,
2954 pTLCb->isBMPS ? " in BMPS" : ""));
Jeff Johnson295189b2012-06-20 16:38:30 -07002955
2956 return VOS_STATUS_SUCCESS;
2957}/* WLANTL_GetRssi */
2958
2959/*==========================================================================
2960
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05302961 FUNCTION WLANTL_GetSnr
2962
2963 DESCRIPTION
2964 TL will extract the SNR information from every data packet from the
2965 ongoing traffic and will store it. It will provide the result to SME
2966 upon request.
2967
2968 DEPENDENCIES
2969
2970 WARNING: the read and write of this value will not be protected
2971 by locks, therefore the information obtained after a read
2972 might not always be consistent.
2973
2974 PARAMETERS
2975
2976 IN
2977 pvosGCtx: pointer to the global vos context; a handle to TL's
2978 or SME's control block can be extracted from its context
2979 ucSTAId: station identifier for the requested value
2980
2981 OUT
2982 pSnr: the average value of the SNR
2983
2984
2985 RETURN VALUE
2986 The result code associated with performing the operation
2987
2988 VOS_STATUS_E_INVAL: Input parameters are invalid
2989 VOS_STATUS_E_FAULT: Station ID is outside array boundaries or pointer
2990 to TL cb is NULL ; access would cause a page fault
2991 VOS_STATUS_E_EXISTS: STA was not yet registered
2992 VOS_STATUS_SUCCESS: Everything is good :)
2993
2994 SIDE EFFECTS
2995
2996============================================================================*/
2997VOS_STATUS
2998WLANTL_GetSnr
2999(
3000 tANI_U8 ucSTAId,
3001 tANI_S8* pSnr
3002)
3003{
3004 WLANTL_CbType* pTLCb = NULL;
3005 WLANTL_STAClientType* pClientSTA = NULL;
3006 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
3007
3008 /*------------------------------------------------------------------------
3009 Sanity check
3010 ------------------------------------------------------------------------*/
3011 if (NULL == pSnr)
3012 {
3013 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3014 "WLAN TL:Invalid parameter sent on %s", __func__));
3015 return VOS_STATUS_E_INVAL;
3016 }
3017
3018 if (WLANTL_STA_ID_INVALID(ucSTAId))
3019 {
3020 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3021 "WLAN TL:Invalid station id requested on %s", __func__));
3022 return VOS_STATUS_E_FAULT;
3023 }
3024
3025 /*------------------------------------------------------------------------
3026 Extract TL control block and check existance
3027 ------------------------------------------------------------------------*/
3028 pTLCb = VOS_GET_TL_CB(vos_get_global_context(VOS_MODULE_ID_TL, NULL));
3029 if (NULL == pTLCb)
3030 {
3031 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3032 "WLAN TL:Invalid TL pointer from pvosGCtx on %s", __func__));
3033 return VOS_STATUS_E_FAULT;
3034 }
3035
3036 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
3037
3038 if (NULL == pClientSTA)
3039 {
3040 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3041 "WLAN TL:Client Memory was not allocated on %s", __func__));
3042 return VOS_STATUS_E_FAILURE;
3043 }
3044
3045 if (0 == pClientSTA->ucExists)
3046 {
3047 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3048 "WLAN TL:Station was not previously registered on %s", __func__));
3049 return VOS_STATUS_E_EXISTS;
3050 }
3051
3052 /*------------------------------------------------------------------------
3053 Copy will not be locked; please read restriction
3054 ------------------------------------------------------------------------*/
3055 if (pTLCb->isBMPS)
3056 {
3057 *pSnr = pClientSTA->snrAvgBmps;
3058 }
3059 else
3060 {
3061 /* SNR is averaged over WLANTL_MAX_SNR_DATA_SAMPLES, if there are not enough
3062 * data samples (snridx) to calculate the average then return the
3063 * average for the window of prevoius 20 packets. And if there aren't
3064 * enough samples and the average for previous window of 20 packets is
3065 * not available then return a predefined value
3066 *
3067 * NOTE: the SNR_HACK_BMPS value is defined to 127, documents from HW
3068 * team reveal that the SNR value has a ceiling well below 127 dBm,
3069 * so if SNR has value of 127 the userspace applications can know that
3070 * the SNR has not been computed yet because enough data was not
3071 * available for SNR calculation
3072 */
3073 if (pClientSTA->snrIdx > (WLANTL_MAX_SNR_DATA_SAMPLES/2)
3074 || !(pClientSTA->prevSnrAvg))
3075 {
3076 *pSnr = pClientSTA->snrSum / pClientSTA->snrIdx;
3077 }
3078 else if (pClientSTA->prevSnrAvg)
3079 {
3080 *pSnr = pClientSTA->prevSnrAvg;
3081 }
3082 else
3083 {
3084 *pSnr = SNR_HACK_BMPS;
3085 }
3086 }
3087
3088 VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
3089 "WLAN TL:WLANTL_GetSnr for STA: %d SNR: %d%s",
3090 ucSTAId, *pSnr,
3091 pTLCb->isBMPS ? " in BMPS" : "");
3092
3093 return VOS_STATUS_SUCCESS;
3094}/* WLANTL_GetSnr */
3095/*==========================================================================
3096
Jeff Johnson295189b2012-06-20 16:38:30 -07003097 FUNCTION WLANTL_GetLinkQuality
3098
3099 DESCRIPTION
3100 TL will extract the SNR information from every data packet from the
3101 ongoing traffic and will store it. It will provide the result to SME
3102 upon request.
3103
3104 DEPENDENCIES
3105
3106 WARNING: the read and write of this value will not be protected
3107 by locks, therefore the information obtained after a read
3108 might not always be consistent.
3109
3110 PARAMETERS
3111
3112 IN
3113 pvosGCtx: pointer to the global vos context; a handle to TL's
3114 or SME's control block can be extracted from its context
3115 ucSTAId: station identifier for the requested value
3116
3117 OUT
3118 puLinkQuality: the average value of the SNR
3119
3120
3121 RETURN VALUE
3122 The result code associated with performing the operation
3123
3124 VOS_STATUS_E_INVAL: Input parameters are invalid
3125 VOS_STATUS_E_FAULT: Station ID is outside array boundaries or pointer
3126 to TL cb is NULL ; access would cause a page fault
3127 VOS_STATUS_E_EXISTS: STA was not yet registered
3128 VOS_STATUS_SUCCESS: Everything is good :)
3129
3130 SIDE EFFECTS
3131
3132============================================================================*/
3133VOS_STATUS
3134WLANTL_GetLinkQuality
3135(
3136 v_PVOID_t pvosGCtx,
3137 v_U8_t ucSTAId,
3138 v_U32_t* puLinkQuality
3139)
3140{
3141 WLANTL_CbType* pTLCb = NULL;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05303142 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07003143
3144 /*------------------------------------------------------------------------
3145 Sanity check
3146 ------------------------------------------------------------------------*/
3147 if ( NULL == puLinkQuality )
3148 {
3149 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3150 "Invalid parameter sent on WLANTL_GetLinkQuality"));
3151 return VOS_STATUS_E_INVAL;
3152 }
3153
3154 if ( WLANTL_STA_ID_INVALID( ucSTAId ) )
3155 {
3156 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3157 "Invalid station id requested on WLANTL_GetLinkQuality"));
3158 return VOS_STATUS_E_FAULT;
3159 }
3160
3161 /*------------------------------------------------------------------------
3162 Extract TL control block and check existance
3163 ------------------------------------------------------------------------*/
3164 pTLCb = VOS_GET_TL_CB(pvosGCtx);
3165 if ( NULL == pTLCb )
3166 {
3167 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3168 "Invalid TL pointer from pvosGCtx on WLANTL_GetLinkQuality"));
3169 return VOS_STATUS_E_FAULT;
3170 }
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05303171 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
Jeff Johnson295189b2012-06-20 16:38:30 -07003172
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05303173 if ( NULL == pClientSTA )
3174 {
3175 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3176 "WLAN TL:Client Memory was not allocated on %s", __func__));
3177 return VOS_STATUS_E_FAILURE;
3178 }
3179
3180 if ( 0 == pClientSTA->ucExists )
Jeff Johnson295189b2012-06-20 16:38:30 -07003181 {
3182 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3183 "Station was not previously registered on WLANTL_GetLinkQuality"));
3184 return VOS_STATUS_E_EXISTS;
3185 }
3186
3187 /*------------------------------------------------------------------------
3188 Copy will not be locked; please read restriction
3189 ------------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05303190 *puLinkQuality = pClientSTA->uLinkQualityAvg;
Jeff Johnson295189b2012-06-20 16:38:30 -07003191
3192 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
3193 "WLANTL_GetLinkQuality for STA: %d LinkQuality: %d", ucSTAId, *puLinkQuality));
3194
3195 return VOS_STATUS_SUCCESS;
3196}/* WLANTL_GetLinkQuality */
3197
3198/*==========================================================================
3199
3200 FUNCTION WLANTL_FlushStaTID
3201
3202 DESCRIPTION
3203 TL provides this API as an interface to SME (BAP) layer. TL inturn posts a
3204 message to HAL. This API is called by the SME inorder to perform a flush
3205 operation.
3206
3207 DEPENDENCIES
3208
3209 PARAMETERS
3210
3211 IN
3212 pvosGCtx: pointer to the global vos context; a handle to TL's
3213 or SME's control block can be extracted from its context
3214 ucSTAId: station identifier for the requested value
3215 ucTid: Tspec ID for the new BA session
3216
3217 OUT
3218 The response for this post is received in the main thread, via a response
3219 message from HAL to TL.
3220
3221 RETURN VALUE
3222 VOS_STATUS_SUCCESS: Everything is good :)
3223
3224 SIDE EFFECTS
3225============================================================================*/
3226VOS_STATUS
3227WLANTL_FlushStaTID
3228(
3229 v_PVOID_t pvosGCtx,
3230 v_U8_t ucSTAId,
3231 v_U8_t ucTid
3232)
3233{
3234 WLANTL_CbType* pTLCb = NULL;
3235 tpFlushACReq FlushACReqPtr = NULL;
3236 vos_msg_t vosMessage;
3237
3238
3239 if ( WLANTL_STA_ID_INVALID( ucSTAId ) )
3240 {
3241 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3242 "Invalid station id requested on WLANTL_FlushStaTID"));
3243 return VOS_STATUS_E_FAULT;
3244 }
3245
3246 /*------------------------------------------------------------------------
3247 Extract TL control block and check existance
3248 ------------------------------------------------------------------------*/
3249 pTLCb = VOS_GET_TL_CB(pvosGCtx);
3250 if ( NULL == pTLCb )
3251 {
3252 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3253 "Invalid TL pointer from pvosGCtx on WLANTL_FlushStaTID"));
3254 return VOS_STATUS_E_FAULT;
3255 }
3256
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05303257 if ( NULL == pTLCb->atlSTAClients[ucSTAId] )
3258 {
3259 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3260 "WLAN TL:Client Memory was not allocated on %s", __func__));
3261 return VOS_STATUS_E_FAILURE;
3262 }
3263
3264 if ( 0 == pTLCb->atlSTAClients[ucSTAId]->ucExists )
Jeff Johnson295189b2012-06-20 16:38:30 -07003265 {
3266 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3267 "Station was not previously registered on WLANTL_FlushStaTID"));
3268 return VOS_STATUS_E_EXISTS;
3269 }
3270
3271 /*------------------------------------------------------------------------
3272 We need to post a message with the STA, TID value to HAL. HAL performs the flush
3273 ------------------------------------------------------------------------*/
3274 FlushACReqPtr = vos_mem_malloc(sizeof(tFlushACReq));
3275
3276 if ( NULL == FlushACReqPtr )
3277 {
3278 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3279 "WLAN TL: fatal failure, cannot allocate Flush Req structure"));
3280 VOS_ASSERT(0);
3281 return VOS_STATUS_E_NOMEM;
3282 }
3283
3284 // Start constructing the message for HAL
3285 FlushACReqPtr->mesgType = SIR_TL_HAL_FLUSH_AC_REQ;
3286 FlushACReqPtr->mesgLen = sizeof(tFlushACReq);
3287 FlushACReqPtr->mesgLen = sizeof(tFlushACReq);
3288 FlushACReqPtr->ucSTAId = ucSTAId;
3289 FlushACReqPtr->ucTid = ucTid;
3290
3291 vosMessage.type = WDA_TL_FLUSH_AC_REQ;
3292 vosMessage.bodyptr = (void *)FlushACReqPtr;
3293
3294 vos_mq_post_message(VOS_MQ_ID_WDA, &vosMessage);
3295 return VOS_STATUS_SUCCESS;
3296}
3297
3298
3299/*----------------------------------------------------------------------------
3300 INTERACTION WITH PE
3301 ---------------------------------------------------------------------------*/
Siddharth Bhal4551b102014-10-09 21:36:36 +05303302/*==========================================================================
Jeff Johnson295189b2012-06-20 16:38:30 -07003303
Siddharth Bhal4551b102014-10-09 21:36:36 +05303304 FUNCTION WLANTL_updateSpoofMacAddr
3305
3306 DESCRIPTION
3307 Called by HDD to update macaddr
3308
3309 DEPENDENCIES
3310 TL must be initialized before this API can be called.
3311
3312 PARAMETERS
3313
3314 IN
3315 pvosGCtx: pointer to the global vos context; a handle to
3316 TL's control block can be extracted from its context
3317 spoofMacAddr: spoofed mac adderess
3318 selfMacAddr: self Mac Address
3319
3320 RETURN VALUE
3321 The result code associated with performing the operation
3322
3323 VOS_STATUS_E_INVAL: Input parameters are invalid
3324 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
3325 page fault
3326 VOS_STATUS_SUCCESS: Everything is good :)
3327
3328 SIDE EFFECTS
3329
3330============================================================================*/
3331VOS_STATUS
3332WLANTL_updateSpoofMacAddr
3333(
3334 v_PVOID_t pvosGCtx,
3335 v_MACADDR_t* spoofMacAddr,
3336 v_MACADDR_t* selfMacAddr
3337)
3338{
3339 WLANTL_CbType* pTLCb = NULL;
3340 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
3341
3342 /*------------------------------------------------------------------------
Siddharth Bhal4551b102014-10-09 21:36:36 +05303343 Extract TL control block
3344 ------------------------------------------------------------------------*/
3345 pTLCb = VOS_GET_TL_CB(pvosGCtx);
3346 if ( NULL == pTLCb )
3347 {
3348 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3349 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_ChangeSTAState");
3350 return VOS_STATUS_E_FAULT;
3351 }
3352
3353 vos_mem_copy(pTLCb->spoofMacAddr.selfMac.bytes, selfMacAddr,
3354 VOS_MAC_ADDRESS_LEN);
3355 vos_mem_copy(pTLCb->spoofMacAddr.spoofMac.bytes, spoofMacAddr,
3356 VOS_MAC_ADDRESS_LEN);
3357
3358 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_LOW,
3359 "TL: SelfSTA mac Addr for current Scan "MAC_ADDRESS_STR,
3360 MAC_ADDR_ARRAY(pTLCb->spoofMacAddr.selfMac.bytes));
3361
3362 return VOS_STATUS_SUCCESS;
3363}/* WLANTL_updateSpoofMacAddr */
Jeff Johnson295189b2012-06-20 16:38:30 -07003364/*==========================================================================
3365
3366 FUNCTION WLANTL_RegisterMgmtFrmClient
3367
3368 DESCRIPTION
3369 Called by PE to register as a client for management frames delivery.
3370
3371 DEPENDENCIES
3372 TL must be initialized before this API can be called.
3373
3374 PARAMETERS
3375
3376 IN
3377 pvosGCtx: pointer to the global vos context; a handle to
3378 TL's control block can be extracted from its context
3379 pfnTlMgmtFrmRx: pointer to the receive processing routine for
3380 management frames
3381
3382 RETURN VALUE
3383 The result code associated with performing the operation
3384
3385 VOS_STATUS_E_INVAL: Input parameters are invalid
3386 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
3387 page fault
3388 VOS_STATUS_E_EXISTS: Mgmt Frame client was already registered
3389 VOS_STATUS_SUCCESS: Everything is good :)
3390
3391 SIDE EFFECTS
3392
3393============================================================================*/
3394VOS_STATUS
3395WLANTL_RegisterMgmtFrmClient
3396(
3397 v_PVOID_t pvosGCtx,
3398 WLANTL_MgmtFrmRxCBType pfnTlMgmtFrmRx
3399)
3400{
3401 WLANTL_CbType* pTLCb = NULL;
3402 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
3403
3404 /*------------------------------------------------------------------------
3405 Sanity check
3406 ------------------------------------------------------------------------*/
3407 if ( NULL == pfnTlMgmtFrmRx )
3408 {
3409 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3410 "WLAN TL:Invalid parameter sent on WLANTL_RegisterMgmtFrmClient"));
3411 return VOS_STATUS_E_INVAL;
3412 }
3413
3414 /*------------------------------------------------------------------------
3415 Extract TL control block
3416 ------------------------------------------------------------------------*/
3417 pTLCb = VOS_GET_TL_CB(pvosGCtx);
3418 if ( NULL == pTLCb )
3419 {
3420 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3421 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_ChangeSTAState"));
3422 return VOS_STATUS_E_FAULT;
3423 }
3424
3425 /*------------------------------------------------------------------------
3426 Make sure this is the first registration attempt
3427 ------------------------------------------------------------------------*/
3428 if ( 0 != pTLCb->tlMgmtFrmClient.ucExists )
3429 {
3430 pTLCb->tlMgmtFrmClient.ucExists++;
3431 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3432 "WLAN TL:Management frame client was already registered"));
3433 return VOS_STATUS_E_EXISTS;
3434 }
3435
3436 /*------------------------------------------------------------------------
3437 Register station with TL
3438 ------------------------------------------------------------------------*/
3439 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
3440 "WLAN TL:Registering Management Frame Client" ));
3441
3442 pTLCb->tlMgmtFrmClient.ucExists++;
3443
3444 if ( NULL != pfnTlMgmtFrmRx )
3445 {
3446 pTLCb->tlMgmtFrmClient.pfnTlMgmtFrmRx = pfnTlMgmtFrmRx;
3447 }
3448
3449 pTLCb->tlMgmtFrmClient.vosPendingDataBuff = NULL;
3450
3451 return VOS_STATUS_SUCCESS;
3452}/* WLANTL_RegisterMgmtFrmClient */
3453
3454/*==========================================================================
3455
3456 FUNCTION WLANTL_DeRegisterMgmtFrmClient
3457
3458 DESCRIPTION
3459 Called by PE to deregister as a client for management frames delivery.
3460
3461 DEPENDENCIES
3462 TL must be initialized before this API can be called.
3463
3464 PARAMETERS
3465
3466 IN
3467 pvosGCtx: pointer to the global vos context; a handle to
3468 TL's control block can be extracted from its context
3469 RETURN VALUE
3470 The result code associated with performing the operation
3471
3472 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
3473 page fault
3474 VOS_STATUS_E_EXISTS: Mgmt Frame client was never registered
3475 VOS_STATUS_SUCCESS: Everything is good :)
3476
3477 SIDE EFFECTS
3478
3479============================================================================*/
3480VOS_STATUS
3481WLANTL_DeRegisterMgmtFrmClient
3482(
3483 v_PVOID_t pvosGCtx
3484)
3485{
3486 WLANTL_CbType* pTLCb = NULL;
3487 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
3488
3489 /*------------------------------------------------------------------------
3490 Extract TL control block
3491 ------------------------------------------------------------------------*/
3492 pTLCb = VOS_GET_TL_CB(pvosGCtx);
3493 if ( NULL == pTLCb )
3494 {
3495 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3496 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_ChangeSTAState"));
3497 return VOS_STATUS_E_FAULT;
3498 }
3499
3500 /*------------------------------------------------------------------------
3501 Make sure this is the first registration attempt
3502 ------------------------------------------------------------------------*/
3503 if ( 0 == pTLCb->tlMgmtFrmClient.ucExists )
3504 {
3505 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3506 "WLAN TL:Management frame client was never registered"));
3507 return VOS_STATUS_E_EXISTS;
3508 }
3509
3510 /*------------------------------------------------------------------------
3511 Clear registration with TL
3512 ------------------------------------------------------------------------*/
3513 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
3514 "WLAN TL:Deregistering Management Frame Client" ));
3515
3516 pTLCb->tlMgmtFrmClient.pfnTlMgmtFrmRx = WLANTL_MgmtFrmRxDefaultCb;
3517 if ( NULL != pTLCb->tlMgmtFrmClient.vosPendingDataBuff)
3518 {
3519 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
3520 "WLAN TL:Management cache buffer not empty on deregistering"
3521 " - dropping packet" ));
3522 vos_pkt_return_packet(pTLCb->tlMgmtFrmClient.vosPendingDataBuff);
3523
3524 pTLCb->tlMgmtFrmClient.vosPendingDataBuff = NULL;
3525 }
3526
3527 pTLCb->tlMgmtFrmClient.ucExists = 0;
3528
3529 return VOS_STATUS_SUCCESS;
3530}/* WLANTL_RegisterMgmtFrmClient */
3531
3532/*==========================================================================
3533
3534 FUNCTION WLANTL_TxMgmtFrm
3535
3536 DESCRIPTION
3537 Called by PE when it want to send out a management frame.
3538 HAL will also use this API for the few frames it sends out, they are not
3539 management frames howevere it is accepted that an exception will be
3540 allowed ONLY for the usage of HAL.
3541 Generic data frames SHOULD NOT travel through this function.
3542
3543 DEPENDENCIES
3544 TL must be initialized before this API can be called.
3545
3546 RESTRICTION: If PE sends another packet before TL manages to process the
3547 previously sent packet call will end in failure
3548
3549 Frames comming through here must be 802.11 frames, frame
3550 translation in UMA will be automatically disabled.
3551
3552 PARAMETERS
3553
3554 IN
3555 pvosGCtx: pointer to the global vos context;a handle to TL's
3556 control block can be extracted from its context
3557 vosFrmBuf: pointer to a vOSS buffer containing the management
3558 frame to be transmitted
3559 usFrmLen: the length of the frame to be transmitted; information
3560 is already included in the vOSS buffer
3561 wFrmType: the type of the frame being transmitted
3562 tid: tid used to transmit this frame
3563 pfnCompTxFunc: function pointer to the transmit complete routine
3564 pvBDHeader: pointer to the BD header, if NULL it means it was not
3565 yet constructed and it lies within TL's responsibility
3566 to do so; if not NULL it is expected that it was
3567 already packed inside the vos packet
3568 ucAckResponse: flag notifying it an interrupt is needed for the
3569 acknowledgement received when the frame is sent out
3570 the air and ; the interrupt will be processed by HAL,
3571 only one such frame can be pending in the system at
3572 one time.
3573
3574
3575 RETURN VALUE
3576 The result code associated with performing the operation
3577
3578 VOS_STATUS_E_INVAL: Input parameters are invalid
3579 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
3580 page fault
3581 VOS_STATUS_E_EXISTS: Mgmt Frame client was not yet registered
3582 VOS_STATUS_E_BUSY: The previous Mgmt packet was not yet transmitted
3583 VOS_STATUS_SUCCESS: Everything is good :)
3584
3585 Other failure messages may be returned from the BD header handling
3586 routines, please check apropriate API for more info.
3587
3588 SIDE EFFECTS
3589
3590============================================================================*/
3591VOS_STATUS
3592WLANTL_TxMgmtFrm
3593(
3594 v_PVOID_t pvosGCtx,
3595 vos_pkt_t* vosFrmBuf,
3596 v_U16_t usFrmLen,
3597 v_U8_t wFrmType,
3598 v_U8_t ucTid,
3599 WLANTL_TxCompCBType pfnCompTxFunc,
3600 v_PVOID_t pvBDHeader,
Ganesh Kondabattini10e67352015-03-16 17:41:57 +05303601 v_U32_t ucAckResponse,
3602 v_U32_t ucTxBdToken
Jeff Johnson295189b2012-06-20 16:38:30 -07003603)
3604{
3605 WLANTL_CbType* pTLCb = NULL;
3606 v_MACADDR_t vDestMacAddr;
3607 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
3608 v_U16_t usPktLen;
3609 v_U32_t usTimeStamp = 0;
3610 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
3611
3612 /*------------------------------------------------------------------------
3613 Sanity check
3614 ------------------------------------------------------------------------*/
3615 if ( NULL == vosFrmBuf )
3616 {
3617 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3618 "WLAN TL:Invalid parameter sent on WLANTL_TxMgmtFrm"));
3619 return VOS_STATUS_E_INVAL;
3620 }
3621
3622 /*------------------------------------------------------------------------
3623 Extract TL control block
3624 ------------------------------------------------------------------------*/
3625 pTLCb = VOS_GET_TL_CB(pvosGCtx);
3626 if ( NULL == pTLCb )
3627 {
3628 TLLOGP(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_FATAL,
3629 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_TxMgmtFrm"));
3630 return VOS_STATUS_E_FAULT;
3631 }
3632
3633 /*------------------------------------------------------------------------
3634 Ensure that management frame client was previously registered
3635 ------------------------------------------------------------------------*/
3636 if ( 0 == pTLCb->tlMgmtFrmClient.ucExists )
3637 {
3638 pTLCb->tlMgmtFrmClient.ucExists++;
3639 TLLOGP(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_FATAL,
3640 "WLAN TL:Management Frame client not register on WLANTL_TxMgmtFrm"));
3641 return VOS_STATUS_E_EXISTS;
3642 }
3643
3644 /*------------------------------------------------------------------------
3645 Check if any Mgmt Frm is pending
3646 ------------------------------------------------------------------------*/
3647 //vosTempBuff = pTLCb->tlMgmtFrmClient.vosPendingDataBuff;
3648 if ( NULL != pTLCb->tlMgmtFrmClient.vosPendingDataBuff )
3649 {
3650
3651 TLLOGP(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_FATAL,
3652 "WLAN TL:Management Frame already pending tx in TL: failing old one"));
3653
3654
3655 /*Failing the tx for the previous packet enqued by PE*/
Arun Kumar Khandavalli0af8d3c2014-02-07 18:05:11 +05303656 //vos_atomic_set( (uintptr_t*)&pTLCb->tlMgmtFrmClient.vosPendingDataBuff,
3657 // (uintptr_t)NULL);
Jeff Johnson295189b2012-06-20 16:38:30 -07003658
3659 //vos_pkt_get_user_data_ptr( vosTempBuff, VOS_PKT_USER_DATA_ID_TL,
3660 // (v_PVOID_t)&pfnTxComp);
3661
3662 /*it should never be NULL - default handler should be registered if none*/
3663 //if ( NULL == pfnTxComp )
3664 //{
3665 // VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3666 // "NULL pointer to Tx Complete on WLANTL_TxMgmtFrm");
3667 // VOS_ASSERT(0);
3668 // return VOS_STATUS_E_FAULT;
3669 //}
3670
3671 //pfnTxComp( pvosGCtx, vosTempBuff, VOS_STATUS_E_RESOURCES );
3672 //return VOS_STATUS_E_BUSY;
3673
3674
3675 //pfnCompTxFunc( pvosGCtx, vosFrmBuf, VOS_STATUS_E_RESOURCES);
3676 return VOS_STATUS_E_RESOURCES;
3677 }
3678
3679
3680 /*------------------------------------------------------------------------
3681 Check if BD header was build, if not construct
3682 ------------------------------------------------------------------------*/
3683 if ( NULL == pvBDHeader )
3684 {
3685 v_MACADDR_t* pvAddr2MacAddr;
3686 v_U8_t uQosHdr = VOS_FALSE;
3687
3688 /* Get address 2 of Mangement Frame to give to WLANHAL_FillTxBd */
3689 vosStatus = vos_pkt_peek_data( vosFrmBuf,
3690 WLANTL_MAC_ADDR_ALIGN(1) + VOS_MAC_ADDR_SIZE,
3691 (v_PVOID_t)&pvAddr2MacAddr, VOS_MAC_ADDR_SIZE);
3692
3693 if ( VOS_STATUS_SUCCESS != vosStatus )
3694 {
3695 TLLOGP(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_FATAL,
3696 "WLAN TL:Failed while attempting to get addr2 %d", vosStatus));
3697 return vosStatus;
3698 }
Gopichand Nakkala0f3eb5c2013-05-07 16:48:38 +05303699
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003700 /* ESE IAPP/TDLS Frame which are data frames but technically used
Jeff Johnson295189b2012-06-20 16:38:30 -07003701 * for management functionality comes through route.
3702 */
3703 if (WLANTL_IS_QOS_DATA_FRAME(wFrmType)) \
3704 {
3705 uQosHdr = VOS_TRUE;
3706 }
Siddharth Bhal4551b102014-10-09 21:36:36 +05303707
3708 if (WLANTL_IS_PROBE_REQ(wFrmType))
3709 {
3710 if (VOS_TRUE == vos_mem_compare((v_VOID_t*) pvAddr2MacAddr,
3711 (v_VOID_t*) &pTLCb->spoofMacAddr.spoofMac, VOS_MAC_ADDRESS_LEN))
3712 {
3713 pvAddr2MacAddr = (v_PVOID_t)pTLCb->spoofMacAddr.selfMac.bytes;
3714 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
3715 "TL: using self sta addr to get staidx for spoofed probe req "
3716 MAC_ADDRESS_STR, MAC_ADDR_ARRAY(pvAddr2MacAddr->bytes));
3717 }
3718 }
3719
Jeff Johnson295189b2012-06-20 16:38:30 -07003720 /*----------------------------------------------------------------------
3721 Call WDA to build TX header
3722 ----------------------------------------------------------------------*/
3723 vosStatus = WDA_DS_BuildTxPacketInfo( pvosGCtx, vosFrmBuf , &vDestMacAddr,
3724 1 /* always 802.11 frames*/, &usPktLen, uQosHdr /*qos not enabled !!!*/,
Siddharth Bhal4551b102014-10-09 21:36:36 +05303725 0 /* WDS off */, 0, wFrmType, pvAddr2MacAddr, ucTid,
Sravan Kumar Kairamd9e8cbb2017-01-17 12:17:28 +05303726 ucAckResponse, usTimeStamp, 0, 0, 0, ucTxBdToken);
Jeff Johnson295189b2012-06-20 16:38:30 -07003727
3728
3729 if ( !VOS_IS_STATUS_SUCCESS(vosStatus) )
3730 {
3731 TLLOGP(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_FATAL,
3732 "WLAN TL:Failed while attempting to build TX header %d", vosStatus));
3733 return vosStatus;
3734 }
3735 }/* if BD header not present */
3736
3737 /*------------------------------------------------------------------------
3738 Save buffer and notify BAL; no lock is needed if the above restriction
3739 is met
3740 Save the tx complete fnct pointer as tl specific data in the vos buffer
3741 ------------------------------------------------------------------------*/
3742 if ( NULL != pfnCompTxFunc )
3743 {
3744 vos_pkt_set_user_data_ptr( vosFrmBuf, VOS_PKT_USER_DATA_ID_TL,
3745 (v_PVOID_t)pfnCompTxFunc);
3746 }
3747 else
3748 {
3749 vos_pkt_set_user_data_ptr( vosFrmBuf, VOS_PKT_USER_DATA_ID_TL,
3750 (v_PVOID_t)WLANTL_TxCompDefaultCb);
3751
3752 }
Arun Kumar Khandavalli0af8d3c2014-02-07 18:05:11 +05303753 vos_atomic_set( (uintptr_t*)&pTLCb->tlMgmtFrmClient.vosPendingDataBuff,
3754 (uintptr_t)vosFrmBuf);
Jeff Johnson295189b2012-06-20 16:38:30 -07003755
3756 /*------------------------------------------------------------------------
3757 Check if thre are enough resources for transmission and tx is not
3758 suspended.
3759 ------------------------------------------------------------------------*/
3760 if ( pTLCb->uResCount >= WDA_TLI_MIN_RES_MF )
3761 {
3762 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
3763 "WLAN TL:Issuing Xmit start request to BAL for MGMT"));
3764 vosStatus = WDA_DS_StartXmit(pvosGCtx);
3765 if(VOS_STATUS_SUCCESS != vosStatus)
3766 {
3767 TLLOGP(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_FATAL,
3768 "WLAN TL:WDA_DS_StartXmit fails. vosStatus %d", vosStatus));
Arun Kumar Khandavalli0af8d3c2014-02-07 18:05:11 +05303769 vos_atomic_set( (uintptr_t*)&pTLCb->tlMgmtFrmClient.vosPendingDataBuff,0);
Jeff Johnson295189b2012-06-20 16:38:30 -07003770 }
3771 return vosStatus;
3772
3773 }
3774 else
3775 {
3776 /*---------------------------------------------------------------------
3777 No error code is sent because TL will resume tx autonomously if
3778 resources become available or tx gets resumed
3779 ---------------------------------------------------------------------*/
3780 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
3781 "WLAN TL:Request to send for Mgmt Frm but condition not met. Res: %d",
3782 pTLCb->uResCount));
3783 }
3784
3785 return VOS_STATUS_SUCCESS;
3786}/* WLANTL_TxMgmtFrm */
3787
3788/*----------------------------------------------------------------------------
3789 INTERACTION WITH HAL
3790 ---------------------------------------------------------------------------*/
3791
3792/*==========================================================================
3793
3794 FUNCTION WLANTL_ResetNotification
3795
3796 DESCRIPTION
3797 HAL notifies TL when the module is being reset.
3798 Currently not used.
3799
3800 DEPENDENCIES
3801
3802 PARAMETERS
3803
3804 IN
3805 pvosGCtx: pointer to the global vos context; a handle to TL's
3806 control block can be extracted from its context
3807
3808
3809 RETURN VALUE
3810 The result code associated with performing the operation
3811
3812 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
3813 page fault
3814 VOS_STATUS_SUCCESS: Everything is good :)
3815
3816 SIDE EFFECTS
3817
3818============================================================================*/
3819VOS_STATUS
3820WLANTL_ResetNotification
3821(
3822 v_PVOID_t pvosGCtx
3823)
3824{
3825 WLANTL_CbType* pTLCb = NULL;
3826 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
3827
3828 /*------------------------------------------------------------------------
3829 Sanity check
3830 Extract TL control block
3831 ------------------------------------------------------------------------*/
3832 pTLCb = VOS_GET_TL_CB(pvosGCtx);
3833 if ( NULL == pTLCb )
3834 {
3835 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3836 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_ResetNotification"));
3837 return VOS_STATUS_E_FAULT;
3838 }
3839
3840 WLANTL_CleanCB(pTLCb, 1 /*empty all queues and pending packets*/);
3841 return VOS_STATUS_SUCCESS;
3842}/* WLANTL_ResetNotification */
3843
3844/*==========================================================================
3845
3846 FUNCTION WLANTL_SuspendDataTx
3847
3848 DESCRIPTION
3849 HAL calls this API when it wishes to suspend transmission for a
3850 particular STA.
3851
3852 DEPENDENCIES
3853 The STA for which the request is made must be first registered with
3854 TL by HDD.
3855
3856 RESTRICTION: In case of a suspend, the flag write and read will not be
3857 locked: worst case scenario one more packet can get
3858 through before the flag gets updated (we can make this
3859 write atomic as well to guarantee consistency)
3860
3861 PARAMETERS
3862
3863 IN
3864 pvosGCtx: pointer to the global vos context; a handle to TL's
3865 control block can be extracted from its context
3866 pucSTAId: identifier of the station for which the request is made;
3867 a value of NULL assumes suspend on all active station
3868 pfnSuspendTxCB: pointer to the suspend result notification in case the
3869 call is asynchronous
3870
3871
3872 RETURN VALUE
3873 The result code associated with performing the operation
3874
3875 VOS_STATUS_E_FAULT: Station ID is outside array boundaries or pointer
3876 to TL cb is NULL ; access would cause a page fault
3877 VOS_STATUS_E_EXISTS: Station was not registered
3878 VOS_STATUS_SUCCESS: Everything is good :)
3879
3880 SIDE EFFECTS
3881
3882============================================================================*/
3883
3884VOS_STATUS
3885WLANTL_SuspendDataTx
3886(
3887 v_PVOID_t pvosGCtx,
3888 v_U8_t* pucSTAId,
3889 WLANTL_SuspendCBType pfnSuspendTx
3890)
3891{
3892 WLANTL_CbType* pTLCb = NULL;
3893 vos_msg_t vosMsg;
Jeff Johnson295189b2012-06-20 16:38:30 -07003894
3895 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
3896
3897 /*------------------------------------------------------------------------
3898 Sanity check
3899 Extract TL control block
3900 ------------------------------------------------------------------------*/
3901 pTLCb = VOS_GET_TL_CB(pvosGCtx);
Hoonki Lee14621352013-04-16 17:51:19 -07003902 if ( NULL == pTLCb )
Jeff Johnson295189b2012-06-20 16:38:30 -07003903 {
3904 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3905 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_SuspendDataTx"));
3906 return VOS_STATUS_E_FAULT;
3907 }
3908
3909 /*------------------------------------------------------------------------
3910 Check the type of request: generic suspend, or per station suspend
3911 ------------------------------------------------------------------------*/
Hoonki Lee14621352013-04-16 17:51:19 -07003912 if (NULL == pucSTAId)
Jeff Johnson295189b2012-06-20 16:38:30 -07003913 {
3914 /* General Suspend Request received */
3915 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
3916 "WLAN TL:General suspend requested"));
Hoonki Lee14621352013-04-16 17:51:19 -07003917 vos_atomic_set_U8( &pTLCb->ucTxSuspended, 1);
Jeff Johnson295189b2012-06-20 16:38:30 -07003918 vosMsg.reserved = WLAN_MAX_STA_COUNT;
3919 }
3920 else
3921 {
Hoonki Lee14621352013-04-16 17:51:19 -07003922 if ( WLANTL_STA_ID_INVALID( *pucSTAId ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07003923 {
Hoonki Lee14621352013-04-16 17:51:19 -07003924 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3925 "WLAN TL:Invalid station id %d requested on WLANTL_SuspendDataTx", *pucSTAId));
3926 return VOS_STATUS_E_FAULT;
3927 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003928
Gopichand Nakkalae5fef6c2013-06-19 18:04:23 +05303929 if ( NULL == pTLCb->atlSTAClients[*pucSTAId] )
3930 {
3931 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3932 "WLAN TL:Invalid pTLCb->atlSTAClients pointer for STA Id :%d on "
3933 "WLANTL_SuspendDataTx", *pucSTAId));
3934 return VOS_STATUS_E_FAULT;
3935 }
3936
3937 if ( 0 == pTLCb->atlSTAClients[*pucSTAId]->ucExists )
Hoonki Lee14621352013-04-16 17:51:19 -07003938 {
3939 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3940 "WLAN TL:Station %d was not previously registered on WLANTL_SuspendDataTx", *pucSTAId));
3941 return VOS_STATUS_E_EXISTS;
3942 }
3943
3944 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
3945 "WLAN TL:Suspend request for station: %d", *pucSTAId));
3946 vos_atomic_set_U8( &pTLCb->atlSTAClients[*pucSTAId]->ucTxSuspended, 1);
Jeff Johnson295189b2012-06-20 16:38:30 -07003947 vosMsg.reserved = *pucSTAId;
3948 }
3949
3950 /*------------------------------------------------------------------------
3951 Serialize request through TX thread
3952 ------------------------------------------------------------------------*/
3953 vosMsg.type = WLANTL_TX_SIG_SUSPEND;
3954 vosMsg.bodyptr = (v_PVOID_t)pfnSuspendTx;
3955
Katya Nigam42e16e82014-02-04 16:28:55 +05303956 MTRACE(vos_trace(VOS_MODULE_ID_TL, TRACE_CODE_TL_SUSPEND_DATA_TX,
3957 vosMsg.reserved , 0 ));
3958
Jeff Johnson295189b2012-06-20 16:38:30 -07003959 if(!VOS_IS_STATUS_SUCCESS(vos_tx_mq_serialize( VOS_MQ_ID_TL, &vosMsg)))
3960 {
3961 VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003962 " %s fails to post message", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003963 }
3964
3965 return VOS_STATUS_SUCCESS;
3966}/* WLANTL_SuspendDataTx */
3967
3968/*==========================================================================
3969
3970 FUNCTION WLANTL_ResumeDataTx
3971
3972 DESCRIPTION
3973 Called by HAL to resume data transmission for a given STA.
3974
3975 WARNING: If a station was individually suspended a global resume will
3976 not resume that station
3977
3978 DEPENDENCIES
3979
3980 PARAMETERS
3981
3982 IN
3983 pvosGCtx: pointer to the global vos context; a handle to TL's
3984 control block can be extracted from its context
3985 pucSTAId: identifier of the station which is being resumed; NULL
3986 translates into global resume
3987
3988 RETURN VALUE
3989 The result code associated with performing the operation
3990
3991 VOS_STATUS_E_FAULT: Station ID is outside array boundaries or pointer
3992 to TL cb is NULL ; access would cause a page fault
3993 VOS_STATUS_E_EXISTS: Station was not registered
3994 VOS_STATUS_SUCCESS: Everything is good :)
3995
3996 SIDE EFFECTS
3997
3998============================================================================*/
3999
4000VOS_STATUS
4001WLANTL_ResumeDataTx
4002(
4003 v_PVOID_t pvosGCtx,
4004 v_U8_t* pucSTAId
4005)
4006{
4007 WLANTL_CbType* pTLCb = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004008 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
4009
4010 /*------------------------------------------------------------------------
4011 Sanity check
4012 Extract TL control block
4013 ------------------------------------------------------------------------*/
4014 pTLCb = VOS_GET_TL_CB(pvosGCtx);
Hoonki Lee14621352013-04-16 17:51:19 -07004015 if ( NULL == pTLCb )
Jeff Johnson295189b2012-06-20 16:38:30 -07004016 {
4017 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
4018 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_ResumeDataTx"));
4019 return VOS_STATUS_E_FAULT;
4020 }
4021
Jeff Johnson295189b2012-06-20 16:38:30 -07004022 /*------------------------------------------------------------------------
4023 Check to see the type of resume
4024 ------------------------------------------------------------------------*/
Hoonki Lee14621352013-04-16 17:51:19 -07004025 if ( NULL == pucSTAId )
Jeff Johnson295189b2012-06-20 16:38:30 -07004026 {
Katya Nigam42e16e82014-02-04 16:28:55 +05304027 MTRACE(vos_trace(VOS_MODULE_ID_TL, TRACE_CODE_TL_RESUME_DATA_TX,
4028 41 , 0 ));
4029
Jeff Johnson295189b2012-06-20 16:38:30 -07004030 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
4031 "WLAN TL:General resume requested"));
4032 vos_atomic_set_U8( &pTLCb->ucTxSuspended, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004033 }
4034 else
4035 {
Katya Nigam42e16e82014-02-04 16:28:55 +05304036 MTRACE(vos_trace(VOS_MODULE_ID_TL, TRACE_CODE_TL_RESUME_DATA_TX,
4037 *pucSTAId , 0 ));
4038
Hoonki Lee14621352013-04-16 17:51:19 -07004039 if ( WLANTL_STA_ID_INVALID( *pucSTAId ))
Jeff Johnson295189b2012-06-20 16:38:30 -07004040 {
Hoonki Lee14621352013-04-16 17:51:19 -07004041 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
4042 "WLAN TL:Invalid station id %d requested on WLANTL_ResumeDataTx", *pucSTAId));
4043 return VOS_STATUS_E_FAULT;
4044 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004045
Gopichand Nakkalae5fef6c2013-06-19 18:04:23 +05304046 if ( NULL == pTLCb->atlSTAClients[*pucSTAId] )
4047 {
4048 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
4049 "WLAN TL:Invalid pTLCb->atlSTAClients pointer for STA Id :%d on "
4050 "WLANTL_ResumeDataTx", *pucSTAId));
4051 return VOS_STATUS_E_FAULT;
4052 }
4053
4054 if ( 0 == pTLCb->atlSTAClients[*pucSTAId]->ucExists )
Hoonki Lee14621352013-04-16 17:51:19 -07004055 {
4056 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
4057 "WLAN TL:Station %d was not previously registered on WLANTL_ResumeDataTx", *pucSTAId));
4058 return VOS_STATUS_E_EXISTS;
4059 }
4060
4061 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
4062 "WLAN TL:Resume request for station: %d", *pucSTAId));
4063 vos_atomic_set_U8( &pTLCb->atlSTAClients[*pucSTAId]->ucTxSuspended, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004064 }
4065
4066 /*------------------------------------------------------------------------
4067 Resuming transmission
4068 ------------------------------------------------------------------------*/
Hoonki Lee14621352013-04-16 17:51:19 -07004069 if (( pTLCb->uResCount >= WDA_TLI_MIN_RES_MF ) &&
4070 ( 0 == pTLCb->ucTxSuspended ))
Jeff Johnson295189b2012-06-20 16:38:30 -07004071 {
4072 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
4073 "WLAN TL:Resuming transmission"));
4074 return WDA_DS_StartXmit(pvosGCtx);
4075 }
4076
4077 return VOS_STATUS_SUCCESS;
4078}/* WLANTL_ResumeDataTx */
4079
4080/*==========================================================================
4081 FUNCTION WLANTL_SuspendCB
4082
4083 DESCRIPTION
4084 Callback function for serializing Suspend signal through Tx thread
4085
4086 DEPENDENCIES
4087 Just notify HAL that suspend in TL is complete.
4088
4089 PARAMETERS
4090
4091 IN
4092 pvosGCtx: pointer to the global vos context; a handle to TL's
4093 control block can be extracted from its context
4094 pUserData: user data sent with the callback
4095
4096 RETURN VALUE
4097 The result code associated with performing the operation
4098
4099 VOS_STATUS_E_INVAL: invalid input parameters
4100 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
4101 page fault
4102 VOS_STATUS_SUCCESS: Everything is good :)
4103
4104
4105 SIDE EFFECTS
4106
4107============================================================================*/
4108VOS_STATUS
4109WLANTL_SuspendCB
4110(
4111 v_PVOID_t pvosGCtx,
4112 WLANTL_SuspendCBType pfnSuspendCB,
4113 v_U16_t usReserved
4114)
4115{
4116 WLANTL_CbType* pTLCb = NULL;
4117 v_U8_t ucSTAId = (v_U8_t)usReserved;
4118 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
4119
4120 /*------------------------------------------------------------------------
4121 Sanity check
4122 ------------------------------------------------------------------------*/
4123 if ( NULL == pfnSuspendCB )
4124 {
4125 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
4126 "WLAN TL: No Call back processing requested WLANTL_SuspendCB"));
4127 return VOS_STATUS_SUCCESS;
4128 }
4129
4130 /*------------------------------------------------------------------------
4131 Extract TL control block
4132 ------------------------------------------------------------------------*/
4133 pTLCb = VOS_GET_TL_CB(pvosGCtx);
4134 if ( NULL == pTLCb )
4135 {
4136 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
4137 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_SuspendCB"));
4138 return VOS_STATUS_E_FAULT;
4139 }
4140
4141 if ( WLANTL_STA_ID_INVALID( ucSTAId ) )
4142 {
4143 pfnSuspendCB(pvosGCtx, NULL, VOS_STATUS_SUCCESS);
4144 }
4145 else
4146 {
4147 pfnSuspendCB(pvosGCtx, &ucSTAId, VOS_STATUS_SUCCESS);
4148 }
4149
4150 return VOS_STATUS_SUCCESS;
4151}/*WLANTL_SuspendCB*/
4152
4153
4154/*----------------------------------------------------------------------------
4155 CLIENT INDEPENDENT INTERFACE
4156 ---------------------------------------------------------------------------*/
4157
4158/*==========================================================================
4159
4160 FUNCTION WLANTL_GetTxPktCount
4161
4162 DESCRIPTION
4163 TL will provide the number of transmitted packets counted per
4164 STA per TID.
4165
4166 DEPENDENCIES
4167
4168 PARAMETERS
4169
4170 IN
4171 pvosGCtx: pointer to the global vos context; a handle to TL's
4172 control block can be extracted from its context
4173 ucSTAId: identifier of the station
4174 ucTid: identifier of the tspec
4175
4176 OUT
4177 puTxPktCount: the number of packets tx packet for this STA and TID
4178
4179 RETURN VALUE
4180 The result code associated with performing the operation
4181
4182 VOS_STATUS_E_INVAL: Input parameters are invalid
4183 VOS_STATUS_E_FAULT: Station ID is outside array boundaries or pointer
4184 to TL cb is NULL ; access would cause a page fault
4185 VOS_STATUS_E_EXISTS: Station was not registered
4186 VOS_STATUS_SUCCESS: Everything is good :)
4187
4188 SIDE EFFECTS
4189
4190============================================================================*/
4191VOS_STATUS
4192WLANTL_GetTxPktCount
4193(
4194 v_PVOID_t pvosGCtx,
4195 v_U8_t ucSTAId,
4196 v_U8_t ucTid,
4197 v_U32_t* puTxPktCount
4198)
4199{
4200 WLANTL_CbType* pTLCb = NULL;
4201 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
4202
4203 /*------------------------------------------------------------------------
4204 Sanity check
4205 ------------------------------------------------------------------------*/
4206 if ( NULL == puTxPktCount )
4207 {
4208 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
4209 "WLAN TL:Invalid parameter sent on WLANTL_GetTxPktCount"));
4210 return VOS_STATUS_E_INVAL;
4211 }
4212
4213 if ( WLANTL_STA_ID_INVALID( ucSTAId ) || WLANTL_TID_INVALID( ucTid) )
4214 {
4215 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
4216 "WLAN TL:Invalid station id %d/tid %d requested on WLANTL_GetTxPktCount",
4217 ucSTAId, ucTid));
4218 return VOS_STATUS_E_FAULT;
4219 }
4220
4221 /*------------------------------------------------------------------------
4222 Extract TL control block and check if station exists
4223 ------------------------------------------------------------------------*/
4224 pTLCb = VOS_GET_TL_CB(pvosGCtx);
4225 if ( NULL == pTLCb )
4226 {
4227 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
4228 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_GetTxPktCount"));
4229 return VOS_STATUS_E_FAULT;
4230 }
4231
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304232 if ( NULL == pTLCb->atlSTAClients[ucSTAId] )
4233 {
4234 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
4235 "WLAN TL:Client Memory was not allocated on %s", __func__));
4236 return VOS_STATUS_E_FAILURE;
4237 }
4238
4239 if ( 0 == pTLCb->atlSTAClients[ucSTAId]->ucExists )
Jeff Johnson295189b2012-06-20 16:38:30 -07004240 {
4241 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
4242 "WLAN TL:Station was not previously registered on WLANTL_GetTxPktCount %d",
4243 ucSTAId));
4244 return VOS_STATUS_E_EXISTS;
4245 }
4246
4247 /*------------------------------------------------------------------------
4248 Return data
4249 ------------------------------------------------------------------------*/
4250 //VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_MED,
4251 // "WLAN TL:Requested tx packet count for STA: %d, TID: %d",
4252 // ucSTAId, ucTid);
4253
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304254 *puTxPktCount = pTLCb->atlSTAClients[ucSTAId]->auTxCount[ucTid];
Jeff Johnson295189b2012-06-20 16:38:30 -07004255
4256 return VOS_STATUS_SUCCESS;
4257}/* WLANTL_GetTxPktCount */
4258
4259/*==========================================================================
4260
4261 FUNCTION WLANTL_GetRxPktCount
4262
4263 DESCRIPTION
4264 TL will provide the number of received packets counted per
4265 STA per TID.
4266
4267 DEPENDENCIES
4268
4269 PARAMETERS
4270
4271 IN
4272 pvosGCtx: pointer to the global vos context; a handle to TL's
4273 control block can be extracted from its context
4274 ucSTAId: identifier of the station
4275 ucTid: identifier of the tspec
4276
4277 OUT
4278 puTxPktCount: the number of packets rx packet for this STA and TID
4279
4280 RETURN VALUE
4281 The result code associated with performing the operation
4282
4283 VOS_STATUS_E_INVAL: Input parameters are invalid
4284 VOS_STATUS_E_FAULT: Station ID is outside array boundaries or pointer
4285 to TL cb is NULL ; access would cause a page fault
4286 VOS_STATUS_E_EXISTS: Station was not registered
4287 VOS_STATUS_SUCCESS: Everything is good :)
4288
4289 SIDE EFFECTS
4290
4291============================================================================*/
4292VOS_STATUS
4293WLANTL_GetRxPktCount
4294(
4295 v_PVOID_t pvosGCtx,
4296 v_U8_t ucSTAId,
4297 v_U8_t ucTid,
4298 v_U32_t* puRxPktCount
4299)
4300{
4301 WLANTL_CbType* pTLCb = NULL;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304302 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004303 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
4304
4305 /*------------------------------------------------------------------------
4306 Sanity check
4307 ------------------------------------------------------------------------*/
4308 if ( NULL == puRxPktCount )
4309 {
4310 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
4311 "WLAN TL:Invalid parameter sent on WLANTL_GetRxPktCount"));
4312 return VOS_STATUS_E_INVAL;
4313 }
4314
4315 if ( WLANTL_STA_ID_INVALID( ucSTAId ) || WLANTL_TID_INVALID( ucTid) )
4316 {
4317 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
4318 "WLAN TL:Invalid station id %d/tid %d requested on WLANTL_GetRxPktCount",
4319 ucSTAId, ucTid));
4320 return VOS_STATUS_E_FAULT;
4321 }
4322
4323 /*------------------------------------------------------------------------
4324 Extract TL control block and existance
4325 ------------------------------------------------------------------------*/
4326 pTLCb = VOS_GET_TL_CB(pvosGCtx);
4327 if ( NULL == pTLCb )
4328 {
4329 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
4330 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_GetRxPktCount"));
4331 return VOS_STATUS_E_FAULT;
4332 }
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304333 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
Jeff Johnson295189b2012-06-20 16:38:30 -07004334
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304335 if ( NULL == pClientSTA )
4336 {
4337 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
4338 "WLAN TL:Client Memory was not allocated on %s", __func__));
4339 return VOS_STATUS_E_FAILURE;
4340 }
4341
4342 if ( 0 == pClientSTA->ucExists )
Jeff Johnson295189b2012-06-20 16:38:30 -07004343 {
4344 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
4345 "WLAN TL:Station was not previously registered on WLANTL_GetRxPktCount"));
4346 return VOS_STATUS_E_EXISTS;
4347 }
4348
4349 /*------------------------------------------------------------------------
4350 Return data
4351 ------------------------------------------------------------------------*/
4352 TLLOG3(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_MED,
4353 "WLAN TL:Requested rx packet count for STA: %d, TID: %d",
4354 ucSTAId, ucTid));
4355
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304356 *puRxPktCount = pClientSTA->auRxCount[ucTid];
Jeff Johnson295189b2012-06-20 16:38:30 -07004357
4358 return VOS_STATUS_SUCCESS;
4359}/* WLANTL_GetRxPktCount */
4360
Jeff Johnson295189b2012-06-20 16:38:30 -07004361VOS_STATUS
4362WLANTL_TxFCFrame
4363(
4364 v_PVOID_t pvosGCtx
4365);
Karthick S79bbe822015-07-14 15:28:08 +05304366
4367/*==========================================================================
4368
4369 FUNCTION WLANTL_IsEAPOLPending
4370
4371 DESCRIPTION
4372
4373 HDD calls this function when hdd_tx_timeout occurs. This checks whether
4374 EAPOL is pending.
4375
4376 DEPENDENCIES
4377
4378 HDD must have registered with TL at least one STA before this function
4379 can be called.
4380
4381 PARAMETERS
4382
4383 IN
4384 pvosGCtx: pointer to the global vos context
4385
4386 RETURN VALUE
4387
4388 The result code associated with performing the operation
4389
4390 Success : Indicates EAPOL frame is pending and sta is in connected state
4391
4392 Failure : EAPOL frame is not pending
4393
4394 SIDE EFFECTS
4395============================================================================*/
4396VOS_STATUS
4397WLANTL_IsEAPOLPending
4398(
4399 v_PVOID_t pvosGCtx
4400)
4401{
4402 WLANTL_CbType* pTLCb = NULL;
4403 v_U32_t i = 0;
4404 /*------------------------------------------------------------------------
4405 Sanity check
4406 Extract TL control block
4407 ------------------------------------------------------------------------*/
4408 pTLCb = VOS_GET_TL_CB(pvosGCtx);
4409 if (NULL == pTLCb)
4410 {
4411 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
4412 "WLAN TL:Invalid TL pointer for pvosGCtx"));
4413 return VOS_STATUS_E_FAILURE;
4414 }
4415 /*---------------------------------------------------------------------
4416 Check to see if there was any EAPOL packet is pending
4417 *--------------------------------------------------------------------*/
4418 for ( i = 0; i < WLAN_MAX_STA_COUNT; i++)
4419 {
4420 if ((NULL != pTLCb->atlSTAClients[i]) &&
4421 (pTLCb->atlSTAClients[i]->ucExists) &&
4422 (0 == pTLCb->atlSTAClients[i]->ucTxSuspended) &&
4423 (WLANTL_STA_CONNECTED == pTLCb->atlSTAClients[i]->tlState) &&
4424 (pTLCb->atlSTAClients[i]->ucPktPending)
4425 )
4426 return VOS_STATUS_SUCCESS;
4427 }
4428 return VOS_STATUS_E_FAILURE;
4429}
4430
Jeff Johnson295189b2012-06-20 16:38:30 -07004431/*============================================================================
4432 TL INTERNAL API DEFINITION
4433============================================================================*/
4434
4435/*==========================================================================
4436
4437 FUNCTION WLANTL_GetFrames
4438
4439 DESCRIPTION
4440
4441 BAL calls this function at the request of the lower bus interface.
4442 When this request is being received TL will retrieve packets from HDD
4443 in accordance with the priority rules and the count supplied by BAL.
4444
4445 DEPENDENCIES
4446
4447 HDD must have registered with TL at least one STA before this function
4448 can be called.
4449
4450 PARAMETERS
4451
4452 IN
4453 pvosGCtx: pointer to the global vos context; a handle to TL's
4454 or BAL's control block can be extracted from its context
4455 uSize: maximum size accepted by the lower layer
4456 uFlowMask TX flow control mask for Prima. Each bit is defined as
4457 WDA_TXFlowEnumType
4458
4459 OUT
4460 vosDataBuff: it will contain a pointer to the first buffer supplied
4461 by TL, if there is more than one packet supplied, TL
4462 will chain them through vOSS buffers
4463
4464 RETURN VALUE
4465
4466 The result code associated with performing the operation
4467
4468 1 or more: number of required resources if there are still frames to fetch
4469 0 : error or HDD queues are drained
4470
4471 SIDE EFFECTS
4472
4473 NOTE
4474
4475 Featurized uFlowMask. If we want to remove featurization, we need to change
4476 BAL on Volans.
4477
4478============================================================================*/
4479v_U32_t
4480WLANTL_GetFrames
4481(
4482 v_PVOID_t pvosGCtx,
4483 vos_pkt_t **ppFrameDataBuff,
4484 v_U32_t uSize,
Jeff Johnson295189b2012-06-20 16:38:30 -07004485 v_U8_t uFlowMask,
Jeff Johnson295189b2012-06-20 16:38:30 -07004486 v_BOOL_t* pbUrgent
4487)
4488{
4489 vos_pkt_t** pvosDataBuff = (vos_pkt_t**)ppFrameDataBuff;
4490 WLANTL_CbType* pTLCb = NULL;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304491 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004492 v_U32_t uRemaining = uSize;
4493 vos_pkt_t* vosRoot;
4494 vos_pkt_t* vosTempBuf;
4495 WLANTL_STAFuncType pfnSTAFsm;
4496 v_U16_t usPktLen;
4497 v_U32_t uResLen;
4498 v_U8_t ucSTAId;
4499 v_U8_t ucAC;
4500 vos_pkt_t* vosDataBuff;
4501 v_U32_t uTotalPktLen;
4502 v_U32_t i=0;
Tushnim Bhattacharyya39a8f182013-02-20 18:10:30 -08004503 v_U32_t j=0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004504 v_U32_t ucResult = 0;
4505 VOS_STATUS vosStatus;
4506 WLANTL_STAEventType wSTAEvent;
4507 tBssSystemRole systemRole;
4508 tpAniSirGlobal pMac;
4509 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
4510
4511 /*------------------------------------------------------------------------
4512 Sanity check
4513 Extract TL control block
4514 ------------------------------------------------------------------------*/
4515 pTLCb = VOS_GET_TL_CB(pvosGCtx);
4516 if (( NULL == pTLCb ) || ( NULL == pvosDataBuff ))
4517 {
4518 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
4519 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_ChangeSTAState"));
4520 return ucResult;
4521 }
4522
4523 pMac = vos_get_context(VOS_MODULE_ID_PE, pvosGCtx);
4524 if ( NULL == pMac )
4525 {
4526 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004527 "%s: Invalid pMac", __func__));
Jeff Johnson295189b2012-06-20 16:38:30 -07004528 return ucResult;
4529 }
4530
4531 vosDataBuff = pTLCb->vosDummyBuf; /* Just to avoid checking for NULL at
4532 each iteration */
4533
Jeff Johnson295189b2012-06-20 16:38:30 -07004534 pTLCb->uResCount = uSize;
Jeff Johnson295189b2012-06-20 16:38:30 -07004535
4536 /*-----------------------------------------------------------------------
4537 Save the root as we will walk this chain as we fill it
4538 -----------------------------------------------------------------------*/
4539 vosRoot = vosDataBuff;
4540
4541 /*-----------------------------------------------------------------------
4542 There is still data - until FSM function says otherwise
4543 -----------------------------------------------------------------------*/
4544 pTLCb->bUrgent = FALSE;
4545
Jeff Johnson295189b2012-06-20 16:38:30 -07004546 while (( pTLCb->tlConfigInfo.uMinFramesProcThres < pTLCb->uResCount ) &&
4547 ( 0 < uRemaining ))
Jeff Johnson295189b2012-06-20 16:38:30 -07004548 {
4549 systemRole = wdaGetGlobalSystemRole(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -07004550#ifdef WLAN_SOFTAP_FLOWCTRL_EN
4551/* FIXME: The code has been disabled since it is creating issues in power save */
4552 if (eSYSTEM_AP_ROLE == systemRole)
4553 {
4554 if (pTLCb->done_once == 0 && NULL == pTLCb->vosTxFCBuf)
4555 {
4556 WLANTL_TxFCFrame (pvosGCtx);
4557 pTLCb->done_once ++;
4558 }
4559 }
4560 if ( NULL != pTLCb->vosTxFCBuf )
4561 {
4562 //there is flow control packet waiting to be sent
4563 WDA_TLI_PROCESS_FRAME_LEN( pTLCb->vosTxFCBuf, usPktLen, uResLen, uTotalPktLen);
4564
4565 if ( ( pTLCb->uResCount > uResLen ) &&
Jeff Johnson9b5dc4d2013-02-22 21:28:47 -08004566 ( uRemaining > uTotalPktLen ) &&
4567 ( uFlowMask & ( 1 << WDA_TXFLOW_FC ) ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07004568 {
4569 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
4570 "WLAN TL:Chaining FC frame first on GetFrame"));
4571
4572 vos_pkt_chain_packet( vosDataBuff, pTLCb->vosTxFCBuf, 1 /*true*/ );
4573
Arun Kumar Khandavalli0af8d3c2014-02-07 18:05:11 +05304574 vos_atomic_set( (uintptr_t*)&pTLCb->vosTxFCBuf, (uintptr_t) NULL);
Jeff Johnson295189b2012-06-20 16:38:30 -07004575
4576 /*FC frames cannot be delayed*/
4577 pTLCb->bUrgent = TRUE;
4578
4579 /*Update remaining len from SSC */
4580 uRemaining -= (usPktLen + WDA_DXE_HEADER_SIZE);
4581
4582 /*Update resource count */
4583 pTLCb->uResCount -= uResLen;
4584 }
4585 else
4586 {
4587 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004588 "WLAN TL:send fc out of source %s", __func__));
Jeff Johnson295189b2012-06-20 16:38:30 -07004589 ucResult = ( pTLCb->uResCount > uResLen )?VOS_TRUE:VOS_FALSE;
4590 break; /* Out of resources or reached max len */
4591 }
4592 }
4593 else
4594#endif //WLAN_SOFTAP_FLOWCTRL_EN
Jeff Johnson295189b2012-06-20 16:38:30 -07004595
Jeff Johnson9b5dc4d2013-02-22 21:28:47 -08004596 if (( NULL != pTLCb->tlMgmtFrmClient.vosPendingDataBuff ) &&
4597 ( uFlowMask & ( 1 << WDA_TXFLOW_MGMT ) ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07004598 {
4599 WDA_TLI_PROCESS_FRAME_LEN( pTLCb->tlMgmtFrmClient.vosPendingDataBuff,
4600 usPktLen, uResLen, uTotalPktLen);
4601
Manjunathappa Prakashfb585462013-12-23 19:07:07 -08004602 if (usPktLen > WLANTL_MAX_ALLOWED_LEN)
4603 {
4604 usPktLen = WLANTL_MAX_ALLOWED_LEN;
4605 VOS_ASSERT(0);
4606 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004607
4608 if ( ( pTLCb->uResCount > uResLen ) &&
Jeff Johnson9b5dc4d2013-02-22 21:28:47 -08004609 ( uRemaining > uTotalPktLen ) &&
4610 ( uFlowMask & ( 1 << WDA_TXFLOW_MGMT ) ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07004611 {
4612 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
4613 "WLAN TL:Chaining management frame on GetFrame"));
4614
4615 vos_pkt_chain_packet( vosDataBuff,
4616 pTLCb->tlMgmtFrmClient.vosPendingDataBuff,
4617 1 /*true*/ );
4618
Arun Kumar Khandavalli0af8d3c2014-02-07 18:05:11 +05304619 vos_atomic_set( (uintptr_t*)&pTLCb->tlMgmtFrmClient.
4620 vosPendingDataBuff, (uintptr_t)NULL);
Jeff Johnson295189b2012-06-20 16:38:30 -07004621
4622 /*management frames cannot be delayed*/
4623 pTLCb->bUrgent = TRUE;
4624
4625 /*Update remaining len from SSC */
4626 uRemaining -= (usPktLen + WDA_DXE_HEADER_SIZE);
4627
4628 /*Update resource count */
4629 pTLCb->uResCount -= uResLen;
4630 }
4631 else
4632 {
4633 ucResult = ( pTLCb->uResCount > uResLen )?VOS_TRUE:VOS_FALSE;
4634 break; /* Out of resources or reached max len */
4635 }
4636 }
4637 else if (( pTLCb->tlBAPClient.vosPendingDataBuff ) &&
4638 ( WDA_TLI_MIN_RES_BAP <= pTLCb->uResCount ) &&
Gopichand Nakkala7e48ca72012-12-31 14:15:07 -08004639 ( 0 == pTLCb->ucTxSuspended ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07004640 {
4641 WDA_TLI_PROCESS_FRAME_LEN( pTLCb->tlBAPClient.vosPendingDataBuff,
4642 usPktLen, uResLen, uTotalPktLen);
4643
Manjunathappa Prakashfb585462013-12-23 19:07:07 -08004644 if (usPktLen > WLANTL_MAX_ALLOWED_LEN)
4645 {
4646 usPktLen = WLANTL_MAX_ALLOWED_LEN;
4647 VOS_ASSERT(0);
4648 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004649
4650 if ( ( pTLCb->uResCount > (uResLen + WDA_TLI_MIN_RES_MF ) ) &&
4651 ( uRemaining > uTotalPktLen ))
4652 {
4653 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
4654 "WLAN TL:Chaining BT-AMP frame on GetFrame"));
4655
4656 vos_pkt_chain_packet( vosDataBuff,
4657 pTLCb->tlBAPClient.vosPendingDataBuff,
4658 1 /*true*/ );
4659
4660 /*BAP frames cannot be delayed*/
4661 pTLCb->bUrgent = TRUE;
4662
Arun Kumar Khandavalli0af8d3c2014-02-07 18:05:11 +05304663 vos_atomic_set( (uintptr_t*)&pTLCb->tlBAPClient.vosPendingDataBuff,
4664 (uintptr_t) NULL);
Jeff Johnson295189b2012-06-20 16:38:30 -07004665
4666 /*Update remaining len from SSC */
4667 uRemaining -= (usPktLen + WDA_DXE_HEADER_SIZE);
4668
4669 /*Update resource count */
4670 pTLCb->uResCount -= uResLen;
4671 }
4672 else
4673 {
Jeff Johnson295189b2012-06-20 16:38:30 -07004674 ucResult = uResLen + WDA_TLI_MIN_RES_MF;
Jeff Johnson295189b2012-06-20 16:38:30 -07004675 break; /* Out of resources or reached max len */
4676 }
4677 }
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -07004678 /* note: this feature implemented only after WLAN_INGETRATED_SOC */
4679 /* search 'EAPOL_HI_PRIORITY' will show EAPOL HI_PRIORITY change in TL and WDI
4680 by default, EAPOL will be treated as higher priority, which means
4681 use mgmt_pool and DXE_TX_HI prority channel.
4682 this is introduced to address EAPOL failure under high background traffic
4683 with multi-channel concurrent mode. But this change works in SCC or standalone, too.
4684 see CR#387009 and WCNSOS-8
4685 */
4686 else if (( WDA_TLI_MIN_RES_MF <= pTLCb->uResCount )&&
4687 ( 0 == pTLCb->ucTxSuspended ) &&
4688 ( uFlowMask & ( 1 << WDA_TXFLOW_MGMT ) )
4689 )
4690 {
4691 vosTempBuf = NULL;
4692 /*---------------------------------------------------------------------
4693 Check to see if there was any EAPOL packet is pending
4694 *--------------------------------------------------------------------*/
4695 for ( i = 0; i < WLAN_MAX_STA_COUNT; i++)
4696 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304697 if ((NULL != pTLCb->atlSTAClients[i]) &&
4698 (pTLCb->atlSTAClients[i]->ucExists) &&
4699 (0 == pTLCb->atlSTAClients[i]->ucTxSuspended) &&
Tushnim Bhattacharyya39a8f182013-02-20 18:10:30 -08004700 (WLANTL_STA_CONNECTED == pTLCb->atlSTAClients[i]->tlState) &&
4701 (pTLCb->atlSTAClients[i]->ucPktPending)
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -07004702 )
4703 break;
4704 }
4705
4706 if (i >= WLAN_MAX_STA_COUNT)
4707 {
4708 /* No More to Serve Exit Get Frames */
4709 break;
4710 }
4711 /* Serve EAPOL frame with HI_FLOW_MASK */
4712 ucSTAId = i;
4713
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304714 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
4715
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05304716 MTRACE(vos_trace(VOS_MODULE_ID_TL,
4717 TRACE_CODE_TL_GET_FRAMES_EAPOL, ucSTAId, pClientSTA->tlState));
4718
4719 if (pClientSTA->wSTADesc.wSTAType == WLAN_STA_INFRA)
4720 {
4721 if(0 != pClientSTA->aucACMask[WLANTL_AC_HIGH_PRIO])
4722 {
4723 pClientSTA->ucCurrentAC = WLANTL_AC_HIGH_PRIO;
4724 pTLCb->uCurServedAC = WLANTL_AC_HIGH_PRIO;
4725 }
4726 else
4727 break;
4728 }
4729 else
4730 {
4731 for (j = WLANTL_MAX_AC ; j > 0; j--)
4732 {
4733 if (0 != pClientSTA->aucACMask[j-1])
4734 {
4735 pClientSTA->ucCurrentAC = j-1;
4736 pTLCb->uCurServedAC = j-1;
4737 break;
4738 }
4739 }
4740 }
4741
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -07004742 wSTAEvent = WLANTL_TX_EVENT;
4743
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304744 pfnSTAFsm = tlSTAFsm[pClientSTA->tlState].
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -07004745 pfnSTATbl[wSTAEvent];
4746
4747 if ( NULL != pfnSTAFsm )
4748 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304749 pClientSTA->ucNoMoreData = 0;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004750 vosStatus = pfnSTAFsm( pvosGCtx, ucSTAId, &vosTempBuf, VOS_FALSE);
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -07004751
4752 if (( VOS_STATUS_SUCCESS != vosStatus ) &&
4753 ( NULL != vosTempBuf ))
4754 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304755 pClientSTA->pfnSTATxComp( pvosGCtx, vosTempBuf, vosStatus );
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -07004756 vosTempBuf = NULL;
4757 break;
4758 }/* status success*/
4759 }
4760
4761 if (NULL != vosTempBuf)
4762 {
4763 WDA_TLI_PROCESS_FRAME_LEN( vosTempBuf, usPktLen, uResLen, uTotalPktLen);
4764
Manjunathappa Prakashfb585462013-12-23 19:07:07 -08004765 if (usPktLen > WLANTL_MAX_ALLOWED_LEN)
4766 {
4767 usPktLen = WLANTL_MAX_ALLOWED_LEN;
4768 VOS_ASSERT(0);
4769 }
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -07004770
4771 TLLOG4(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_LOW,
4772 "WLAN TL:Resources needed by frame: %d", uResLen));
4773
4774 if ( ( pTLCb->uResCount >= (uResLen + WDA_TLI_MIN_RES_MF ) ) &&
4775 ( uRemaining > uTotalPktLen )
4776 )
4777 {
4778 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
4779 "WLAN TL:Chaining data frame on GetFrame"));
4780
4781 vos_pkt_chain_packet( vosDataBuff, vosTempBuf, 1 /*true*/ );
4782
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -07004783 /*EAPOL frame cannot be delayed*/
4784 pTLCb->bUrgent = TRUE;
4785
4786 vosTempBuf = NULL;
4787
4788 /*Update remaining len from SSC */
4789 uRemaining -= (usPktLen + WDA_DXE_HEADER_SIZE);
4790
4791 /*Update resource count */
4792 pTLCb->uResCount -= uResLen;
4793
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -07004794 //fow control update
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304795 pClientSTA->uIngress_length += uResLen;
4796 pClientSTA->uBuffThresholdMax = (pClientSTA->uBuffThresholdMax >= uResLen) ?
4797 (pClientSTA->uBuffThresholdMax - uResLen) : 0;
Tushnim Bhattacharyya39a8f182013-02-20 18:10:30 -08004798 pClientSTA->ucEapolPktPending = 0;
4799 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
4800 "WLAN TL:GetFrames STA: %d EAPOLPktPending %d",
4801 ucSTAId, pClientSTA->ucEapolPktPending);
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -07004802 }
4803 }
4804 else
4805 { // no EAPOL frames exit Get frames
Tushnim Bhattacharyya39a8f182013-02-20 18:10:30 -08004806 TLLOG2(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
4807 "WLAN TL:GetFrames STA: %d, no EAPOL frame, continue.",
4808 ucSTAId));
4809 continue;
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -07004810 }
4811 }
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -07004812
Jeff Johnson9b5dc4d2013-02-22 21:28:47 -08004813 else if (( WDA_TLI_MIN_RES_DATA <= pTLCb->uResCount ) &&
4814 ( 0 == pTLCb->ucTxSuspended ) &&
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05304815 ( uFlowMask & WLANTL_DATA_FLOW_MASK))
Jeff Johnson295189b2012-06-20 16:38:30 -07004816 {
4817 /*---------------------------------------------------------------------
4818 Check to see if there was any packet left behind previously due to
4819 size constraints
4820 ---------------------------------------------------------------------*/
4821 vosTempBuf = NULL;
4822
4823 if ( NULL != pTLCb->vosTempBuf )
4824 {
4825 vosTempBuf = pTLCb->vosTempBuf;
4826 pTLCb->vosTempBuf = NULL;
4827 ucSTAId = pTLCb->ucCachedSTAId;
4828 ucAC = pTLCb->ucCachedAC;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304829
4830 if ( NULL == pTLCb->atlSTAClients[ucSTAId] )
4831 {
4832 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
4833 "WLAN TL:Client Memory was not allocated on %s", __func__));
Madan Mohan Koyylamudi64258222013-01-30 14:35:10 +05304834 continue;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304835 }
4836
4837 pTLCb->atlSTAClients[ucSTAId]->ucNoMoreData = 0;
Madan Mohan Koyylamudi64258222013-01-30 14:35:10 +05304838 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
Jeff Johnson295189b2012-06-20 16:38:30 -07004839
4840 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
4841 "WLAN TL:Chaining cached data frame on GetFrame"));
4842 }
4843 else
4844 {
4845 WLAN_TLGetNextTxIds( pvosGCtx, &ucSTAId);
4846 if (ucSTAId >= WLAN_MAX_STA_COUNT)
4847 {
4848 /* Packets start coming in even after insmod Without *
4849 starting Hostapd or Interface being up *
4850 During which cases STAID is invaled and hence
4851 the check. HalMsg_ScnaComplete Triggers */
4852
4853 break;
4854 }
4855 /* ucCurrentAC should have correct AC to be served by calling
4856 WLAN_TLGetNextTxIds */
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304857 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304858 if ( NULL == pClientSTA )
4859 {
4860 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
4861 "WLAN TL:Client Memory was not allocated on %s", __func__));
Madan Mohan Koyylamudi64258222013-01-30 14:35:10 +05304862 continue;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304863 }
4864
4865 ucAC = pClientSTA->ucCurrentAC;
4866
4867 pClientSTA->ucNoMoreData = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07004868 TLLOG4(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_LOW,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004869 "WLAN TL: %s get one data frame, station ID %d ", __func__, ucSTAId));
Jeff Johnson295189b2012-06-20 16:38:30 -07004870 /*-------------------------------------------------------------------
4871 Check to see that STA is valid and tx is not suspended
4872 -------------------------------------------------------------------*/
4873 if ( ( ! WLANTL_STA_ID_INVALID( ucSTAId ) ) &&
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304874 ( 0 == pClientSTA->ucTxSuspended ) &&
4875 ( 0 == pClientSTA->fcStaTxDisabled) )
Jeff Johnson295189b2012-06-20 16:38:30 -07004876 {
4877 TLLOG4(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_LOW,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004878 "WLAN TL: %s sta id valid and not suspended ",__func__));
Jeff Johnson295189b2012-06-20 16:38:30 -07004879 wSTAEvent = WLANTL_TX_EVENT;
4880
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304881 pfnSTAFsm = tlSTAFsm[pClientSTA->tlState].
Jeff Johnson295189b2012-06-20 16:38:30 -07004882 pfnSTATbl[wSTAEvent];
4883
4884 if ( NULL != pfnSTAFsm )
4885 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304886 pClientSTA->ucNoMoreData = 0;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004887 vosStatus = pfnSTAFsm( pvosGCtx, ucSTAId, &vosTempBuf, VOS_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07004888
4889 if (( VOS_STATUS_SUCCESS != vosStatus ) &&
4890 ( NULL != vosTempBuf ))
4891 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304892 pClientSTA->pfnSTATxComp( pvosGCtx,
Jeff Johnson295189b2012-06-20 16:38:30 -07004893 vosTempBuf,
4894 vosStatus );
4895 vosTempBuf = NULL;
4896 }/* status success*/
4897 }/*NULL function state*/
4898 }/* valid STA id and ! suspended*/
4899 else
4900 {
4901 if ( ! WLANTL_STA_ID_INVALID( ucSTAId ) )
4902 {
Alok Kumar1ee092e2018-10-01 11:38:42 +05304903 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_DEBUG,
Jeff Johnson295189b2012-06-20 16:38:30 -07004904 "WLAN TL:Not fetching frame because suspended for sta ID %d",
4905 ucSTAId));
4906 }
4907 }
4908 }/* data */
4909
4910 if ( NULL != vosTempBuf )
4911 {
4912 WDA_TLI_PROCESS_FRAME_LEN( vosTempBuf, usPktLen, uResLen, uTotalPktLen);
4913
Manjunathappa Prakashfb585462013-12-23 19:07:07 -08004914 if (usPktLen > WLANTL_MAX_ALLOWED_LEN)
4915 {
4916 usPktLen = WLANTL_MAX_ALLOWED_LEN;
4917 VOS_ASSERT(0);
4918 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004919
4920 TLLOG4(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_LOW,
4921 "WLAN TL:Resources needed by frame: %d", uResLen));
4922
4923 if ( ( pTLCb->uResCount >= (uResLen + WDA_TLI_MIN_RES_BAP ) ) &&
Jeff Johnson9b5dc4d2013-02-22 21:28:47 -08004924 ( uRemaining > uTotalPktLen ) &&
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05304925 ( uFlowMask & WLANTL_DATA_FLOW_MASK ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07004926 {
4927 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
4928 "WLAN TL:Chaining data frame on GetFrame"));
4929
4930 vos_pkt_chain_packet( vosDataBuff, vosTempBuf, 1 /*true*/ );
4931 vosTempBuf = NULL;
4932
4933 /*Update remaining len from SSC */
4934 uRemaining -= (usPktLen + WDA_DXE_HEADER_SIZE);
4935
4936 /*Update resource count */
4937 pTLCb->uResCount -= uResLen;
4938
Jeff Johnson295189b2012-06-20 16:38:30 -07004939 //fow control update
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304940 pClientSTA->uIngress_length += uResLen;
4941 pClientSTA->uBuffThresholdMax = (pClientSTA->uBuffThresholdMax >= uResLen) ?
4942 (pClientSTA->uBuffThresholdMax - uResLen) : 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004943
Sravan Kumar Kairam60b8cf02016-12-12 16:22:09 +05304944 pClientSTA->tx_frames ++;
4945
Jeff Johnson295189b2012-06-20 16:38:30 -07004946 }
4947 else
4948 {
4949 /* Store this for later tx - already fetched from HDD */
4950 pTLCb->vosTempBuf = vosTempBuf;
4951 pTLCb->ucCachedSTAId = ucSTAId;
4952 pTLCb->ucCachedAC = ucAC;
Jeff Johnson295189b2012-06-20 16:38:30 -07004953 ucResult = uResLen + WDA_TLI_MIN_RES_BAP;
4954 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
4955 "min %d res required by TL.", ucResult ));
Jeff Johnson295189b2012-06-20 16:38:30 -07004956 break; /* Out of resources or reached max len */
4957 }
4958 }
4959 else
4960 {
4961 for ( i = 0; i < WLAN_MAX_STA_COUNT; i++)
4962 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304963 if (NULL != pTLCb->atlSTAClients[i] && (pTLCb->atlSTAClients[i]->ucExists) &&
Bhargav Shahfbaeca22016-07-13 10:27:35 +05304964 (pTLCb->atlSTAClients[i]->ucPktPending) &&
4965 (pTLCb->atlSTAClients[i]->disassoc_progress == VOS_FALSE))
Jeff Johnson295189b2012-06-20 16:38:30 -07004966 {
4967 /* There is station to be Served */
4968 break;
4969 }
4970 }
4971 if (i >= WLAN_MAX_STA_COUNT)
4972 {
4973 /* No More to Serve Exit Get Frames */
4974 break;
4975 }
4976 else
4977 {
4978 /* More to be Served */
4979 continue;
4980 }
4981 }
4982 }
4983 else
4984 {
4985 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
4986 "WLAN TL:Returning from GetFrame: resources = %d suspended = %d",
4987 pTLCb->uResCount, pTLCb->ucTxSuspended));
Jeff Johnson295189b2012-06-20 16:38:30 -07004988 /* TL is starving even when DXE is not in low resource condition
4989 Return min resource number required and Let DXE deceide what to do */
4990 if(( 0 == pTLCb->ucTxSuspended ) &&
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05304991 ( uFlowMask & WLANTL_DATA_FLOW_MASK ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07004992 {
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07004993 TLLOG1(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -07004994 "WLAN TL:Returning from GetFrame: resources = %d",
4995 pTLCb->uResCount));
4996 ucResult = WDA_TLI_MIN_RES_DATA;
4997 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004998 break; /*out of min data resources*/
4999 }
5000
5001 pTLCb->usPendingTxCompleteCount++;
5002 /* Move data buffer up one packet */
5003 vos_pkt_walk_packet_chain( vosDataBuff, &vosDataBuff, 0/*false*/ );
5004 }
5005
5006 /*----------------------------------------------------------------------
5007 Packet chain starts at root + 1
5008 ----------------------------------------------------------------------*/
5009 vos_pkt_walk_packet_chain( vosRoot, &vosDataBuff, 1/*true*/ );
5010
5011 *pvosDataBuff = vosDataBuff;
Manjunathappa Prakashfb585462013-12-23 19:07:07 -08005012 if (pbUrgent)
5013 {
5014 *pbUrgent = pTLCb->bUrgent;
5015 }
5016 else
5017 {
5018 VOS_ASSERT( pbUrgent );
5019 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005020 return ucResult;
5021}/* WLANTL_GetFrames */
5022
5023
5024/*==========================================================================
5025
5026 FUNCTION WLANTL_TxComp
5027
5028 DESCRIPTION
5029 It is being called by BAL upon asynchronous notification of the packet
5030 or packets being sent over the bus.
5031
5032 DEPENDENCIES
5033 Tx complete cannot be called without a previous transmit.
5034
5035 PARAMETERS
5036
5037 IN
5038 pvosGCtx: pointer to the global vos context; a handle to TL's
5039 or BAL's control block can be extracted from its context
5040 vosDataBuff: it will contain a pointer to the first buffer for which
5041 the BAL report is being made, if there is more then one
5042 packet they will be chained using vOSS buffers.
5043 wTxStatus: the status of the transmitted packet, see above chapter
5044 on HDD interaction for a list of possible values
5045
5046 RETURN VALUE
5047 The result code associated with performing the operation
5048
5049 VOS_STATUS_E_INVAL: Input parameters are invalid
5050 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
5051 page fault
5052 VOS_STATUS_E_EXISTS: Station was not registered
5053 VOS_STATUS_SUCCESS: Everything is good :)
5054
5055 SIDE EFFECTS
5056
5057============================================================================*/
5058VOS_STATUS
5059WLANTL_TxComp
5060(
5061 v_PVOID_t pvosGCtx,
5062 vos_pkt_t *pFrameDataBuff,
5063 VOS_STATUS wTxStatus
5064)
5065{
5066 vos_pkt_t* vosDataBuff = (vos_pkt_t*)pFrameDataBuff;
5067 WLANTL_CbType* pTLCb = NULL;
5068 WLANTL_TxCompCBType pfnTxComp = NULL;
5069 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07005070 vos_pkt_t* vosTempTx = NULL;
5071
5072 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
5073
5074 /*------------------------------------------------------------------------
5075 Sanity check
5076 ------------------------------------------------------------------------*/
5077 if ( NULL == vosDataBuff )
5078 {
5079 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
5080 "WLAN TL:Extraneous NULL data pointer on WLANTL_TxComp"));
5081 return VOS_STATUS_E_INVAL;
5082 }
5083
5084 /*------------------------------------------------------------------------
5085 Extract TL control block
5086 ------------------------------------------------------------------------*/
5087 pTLCb = VOS_GET_TL_CB(pvosGCtx);
5088 if ( NULL == pTLCb )
5089 {
5090 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
5091 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_TxComp"));
5092 return VOS_STATUS_E_FAULT;
5093 }
5094
5095 while ((0 < pTLCb->usPendingTxCompleteCount) &&
5096 ( VOS_STATUS_SUCCESS == vosStatus ) &&
5097 ( NULL != vosDataBuff))
5098 {
5099 vos_pkt_get_user_data_ptr( vosDataBuff, VOS_PKT_USER_DATA_ID_TL,
5100 (v_PVOID_t)&pfnTxComp);
5101
5102 /*it should never be NULL - default handler should be registered if none*/
5103 if ( NULL == pfnTxComp )
5104 {
5105 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
5106 "WLAN TL:NULL pointer to Tx Complete on WLANTL_TxComp"));
5107 VOS_ASSERT(0);
5108 return VOS_STATUS_E_FAULT;
5109 }
5110
5111 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
Jeff Johnsonddec6482017-09-19 08:33:57 -07005112 "WLAN TL:Calling Tx complete for pkt %pK in function %pK",
Jeff Johnson295189b2012-06-20 16:38:30 -07005113 vosDataBuff, pfnTxComp));
5114
5115 vosTempTx = vosDataBuff;
5116 vosStatus = vos_pkt_walk_packet_chain( vosDataBuff,
5117 &vosDataBuff, 1/*true*/);
5118
5119 pfnTxComp( pvosGCtx, vosTempTx, wTxStatus );
5120
5121 pTLCb->usPendingTxCompleteCount--;
5122 }
5123
Jeff Johnson295189b2012-06-20 16:38:30 -07005124
5125 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
5126 "WLAN TL: current TL values are: resources = %d "
5127 "pTLCb->usPendingTxCompleteCount = %d",
5128 pTLCb->uResCount, pTLCb->usPendingTxCompleteCount));
5129
5130 return VOS_STATUS_SUCCESS;
5131}/* WLANTL_TxComp */
5132
5133/*==========================================================================
5134
5135 FUNCTION WLANTL_CacheSTAFrame
5136
5137 DESCRIPTION
5138 Internal utility function for for caching incoming data frames that do
5139 not have a registered station yet.
5140
5141 DEPENDENCIES
5142 TL must be initiailized before this function gets called.
5143 In order to benefit from thsi caching, the components must ensure that
5144 they will only register with TL at the moment when they are fully setup
5145 and ready to receive incoming data
5146
5147 PARAMETERS
5148
5149 IN
5150
5151 pTLCb: TL control block
5152 ucSTAId: station id
5153 vosTempBuff: the data packet
5154 uDPUSig: DPU signature of the incoming packet
5155 bBcast: true if packet had the MC/BC bit set
5156
5157 RETURN VALUE
5158 The result code associated with performing the operation
5159
5160 VOS_STATUS_E_FAULT: pointer to TL cb is NULL or STA Id invalid ; access
5161 would cause a page fault
5162 VOS_STATUS_SUCCESS: Everything is good :)
5163
5164 SIDE EFFECTS
5165
5166============================================================================*/
5167static VOS_STATUS
5168WLANTL_CacheSTAFrame
5169(
5170 WLANTL_CbType* pTLCb,
5171 v_U8_t ucSTAId,
5172 vos_pkt_t* vosTempBuff,
5173 v_U32_t uDPUSig,
5174 v_U8_t bBcast,
5175 v_U8_t ucFrmType
5176)
5177{
5178 v_U8_t ucUcastSig;
5179 v_U8_t ucBcastSig;
5180 v_BOOL_t bOldSTAPkt;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05305181 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005182 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
5183
5184 /*-------------------------------------------------------------------------
5185 Sanity check
5186 -------------------------------------------------------------------------*/
5187 if (( NULL == pTLCb ) || ( NULL == vosTempBuff ) )
5188 {
5189 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Jeff Johnsonddec6482017-09-19 08:33:57 -07005190 "WLAN TL: Invalid input pointer on WLANTL_CacheSTAFrame TL %pK"
5191 " Packet %pK", pTLCb, vosTempBuff ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005192 return VOS_STATUS_E_FAULT;
5193 }
5194
5195 if ( WLANTL_STA_ID_INVALID( ucSTAId ) )
5196 {
5197 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
5198 "WLAN TL:Invalid station id requested on WLANTL_CacheSTAFrame"));
5199 return VOS_STATUS_E_FAULT;
5200 }
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05305201 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
5202
5203 if ( NULL == pClientSTA )
5204 {
5205 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
5206 "WLAN TL:Client Memory was not allocated on %s", __func__));
5207 return VOS_STATUS_E_FAILURE;
5208 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005209
5210 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
5211 "WLAN TL:Attempting to cache pkt for STA %d, BD DPU Sig: %d with sig UC: %d, BC: %d",
5212 ucSTAId, uDPUSig,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05305213 pClientSTA->wSTADesc.ucUcastSig,
5214 pClientSTA->wSTADesc.ucBcastSig));
Jeff Johnson295189b2012-06-20 16:38:30 -07005215
5216 if(WLANTL_IS_CTRL_FRAME(ucFrmType))
5217 {
5218 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
5219 "WLAN TL: No need to cache CTRL frame. Dropping"));
5220 vos_pkt_return_packet(vosTempBuff);
5221 return VOS_STATUS_SUCCESS;
5222 }
5223
5224 /*-------------------------------------------------------------------------
5225 Check if the packet that we are trying to cache belongs to the old
5226 registered station (if any) or the new (potentially)upcoming station
5227
5228 - If the STA with this Id was never registered with TL - the signature
5229 will be invalid;
5230 - If the STA was previously registered TL will have cached the former
5231 set of DPU signatures
5232 -------------------------------------------------------------------------*/
5233 if ( bBcast )
5234 {
5235 ucBcastSig = (v_U8_t)uDPUSig;
5236 bOldSTAPkt = (( WLAN_TL_INVALID_B_SIG !=
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05305237 pClientSTA->wSTADesc.ucBcastSig ) &&
5238 ( ucBcastSig == pClientSTA->wSTADesc.ucBcastSig ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005239 }
5240 else
5241 {
5242 ucUcastSig = (v_U8_t)uDPUSig;
5243 bOldSTAPkt = (( WLAN_TL_INVALID_U_SIG !=
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05305244 pClientSTA->wSTADesc.ucUcastSig ) &&
5245 ( ucUcastSig == pClientSTA->wSTADesc.ucUcastSig ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005246 }
5247
5248 /*------------------------------------------------------------------------
5249 If the value of the DPU SIG matches the old, this packet will not
5250 be cached as it belonged to the former association
5251 In case the SIG does not match - this is a packet for a potentially new
5252 associated station
5253 -------------------------------------------------------------------------*/
Varun Reddy Yeturua39b9902013-01-18 15:48:32 -08005254 if ( bOldSTAPkt || bBcast )
Jeff Johnson295189b2012-06-20 16:38:30 -07005255 {
5256 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
5257 "WLAN TL:Data packet matches old sig for sig DPU: %d UC: %d, "
5258 "BC: %d - dropping",
5259 uDPUSig,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05305260 pClientSTA->wSTADesc.ucUcastSig,
5261 pClientSTA->wSTADesc.ucBcastSig));
Jeff Johnson295189b2012-06-20 16:38:30 -07005262 vos_pkt_return_packet(vosTempBuff);
5263 }
5264 else
5265 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05305266 if ( NULL == pClientSTA->vosBegCachedFrame )
Jeff Johnson295189b2012-06-20 16:38:30 -07005267 {
5268 /*this is the first frame that we are caching */
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05305269 pClientSTA->vosBegCachedFrame = vosTempBuff;
Mihir Sheteb7337272014-04-11 15:53:08 +05305270
5271 pClientSTA->tlCacheInfo.cacheInitTime = vos_timer_get_system_time();
5272 pClientSTA->tlCacheInfo.cacheDoneTime =
5273 pClientSTA->tlCacheInfo.cacheInitTime;
5274 pClientSTA->tlCacheInfo.cacheSize = 1;
5275
Mihir Sheteae6f02b2014-04-11 19:49:21 +05305276 MTRACE(vos_trace(VOS_MODULE_ID_TL, TRACE_CODE_TL_CACHE_FRAME,
5277 ucSTAId, pClientSTA->tlCacheInfo.cacheSize));
5278
Jeff Johnson295189b2012-06-20 16:38:30 -07005279 }
5280 else
5281 {
5282 /*this is a subsequent frame that we are caching: chain to the end */
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05305283 vos_pkt_chain_packet(pClientSTA->vosEndCachedFrame,
Jeff Johnson295189b2012-06-20 16:38:30 -07005284 vosTempBuff, VOS_TRUE);
Mihir Sheteb7337272014-04-11 15:53:08 +05305285
5286 pClientSTA->tlCacheInfo.cacheDoneTime = vos_timer_get_system_time();
5287 pClientSTA->tlCacheInfo.cacheSize ++;
5288
5289 if (pClientSTA->tlCacheInfo.cacheSize % WLANTL_CACHE_TRACE_WATERMARK == 0)
5290 {
5291 VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
5292 "%s: Cache High watermark for staid:%d (%d)",
5293 __func__,ucSTAId, pClientSTA->tlCacheInfo.cacheSize);
Mihir Sheteae6f02b2014-04-11 19:49:21 +05305294 MTRACE(vos_trace(VOS_MODULE_ID_TL, TRACE_CODE_TL_CACHE_FRAME,
5295 ucSTAId, pClientSTA->tlCacheInfo.cacheSize));
Mihir Sheteb7337272014-04-11 15:53:08 +05305296 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005297 }
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05305298 pClientSTA->vosEndCachedFrame = vosTempBuff;
Jeff Johnson295189b2012-06-20 16:38:30 -07005299 }/*else new packet*/
5300
5301 return VOS_STATUS_SUCCESS;
5302}/*WLANTL_CacheSTAFrame*/
5303
5304/*==========================================================================
5305
5306 FUNCTION WLANTL_FlushCachedFrames
5307
5308 DESCRIPTION
5309 Internal utility function used by TL to flush the station cache
5310
5311 DEPENDENCIES
5312 TL must be initiailized before this function gets called.
5313
5314 PARAMETERS
5315
5316 IN
5317
5318 vosDataBuff: it will contain a pointer to the first cached buffer
5319 received,
5320
5321 RETURN VALUE
5322 The result code associated with performing the operation
5323
5324 VOS_STATUS_SUCCESS: Everything is good :)
5325
5326 SIDE EFFECTS
5327
5328 NOTE
5329 This function doesn't re-initialize vosDataBuff to NULL. It's caller's
5330 responsibility to do so, if required, after this function call.
5331 Because of this restriction, we decide to make this function to static
5332 so that upper layer doesn't need to be aware of this restriction.
5333
5334============================================================================*/
5335static VOS_STATUS
5336WLANTL_FlushCachedFrames
5337(
5338 vos_pkt_t* vosDataBuff
5339)
5340{
5341 /*----------------------------------------------------------------------
5342 Return the entire chain to vos if there are indeed cache frames
5343 ----------------------------------------------------------------------*/
5344 if ( NULL != vosDataBuff )
5345 {
5346 vos_pkt_return_packet(vosDataBuff);
5347 }
5348
5349 return VOS_STATUS_SUCCESS;
5350}/*WLANTL_FlushCachedFrames*/
5351
5352/*==========================================================================
5353
5354 FUNCTION WLANTL_ForwardSTAFrames
5355
5356 DESCRIPTION
5357 Internal utility function for either forwarding cached data to the station after
5358 the station has been registered, or flushing cached data if the station has not
5359 been registered.
5360
5361
5362 DEPENDENCIES
5363 TL must be initiailized before this function gets called.
5364
5365 PARAMETERS
5366
5367 IN
5368
5369 pTLCb: TL control block
5370 ucSTAId: station id
5371
5372 RETURN VALUE
5373 The result code associated with performing the operation
5374
5375 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
5376 page fault
5377 VOS_STATUS_SUCCESS: Everything is good :)
5378
5379 SIDE EFFECTS
5380 This function doesn't re-initialize vosDataBuff to NULL. It's caller's
5381 responsibility to do so, if required, after this function call.
5382 Because of this restriction, we decide to make this function to static
5383 so that upper layer doesn't need to be aware of this restriction.
5384
5385============================================================================*/
5386static VOS_STATUS
5387WLANTL_ForwardSTAFrames
5388(
5389 void* pvosGCtx,
5390 v_U8_t ucSTAId,
5391 v_U8_t ucUcastSig,
5392 v_U8_t ucBcastSig
5393)
5394{
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05305395 WLANTL_CbType* pTLCb = NULL;
5396 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005397 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
5398
5399 /*-------------------------------------------------------------------------
5400 Sanity check
5401 -------------------------------------------------------------------------*/
5402 pTLCb = VOS_GET_TL_CB(pvosGCtx);
5403 if ( NULL == pTLCb )
5404 {
5405 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Jeff Johnsonddec6482017-09-19 08:33:57 -07005406 "WLAN TL: Invalid input pointer on WLANTL_ForwardSTAFrames TL %pK",
Jeff Johnson295189b2012-06-20 16:38:30 -07005407 pTLCb ));
5408 return VOS_STATUS_E_FAULT;
5409 }
5410
5411 if ( WLANTL_STA_ID_INVALID( ucSTAId ) )
5412 {
5413 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
5414 "WLAN TL:Invalid station id requested on WLANTL_ForwardSTAFrames"));
5415 return VOS_STATUS_E_FAULT;
5416 }
5417
5418 //WLAN_TL_LOCK_STA_CACHE(pTLCb->atlSTAClients[ucSTAId]);
5419
5420 /*------------------------------------------------------------------------
5421 Check if station has not been registered in the mean while
5422 if not registered, flush cached frames.
5423 ------------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05305424 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
5425
5426 if ( NULL == pClientSTA )
5427 {
5428 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
5429 "WLAN TL:Client Memory was not allocated on %s", __func__));
5430 return VOS_STATUS_E_FAILURE;
5431 }
5432
5433 if ( 0 == pClientSTA->ucExists )
Jeff Johnson295189b2012-06-20 16:38:30 -07005434 {
5435 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
5436 "WLAN TL:Station has been deleted for STA %d - flushing cache", ucSTAId));
Mihir Sheteae6f02b2014-04-11 19:49:21 +05305437 MTRACE(vos_trace(VOS_MODULE_ID_TL, TRACE_CODE_TL_FLUSH_CACHED_FRAMES,
5438 ucSTAId, pClientSTA->tlCacheInfo.cacheSize));
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05305439 WLANTL_FlushCachedFrames(pClientSTA->vosBegCachedFrame);
Jeff Johnson295189b2012-06-20 16:38:30 -07005440 goto done;
5441 }
5442
5443 /*------------------------------------------------------------------------
5444 Forwarding cache frames received while the station was in the process
5445 of being registered with the rest of the SW components
5446
5447 Access to the cache must be locked; similarly updating the signature and
5448 the existence flag must be synchronized because these values are checked
5449 during cached
5450 ------------------------------------------------------------------------*/
5451 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
5452 "WLAN TL:Preparing to fwd packets for STA %d", ucSTAId));
5453
5454 /*-----------------------------------------------------------------------
5455 Save the new signature values
5456 ------------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05305457 pClientSTA->wSTADesc.ucUcastSig = ucUcastSig;
5458 pClientSTA->wSTADesc.ucBcastSig = ucBcastSig;
Jeff Johnson295189b2012-06-20 16:38:30 -07005459
5460 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
5461 "WLAN TL:Fwd-ing packets for STA %d UC %d BC %d",
5462 ucSTAId, ucUcastSig, ucBcastSig));
5463
5464 /*-------------------------------------------------------------------------
5465 Check to see if we have any cached data to forward
5466 -------------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05305467 if ( NULL != pClientSTA->vosBegCachedFrame )
Jeff Johnson295189b2012-06-20 16:38:30 -07005468 {
5469 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
5470 "WLAN TL: Fwd-ing Cached packets for station %d", ucSTAId ));
5471
5472 WLANTL_RxCachedFrames( pTLCb,
5473 ucSTAId,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05305474 pClientSTA->vosBegCachedFrame);
Jeff Johnson295189b2012-06-20 16:38:30 -07005475 }
5476 else
5477 {
5478 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
5479 "WLAN TL: NO cached packets for station %d", ucSTAId ));
5480 }
5481
5482done:
5483 /*-------------------------------------------------------------------------
5484 Clear the station cache
5485 -------------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05305486 pClientSTA->vosBegCachedFrame = NULL;
5487 pClientSTA->vosEndCachedFrame = NULL;
Mihir Sheteb7337272014-04-11 15:53:08 +05305488 pClientSTA->tlCacheInfo.cacheSize = 0;
5489 pClientSTA->tlCacheInfo.cacheClearTime = vos_timer_get_system_time();
Jeff Johnson295189b2012-06-20 16:38:30 -07005490
5491 /*-----------------------------------------------------------------------
5492 After all the init is complete we can mark the existance flag
5493 ----------------------------------------------------------------------*/
Katya Nigam63902932014-06-26 19:04:23 +05305494 pClientSTA->enableCaching = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005495
5496 //WLAN_TL_UNLOCK_STA_CACHE(pTLCb->atlSTAClients[ucSTAId]);
5497 return VOS_STATUS_SUCCESS;
5498
5499}/*WLANTL_ForwardSTAFrames*/
5500
5501
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005502#if defined(FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_ESE_UPLOAD)
Jeff Johnson295189b2012-06-20 16:38:30 -07005503/*==========================================================================
5504
5505 FUNCTION WLANTL_IsIAPPFrame
5506
5507 DESCRIPTION
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005508 Internal utility function for detecting incoming ESE IAPP frames
Jeff Johnson295189b2012-06-20 16:38:30 -07005509
5510 DEPENDENCIES
5511
5512 PARAMETERS
5513
5514 IN
5515
5516 pvBDHeader: pointer to the BD header
5517 vosTempBuff: the data packet
5518
5519 IN/OUT
5520 pFirstDataPktArrived: static from caller function; used for rssi
5521 computation
5522 RETURN VALUE
5523 The result code associated with performing the operation
5524
5525 VOS_TRUE: It is a IAPP frame
5526 VOS_FALSE: It is NOT IAPP frame
5527
5528 SIDE EFFECTS
5529
5530============================================================================*/
5531v_BOOL_t
5532WLANTL_IsIAPPFrame
5533(
5534 v_PVOID_t pvBDHeader,
5535 vos_pkt_t* vosTempBuff
5536)
5537{
5538 v_U16_t usMPDUDOffset;
5539 v_U8_t ucOffset;
5540 v_U8_t ucSnapHdr[WLANTL_LLC_SNAP_SIZE];
5541 v_SIZE_t usSnapHdrSize = WLANTL_LLC_SNAP_SIZE;
5542 VOS_STATUS vosStatus;
5543
5544 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
5545
5546 /*------------------------------------------------------------------------
5547 Check if OUI field is present.
5548 -------------------------------------------------------------------------*/
5549 if ( VOS_FALSE == WDA_IS_RX_LLC_PRESENT(pvBDHeader) )
5550 {
5551 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
5552 "WLAN TL:LLC header removed, cannot determine BT-AMP type -"
5553 "dropping pkt"));
5554 /* Drop packet */
5555 vos_pkt_return_packet(vosTempBuff);
5556 return VOS_TRUE;
5557 }
5558 usMPDUDOffset = (v_U8_t)WDA_GET_RX_MPDU_DATA_OFFSET(pvBDHeader);
5559 ucOffset = (v_U8_t)usMPDUDOffset + WLANTL_LLC_SNAP_OFFSET;
5560
5561 vosStatus = vos_pkt_extract_data( vosTempBuff, ucOffset,
5562 (v_PVOID_t)ucSnapHdr, &usSnapHdrSize);
5563
5564 if (( VOS_STATUS_SUCCESS != vosStatus))
5565 {
5566 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
5567 "Unable to extract Snap Hdr of data packet -"
5568 "dropping pkt"));
5569 return VOS_FALSE;
5570 }
5571
5572 /*------------------------------------------------------------------------
5573 Check if this is IAPP frame by matching Aironet Snap hdr.
5574 -------------------------------------------------------------------------*/
5575 // Compare returns 1 if values are same and 0
5576 // if not the same.
5577 if (( WLANTL_LLC_SNAP_SIZE != usSnapHdrSize ) ||
5578 ( 0 == vos_mem_compare(ucSnapHdr, (v_PVOID_t)WLANTL_AIRONET_SNAP_HEADER,
5579 WLANTL_LLC_SNAP_SIZE ) ))
5580 {
5581 return VOS_FALSE;
5582 }
5583
5584 return VOS_TRUE;
5585
5586}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005587#endif //FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07005588
5589/*==========================================================================
5590
5591 FUNCTION WLANTL_ProcessBAPFrame
5592
5593 DESCRIPTION
5594 Internal utility function for processing incoming BT-AMP frames
5595
5596 DEPENDENCIES
5597 TL must be initiailized before this function gets called.
5598 Bothe the BT-AMP station and the BAP Ctrl path must have been previously
5599 registered with TL.
5600
5601 PARAMETERS
5602
5603 IN
5604
5605 pvBDHeader: pointer to the BD header
5606 vosTempBuff: the data packet
5607 pTLCb: TL control block
5608 ucSTAId: station id
5609
5610 IN/OUT
5611 pFirstDataPktArrived: static from caller function; used for rssi
5612 computation
5613 RETURN VALUE
5614 The result code associated with performing the operation
5615
5616 VOS_STATUS_E_INVAL: Input parameters are invalid
5617 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
5618 page fault
5619 VOS_STATUS_SUCCESS: Everything is good :)
5620
5621 SIDE EFFECTS
5622
5623============================================================================*/
5624v_BOOL_t
5625WLANTL_ProcessBAPFrame
5626(
5627 v_PVOID_t pvBDHeader,
5628 vos_pkt_t* vosTempBuff,
5629 WLANTL_CbType* pTLCb,
5630 v_U8_t* pFirstDataPktArrived,
5631 v_U8_t ucSTAId
5632)
5633{
5634 v_U16_t usMPDUDOffset;
5635 v_U8_t ucOffset;
5636 v_U8_t ucOUI[WLANTL_LLC_OUI_SIZE];
5637 v_SIZE_t usOUISize = WLANTL_LLC_OUI_SIZE;
5638 VOS_STATUS vosStatus;
5639 v_U16_t usType;
5640 v_SIZE_t usTypeLen = sizeof(usType);
5641 v_U8_t ucMPDUHOffset;
5642 v_U8_t ucMPDUHLen = 0;
5643 v_U16_t usActualHLen = 0;
5644
5645 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
5646
5647 /*------------------------------------------------------------------------
5648 Extract OUI and type from LLC and validate; if non-data send to BAP
5649 -------------------------------------------------------------------------*/
5650 if ( VOS_FALSE == WDA_IS_RX_LLC_PRESENT(pvBDHeader) )
5651 {
5652 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
5653 "WLAN TL:LLC header removed, cannot determine BT-AMP type -"
5654 "dropping pkt"));
5655 /* Drop packet */
5656 vos_pkt_return_packet(vosTempBuff);
5657 return VOS_TRUE;
5658 }
5659
5660 usMPDUDOffset = (v_U8_t)WDA_GET_RX_MPDU_DATA_OFFSET(pvBDHeader);
5661 ucMPDUHOffset = (v_U8_t)WDA_GET_RX_MPDU_HEADER_OFFSET(pvBDHeader);
5662 ucMPDUHLen = (v_U8_t)WDA_GET_RX_MPDU_HEADER_LEN(pvBDHeader);
5663 ucOffset = (v_U8_t)usMPDUDOffset + WLANTL_LLC_OUI_OFFSET;
5664
5665 vosStatus = vos_pkt_extract_data( vosTempBuff, ucOffset,
5666 (v_PVOID_t)ucOUI, &usOUISize);
5667
5668#if 0
5669 // Compare returns 1 if values are same and 0
5670 // if not the same.
5671 if (( WLANTL_LLC_OUI_SIZE != usOUISize ) ||
5672 ( 0 == vos_mem_compare(ucOUI, (v_PVOID_t)WLANTL_BT_AMP_OUI,
5673 WLANTL_LLC_OUI_SIZE ) ))
5674 {
5675 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
5676 "LLC header points to diff OUI in BT-AMP station -"
5677 "dropping pkt"));
5678 /* Drop packet */
5679 vos_pkt_return_packet(vosTempBuff);
5680 return VOS_TRUE;
5681 }
5682#endif
5683 /*------------------------------------------------------------------------
5684 Extract LLC OUI and ensure that this is indeed a BT-AMP frame
5685 ------------------------------------------------------------------------*/
5686 vosStatus = vos_pkt_extract_data( vosTempBuff,
5687 ucOffset + WLANTL_LLC_OUI_SIZE,
5688 (v_PVOID_t)&usType, &usTypeLen);
5689
5690 if (( VOS_STATUS_SUCCESS != vosStatus) ||
5691 ( sizeof(usType) != usTypeLen ))
5692 {
5693 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
5694 "Unable to extract type on incoming BAP packet -"
5695 "dropping pkt"));
5696 /* Drop packet */
5697 vos_pkt_return_packet(vosTempBuff);
5698 return VOS_TRUE;
5699 }
5700
5701 /*------------------------------------------------------------------------
5702 Check if this is BT-AMP data or ctrl packet(RSN, LinkSvision, ActivityR)
5703 ------------------------------------------------------------------------*/
5704 usType = vos_be16_to_cpu(usType);
5705
5706 if (WLANTL_BAP_IS_NON_DATA_PKT_TYPE(usType))
5707 {
5708 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
5709 "WLAN TL:Non-data packet received over BT-AMP link: %d, => BAP",
5710 usType));
5711
5712 /*Flatten packet as BAP expects to be able to peek*/
5713 if ( VOS_STATUS_SUCCESS != vos_pkt_flatten_rx_pkt(&vosTempBuff))
5714 {
5715 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
5716 "WLAN TL:Cannot flatten BT-AMP packet - dropping"));
5717 /* Drop packet */
5718 vos_pkt_return_packet(vosTempBuff);
5719 return VOS_TRUE;
5720 }
5721
5722 /* Send packet to BAP client*/
Jeff Johnson295189b2012-06-20 16:38:30 -07005723 if ( VOS_STATUS_SUCCESS != WDA_DS_TrimRxPacketInfo( vosTempBuff ) )
5724 {
5725 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
5726 "WLAN TL:BD header corrupted - dropping packet"));
5727 /* Drop packet */
5728 vos_pkt_return_packet(vosTempBuff);
5729 return VOS_TRUE;
5730 }
5731
5732 if ( 0 == WDA_GET_RX_FT_DONE(pvBDHeader) )
5733 {
5734 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
5735 "Non-data packet received over BT-AMP link: Sending it for "
5736 "frame Translation"));
5737
5738 if (usMPDUDOffset > ucMPDUHOffset)
5739 {
5740 usActualHLen = usMPDUDOffset - ucMPDUHOffset;
5741 }
5742
5743 /* software frame translation for BTAMP WDS.*/
5744 WLANTL_Translate80211To8023Header( vosTempBuff, &vosStatus, usActualHLen,
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005745 ucMPDUHLen, pTLCb,ucSTAId, VOS_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07005746
5747 }
5748 if (pTLCb->tlBAPClient.pfnTlBAPRx)
5749 pTLCb->tlBAPClient.pfnTlBAPRx( vos_get_global_context(VOS_MODULE_ID_TL,pTLCb),
5750 vosTempBuff,
5751 (WLANTL_BAPFrameEnumType)usType );
Manjunathappa Prakashfb585462013-12-23 19:07:07 -08005752 else
5753 {
5754 VOS_ASSERT(0);
5755 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005756
5757 return VOS_TRUE;
5758 }
5759 else
5760 {
5761 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
5762 "WLAN TL: BAP DATA packet received over BT-AMP link: %d, => BAP",
5763 usType));
5764 /*!!!FIX ME!!*/
5765 #if 0
5766 /*--------------------------------------------------------------------
5767 For data packet collect phy stats RSSI and Link Quality
5768 Calculate the RSSI average and save it. Continuous average is done.
5769 --------------------------------------------------------------------*/
5770 if ( *pFirstDataPktArrived == 0)
5771 {
5772 pTLCb->atlSTAClients[ucSTAId].rssiAvg =
5773 WLANHAL_GET_RSSI_AVERAGE( pvBDHeader );
5774 pTLCb->atlSTAClients[ucSTAId].uLinkQualityAvg =
5775 WLANHAL_RX_BD_GET_SNR( pvBDHeader );
5776
5777 // Rcvd 1st pkt, start average from next time
5778 *pFirstDataPktArrived = 1;
5779 }
5780 else
5781 {
5782 pTLCb->atlSTAClients[ucSTAId].rssiAvg =
5783 (WLANHAL_GET_RSSI_AVERAGE( pvBDHeader ) +
5784 pTLCb->atlSTAClients[ucSTAId].rssiAvg)/2;
5785 pTLCb->atlSTAClients[ucSTAId].uLinkQualityAvg =
5786 (WLANHAL_RX_BD_GET_SNR( pvBDHeader ) +
5787 pTLCb->atlSTAClients[ucSTAId].uLinkQualityAvg)/2;
5788 }/*Else, first data packet*/
5789 #endif
5790 }/*BT-AMP data packet*/
5791
5792 return VOS_FALSE;
5793}/*WLANTL_ProcessBAPFrame*/
5794
Jeff Johnson295189b2012-06-20 16:38:30 -07005795
5796/*==========================================================================
5797
5798 FUNCTION WLANTL_ProcessFCFrame
5799
5800 DESCRIPTION
5801 Internal utility function for processing incoming Flow Control frames. Enable
5802 or disable LWM mode based on the information.
5803
5804 DEPENDENCIES
5805 TL must be initiailized before this function gets called.
5806 FW sends up special flow control frame.
5807
5808 PARAMETERS
5809
5810 IN
5811 pvosGCtx pointer to vos global context
5812 pvBDHeader: pointer to the BD header
5813 pTLCb: TL control block
5814 pvBDHeader pointer to BD header.
5815
5816 IN/OUT
5817 pFirstDataPktArrived: static from caller function; used for rssi
5818 computation
5819 RETURN VALUE
5820 The result code associated with performing the operation
5821
5822 VOS_STATUS_E_INVAL: Input frame are invalid
5823 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
5824 page fault
5825 VOS_STATUS_SUCCESS: Everything is good :)
5826
5827 SIDE EFFECTS
5828 The ingress and egress of each station will be updated. If needed, LWM mode will
5829 be enabled or disabled based on the flow control algorithm.
5830
5831============================================================================*/
5832v_BOOL_t
5833WLANTL_ProcessFCFrame
5834(
5835 v_PVOID_t pvosGCtx,
5836 vos_pkt_t* pvosDataBuff,
5837 v_PVOID_t pvBDHeader
5838)
5839{
5840#if 1 //enable processing of only fcStaTxDisabled bitmap for now. the else part is old better qos code.
5841 // need to revisit the old code for full implementation.
Hoonki Lee14621352013-04-16 17:51:19 -07005842 v_U8_t ucSTAId;
5843 v_U16_t ucStaValidBitmap;
5844 v_U16_t ucStaTxDisabledBitmap;
5845 WLANTL_CbType* pTLCb = NULL;
5846 #ifdef TL_DEBUG_FC
5847 v_U32_t rxTimeStamp;
5848 v_U32_t curTick;
5849 #endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005850 /*------------------------------------------------------------------------
Hoonki Lee14621352013-04-16 17:51:19 -07005851 Extract TL control block
Jeff Johnson295189b2012-06-20 16:38:30 -07005852 ------------------------------------------------------------------------*/
5853 pTLCb = VOS_GET_TL_CB(pvosGCtx);
5854 if ( NULL == pTLCb )
5855 {
5856 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
5857 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_SuspendDataTx"));
5858 return VOS_STATUS_E_FAULT;
5859 }
Hoonki Lee14621352013-04-16 17:51:19 -07005860 ucStaValidBitmap = WDA_GET_RX_FC_VALID_STA_MASK(pvBDHeader);
5861 ucStaTxDisabledBitmap = WDA_GET_RX_FC_STA_TX_DISABLED_BITMAP(pvBDHeader);
5862#ifdef TL_DEBUG_FC
5863 rxTimeStamp = WDA_GET_RX_TIMESTAMP(pvBDHeader);
5864 /* hard code of MTU_GLOBAL_TIMER_ADDR to calculate the time between generated and processed */
5865 wpalReadRegister(0x03081400+0x1D4, &curTick);
Jeff Johnson295189b2012-06-20 16:38:30 -07005866
Jeff Johnson295189b2012-06-20 16:38:30 -07005867 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Arif Hussainf2b00992013-11-17 21:46:15 -08005868 "%ld (%ld-%ld): Disabled %x Valid %x", curTick > rxTimeStamp ? curTick - rxTimeStamp : rxTimeStamp - (0xFFFFFFFF - curTick),
Hoonki Lee14621352013-04-16 17:51:19 -07005869 curTick, rxTimeStamp, ucStaTxDisabledBitmap, ucStaValidBitmap));
5870#endif
5871 for(ucSTAId = 0; ucStaValidBitmap != 0; ucStaValidBitmap >>=1, ucStaTxDisabledBitmap >>= 1, ucSTAId ++)
Jeff Johnson295189b2012-06-20 16:38:30 -07005872 {
Hoonki Lee14621352013-04-16 17:51:19 -07005873 if ( (0 == (ucStaValidBitmap & 0x1)) || (pTLCb->atlSTAClients[ucSTAId] && (0 == pTLCb->atlSTAClients[ucSTAId]->ucExists)) )
5874 continue;
5875
5876 if (ucStaTxDisabledBitmap & 0x1)
5877 {
5878 WLANTL_SuspendDataTx(pvosGCtx, &ucSTAId, NULL);
5879 }
5880 else
5881 {
5882 WLANTL_ResumeDataTx(pvosGCtx, &ucSTAId);
5883 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005884 }
5885
5886#else
5887 VOS_STATUS vosStatus;
5888 tpHalFcRxBd pvFcRxBd = NULL;
5889 v_U8_t ucBitCheck = 0x1;
5890 v_U8_t ucStaValid = 0;
5891 v_U8_t ucSTAId = 0;
5892
5893 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
5894 "Received FC Response");
5895 if ( (NULL == pTLCb) || (NULL == pvosDataBuff))
5896 {
5897 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Arif Hussainf2b00992013-11-17 21:46:15 -08005898 "WLAN TL:Invalid pointer in %s", __func__));
Jeff Johnson295189b2012-06-20 16:38:30 -07005899 return VOS_STATUS_E_FAULT;
5900 }
5901 vosStatus = vos_pkt_peek_data( pvosDataBuff, 0, (v_PVOID_t)&pvFcRxBd,
5902 sizeof(tHalFcRxBd));
5903
5904 if ( (VOS_STATUS_SUCCESS != vosStatus) || (NULL == pvFcRxBd) )
5905 {
5906 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
5907 "WLAN TL:wrong FC Rx packet"));
5908 return VOS_STATUS_E_INVAL;
5909 }
5910
5911 // need to swap bytes in the FC contents.
5912 WLANHAL_SwapFcRxBd(&pvFcRxBd->fcSTATxQLen[0]);
5913
5914 //logic to enable/disable LWM mode for each station
5915 for( ucStaValid = (v_U8_t)pvFcRxBd->fcSTAValidMask; ucStaValid; ucStaValid >>= 1, ucBitCheck <<= 1, ucSTAId ++)
5916 {
5917 if ( (0 == (ucStaValid & 0x1)) || (0 == pTLCb->atlSTAClients[ucSTAId].ucExists) )
5918 {
5919 continue;
5920 }
5921
5922 if ( pvFcRxBd->fcSTAThreshIndMask & ucBitCheck )
5923 {
5924 //LWM event is reported by FW. Able to fetch more packet
5925 if( pTLCb->atlSTAClients[ucSTAId].ucLwmModeEnabled )
5926 {
5927 //Now memory usage is below LWM. Station can send more packets.
5928 pTLCb->atlSTAClients[ucSTAId].ucLwmEventReported = TRUE;
5929 }
5930 else
5931 {
5932 TLLOG4(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_LOW,
Arif Hussainf2b00992013-11-17 21:46:15 -08005933 "WLAN TL: FW report LWM event but the station %d is not in LWM mode", ucSTAId));
Jeff Johnson295189b2012-06-20 16:38:30 -07005934 }
5935 }
5936
5937 //calculate uEgress_length/uIngress_length only after receiving enough packets
5938 if (WLANTL_LWM_INGRESS_SAMPLE_THRESHOLD <= pTLCb->atlSTAClients[ucSTAId].uIngress_length)
5939 {
5940 //check memory usage info to see whether LWM mode should be enabled for the station
5941 v_U32_t uEgress_length = pTLCb->atlSTAClients[ucSTAId].uIngress_length +
5942 pTLCb->atlSTAClients[ucSTAId].bmuMemConsumed - pvFcRxBd->fcSTATxQLen[ucSTAId];
5943
5944 //if ((float)uEgress_length/(float)pTLCb->atlSTAClients[ucSTAId].uIngress_length
5945 // <= WLANTL_LWM_EGRESS_INGRESS_THRESHOLD)
5946 if ( (pTLCb->atlSTAClients[ucSTAId].uIngress_length > uEgress_length) &&
5947 ((pTLCb->atlSTAClients[ucSTAId].uIngress_length - uEgress_length ) >=
5948 (pTLCb->atlSTAClients[ucSTAId].uIngress_length >> 2))
5949 )
5950 {
5951 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
Arif Hussainf2b00992013-11-17 21:46:15 -08005952 "WLAN TL:Enable LWM mode for station %d", ucSTAId));
Jeff Johnson295189b2012-06-20 16:38:30 -07005953 pTLCb->atlSTAClients[ucSTAId].ucLwmModeEnabled = TRUE;
5954 }
5955 else
5956 {
5957 if( pTLCb->atlSTAClients[ucSTAId].ucLwmModeEnabled )
5958 {
5959 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
Arif Hussainf2b00992013-11-17 21:46:15 -08005960 "WLAN TL:Disable LWM mode for station %d", ucSTAId));
Jeff Johnson295189b2012-06-20 16:38:30 -07005961 pTLCb->atlSTAClients[ucSTAId].ucLwmModeEnabled = FALSE;
5962 }
5963
5964 }
5965
5966 //remember memory usage in FW starting from this round
5967 pTLCb->atlSTAClients[ucSTAId].bmuMemConsumed = pvFcRxBd->fcSTATxQLen[ucSTAId];
5968 pTLCb->atlSTAClients[ucSTAId].uIngress_length = 0;
5969 } //(WLANTL_LWM_INGRESS_SAMPLE_THRESHOLD <= pTLCb->atlSTAClients[ucSTAId].uIngress_length)
5970
5971 if( pTLCb->atlSTAClients[ucSTAId].ucLwmModeEnabled )
5972 {
5973 //always update current maximum allowed memeory usage
5974 pTLCb->atlSTAClients[ucSTAId].uBuffThresholdMax = WLANTL_STA_BMU_THRESHOLD_MAX -
5975 pvFcRxBd->fcSTATxQLen[ucSTAId];
5976 }
5977
5978 }
5979#endif
5980
5981 return VOS_STATUS_SUCCESS;
5982}
Jeff Johnson295189b2012-06-20 16:38:30 -07005983
Sravan Kumar Kairamb0edc612016-10-26 13:55:24 +05305984/**
5985 * WLANTL_FlowControl() - TX Flow control
5986 * @pTLCb: TL context pointer
5987 * @pvosDataBuff: Firmware indication data buffer
5988 *
5989 * This function implenets the algorithm to flow control TX traffic in case
5990 * of SAP and SAP + STA concurrency.
5991 *
5992 * Algorithm goal is to fetch more packets from good peer than bad peer by
5993 * introducing weights for each station connected. Weight of each station is
5994 * calcutated by taking ratio of max RA rate of the peers to its rate. If the
5995 * ratio is less than two based on number of queued frames in the station BTQM
5996 * weight is modified. If the queued frames reaches the defined threshold weight
5997 * is assigned as four. Here weight is inversely proportional to the number of
5998 * packets fetch.
5999 *
6000 * Return true if flow controlled or false otherwise.
6001 */
6002static bool WLANTL_FlowControl(WLANTL_CbType* pTLCb, vos_pkt_t* pvosDataBuff)
6003{
6004 WLANTL_FlowControlInfo *fc_data = NULL;
6005 WLANTL_PerStaFlowControlParam *sta_fc_params = NULL;
6006 uint8_t num_stas;
6007 struct sk_buff *skb = NULL;
6008 uint16_t data_len;
6009 uint8_t *staid;
6010 uint16_t max_rate = 0;
6011 uint8_t i;
6012
6013 vos_pkt_get_packet_length(pvosDataBuff, &data_len);
6014 if (!data_len) {
6015 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6016 "%s: Null fw indication data", __func__));
6017 return false;
6018 }
6019
6020 vos_pkt_get_os_packet(pvosDataBuff, (v_VOID_t **)&skb, 0);
6021 fc_data = (WLANTL_FlowControlInfo *)skb->data;
6022 num_stas = fc_data->num_stas;
6023 if (!num_stas) {
6024 TLLOG1(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
6025 "%s: No connected stations", __func__));
6026 return true;
6027 }
6028
6029 /* Skip flow control for one connected station */
6030 if (1 == num_stas)
6031 return true;
6032
6033 staid = (uint8_t *)vos_mem_malloc(WLAN_MAX_STA_COUNT);
6034 if (!staid) {
6035 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6036 "%s: mem allocation failure", __func__));
6037 return false;
6038 }
6039 vos_mem_set((uint8_t *)staid, WLAN_MAX_STA_COUNT, 0);
6040
6041 sta_fc_params = (WLANTL_PerStaFlowControlParam *)(&fc_data->num_stas + 1);
6042
6043 for(i = 0; i < num_stas; i ++, sta_fc_params ++) {
6044 staid[i] = sta_fc_params->sta_id;
6045
6046 if (!pTLCb->atlSTAClients[staid[i]])
6047 continue;
6048
6049 pTLCb->atlSTAClients[staid[i]]->per = sta_fc_params->avg_per;
6050 pTLCb->atlSTAClients[staid[i]]->queue = sta_fc_params->queue_len;
6051 pTLCb->atlSTAClients[staid[i]]->trate = sta_fc_params->rate;
6052 max_rate = max_rate > pTLCb->atlSTAClients[staid[i]]->trate ?
6053 max_rate : pTLCb->atlSTAClients[staid[i]]->trate;
6054
6055 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
6056 "%s: sta_id:%d in:%d queue:%d avg_per:%d rate:%d", __func__,
6057 staid[i], pTLCb->atlSTAClients[staid[i]]->tx_samples_sum,
6058 pTLCb->atlSTAClients[staid[i]]->queue,
6059 pTLCb->atlSTAClients[staid[i]]->per,
6060 pTLCb->atlSTAClients[staid[i]]->trate));
6061 }
6062
6063 for (i = 0; i < num_stas; i++) {
6064 pTLCb->atlSTAClients[staid[i]]->weight =
6065 max_rate/pTLCb->atlSTAClients[staid[i]]->trate;
Sravan Kumar Kairamd482a2b2017-02-09 17:44:58 +05306066 if (pTLCb->atlSTAClients[staid[i]]->weight >=
6067 WLANTL_RATE_RATIO_THRESHOLD) {
6068 if (!pTLCb->atlSTAClients[staid[i]]->set_flag) {
Sravan Kumar Kairamb0edc612016-10-26 13:55:24 +05306069 vos_set_hdd_bad_sta(staid[i]);
6070 pTLCb->atlSTAClients[staid[i]]->set_flag = true;
Sravan Kumar Kairamd482a2b2017-02-09 17:44:58 +05306071 }
6072 /**
6073 * If station's link becomes very bad rssi below -90dbm then because
6074 * of high PER rate high number of packets are stuck in BTQM which is
6075 * affecting the good peers throughput. So throttle further the bad
6076 * link traffic.
6077 */
6078 if ((pTLCb->atlSTAClients[staid[i]]->weight >
6079 WLANTL_WEIGHT_THRESHOLD) &&
6080 (pTLCb->atlSTAClients[staid[i]]->queue >
6081 WLANTL_QUEUE_THRESHOLD))
6082 pTLCb->atlSTAClients[staid[i]]->weight *= 2;
Sravan Kumar Kairamb0edc612016-10-26 13:55:24 +05306083 }
6084 if (pTLCb->atlSTAClients[staid[i]]->weight <
6085 WLANTL_RATE_RATIO_THRESHOLD) {
Sravan Kumar Kairamd482a2b2017-02-09 17:44:58 +05306086 if (pTLCb->atlSTAClients[staid[i]]->per >= WLANTL_PER_THRESHOLD &&
Sravan Kumar Kairam7ce69332017-02-15 15:41:43 +05306087 pTLCb->atlSTAClients[staid[i]]->queue > WLANTL_QUEUE_THRESHOLD
6088 && !pTLCb->atlSTAClients[staid[i]]->set_flag) {
6089 pTLCb->atlSTAClients[staid[i]]->weight *= 2;
6090 vos_set_hdd_bad_sta(staid[i]);
6091 pTLCb->atlSTAClients[staid[i]]->set_flag = true;
Sravan Kumar Kairam416a0c22017-01-02 22:58:09 +05306092 }
6093 else if (pTLCb->atlSTAClients[staid[i]]->set_flag) {
Sravan Kumar Kairamb0edc612016-10-26 13:55:24 +05306094 vos_reset_hdd_bad_sta(staid[i]);
6095 pTLCb->atlSTAClients[staid[i]]->set_flag = false;
6096 }
6097 }
6098 }
6099 vos_mem_free(staid);
6100 return true;
6101}
Jeff Johnson295189b2012-06-20 16:38:30 -07006102
Sravan Kumar Kairam091e5b62017-01-23 14:14:20 +05306103/**
6104 * WLANTL_CacheEapol() - cache eapol frames
6105 * @pTLCb : pointer to TL context
6106 * @vosTempBuff: pointer to vos packet buff
6107 *
6108 * Return: None
6109 *
6110 */
6111static void WLANTL_CacheEapol(WLANTL_CbType* pTLCb, vos_pkt_t* vosTempBuff)
6112{
6113 if ((NULL == pTLCb) || (NULL == vosTempBuff))
6114 {
6115 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6116 "%s: Invalid input pointer", __func__));
6117 return;
6118 }
6119
6120 if (NULL == pTLCb->vosEapolCachedFrame) {
6121 TLLOG1(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
6122 "%s: Cache Eapol frame", __func__));
6123 pTLCb->vosEapolCachedFrame = vosTempBuff;
6124 }
Sravan Kumar Kairam2e44dd42017-02-13 18:31:09 +05306125 else {
6126 TLLOG1(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
6127 "%s: Drop duplicate EAPOL frame", __func__));
6128 vos_pkt_return_packet(vosTempBuff);
6129 }
Sravan Kumar Kairam091e5b62017-01-23 14:14:20 +05306130}
6131
Sravan Kumar Kairame0e78442017-09-18 18:00:53 +05306132/**
6133 * WLANTL_SampleRxRSSI() - Collect RX rssi samples
6134 * @pTLCb: TL context pointer
6135 * @pBDHeader: RX Meta data pointer
6136 * @sta_id: Station ID
6137 *
6138 * This function records the last twenty RX RSSI samples
6139 *
6140 * Return: void
6141 */
6142static void WLANTL_SampleRxRSSI(WLANTL_CbType* pTLCb, void * pBDHeader,
6143 uint8_t sta_id)
6144{
Alok Kumarbf87d262018-04-17 12:11:38 +05306145 uint8_t count;
6146 uint8_t old_idx;
Sravan Kumar Kairame0e78442017-09-18 18:00:53 +05306147 s8 curr_RSSI, curr_RSSI0, curr_RSSI1;
Alok Kumarbf87d262018-04-17 12:11:38 +05306148 WLANTL_STAClientType *pClientSTA = pTLCb->atlSTAClients[sta_id];
6149
6150 if(pClientSTA == NULL) {
6151 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6152 " %s: pClientSTA is NULL", __func__));
6153 return;
6154 }
6155 count = pClientSTA->rssi_sample_cnt;
6156 old_idx = pClientSTA->rssi_stale_idx;
Sravan Kumar Kairame0e78442017-09-18 18:00:53 +05306157
6158 curr_RSSI0 = WLANTL_GETRSSI0(pBDHeader);
6159 curr_RSSI1 = WLANTL_GETRSSI1(pBDHeader);
6160
6161 curr_RSSI = (curr_RSSI0 > curr_RSSI1) ? curr_RSSI0 : curr_RSSI1;
6162
6163 if (count >= WLANTL_RSSI_SAMPLE_CNT) {
6164 pClientSTA->rssi_sample_sum -= pClientSTA->rssi_sample[old_idx];
6165 pClientSTA->rssi_sample[old_idx] = curr_RSSI;
6166 pClientSTA->rssi_sample_sum += pClientSTA->rssi_sample[old_idx];
Rakshith Suresh Patkarc97b0ec2018-06-05 11:53:08 +05306167 old_idx >= (WLANTL_RSSI_SAMPLE_CNT - 1) ? old_idx = 0 : old_idx++;
Sravan Kumar Kairame0e78442017-09-18 18:00:53 +05306168 pClientSTA->rssi_stale_idx = old_idx;
6169 } else {
6170 pClientSTA->rssi_sample[count] = curr_RSSI;
6171 pClientSTA->rssi_sample_sum += pClientSTA->rssi_sample[count];
6172 pClientSTA->rssi_sample_cnt++;
6173 }
6174}
6175
Alok Kumarda6c8882017-12-08 11:11:59 +05306176/**
6177 * WLANTL_StaMonRX - Send packets to monitor mode
6178 * @pTLCb: TL context pointer
6179 * @pFrame: Rx buffer pointer
6180 * @pBDHeader: RX Meta data pointer
6181 * @sta_id: Station ID
6182 *
6183 * Return: true if RX monitor mode or false otherwise
6184 */
6185static bool WLANTL_StaMonRX(WLANTL_CbType* pTLCb, vos_pkt_t *pFrame,
6186 WDI_DS_RxMetaInfoType *pRxMetadata,
6187 uint8_t sta_id)
6188{
6189 WLANTL_STAClientType *pClientSTA = NULL;
6190 tpSirMacMgmtHdr pHdr = NULL;
6191 v_MACADDR_t *peerMacAddr = NULL;
6192 uint8_t i = 0;
Rajeev Kumar Sirasanagandla8701da32018-02-05 16:59:08 +05306193 uint8_t addr1_index = WDA_GET_RX_ADDR1_IDX(pRxMetadata);
6194 bool tp_data = false;
Alok Kumarda6c8882017-12-08 11:11:59 +05306195
6196 pHdr = (tpSirMacMgmtHdr)pRxMetadata->mpduHeaderPtr;
Rajeev Kumar Sirasanagandla8701da32018-02-05 16:59:08 +05306197 peerMacAddr = (v_MACADDR_t *)pHdr->da;
Alok Kumarda6c8882017-12-08 11:11:59 +05306198
Rajeev Kumar Sirasanagandla8701da32018-02-05 16:59:08 +05306199 if (vos_check_monitor_state() == false)
6200 return false;
6201
6202 if ((addr1_index == 254) &&
6203 WLANTL_IS_DATA_FRAME(WDA_GET_RX_TYPE_SUBTYPE(pRxMetadata)) &&
6204 !pRxMetadata->bcast) {
6205 tp_data = true;
6206 } else if (WLANTL_STA_ID_MONIFACE(sta_id) == 0) {
6207 return false;
6208 }
6209
6210 if (WLANTL_IS_MGMT_FRAME(WDA_GET_RX_TYPE_SUBTYPE(pRxMetadata)) || tp_data) {
Alok Kumarda6c8882017-12-08 11:11:59 +05306211
6212 if (pRxMetadata->bcast)
6213 return false;
6214
6215 for (i = 0; i < WLAN_MAX_STA_COUNT; i++) {
6216 if (NULL == pTLCb->atlSTAClients[i])
6217 continue;
6218 if (0 == pTLCb->atlSTAClients[i]->ucExists)
6219 continue;
6220 if (WLANTL_STA_AUTHENTICATED == pTLCb->atlSTAClients[i]->tlState)
6221 break;
6222 }
6223
Rajeev Kumar Sirasanagandla8701da32018-02-05 16:59:08 +05306224 if (i == WLAN_MAX_STA_COUNT) {
6225 if (tp_data)
6226 return true;
6227
Alok Kumarda6c8882017-12-08 11:11:59 +05306228 return false;
Rajeev Kumar Sirasanagandla8701da32018-02-05 16:59:08 +05306229 }
Alok Kumarda6c8882017-12-08 11:11:59 +05306230
6231 pClientSTA = pTLCb->atlSTAClients[i];
Alok Kumarda6c8882017-12-08 11:11:59 +05306232
6233 if (vos_is_macaddr_equal(peerMacAddr,
Rajeev Kumar Sirasanagandla8701da32018-02-05 16:59:08 +05306234 &pClientSTA->wSTADesc.vSelfMACAddress))
6235 return false;
6236
6237 if (vos_is_macaddr_equal(peerMacAddr, &pTLCb->spoofMacAddr.spoofMac) &&
6238 !tp_data)
Alok Kumarda6c8882017-12-08 11:11:59 +05306239 return false;
6240 }
6241
6242 return true;
6243}
6244
Jeff Johnson295189b2012-06-20 16:38:30 -07006245/*==========================================================================
6246
6247 FUNCTION WLANTL_RxFrames
6248
6249 DESCRIPTION
6250 Callback registered by TL and called by BAL when a packet is received
6251 over the bus. Upon the call of this function TL will make the necessary
6252 decision with regards to the forwarding or queuing of this packet and
6253 the layer it needs to be delivered to.
6254
6255 DEPENDENCIES
6256 TL must be initiailized before this function gets called.
6257 If the frame carried is a data frame then the station for which it is
6258 destined to must have been previously registered with TL.
6259
6260 PARAMETERS
6261
6262 IN
6263 pvosGCtx: pointer to the global vos context; a handle to TL's
6264 or BAL's control block can be extracted from its context
6265
6266 vosDataBuff: it will contain a pointer to the first buffer received,
6267 if there is more then one packet they will be chained
6268 using vOSS buffers.
6269
6270 RETURN VALUE
6271 The result code associated with performing the operation
6272
6273 VOS_STATUS_E_INVAL: Input parameters are invalid
6274 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
6275 page fault
6276 VOS_STATUS_SUCCESS: Everything is good :)
6277
6278 SIDE EFFECTS
6279
6280============================================================================*/
6281VOS_STATUS
6282WLANTL_RxFrames
6283(
6284 v_PVOID_t pvosGCtx,
6285 vos_pkt_t *pFrameDataBuff
6286)
6287{
6288 vos_pkt_t* vosDataBuff = (vos_pkt_t*)pFrameDataBuff;
6289 WLANTL_CbType* pTLCb = NULL;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306290 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07006291 WLANTL_STAFuncType pfnSTAFsm;
6292 vos_pkt_t* vosTempBuff;
6293 v_U8_t ucSTAId;
6294 VOS_STATUS vosStatus;
6295 v_U8_t ucFrmType;
6296 v_PVOID_t pvBDHeader = NULL;
6297 WLANTL_STAEventType wSTAEvent = WLANTL_RX_EVENT;
6298 v_U8_t ucTid = 0;
6299 v_BOOL_t broadcast = VOS_FALSE;
6300 v_BOOL_t selfBcastLoopback = VOS_FALSE;
Madan Mohan Koyyalamudidfd6aa82012-10-18 20:18:43 -07006301 static v_U8_t first_data_pkt_arrived;
Jeff Johnson295189b2012-06-20 16:38:30 -07006302 v_U32_t uDPUSig;
Jeff Johnson295189b2012-06-20 16:38:30 -07006303 v_U16_t usPktLen;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07006304 v_BOOL_t bForwardIAPPwithLLC = VOS_FALSE;
Dino Mycle3b9536d2014-07-09 22:05:24 +05306305#ifdef WLAN_FEATURE_LINK_LAYER_STATS
6306 v_S7_t currentAvgRSSI = 0;
6307 v_U8_t ac;
Dino Mycle3b9536d2014-07-09 22:05:24 +05306308#endif
Sravan Kumar Kairam2e44dd42017-02-13 18:31:09 +05306309 uint8_t ucMPDUHLen;
Sravan Kumar Kairam091e5b62017-01-23 14:14:20 +05306310 uint16_t seq_no;
Sravan Kumar Kairam04f093a2017-11-16 19:59:05 +05306311 u64 pn_num;
Sravan Kumar Kairam2e44dd42017-02-13 18:31:09 +05306312 uint16_t usEtherType = 0;
Alok Kumarda6c8882017-12-08 11:11:59 +05306313 bool sta_mon_data = false;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07006314
Jeff Johnson295189b2012-06-20 16:38:30 -07006315 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
6316
6317 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
6318 "WLAN TL:TL Receive Frames called"));
6319
6320 /*------------------------------------------------------------------------
6321 Sanity check
6322 ------------------------------------------------------------------------*/
6323 if ( NULL == vosDataBuff )
6324 {
6325 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6326 "WLAN TL:Invalid parameter sent on WLANTL_RxFrames"));
6327 return VOS_STATUS_E_INVAL;
6328 }
6329
Katya Nigam3802f202013-12-16 19:27:14 +05306330 /*------------------------------------------------------------------------
6331 Popolaute timestamp as the time when packet arrives
6332 ---------------------------------------------------------------------- */
6333 vosDataBuff->timestamp = vos_timer_get_system_ticks();
6334
Jeff Johnson295189b2012-06-20 16:38:30 -07006335 /*------------------------------------------------------------------------
6336 Extract TL control block
6337 ------------------------------------------------------------------------*/
6338 pTLCb = VOS_GET_TL_CB(pvosGCtx);
6339 if ( NULL == pTLCb )
6340 {
6341 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6342 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_ChangeSTAState"));
6343 return VOS_STATUS_E_FAULT;
6344 }
6345
6346 /*---------------------------------------------------------------------
6347 Save the initial buffer - this is the first received buffer
6348 ---------------------------------------------------------------------*/
6349 vosTempBuff = vosDataBuff;
6350
Sravan Kumar Kairam4ea1c422017-02-21 11:59:13 +05306351 while (NULL != vosDataBuff)
Jeff Johnson295189b2012-06-20 16:38:30 -07006352 {
Madan Mohan Koyyalamudia148e1e2012-11-30 14:52:59 -08006353 broadcast = VOS_FALSE;
6354 selfBcastLoopback = VOS_FALSE;
6355
Jeff Johnson295189b2012-06-20 16:38:30 -07006356 vos_pkt_walk_packet_chain( vosDataBuff, &vosDataBuff, 1/*true*/ );
6357
6358 /*---------------------------------------------------------------------
6359 Peek at BD header - do not remove
6360 !!! Optimize me: only part of header is needed; not entire one
6361 ---------------------------------------------------------------------*/
6362 vosStatus = WDA_DS_PeekRxPacketInfo( vosTempBuff, (v_PVOID_t)&pvBDHeader, 1/*Swap BD*/ );
6363
6364 if ( NULL == pvBDHeader )
6365 {
6366 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6367 "WLAN TL:Cannot extract BD header"));
6368 /* Drop packet */
6369 vos_pkt_return_packet(vosTempBuff);
6370 vosTempBuff = vosDataBuff;
6371 continue;
6372 }
6373
Jeff Johnson295189b2012-06-20 16:38:30 -07006374 /*---------------------------------------------------------------------
Alok Kumarda6c8882017-12-08 11:11:59 +05306375 Check if frame is for monitor interface
6376 ---------------------------------------------------------------------*/
6377 ucSTAId = (v_U8_t)WDA_GET_RX_STAID(pvBDHeader);
6378
6379 sta_mon_data = WLANTL_StaMonRX(pTLCb, vosTempBuff, pvBDHeader, ucSTAId);
6380
6381 if (vos_get_conparam() == VOS_MONITOR_MODE || sta_mon_data)
6382 {
6383 sta_mon_data = false;
6384
6385 if( pTLCb->isConversionReq )
6386 WLANTL_MonTranslate80211To8023Header(vosTempBuff, pTLCb);
6387
6388 pTLCb->pfnMonRx(pvosGCtx, vosTempBuff, pTLCb->isConversionReq);
6389 vosTempBuff = vosDataBuff;
6390 continue;
6391 }
6392
6393 /*---------------------------------------------------------------------
Jeff Johnson295189b2012-06-20 16:38:30 -07006394 Check if FC frame reported from FW
6395 ---------------------------------------------------------------------*/
6396 if(WDA_IS_RX_FC(pvBDHeader))
6397 {
6398 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
6399 "WLAN TL:receive one FC frame"));
6400
Sravan Kumar Kairamb0edc612016-10-26 13:55:24 +05306401 WLANTL_FlowControl(pTLCb, vosTempBuff);
6402
Jeff Johnson295189b2012-06-20 16:38:30 -07006403 /* Drop packet */
6404 vos_pkt_return_packet(vosTempBuff);
6405 vosTempBuff = vosDataBuff;
6406 continue;
6407 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006408
6409 /* AMSDU HW bug fix
6410 * After 2nd AMSDU subframe HW could not handle BD correctly
6411 * HAL workaround is needed */
6412 if(WDA_GET_RX_ASF(pvBDHeader))
6413 {
6414 WDA_DS_RxAmsduBdFix(pvosGCtx, pvBDHeader);
6415 }
6416
6417 /*---------------------------------------------------------------------
6418 Extract frame control field from 802.11 header if present
6419 (frame translation not done)
6420 ---------------------------------------------------------------------*/
6421
6422 vosStatus = WDA_DS_GetFrameTypeSubType( pvosGCtx, vosTempBuff,
6423 pvBDHeader, &ucFrmType );
6424 if ( VOS_STATUS_SUCCESS != vosStatus )
6425 {
6426 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6427 "WLAN TL:Cannot extract Frame Control Field"));
6428 /* Drop packet */
6429 vos_pkt_return_packet(vosTempBuff);
6430 vosTempBuff = vosDataBuff;
6431 continue;
6432 }
6433
Jeff Johnson295189b2012-06-20 16:38:30 -07006434 vos_pkt_get_packet_length(vosTempBuff, &usPktLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07006435
6436 /*---------------------------------------------------------------------
6437 Check if management and send to PE
6438 ---------------------------------------------------------------------*/
6439
Deepthi Gowrie89de132015-05-14 12:23:57 +05306440 if ( WLANTL_IS_MGMT_FRAME(ucFrmType))
Jeff Johnson295189b2012-06-20 16:38:30 -07006441 {
6442 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
6443 "WLAN TL:Sending packet to management client"));
6444 if ( VOS_STATUS_SUCCESS != vos_pkt_flatten_rx_pkt(&vosTempBuff))
6445 {
6446 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6447 "WLAN TL:Cannot flatten packet - dropping"));
6448 /* Drop packet */
6449 vos_pkt_return_packet(vosTempBuff);
6450 vosTempBuff = vosDataBuff;
6451 continue;
6452 }
6453 ucSTAId = (v_U8_t)WDA_GET_RX_STAID( pvBDHeader );
6454 /* Read RSSI and update */
6455 if(!WLANTL_STA_ID_INVALID(ucSTAId))
6456 {
6457#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
6458 /* Read RSSI and update */
6459 vosStatus = WLANTL_HSHandleRXFrame(pvosGCtx,
6460 WLANTL_MGMT_FRAME_TYPE,
6461 pvBDHeader,
6462 ucSTAId,
6463 VOS_FALSE,
6464 NULL);
6465#else
6466 vosStatus = WLANTL_ReadRSSI(pvosGCtx, pvBDHeader, ucSTAId);
6467#endif
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05306468 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
6469 {
6470 TLLOGW(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
6471 "Handle RX Management Frame fail within Handoff "
6472 "support module"));
6473 /* Do Not Drop packet at here
6474 * Revisit why HO module return fail
6475 * vos_pkt_return_packet(vosTempBuff);
6476 * vosTempBuff = vosDataBuff;
6477 * continue;
6478 */
6479 }
6480 vosStatus = WLANTL_ReadSNR(pvosGCtx, pvBDHeader, ucSTAId);
6481
6482 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
6483 {
6484 TLLOGW(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
6485 FL("Failed to Read SNR")));
6486 }
Dino Mycle3b9536d2014-07-09 22:05:24 +05306487#ifdef WLAN_FEATURE_LINK_LAYER_STATS
6488 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
6489 if ( NULL != pClientSTA)
6490 {
6491 pClientSTA->interfaceStats.mgmtRx++;
Dino Mycle3b9536d2014-07-09 22:05:24 +05306492 }
6493#endif
Sravan Kumar Kairame0e78442017-09-18 18:00:53 +05306494
6495 WLANTL_SampleRxRSSI(pTLCb, pvBDHeader, ucSTAId);
6496
Jeff Johnson295189b2012-06-20 16:38:30 -07006497 }
6498
Jeff Johnson295189b2012-06-20 16:38:30 -07006499 pTLCb->tlMgmtFrmClient.pfnTlMgmtFrmRx( pvosGCtx, vosTempBuff);
6500 }
6501 else /* Data Frame */
6502 {
6503 ucSTAId = (v_U8_t)WDA_GET_RX_STAID( pvBDHeader );
6504 ucTid = (v_U8_t)WDA_GET_RX_TID( pvBDHeader );
Sravan Kumar Kairam091e5b62017-01-23 14:14:20 +05306505 uDPUSig = WDA_GET_RX_DPUSIG(pvBDHeader);
Sravan Kumar Kairam2e44dd42017-02-13 18:31:09 +05306506 ucMPDUHLen = (uint8_t)WDA_GET_RX_MPDU_HEADER_LEN(pvBDHeader);
Sravan Kumar Kairam091e5b62017-01-23 14:14:20 +05306507 seq_no = (uint16_t)WDA_GET_RX_REORDER_CUR_PKT_SEQ_NO(pvBDHeader);
Sravan Kumar Kairam04f093a2017-11-16 19:59:05 +05306508 pn_num = WDA_GET_RX_REPLAY_COUNT(pvBDHeader);
6509
Sravan Kumar Kairamfb0b19d2018-02-01 12:25:28 +05306510 vosTempBuff->pn_replay_skip = 0;
Sravan Kumar Kairam04f093a2017-11-16 19:59:05 +05306511 vosTempBuff->pn_num = pn_num;
Jeff Johnson295189b2012-06-20 16:38:30 -07006512
6513 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
6514 "WLAN TL:Data packet received for STA %d", ucSTAId));
6515
6516 /*------------------------------------------------------------------
6517 This should be corrected when multipe sta support is added !!!
6518 for now bcast frames will be sent to the last registered STA
6519 ------------------------------------------------------------------*/
6520 if ( WDA_IS_RX_BCAST(pvBDHeader))
6521 {
6522 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
6523 "WLAN TL:TL rx Bcast frame - sending to last registered station"));
6524 broadcast = VOS_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006525 /*-------------------------------------------------------------------
6526 If Addr1 is b/mcast, but Addr3 is our own self MAC, it is a b/mcast
6527 pkt we sent looping back to us. To be dropped if we are non BTAMP
6528 -------------------------------------------------------------------*/
6529 if( WLANHAL_RX_BD_ADDR3_SELF_IDX ==
6530 (v_U8_t)WDA_GET_RX_ADDR3_IDX( pvBDHeader ))
6531 {
6532 selfBcastLoopback = VOS_TRUE;
6533 }
6534 }/*if bcast*/
6535
Sravan Kumar Kairam091e5b62017-01-23 14:14:20 +05306536 /* Pre assoc cache eapol */
6537 if (pTLCb->preassoc_caching)
6538 {
Sravan Kumar Kairam2e44dd42017-02-13 18:31:09 +05306539 WLANTL_GetEtherType(pvBDHeader,vosTempBuff, ucMPDUHLen, &usEtherType);
6540 if (WLANTL_LLC_8021X_TYPE != usEtherType)
6541 {
6542 VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
6543 "%s: RX Frame not EAPOL EtherType %d",
6544 __func__, usEtherType);
6545 vos_pkt_return_packet(vosTempBuff);
6546 }
6547 else
6548 {
6549 WLANTL_CacheEapol(pTLCb, vosTempBuff);
6550 TLLOG1(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
6551 "WLAN TL:TL preassoc_caching is enabled seq No: %d", seq_no));
6552 }
6553
Sravan Kumar Kairam091e5b62017-01-23 14:14:20 +05306554 vosTempBuff = vosDataBuff;
6555 continue;
6556 }
6557
Sravan Kumar Kairam09a5e0b2016-05-03 13:17:42 +05306558 if (WLANTL_STA_ID_INVALID(ucSTAId))
Jeff Johnson295189b2012-06-20 16:38:30 -07006559 {
6560 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
Sravan Kumar Kairam09a5e0b2016-05-03 13:17:42 +05306561 "WLAN TL:STAId %d. Invalid STA ID dropping pkt",
6562 ucSTAId));
Jeff Johnson295189b2012-06-20 16:38:30 -07006563 /* Drop packet */
6564 vos_pkt_return_packet(vosTempBuff);
6565 vosTempBuff = vosDataBuff;
6566 continue;
6567 }
6568
Sravan Kumar Kairam09a5e0b2016-05-03 13:17:42 +05306569 if (WLANTL_TID_INVALID( ucTid)) {
6570 /* There is a possibility AP uses wrong TID. In that case to avoid
6571 dropping EAPOL packet in the driver use TID to zero.*/
6572 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
6573 "WLAN TL:Invalid Tid: %d Frame type: %d", ucTid, ucFrmType);
Paul Zhangda6dd252016-08-11 13:51:49 +08006574 WDA_GET_RX_TID( pvBDHeader ) = 0;
Sravan Kumar Kairam09a5e0b2016-05-03 13:17:42 +05306575 ucTid = 0;
6576 }
6577
jagadeesh99d8e632015-04-27 13:21:24 +05306578#ifdef WLAN_FEATURE_LINK_LAYER_STATS
6579 ac = WLANTL_TID_2_AC[ucTid];
6580#endif
6581
Jeff Johnson295189b2012-06-20 16:38:30 -07006582 /*----------------------------------------------------------------------
6583 No need to lock cache access because cache manipulation only happens
6584 in the transport thread/task context
6585 - These frames are to be forwarded to the station upon registration
6586 which happens in the main thread context
6587 The caching here can happen in either Tx or Rx thread depending
6588 on the current SSC scheduling
6589 - also we need to make sure that the frames in the cache are fwd-ed to
6590 the station before the new incoming ones
6591 -----------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306592 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
6593 if (NULL == pClientSTA)
6594 {
6595 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
6596 "WLAN TL:STA not allocated memory. Dropping packet"));
6597 vos_pkt_return_packet(vosTempBuff);
6598 vosTempBuff = vosDataBuff;
6599 continue;
6600 }
6601
Hoonki Lee5305c3a2013-04-29 23:28:59 -07006602#ifdef FEATURE_WLAN_TDLS
6603 if (( pClientSTA->ucExists ) &&
6604 (WLAN_STA_TDLS == pClientSTA->wSTADesc.wSTAType) &&
6605 (pClientSTA->ucTxSuspended))
6606 vos_atomic_set_U8( &pClientSTA->ucTxSuspended, 0 );
6607 else if ( !broadcast && (pClientSTA->ucExists == 0 ) )
6608 {
6609 tpSirMacMgmtHdr pMacHeader = WDA_GET_RX_MAC_HEADER( pvBDHeader );
6610
6611 /* from the direct peer while it is not registered to TL yet */
6612 if ( (pMacHeader->fc.fromDS == 0) &&
6613 (pMacHeader->fc.toDS == 0) )
6614 {
6615 v_U8_t ucAddr3STAId;
6616
6617 ucAddr3STAId = WDA_GET_RX_ADDR3_IDX(pvBDHeader);
6618
6619 if ( WLANTL_STA_ID_INVALID(ucAddr3STAId) )
6620 {
6621 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
6622 "WLAN TL:STA ID %d invalid - dropping pkt", ucAddr3STAId));
6623 /* Drop packet */
6624 vos_pkt_return_packet(vosTempBuff);
6625 vosTempBuff = vosDataBuff;
6626 continue;
6627 }
6628
6629 if (!(pTLCb->atlSTAClients[ucAddr3STAId] && pTLCb->atlSTAClients[ucAddr3STAId]->ucExists &&
6630 (WLAN_STA_INFRA == pTLCb->atlSTAClients[ucAddr3STAId]->wSTADesc.wSTAType) &&
6631 (WLANTL_STA_AUTHENTICATED == pTLCb->atlSTAClients[ucAddr3STAId]->tlState)))
6632 {
6633 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
Arif Hussainf2b00992013-11-17 21:46:15 -08006634 "%s: staId %d addr3Id %d tlState %d. Unkown Receiver/Transmitter Dropping packet", __func__,
Hoonki Lee5305c3a2013-04-29 23:28:59 -07006635 ucSTAId, ucAddr3STAId, pTLCb->atlSTAClients[ucAddr3STAId]->tlState));
6636 vos_pkt_return_packet(vosTempBuff);
6637 vosTempBuff = vosDataBuff;
6638 continue;
6639 }
6640 else
6641 {
Alok Kumar1aacd0e2018-09-17 17:54:02 +05306642 VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_DEBUG,
Sravan Kumar Kairamfb0b19d2018-02-01 12:25:28 +05306643 "staId %d doesn't exist"
6644 " but mapped to AP staId %d PN:[0x%llX]",
6645 ucSTAId, ucAddr3STAId, pn_num);
Hoonki Lee5305c3a2013-04-29 23:28:59 -07006646 ucSTAId = ucAddr3STAId;
6647 pClientSTA = pTLCb->atlSTAClients[ucAddr3STAId];
Sravan Kumar Kairamfb0b19d2018-02-01 12:25:28 +05306648 vosTempBuff->pn_replay_skip = 1;
Hoonki Lee5305c3a2013-04-29 23:28:59 -07006649 }
6650 }
6651 }
6652#endif
6653
Katya Nigam63902932014-06-26 19:04:23 +05306654 if (( pClientSTA->enableCaching == 1 ) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07006655 /*Dont buffer Broadcast/Multicast frames. If AP transmits bursts of Broadcast/Multicast data frames,
6656 * libra buffers all Broadcast/Multicast packets after authentication with AP,
6657 * So it will lead to low resource condition in Rx Data Path.*/
Katya Nigam63902932014-06-26 19:04:23 +05306658 ( WDA_IS_RX_BCAST(pvBDHeader) == 0 ))
Jeff Johnson295189b2012-06-20 16:38:30 -07006659 {
Katya Nigam6201c3e2014-05-27 17:51:42 +05306660 if( WDA_IsSelfSTA(pvosGCtx,ucSTAId))
6661 {
6662 //drop packet for Self STA index
6663 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
6664 "%s: Packet dropped for Self STA with staId %d ", __func__, ucSTAId ));
6665
6666 vos_pkt_return_packet(vosTempBuff);
6667 vosTempBuff = vosDataBuff;
6668 continue;
6669 }
Sravan Kumar Kairam091e5b62017-01-23 14:14:20 +05306670 /* Station has not yet been registered with TL - cache the frame */
Hoonki Lee5305c3a2013-04-29 23:28:59 -07006671 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
Arif Hussainf2b00992013-11-17 21:46:15 -08006672 "%s: staId %d exist %d tlState %d cache rx frame", __func__, ucSTAId,
Hoonki Lee5305c3a2013-04-29 23:28:59 -07006673 pClientSTA->ucExists, pClientSTA->tlState));
Jeff Johnson295189b2012-06-20 16:38:30 -07006674 WLANTL_CacheSTAFrame( pTLCb, ucSTAId, vosTempBuff, uDPUSig, broadcast, ucFrmType);
6675 vosTempBuff = vosDataBuff;
6676 continue;
6677 }
6678
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08006679#ifdef FEATURE_WLAN_ESE_UPLOAD
6680 if ((pClientSTA->wSTADesc.ucIsEseSta)|| broadcast)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07006681 {
6682 /*--------------------------------------------------------------------
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08006683 Filter the IAPP frames for ESE connection;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07006684 if data it will return false and it
6685 will be routed through the regular data path
6686 --------------------------------------------------------------------*/
6687 if ( WLANTL_IsIAPPFrame(pvBDHeader,
6688 vosTempBuff))
6689 {
6690 bForwardIAPPwithLLC = VOS_TRUE;
6691 }
6692 }
6693#endif
6694
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08006695#if defined(FEATURE_WLAN_ESE) && !defined(FEATURE_WLAN_ESE_UPLOAD)
6696 if ((pClientSTA->wSTADesc.ucIsEseSta)|| broadcast)
Jeff Johnson295189b2012-06-20 16:38:30 -07006697 {
6698 /*--------------------------------------------------------------------
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08006699 Filter the IAPP frames for ESE connection;
Jeff Johnson295189b2012-06-20 16:38:30 -07006700 if data it will return false and it
6701 will be routed through the regular data path
6702 --------------------------------------------------------------------*/
6703 if ( WLANTL_IsIAPPFrame(pvBDHeader,
6704 vosTempBuff))
6705 {
6706 if ( VOS_STATUS_SUCCESS != vos_pkt_flatten_rx_pkt(&vosTempBuff))
6707 {
6708 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6709 "WLAN TL:Cannot flatten packet - dropping"));
6710 /* Drop packet */
6711 vos_pkt_return_packet(vosTempBuff);
6712 } else {
6713
6714 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08006715 "WLAN TL: Received ESE IAPP Frame"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006716
6717 pTLCb->tlMgmtFrmClient.pfnTlMgmtFrmRx( pvosGCtx, vosTempBuff);
6718 }
6719 vosTempBuff = vosDataBuff;
6720 continue;
6721 }
6722 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08006723#endif /* defined(FEATURE_WLAN_ESE) && !defined(FEATURE_WLAN_ESE_UPLOAD) */
Jeff Johnson295189b2012-06-20 16:38:30 -07006724
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306725 if ( WLAN_STA_BT_AMP == pClientSTA->wSTADesc.wSTAType )
Jeff Johnson295189b2012-06-20 16:38:30 -07006726 {
6727 /*--------------------------------------------------------------------
6728 Process the ctrl BAP frame; if data it will return false and it
6729 will be routed through the regular data path
6730 --------------------------------------------------------------------*/
6731 if ( WLANTL_ProcessBAPFrame( pvBDHeader,
6732 vosTempBuff,
6733 pTLCb,
6734 &first_data_pkt_arrived,
6735 ucSTAId))
6736 {
6737 vosTempBuff = vosDataBuff;
6738 continue;
6739 }
6740 }/*if BT-AMP station*/
6741 else if(selfBcastLoopback == VOS_TRUE)
6742 {
6743 /* Drop packet */
6744 vos_pkt_return_packet(vosTempBuff);
6745 vosTempBuff = vosDataBuff;
6746 continue;
6747 }
6748
6749 /*---------------------------------------------------------------------
6750 Data packet received, send to state machine
6751 ---------------------------------------------------------------------*/
6752 wSTAEvent = WLANTL_RX_EVENT;
6753
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306754 pfnSTAFsm = tlSTAFsm[pClientSTA->tlState].
Jeff Johnson295189b2012-06-20 16:38:30 -07006755 pfnSTATbl[wSTAEvent];
6756
6757 if ( NULL != pfnSTAFsm )
6758 {
6759#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
6760 /* Read RSSI and update */
6761 vosStatus = WLANTL_HSHandleRXFrame(pvosGCtx,
6762 WLANTL_DATA_FRAME_TYPE,
6763 pvBDHeader,
6764 ucSTAId,
6765 broadcast,
6766 vosTempBuff);
6767 broadcast = VOS_FALSE;
6768#else
6769 vosStatus = WLANTL_ReadRSSI(pvosGCtx, pvBDHeader, ucSTAId);
Kiet Lam47325522014-03-10 11:50:46 -07006770#endif
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05306771 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
Jeff Johnson295189b2012-06-20 16:38:30 -07006772 {
6773 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
6774 "Handle RX Data Frame fail within Handoff support module"));
6775 /* Do Not Drop packet at here
6776 * Revisit why HO module return fail
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05306777 * vos_pkt_return_packet(vosTempBuff);
6778 * vosTempBuff = vosDataBuff;
6779 * continue;
Jeff Johnson295189b2012-06-20 16:38:30 -07006780 */
6781 }
Dino Mycle3b9536d2014-07-09 22:05:24 +05306782#ifdef WLAN_FEATURE_LINK_LAYER_STATS
6783 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
6784 if ( NULL != pClientSTA)
6785 {
6786 tpSirMacMgmtHdr pMacHeader = WDA_GET_RX_MAC_HEADER( pvBDHeader );
Mahesh A Saptasagarbbdcf122014-10-28 20:57:11 +05306787 if (!IS_BROADCAST_ADD(pMacHeader->da) && IS_MULTICAST_ADD(pMacHeader->da))
Dino Mycle3b9536d2014-07-09 22:05:24 +05306788 {
6789 pClientSTA->interfaceStats.accessCategoryStats[ac].rxMcast++;
6790 }
6791
6792 WLANTL_HSGetDataRSSI(pvosGCtx, pvBDHeader, ucSTAId,
6793 &currentAvgRSSI);
6794 pClientSTA->interfaceStats.rssiData = currentAvgRSSI;
6795
6796 pClientSTA->interfaceStats.accessCategoryStats[ac].rxMpdu++;
6797 if (WDA_IS_RX_AN_AMPDU (pvBDHeader))
6798 {
6799 pClientSTA->interfaceStats.accessCategoryStats[ac].rxAmpdu++;
6800 }
6801 }
6802
6803
6804#endif
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05306805 vosStatus = WLANTL_ReadSNR(pvosGCtx, pvBDHeader, ucSTAId);
6806
6807 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
6808 {
6809 TLLOGW(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
6810 FL("Failed to Read SNR")));
6811 }
6812
Sravan Kumar Kairame0e78442017-09-18 18:00:53 +05306813 WLANTL_SampleRxRSSI(pTLCb, pvBDHeader, ucSTAId);
6814
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07006815 pfnSTAFsm( pvosGCtx, ucSTAId, &vosTempBuff, bForwardIAPPwithLLC);
Jeff Johnson295189b2012-06-20 16:38:30 -07006816 }
6817 else
6818 {
6819 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
6820 "WLAN TL:NULL state function, STA:%d, State: %d- dropping packet",
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306821 ucSTAId, pClientSTA->tlState));
Jeff Johnson295189b2012-06-20 16:38:30 -07006822 /* Drop packet */
6823 vos_pkt_return_packet(vosTempBuff);
6824 vosTempBuff = vosDataBuff;
6825 continue;
6826 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006827 }/* else data frame*/
6828
6829 vosTempBuff = vosDataBuff;
6830 }/*while chain*/
6831
6832 return VOS_STATUS_SUCCESS;
6833}/* WLANTL_RxFrames */
6834
Dino Mycle3b9536d2014-07-09 22:05:24 +05306835#ifdef WLAN_FEATURE_LINK_LAYER_STATS
6836/*==========================================================================
6837
6838 FUNCTION WLANTL_CollectInterfaceStats
6839
6840 DESCRIPTION
6841 Utility function used by TL to send the statitics
6842
6843 DEPENDENCIES
6844
6845
6846 PARAMETERS
6847
6848 IN
6849
6850 ucSTAId: station for which the statistics need to collected
6851
6852 vosDataBuff: it will contain the pointer to the corresponding
6853 structure
6854
6855 RETURN VALUE
6856 The result code associated with performing the operation
6857
6858 VOS_STATUS_E_INVAL: Input parameters are invalid
6859 VOS_STATUS_SUCCESS: Everything is good :)
6860
6861 SIDE EFFECTS
6862
6863============================================================================*/
6864VOS_STATUS
6865WLANTL_CollectInterfaceStats
6866(
6867 v_PVOID_t pvosGCtx,
6868 v_U8_t ucSTAId,
6869 WLANTL_InterfaceStatsType *vosDataBuff
6870)
6871{
6872 WLANTL_CbType* pTLCb = NULL;
6873 /*------------------------------------------------------------------------
6874 Sanity check
6875 ------------------------------------------------------------------------*/
6876 if ( WLANTL_STA_ID_INVALID( ucSTAId ) )
6877 {
6878 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6879 "WLAN TL:Invalid station id requested on WLANTL_CollectStats"));
6880 return VOS_STATUS_E_FAULT;
6881 }
6882 /*------------------------------------------------------------------------
6883 Extract TL control block
6884 ------------------------------------------------------------------------*/
6885 pTLCb = VOS_GET_TL_CB(pvosGCtx);
6886 if ( NULL == pTLCb )
6887 {
6888 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6889 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_CollectStats"));
6890 return VOS_STATUS_E_FAULT;
6891 }
6892
6893 if ( NULL == pTLCb->atlSTAClients[ucSTAId] )
6894 {
6895 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6896 "WLAN TL:Client Memory was not allocated on %s", __func__));
6897 return VOS_STATUS_E_FAILURE;
6898 }
Srinivas Dasari98947432014-11-07 19:41:24 +05306899 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
6900 "WLAN TL: collect WIFI_STATS_IFACE results"));
6901
Dino Mycle3b9536d2014-07-09 22:05:24 +05306902 vos_mem_copy(vosDataBuff, &pTLCb->atlSTAClients[ucSTAId]->interfaceStats,
6903 sizeof(WLANTL_InterfaceStatsType));
6904 return VOS_STATUS_SUCCESS;
6905}
6906
Srinivas Dasari98947432014-11-07 19:41:24 +05306907/*==========================================================================
6908
6909 FUNCTION WLANTL_ClearInterfaceStats
6910
6911 DESCRIPTION
6912 Utility function used by TL to clear the statitics
6913
6914 DEPENDENCIES
6915
6916
6917 PARAMETERS
6918
6919 IN
6920
6921 ucSTAId: station for which the statistics need to collected
6922
6923 RETURN VALUE
6924 The result code associated with performing the operation
6925
6926 VOS_STATUS_E_INVAL: Input parameters are invalid
6927 VOS_STATUS_SUCCESS: Everything is good :)
6928
6929 SIDE EFFECTS
6930
6931============================================================================*/
6932VOS_STATUS
6933WLANTL_ClearInterfaceStats
6934(
6935 v_PVOID_t pvosGCtx,
6936 v_U8_t ucSTAId,
6937 v_U8_t statsClearReqMask
6938)
6939{
6940 WLANTL_CbType* pTLCb = NULL;
6941 WLANTL_STAClientType* pClientSTA = NULL;
6942 /*------------------------------------------------------------------------
6943 Sanity check
6944 ------------------------------------------------------------------------*/
6945 if ( WLANTL_STA_ID_INVALID( ucSTAId ) )
6946 {
6947 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6948 "WLAN TL:Invalid station id requested on WLANTL_CollectStats"));
6949 return VOS_STATUS_E_FAULT;
6950 }
6951 /*------------------------------------------------------------------------
6952 Extract TL control block
6953 ------------------------------------------------------------------------*/
6954 pTLCb = VOS_GET_TL_CB(pvosGCtx);
6955 if ( NULL == pTLCb )
6956 {
6957 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
6958 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_CollectStats"));
6959 return VOS_STATUS_E_FAULT;
6960 }
6961
6962 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
6963 if ( NULL == pClientSTA )
6964 {
6965 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
6966 "WLAN TL:Client Memory was not allocated on %s", __func__));
6967 return VOS_STATUS_E_FAILURE;
6968 }
6969
6970 if ((statsClearReqMask & WIFI_STATS_IFACE_AC) ||
6971 (statsClearReqMask & WIFI_STATS_IFACE)) {
6972 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
6973 "WLAN TL:cleared WIFI_STATS_IFACE_AC results"));
6974 pClientSTA->interfaceStats.accessCategoryStats[0].rxMcast = 0;
6975 pClientSTA->interfaceStats.accessCategoryStats[1].rxMcast = 0;
6976 pClientSTA->interfaceStats.accessCategoryStats[2].rxMcast = 0;
6977 pClientSTA->interfaceStats.accessCategoryStats[3].rxMcast = 0;
6978
6979 pClientSTA->interfaceStats.accessCategoryStats[0].rxMpdu = 0;
6980 pClientSTA->interfaceStats.accessCategoryStats[1].rxMpdu = 0;
6981 pClientSTA->interfaceStats.accessCategoryStats[2].rxMpdu = 0;
6982 pClientSTA->interfaceStats.accessCategoryStats[3].rxMpdu = 0;
6983
6984 pClientSTA->interfaceStats.accessCategoryStats[0].rxAmpdu = 0;
6985 pClientSTA->interfaceStats.accessCategoryStats[1].rxAmpdu = 0;
6986 pClientSTA->interfaceStats.accessCategoryStats[2].rxAmpdu = 0;
6987 pClientSTA->interfaceStats.accessCategoryStats[3].rxAmpdu = 0;
6988 }
6989
6990 if (statsClearReqMask & WIFI_STATS_IFACE) {
6991 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
6992 "WLAN TL:cleared WIFI_STATS_IFACE results"));
6993 pClientSTA->interfaceStats.mgmtRx = 0;
6994 pClientSTA->interfaceStats.rssiData = 0;
6995 return VOS_STATUS_SUCCESS;
6996 }
6997
6998 return VOS_STATUS_SUCCESS;
6999}
7000
Dino Mycle3b9536d2014-07-09 22:05:24 +05307001#endif /* WLAN_FEATURE_LINK_LAYER_STATS */
Jeff Johnson295189b2012-06-20 16:38:30 -07007002
7003/*==========================================================================
7004
7005 FUNCTION WLANTL_RxCachedFrames
7006
7007 DESCRIPTION
7008 Utility function used by TL to forward the cached frames to a particular
7009 station;
7010
7011 DEPENDENCIES
7012 TL must be initiailized before this function gets called.
7013 If the frame carried is a data frame then the station for which it is
7014 destined to must have been previously registered with TL.
7015
7016 PARAMETERS
7017
7018 IN
7019 pTLCb: pointer to TL handle
7020
7021 ucSTAId: station for which we need to forward the packets
7022
7023 vosDataBuff: it will contain a pointer to the first cached buffer
7024 received, if there is more then one packet they will be
7025 chained using vOSS buffers.
7026
7027 RETURN VALUE
7028 The result code associated with performing the operation
7029
7030 VOS_STATUS_E_INVAL: Input parameters are invalid
7031 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
7032 page fault
7033 VOS_STATUS_SUCCESS: Everything is good :)
7034
7035 SIDE EFFECTS
7036
7037============================================================================*/
7038VOS_STATUS
7039WLANTL_RxCachedFrames
7040(
7041 WLANTL_CbType* pTLCb,
7042 v_U8_t ucSTAId,
7043 vos_pkt_t* vosDataBuff
7044)
7045{
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307046 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07007047 WLANTL_STAFuncType pfnSTAFsm;
7048 vos_pkt_t* vosTempBuff;
7049 VOS_STATUS vosStatus;
7050 v_PVOID_t pvBDHeader = NULL;
7051 WLANTL_STAEventType wSTAEvent = WLANTL_RX_EVENT;
7052 v_U8_t ucTid = 0;
7053 v_BOOL_t broadcast = VOS_FALSE;
7054 v_BOOL_t bSigMatch = VOS_FALSE;
7055 v_BOOL_t selfBcastLoopback = VOS_FALSE;
Madan Mohan Koyyalamudidfd6aa82012-10-18 20:18:43 -07007056 static v_U8_t first_data_pkt_arrived;
Jeff Johnson295189b2012-06-20 16:38:30 -07007057 v_U32_t uDPUSig;
7058 v_U8_t ucUcastSig;
7059 v_U8_t ucBcastSig;
7060 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
7061
7062 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
7063 "WLAN TL:TL Receive Cached Frames called"));
7064
7065 /*------------------------------------------------------------------------
7066 Sanity check
7067 ------------------------------------------------------------------------*/
7068 if ( NULL == vosDataBuff )
7069 {
7070 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7071 "WLAN TL:Invalid parameter sent on WLANTL_RxFrames"));
7072 return VOS_STATUS_E_INVAL;
7073 }
7074
Mihir Sheteae6f02b2014-04-11 19:49:21 +05307075 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
7076
7077 if ( NULL == pClientSTA )
7078 {
7079 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7080 "WLAN TL:Client Memory was not allocated on %s", __func__));
7081 return VOS_STATUS_E_FAILURE;
7082 }
7083
7084 MTRACE(vos_trace(VOS_MODULE_ID_TL, TRACE_CODE_TL_FORWARD_CACHED_FRAMES,
7085 ucSTAId, 1<<16 | pClientSTA->tlCacheInfo.cacheSize));
7086
Jeff Johnson295189b2012-06-20 16:38:30 -07007087 /*---------------------------------------------------------------------
7088 Save the initial buffer - this is the first received buffer
7089 ---------------------------------------------------------------------*/
7090 vosTempBuff = vosDataBuff;
7091
7092 while ( NULL != vosTempBuff )
7093 {
Madan Mohan Koyyalamudia148e1e2012-11-30 14:52:59 -08007094 broadcast = VOS_FALSE;
7095 selfBcastLoopback = VOS_FALSE;
7096
Jeff Johnson295189b2012-06-20 16:38:30 -07007097 vos_pkt_walk_packet_chain( vosDataBuff, &vosDataBuff, 1/*true*/ );
7098
7099 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
7100 "WLAN TL:Sending new cached packet to station %d", ucSTAId));
7101 /*---------------------------------------------------------------------
7102 Peek at BD header - do not remove
7103 !!! Optimize me: only part of header is needed; not entire one
7104 ---------------------------------------------------------------------*/
7105 vosStatus = WDA_DS_PeekRxPacketInfo( vosTempBuff, (v_PVOID_t)&pvBDHeader, 0 );
7106
7107 if ( NULL == pvBDHeader )
7108 {
7109 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7110 "WLAN TL:Cannot extract BD header"));
7111 /* Drop packet */
7112 vos_pkt_return_packet(vosTempBuff);
7113 vosTempBuff = vosDataBuff;
7114 continue;
7115 }
7116
7117 uDPUSig = WDA_GET_RX_DPUSIG( pvBDHeader );
7118
7119 /* AMSDU HW bug fix
7120 * After 2nd AMSDU subframe HW could not handle BD correctly
7121 * HAL workaround is needed */
7122 if(WDA_GET_RX_ASF(pvBDHeader))
7123 {
7124 WDA_DS_RxAmsduBdFix(vos_get_global_context(VOS_MODULE_ID_TL,pTLCb),
7125 pvBDHeader);
7126 }
7127
7128 ucTid = (v_U8_t)WDA_GET_RX_TID( pvBDHeader );
7129
7130 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
7131 "WLAN TL:Data packet cached for STA %d", ucSTAId);
7132
7133 /*------------------------------------------------------------------
7134 This should be corrected when multipe sta support is added !!!
7135 for now bcast frames will be sent to the last registered STA
7136 ------------------------------------------------------------------*/
7137 if ( WDA_IS_RX_BCAST(pvBDHeader))
7138 {
7139 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
7140 "WLAN TL:TL rx Bcast frame "));
7141 broadcast = VOS_TRUE;
7142
7143 /* If Addr1 is b/mcast, but Addr3 is our own self MAC, it is a b/mcast
7144 * pkt we sent looping back to us. To be dropped if we are non BTAMP
7145 */
7146 if( WLANHAL_RX_BD_ADDR3_SELF_IDX ==
7147 (v_U8_t)WDA_GET_RX_ADDR3_IDX( pvBDHeader ))
7148 {
7149 selfBcastLoopback = VOS_TRUE;
7150 }
7151 }/*if bcast*/
7152
7153 /*-------------------------------------------------------------------------
7154 Check if the packet that we cached matches the DPU signature of the
7155 newly added station
7156 -------------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307157 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
7158
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307159 if ( NULL == pClientSTA )
7160 {
7161 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7162 "WLAN TL:Client Memory was not allocated on %s", __func__));
7163 return VOS_STATUS_E_FAILURE;
7164 }
7165
Jeff Johnson295189b2012-06-20 16:38:30 -07007166 if ( broadcast )
7167 {
7168 ucBcastSig = (v_U8_t)uDPUSig;
7169 bSigMatch = (( WLAN_TL_INVALID_B_SIG !=
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307170 pClientSTA->wSTADesc.ucBcastSig ) &&
7171 ( ucBcastSig == pClientSTA->wSTADesc.ucBcastSig ));
Jeff Johnson295189b2012-06-20 16:38:30 -07007172 }
7173 else
7174 {
7175 ucUcastSig = (v_U8_t)uDPUSig;
7176 bSigMatch = (( WLAN_TL_INVALID_U_SIG !=
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307177 pClientSTA->wSTADesc.ucUcastSig ) &&
7178 ( ucUcastSig == pClientSTA->wSTADesc.ucUcastSig ));
Jeff Johnson295189b2012-06-20 16:38:30 -07007179 }
7180
7181 /*-------------------------------------------------------------------------
7182 If the packet doesn't match - drop it
7183 -------------------------------------------------------------------------*/
7184 if ( !bSigMatch )
7185 {
Rajesh Chauhana6b08f42013-06-18 19:01:26 -07007186 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_MED,
Jeff Johnson295189b2012-06-20 16:38:30 -07007187 "WLAN TL: Cached packet does not match DPU Sig of the new STA - drop "
7188 " DPU Sig %d UC %d BC %d B %d",
7189 uDPUSig,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307190 pClientSTA->wSTADesc.ucUcastSig,
Rajesh Chauhana6b08f42013-06-18 19:01:26 -07007191 pClientSTA->wSTADesc.ucBcastSig,
Jeff Johnson295189b2012-06-20 16:38:30 -07007192 broadcast));
7193
7194 /* Drop packet */
7195 vos_pkt_return_packet(vosTempBuff);
7196 vosTempBuff = vosDataBuff;
7197 continue;
7198
7199 }/*if signature mismatch*/
7200
7201 /*------------------------------------------------------------------------
7202 Check if BT-AMP frame:
7203 - additional processing needed in this case to separate BT-AMP date
7204 from BT-AMP Ctrl path
7205 ------------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307206 if ( WLAN_STA_BT_AMP == pClientSTA->wSTADesc.wSTAType )
Jeff Johnson295189b2012-06-20 16:38:30 -07007207 {
7208 /*--------------------------------------------------------------------
7209 Process the ctrl BAP frame; if data it will return false and it
7210 will be routed through the regular data path
7211 --------------------------------------------------------------------*/
7212 if ( WLANTL_ProcessBAPFrame( pvBDHeader,
7213 vosTempBuff,
7214 pTLCb,
7215 &first_data_pkt_arrived,
7216 ucSTAId))
7217 {
7218 vosTempBuff = vosDataBuff;
7219 continue;
7220 }
7221 }/*if BT-AMP station*/
7222 else if(selfBcastLoopback == VOS_TRUE)
7223 {
7224 /* Drop packet */
7225 vos_pkt_return_packet(vosTempBuff);
7226 vosTempBuff = vosDataBuff;
7227 continue;
7228 }
7229
7230 /*---------------------------------------------------------------------
7231 Data packet received, send to state machine
7232 ---------------------------------------------------------------------*/
7233 wSTAEvent = WLANTL_RX_EVENT;
7234
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307235 pfnSTAFsm = tlSTAFsm[pClientSTA->tlState].
Jeff Johnson295189b2012-06-20 16:38:30 -07007236 pfnSTATbl[wSTAEvent];
7237
7238 if ( NULL != pfnSTAFsm )
7239 {
7240#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
7241 /* Read RSSI and update */
7242 vosStatus = WLANTL_HSHandleRXFrame(vos_get_global_context(
7243 VOS_MODULE_ID_TL,pTLCb),
7244 WLANTL_DATA_FRAME_TYPE,
7245 pvBDHeader,
7246 ucSTAId,
7247 broadcast,
7248 vosTempBuff);
7249 broadcast = VOS_FALSE;
7250#else
7251 vosStatus = WLANTL_ReadRSSI(vos_get_global_context(VOS_MODULE_ID_TL,pTLCb), pvBDHeader, ucSTAId);
Kiet Lam47325522014-03-10 11:50:46 -07007252#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007253 if(!VOS_IS_STATUS_SUCCESS(vosStatus))
7254 {
7255 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7256 "Handle RX Data Frame fail within Handoff support module"));
7257 /* Do Not Drop packet at here
7258 * Revisit why HO module return fail
7259 vos_pkt_return_packet(vosTempBuff);
7260 vosTempBuff = vosDataBuff;
7261 continue;
7262 */
7263 }
7264 pfnSTAFsm( vos_get_global_context(VOS_MODULE_ID_TL,pTLCb), ucSTAId,
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07007265 &vosTempBuff, VOS_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07007266 }
7267 else
7268 {
7269 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7270 "WLAN TL:NULL state function, STA:%d, State: %d- dropping packet",
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307271 ucSTAId, pClientSTA->tlState));
Jeff Johnson295189b2012-06-20 16:38:30 -07007272 /* Drop packet */
7273 vos_pkt_return_packet(vosTempBuff);
7274 vosTempBuff = vosDataBuff;
7275 continue;
7276 }
7277
7278 vosTempBuff = vosDataBuff;
7279 }/*while chain*/
7280
7281 return VOS_STATUS_SUCCESS;
7282}/* WLANTL_RxCachedFrames */
7283
Sravan Kumar Kairam091e5b62017-01-23 14:14:20 +05307284/**
7285 * WLANTL_ForwardPkts() - forward cached eapol frames
7286 * @pvosGCtx: pointer to vos global context
7287 * @data: value to indicate either forward or flush
7288 *
7289 * Return: None
7290 *
7291 */
7292static VOS_STATUS WLANTL_ForwardPkts(void* pvosGCtx, uint32_t data)
7293{
7294 WLANTL_CbType* pTLCb = NULL;
7295
7296 pTLCb = VOS_GET_TL_CB(pvosGCtx);
7297 if (NULL == pTLCb) {
7298 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7299 "%s: Invalid input pointer", __func__));
7300 return VOS_STATUS_E_FAULT;
7301 }
7302
7303 if (!data) {
7304 TLLOG2(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
7305 "%s: Pre assoc fail flush cache", __func__));
7306 WLANTL_FlushCachedFrames(pTLCb->vosEapolCachedFrame);
7307 goto done;
7308 }
7309
7310 /* forward packets to HDD */
7311 if (NULL != pTLCb->vosEapolCachedFrame) {
7312 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
7313 "%s: forward pre assoc cached frames", __func__));
7314 WLANTL_MonTranslate80211To8023Header(pTLCb->vosEapolCachedFrame, pTLCb);
7315 pTLCb->pfnEapolFwd(pvosGCtx, pTLCb->vosEapolCachedFrame);
7316 }
7317
7318done:
7319 pTLCb->vosEapolCachedFrame = NULL;
7320 pTLCb->preassoc_caching = false;
7321
7322 return VOS_STATUS_SUCCESS;
7323}
7324
Jeff Johnson295189b2012-06-20 16:38:30 -07007325/*==========================================================================
Katya Nigam664f5032014-05-05 12:24:32 +05307326 FUNCTION WLANTL_RxProcessMsg
7327
7328 DESCRIPTION
7329 Called by VOSS when a message was serialized for TL through the
7330 rx thread/task.
7331
7332 DEPENDENCIES
7333 The TL must be initialized before this function can be called.
7334
7335 PARAMETERS
7336
7337 IN
7338 pvosGCtx: pointer to the global vos context; a handle to TL's
7339 control block can be extracted from its context
7340 message: type and content of the message
7341
7342
7343 RETURN VALUE
7344 The result code associated with performing the operation
7345
7346 VOS_STATUS_E_INVAL: invalid input parameters
7347 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
7348 page fault
7349 VOS_STATUS_SUCCESS: Everything is good :)
7350
7351 Other values can be returned as a result of a function call, please check
7352 corresponding API for more info.
7353 SIDE EFFECTS
7354
7355============================================================================*/
7356VOS_STATUS
7357WLANTL_RxProcessMsg
7358(
7359 v_PVOID_t pvosGCtx,
7360 vos_msg_t* message
7361)
7362{
7363 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
7364 v_U32_t uData;
7365 v_U8_t ucSTAId;
7366 v_U8_t ucUcastSig;
7367 v_U8_t ucBcastSig;
7368
7369 /*------------------------------------------------------------------------
7370 Sanity check
7371 ------------------------------------------------------------------------*/
7372 if ( NULL == message )
7373 {
7374 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7375 "WLAN TL:Invalid parameter sent on WLANTL_RxProcessMessage"));
7376 return VOS_STATUS_E_INVAL;
7377 }
7378
7379 /*------------------------------------------------------------------------
7380 Process message
7381 ------------------------------------------------------------------------*/
7382 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
7383 "WLAN TL:Received message: %d through rx flow", message->type));
7384
7385 switch( message->type )
7386 {
7387
7388 case WLANTL_RX_FWD_CACHED:
7389 /*---------------------------------------------------------------------
7390 The data sent with the message has the following structure:
7391 | 00 | ucBcastSignature | ucUcastSignature | ucSTAID |
7392 each field above is one byte
7393 ---------------------------------------------------------------------*/
7394 uData = message->bodyval;
7395 ucSTAId = ( uData & 0x000000FF);
7396 ucUcastSig = ( uData & 0x0000FF00)>>8;
7397 ucBcastSig = (v_U8_t)(( uData & 0x00FF0000)>>16);
7398 vosStatus = WLANTL_ForwardSTAFrames( pvosGCtx, ucSTAId,
7399 ucUcastSig, ucBcastSig);
7400 break;
7401
Sravan Kumar Kairam091e5b62017-01-23 14:14:20 +05307402 case WLANTL_RX_FWD_PRE_ASSOC_CACHED:
7403 uData = message->bodyval;
7404 vosStatus = WLANTL_ForwardPkts(pvosGCtx, uData);
7405 break;
7406
Katya Nigam664f5032014-05-05 12:24:32 +05307407 default:
7408 /*no processing for now*/
7409 break;
7410 }
7411
7412 return VOS_STATUS_SUCCESS;
7413}
7414
7415
7416/*==========================================================================
Jeff Johnson295189b2012-06-20 16:38:30 -07007417 FUNCTION WLANTL_ResourceCB
7418
7419 DESCRIPTION
7420 Called by the TL when it has packets available for transmission.
7421
7422 DEPENDENCIES
7423 The TL must be registered with BAL before this function can be called.
7424
7425 PARAMETERS
7426
7427 IN
7428 pvosGCtx: pointer to the global vos context; a handle to TL's
7429 or BAL's control block can be extracted from its context
7430
7431 RETURN VALUE
7432 The result code associated with performing the operation
7433
7434 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
7435 page fault
7436 VOS_STATUS_SUCCESS: Everything is good :)
7437
7438 SIDE EFFECTS
7439
7440============================================================================*/
7441VOS_STATUS
7442WLANTL_ResourceCB
7443(
7444 v_PVOID_t pvosGCtx,
7445 v_U32_t uCount
7446)
7447{
7448 WLANTL_CbType* pTLCb = NULL;
7449 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
7450
7451 /*------------------------------------------------------------------------
7452 Sanity check
7453 Extract TL control block
7454 ------------------------------------------------------------------------*/
7455 pTLCb = VOS_GET_TL_CB(pvosGCtx);
7456 if ( NULL == pTLCb )
7457 {
7458 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7459 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_ChangeSTAState"));
7460 return VOS_STATUS_E_FAULT;
7461 }
7462
7463 pTLCb->uResCount = uCount;
7464
7465
7466 /*-----------------------------------------------------------------------
7467 Resume Tx if enough res and not suspended
7468 -----------------------------------------------------------------------*/
7469 if (( pTLCb->uResCount >= WDA_TLI_MIN_RES_MF ) &&
7470 ( 0 == pTLCb->ucTxSuspended ))
7471 {
7472 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
7473 "WLAN TL:Issuing Xmit start request to BAL for avail res ASYNC"));
7474 return WDA_DS_StartXmit(pvosGCtx);
7475 }
7476
7477 return VOS_STATUS_SUCCESS;
7478}/* WLANTL_ResourceCB */
7479
7480
Gopichand Nakkala11acd112012-12-31 16:04:04 -08007481/*==========================================================================
7482 FUNCTION WLANTL_IsTxXmitPending
7483
7484 DESCRIPTION
7485 Called by the WDA when it wants to know whether WDA_DS_TX_START_XMIT msg
7486 is pending in TL msg queue
7487
7488 DEPENDENCIES
7489 The TL must be registered with WDA before this function can be called.
7490
7491 PARAMETERS
7492
7493 IN
7494 pvosGCtx: pointer to the global vos context; a handle to TL's
7495 or WDA's control block can be extracted from its context
7496
7497 RETURN VALUE
7498 The result code associated with performing the operation
7499
7500 0: No WDA_DS_TX_START_XMIT msg pending
7501 1: Msg WDA_DS_TX_START_XMIT already pending in TL msg queue
7502
7503 SIDE EFFECTS
7504
7505============================================================================*/
7506v_BOOL_t
7507WLANTL_IsTxXmitPending
7508(
7509 v_PVOID_t pvosGCtx
7510)
7511{
7512
7513 WLANTL_CbType* pTLCb = NULL;
7514 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
7515
7516 /*------------------------------------------------------------------------
7517 Sanity check
7518 Extract TL control block
7519 ------------------------------------------------------------------------*/
7520 pTLCb = VOS_GET_TL_CB(pvosGCtx);
7521 if ( NULL == pTLCb )
7522 {
7523 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_FATAL,
7524 "WLAN TL:Invalid TL pointer from pvosGCtx in WLANTL_IsTxXmitPending "));
7525 return FALSE;
7526 }
7527
7528 return pTLCb->isTxTranmitMsgPending;
7529
7530}/*WLANTL_IsTxXmitPending */
7531
7532/*==========================================================================
7533 FUNCTION WLANTL_SetTxXmitPending
7534
7535 DESCRIPTION
7536 Called by the WDA when it wants to indicate that WDA_DS_TX_START_XMIT msg
7537 is pending in TL msg queue
7538
7539 DEPENDENCIES
7540 The TL must be registered with WDA before this function can be called.
7541
7542 PARAMETERS
7543
7544 IN
7545 pvosGCtx: pointer to the global vos context; a handle to TL's
7546 or WDA's control block can be extracted from its context
7547
7548 RETURN VALUE None
7549
7550 SIDE EFFECTS
7551
7552============================================================================*/
7553
7554v_VOID_t
7555WLANTL_SetTxXmitPending
7556(
7557 v_PVOID_t pvosGCtx
7558)
7559{
7560
7561 WLANTL_CbType* pTLCb = NULL;
7562 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
7563
7564 /*------------------------------------------------------------------------
7565 Sanity check
7566 Extract TL control block
7567 ------------------------------------------------------------------------*/
7568 pTLCb = VOS_GET_TL_CB(pvosGCtx);
7569 if ( NULL == pTLCb )
7570 {
7571 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_FATAL,
7572 "WLAN TL:Invalid TL pointer from pvosGCtx in WLANTL_SetTxXmitPending"));
7573 return;
7574 }
7575
7576 pTLCb->isTxTranmitMsgPending = 1;
7577 return;
7578
7579}/*WLANTL_SetTxXmitPending */
7580
7581/*==========================================================================
7582 FUNCTION WLANTL_ClearTxXmitPending
7583
7584 DESCRIPTION
7585 Called by the WDA when it wants to indicate that no WDA_DS_TX_START_XMIT msg
7586 is pending in TL msg queue
7587
7588 DEPENDENCIES
7589 The TL must be registered with WDA before this function can be called.
7590
7591 PARAMETERS
7592
7593 IN
7594 pvosGCtx: pointer to the global vos context; a handle to TL's
7595 or WDA's control block can be extracted from its context
7596
7597 RETURN VALUE None
7598
7599 SIDE EFFECTS
7600
7601============================================================================*/
7602
7603v_VOID_t
7604WLANTL_ClearTxXmitPending
7605(
7606 v_PVOID_t pvosGCtx
7607)
7608{
7609
7610 WLANTL_CbType* pTLCb = NULL;
7611 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
7612
7613 /*------------------------------------------------------------------------
7614 Sanity check
7615 Extract TL control block
7616 ------------------------------------------------------------------------*/
7617 pTLCb = VOS_GET_TL_CB(pvosGCtx);
7618 if ( NULL == pTLCb )
7619 {
7620 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_FATAL,
7621 "WLAN TL:Invalid TL pointer from pvosGCtx in WLANTL_ClearTxXmitPending "));
7622 return;
7623 }
7624
7625 pTLCb->isTxTranmitMsgPending = 0;
7626 return;
7627}/*WLANTL_ClearTxXmitPending */
7628
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307629/*==========================================================================
7630 FUNCTION WLANTL_TxThreadDebugHandler
7631
7632 DESCRIPTION
7633 Printing TL Snapshot dump, processed under TxThread context, currently
7634 information regarding the global TlCb struture. Dumps information related
7635 to per active STA connection currently in use by TL.
7636
7637 DEPENDENCIES
7638 The TL must be initialized before this gets called.
7639
7640 PARAMETERS
7641
7642 IN
7643 pvosGCtx: pointer to the global vos context; a handle to TL's
7644 or WDA's control block can be extracted from its context
7645
7646 RETURN VALUE None
7647
7648 SIDE EFFECTS
7649
7650============================================================================*/
7651
7652v_VOID_t
7653WLANTL_TxThreadDebugHandler
7654(
7655 v_PVOID_t *pVosContext
7656)
7657{
7658 WLANTL_CbType* pTLCb = NULL;
7659 WLANTL_STAClientType* pClientSTA = NULL;
7660 int i = 0;
Mihir Shete5d148f12014-12-16 17:54:49 +05307661 v_U8_t uFlowMask; // TX FlowMask from WDA
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307662
7663 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_FATAL,
7664 "WLAN TL: %s Enter ", __func__));
7665
7666 pTLCb = VOS_GET_TL_CB(pVosContext);
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307667
7668 if ( NULL == pVosContext || NULL == pTLCb )
7669 {
7670 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7671 "Global VoS Context or TL Context are NULL"));
7672 return;
7673 }
7674
Mihir Shete5d148f12014-12-16 17:54:49 +05307675 if (VOS_STATUS_SUCCESS == WDA_DS_GetTxFlowMask(pVosContext, &uFlowMask))
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307676 {
7677 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Mihir Shete5d148f12014-12-16 17:54:49 +05307678 "WDA uTxFlowMask: 0x%x", uFlowMask));
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307679 }
Mihir Shete5d148f12014-12-16 17:54:49 +05307680
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307681 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7682 "************************TL DUMP INFORMATION**************"));
7683
7684 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7685 "uDelayedTriggerFrmInt:%d\tuMinFramesProcThres:%d",
7686 pTLCb->tlConfigInfo.uDelayedTriggerFrmInt,
7687 pTLCb->tlConfigInfo.uMinFramesProcThres));
7688
7689 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7690 "Management Frame Client exists: %d",
7691 pTLCb->tlMgmtFrmClient.ucExists));
7692 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7693 "usPendingTxCompleteCount: %d\tucTxSuspended: %d",
7694 pTLCb->usPendingTxCompleteCount,
7695 pTLCb->ucTxSuspended));
7696
7697 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7698 "uResCount: %d", pTLCb->uResCount));
7699
7700 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7701 "ucRegisteredStaId: %d\tucCurrentSTA: %d",
7702 pTLCb->ucRegisteredStaId, pTLCb->ucCurrentSTA));
7703
7704 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7705 "UrgentFrameProcessing: %s\tuFramesProcThres: %d",
7706 (pTLCb->bUrgent?"True":"False"), pTLCb->uFramesProcThres));
7707
7708 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7709 "isTxTranmitMsgPending: %d\t isBMPS: %s",
7710 pTLCb->isTxTranmitMsgPending, pTLCb->isBMPS?"True":"False"));
7711
7712#ifdef FEATURE_WLAN_TDLS
7713 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7714 "TDLS Peer Count: %d", pTLCb->ucTdlsPeerCount));
7715#endif
7716
Mukul Sharma252582d2015-10-23 16:47:36 +05307717 TLLOG1(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307718 "++++++++++++++++++++Registerd Client Information++++++++++"));
7719
7720 for ( i =0; i<WLAN_MAX_STA_COUNT; i++ )
7721 {
7722 pClientSTA = pTLCb->atlSTAClients[i];
7723 if( NULL == pClientSTA || 0 == pClientSTA->ucExists)
7724 {
7725 continue;
7726 }
7727
Mukul Sharma252582d2015-10-23 16:47:36 +05307728 TLLOG1(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307729 "######################STA Index: %d ############################",i));
Mukul Sharma252582d2015-10-23 16:47:36 +05307730 TLLOG1(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO, "WLAN_STADescType:"));
7731 TLLOG1(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307732 "STAId: %d\t STA MAC Address: %pM", pClientSTA->wSTADesc.ucSTAId,
7733 pClientSTA->wSTADesc.vSTAMACAddress.bytes));
Mukul Sharma252582d2015-10-23 16:47:36 +05307734 TLLOG1(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307735 "STA Type: %d\tProtectedFrame: %d",
7736 pClientSTA->wSTADesc.wSTAType, pClientSTA->wSTADesc.ucProtectedFrame));
Mukul Sharma252582d2015-10-23 16:47:36 +05307737 TLLOG1(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307738 "QoS: %d\tRxFrameTrans: %d\tTxFrameTrans: %d",
7739 pClientSTA->wSTADesc.ucQosEnabled, pClientSTA->wSTADesc.ucSwFrameRXXlation,
7740 pClientSTA->wSTADesc.ucSwFrameTXXlation));
Mukul Sharma252582d2015-10-23 16:47:36 +05307741 TLLOG1(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307742 "ucUcastSig: %d\tucBcastSig: %d", pClientSTA->wSTADesc.ucUcastSig,
7743 pClientSTA->wSTADesc.ucBcastSig));
7744
Mukul Sharma252582d2015-10-23 16:47:36 +05307745 TLLOG1(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307746 "ClientIndex: %d\t Exists: %d", i, pClientSTA->ucExists));
Mukul Sharma252582d2015-10-23 16:47:36 +05307747 TLLOG1(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307748 "TL State: %d\t TL Priority: %d", pClientSTA->tlState,
7749 pClientSTA->tlPri));
Mukul Sharma252582d2015-10-23 16:47:36 +05307750 TLLOG1(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307751 "ucTxSuspended: %d\tucPktPending: %d", pClientSTA->ucTxSuspended,
7752 pClientSTA->ucPktPending));
Mukul Sharma252582d2015-10-23 16:47:36 +05307753 TLLOG1(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307754 "ucEAPOLPktPending: %d\tucNoMoreData: %d",
7755 pClientSTA->ucEapolPktPending, pClientSTA->ucNoMoreData));
Mukul Sharma252582d2015-10-23 16:47:36 +05307756 TLLOG1(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Katya Nigam63902932014-06-26 19:04:23 +05307757 "enableCaching: %d\t fcStaTxDisabled: %d", pClientSTA->enableCaching,
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307758 pClientSTA->fcStaTxDisabled));
Mukul Sharma252582d2015-10-23 16:47:36 +05307759 TLLOG1(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307760 "ucCurrentAC: %d\tucServicedAC: %d", pClientSTA->ucCurrentAC,
7761 pClientSTA->ucServicedAC));
Mukul Sharma252582d2015-10-23 16:47:36 +05307762 TLLOG1(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307763 "TID: %d\tautTxCount[0]: %d\tauRxCount[0]: %d",0, pClientSTA->auTxCount[0],
7764 pClientSTA->auRxCount[0]));
Mukul Sharma252582d2015-10-23 16:47:36 +05307765 TLLOG1(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307766 "aucAcMask[0]: %d\taucAcMask[1]: %d\taucAcMask[2]: %d\taucAcMask[3]: %d\t",
7767 pClientSTA->aucACMask[0], pClientSTA->aucACMask[1],
7768 pClientSTA->aucACMask[2], pClientSTA->aucACMask[3]));
7769 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Mukul Sharma252582d2015-10-23 16:47:36 +05307770
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307771 "ucCurrentWeight: %d", pClientSTA->ucCurrentWeight));
7772
7773 if( WLAN_STA_SOFTAP == pClientSTA->wSTADesc.wSTAType)
7774 {
mukul sharma2cdb8ea2015-10-01 14:53:38 +05307775 TLLOG1(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307776 "TrafficStatistics for SOFTAP Station:"));
mukul sharma2cdb8ea2015-10-01 14:53:38 +05307777 TLLOG1(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307778 "RUF=%d\tRMF=%d\tRBF=%d", pClientSTA->trafficStatistics.rxUCFcnt,
7779 pClientSTA->trafficStatistics.rxMCFcnt,
7780 pClientSTA->trafficStatistics.rxBCFcnt));
mukul sharma2cdb8ea2015-10-01 14:53:38 +05307781 TLLOG1(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307782 "RUB=%d\tRMB=%d\tRBB=%d", pClientSTA->trafficStatistics.rxUCBcnt,
7783 pClientSTA->trafficStatistics.rxMCBcnt,
7784 pClientSTA->trafficStatistics.rxBCBcnt));
mukul sharma2cdb8ea2015-10-01 14:53:38 +05307785 TLLOG1(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307786 "TUF=%d\tTMF=%d\tTBF=%d", pClientSTA->trafficStatistics.txUCFcnt,
7787 pClientSTA->trafficStatistics.txMCFcnt,
7788 pClientSTA->trafficStatistics.txBCFcnt));
mukul sharma2cdb8ea2015-10-01 14:53:38 +05307789 TLLOG1(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307790 "TUB=%d\tTMB=%d\tTBB=%d", pClientSTA->trafficStatistics.txUCBcnt,
7791 pClientSTA->trafficStatistics.txMCBcnt,
7792 pClientSTA->trafficStatistics.txBCBcnt));
7793 }
mukul sharma2cdb8ea2015-10-01 14:53:38 +05307794
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307795 }
7796 return;
7797}
7798
7799/*==========================================================================
Mihir Shetefd62d9d2014-08-06 15:08:21 +05307800 FUNCTION WLANTL_FatalErrorHandler
7801
7802 DESCRIPTION
7803 Handle Fatal errors detected on the TX path.
7804 Currently issues SSR to recover from the error.
7805
7806 DEPENDENCIES
7807 The TL must be initialized before this gets called.
7808
7809 PARAMETERS
7810
7811 IN
7812 pvosGCtx: pointer to the global vos context; a handle to TL's
7813 or WDA's control block can be extracted from its context
7814
7815 RETURN VALUE None
7816
7817 SIDE EFFECTS
7818
7819============================================================================*/
7820v_VOID_t
7821WLANTL_FatalErrorHandler
7822(
7823 v_PVOID_t *pVosContext
7824)
7825{
7826
7827 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_FATAL,
7828 "WLAN TL: %s Enter ", __func__));
7829
7830 if ( NULL == pVosContext )
7831 {
7832 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7833 "%s: Global VoS Context or TL Context are NULL",
7834 __func__));
7835 return;
7836 }
7837
7838 /*
7839 * Issue SSR. vos_wlanRestart has tight checks to make sure that
7840 * we do not send an FIQ if previous FIQ is not processed
7841 */
Anurag Chouhanf0d0ba12018-02-09 15:13:43 +05307842 vos_wlanRestart(VOS_REASON_UNSPECIFIED);
Mihir Shetefd62d9d2014-08-06 15:08:21 +05307843}
7844
7845/*==========================================================================
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307846 FUNCTION WLANTL_TLDebugMessage
7847
7848 DESCRIPTION
7849 Post a TL Snapshot request, posts message in TxThread.
7850
7851 DEPENDENCIES
7852 The TL must be initialized before this gets called.
7853
7854 PARAMETERS
7855
7856 IN
7857 displaySnapshot Boolean showing whether to dump the snapshot or not.
7858
7859 RETURN VALUE None
7860
7861 SIDE EFFECTS
7862
7863============================================================================*/
7864
7865v_VOID_t
7866WLANTL_TLDebugMessage
7867(
Mihir Shete327c2ab2014-11-13 15:17:02 +05307868 v_U32_t debugFlags
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307869)
7870{
7871 vos_msg_t vosMsg;
7872 VOS_STATUS status;
7873
Mihir Shete327c2ab2014-11-13 15:17:02 +05307874 if(debugFlags & WLANTL_DEBUG_TX_SNAPSHOT)
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307875 {
7876 vosMsg.reserved = 0;
7877 vosMsg.bodyptr = NULL;
7878 vosMsg.type = WLANTL_TX_SNAPSHOT;
7879
7880 status = vos_tx_mq_serialize( VOS_MODULE_ID_TL, &vosMsg);
7881 if(status != VOS_STATUS_SUCCESS)
7882 {
7883 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR, "TX Msg Posting Failed with status: %d",status));
7884 return;
7885 }
7886 }
Mihir Shete327c2ab2014-11-13 15:17:02 +05307887 if (debugFlags & WLANTL_DEBUG_FW_CLEANUP)
7888 {
7889 vosMsg.reserved = 0;
7890 vosMsg.bodyptr = NULL;
7891 vosMsg.type = WLANTL_TX_FW_DEBUG;
7892
7893 status = vos_tx_mq_serialize( VOS_MODULE_ID_TL, &vosMsg);
7894 if(status != VOS_STATUS_SUCCESS)
7895 {
7896 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR, "TX Msg Posting Failed with status: %d",status));
7897 return;
7898 }
7899 }
Sravan Kumar Kairame9d186c2015-11-27 23:37:02 +05307900 if(debugFlags & WLANTL_DEBUG_KICKDXE)
7901 {
7902 vosMsg.reserved = 0;
7903 vosMsg.bodyptr = NULL;
7904 vosMsg.type = WLANTL_TX_KICKDXE;
7905
7906 status = vos_tx_mq_serialize( VOS_MODULE_ID_TL, &vosMsg);
7907 if(status != VOS_STATUS_SUCCESS)
7908 {
7909 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR, "TX Msg Posting Failed with status: %d",status));
7910 return;
7911 }
7912 }
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307913 return;
7914}
Jeff Johnson295189b2012-06-20 16:38:30 -07007915
Mihir Shetefd62d9d2014-08-06 15:08:21 +05307916/*==========================================================================
7917 FUNCTION WLANTL_FatalError
7918
7919 DESCRIPTION
7920 Fatal error reported in TX path, post an event to TX Thread for further
7921 handling
7922
7923 DEPENDENCIES
7924 The TL must be initialized before this gets called.
7925
7926 PARAMETERS
7927
7928 VOID
7929
7930 RETURN VALUE None
7931
7932 SIDE EFFECTS
7933
7934============================================================================*/
7935
7936v_VOID_t
7937WLANTL_FatalError
7938(
7939 v_VOID_t
7940)
7941{
7942 vos_msg_t vosMsg;
7943 VOS_STATUS status;
7944
7945 vosMsg.reserved = 0;
7946 vosMsg.bodyptr = NULL;
7947 vosMsg.type = WLANTL_TX_FATAL_ERROR;
7948
7949 status = vos_tx_mq_serialize( VOS_MODULE_ID_TL, &vosMsg);
7950 if(status != VOS_STATUS_SUCCESS)
7951 {
7952 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7953 "%s: TX Msg Posting Failed with status: %d",
7954 __func__,status));
7955 }
7956 return;
7957}
Jeff Johnson295189b2012-06-20 16:38:30 -07007958/*============================================================================
7959 TL STATE MACHINE
7960============================================================================*/
7961
7962/*==========================================================================
7963 FUNCTION WLANTL_STATxConn
7964
7965 DESCRIPTION
7966 Transmit in connected state - only EAPOL and WAI packets allowed
7967
7968 DEPENDENCIES
7969 The STA must be registered with TL before this function can be called.
7970
7971 PARAMETERS
7972
7973 IN
7974 pvosGCtx: pointer to the global vos context; a handle to TL's
7975 control block can be extracted from its context
7976 ucSTAId: identifier of the station being processed
7977 vosDataBuff: pointer to the tx vos buffer
7978
7979 RETURN VALUE
7980 The result code associated with performing the operation
7981
7982 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
7983 page fault
7984 VOS_STATUS_SUCCESS: Everything is good :)
7985
7986 Other return values are possible coming from the called functions.
7987 Please check API for additional info.
7988
7989 SIDE EFFECTS
7990
7991============================================================================*/
7992VOS_STATUS
7993WLANTL_STATxConn
7994(
7995 v_PVOID_t pvosGCtx,
7996 v_U8_t ucSTAId,
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07007997 vos_pkt_t** pvosDataBuff,
7998 v_BOOL_t bForwardIAPPwithLLC
Jeff Johnson295189b2012-06-20 16:38:30 -07007999)
8000{
8001 v_U16_t usPktLen;
8002 VOS_STATUS vosStatus;
8003 v_MACADDR_t vDestMacAddr;
8004 vos_pkt_t* vosDataBuff = NULL;
8005 WLANTL_CbType* pTLCb = NULL;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308006 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07008007 WLANTL_MetaInfoType tlMetaInfo;
8008 v_U8_t ucTypeSubtype = 0;
8009 v_U8_t ucTid;
8010 v_U8_t extraHeadSpace = 0;
8011 v_U8_t ucWDSEnabled = 0;
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07008012 v_U8_t ucAC, ucACMask, i;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05308013 v_U32_t txFlag = HAL_TX_NO_ENCRYPTION_MASK;
Jeff Johnson295189b2012-06-20 16:38:30 -07008014 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
8015
8016 /*------------------------------------------------------------------------
8017 Sanity check
8018 Extract TL control block
8019 ------------------------------------------------------------------------*/
8020 pTLCb = VOS_GET_TL_CB(pvosGCtx);
8021 if ( NULL == pTLCb )
8022 {
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07008023 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8024 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_STATxConn");
Jeff Johnson295189b2012-06-20 16:38:30 -07008025 *pvosDataBuff = NULL;
8026 return VOS_STATUS_E_FAULT;
8027 }
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308028 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
8029
8030 if ( NULL == pClientSTA )
8031 {
8032 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8033 "WLAN TL:Client Memory was not allocated on %s", __func__));
8034 return VOS_STATUS_E_FAILURE;
8035 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008036
8037 /*-------------------------------------------------------------------
8038 Disable AC temporary - if successfull retrieve re-enable
8039 The order is justified because of the possible scenario
8040 - TL tryes to fetch packet for AC and it returns NULL
8041 - TL analyzes the data it has received to see if there are
8042 any more pkts available for AC -> if not TL will disable AC
8043 - however it is possible that while analyzing results TL got
8044 preempted by a pending indication where the mask was again set
8045 TL will not check again and as a result when it resumes
8046 execution it will disable AC
8047 To prevent this the AC will be disabled here and if retrieve
8048 is successfull it will be re-enabled
8049 -------------------------------------------------------------------*/
8050
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07008051
8052 //LTI:pTLCb->atlSTAClients[ucSTAId].
8053 //LTI: aucACMask[pTLCb->atlSTAClients[ucSTAId].ucCurrentAC] = 0;
8054
8055 /*------------------------------------------------------------------------
8056 Fetch packet from HDD
8057 ------------------------------------------------------------------------*/
Sunil Ravid5406f22013-01-22 00:18:31 -08008058#ifdef FEATURE_WLAN_TDLS
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308059 if ((WLAN_STA_SOFTAP != pClientSTA->wSTADesc.wSTAType) &&
Agarwal Ashishcd86f7b2014-06-16 17:11:58 +05308060 !(vos_concurrent_open_sessions_running()) &&
Sunil Ravid5406f22013-01-22 00:18:31 -08008061 !pTLCb->ucTdlsPeerCount)
8062 {
8063#else
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308064 if ((WLAN_STA_SOFTAP != pClientSTA->wSTADesc.wSTAType) &&
Agarwal Ashishcd86f7b2014-06-16 17:11:58 +05308065 !(vos_concurrent_open_sessions_running()))
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07008066 {
Sunil Ravid5406f22013-01-22 00:18:31 -08008067#endif
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308068 ucAC = pClientSTA->ucCurrentAC;
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07008069
8070 /*-------------------------------------------------------------------
8071 Disable AC temporary - if successfull retrieve re-enable
8072 The order is justified because of the possible scenario
8073 - TL tryes to fetch packet for AC and it returns NULL
8074 - TL analyzes the data it has received to see if there are
8075 any more pkts available for AC -> if not TL will disable AC
8076 - however it is possible that while analyzing results TL got
8077 preempted by a pending indication where the mask was again set
8078 TL will not check again and as a result when it resumes
8079 execution it will disable AC
8080 To prevent this the AC will be disabled here and if retrieve
8081 is successfull it will be re-enabled
8082 -------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308083 pClientSTA->aucACMask[ucAC] = 0;
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07008084 }
8085 else
8086 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308087 //softap case
8088 ucAC = pTLCb->uCurServedAC;
8089 pClientSTA->aucACMask[ucAC] = 0;
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07008090 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008091
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308092 /*You make an initial assumption that HDD has no more data and if the
Jeff Johnson295189b2012-06-20 16:38:30 -07008093 assumption was wrong you reset the flags to their original state
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308094 This will prevent from exposing a race condition between checking with HDD
Jeff Johnson295189b2012-06-20 16:38:30 -07008095 for packets and setting the flags to false*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308096 //LTI: vos_atomic_set_U8( &pTLCb->atlSTAClients[ucSTAId].ucPktPending, 0);
8097 //LTI: pTLCb->atlSTAClients[ucSTAId].ucNoMoreData = 1;
8098 vos_atomic_set_U8( &pClientSTA->ucPktPending, 0);
8099 WLAN_TL_AC_ARRAY_2_MASK( pClientSTA, ucACMask, i);
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308100 /*You make an initial assumption that HDD has no more data and if the
8101 assumption was wrong you reset the flags to their original state
8102 This will prevent from exposing a race condition between checking with HDD
8103 for packets and setting the flags to false*/
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07008104 if ( 0 == ucACMask )
8105 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308106 pClientSTA->ucNoMoreData = 1;
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07008107 }
8108 else
8109 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308110 vos_atomic_set_U8( &pClientSTA->ucPktPending, 1);
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07008111 }
8112
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07008113
Madan Mohan Koyyalamudid93f4942012-10-05 15:05:40 -07008114 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07008115 "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 +05308116 ucAC, ucACMask, pClientSTA->ucPktPending);
Jeff Johnson295189b2012-06-20 16:38:30 -07008117
8118 /*------------------------------------------------------------------------
8119 Fetch tx packet from HDD
8120 ------------------------------------------------------------------------*/
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07008121
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308122 vosStatus = pClientSTA->pfnSTAFetchPkt( pvosGCtx,
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07008123 &ucSTAId,
8124 ucAC,
8125 &vosDataBuff, &tlMetaInfo );
Jeff Johnson295189b2012-06-20 16:38:30 -07008126
8127 if (( VOS_STATUS_SUCCESS != vosStatus ) || ( NULL == vosDataBuff ))
8128 {
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07008129 TLLOG1(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -07008130 "WLAN TL:No more data at HDD status %d", vosStatus));
8131 *pvosDataBuff = NULL;
8132
8133 /*--------------------------------------------------------------------
8134 Reset AC for the serviced station to the highest priority AC
8135 -> due to no more data at the station
8136 Even if this AC is not supported by the station, correction will be
8137 made in the main TL loop
8138 --------------------------------------------------------------------*/
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05308139 pClientSTA->ucCurrentAC = WLANTL_AC_HIGH_PRIO;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308140 pClientSTA->ucCurrentWeight = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07008141
Madan Mohan Koyyalamudid8000342012-11-08 14:55:26 -08008142 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07008143 "WLAN TL: WLANTL_STATxConn no more packets in HDD for AC: %d AC Mask: %d",
8144 ucAC, ucACMask);
8145
Jeff Johnson295189b2012-06-20 16:38:30 -07008146 return vosStatus;
8147 }
8148
8149 /*There are still packets in HDD - set back the pending packets and
8150 the no more data assumption*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308151 vos_atomic_set_U8( &pClientSTA->ucPktPending, 1);
8152 pClientSTA->ucNoMoreData = 0;
8153 pClientSTA->aucACMask[ucAC] = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07008154
Jeff Johnson295189b2012-06-20 16:38:30 -07008155#ifdef WLAN_PERF
8156 vos_pkt_set_user_data_ptr( vosDataBuff, VOS_PKT_USER_DATA_ID_BAL,
8157 (v_PVOID_t)0);
8158
8159#endif /*WLAN_PERF*/
8160
8161
8162#ifdef FEATURE_WLAN_WAPI
8163 /*------------------------------------------------------------------------
8164 If the packet is neither an Eapol packet nor a WAI packet then drop it
8165 ------------------------------------------------------------------------*/
8166 if ( 0 == tlMetaInfo.ucIsEapol && 0 == tlMetaInfo.ucIsWai )
8167 {
Madan Mohan Koyyalamudid93f4942012-10-05 15:05:40 -07008168 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -07008169 "WLAN TL:Only EAPOL or WAI packets allowed before authentication"));
8170
8171 /* Fail tx for packet */
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308172 pClientSTA->pfnSTATxComp( pvosGCtx, vosDataBuff,
Jeff Johnson295189b2012-06-20 16:38:30 -07008173 VOS_STATUS_E_BADMSG);
8174 vosDataBuff = NULL;
8175 *pvosDataBuff = NULL;
8176 return VOS_STATUS_SUCCESS;
8177 }
8178#else
8179 if ( 0 == tlMetaInfo.ucIsEapol )
8180 {
8181 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
8182 "WLAN TL:Received non EAPOL packet before authentication"));
8183
8184 /* Fail tx for packet */
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308185 pClientSTA->pfnSTATxComp( pvosGCtx, vosDataBuff,
Jeff Johnson295189b2012-06-20 16:38:30 -07008186 VOS_STATUS_E_BADMSG);
8187 vosDataBuff = NULL;
8188 *pvosDataBuff = NULL;
8189 return VOS_STATUS_SUCCESS;
8190 }
8191#endif /* FEATURE_WLAN_WAPI */
8192
8193 /*-------------------------------------------------------------------------
8194 Check TID
8195 -------------------------------------------------------------------------*/
8196 ucTid = tlMetaInfo.ucTID;
8197
8198 /*Make sure TID is valid*/
8199 if ( WLANTL_TID_INVALID(ucTid))
8200 {
Rajesh Chauhan2df40bf2013-08-22 11:26:12 -07008201 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
Jeff Johnson295189b2012-06-20 16:38:30 -07008202 "WLAN TL:Invalid TID sent in meta info %d - defaulting to 0 (BE)",
8203 ucTid));
8204 ucTid = 0;
8205 }
8206
8207 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
8208 "WLAN TL:Attaching BD header to pkt on WLANTL_STATxConn"));
8209
8210#ifdef FEATURE_WLAN_WAPI
8211 /*------------------------------------------------------------------------
8212 Translate 802.3 frame to 802.11 if Frame translation is enabled or if
8213 frame is a WAI frame.
8214 ------------------------------------------------------------------------*/
8215 if ( ( 1 == tlMetaInfo.ucIsWai ) ||
8216 ( 0 == tlMetaInfo.ucDisableFrmXtl ) )
8217#else
8218 /*------------------------------------------------------------------------
8219 Translate 802.3 frame to 802.11 if Frame translation is enabled
8220 ------------------------------------------------------------------------*/
8221 if ( ( 0 == tlMetaInfo.ucDisableFrmXtl ) &&
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308222 ( 0 != pClientSTA->wSTADesc.ucSwFrameTXXlation) )
Jeff Johnson295189b2012-06-20 16:38:30 -07008223#endif //#ifdef FEATURE_WLAN_WAPI
8224 {
Kiran Venkatappacab0d352012-12-17 13:09:22 -08008225 vosStatus = WLANTL_Translate8023To80211Header( vosDataBuff, &vosStatus,
8226 pTLCb, &ucSTAId,
Ravi Joshid0699502013-07-08 15:48:47 -07008227 &tlMetaInfo, &ucWDSEnabled,
8228 &extraHeadSpace);
Jeff Johnson295189b2012-06-20 16:38:30 -07008229 if ( VOS_STATUS_SUCCESS != vosStatus )
8230 {
8231 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8232 "WLAN TL:Error when translating header WLANTL_STATxConn"));
8233
8234 return vosStatus;
8235 }
8236
8237 tlMetaInfo.ucDisableFrmXtl = 1;
8238 }
8239
8240 /*-------------------------------------------------------------------------
8241 Call HAL to fill BD header
8242 -------------------------------------------------------------------------*/
8243 ucTypeSubtype |= (WLANTL_80211_DATA_TYPE << 4);
8244
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308245 if ( pClientSTA->wSTADesc.ucQosEnabled )
Jeff Johnson295189b2012-06-20 16:38:30 -07008246 {
8247 ucTypeSubtype |= (WLANTL_80211_DATA_QOS_SUBTYPE);
8248 }
8249
Gopichand Nakkala8b54e912013-03-11 10:44:21 +05308250#ifdef FEATURE_WLAN_WAPI
8251 /* TL State does not transition to AUTHENTICATED till GTK is installed, So in
8252 * case of WPA where GTK handshake is done after the 4 way handshake, the
8253 * unicast 2/2 EAPOL packet from the STA->AP has to be encrypted even before
8254 * the TL is in authenticated state. Since the PTK has been installed
8255 * already (after the 4 way handshake) we make sure that all traffic
8256 * is encrypted henceforth.(Note: TL is still not in AUTHENTICATED state so
8257 * we will only allow EAPOL data or WAI in case of WAPI)
8258 */
8259 if (tlMetaInfo.ucIsEapol && pClientSTA->ptkInstalled)
8260 {
8261 txFlag = 0;
8262 }
8263#else
8264 if (pClientSTA->ptkInstalled)
8265 {
8266 txFlag = 0;
8267 }
8268#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07008269
8270 vosStatus = (VOS_STATUS)WDA_DS_BuildTxPacketInfo( pvosGCtx, vosDataBuff , &vDestMacAddr,
8271 tlMetaInfo.ucDisableFrmXtl, &usPktLen,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308272 pClientSTA->wSTADesc.ucQosEnabled, ucWDSEnabled,
Jeff Johnson295189b2012-06-20 16:38:30 -07008273 extraHeadSpace,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308274 ucTypeSubtype, &pClientSTA->wSTADesc.vSelfMACAddress,
Gopichand Nakkala8b54e912013-03-11 10:44:21 +05308275 ucTid, txFlag,
Sravan Kumar Kairamd9e8cbb2017-01-17 12:17:28 +05308276 tlMetaInfo.usTimeStamp, tlMetaInfo.ucIsEapol || tlMetaInfo.ucIsWai,
8277 tlMetaInfo.ucIsArp, tlMetaInfo.ucUP, tlMetaInfo.ucTxBdToken);
Jeff Johnson295189b2012-06-20 16:38:30 -07008278
8279 if ( VOS_STATUS_SUCCESS != vosStatus )
8280 {
8281 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8282 "WLAN TL:Failed while attempting to fill BD %d", vosStatus));
8283 *pvosDataBuff = NULL;
8284 return vosStatus;
8285 }
8286
8287 /*-----------------------------------------------------------------------
8288 Update tx counter for BA session query for tx side
8289 !1 - should this be done for EAPOL frames?
8290 -----------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308291 pClientSTA->auTxCount[ucTid]++;
Jeff Johnson295189b2012-06-20 16:38:30 -07008292
8293 vos_pkt_set_user_data_ptr( vosDataBuff, VOS_PKT_USER_DATA_ID_TL,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308294 (v_PVOID_t)pClientSTA->pfnSTATxComp );
Jeff Johnson295189b2012-06-20 16:38:30 -07008295
8296 /*------------------------------------------------------------------------
8297 Save data to input pointer for TL core
8298 ------------------------------------------------------------------------*/
8299 *pvosDataBuff = vosDataBuff;
8300 /*security frames cannot be delayed*/
8301 pTLCb->bUrgent = TRUE;
8302
Jeff Johnson295189b2012-06-20 16:38:30 -07008303 /* TX Statistics */
8304 if (!(tlMetaInfo.ucBcast || tlMetaInfo.ucMcast))
8305 {
8306 /* This is TX UC frame */
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308307 pClientSTA->trafficStatistics.txUCFcnt++;
8308 pClientSTA->trafficStatistics.txUCBcnt += usPktLen;
Jeff Johnson295189b2012-06-20 16:38:30 -07008309 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008310
8311 return VOS_STATUS_SUCCESS;
8312}/* WLANTL_STATxConn */
8313
8314
8315/*==========================================================================
8316 FUNCTION WLANTL_STATxAuth
8317
8318 DESCRIPTION
8319 Transmit in authenticated state - all data allowed
8320
8321 DEPENDENCIES
8322 The STA must be registered with TL before this function can be called.
8323
8324 PARAMETERS
8325
8326 IN
8327 pvosGCtx: pointer to the global vos context; a handle to TL's
8328 control block can be extracted from its context
8329 ucSTAId: identifier of the station being processed
8330 vosDataBuff: pointer to the tx vos buffer
8331
8332 RETURN VALUE
8333 The result code associated with performing the operation
8334
8335 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
8336 page fault
8337 VOS_STATUS_SUCCESS: Everything is good :)
8338
8339 Other return values are possible coming from the called functions.
8340 Please check API for additional info.
8341
8342 SIDE EFFECTS
8343
8344============================================================================*/
8345VOS_STATUS
8346WLANTL_STATxAuth
8347(
8348 v_PVOID_t pvosGCtx,
8349 v_U8_t ucSTAId,
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07008350 vos_pkt_t** pvosDataBuff,
8351 v_BOOL_t bForwardIAPPwithLLC
Jeff Johnson295189b2012-06-20 16:38:30 -07008352)
8353{
8354 v_U16_t usPktLen;
8355 VOS_STATUS vosStatus;
8356 v_MACADDR_t vDestMacAddr;
8357 vos_pkt_t* vosDataBuff = NULL;
8358 WLANTL_CbType* pTLCb = NULL;
8359 WLANTL_MetaInfoType tlMetaInfo;
8360 v_U8_t ucTypeSubtype = 0;
8361 WLANTL_ACEnumType ucAC;
8362 WLANTL_ACEnumType ucNextAC;
8363 v_U8_t ucTid;
8364 v_U8_t ucSwFrmXtl = 0;
8365 v_U8_t extraHeadSpace = 0;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308366 WLANTL_STAClientType *pStaClient = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07008367 v_U8_t ucWDSEnabled = 0;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05308368 v_U32_t ucTxFlag = 0;
Abhishek Singh45e68fe2014-12-11 12:55:59 +05308369 v_U8_t ucACMask, i;
Jeff Johnson295189b2012-06-20 16:38:30 -07008370 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
8371
8372 /*------------------------------------------------------------------------
8373 Sanity check
8374 Extract TL control block
8375 ------------------------------------------------------------------------*/
8376 pTLCb = VOS_GET_TL_CB(pvosGCtx);
8377 if (( NULL == pTLCb ) || ( NULL == pvosDataBuff ))
8378 {
8379 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Jeff Johnsonddec6482017-09-19 08:33:57 -07008380 "WLAN TL:Invalid input params on WLANTL_STATxAuth TL %pK DB %pK",
Jeff Johnson295189b2012-06-20 16:38:30 -07008381 pTLCb, pvosDataBuff));
8382 if (NULL != pvosDataBuff)
8383 {
8384 *pvosDataBuff = NULL;
8385 }
8386 if(NULL != pTLCb)
8387 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308388 if ( NULL == pTLCb->atlSTAClients[ucSTAId] )
8389 {
8390 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8391 "WLAN TL:Client Memory was not allocated on %s", __func__));
8392 return VOS_STATUS_E_FAILURE;
8393 }
8394 pTLCb->atlSTAClients[ucSTAId]->ucNoMoreData = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07008395 }
8396 return VOS_STATUS_E_FAULT;
8397 }
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308398 pStaClient = pTLCb->atlSTAClients[ucSTAId];
Jeff Johnson295189b2012-06-20 16:38:30 -07008399
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308400 if ( NULL == pStaClient )
8401 {
8402 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8403 "WLAN TL:Client Memory was not allocated on %s", __func__));
8404 return VOS_STATUS_E_FAILURE;
8405 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008406
8407 vos_mem_zero(&tlMetaInfo, sizeof(tlMetaInfo));
8408 /*------------------------------------------------------------------------
8409 Fetch packet from HDD
8410 ------------------------------------------------------------------------*/
Sunil Ravid5406f22013-01-22 00:18:31 -08008411#ifdef FEATURE_WLAN_TDLS
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308412 if ((WLAN_STA_SOFTAP != pStaClient->wSTADesc.wSTAType) &&
Agarwal Ashishcd86f7b2014-06-16 17:11:58 +05308413 (!vos_concurrent_open_sessions_running()) &&
Sunil Ravid5406f22013-01-22 00:18:31 -08008414 !pTLCb->ucTdlsPeerCount)
8415 {
8416#else
Jeff Johnson295189b2012-06-20 16:38:30 -07008417 if ((WLAN_STA_SOFTAP != pStaClient->wSTADesc.wSTAType) &&
Agarwal Ashishcd86f7b2014-06-16 17:11:58 +05308418 (!vos_concurrent_open_sessions_running()))
Jeff Johnson295189b2012-06-20 16:38:30 -07008419 {
8420#endif
8421 ucAC = pStaClient->ucCurrentAC;
8422
8423 /*-------------------------------------------------------------------
8424 Disable AC temporary - if successfull retrieve re-enable
8425 The order is justified because of the possible scenario
8426 - TL tryes to fetch packet for AC and it returns NULL
8427 - TL analyzes the data it has received to see if there are
8428 any more pkts available for AC -> if not TL will disable AC
8429 - however it is possible that while analyzing results TL got
8430 preempted by a pending indication where the mask was again set
8431 TL will not check again and as a result when it resumes
8432 execution it will disable AC
8433 To prevent this the AC will be disabled here and if retrieve
8434 is successfull it will be re-enabled
8435 -------------------------------------------------------------------*/
8436 pStaClient->aucACMask[pStaClient->ucCurrentAC] = 0;
8437
8438 // don't reset it, as other AC queues in HDD may have packets
8439 //vos_atomic_set_U8( &pStaClient->ucPktPending, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07008440 }
8441 else
8442 {
8443 //softap case
8444 ucAC = pTLCb->uCurServedAC;
8445 pStaClient->aucACMask[ucAC] = 0;
8446
8447 //vos_atomic_set_U8( &pStaClient->ucPktPending, 0);
8448 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008449
8450 WLAN_TL_AC_ARRAY_2_MASK( pStaClient, ucACMask, i);
Jeff Johnson295189b2012-06-20 16:38:30 -07008451 /*You make an initial assumption that HDD has no more data and if the
8452 assumption was wrong you reset the flags to their original state
8453 This will prevent from exposing a race condition between checking with HDD
8454 for packets and setting the flags to false*/
8455 if ( 0 == ucACMask )
8456 {
8457 vos_atomic_set_U8( &pStaClient->ucPktPending, 0);
8458 pStaClient->ucNoMoreData = 1;
8459 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008460
8461 vosStatus = pStaClient->pfnSTAFetchPkt( pvosGCtx,
8462 &ucSTAId,
8463 ucAC,
8464 &vosDataBuff, &tlMetaInfo );
8465
8466
8467 if (( VOS_STATUS_SUCCESS != vosStatus ) || ( NULL == vosDataBuff ))
8468 {
8469
8470 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05308471 "WLAN TL:Failed while attempting to fetch pkt from HDD QId:%d status:%d",
8472 ucAC, vosStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07008473 *pvosDataBuff = NULL;
8474 /*--------------------------------------------------------------------
8475 Reset AC for the serviced station to the highest priority AC
8476 -> due to no more data at the station
8477 Even if this AC is not supported by the station, correction will be
8478 made in the main TL loop
8479 --------------------------------------------------------------------*/
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05308480 pStaClient->ucCurrentAC = WLANTL_AC_HIGH_PRIO;
Jeff Johnson295189b2012-06-20 16:38:30 -07008481 pStaClient->ucCurrentWeight = 0;
8482
8483 return vosStatus;
8484 }
8485
Jeff Johnsone7245742012-09-05 17:12:55 -07008486 WLANTL_StatHandleTXFrame(pvosGCtx, ucSTAId, vosDataBuff, NULL, &tlMetaInfo);
Jeff Johnsone7245742012-09-05 17:12:55 -07008487
Jeff Johnson295189b2012-06-20 16:38:30 -07008488 /*There are still packets in HDD - set back the pending packets and
8489 the no more data assumption*/
8490 vos_atomic_set_U8( &pStaClient->ucPktPending, 1);
8491 pStaClient->ucNoMoreData = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07008492
Jeff Johnson295189b2012-06-20 16:38:30 -07008493 if (WLAN_STA_SOFTAP != pStaClient->wSTADesc.wSTAType)
8494 {
Jeff Johnson295189b2012-06-20 16:38:30 -07008495 // don't need to set it, as we don't reset it in this function.
8496 //vos_atomic_set_U8( &pTLCb->atlSTAClients[ucSTAId].ucPktPending, 1);
Jeff Johnson295189b2012-06-20 16:38:30 -07008497 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008498
8499#ifdef WLAN_PERF
8500 vos_pkt_set_user_data_ptr( vosDataBuff, VOS_PKT_USER_DATA_ID_BAL,
8501 (v_PVOID_t)0);
8502#endif /*WLAN_PERF*/
8503
8504 /*-------------------------------------------------------------------------
8505 Check TID
8506 -------------------------------------------------------------------------*/
8507 ucTid = tlMetaInfo.ucTID;
8508
8509 /*Make sure TID is valid*/
8510 if ( WLANTL_TID_INVALID(ucTid))
8511 {
Rajesh Chauhan2df40bf2013-08-22 11:26:12 -07008512 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
Jeff Johnson295189b2012-06-20 16:38:30 -07008513 "WLAN TL:Invalid TID sent in meta info %d - defaulting to 0 (BE)",
8514 ucTid));
8515 ucTid = 0;
8516 }
8517
8518 /*Save for UAPSD timer consideration*/
8519 pStaClient->ucServicedAC = ucAC;
8520
8521 if ( ucAC == pStaClient->ucCurrentAC )
8522 {
8523 pStaClient->aucACMask[pStaClient->ucCurrentAC] = 1;
8524 pStaClient->ucCurrentWeight--;
8525 }
8526 else
8527 {
8528 pStaClient->ucCurrentAC = ucAC;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308529 pStaClient->ucCurrentWeight = pTLCb->tlConfigInfo.ucAcWeights[ucAC] - 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07008530
8531 pStaClient->aucACMask[pStaClient->ucCurrentAC] = 1;
8532
8533 }
8534
Jeff Johnson295189b2012-06-20 16:38:30 -07008535 if (WLAN_STA_SOFTAP != pStaClient->wSTADesc.wSTAType)
8536 {
Jeff Johnson295189b2012-06-20 16:38:30 -07008537 if ( 0 == pStaClient->ucCurrentWeight )
8538 {
8539 WLANTL_ACEnumType tempAC = ucAC;
8540 /*-----------------------------------------------------------------------
8541 Choose next AC - !!! optimize me
8542 -----------------------------------------------------------------------*/
8543 while ( 0 != ucACMask )
8544 {
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05308545 if(tempAC == WLANTL_AC_BK)
8546 ucNextAC = WLANTL_AC_HIGH_PRIO;
8547 else
8548 ucNextAC = (tempAC - 1);
8549
Jeff Johnson295189b2012-06-20 16:38:30 -07008550 if ( 0 != pStaClient->aucACMask[ucNextAC] )
8551 {
8552 pStaClient->ucCurrentAC = ucNextAC;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308553 pStaClient->ucCurrentWeight = pTLCb->tlConfigInfo.ucAcWeights[ucNextAC];
Jeff Johnson295189b2012-06-20 16:38:30 -07008554
8555 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
8556 "WLAN TL: Changing serviced AC to: %d with Weight: %d",
8557 pStaClient->ucCurrentAC ,
8558 pStaClient->ucCurrentWeight));
8559 break;
8560 }
8561 tempAC = ucNextAC;
8562 }
8563 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008564 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008565
8566 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
8567 "WLAN TL:Attaching BD header to pkt on WLANTL_STATxAuth"));
8568
8569 /*------------------------------------------------------------------------
8570 Translate 802.3 frame to 802.11
8571 ------------------------------------------------------------------------*/
8572 if ( 0 == tlMetaInfo.ucDisableFrmXtl )
8573 {
8574 /* Needs frame translation */
8575 // if the client has not enabled SW-only frame translation
8576 // and if the frame is a unicast frame
8577 // (HW frame translation does not support multiple broadcast domains
8578 // so we use SW frame translation for broadcast/multicast frames)
8579#ifdef FEATURE_WLAN_WAPI
8580 // and if the frame is not a WAPI frame
8581#endif
8582 // then use HW_based frame translation
8583
8584 if ( ( 0 == pStaClient->wSTADesc.ucSwFrameTXXlation ) &&
8585 ( 0 == tlMetaInfo.ucBcast ) &&
8586 ( 0 == tlMetaInfo.ucMcast )
8587#ifdef FEATURE_WLAN_WAPI
8588 && ( tlMetaInfo.ucIsWai != 1 )
8589#endif
8590 )
8591 {
8592#ifdef WLAN_PERF
8593 v_U32_t uFastFwdOK = 0;
8594
8595 /* HW based translation. See if the frame could be fast forwarded */
8596 WDA_TLI_FastHwFwdDataFrame( pvosGCtx, vosDataBuff , &vosStatus,
8597 &uFastFwdOK, &tlMetaInfo, &pStaClient->wSTADesc);
8598
8599 if( VOS_STATUS_SUCCESS == vosStatus )
8600 {
8601 if(uFastFwdOK)
8602 {
8603 /* Packet could be fast forwarded now */
8604 vos_pkt_set_user_data_ptr( vosDataBuff, VOS_PKT_USER_DATA_ID_TL,
8605 (v_PVOID_t)pStaClient->pfnSTATxComp );
8606
8607 *pvosDataBuff = vosDataBuff;
8608
8609 /* TODO: Do we really need to update WLANTL_HSHandleTXFrame()
8610 stats for every pkt? */
8611 pStaClient->auTxCount[tlMetaInfo.ucTID]++;
8612 return vosStatus;
8613 }
8614 /* can't be fast forwarded, fall through normal (slow) path. */
8615 }
8616 else
8617 {
8618
8619 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8620 "WLAN TL:Failed while attempting to fastFwd BD %d", vosStatus));
8621 *pvosDataBuff = NULL;
8622 return vosStatus;
8623 }
8624#endif /*WLAN_PERF*/
8625 }
8626 else
8627 {
8628 /* SW based translation */
8629
Kiran Venkatappacab0d352012-12-17 13:09:22 -08008630 vosStatus = WLANTL_Translate8023To80211Header( vosDataBuff, &vosStatus,
8631 pTLCb, &ucSTAId,
Ravi Joshid0699502013-07-08 15:48:47 -07008632 &tlMetaInfo, &ucWDSEnabled,
8633 &extraHeadSpace);
Jeff Johnson295189b2012-06-20 16:38:30 -07008634 if ( VOS_STATUS_SUCCESS != vosStatus )
8635 {
8636 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8637 "WLAN TL:Error when translating header WLANTL_STATxAuth"));
8638 return vosStatus;
8639 }
8640
8641 TLLOG4(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_LOW,
Arif Hussainf2b00992013-11-17 21:46:15 -08008642 "WLAN TL software translation success"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008643 ucSwFrmXtl = 1;
8644 tlMetaInfo.ucDisableFrmXtl = 1;
8645 }
8646 }
Gopichand Nakkala574f6d12013-06-27 19:38:43 +05308647#ifdef FEATURE_WLAN_TDLS
8648 /*In case of TDLS, if the packet is destined to TDLS STA ucSTAId may
8649 change. so update the pStaClient accordingly */
8650 pStaClient = pTLCb->atlSTAClients[ucSTAId];
Jeff Johnson295189b2012-06-20 16:38:30 -07008651
Gopichand Nakkala574f6d12013-06-27 19:38:43 +05308652 if ( NULL == pStaClient )
8653 {
8654 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8655 "pStaClient is NULL %s", __func__));
8656 return VOS_STATUS_E_FAILURE;
8657 }
8658#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07008659 /*-------------------------------------------------------------------------
8660 Call HAL to fill BD header
8661 -------------------------------------------------------------------------*/
8662 ucTypeSubtype |= (WLANTL_80211_DATA_TYPE << 4);
8663
8664 if ( pStaClient->wSTADesc.ucQosEnabled )
8665 {
8666 ucTypeSubtype |= (WLANTL_80211_DATA_QOS_SUBTYPE);
8667 }
8668
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05308669 /* ucAC now points to TL Q ID with a new queue added in TL,
8670 * hence look for the uapsd info for the correct AC that
8671 * this packet belongs to.
8672 */
8673 ucTxFlag = (0 != pStaClient->wUAPSDInfo[tlMetaInfo.ac].ucSet)?
Jeff Johnson295189b2012-06-20 16:38:30 -07008674 HAL_TRIGGER_ENABLED_AC_MASK:0;
8675
8676#ifdef FEATURE_WLAN_WAPI
8677 if ( pStaClient->wSTADesc.ucIsWapiSta == 1 )
8678 {
8679#ifdef LIBRA_WAPI_SUPPORT
8680 ucTxFlag = ucTxFlag | HAL_WAPI_STA_MASK;
8681#endif //LIBRA_WAPI_SUPPORT
8682 if ( tlMetaInfo.ucIsWai == 1 )
8683 {
8684 ucTxFlag = ucTxFlag | HAL_TX_NO_ENCRYPTION_MASK;
8685 }
8686 }
8687#endif /* FEATURE_WLAN_WAPI */
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008688#ifdef FEATURE_WLAN_TDLS
8689 if ( pStaClient->wSTADesc.wSTAType == WLAN_STA_TDLS )
8690 {
8691 ucTxFlag = ucTxFlag | HAL_TDLS_PEER_STA_MASK;
8692 }
8693#endif /* FEATURE_WLAN_TDLS */
Abhishek Singhfa011222014-04-14 10:57:08 +05308694 if( tlMetaInfo.ucIsArp )
8695 {
Sravan Kumar Kairamd9e8cbb2017-01-17 12:17:28 +05308696 if (pTLCb->track_arp)
8697 {
8698 if (vos_check_arp_target_ip(vosDataBuff))
8699 {
8700 ucTxFlag |= HAL_USE_FW_IN_TX_PATH;
8701 ucTxFlag |= HAL_TXCOMP_REQUESTED_MASK;
8702 tlMetaInfo.ucTxBdToken = ++ pTLCb->txbd_token;
8703 }
8704 }
8705
Hanumantha Reddy Pothulae5ab23d2015-09-14 18:08:24 +05308706 if (pStaClient->arpOnWQ5)
8707 {
8708 ucTxFlag |= HAL_USE_FW_IN_TX_PATH;
8709 }
Hanumantha Reddy Pothulaee001fc2015-05-26 15:21:53 +05308710 if (pStaClient->arpRate == 0)
8711 {
8712 ucTxFlag |= HAL_USE_BD_RATE_1_MASK;
8713 }
8714 else if (pStaClient->arpRate == 1 || pStaClient->arpRate == 3)
8715 {
8716 pStaClient->arpRate ^= 0x2;
8717 ucTxFlag |= HAL_USE_BD_RATE_1_MASK<<(pStaClient->arpRate-1);
8718 }
8719 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
8720 "arp pkt sending on BD rate: %hhu", pStaClient->arpRate));
Abhishek Singhfa011222014-04-14 10:57:08 +05308721 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008722
8723 vosStatus = (VOS_STATUS)WDA_DS_BuildTxPacketInfo( pvosGCtx,
8724 vosDataBuff , &vDestMacAddr,
8725 tlMetaInfo.ucDisableFrmXtl, &usPktLen,
8726 pStaClient->wSTADesc.ucQosEnabled, ucWDSEnabled,
8727 extraHeadSpace,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308728 ucTypeSubtype, &pStaClient->wSTADesc.vSelfMACAddress,
Jeff Johnson295189b2012-06-20 16:38:30 -07008729 ucTid, ucTxFlag, tlMetaInfo.usTimeStamp,
Sravan Kumar Kairamd9e8cbb2017-01-17 12:17:28 +05308730 tlMetaInfo.ucIsEapol, tlMetaInfo.ucIsArp, tlMetaInfo.ucUP,
Ganesh Kondabattini10e67352015-03-16 17:41:57 +05308731 tlMetaInfo.ucTxBdToken);
Jeff Johnson295189b2012-06-20 16:38:30 -07008732
8733 if(!VOS_IS_STATUS_SUCCESS(vosStatus))
8734 {
8735 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8736 "Fill TX BD Error status %d", vosStatus));
8737
8738 return vosStatus;
8739 }
8740
Jeff Johnson295189b2012-06-20 16:38:30 -07008741 /* TX Statistics */
8742 if (!(tlMetaInfo.ucBcast || tlMetaInfo.ucMcast))
8743 {
8744 /* This is TX UC frame */
8745 pStaClient->trafficStatistics.txUCFcnt++;
8746 pStaClient->trafficStatistics.txUCBcnt += usPktLen;
8747 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008748
Kiran Venkatappacab0d352012-12-17 13:09:22 -08008749#ifndef FEATURE_WLAN_TDLS
Jeff Johnson295189b2012-06-20 16:38:30 -07008750 /*-----------------------------------------------------------------------
8751 Update tx counter for BA session query for tx side
8752 -----------------------------------------------------------------------*/
8753 pStaClient->auTxCount[ucTid]++;
Kiran Venkatappacab0d352012-12-17 13:09:22 -08008754#else
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308755 pTLCb->atlSTAClients[ucSTAId]->auTxCount[ucTid]++;
Kiran Venkatappacab0d352012-12-17 13:09:22 -08008756#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07008757
8758 /* This code is to send traffic with lower priority AC when we does not
8759 get admitted to send it. Today HAL does not downgrade AC so this code
8760 does not get executed.(In other words, HAL doesnÂ’t change tid. The if
8761 statement is always false.)
8762 NOTE: In the case of LA downgrade occurs in HDD (that was the change
8763 Phani made during WMM-AC plugfest). If WM & BMP also took this approach,
8764 then there will be no need for any AC downgrade logic in TL/WDI. */
8765#if 0
8766 if (( ucTid != tlMetaInfo.ucTID ) &&
8767 ( 0 != pStaClient->wSTADesc.ucQosEnabled ) &&
8768 ( 0 != ucSwFrmXtl ))
8769 {
8770 /*---------------------------------------------------------------------
8771 !! FIX me: Once downgrading is clear put in the proper change
8772 ---------------------------------------------------------------------*/
8773 ucQCOffset = WLANHAL_TX_BD_HEADER_SIZE + WLANTL_802_11_HEADER_LEN;
8774
8775 //!!!Fix this replace peek with extract
8776 vos_pkt_peek_data( vosDataBuff, ucQCOffset,(v_PVOID_t)&pucQosCtrl,
8777 sizeof(*pucQosCtrl));
8778 *pucQosCtrl = ucTid; //? proper byte order
8779 }
8780#endif
8781
8782 if ( VOS_STATUS_SUCCESS != vosStatus )
8783 {
8784 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8785 "WLAN TL:Failed while attempting to fill BD %d", vosStatus));
8786 *pvosDataBuff = NULL;
8787 return vosStatus;
8788 }
8789
8790 vos_pkt_set_user_data_ptr( vosDataBuff, VOS_PKT_USER_DATA_ID_TL,
8791 (v_PVOID_t)pStaClient->pfnSTATxComp );
8792
8793 *pvosDataBuff = vosDataBuff;
8794
8795 /*BE & BK can be delayed, VO and VI not frames cannot be delayed*/
8796 if ( pStaClient->ucServicedAC > WLANTL_AC_BE )
8797 {
8798 pTLCb->bUrgent= TRUE;
8799 }
8800
8801 return VOS_STATUS_SUCCESS;
8802}/* WLANTL_STATxAuth */
8803
8804/*==========================================================================
8805 FUNCTION WLANTL_STATxDisc
8806
8807 DESCRIPTION
8808 Transmit in disconnected state - no data allowed
8809
8810 DEPENDENCIES
8811 The STA must be registered with TL before this function can be called.
8812
8813 PARAMETERS
8814
8815 IN
8816 pvosGCtx: pointer to the global vos context; a handle to TL's
8817 control block can be extracted from its context
8818 ucSTAId: identifier of the station being processed
8819 vosDataBuff: pointer to the tx vos buffer
8820
8821 RETURN VALUE
8822 The result code associated with performing the operation
8823
8824 VOS_STATUS_SUCCESS: Everything is good :)
8825
8826 SIDE EFFECTS
8827
8828============================================================================*/
8829VOS_STATUS
8830WLANTL_STATxDisc
8831(
8832 v_PVOID_t pvosGCtx,
8833 v_U8_t ucSTAId,
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07008834 vos_pkt_t** pvosDataBuff,
8835 v_BOOL_t bForwardIAPPwithLLC
Jeff Johnson295189b2012-06-20 16:38:30 -07008836)
8837{
8838 WLANTL_CbType* pTLCb = NULL;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308839 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07008840 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
8841
Jeff Johnson295189b2012-06-20 16:38:30 -07008842 /*------------------------------------------------------------------------
8843 Sanity check
8844 Extract TL control block
8845 ------------------------------------------------------------------------*/
8846 pTLCb = VOS_GET_TL_CB(pvosGCtx);
8847 if ( NULL == pTLCb )
8848 {
8849 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8850 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_STATxAuth"));
8851 *pvosDataBuff = NULL;
8852 return VOS_STATUS_E_FAULT;
8853 }
8854
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308855 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
8856
8857 if ( NULL == pClientSTA )
8858 {
8859 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8860 "WLAN TL:Client Memory was not allocated on %s", __func__));
8861 return VOS_STATUS_E_FAILURE;
8862 }
8863
Jeff Johnson295189b2012-06-20 16:38:30 -07008864 /*------------------------------------------------------------------------
8865 Error
8866 ------------------------------------------------------------------------*/
8867 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
8868 "WLAN TL:Packet should not be transmitted in state disconnected ignoring"
8869 " request"));
8870
8871 *pvosDataBuff = NULL;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308872 pClientSTA->ucNoMoreData = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07008873
8874 //Should not be anything pending in disconnect state
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308875 vos_atomic_set_U8( &pClientSTA->ucPktPending, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07008876
8877 return VOS_STATUS_SUCCESS;
8878}/* WLANTL_STATxDisc */
8879
8880/*==========================================================================
8881 FUNCTION WLANTL_STARxConn
8882
8883 DESCRIPTION
8884 Receive in connected state - only EAPOL
8885
8886 DEPENDENCIES
8887 The STA must be registered with TL before this function can be called.
8888
8889 PARAMETERS
8890
8891 IN
8892 pvosGCtx: pointer to the global vos context; a handle to TL's
8893 control block can be extracted from its context
8894 ucSTAId: identifier of the station being processed
8895 vosDataBuff: pointer to the tx/rx vos buffer
8896
8897 RETURN VALUE
8898 The result code associated with performing the operation
8899
8900 VOS_STATUS_E_INVAL: invalid input parameters
8901 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
8902 page fault
8903 VOS_STATUS_SUCCESS: Everything is good :)
8904
8905 SIDE EFFECTS
8906
8907============================================================================*/
8908VOS_STATUS
8909WLANTL_STARxConn
8910(
8911 v_PVOID_t pvosGCtx,
8912 v_U8_t ucSTAId,
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07008913 vos_pkt_t** pvosDataBuff,
8914 v_BOOL_t bForwardIAPPwithLLC
Jeff Johnson295189b2012-06-20 16:38:30 -07008915)
8916{
8917 WLANTL_CbType* pTLCb = NULL;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308918 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07008919 v_U16_t usEtherType = 0;
8920 v_U16_t usPktLen;
8921 v_U8_t ucMPDUHOffset;
8922 v_U16_t usMPDUDOffset;
8923 v_U16_t usMPDULen;
8924 v_U8_t ucMPDUHLen;
8925 v_U16_t usActualHLen = 0;
8926 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
8927 vos_pkt_t* vosDataBuff;
8928 v_PVOID_t aucBDHeader;
8929 v_U8_t ucTid;
8930 WLANTL_RxMetaInfoType wRxMetaInfo;
Dundi Raviteja09daf5f2021-03-05 21:03:57 +05308931 v_U8_t ucAsf; /* AMSDU sub frame */
Jeff Johnson295189b2012-06-20 16:38:30 -07008932 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
8933
8934 /*------------------------------------------------------------------------
8935 Sanity check
8936 ------------------------------------------------------------------------*/
8937 if (( NULL == pvosDataBuff ) || ( NULL == ( vosDataBuff = *pvosDataBuff )))
8938 {
8939 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8940 "WLAN TL:Invalid parameter sent on WLANTL_STARxConn"));
8941 return VOS_STATUS_E_INVAL;
8942 }
8943
8944 /*------------------------------------------------------------------------
8945 Extract TL control block
8946 ------------------------------------------------------------------------*/
8947 pTLCb = VOS_GET_TL_CB(pvosGCtx);
8948 if ( NULL == pTLCb )
8949 {
8950 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8951 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_ChangeSTAState"));
8952 return VOS_STATUS_E_FAULT;
8953 }
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308954 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
8955
8956 if ( NULL == pClientSTA )
8957 {
8958 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8959 "WLAN TL:Client Memory was not allocated on %s", __func__));
8960 return VOS_STATUS_E_FAILURE;
8961 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008962
8963 /*------------------------------------------------------------------------
8964 Extract BD header and check if valid
8965 ------------------------------------------------------------------------*/
8966 vosStatus = WDA_DS_PeekRxPacketInfo( vosDataBuff, (v_PVOID_t)&aucBDHeader, 0/*Swap BD*/ );
8967
8968 if ( NULL == aucBDHeader )
8969 {
8970 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8971 "WLAN TL:Cannot extract BD header"));
8972 VOS_ASSERT( 0 );
8973 return VOS_STATUS_E_FAULT;
8974 }
8975
8976
8977 ucMPDUHOffset = (v_U8_t)WDA_GET_RX_MPDU_HEADER_OFFSET(aucBDHeader);
8978 usMPDUDOffset = (v_U16_t)WDA_GET_RX_MPDU_DATA_OFFSET(aucBDHeader);
8979 usMPDULen = (v_U16_t)WDA_GET_RX_MPDU_LEN(aucBDHeader);
8980 ucMPDUHLen = (v_U8_t)WDA_GET_RX_MPDU_HEADER_LEN(aucBDHeader);
8981 ucTid = (v_U8_t)WDA_GET_RX_TID(aucBDHeader);
Dundi Raviteja09daf5f2021-03-05 21:03:57 +05308982 ucAsf = (v_U8_t)WDA_GET_RX_ASF(aucBDHeader);
Jeff Johnson295189b2012-06-20 16:38:30 -07008983
8984 vos_pkt_get_packet_length( vosDataBuff, &usPktLen);
8985
8986 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
8987 "WLAN TL:BD header processing data: HO %d DO %d Len %d HLen %d",
8988 ucMPDUHOffset, usMPDUDOffset, usMPDULen, ucMPDUHLen));
8989
8990 /*It will cut out the 802.11 header if not used*/
8991 if ( VOS_STATUS_SUCCESS != WDA_DS_TrimRxPacketInfo( vosDataBuff ) )
8992 {
8993 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
8994 "WLAN TL:BD header corrupted - dropping packet"));
8995 /* Drop packet */
8996 vos_pkt_return_packet(vosDataBuff);
8997 return VOS_STATUS_SUCCESS;
8998 }
8999
Dundi Raviteja09daf5f2021-03-05 21:03:57 +05309000 if (ucAsf) {
9001 vos_pkt_return_packet(vosDataBuff);
9002 *pvosDataBuff = NULL;
9003 VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9004 "WLAN TL: AMSDU frames are not allowed while authentication - dropping");
9005 return VOS_STATUS_SUCCESS;
9006 }
9007
Jeff Johnson295189b2012-06-20 16:38:30 -07009008 vosStatus = WLANTL_GetEtherType(aucBDHeader,vosDataBuff,ucMPDUHLen,&usEtherType);
9009
9010 if( VOS_IS_STATUS_SUCCESS(vosStatus) )
9011 {
9012#ifdef FEATURE_WLAN_WAPI
9013 /* If frame is neither an EAPOL frame nor a WAI frame then we drop the frame*/
9014 /* TODO: Do we need a check to see if we are in WAPI mode? If not is it possible */
9015 /* that we get an EAPOL packet in WAPI mode or vice versa? */
9016 if ( WLANTL_LLC_8021X_TYPE != usEtherType && WLANTL_LLC_WAI_TYPE != usEtherType )
9017 {
Sunil Ravid5406f22013-01-22 00:18:31 -08009018 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07009019 "WLAN TL:RX Frame not EAPOL or WAI EtherType %d - dropping", usEtherType );
Jeff Johnson295189b2012-06-20 16:38:30 -07009020 /* Drop packet */
9021 vos_pkt_return_packet(vosDataBuff);
9022 }
9023#else
9024 if ( WLANTL_LLC_8021X_TYPE != usEtherType )
9025 {
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07009026 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9027 "WLAN TL:RX Frame not EAPOL EtherType %d - dropping", usEtherType);
Jeff Johnson295189b2012-06-20 16:38:30 -07009028 /* Drop packet */
9029 vos_pkt_return_packet(vosDataBuff);
9030 }
9031#endif /* FEATURE_WLAN_WAPI */
9032 else /* Frame is an EAPOL frame or a WAI frame*/
9033 {
Katya Nigam42e16e82014-02-04 16:28:55 +05309034 MTRACE(vos_trace(VOS_MODULE_ID_TL,
9035 TRACE_CODE_TL_RX_CONN_EAPOL, ucSTAId, usEtherType ));
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07009036
Madan Mohan Koyyalamudid8000342012-11-08 14:55:26 -08009037 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07009038 "WLAN TL:RX Frame EAPOL EtherType %d - processing", usEtherType);
9039
Jeff Johnson295189b2012-06-20 16:38:30 -07009040 if (( 0 == WDA_GET_RX_FT_DONE(aucBDHeader) ) &&
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309041 ( 0 != pClientSTA->wSTADesc.ucSwFrameRXXlation))
Jeff Johnson295189b2012-06-20 16:38:30 -07009042 {
9043 if (usMPDUDOffset > ucMPDUHOffset)
9044 {
9045 usActualHLen = usMPDUDOffset - ucMPDUHOffset;
9046 }
9047
9048 vosStatus = WLANTL_Translate80211To8023Header( vosDataBuff, &vosStatus, usActualHLen,
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009049 ucMPDUHLen, pTLCb, ucSTAId, bForwardIAPPwithLLC);
Jeff Johnson295189b2012-06-20 16:38:30 -07009050
9051 if ( VOS_STATUS_SUCCESS != vosStatus )
9052 {
Kaushik, Sushante386ee12014-05-01 15:50:52 +05309053 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
Jeff Johnson295189b2012-06-20 16:38:30 -07009054 "WLAN TL:Failed to translate from 802.11 to 802.3 - dropping"));
9055 /* Drop packet */
9056 vos_pkt_return_packet(vosDataBuff);
9057 return vosStatus;
9058 }
9059 }
9060 /*-------------------------------------------------------------------
9061 Increment receive counter
9062 -------------------------------------------------------------------*/
Madan Mohan Koyyalamudic0e5bd82012-09-18 17:12:27 -07009063 if ( !WLANTL_TID_INVALID( ucTid) )
9064 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309065 pClientSTA->auRxCount[ucTid]++;
Madan Mohan Koyyalamudic0e5bd82012-09-18 17:12:27 -07009066 }
9067 else
9068 {
9069 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9070 "WLAN TL:Invalid tid %d (Station ID %d) on %s",
9071 ucTid, ucSTAId, __func__));
Hanumantha Reddy Pothula0de10802016-02-11 17:29:27 +05309072 vos_pkt_return_packet(vosDataBuff);
9073 return VOS_STATUS_E_FAILURE;
Madan Mohan Koyyalamudic0e5bd82012-09-18 17:12:27 -07009074 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009075
9076 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
9077 "WLAN TL:Sending EAPoL frame to station %d AC %d", ucSTAId, ucTid));
9078
9079 /*-------------------------------------------------------------------
9080 !!!Assuming TID = UP mapping
9081 -------------------------------------------------------------------*/
9082 wRxMetaInfo.ucUP = ucTid;
9083
Jeff Johnson295189b2012-06-20 16:38:30 -07009084 TLLOG4(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_LOW,
Arif Hussainf2b00992013-11-17 21:46:15 -08009085 "WLAN TL %s:Sending data chain to station", __func__));
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309086 if ( WLAN_STA_SOFTAP == pClientSTA->wSTADesc.wSTAType )
Jeff Johnson295189b2012-06-20 16:38:30 -07009087 {
9088 wRxMetaInfo.ucDesSTAId = WLAN_RX_SAP_SELF_STA_ID;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309089 pClientSTA->pfnSTARx( pvosGCtx, vosDataBuff, ucSTAId,
Jeff Johnson295189b2012-06-20 16:38:30 -07009090 &wRxMetaInfo );
9091 }
9092 else
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309093 pClientSTA->pfnSTARx( pvosGCtx, vosDataBuff, ucSTAId,
Jeff Johnson295189b2012-06-20 16:38:30 -07009094 &wRxMetaInfo );
9095 }/*EAPOL frame or WAI frame*/
9096 }/*vos status success*/
9097
9098 return VOS_STATUS_SUCCESS;
9099}/* WLANTL_STARxConn */
9100
Jeff Johnson295189b2012-06-20 16:38:30 -07009101/*==========================================================================
9102 FUNCTION WLANTL_FwdPktToHDD
9103
9104 DESCRIPTION
9105 Determine the Destation Station ID and route the Frame to Upper Layer
9106
9107 DEPENDENCIES
9108
9109 PARAMETERS
9110
9111 IN
9112 pvosGCtx: pointer to the global vos context; a handle to TL's
9113 control block can be extracted from its context
9114 ucSTAId: identifier of the station being processed
9115 vosDataBuff: pointer to the rx vos buffer
9116
9117 RETURN VALUE
9118 The result code associated with performing the operation
9119
9120 VOS_STATUS_E_INVAL: invalid input parameters
9121 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
9122 page fault
9123 VOS_STATUS_SUCCESS: Everything is good :)
9124
9125 SIDE EFFECTS
9126
9127============================================================================*/
9128
9129VOS_STATUS
9130WLANTL_FwdPktToHDD
9131(
9132 v_PVOID_t pvosGCtx,
9133 vos_pkt_t* pvosDataBuff,
9134 v_U8_t ucSTAId
9135)
9136{
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309137 v_MACADDR_t DestMacAddress;
9138 v_MACADDR_t *pDestMacAddress = &DestMacAddress;
9139 v_SIZE_t usMacAddSize = VOS_MAC_ADDR_SIZE;
Jeff Johnson295189b2012-06-20 16:38:30 -07009140 WLANTL_CbType* pTLCb = NULL;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309141 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07009142 vos_pkt_t* vosDataBuff ;
9143 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
Girish Gowli93e3edd2014-05-01 15:42:31 +05309144 v_U32_t* STAMetaInfoPtr;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309145 vos_pkt_t* vosNextDataBuff ;
9146 v_U8_t ucDesSTAId;
Jeff Johnson295189b2012-06-20 16:38:30 -07009147 WLANTL_RxMetaInfoType wRxMetaInfo;
9148
Jeff Johnson295189b2012-06-20 16:38:30 -07009149 /*------------------------------------------------------------------------
9150 Sanity check
9151 ------------------------------------------------------------------------*/
9152 if (( NULL == pvosDataBuff ) || ( NULL == ( vosDataBuff = pvosDataBuff )))
9153 {
9154 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9155 "WLAN TL:Invalid parameter sent on WLANTL_FwdPktToHdd"));
9156 return VOS_STATUS_E_INVAL;
9157 }
9158
9159 /*------------------------------------------------------------------------
9160 Extract TL control block
9161 ------------------------------------------------------------------------*/
9162 pTLCb = VOS_GET_TL_CB(pvosGCtx);
9163 if ( NULL == pTLCb )
9164 {
9165 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9166 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_FwdPktToHdd"));
9167 return VOS_STATUS_E_FAULT;
9168 }
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309169
Tushnim Bhattacharyya5dd94562013-03-20 20:15:03 -07009170 if(WLANTL_STA_ID_INVALID(ucSTAId))
9171 {
9172 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,"ucSTAId %d is not valid",
9173 ucSTAId));
9174 return VOS_STATUS_E_INVAL;
9175 }
9176
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309177 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
9178
9179 if ( NULL == pClientSTA )
9180 {
9181 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9182 "WLAN TL:Client Memory was not allocated on %s", __func__));
9183 return VOS_STATUS_E_FAILURE;
9184 }
9185
Jeff Johnson295189b2012-06-20 16:38:30 -07009186 /* This the change required for SoftAp to handle Reordered Buffer. Since a STA
9187 may have packets destined to multiple destinations we have to process each packet
9188 at a time and determine its Destination. So the Voschain provided by Reorder code
9189 is unchain and forwarded to Upper Layer after Determining the Destination */
9190
9191 vosDataBuff = pvosDataBuff;
9192 while (vosDataBuff != NULL)
9193 {
9194 vos_pkt_walk_packet_chain( vosDataBuff, &vosNextDataBuff, 1/*true*/ );
9195 vos_pkt_get_user_data_ptr( vosDataBuff, VOS_PKT_USER_DATA_ID_TL,
Girish Gowli93e3edd2014-05-01 15:42:31 +05309196 (v_PVOID_t *)&STAMetaInfoPtr );
9197 wRxMetaInfo.ucUP = (v_U8_t)((uintptr_t)STAMetaInfoPtr & WLANTL_AC_MASK);
9198 ucDesSTAId = (v_U8_t)(((uintptr_t)STAMetaInfoPtr) >> WLANTL_STAID_OFFSET);
Jeff Johnson295189b2012-06-20 16:38:30 -07009199
9200 vosStatus = vos_pkt_extract_data( vosDataBuff, 0, (v_VOID_t *)pDestMacAddress, &usMacAddSize);
9201 if ( VOS_STATUS_SUCCESS != vosStatus )
9202 {
9203 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Arif Hussainf2b00992013-11-17 21:46:15 -08009204 "WLAN TL: recv corrupted data packet"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009205 vos_pkt_return_packet(vosDataBuff);
9206 return vosStatus;
9207 }
9208
Arif Hussaina7c8e412013-11-20 11:06:42 -08009209 TLLOG4(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_LOW,
9210 "station mac "MAC_ADDRESS_STR,
9211 MAC_ADDR_ARRAY(pDestMacAddress->bytes)));
Jeff Johnson295189b2012-06-20 16:38:30 -07009212
9213 if (vos_is_macaddr_broadcast( pDestMacAddress ) || vos_is_macaddr_group(pDestMacAddress))
9214 {
9215 // destination is mc/bc station
9216 ucDesSTAId = WLAN_RX_BCMC_STA_ID;
9217 TLLOG4(VOS_TRACE( VOS_MODULE_ID_HDD_SOFTAP, VOS_TRACE_LEVEL_INFO_LOW,
Arif Hussainf2b00992013-11-17 21:46:15 -08009218 "%s: BC/MC packet, id %d", __func__, WLAN_RX_BCMC_STA_ID));
Jeff Johnson295189b2012-06-20 16:38:30 -07009219 }
9220 else
9221 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309222 if (vos_is_macaddr_equal(pDestMacAddress, &pClientSTA->wSTADesc.vSelfMACAddress))
Jeff Johnson295189b2012-06-20 16:38:30 -07009223 {
9224 // destination is AP itself
9225 ucDesSTAId = WLAN_RX_SAP_SELF_STA_ID;
9226 TLLOG4(VOS_TRACE( VOS_MODULE_ID_HDD_SOFTAP, VOS_TRACE_LEVEL_INFO_LOW,
Arif Hussainf2b00992013-11-17 21:46:15 -08009227 "%s: packet to AP itself, id %d", __func__, WLAN_RX_SAP_SELF_STA_ID));
Jeff Johnson295189b2012-06-20 16:38:30 -07009228 }
Madan Mohan Koyylamudi64258222013-01-30 14:35:10 +05309229 else if (( WLAN_MAX_STA_COUNT <= ucDesSTAId ) || (NULL != pTLCb->atlSTAClients[ucDesSTAId] && pTLCb->atlSTAClients[ucDesSTAId]->ucExists == 0))
Jeff Johnson295189b2012-06-20 16:38:30 -07009230 {
9231 // destination station is something else
9232 TLLOG4(VOS_TRACE( VOS_MODULE_ID_HDD_SOFTAP, VOS_TRACE_LEVEL_INFO_LOW,
Arif Hussainf2b00992013-11-17 21:46:15 -08009233 "%s: get an station index larger than WLAN_MAX_STA_COUNT %d", __func__, ucDesSTAId));
Jeff Johnson295189b2012-06-20 16:38:30 -07009234 ucDesSTAId = WLAN_RX_SAP_SELF_STA_ID;
9235 }
9236
9237
9238 //loopback unicast station comes here
9239 }
9240
Girish Gowli93e3edd2014-05-01 15:42:31 +05309241 wRxMetaInfo.ucUP = (v_U8_t)((uintptr_t)STAMetaInfoPtr & WLANTL_AC_MASK);
Jeff Johnson295189b2012-06-20 16:38:30 -07009242 wRxMetaInfo.ucDesSTAId = ucDesSTAId;
9243
Madan Mohan Koyyalamudi6c2977d2013-09-04 15:42:45 +05309244 vosStatus = pClientSTA->pfnSTARx( pvosGCtx, vosDataBuff, ucDesSTAId,
Jeff Johnson295189b2012-06-20 16:38:30 -07009245 &wRxMetaInfo );
Madan Mohan Koyyalamudi6c2977d2013-09-04 15:42:45 +05309246 if ( VOS_STATUS_SUCCESS != vosStatus )
9247 {
9248 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Arif Hussainf2b00992013-11-17 21:46:15 -08009249 "WLAN TL: failed to send pkt to HDD"));
Madan Mohan Koyyalamudi6c2977d2013-09-04 15:42:45 +05309250 vos_pkt_return_packet(vosDataBuff);
9251
9252 return vosStatus;
9253 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009254 vosDataBuff = vosNextDataBuff;
9255 }
9256 return VOS_STATUS_SUCCESS;
9257}
Jeff Johnson295189b2012-06-20 16:38:30 -07009258
Kapil Guptad90b3862016-06-25 00:42:49 +05309259#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
9260void WLANTL_StopRxRateMonitor(v_PVOID_t pvosGCtx)
9261{
9262 WLANTL_CbType *pTLCb = VOS_GET_TL_CB(pvosGCtx);
9263 if (!pTLCb)
9264 return;
9265 pTLCb->gDsRxRoamStats.running = eWLAN_PAL_FALSE;
9266}
9267
9268void WLANTL_StartRxRateMonitor(v_PVOID_t pvosGCtx, v_U8_t staId,
9269 v_U16_t minRate,
9270 v_U16_t maxRate, v_U8_t minPercentage,
9271 v_U16_t minPktRequired, void *hHal,
9272 v_U64_t timeToWait,
9273 void (*triggerRoamScanfn) (void *, v_U8_t))
9274{
9275
9276 WLANTL_CbType *pTLCb = VOS_GET_TL_CB(pvosGCtx);
9277 if (!pTLCb)
9278 return;
9279
9280 pTLCb->gDsRxRoamStats.running = eWLAN_PAL_TRUE;
9281 pTLCb->gDsRxRoamStats.index = 0;
9282 pTLCb->gDsRxRoamStats.lastTriggerTime = jiffies_to_msecs(jiffies);
9283 pTLCb->gDsRxRoamStats.maxRate = maxRate;
9284 pTLCb->gDsRxRoamStats.minRate = minRate;
9285 pTLCb->gDsRxRoamStats.staId = staId;
9286 pTLCb->gDsRxRoamStats.minPercentage = minPercentage;
9287 pTLCb->gDsRxRoamStats.timeToWait = timeToWait * 1000;
9288 pTLCb->gDsRxRoamStats.intialPktToStart = 0;
9289 pTLCb->gDsRxRoamStats.minPktRequired = minPktRequired;
9290 pTLCb->gDsRxRoamStats.triggerRoamScanfn = triggerRoamScanfn;
9291 pTLCb->gDsRxRoamStats.hHal = hHal;
9292 vos_mem_zero(pTLCb->gDsRxRoamStats.rxRoamStats, ROAM_MAX_INDEX_NUM *
9293 sizeof(WLANTL_RoamTrafficStatsType));
9294 VOS_TRACE(VOS_MODULE_ID_WDI, VOS_TRACE_LEVEL_DEBUG,
9295 "staId=%d, minRate=%d maxRate=%d minPercentage=%d minPktRequired=%d",
9296 staId, minRate, maxRate, minPercentage, minPktRequired);
9297}
9298
9299void static WLANTL_ClearAllRoamStats(WLANTL_CbType *pTLCb)
9300{
9301 pTLCb->gDsRxRoamStats.index = 0;
9302 pTLCb->gDsRxRoamStats.totalPkt = 0;
9303 pTLCb->gDsRxRoamStats.lowRatePkt = 0;
9304 pTLCb->gDsRxRoamStats.intialPktToStart = 0;
9305 vos_mem_zero(pTLCb->gDsRxRoamStats.rxRoamStats, ROAM_MAX_INDEX_NUM *
9306 sizeof(WLANTL_RoamTrafficStatsType));
9307}
9308
9309/*
9310 * WLANTL_ClearRoamStatsTillIndex : This API will clear older data
9311 * at the indexes.
9312 *
9313 * Since its a circular buffer we don't know if we are filling
9314 * data first time or some older data was already present at
9315 * the index. In that case we should clear the older data from
9316 * current index to new index and subtract this data from
9317 * global count as well before filling new one.
9318 */
9319static inline void WLANTL_ClearRoamStatsTillIndex(WLANTL_CbType *pTLCb,
9320 v_U8_t newIndex)
9321{
9322 while (pTLCb->gDsRxRoamStats.index < newIndex)
9323 {
9324 pTLCb->gDsRxRoamStats.index++;
9325 pTLCb->gDsRxRoamStats.totalPkt -=
9326 pTLCb->gDsRxRoamStats.
9327 rxRoamStats[pTLCb->gDsRxRoamStats.index].totalPktRcvd;
9328 pTLCb->gDsRxRoamStats.lowRatePkt -=
9329 pTLCb->gDsRxRoamStats.
9330 rxRoamStats[pTLCb->gDsRxRoamStats.index].lowRateRxPacketsRcvd;
9331 pTLCb->gDsRxRoamStats.
9332 rxRoamStats[pTLCb->gDsRxRoamStats.index].totalPktRcvd = 0;
9333 pTLCb->gDsRxRoamStats.
9334 rxRoamStats[pTLCb->gDsRxRoamStats.index].lowRateRxPacketsRcvd = 0;
9335 }
9336}
9337
9338
9339static void WLANTL_ClearOldPERStats(WLANTL_CbType *pTLCb, v_U8_t incrementCnt)
9340{
9341 v_U8_t newIndex;
9342
9343 newIndex = (pTLCb->gDsRxRoamStats.index + incrementCnt) %
9344 ROAM_MAX_INDEX_NUM;
9345
9346 /* We have crossed the max limit of buffer, clear the stats
9347 * till ROAM_MAX_INDEX_NUM and set index as 0 */
9348 if ((pTLCb->gDsRxRoamStats.index + incrementCnt) >=
9349 ROAM_MAX_INDEX_NUM)
9350 {
9351 WLANTL_ClearRoamStatsTillIndex(pTLCb, ROAM_MAX_INDEX_NUM - 1);
9352 pTLCb->gDsRxRoamStats.index = -1;
9353 }
9354 /* Clear the stats from current index till new index */
9355 WLANTL_ClearRoamStatsTillIndex(pTLCb, newIndex);
9356}
9357
9358/*
9359 * This API implements a circular buffer to store rate stats for a station to
9360 * trigger PER based roam scan.
9361 * API will start monitoring only if DUT gets continues packets which are below
9362 * configured rate. In the upper rates, this should have minimal effect on data
9363 * throughput.
9364 *
9365 * This API will store stats in a circular buffer of size ROAM_MAX_INDEX_NUM
9366 * where each index will have time duration of ROAM_PER_INDEX_TIME.
9367 * Using a buffer instead of counter will help to maintain stats of time
9368 * duration ROAM_PER_INDEX_TIME * ROAM_MAX_INDEX_NUM. Whenever host gets a new
9369 * packet, it will remove last ROAM_PER_INDEX_TIME duration of packets from
9370 * global entry and index entry and fill new data.
9371 *
9372 * Global stats of data also be maintained so that host need not to parse whole
9373 * buffer while checking the trigger condition
9374 * Each of the index will be having the packets stats at duration of
9375 * ROAM_PER_INDEX_TIME from the first packet which arrived in that.
9376 * Global index will be used to calculate new index position to fill once host
9377 * gets a packet.
9378 */
9379static void WLANTL_updatePERStats(WLANTL_CbType *pTLCb,
9380 v_U8_t rateIndex)
9381{
Sravan Kumar Kairamd634cc92016-08-26 16:36:09 +05309382 v_U8_t incrementCnt = 0;
Kapil Guptad90b3862016-06-25 00:42:49 +05309383 v_U64_t currentTime, timeDifference;
9384
9385 /*
9386 * Host will start monitoring Rx rates only if it gets
9387 * MIN_PKTS_TO_START_MONTIOR number of pkts continuously below min rate
9388 * This will make sure we never do this much processing in high
9389 * rates/throughput cases
9390 */
9391
9392 if(pTLCb->gDsRxRoamStats.intialPktToStart < MIN_PKTS_TO_START_MONTIOR)
9393 {
9394 if (gTLRateInfo[rateIndex].phyRate < pTLCb->gDsRxRoamStats.minRate)
9395 pTLCb->gDsRxRoamStats.intialPktToStart++;
9396 else
9397 pTLCb->gDsRxRoamStats.intialPktToStart = 0;
9398 return;
9399 }
9400
9401 currentTime = jiffies_to_msecs(jiffies);
9402 /*
9403 * scan was triggered in last timeToWait time duration
9404 * Wait for timeToWait before monitoring again.
9405 */
9406 if((currentTime - pTLCb->gDsRxRoamStats.lastTriggerTime) <
9407 pTLCb->gDsRxRoamStats.timeToWait)
9408 return;
9409
9410 /* paket above max rate, clear current stats and montior again */
9411 if (gTLRateInfo[rateIndex].phyRate >=
9412 pTLCb->gDsRxRoamStats.maxRate)
9413 {
9414 WLANTL_ClearAllRoamStats(pTLCb);
9415 /* Stop any PER based scan if going on */
9416 pTLCb->gDsRxRoamStats.
9417 triggerRoamScanfn(pTLCb->gDsRxRoamStats.hHal, 0);
9418 return;
9419 }
9420
9421 timeDifference = currentTime -
9422 pTLCb->gDsRxRoamStats.rxRoamStats[pTLCb->gDsRxRoamStats.index].time;
9423
9424 if (timeDifference)
Kapil Guptafe5d92a2016-07-12 18:05:24 +05309425 incrementCnt = do_div(timeDifference, ROAM_PER_INDEX_TIME);
Kapil Guptad90b3862016-06-25 00:42:49 +05309426
9427 /* More that ROAM_PER_INDEX_TIME has esclapsed,
9428 * fill data at new index */
9429 if (incrementCnt)
9430 {
9431 if (incrementCnt > ROAM_MAX_INDEX_NUM)
9432 {
9433 /*
9434 * Clear all stats, these are older than
9435 * ROAM_MAX_INDEX_NUM * ROAM_PER_INDEX_TIME (Max buffer time)
9436 */
9437 WLANTL_ClearAllRoamStats(pTLCb);
9438 pTLCb->gDsRxRoamStats.index = 0;
9439 }
9440 else
9441 WLANTL_ClearOldPERStats(pTLCb, incrementCnt);
9442
9443 pTLCb->gDsRxRoamStats.rxRoamStats
9444 [pTLCb->gDsRxRoamStats.index].time = currentTime;
9445 }
9446
9447 /* If pkt rate below minRate, increment low pkts counts */
9448 if (gTLRateInfo[rateIndex].phyRate <
9449 pTLCb->gDsRxRoamStats.minRate)
9450 {
9451 pTLCb->gDsRxRoamStats.
9452 rxRoamStats[pTLCb->gDsRxRoamStats.index].
9453 lowRateRxPacketsRcvd++;
9454 pTLCb->gDsRxRoamStats.lowRatePkt++;
9455 }
9456 /* Increment total pkts counts */
9457 pTLCb->gDsRxRoamStats.
9458 rxRoamStats[pTLCb->gDsRxRoamStats.index].totalPktRcvd++;
9459 pTLCb->gDsRxRoamStats.totalPkt++;
9460
9461 /* Check if we have reached threshold value to trigger a roam scan */
9462 if ((pTLCb->gDsRxRoamStats.totalPkt != 0) &&
9463 (pTLCb->gDsRxRoamStats.totalPkt >
9464 pTLCb->gDsRxRoamStats.minPktRequired)&&
Kapil Guptafe5d92a2016-07-12 18:05:24 +05309465 ((pTLCb->gDsRxRoamStats.lowRatePkt * 100) >
9466 (pTLCb->gDsRxRoamStats.totalPkt *
9467 pTLCb->gDsRxRoamStats.minPercentage)))
Kapil Guptad90b3862016-06-25 00:42:49 +05309468 {
9469 /* callback handler to trigger a roam scan */
9470 if (pTLCb->gDsRxRoamStats.triggerRoamScanfn)
9471 pTLCb->gDsRxRoamStats.
9472 triggerRoamScanfn(pTLCb->gDsRxRoamStats.hHal, 1);
9473
9474 VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_DEBUG,
9475 "PER Roam: triggerring roam scan totalPkt =%lu lowRatePkt %lu minPktRequired %u minPercentage %d",
9476 (long unsigned int) pTLCb->gDsRxRoamStats.totalPkt,
9477 (long unsigned int) pTLCb->gDsRxRoamStats.lowRatePkt,
9478 (unsigned int) pTLCb->gDsRxRoamStats.minPktRequired,
9479 pTLCb->gDsRxRoamStats.minPercentage);
9480
9481 WLANTL_ClearAllRoamStats(pTLCb);
9482 /* save current time as last trigger time */
9483 pTLCb->gDsRxRoamStats.lastTriggerTime = currentTime;
9484 }
9485}
9486#endif
9487
Jeff Johnson295189b2012-06-20 16:38:30 -07009488/*==========================================================================
9489 FUNCTION WLANTL_STARxAuth
9490
9491 DESCRIPTION
9492 Receive in authenticated state - all data allowed
9493
9494 DEPENDENCIES
9495 The STA must be registered with TL before this function can be called.
9496
9497 PARAMETERS
9498
9499 IN
9500 pvosGCtx: pointer to the global vos context; a handle to TL's
9501 control block can be extracted from its context
9502 ucSTAId: identifier of the station being processed
9503 vosDataBuff: pointer to the rx vos buffer
9504
9505 RETURN VALUE
9506 The result code associated with performing the operation
9507
9508 VOS_STATUS_E_INVAL: invalid input parameters
9509 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
9510 page fault
9511 VOS_STATUS_SUCCESS: Everything is good :)
9512
9513 SIDE EFFECTS
9514
9515============================================================================*/
9516VOS_STATUS
9517WLANTL_STARxAuth
9518(
9519 v_PVOID_t pvosGCtx,
9520 v_U8_t ucSTAId,
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009521 vos_pkt_t** pvosDataBuff,
9522 v_BOOL_t bForwardIAPPwithLLC
Jeff Johnson295189b2012-06-20 16:38:30 -07009523)
9524{
9525 WLANTL_CbType* pTLCb = NULL;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309526 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07009527 v_U8_t ucAsf; /* AMSDU sub frame */
9528 v_U16_t usMPDUDOffset;
9529 v_U8_t ucMPDUHOffset;
9530 v_U16_t usMPDULen;
9531 v_U8_t ucMPDUHLen;
9532 v_U16_t usActualHLen = 0;
9533 v_U8_t ucTid;
Kapil Guptad90b3862016-06-25 00:42:49 +05309534#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
9535 v_U8_t rxRate;
9536 v_U8_t type;
9537#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009538#ifdef FEATURE_WLAN_WAPI
Jeff Johnsone0343db2013-04-03 16:39:24 -07009539 v_U16_t usEtherType = 0;
Abhishek Singh3c47c6c2015-06-15 11:36:08 +05309540 tSirMacMgmtHdr *hdr;
Jeff Johnson295189b2012-06-20 16:38:30 -07009541#endif
9542 v_U16_t usPktLen;
9543 vos_pkt_t* vosDataBuff ;
9544 v_PVOID_t aucBDHeader;
9545 VOS_STATUS vosStatus;
9546 WLANTL_RxMetaInfoType wRxMetaInfo;
Madan Mohan Koyyalamudidfd6aa82012-10-18 20:18:43 -07009547 static v_U8_t ucPMPDUHLen;
Girish Gowli93e3edd2014-05-01 15:42:31 +05309548 v_U32_t* STAMetaInfoPtr;
Jeff Johnson295189b2012-06-20 16:38:30 -07009549 v_U8_t ucEsf=0; /* first subframe of AMSDU flag */
9550 v_U64_t ullcurrentReplayCounter=0; /*current replay counter*/
9551 v_U64_t ullpreviousReplayCounter=0; /*previous replay counter*/
9552 v_U16_t ucUnicastBroadcastType=0; /*It denotes whether received frame is UC or BC*/
Madan Mohan Koyyalamudi4fe30172012-10-18 20:13:40 -07009553 struct _BARFrmStruct *pBarFrame = NULL;
9554
Jeff Johnson295189b2012-06-20 16:38:30 -07009555 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
9556
9557 /*------------------------------------------------------------------------
9558 Sanity check
9559 ------------------------------------------------------------------------*/
9560 if (( NULL == pvosDataBuff ) || ( NULL == ( vosDataBuff = *pvosDataBuff )))
9561 {
9562 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9563 "WLAN TL:Invalid parameter sent on WLANTL_STARxAuth"));
9564 return VOS_STATUS_E_INVAL;
9565 }
9566
9567 /*------------------------------------------------------------------------
9568 Extract TL control block
9569 ------------------------------------------------------------------------*/
9570 pTLCb = VOS_GET_TL_CB(pvosGCtx);
9571 if ( NULL == pTLCb )
9572 {
9573 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9574 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_STARxAuth"));
9575 return VOS_STATUS_E_FAULT;
9576 }
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309577 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
9578
9579 if ( NULL == pClientSTA )
9580 {
9581 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9582 "WLAN TL:Client Memory was not allocated on %s", __func__));
9583 return VOS_STATUS_E_FAILURE;
9584 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009585
9586 /*------------------------------------------------------------------------
9587 Extract BD header and check if valid
9588 ------------------------------------------------------------------------*/
9589 WDA_DS_PeekRxPacketInfo( vosDataBuff, (v_PVOID_t)&aucBDHeader, 0 );
9590
9591 ucMPDUHOffset = (v_U8_t)WDA_GET_RX_MPDU_HEADER_OFFSET(aucBDHeader);
9592 usMPDUDOffset = (v_U16_t)WDA_GET_RX_MPDU_DATA_OFFSET(aucBDHeader);
9593 usMPDULen = (v_U16_t)WDA_GET_RX_MPDU_LEN(aucBDHeader);
9594 ucMPDUHLen = (v_U8_t)WDA_GET_RX_MPDU_HEADER_LEN(aucBDHeader);
9595 ucTid = (v_U8_t)WDA_GET_RX_TID(aucBDHeader);
Kapil Guptad90b3862016-06-25 00:42:49 +05309596#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
9597 rxRate = (v_U8_t)WDA_GET_RX_MAC_RATE_IDX(aucBDHeader);
9598 type = (v_U8_t)WDA_GET_RX_TYPE(aucBDHeader);
9599#endif
Hanumanth Reddy Pothula57323632017-12-06 17:55:09 +05309600 pClientSTA->rate_idx = (v_U8_t)WDA_GET_RX_MAC_RATE_IDX(aucBDHeader);
Jeff Johnson295189b2012-06-20 16:38:30 -07009601
Madan Mohan Koyyalamudi4fe30172012-10-18 20:13:40 -07009602 /* Fix for a hardware bug.
9603 * H/W does not update the tid field in BD header for BAR frames.
9604 * Fix is to read the tid field from MAC header of BAR frame */
9605 if( (WDA_GET_RX_TYPE(aucBDHeader) == SIR_MAC_CTRL_FRAME) &&
9606 (WDA_GET_RX_SUBTYPE(aucBDHeader) == SIR_MAC_CTRL_BAR))
9607 {
9608 pBarFrame = (struct _BARFrmStruct *)(WDA_GET_RX_MAC_HEADER(aucBDHeader));
9609 ucTid = pBarFrame->barControl.numTID;
9610 }
9611
Jeff Johnson295189b2012-06-20 16:38:30 -07009612 /*Host based replay check is needed for unicast data frames*/
9613 ucUnicastBroadcastType = (v_U16_t)WDA_IS_RX_BCAST(aucBDHeader);
Jeff Johnson295189b2012-06-20 16:38:30 -07009614 if(0 != ucMPDUHLen)
9615 {
9616 ucPMPDUHLen = ucMPDUHLen;
9617 }
9618
9619 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
9620 "WLAN TL:BD header processing data: HO %d DO %d Len %d HLen %d"
9621 " Tid %d BD %d",
9622 ucMPDUHOffset, usMPDUDOffset, usMPDULen, ucMPDUHLen, ucTid,
9623 WLANHAL_RX_BD_HEADER_SIZE));
9624
9625 vos_pkt_get_packet_length( vosDataBuff, &usPktLen);
9626
9627 if ( VOS_STATUS_SUCCESS != WDA_DS_TrimRxPacketInfo( vosDataBuff ) )
9628 {
9629 if((WDA_GET_RX_ASF(aucBDHeader) && !WDA_GET_RX_ESF(aucBDHeader)))
9630 {
9631 /* AMSDU case, ucMPDUHOffset = 0
9632 * it should be hancdled seperatly */
9633 if(( usMPDUDOffset > ucMPDUHOffset ) &&
9634 ( usMPDULen >= ucMPDUHLen ) && ( usPktLen >= usMPDULen ) &&
9635 ( !WLANTL_TID_INVALID(ucTid) ))
9636 {
9637 ucMPDUHOffset = usMPDUDOffset - WLANTL_MPDU_HEADER_LEN;
9638 }
9639 else
9640 {
9641 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
9642 "WLAN TL:BD header corrupted - dropping packet"));
9643 /* Drop packet */
9644 vos_pkt_return_packet(vosDataBuff);
9645 return VOS_STATUS_SUCCESS;
9646 }
9647 }
9648 else
9649 {
9650 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
9651 "WLAN TL:BD header corrupted - dropping packet"));
9652 /* Drop packet */
9653 vos_pkt_return_packet(vosDataBuff);
9654 return VOS_STATUS_SUCCESS;
9655 }
9656 }
9657
Abhishek Singh00b71972016-01-07 10:51:04 +05309658#ifdef WLAN_FEATURE_RMC
9659 if (pTLCb->multicastDuplicateDetectionEnabled &&
9660 (WLAN_STA_IBSS == pClientSTA->wSTADesc.wSTAType) &&
9661 WLANTL_IS_DATA_FRAME(WDA_GET_RX_TYPE_SUBTYPE(aucBDHeader)))
9662 {
9663 /*
9664 * Multicast duplicate detection is only for frames received in
9665 * IBSS mode.
9666 */
9667 if (VOS_TRUE == WLANTL_IsDuplicateMcastFrm(pClientSTA, vosDataBuff))
9668 {
9669 pTLCb->mcastDupCnt++;
9670 /* Duplicate multicast data packet, drop the packet */
9671 vos_pkt_return_packet(vosDataBuff);
9672 return VOS_STATUS_SUCCESS;
9673 }
9674 }
9675#endif /* WLAN_FEATURE_RMC */
9676
Jeff Johnson295189b2012-06-20 16:38:30 -07009677#ifdef FEATURE_WLAN_WAPI
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309678 if ( pClientSTA->wSTADesc.ucIsWapiSta )
Jeff Johnson295189b2012-06-20 16:38:30 -07009679 {
9680 vosStatus = WLANTL_GetEtherType(aucBDHeader, vosDataBuff, ucMPDUHLen, &usEtherType);
9681 if( VOS_IS_STATUS_SUCCESS(vosStatus) )
9682 {
9683 if ( WLANTL_LLC_WAI_TYPE == usEtherType )
Abhishek Singh3c47c6c2015-06-15 11:36:08 +05309684 {
9685 hdr = WDA_GET_RX_MAC_HEADER(aucBDHeader);
9686 if ( hdr->fc.wep )
Jeff Johnson295189b2012-06-20 16:38:30 -07009687 {
9688 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9689 "WLAN TL:WAI frame was received encrypted - dropping"));
9690 /* Drop packet */
9691 /*Temporary fix added to fix wapi rekey issue*/
Abhishek Singh3c47c6c2015-06-15 11:36:08 +05309692 vos_pkt_return_packet(vosDataBuff);
9693 return vosStatus; //returning success
Jeff Johnson295189b2012-06-20 16:38:30 -07009694 }
9695 }
9696 else
9697 {
9698 if ( WLANHAL_RX_IS_UNPROTECTED_WPI_FRAME(aucBDHeader) )
9699 {
9700 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9701 "WLAN TL:Non-WAI frame was received unencrypted - dropping"));
9702 /* Drop packet */
9703 vos_pkt_return_packet(vosDataBuff);
9704 return vosStatus; //returning success
9705 }
9706 }
9707 }
9708 else //could not extract EtherType - this should not happen
9709 {
9710 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009711 "WLAN TL:Could not extract EtherType"));
9712 //Packet is already freed
Jeff Johnson295189b2012-06-20 16:38:30 -07009713 return vosStatus; //returning failure
Jeff Johnson295189b2012-06-20 16:38:30 -07009714 }
9715 }
9716#endif /* FEATURE_WLAN_WAPI */
9717
9718 /*----------------------------------------------------------------------
9719 Increment receive counter
9720 !! not sure this is the best place to increase this - pkt might be
9721 dropped below or delayed in TL's queues
9722 - will leave it here for now
9723 ------------------------------------------------------------------------*/
Madan Mohan Koyyalamudic0e5bd82012-09-18 17:12:27 -07009724 if ( !WLANTL_TID_INVALID( ucTid) )
9725 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309726 pClientSTA->auRxCount[ucTid]++;
Madan Mohan Koyyalamudic0e5bd82012-09-18 17:12:27 -07009727 }
9728 else
9729 {
9730 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9731 "WLAN TL:Invalid tid %d (Station ID %d) on %s",
9732 ucTid, ucSTAId, __func__));
Hanumantha Reddy Pothula0de10802016-02-11 17:29:27 +05309733 vos_pkt_return_packet(vosDataBuff);
9734 return VOS_STATUS_E_FAILURE;
Madan Mohan Koyyalamudic0e5bd82012-09-18 17:12:27 -07009735 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009736
Kapil Guptad90b3862016-06-25 00:42:49 +05309737#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
9738 if (pTLCb->gDsRxRoamStats.running &&
9739 (ucSTAId == pTLCb->gDsRxRoamStats.staId) &&
9740 (rxRate < WLANTL_MAX_RATE_NUM) && (type == SIR_MAC_DATA_FRAME))
9741 {
9742 WLANTL_updatePERStats(pTLCb, rxRate);
9743 }
9744#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009745 /*------------------------------------------------------------------------
9746 Check if AMSDU and send for processing if so
9747 ------------------------------------------------------------------------*/
9748 ucAsf = (v_U8_t)WDA_GET_RX_ASF(aucBDHeader);
9749
9750 if ( 0 != ucAsf )
9751 {
9752 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
9753 "WLAN TL:Packet is AMSDU sub frame - sending for completion"));
9754 vosStatus = WLANTL_AMSDUProcess( pvosGCtx, &vosDataBuff, aucBDHeader, ucSTAId,
9755 ucMPDUHLen, usMPDULen );
9756 if(NULL == vosDataBuff)
9757 {
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009758 //Packet is already freed
Jeff Johnson295189b2012-06-20 16:38:30 -07009759 return VOS_STATUS_SUCCESS;
9760 }
9761 }
9762 /* After AMSDU header handled
9763 * AMSDU frame just same with normal frames */
9764 /*-------------------------------------------------------------------
9765 Translating header if necesary
9766 !! Fix me: rmv comments below
9767 ----------------------------------------------------------------------*/
9768 if (( 0 == WDA_GET_RX_FT_DONE(aucBDHeader) ) &&
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309769 ( 0 != pClientSTA->wSTADesc.ucSwFrameRXXlation) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07009770 ( WLANTL_IS_DATA_FRAME(WDA_GET_RX_TYPE_SUBTYPE(aucBDHeader)) ))
9771 {
9772 if(0 == ucMPDUHLen)
9773 {
9774 ucMPDUHLen = ucPMPDUHLen;
9775 }
9776 if (usMPDUDOffset > ucMPDUHOffset)
9777 {
9778 usActualHLen = usMPDUDOffset - ucMPDUHOffset;
9779 }
9780 vosStatus = WLANTL_Translate80211To8023Header( vosDataBuff, &vosStatus, usActualHLen,
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009781 ucMPDUHLen, pTLCb, ucSTAId, bForwardIAPPwithLLC);
Jeff Johnson295189b2012-06-20 16:38:30 -07009782
9783 if ( VOS_STATUS_SUCCESS != vosStatus )
9784 {
Kaushik, Sushante386ee12014-05-01 15:50:52 +05309785 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
Jeff Johnson295189b2012-06-20 16:38:30 -07009786 "WLAN TL:Failed to translate from 802.11 to 802.3 - dropping"));
9787 /* Drop packet */
9788 vos_pkt_return_packet(vosDataBuff);
9789 return vosStatus;
9790 }
9791 }
9792 /* Softap requires additional Info such as Destination STAID and Access
9793 Category. Voschain or Buffer returned by BA would be unchain and this
9794 Meta Data would help in routing the packets to appropriate Destination */
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309795 if( WLAN_STA_SOFTAP == pClientSTA->wSTADesc.wSTAType)
Jeff Johnson295189b2012-06-20 16:38:30 -07009796 {
Arun Kumar Khandavalli37cfc222014-01-09 22:32:40 +05309797 STAMetaInfoPtr = (v_U32_t *)(uintptr_t)(ucTid | (WDA_GET_RX_ADDR3_IDX(aucBDHeader) << WLANTL_STAID_OFFSET));
Jeff Johnson295189b2012-06-20 16:38:30 -07009798 vos_pkt_set_user_data_ptr( vosDataBuff, VOS_PKT_USER_DATA_ID_TL,
9799 (v_PVOID_t)STAMetaInfoPtr);
9800 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009801
Sravan Kumar Kairamfb0b19d2018-02-01 12:25:28 +05309802 /* Check to see if re-ordering session is in place.
9803 Skip add to reorder list for TDLS packet on AP staid*/
9804 if (0 != pClientSTA->atlBAReorderInfo[ucTid].ucExists &&
9805 !vosDataBuff->pn_replay_skip)
Jeff Johnson295189b2012-06-20 16:38:30 -07009806 {
9807 WLANTL_MSDUReorder( pTLCb, &vosDataBuff, aucBDHeader, ucSTAId, ucTid );
9808 }
9809
Sravan Kumar Kairam04f093a2017-11-16 19:59:05 +05309810if(WLANTL_IS_DATA_FRAME(WDA_GET_RX_TYPE_SUBTYPE(aucBDHeader)) &&
9811 (0 == ucUnicastBroadcastType)
Jeff Johnson295189b2012-06-20 16:38:30 -07009812#ifdef FEATURE_ON_CHIP_REORDERING
9813 && (WLANHAL_IsOnChipReorderingEnabledForTID(pvosGCtx, ucSTAId, ucTid) != TRUE)
9814#endif
9815)
9816{
Sravan Kumar Kairamfb0b19d2018-02-01 12:25:28 +05309817 /* replay check code : check whether replay check is needed or not
9818 Skip replay check for TDLS traffic with AP sta id */
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309819 if(VOS_TRUE == pClientSTA->ucIsReplayCheckValid)
Jeff Johnson295189b2012-06-20 16:38:30 -07009820 {
9821 /* replay check is needed for the station */
9822
9823 /* check whether frame is AMSDU frame */
9824 if ( 0 != ucAsf )
9825 {
9826 /* Since virgo can't send AMSDU frames this leg of the code
9827 was not tested properly, it needs to be tested properly*/
9828 /* Frame is AMSDU frame. As per 802.11n only first
9829 subframe will have replay counter */
9830 ucEsf = WDA_GET_RX_ESF( aucBDHeader );
9831 if( 0 != ucEsf )
9832 {
9833 v_BOOL_t status;
9834 /* Getting 48-bit replay counter from the RX BD */
9835 ullcurrentReplayCounter = WDA_DS_GetReplayCounter(aucBDHeader);
9836
9837 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Arif Hussainf2b00992013-11-17 21:46:15 -08009838 "WLAN TL: AMSDU currentReplayCounter [0x%llX]",ullcurrentReplayCounter);
Jeff Johnson295189b2012-06-20 16:38:30 -07009839
9840 /* Getting 48-bit previous replay counter from TL control block */
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309841 ullpreviousReplayCounter = pClientSTA->ullReplayCounter[ucTid];
Jeff Johnson295189b2012-06-20 16:38:30 -07009842
9843 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Arif Hussainf2b00992013-11-17 21:46:15 -08009844 "WLAN TL: AMSDU previousReplayCounter [0x%llX]",ullpreviousReplayCounter);
Jeff Johnson295189b2012-06-20 16:38:30 -07009845
9846 /* It is first subframe of AMSDU thus it
9847 conatains replay counter perform the
9848 replay check for this first subframe*/
9849 status = WLANTL_IsReplayPacket( ullcurrentReplayCounter, ullpreviousReplayCounter);
9850 if(VOS_FALSE == status)
9851 {
9852 /* Not a replay paket, update previous replay counter in TL CB */
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309853 pClientSTA->ullReplayCounter[ucTid] = ullcurrentReplayCounter;
Jeff Johnson295189b2012-06-20 16:38:30 -07009854 }
9855 else
9856 {
9857 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Arif Hussainf2b00992013-11-17 21:46:15 -08009858 "WLAN TL: AMSDU Drop the replay packet with PN : [0x%llX]",ullcurrentReplayCounter);
Jeff Johnson295189b2012-06-20 16:38:30 -07009859
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309860 pClientSTA->ulTotalReplayPacketsDetected++;
Jeff Johnson295189b2012-06-20 16:38:30 -07009861 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Arif Hussainf2b00992013-11-17 21:46:15 -08009862 "WLAN TL: AMSDU total dropped replay packets on STA ID %X is [0x%X]",
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309863 ucSTAId, pClientSTA->ulTotalReplayPacketsDetected);
Jeff Johnson295189b2012-06-20 16:38:30 -07009864
9865 /* Drop the packet */
9866 vos_pkt_return_packet(vosDataBuff);
9867 return VOS_STATUS_SUCCESS;
9868 }
9869 }
9870 }
9871 else
9872 {
9873 v_BOOL_t status;
Sravan Kumar Kairamfb0b19d2018-02-01 12:25:28 +05309874 uint16_t seq_no = (uint16_t)WDA_GET_RX_REORDER_CUR_PKT_SEQ_NO(aucBDHeader);
Jeff Johnson295189b2012-06-20 16:38:30 -07009875
9876 /* Getting 48-bit replay counter from the RX BD */
9877 ullcurrentReplayCounter = WDA_DS_GetReplayCounter(aucBDHeader);
9878
9879 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Arif Hussainf2b00992013-11-17 21:46:15 -08009880 "WLAN TL: Non-AMSDU currentReplayCounter [0x%llX]",ullcurrentReplayCounter);
Jeff Johnson295189b2012-06-20 16:38:30 -07009881
9882 /* Getting 48-bit previous replay counter from TL control block */
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309883 ullpreviousReplayCounter = pClientSTA->ullReplayCounter[ucTid];
Jeff Johnson295189b2012-06-20 16:38:30 -07009884
9885 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Arif Hussainf2b00992013-11-17 21:46:15 -08009886 "WLAN TL: Non-AMSDU previousReplayCounter [0x%llX]",ullpreviousReplayCounter);
Jeff Johnson295189b2012-06-20 16:38:30 -07009887
9888 /* It is not AMSDU frame so perform
9889 reaply check for each packet, as
Sravan Kumar Kairam04f093a2017-11-16 19:59:05 +05309890 each packet contains valid replay counter*/
Sravan Kumar Kairamfb0b19d2018-02-01 12:25:28 +05309891 if (vosDataBuff != NULL && !vosDataBuff->pn_replay_skip) {
Sravan Kumar Kairam04f093a2017-11-16 19:59:05 +05309892 if (vos_is_pkt_chain(vosDataBuff)) {
9893 WLANTL_ReorderReplayCheck(pClientSTA, &vosDataBuff, ucTid);
9894 } else {
9895 status = WLANTL_IsReplayPacket(ullcurrentReplayCounter,
9896 ullpreviousReplayCounter);
9897 if(VOS_FALSE == status) {
9898 /* Not a replay paket, update previous replay counter in TL CB */
9899 pClientSTA->ullReplayCounter[ucTid] = ullcurrentReplayCounter;
Sravan Kumar Kairamfb0b19d2018-02-01 12:25:28 +05309900 pClientSTA->last_seq_no[ucTid] = seq_no;
Sravan Kumar Kairam04f093a2017-11-16 19:59:05 +05309901 } else {
9902 VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Sravan Kumar Kairamfb0b19d2018-02-01 12:25:28 +05309903 "Non AMSDU Drop replay with PN: [0x%llX], prevPN: [0x%llx]"
9904 " seq_no:%d last_seq_no:%d",
9905 ullcurrentReplayCounter, ullpreviousReplayCounter, seq_no,
9906 pClientSTA->last_seq_no[ucTid]);
Jeff Johnson295189b2012-06-20 16:38:30 -07009907
Sravan Kumar Kairam04f093a2017-11-16 19:59:05 +05309908 pClientSTA->ulTotalReplayPacketsDetected++;
9909 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9910 "WLAN TL: Non AMSDU total dropped replay packets on STA ID %X is [0x%X]",
9911 ucSTAId, pClientSTA->ulTotalReplayPacketsDetected);
Jeff Johnson295189b2012-06-20 16:38:30 -07009912
Sravan Kumar Kairam04f093a2017-11-16 19:59:05 +05309913 /* Repaly packet, drop the packet */
9914 vos_pkt_return_packet(vosDataBuff);
9915 return VOS_STATUS_SUCCESS;
9916 }
9917 }
9918 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009919 }
Sravan Kumar Kairam04f093a2017-11-16 19:59:05 +05309920 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009921}
Sravan Kumar Kairam04f093a2017-11-16 19:59:05 +05309922
Jeff Johnson295189b2012-06-20 16:38:30 -07009923/*It is a broadast packet DPU has already done replay check for
9924 broadcast packets no need to do replay check of these packets*/
Jeff Johnson295189b2012-06-20 16:38:30 -07009925
9926 if ( NULL != vosDataBuff )
9927 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309928 if( WLAN_STA_SOFTAP == pClientSTA->wSTADesc.wSTAType)
Jeff Johnson295189b2012-06-20 16:38:30 -07009929 {
9930 WLANTL_FwdPktToHDD( pvosGCtx, vosDataBuff, ucSTAId );
9931 }
9932 else
Jeff Johnson295189b2012-06-20 16:38:30 -07009933 {
9934 wRxMetaInfo.ucUP = ucTid;
Shailender Karmuchi13c0d082013-03-26 14:41:39 -07009935 wRxMetaInfo.rssiAvg = pClientSTA->rssiAvg;
Gopichand Nakkala4a2fc1a2013-05-17 16:59:39 +05309936#ifdef FEATURE_WLAN_TDLS
9937 if (WLAN_STA_TDLS == pClientSTA->wSTADesc.wSTAType)
9938 {
9939 wRxMetaInfo.isStaTdls = TRUE;
9940 }
9941 else
9942 {
9943 wRxMetaInfo.isStaTdls = FALSE;
9944 }
9945#endif
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309946 pClientSTA->pfnSTARx( pvosGCtx, vosDataBuff, ucSTAId,
Jeff Johnson295189b2012-06-20 16:38:30 -07009947 &wRxMetaInfo );
9948 }
9949 }/* if not NULL */
9950
9951 return VOS_STATUS_SUCCESS;
9952}/* WLANTL_STARxAuth */
9953
9954
9955/*==========================================================================
9956 FUNCTION WLANTL_STARxDisc
9957
9958 DESCRIPTION
9959 Receive in disconnected state - no data allowed
9960
9961 DEPENDENCIES
9962 The STA must be registered with TL before this function can be called.
9963
9964 PARAMETERS
9965
9966 IN
9967 pvosGCtx: pointer to the global vos context; a handle to TL's
9968 control block can be extracted from its context
9969 ucSTAId: identifier of the station being processed
9970 vosDataBuff: pointer to the rx vos buffer
9971
9972 RETURN VALUE
9973 The result code associated with performing the operation
9974
9975 VOS_STATUS_SUCCESS: Everything is good :)
9976
9977 SIDE EFFECTS
9978
9979============================================================================*/
9980VOS_STATUS
9981WLANTL_STARxDisc
9982(
9983 v_PVOID_t pvosGCtx,
9984 v_U8_t ucSTAId,
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009985 vos_pkt_t** pvosDataBuff,
9986 v_BOOL_t bForwardIAPPwithLLC
Jeff Johnson295189b2012-06-20 16:38:30 -07009987)
9988{
9989 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
9990
9991 /*------------------------------------------------------------------------
9992 Sanity check
9993 ------------------------------------------------------------------------*/
9994 if (( NULL == pvosDataBuff ) || ( NULL == *pvosDataBuff ))
9995 {
9996 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9997 "WLAN TL:Invalid parameter sent on WLANTL_STARxDisc"));
9998 return VOS_STATUS_E_INVAL;
9999 }
10000
10001 /*------------------------------------------------------------------------
10002 Error - drop packet
10003 ------------------------------------------------------------------------*/
10004 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
10005 "WLAN TL:Packet should not be received in state disconnected"
10006 " - dropping"));
10007 vos_pkt_return_packet(*pvosDataBuff);
10008 *pvosDataBuff = NULL;
10009
10010 return VOS_STATUS_SUCCESS;
10011}/* WLANTL_STARxDisc */
10012
10013/*==========================================================================
10014 Processing main loops for MAIN and TX threads
10015 ==========================================================================*/
10016
10017/*==========================================================================
10018 FUNCTION WLANTL_McProcessMsg
10019
10020 DESCRIPTION
10021 Called by VOSS when a message was serialized for TL through the
10022 main thread/task.
10023
10024 DEPENDENCIES
10025 The TL must be initialized before this function can be called.
10026
10027 PARAMETERS
10028
10029 IN
10030 pvosGCtx: pointer to the global vos context; a handle to TL's
10031 control block can be extracted from its context
10032 message: type and content of the message
10033
10034
10035 RETURN VALUE
10036 The result code associated with performing the operation
10037
10038 VOS_STATUS_E_INVAL: invalid input parameters
10039 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
10040 page fault
10041 VOS_STATUS_SUCCESS: Everything is good :)
10042
10043 SIDE EFFECTS
10044
10045============================================================================*/
10046VOS_STATUS
10047WLANTL_McProcessMsg
10048(
10049 v_PVOID_t pvosGCtx,
10050 vos_msg_t* message
10051)
10052{
10053 WLANTL_CbType* pTLCb = NULL;
10054 tAddBAInd* ptAddBaInd = NULL;
10055 tDelBAInd* ptDelBaInd = NULL;
10056 tAddBARsp* ptAddBaRsp = NULL;
10057 vos_msg_t vosMessage;
10058 VOS_STATUS vosStatus;
10059 tpFlushACRsp FlushACRspPtr;
10060 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
10061
10062 /*------------------------------------------------------------------------
10063 Sanity check
10064 ------------------------------------------------------------------------*/
10065 if ( NULL == message )
10066 {
10067 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
10068 "WLAN TL:Invalid parameter sent on WLANTL_ProcessMainMessage"));
10069 return VOS_STATUS_E_INVAL;
10070 }
10071
10072 /*------------------------------------------------------------------------
10073 Extract TL control block
10074 ------------------------------------------------------------------------*/
10075 pTLCb = VOS_GET_TL_CB(pvosGCtx);
10076 if ( NULL == pTLCb )
10077 {
10078 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
10079 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_ProcessMainMessage"));
10080 return VOS_STATUS_E_FAULT;
10081 }
10082
10083 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
10084 "WLAN TL:Received message: %d through main flow", message->type));
10085
10086 switch( message->type )
10087 {
10088 case WDA_TL_FLUSH_AC_RSP:
10089 // Extract the message from the message body
10090 FlushACRspPtr = (tpFlushACRsp)(message->bodyptr);
10091 // Make sure the call back function is not null.
Tushnim Bhattacharyya5dd94562013-03-20 20:15:03 -070010092 if ( NULL == pTLCb->tlBAPClient.pfnFlushOpCompleteCb )
10093 {
10094 VOS_ASSERT(0);
10095 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
10096 "WLAN TL:Invalid TL pointer pfnFlushOpCompleteCb"));
10097 return VOS_STATUS_E_FAULT;
10098 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010099
10100 TLLOG2(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
10101 "Received message: Flush complete received by TL"));
10102
10103 // Since we have the response back from HAL, just call the BAP client
10104 // registered call back from TL. There is only 1 possible
10105 // BAP client. So directly reference tlBAPClient
10106 pTLCb->tlBAPClient.pfnFlushOpCompleteCb( pvosGCtx,
10107 FlushACRspPtr->ucSTAId,
10108 FlushACRspPtr->ucTid, FlushACRspPtr->status );
10109
10110 // Free the PAL memory, we are done with it.
10111 TLLOG2(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
Jeff Johnsonddec6482017-09-19 08:33:57 -070010112 "Flush complete received by TL: Freeing %pK", FlushACRspPtr));
Jeff Johnson295189b2012-06-20 16:38:30 -070010113 vos_mem_free((v_VOID_t *)FlushACRspPtr);
10114 break;
10115
10116 case WDA_HDD_ADDBA_REQ:
10117 ptAddBaInd = (tAddBAInd*)(message->bodyptr);
10118 vosStatus = WLANTL_BaSessionAdd( pvosGCtx,
10119 ptAddBaInd->baSession.baSessionID,
10120 ptAddBaInd->baSession.STAID,
10121 ptAddBaInd->baSession.baTID,
10122 (v_U32_t)ptAddBaInd->baSession.baBufferSize,
10123 ptAddBaInd->baSession.winSize,
10124 ptAddBaInd->baSession.SSN);
10125 ptAddBaRsp = vos_mem_malloc(sizeof(*ptAddBaRsp));
10126
10127 if ( NULL == ptAddBaRsp )
10128 {
10129 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
10130 "WLAN TL: fatal failure, cannot allocate BA Rsp structure"));
10131 VOS_ASSERT(0);
10132 return VOS_STATUS_E_NOMEM;
10133 }
10134
10135 if ( VOS_STATUS_SUCCESS == vosStatus )
10136 {
10137 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
10138 "WLAN TL: Sending success indication to HAL for ADD BA"));
10139 /*Send success*/
10140 ptAddBaRsp->mesgType = WDA_HDD_ADDBA_RSP;
10141 vosMessage.type = WDA_HDD_ADDBA_RSP;
10142 }
10143 else
10144 {
10145 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
10146 "WLAN TL: Sending failure indication to HAL for ADD BA"));
10147
10148 /*Send failure*/
10149 ptAddBaRsp->mesgType = WDA_BA_FAIL_IND;
10150 vosMessage.type = WDA_BA_FAIL_IND;
10151 }
10152
10153 ptAddBaRsp->mesgLen = sizeof(tAddBARsp);
10154 ptAddBaRsp->baSessionID = ptAddBaInd->baSession.baSessionID;
10155 /* This is default, reply win size has to be handled BA module, FIX THIS */
10156 ptAddBaRsp->replyWinSize = WLANTL_MAX_WINSIZE;
10157 vosMessage.bodyptr = ptAddBaRsp;
10158
10159 vos_mq_post_message( VOS_MQ_ID_WDA, &vosMessage );
10160 WLANTL_McFreeMsg (pvosGCtx, message);
10161 break;
10162 case WDA_DELETEBA_IND:
10163 ptDelBaInd = (tDelBAInd*)(message->bodyptr);
10164 vosStatus = WLANTL_BaSessionDel(pvosGCtx,
10165 ptDelBaInd->staIdx,
10166 ptDelBaInd->baTID);
10167
10168 if ( VOS_STATUS_SUCCESS != vosStatus )
10169 {
10170 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
10171 "WLAN TL: Failed to del BA session STA:%d TID:%d Status :%d",
10172 ptDelBaInd->staIdx,
10173 ptDelBaInd->baTID,
10174 vosStatus));
10175 }
10176 WLANTL_McFreeMsg (pvosGCtx, message);
10177 break;
10178 default:
10179 /*no processing for now*/
10180 break;
10181 }
10182
10183 return VOS_STATUS_SUCCESS;
10184}/* WLANTL_ProcessMainMessage */
10185
10186/*==========================================================================
10187 FUNCTION WLANTL_McFreeMsg
10188
10189 DESCRIPTION
10190 Called by VOSS to free a given TL message on the Main thread when there
10191 are messages pending in the queue when the whole system is been reset.
10192 For now, TL does not allocate any body so this function shout translate
10193 into a NOOP
10194
10195 DEPENDENCIES
10196 The TL must be initialized before this function can be called.
10197
10198 PARAMETERS
10199
10200 IN
10201 pvosGCtx: pointer to the global vos context; a handle to TL's
10202 control block can be extracted from its context
10203 message: type and content of the message
10204
10205
10206 RETURN VALUE
10207 The result code associated with performing the operation
10208
10209 VOS_STATUS_SUCCESS: Everything is good :)
10210
10211 SIDE EFFECTS
10212
10213============================================================================*/
10214VOS_STATUS
10215WLANTL_McFreeMsg
10216(
10217 v_PVOID_t pvosGCtx,
10218 vos_msg_t* message
10219)
10220{
10221 WLANTL_CbType* pTLCb = NULL;
10222 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
10223
10224 /*------------------------------------------------------------------------
10225 Sanity check
10226 ------------------------------------------------------------------------*/
10227 if ( NULL == message )
10228 {
10229 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
10230 "WLAN TL:Invalid parameter sent on WLANTL_McFreeMsg"));
10231 return VOS_STATUS_E_INVAL;
10232 }
10233
10234 /*------------------------------------------------------------------------
10235 Extract TL control block
10236 ------------------------------------------------------------------------*/
10237 pTLCb = VOS_GET_TL_CB(pvosGCtx);
10238 if ( NULL == pTLCb )
10239 {
10240 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
10241 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_McFreeMsg"));
10242 return VOS_STATUS_E_FAULT;
10243 }
10244
10245 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
10246 "WLAN TL:Received message: %d through main free", message->type));
10247
10248 switch( message->type )
10249 {
10250 case WDA_HDD_ADDBA_REQ:
10251 case WDA_DELETEBA_IND:
10252 /*vos free body pointer*/
10253 vos_mem_free(message->bodyptr);
10254 message->bodyptr = NULL;
10255 break;
10256 default:
10257 /*no processing for now*/
10258 break;
10259 }
10260
10261 return VOS_STATUS_SUCCESS;
10262}/*WLANTL_McFreeMsg*/
10263
10264/*==========================================================================
10265 FUNCTION WLANTL_TxProcessMsg
10266
10267 DESCRIPTION
10268 Called by VOSS when a message was serialized for TL through the
10269 tx thread/task.
10270
10271 DEPENDENCIES
10272 The TL must be initialized before this function can be called.
10273
10274 PARAMETERS
10275
10276 IN
10277 pvosGCtx: pointer to the global vos context; a handle to TL's
10278 control block can be extracted from its context
10279 message: type and content of the message
10280
10281
10282 RETURN VALUE
10283 The result code associated with performing the operation
10284
10285 VOS_STATUS_E_INVAL: invalid input parameters
10286 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
10287 page fault
10288 VOS_STATUS_SUCCESS: Everything is good :)
10289
10290 Other values can be returned as a result of a function call, please check
10291 corresponding API for more info.
10292 SIDE EFFECTS
10293
10294============================================================================*/
10295VOS_STATUS
10296WLANTL_TxProcessMsg
10297(
10298 v_PVOID_t pvosGCtx,
10299 vos_msg_t* message
10300)
10301{
10302 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070010303 void (*callbackRoutine) (void *callbackContext);
10304 void *callbackContext;
Jeff Johnson295189b2012-06-20 16:38:30 -070010305 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
10306
10307 /*------------------------------------------------------------------------
10308 Sanity check
10309 ------------------------------------------------------------------------*/
10310 if ( NULL == message )
10311 {
10312 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
10313 "WLAN TL:Invalid parameter sent on WLANTL_ProcessTxMessage"));
10314 return VOS_STATUS_E_INVAL;
10315 }
10316
10317 /*------------------------------------------------------------------------
10318 Process message
10319 ------------------------------------------------------------------------*/
10320 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
10321 "WLAN TL:Received message: %d through tx flow", message->type));
10322
10323 switch( message->type )
10324 {
10325 case WLANTL_TX_SIG_SUSPEND:
10326 vosStatus = WLANTL_SuspendCB( pvosGCtx,
10327 (WLANTL_SuspendCBType)message->bodyptr,
10328 message->reserved);
10329 break;
10330 case WLANTL_TX_RES_NEEDED:
10331 vosStatus = WLANTL_GetTxResourcesCB( pvosGCtx );
10332 break;
Katya Nigam664f5032014-05-05 12:24:32 +053010333
Jeff Johnson295189b2012-06-20 16:38:30 -070010334 case WDA_DS_TX_START_XMIT:
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +053010335 WLANTL_ClearTxXmitPending(pvosGCtx);
10336 vosStatus = WDA_DS_TxFrames( pvosGCtx );
Jeff Johnson295189b2012-06-20 16:38:30 -070010337 break;
10338
10339 case WDA_DS_FINISH_ULA:
Arun Kumar Khandavalli8d1979d2014-01-09 21:12:25 +053010340 callbackContext = message->bodyptr;
10341 callbackRoutine = message->callback;
10342 if ( NULL != callbackRoutine )
10343 {
10344 callbackRoutine(callbackContext);
10345 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010346 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010347
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +053010348 case WLANTL_TX_SNAPSHOT:
10349 /*Dumping TL State and then continuing to print
10350 the DXE Dump*/
10351 WLANTL_TxThreadDebugHandler(pvosGCtx);
10352 WDA_TransportChannelDebug(NULL, VOS_TRUE, VOS_FALSE);
10353 break;
10354
Mihir Shetefd62d9d2014-08-06 15:08:21 +053010355 case WLANTL_TX_FATAL_ERROR:
10356 WLANTL_FatalErrorHandler(pvosGCtx);
10357 break;
10358
Mihir Shete327c2ab2014-11-13 15:17:02 +053010359 case WLANTL_TX_FW_DEBUG:
Siddharth Bhal68115602015-01-18 20:44:55 +053010360 vos_fwDumpReq(274, 0, 0, 0, 0, 1); //Async event
Mihir Shete327c2ab2014-11-13 15:17:02 +053010361 break;
10362
Sravan Kumar Kairame9d186c2015-11-27 23:37:02 +053010363 case WLANTL_TX_KICKDXE:
10364 WDA_TransportKickDxe();
10365 break;
10366
Jeff Johnson295189b2012-06-20 16:38:30 -070010367 default:
10368 /*no processing for now*/
10369 break;
10370 }
10371
10372 return vosStatus;
10373}/* WLANTL_TxProcessMsg */
10374
10375/*==========================================================================
10376 FUNCTION WLANTL_McFreeMsg
10377
10378 DESCRIPTION
10379 Called by VOSS to free a given TL message on the Main thread when there
10380 are messages pending in the queue when the whole system is been reset.
10381 For now, TL does not allocate any body so this function shout translate
10382 into a NOOP
10383
10384 DEPENDENCIES
10385 The TL must be initialized before this function can be called.
10386
10387 PARAMETERS
10388
10389 IN
10390 pvosGCtx: pointer to the global vos context; a handle to TL's
10391 control block can be extracted from its context
10392 message: type and content of the message
10393
10394
10395 RETURN VALUE
10396 The result code associated with performing the operation
10397
10398 VOS_STATUS_SUCCESS: Everything is good :)
10399
10400 SIDE EFFECTS
10401
10402============================================================================*/
10403VOS_STATUS
10404WLANTL_TxFreeMsg
10405(
10406 v_PVOID_t pvosGCtx,
10407 vos_msg_t* message
10408)
10409{
10410 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
10411
10412 /*Nothing to do for now!!!*/
10413 return VOS_STATUS_SUCCESS;
10414}/*WLANTL_TxFreeMsg*/
10415
Jeff Johnson295189b2012-06-20 16:38:30 -070010416/*==========================================================================
10417
10418 FUNCTION WLANTL_TxFCFrame
10419
10420 DESCRIPTION
10421 Internal utility function to send FC frame. Enable
10422 or disable LWM mode based on the information.
10423
10424 DEPENDENCIES
10425 TL must be initiailized before this function gets called.
10426 FW sends up special flow control frame.
10427
10428 PARAMETERS
10429
10430 IN
10431 pvosGCtx: pointer to the global vos context; a handle to TL's
10432 control block can be extracted from its context
10433
10434 RETURN VALUE
10435 The result code associated with performing the operation
10436
10437 VOS_STATUS_E_INVAL: Input pointers are NULL.
10438 VOS_STATUS_E_FAULT: Something is wrong.
10439 VOS_STATUS_SUCCESS: Everything is good.
10440
10441 SIDE EFFECTS
10442 Newly formed FC frame is generated and waits to be transmitted. Previously unsent frame will
10443 be released.
10444
10445============================================================================*/
10446VOS_STATUS
10447WLANTL_TxFCFrame
10448(
10449 v_PVOID_t pvosGCtx
10450)
10451{
10452#if 0
10453 WLANTL_CbType* pTLCb = NULL;
10454 VOS_STATUS vosStatus;
10455 tpHalFcTxBd pvFcTxBd = NULL;
10456 vos_pkt_t * pPacket = NULL;
10457 v_U8_t ucSTAId = 0;
10458 v_U8_t ucBitCheck = 1;
10459
10460 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070010461 "WLAN TL: Send FC frame %s", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070010462
10463 /*------------------------------------------------------------------------
10464 Sanity check
10465 ------------------------------------------------------------------------*/
10466 if ( NULL == pvosGCtx )
10467 {
10468 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070010469 "WLAN TL:Invalid parameter %s", __func__));
Jeff Johnson295189b2012-06-20 16:38:30 -070010470 return VOS_STATUS_E_INVAL;
10471 }
10472 /*------------------------------------------------------------------------
10473 Extract TL control block
10474 ------------------------------------------------------------------------*/
10475 pTLCb = VOS_GET_TL_CB(pvosGCtx);
10476
10477 if (NULL == pTLCb)
10478 {
10479 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070010480 "WLAN TL:Invalid pointer in %s \n", __func__));
Jeff Johnson295189b2012-06-20 16:38:30 -070010481 return VOS_STATUS_E_INVAL;
10482 }
10483
10484 //Get one voss packet
10485 vosStatus = vos_pkt_get_packet( &pPacket, VOS_PKT_TYPE_TX_802_11_MGMT, sizeof(tHalFcTxBd), 1,
10486 VOS_FALSE, NULL, NULL );
10487
10488 if ( VOS_STATUS_SUCCESS != vosStatus )
10489 {
10490 return VOS_STATUS_E_INVAL;
10491 }
10492
10493 vosStatus = vos_pkt_reserve_head( pPacket, (void *)&pvFcTxBd, sizeof(tHalFcTxBd));
10494
10495 if( VOS_STATUS_SUCCESS != vosStatus )
10496 {
10497 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070010498 "%s: failed to reserve FC TX BD %d\n",__func__, sizeof(tHalFcTxBd)));
Jeff Johnson295189b2012-06-20 16:38:30 -070010499 vos_pkt_return_packet( pPacket );
10500 return VOS_STATUS_E_FAULT;
10501 }
10502
10503 //Generate most recent tlFCInfo. Most fields are correct.
10504 pTLCb->tlFCInfo.fcSTAThreshEnabledMask = 0;
10505 pTLCb->tlFCInfo.fcSTATxMoreDataMask = 0;
10506 for( ucSTAId = 0, ucBitCheck = 1 ; ucSTAId < WLAN_MAX_STA_COUNT; ucBitCheck <<= 1, ucSTAId ++)
10507 {
10508 if (0 == pTLCb->atlSTAClients[ucSTAId].ucExists)
10509 {
10510 continue;
10511 }
10512
10513 if (pTLCb->atlSTAClients[ucSTAId].ucPktPending)
10514 {
10515 pTLCb->tlFCInfo.fcSTATxMoreDataMask |= ucBitCheck;
10516 }
10517
10518 if ( (pTLCb->atlSTAClients[ucSTAId].ucLwmModeEnabled) &&
10519 (pTLCb->atlSTAClients[ucSTAId].bmuMemConsumed > pTLCb->atlSTAClients[ucSTAId].uLwmThreshold))
10520 {
10521 pTLCb->tlFCInfo.fcSTAThreshEnabledMask |= ucBitCheck;
10522
10523 pTLCb->tlFCInfo.fcSTAThresh[ucSTAId] = (tANI_U8)pTLCb->atlSTAClients[ucSTAId].uLwmThreshold;
10524
10525 pTLCb->atlSTAClients[ucSTAId].ucLwmEventReported = FALSE;
10526 }
10527
10528 }
10529
10530 //request immediate feedback
10531 pTLCb->tlFCInfo.fcConfig |= 0x4;
10532
10533 //fill in BD to sent
10534 vosStatus = WLANHAL_FillFcTxBd(pvosGCtx, &pTLCb->tlFCInfo, (void *)pvFcTxBd);
10535
10536 if( VOS_STATUS_SUCCESS != vosStatus )
10537 {
10538 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070010539 "%s: Fill FC TX BD unsuccessful\n", __func__));
Jeff Johnson295189b2012-06-20 16:38:30 -070010540 vos_pkt_return_packet( pPacket );
10541 return VOS_STATUS_E_FAULT;
10542 }
10543
10544 if (NULL != pTLCb->vosTxFCBuf)
10545 {
10546 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070010547 "%s: Previous FC TX BD not sent\n", __func__));
Jeff Johnson295189b2012-06-20 16:38:30 -070010548 vos_pkt_return_packet(pTLCb->vosTxFCBuf);
10549 }
10550
10551 pTLCb->vosTxFCBuf = pPacket;
10552
10553 vos_pkt_set_user_data_ptr( pPacket, VOS_PKT_USER_DATA_ID_TL,
10554 (v_PVOID_t)WLANTL_TxCompDefaultCb);
10555 vosStatus = WDA_DS_StartXmit(pvosGCtx);
10556
10557 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070010558 "WLAN TL: send FC frame leave %s", __func__));
Jeff Johnson295189b2012-06-20 16:38:30 -070010559#endif
10560 return VOS_STATUS_SUCCESS;
10561}
10562
Jeff Johnson295189b2012-06-20 16:38:30 -070010563
10564/*==========================================================================
10565 FUNCTION WLANTL_GetTxResourcesCB
10566
10567 DESCRIPTION
10568 Processing function for Resource needed signal. A request will be issued
10569 to BAL to get more tx resources.
10570
10571 DEPENDENCIES
10572 The TL must be initialized before this function can be called.
10573
10574 PARAMETERS
10575
10576 IN
10577 pvosGCtx: pointer to the global vos context; a handle to TL's
10578 control block can be extracted from its context
10579
10580
10581 RETURN VALUE
10582 The result code associated with performing the operation
10583
10584 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
10585 page fault
10586 VOS_STATUS_SUCCESS: Everything is good :)
10587
10588 Other values can be returned as a result of a function call, please check
10589 corresponding API for more info.
10590 SIDE EFFECTS
10591
10592============================================================================*/
10593VOS_STATUS
10594WLANTL_GetTxResourcesCB
10595(
10596 v_PVOID_t pvosGCtx
10597)
10598{
10599 WLANTL_CbType* pTLCb = NULL;
10600 v_U32_t uResCount = WDA_TLI_MIN_RES_DATA;
10601 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
10602 v_U8_t ucMgmt = 0;
10603 v_U8_t ucBAP = 0;
10604 v_U8_t ucData = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070010605#ifdef WLAN_SOFTAP_FLOWCTRL_EN
10606 tBssSystemRole systemRole;
10607 tpAniSirGlobal pMac;
10608#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010609 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
10610 /*------------------------------------------------------------------------
10611 Extract TL control block
10612 ------------------------------------------------------------------------*/
10613 pTLCb = VOS_GET_TL_CB(pvosGCtx);
10614 if ( NULL == pTLCb )
10615 {
10616 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
10617 "WLAN TL:Invalid TL pointer from pvosGCtx on"
10618 " WLANTL_ProcessTxMessage"));
10619 return VOS_STATUS_E_FAULT;
10620 }
10621
10622 /*------------------------------------------------------------------------
10623 Get tx resources from BAL
10624 ------------------------------------------------------------------------*/
10625 vosStatus = WDA_DS_GetTxResources( pvosGCtx, &uResCount );
10626
10627 if ( (VOS_STATUS_SUCCESS != vosStatus) && (VOS_STATUS_E_RESOURCES != vosStatus))
10628 {
10629 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
10630 "WLAN TL:TL failed to get resources from BAL, Err: %d",
10631 vosStatus));
10632 return vosStatus;
10633 }
10634
10635 /* Currently only Linux BAL returns the E_RESOURCES error code when it is running
10636 out of BD/PDUs. To make use of this interrupt for throughput enhancement, similar
10637 changes should be done in BAL code of AMSS and WM */
10638 if (VOS_STATUS_E_RESOURCES == vosStatus)
10639 {
10640#ifdef VOLANS_PERF
10641 WLANHAL_EnableIdleBdPduInterrupt(pvosGCtx, (tANI_U8)bdPduInterruptGetThreshold);
10642 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
10643 "WLAN TL: Enabling Idle BD/PDU interrupt, Current resources = %d", uResCount);
10644#else
10645 return VOS_STATUS_E_FAILURE;
10646#endif
10647 }
10648
10649 pTLCb->uResCount = uResCount;
10650
10651
Jeff Johnson295189b2012-06-20 16:38:30 -070010652#ifdef WLAN_SOFTAP_FLOWCTRL_EN
10653 /* FIXME: disabled since creating issues in power-save, needs to be addressed */
10654 pTLCb->sendFCFrame ++;
10655 pMac = vos_get_context(VOS_MODULE_ID_WDA, pvosGCtx);
10656 systemRole = wdaGetGlobalSystemRole(pMac);
10657 if (eSYSTEM_AP_ROLE == systemRole)
10658 {
10659 if (pTLCb->sendFCFrame % 16 == 0)
10660 {
10661 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
10662 "Transmit FC"));
10663 WLANTL_TxFCFrame (pvosGCtx);
10664 }
10665 }
10666#endif //WLAN_SOFTAP_FLOWCTRL_EN
Jeff Johnson295189b2012-06-20 16:38:30 -070010667
10668 ucData = ( pTLCb->uResCount >= WDA_TLI_MIN_RES_DATA );
10669 ucBAP = ( pTLCb->uResCount >= WDA_TLI_MIN_RES_BAP ) &&
10670 ( NULL != pTLCb->tlBAPClient.vosPendingDataBuff );
10671 ucMgmt = ( pTLCb->uResCount >= WDA_TLI_MIN_RES_MF ) &&
10672 ( NULL != pTLCb->tlMgmtFrmClient.vosPendingDataBuff );
10673
10674 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
10675 "WLAN TL: Eval Resume tx Res: %d DATA: %d BAP: %d MGMT: %d",
10676 pTLCb->uResCount, ucData, ucBAP, ucMgmt));
10677
10678 if (( 0 == pTLCb->ucTxSuspended ) &&
10679 (( 0 != ucData ) || ( 0 != ucMgmt ) || ( 0 != ucBAP ) ) )
10680 {
10681 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
10682 "Issuing Xmit start request to BAL for avail res SYNC"));
10683 vosStatus =WDA_DS_StartXmit(pvosGCtx);
10684 }
10685 return vosStatus;
10686}/*WLANTL_GetTxResourcesCB*/
10687
10688/*==========================================================================
10689 Utility functions
10690 ==========================================================================*/
10691
10692/*==========================================================================
10693 FUNCTION WLANTL_Translate8023To80211Header
10694
10695 DESCRIPTION
10696 Inline function for translating and 802.11 header into an 802.3 header.
10697
10698 DEPENDENCIES
10699
10700
10701 PARAMETERS
10702
10703 IN
10704 pTLCb: TL control block
Kiran Venkatappaa044eb92012-12-17 15:48:49 -080010705 IN/OUT
10706 ucStaId: station ID. Incase of TDLS, this returns actual TDLS
10707 station ID used
Jeff Johnson295189b2012-06-20 16:38:30 -070010708
10709 IN/OUT
10710 vosDataBuff: vos data buffer, will contain the new header on output
10711
10712 OUT
10713 pvosStatus: status of the operation
10714
10715 RETURN VALUE
10716
10717 VOS_STATUS_SUCCESS: Everything is good :)
10718
10719 Other error codes might be returned from the vos api used in the function
10720 please check those return values.
10721
10722 SIDE EFFECTS
10723
10724============================================================================*/
Kiran Venkatappacab0d352012-12-17 13:09:22 -080010725VOS_STATUS
10726WLANTL_Translate8023To80211Header
10727(
10728 vos_pkt_t* vosDataBuff,
10729 VOS_STATUS* pvosStatus,
10730 WLANTL_CbType* pTLCb,
10731 v_U8_t *pucStaId,
Ravi Joshid0699502013-07-08 15:48:47 -070010732 WLANTL_MetaInfoType *tlMetaInfo,
Kiran Venkatappacab0d352012-12-17 13:09:22 -080010733 v_U8_t *ucWDSEnabled,
10734 v_U8_t *extraHeadSpace
10735)
Jeff Johnson295189b2012-06-20 16:38:30 -070010736{
10737 WLANTL_8023HeaderType w8023Header;
10738 WLANTL_80211HeaderType *pw80211Header; // Allocate an aligned BD and then fill it.
10739 VOS_STATUS vosStatus;
10740 v_U8_t MandatoryucHeaderSize = WLAN80211_MANDATORY_HEADER_SIZE;
10741 v_U8_t ucHeaderSize = 0;
10742 v_VOID_t *ppvBDHeader = NULL;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053010743 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070010744 v_U8_t ucQoSOffset = WLAN80211_MANDATORY_HEADER_SIZE;
Kiran Venkatappacab0d352012-12-17 13:09:22 -080010745 v_U8_t ucStaId;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010746#ifdef FEATURE_WLAN_ESE_UPLOAD
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070010747 v_BOOL_t bIAPPTxwithLLC = VOS_FALSE;
10748 v_SIZE_t wIAPPSnapSize = WLANTL_LLC_HEADER_LEN;
10749 v_U8_t wIAPPSnap[WLANTL_LLC_HEADER_LEN] = {0};
10750#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010751 *ucWDSEnabled = 0; // default WDS off.
10752 vosStatus = vos_pkt_pop_head( vosDataBuff, &w8023Header,
10753 sizeof(w8023Header));
10754
10755 if ( VOS_STATUS_SUCCESS != vosStatus )
10756 {
10757 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
10758 "WLAN TL: Packet pop header fails on WLANTL_Translate8023To80211Header"));
10759 return vosStatus;
10760 }
10761
Kiran Venkatappacab0d352012-12-17 13:09:22 -080010762 if( NULL == pucStaId )
10763 {
10764 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
10765 "WLAN TL: Invalid pointer for StaId"));
10766 return VOS_STATUS_E_INVAL;
10767 }
10768 ucStaId = *pucStaId;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053010769 pClientSTA = pTLCb->atlSTAClients[ucStaId];
10770
10771 if ( NULL == pClientSTA )
10772 {
10773 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
10774 "WLAN TL:Client Memory was not allocated on %s", __func__));
10775 return VOS_STATUS_E_FAILURE;
10776 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080010777
Kiran Venkatappaa044eb92012-12-17 15:48:49 -080010778#ifdef FEATURE_WLAN_TDLS
10779
Madan Mohan Koyylamudi64258222013-01-30 14:35:10 +053010780 if ( WLAN_STA_INFRA == pTLCb->atlSTAClients[ucStaId]->wSTADesc.wSTAType
10781 && pTLCb->ucTdlsPeerCount )
Kiran Venkatappacab0d352012-12-17 13:09:22 -080010782 {
10783 v_U8_t ucIndex = 0;
10784 for ( ucIndex = 0; ucIndex < WLAN_MAX_STA_COUNT ; ucIndex++)
10785 {
Madan Mohan Koyylamudi64258222013-01-30 14:35:10 +053010786 if ( ucIndex != ucStaId && pTLCb->atlSTAClients[ucIndex] && pTLCb->atlSTAClients[ucIndex]->ucExists &&
Gopichand Nakkala471708b2013-06-04 20:03:01 +053010787 (pTLCb->atlSTAClients[ucIndex]->tlState == WLANTL_STA_AUTHENTICATED) &&
10788 (!pTLCb->atlSTAClients[ucIndex]->ucTxSuspended) &&
Madan Mohan Koyylamudi64258222013-01-30 14:35:10 +053010789 vos_mem_compare( (void*)pTLCb->atlSTAClients[ucIndex]->wSTADesc.vSTAMACAddress.bytes,
Kiran Venkatappacab0d352012-12-17 13:09:22 -080010790 (void*)w8023Header.vDA, 6) )
10791 {
10792 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_LOW,
10793 "WLAN TL: Got a TDLS station. Using that index"));
10794 ucStaId = ucIndex;
10795 *pucStaId = ucStaId;
Madan Mohan Koyylamudi64258222013-01-30 14:35:10 +053010796 pClientSTA = pTLCb->atlSTAClients[ucStaId];
10797 if ( NULL == pClientSTA )
10798 {
10799 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
10800 "WLAN TL:Client Memory was not allocated on %s", __func__));
10801 return VOS_STATUS_E_FAILURE;
10802 }
Kiran Venkatappacab0d352012-12-17 13:09:22 -080010803 break;
10804 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080010805 }
Kiran Venkatappacab0d352012-12-17 13:09:22 -080010806 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080010807#endif
10808
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010809#ifdef FEATURE_WLAN_ESE_UPLOAD
10810if ((0 == w8023Header.usLenType) && (pClientSTA->wSTADesc.ucIsEseSta))
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070010811{
10812 vos_pkt_extract_data(vosDataBuff,0,&wIAPPSnap[0],&wIAPPSnapSize);
10813 if (vos_mem_compare(wIAPPSnap,WLANTL_AIRONET_SNAP_HEADER,WLANTL_LLC_HEADER_LEN))
10814 {
10815 /*The SNAP and the protocol type are already in the data buffer.
10816 They are filled by the application (wpa_supplicant). So, Skip Adding LLC below.*/
10817 bIAPPTxwithLLC = VOS_TRUE;
10818 }
10819 else
10820 {
10821 bIAPPTxwithLLC = VOS_FALSE;
10822 }
10823}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010824#endif /* FEATURE_WLAN_ESE_UPLOAD */
Jeff Johnson295189b2012-06-20 16:38:30 -070010825
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070010826 if ((0 != pClientSTA->wSTADesc.ucAddRmvLLC)
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010827#ifdef FEATURE_WLAN_ESE_UPLOAD
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070010828 && (!bIAPPTxwithLLC)
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010829#endif /* FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070010830 )
Jeff Johnson295189b2012-06-20 16:38:30 -070010831 {
10832 /* Push the length */
10833 vosStatus = vos_pkt_push_head(vosDataBuff,
10834 &w8023Header.usLenType, sizeof(w8023Header.usLenType));
10835
10836 if ( VOS_STATUS_SUCCESS != vosStatus )
10837 {
10838 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
10839 "WLAN TL: Packet push ether type fails on"
10840 " WLANTL_Translate8023To80211Header"));
10841 return vosStatus;
10842 }
10843
10844#ifdef BTAMP_TEST
10845 // The STA side will execute this, a hack to test BTAMP by using the
10846 // infra setup. On real BTAMP this will come from BAP itself.
10847 {
10848 static v_U8_t WLANTL_BT_AMP_LLC_HEADER[] = {0xAA, 0xAA, 0x03, 0x00, 0x19, 0x58 };
10849 vosStatus = vos_pkt_push_head(vosDataBuff, WLANTL_BT_AMP_LLC_HEADER,
10850 sizeof(WLANTL_BT_AMP_LLC_HEADER));
10851
10852 if ( VOS_STATUS_SUCCESS != vosStatus )
10853 {
10854 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
10855 "WLAN TL: Packet push LLC header fails on"
10856 " WLANTL_Translate8023To80211Header"));
10857 return vosStatus;
10858 }
10859 }
10860#else
10861 vosStatus = vos_pkt_push_head(vosDataBuff, WLANTL_LLC_HEADER,
10862 sizeof(WLANTL_LLC_HEADER));
10863
10864 if ( VOS_STATUS_SUCCESS != vosStatus )
10865 {
10866 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
10867 "WLAN TL: Packet push LLC header fails on"
10868 " WLANTL_Translate8023To80211Header"));
10869 return vosStatus;
10870 }
10871#endif
10872 }/*If add LLC is enabled*/
10873 else
10874 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010875#ifdef FEATURE_WLAN_ESE_UPLOAD
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070010876 bIAPPTxwithLLC = VOS_FALSE; /*Reset the Flag here to start afresh with the next TX pkt*/
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010877#endif /* FEATURE_WLAN_ESE_UPLOAD */
Jeff Johnson295189b2012-06-20 16:38:30 -070010878 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
10879 "WLAN TL: STA Client registered to not remove LLC"
10880 " WLANTL_Translate8023To80211Header"));
10881 }
10882
10883#ifdef BTAMP_TEST
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053010884 pClientSTA->wSTADesc.wSTAType = WLAN_STA_BT_AMP;
Jeff Johnson295189b2012-06-20 16:38:30 -070010885#endif
10886
10887 // Find the space required for the 802.11 header format
10888 // based on the frame control fields.
10889 ucHeaderSize = MandatoryucHeaderSize;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053010890 if (pClientSTA->wSTADesc.ucQosEnabled)
Jeff Johnson295189b2012-06-20 16:38:30 -070010891 {
10892 ucHeaderSize += sizeof(pw80211Header->usQosCtrl);
10893 }
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053010894 if (pClientSTA->wSTADesc.wSTAType == WLAN_STA_BT_AMP)
Jeff Johnson295189b2012-06-20 16:38:30 -070010895 {
10896 ucHeaderSize += sizeof(pw80211Header->optvA4);
Jeff Johnson295189b2012-06-20 16:38:30 -070010897 ucQoSOffset += sizeof(pw80211Header->optvA4);
Jeff Johnson295189b2012-06-20 16:38:30 -070010898 }
10899
10900 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
10901 " WLANTL_Translate8023To80211Header : Header size = %d ", ucHeaderSize));
10902
10903 vos_pkt_reserve_head( vosDataBuff, &ppvBDHeader, ucHeaderSize );
10904 if ( NULL == ppvBDHeader )
10905 {
10906 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
10907 "WLAN TL:VOSS packet corrupted "));
10908 *pvosStatus = VOS_STATUS_E_INVAL;
10909 return *pvosStatus;
10910 }
10911
Jeff Johnson295189b2012-06-20 16:38:30 -070010912
10913 // OK now we have the space. Fill the 80211 header
10914 /* Fill A2 */
10915 pw80211Header = (WLANTL_80211HeaderType *)(ppvBDHeader);
10916 // only clear the required space.
10917 vos_mem_set( pw80211Header, ucHeaderSize, 0 );
10918 vos_mem_copy( pw80211Header->vA2, w8023Header.vSA, VOS_MAC_ADDR_SIZE);
10919
10920
10921#ifdef FEATURE_WLAN_WAPI
Gopichand Nakkala8b54e912013-03-11 10:44:21 +053010922 if (( WLANTL_STA_AUTHENTICATED == pClientSTA->tlState ||
Abhishek Singh8cecdaa2015-05-22 14:46:40 +053010923 pClientSTA->ptkInstalled ) && (tlMetaInfo->ucIsWai != 1))
Jeff Johnson295189b2012-06-20 16:38:30 -070010924#else
Gopichand Nakkala8b54e912013-03-11 10:44:21 +053010925 if ( WLANTL_STA_AUTHENTICATED == pClientSTA->tlState ||
10926 pClientSTA->ptkInstalled )
Jeff Johnson295189b2012-06-20 16:38:30 -070010927#endif
10928 {
10929 pw80211Header->wFrmCtrl.wep =
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053010930 pClientSTA->wSTADesc.ucProtectedFrame;
Jeff Johnson295189b2012-06-20 16:38:30 -070010931 }
10932
10933 pw80211Header->usDurationId = 0;
10934 pw80211Header->usSeqCtrl = 0;
10935
10936 pw80211Header->wFrmCtrl.type = WLANTL_80211_DATA_TYPE;
10937
10938
10939
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053010940 if(pClientSTA->wSTADesc.ucQosEnabled)
Jeff Johnson295189b2012-06-20 16:38:30 -070010941 {
10942 pw80211Header->wFrmCtrl.subType = WLANTL_80211_DATA_QOS_SUBTYPE;
10943
Ravi Joshid0699502013-07-08 15:48:47 -070010944 *((v_U16_t *)((v_U8_t *)ppvBDHeader + ucQoSOffset)) = tlMetaInfo->ucUP;
Jeff Johnson295189b2012-06-20 16:38:30 -070010945
10946 }
10947 else
10948 {
10949 pw80211Header->wFrmCtrl.subType = 0;
Agarwal Ashish8b343f12015-01-08 20:06:44 +053010950 tlMetaInfo->ucUP = 0;
10951 tlMetaInfo->ucTID = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070010952
10953 // NO NO NO - there is not enough memory allocated to write the QOS ctrl
10954 // field, it will overwrite the first 2 bytes of the data packet(LLC header)
10955 // pw80211Header->usQosCtrl = 0;
10956 }
10957
10958
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053010959 switch( pClientSTA->wSTADesc.wSTAType )
Jeff Johnson295189b2012-06-20 16:38:30 -070010960 {
Ravi Joshid0699502013-07-08 15:48:47 -070010961 case WLAN_STA_IBSS:
Jeff Johnson295189b2012-06-20 16:38:30 -070010962 pw80211Header->wFrmCtrl.toDS = 0;
10963 pw80211Header->wFrmCtrl.fromDS = 0;
Ravi Joshid0699502013-07-08 15:48:47 -070010964
Abhishek Singh45e68fe2014-12-11 12:55:59 +053010965 vos_copy_macaddr( (v_MACADDR_t*)&pw80211Header->vA1,
Ravi Joshid0699502013-07-08 15:48:47 -070010966 (v_MACADDR_t*)&w8023Header.vDA);
Jeff Johnson295189b2012-06-20 16:38:30 -070010967 vos_mem_copy( pw80211Header->vA3,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053010968 &pClientSTA->wSTADesc.vBSSIDforIBSS ,
Jeff Johnson295189b2012-06-20 16:38:30 -070010969 VOS_MAC_ADDR_SIZE);
10970 break;
10971
Ravi Joshid0699502013-07-08 15:48:47 -070010972 case WLAN_STA_BT_AMP:
Jeff Johnson295189b2012-06-20 16:38:30 -070010973 *ucWDSEnabled = 1; // WDS on.
10974 pw80211Header->wFrmCtrl.toDS = 1;
10975 pw80211Header->wFrmCtrl.fromDS = 1;
10976 vos_copy_macaddr( (v_MACADDR_t*)&pw80211Header->vA1,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053010977 &pClientSTA->wSTADesc.vSTAMACAddress);
Jeff Johnson295189b2012-06-20 16:38:30 -070010978 vos_mem_copy( pw80211Header->vA2,
Ravi Joshid0699502013-07-08 15:48:47 -070010979 w8023Header.vSA, VOS_MAC_ADDR_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -070010980 vos_copy_macaddr( (v_MACADDR_t*)&pw80211Header->vA3,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053010981 &pClientSTA->wSTADesc.vSTAMACAddress);
Jeff Johnson295189b2012-06-20 16:38:30 -070010982 /* fill the optional A4 header */
10983 vos_mem_copy( pw80211Header->optvA4,
Ravi Joshid0699502013-07-08 15:48:47 -070010984 w8023Header.vSA, VOS_MAC_ADDR_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -070010985 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
Arif Hussainf2b00992013-11-17 21:46:15 -080010986 "BTAMP CASE NOW ---------staid=%d",
Ravi Joshid0699502013-07-08 15:48:47 -070010987 ucStaId));
Jeff Johnson295189b2012-06-20 16:38:30 -070010988 break;
10989
Ravi Joshid0699502013-07-08 15:48:47 -070010990 case WLAN_STA_SOFTAP:
Jeff Johnson295189b2012-06-20 16:38:30 -070010991 *ucWDSEnabled = 0; // WDS off.
10992 pw80211Header->wFrmCtrl.toDS = 0;
10993 pw80211Header->wFrmCtrl.fromDS = 1;
10994 /*Copy the DA to A1*/
10995 vos_mem_copy( pw80211Header->vA1, w8023Header.vDA , VOS_MAC_ADDR_SIZE);
10996 vos_copy_macaddr( (v_MACADDR_t*)&pw80211Header->vA2,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053010997 &pClientSTA->wSTADesc.vSelfMACAddress);
Jeff Johnson295189b2012-06-20 16:38:30 -070010998 vos_mem_copy( pw80211Header->vA3,
Ravi Joshid0699502013-07-08 15:48:47 -070010999 w8023Header.vSA, VOS_MAC_ADDR_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -070011000 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
Arif Hussainf2b00992013-11-17 21:46:15 -080011001 "sw 802 to 80211 softap case ---------staid=%d",
Ravi Joshid0699502013-07-08 15:48:47 -070011002 ucStaId));
Jeff Johnson295189b2012-06-20 16:38:30 -070011003 break;
Mohit Khanna698ba2a2012-12-04 15:08:18 -080011004#ifdef FEATURE_WLAN_TDLS
Ravi Joshid0699502013-07-08 15:48:47 -070011005 case WLAN_STA_TDLS:
Mohit Khanna698ba2a2012-12-04 15:08:18 -080011006 pw80211Header->wFrmCtrl.toDS = 0;
11007 pw80211Header->wFrmCtrl.fromDS = 0;
11008 /*Fix me*/
11009 vos_copy_macaddr( (v_MACADDR_t*)&pw80211Header->vA1,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053011010 &pClientSTA->wSTADesc.vSTAMACAddress);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080011011 vos_mem_copy( pw80211Header->vA3,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053011012 &pClientSTA->wSTADesc.vBSSIDforIBSS ,
Mohit Khanna698ba2a2012-12-04 15:08:18 -080011013 VOS_MAC_ADDR_SIZE);
11014 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
Arif Hussainf2b00992013-11-17 21:46:15 -080011015 ("TL:TDLS CASE NOW ---------staid=%d"), ucStaId);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080011016 break;
11017#endif
Ravi Joshid0699502013-07-08 15:48:47 -070011018 case WLAN_STA_INFRA:
11019 default:
Jeff Johnson295189b2012-06-20 16:38:30 -070011020 pw80211Header->wFrmCtrl.toDS = 1;
11021 pw80211Header->wFrmCtrl.fromDS = 0;
11022 vos_copy_macaddr( (v_MACADDR_t*)&pw80211Header->vA1,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053011023 &pClientSTA->wSTADesc.vSTAMACAddress);
Jeff Johnson295189b2012-06-20 16:38:30 -070011024 vos_mem_copy( pw80211Header->vA3, w8023Header.vDA , VOS_MAC_ADDR_SIZE);
11025 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
Arif Hussainf2b00992013-11-17 21:46:15 -080011026 "REGULAR INFRA LINK CASE---------staid=%d",
Ravi Joshid0699502013-07-08 15:48:47 -070011027 ucStaId));
Jeff Johnson295189b2012-06-20 16:38:30 -070011028 break;
11029 }
11030 // OK now we have the space. Fill the 80211 header
11031 /* Fill A2 */
11032 pw80211Header = (WLANTL_80211HeaderType *)(ppvBDHeader);
11033 return VOS_STATUS_SUCCESS;
11034}/*WLANTL_Translate8023To80211Header*/
11035
11036
11037/*=============================================================================
11038 BEGIN LOG FUNCTION !!! Remove me or clean me
11039=============================================================================*/
Ravi Kumar Vaishnavb7652402013-01-18 19:05:15 -080011040#if 0 //def WLANTL_DEBUG
Jeff Johnson295189b2012-06-20 16:38:30 -070011041
11042#define WLANTL_DEBUG_FRAME_BYTE_PER_LINE 16
11043#define WLANTL_DEBUG_FRAME_BYTE_PER_BYTE 4
11044
11045static v_VOID_t WLANTL_DebugFrame
11046(
11047 v_PVOID_t dataPointer,
11048 v_U32_t dataSize
11049)
11050{
11051 v_U8_t lineBuffer[WLANTL_DEBUG_FRAME_BYTE_PER_LINE];
11052 v_U32_t numLines;
11053 v_U32_t numBytes;
11054 v_U32_t idx;
11055 v_U8_t *linePointer;
11056
11057 numLines = dataSize / WLANTL_DEBUG_FRAME_BYTE_PER_LINE;
11058 numBytes = dataSize % WLANTL_DEBUG_FRAME_BYTE_PER_LINE;
11059 linePointer = (v_U8_t *)dataPointer;
11060
Jeff Johnsonddec6482017-09-19 08:33:57 -070011061 TLLOGE(VOS_TRACE(VOS_MODULE_ID_SAL, VOS_TRACE_LEVEL_ERROR, "WLAN TL:Frame Debug Frame Size %d, Pointer 0x%pK", dataSize, dataPointer));
Jeff Johnson295189b2012-06-20 16:38:30 -070011062 for(idx = 0; idx < numLines; idx++)
11063 {
11064 memset(lineBuffer, 0, WLANTL_DEBUG_FRAME_BYTE_PER_LINE);
11065 memcpy(lineBuffer, linePointer, WLANTL_DEBUG_FRAME_BYTE_PER_LINE);
11066 TLLOGE(VOS_TRACE(VOS_MODULE_ID_SAL, VOS_TRACE_LEVEL_ERROR,
11067 "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",
11068 lineBuffer[0], lineBuffer[1], lineBuffer[2], lineBuffer[3], lineBuffer[4], lineBuffer[5], lineBuffer[6], lineBuffer[7],
11069 lineBuffer[8], lineBuffer[9], lineBuffer[10], lineBuffer[11], lineBuffer[12], lineBuffer[13], lineBuffer[14], lineBuffer[15]));
11070 linePointer += WLANTL_DEBUG_FRAME_BYTE_PER_LINE;
11071 }
11072
11073 if(0 == numBytes)
11074 return;
11075
11076 memset(lineBuffer, 0, WLANTL_DEBUG_FRAME_BYTE_PER_LINE);
11077 memcpy(lineBuffer, linePointer, numBytes);
11078 for(idx = 0; idx < WLANTL_DEBUG_FRAME_BYTE_PER_LINE / WLANTL_DEBUG_FRAME_BYTE_PER_BYTE; idx++)
11079 {
11080 TLLOGE(VOS_TRACE(VOS_MODULE_ID_SAL, VOS_TRACE_LEVEL_ERROR, "WLAN TL:0x%2x 0x%2x 0x%2x 0x%2x",
11081 lineBuffer[idx * WLANTL_DEBUG_FRAME_BYTE_PER_BYTE], lineBuffer[1 + idx * WLANTL_DEBUG_FRAME_BYTE_PER_BYTE],
11082 lineBuffer[2 + idx * WLANTL_DEBUG_FRAME_BYTE_PER_BYTE], lineBuffer[3 + idx * WLANTL_DEBUG_FRAME_BYTE_PER_BYTE]));
11083 if(((idx + 1) * WLANTL_DEBUG_FRAME_BYTE_PER_BYTE) >= numBytes)
11084 break;
11085 }
11086
11087 return;
11088}
11089#endif
11090
11091/*=============================================================================
11092 END LOG FUNCTION
11093=============================================================================*/
11094
11095/*==========================================================================
11096 FUNCTION WLANTL_Translate80211To8023Header
11097
11098 DESCRIPTION
11099 Inline function for translating and 802.11 header into an 802.3 header.
11100
11101 DEPENDENCIES
11102
11103
11104 PARAMETERS
11105
11106 IN
11107 pTLCb: TL control block
11108 ucStaId: station ID
11109 ucHeaderLen: Length of the header from BD
11110 ucActualHLen: Length of header including padding or any other trailers
11111
11112 IN/OUT
11113 vosDataBuff: vos data buffer, will contain the new header on output
11114
11115 OUT
11116 pvosStatus: status of the operation
11117
11118 RETURN VALUE
11119
11120 The result code associated with performing the operation
11121 VOS_STATUS_SUCCESS: Everything is good :)
11122
11123 SIDE EFFECTS
11124
11125============================================================================*/
11126VOS_STATUS
11127WLANTL_Translate80211To8023Header
11128(
11129 vos_pkt_t* vosDataBuff,
11130 VOS_STATUS* pvosStatus,
11131 v_U16_t usActualHLen,
11132 v_U8_t ucHeaderLen,
11133 WLANTL_CbType* pTLCb,
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070011134 v_U8_t ucSTAId,
11135 v_BOOL_t bForwardIAPPwithLLC
Jeff Johnson295189b2012-06-20 16:38:30 -070011136)
11137{
11138 WLANTL_8023HeaderType w8023Header;
11139 WLANTL_80211HeaderType w80211Header;
11140 v_U8_t aucLLCHeader[WLANTL_LLC_HEADER_LEN];
11141 VOS_STATUS vosStatus;
11142 v_U16_t usDataStartOffset = 0;
11143 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
11144
11145 if ( sizeof(w80211Header) < ucHeaderLen )
11146 {
11147 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
11148 "Warning !: Check the header size for the Rx frame structure=%d received=%dn",
11149 sizeof(w80211Header), ucHeaderLen));
11150 ucHeaderLen = sizeof(w80211Header);
11151 }
11152
11153 // This will take care of headers of all sizes, 3 address, 3 addr QOS,
11154 // WDS non-QOS and WDS QoS etc. We have space for all in the 802.11 header structure.
11155 vosStatus = vos_pkt_pop_head( vosDataBuff, &w80211Header, ucHeaderLen);
11156
11157 if ( VOS_STATUS_SUCCESS != vosStatus )
11158 {
11159 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11160 "WLAN TL: Failed to pop 80211 header from packet %d",
11161 vosStatus));
11162
11163 return vosStatus;
11164 }
11165
11166 switch ( w80211Header.wFrmCtrl.fromDS )
11167 {
11168 case 0:
Jeff Johnson295189b2012-06-20 16:38:30 -070011169 if ( w80211Header.wFrmCtrl.toDS )
11170 {
11171 //SoftAP AP mode
11172 vos_mem_copy( w8023Header.vDA, w80211Header.vA3, VOS_MAC_ADDR_SIZE);
11173 vos_mem_copy( w8023Header.vSA, w80211Header.vA2, VOS_MAC_ADDR_SIZE);
11174 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
Arif Hussainf2b00992013-11-17 21:46:15 -080011175 "WLAN TL SoftAP: 802 3 DA %08x SA %08x",
Jeff Johnson295189b2012-06-20 16:38:30 -070011176 w8023Header.vDA, w8023Header.vSA));
11177 }
11178 else
11179 {
11180 /* IBSS */
11181 vos_mem_copy( w8023Header.vDA, w80211Header.vA1, VOS_MAC_ADDR_SIZE);
11182 vos_mem_copy( w8023Header.vSA, w80211Header.vA2, VOS_MAC_ADDR_SIZE);
11183 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011184 break;
11185 case 1:
11186 if ( w80211Header.wFrmCtrl.toDS )
11187 {
11188 /* BT-AMP case */
11189 vos_mem_copy( w8023Header.vDA, w80211Header.vA1, VOS_MAC_ADDR_SIZE);
11190 vos_mem_copy( w8023Header.vSA, w80211Header.vA2, VOS_MAC_ADDR_SIZE);
11191 }
11192 else
11193 { /* Infra */
11194 vos_mem_copy( w8023Header.vDA, w80211Header.vA1, VOS_MAC_ADDR_SIZE);
11195 vos_mem_copy( w8023Header.vSA, w80211Header.vA3, VOS_MAC_ADDR_SIZE);
11196 }
11197 break;
11198 }
11199
11200 if( usActualHLen > ucHeaderLen )
11201 {
11202 usDataStartOffset = usActualHLen - ucHeaderLen;
11203 }
11204
11205 if ( 0 < usDataStartOffset )
11206 {
11207 vosStatus = vos_pkt_trim_head( vosDataBuff, usDataStartOffset );
11208
11209 if ( VOS_STATUS_SUCCESS != vosStatus )
11210 {
11211 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11212 "WLAN TL: Failed to trim header from packet %d",
11213 vosStatus));
11214 return vosStatus;
11215 }
11216 }
11217
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053011218 if ( NULL == pTLCb->atlSTAClients[ucSTAId] )
11219 {
11220 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11221 "WLAN TL:Client Memory was not allocated on %s", __func__));
11222 return VOS_STATUS_E_FAILURE;
11223 }
11224
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070011225 if ( 0 != pTLCb->atlSTAClients[ucSTAId]->wSTADesc.ucAddRmvLLC
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080011226#ifdef FEATURE_WLAN_ESE_UPLOAD
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070011227 && (!bForwardIAPPwithLLC)
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080011228#endif /* FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070011229 )
Jeff Johnson295189b2012-06-20 16:38:30 -070011230 {
11231 // Extract the LLC header
11232 vosStatus = vos_pkt_pop_head( vosDataBuff, aucLLCHeader,
11233 WLANTL_LLC_HEADER_LEN);
11234
11235 if ( VOS_STATUS_SUCCESS != vosStatus )
11236 {
Kaushik, Sushante386ee12014-05-01 15:50:52 +053011237 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
Jeff Johnson295189b2012-06-20 16:38:30 -070011238 "WLAN TL: Failed to pop LLC header from packet %d",
11239 vosStatus));
11240
11241 return vosStatus;
11242 }
11243
11244 //Extract the length
11245 vos_mem_copy(&w8023Header.usLenType,
11246 &aucLLCHeader[WLANTL_LLC_HEADER_LEN - sizeof(w8023Header.usLenType)],
11247 sizeof(w8023Header.usLenType) );
11248 }
11249 else
11250 {
11251 vosStatus = vos_pkt_get_packet_length(vosDataBuff,
11252 &w8023Header.usLenType);
11253
11254 if ( VOS_STATUS_SUCCESS != vosStatus )
11255 {
11256 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11257 "WLAN TL: Failed to get packet length %d",
11258 vosStatus));
11259
11260 return vosStatus;
11261 }
11262
11263 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
11264 "WLAN TL: BTAMP len (ethertype) fld = %d",
11265 w8023Header.usLenType));
11266 w8023Header.usLenType = vos_cpu_to_be16(w8023Header.usLenType);
11267 }
11268
11269 vos_pkt_push_head(vosDataBuff, &w8023Header, sizeof(w8023Header));
11270
11271#ifdef BTAMP_TEST
11272 {
11273 // AP side will execute this.
11274 v_U8_t *temp_w8023Header = NULL;
11275 vosStatus = vos_pkt_peek_data( vosDataBuff, 0,
11276 &temp_w8023Header, sizeof(w8023Header) );
11277 }
11278#endif
11279#if 0 /*TL_DEBUG*/
11280 vos_pkt_get_packet_length(vosDataBuff, &usLen);
11281 vos_pkt_pop_head( vosDataBuff, aucData, usLen);
11282
11283 WLANTL_DebugFrame(aucData, usLen);
11284
11285 vos_pkt_push_head(vosDataBuff, aucData, usLen);
11286
11287#endif
11288
11289 *pvosStatus = VOS_STATUS_SUCCESS;
11290
11291 return VOS_STATUS_SUCCESS;
11292}/*WLANTL_Translate80211To8023Header*/
11293
Katya Nigame7b69a82015-04-28 15:24:06 +053011294VOS_STATUS
11295WLANTL_MonTranslate80211To8023Header
11296(
11297 vos_pkt_t* vosDataBuff,
11298 WLANTL_CbType* pTLCb
11299)
11300{
11301 v_U16_t usMPDUDOffset;
11302 v_U8_t ucMPDUHOffset;
11303 v_U8_t ucMPDUHLen;
11304 v_U16_t usActualHLen = 0;
11305 v_U16_t usDataStartOffset = 0;
11306 v_PVOID_t aucBDHeader;
11307 WLANTL_8023HeaderType w8023Header;
11308 WLANTL_80211HeaderType w80211Header;
11309 VOS_STATUS vosStatus;
11310 v_U8_t aucLLCHeader[WLANTL_LLC_HEADER_LEN];
11311
11312 WDA_DS_PeekRxPacketInfo( vosDataBuff, (v_PVOID_t)&aucBDHeader, 0 );
11313 ucMPDUHOffset = (v_U8_t)WDA_GET_RX_MPDU_HEADER_OFFSET(aucBDHeader);
11314 usMPDUDOffset = (v_U16_t)WDA_GET_RX_MPDU_DATA_OFFSET(aucBDHeader);
11315 ucMPDUHLen = (v_U8_t)WDA_GET_RX_MPDU_HEADER_LEN(aucBDHeader);
11316 if (usMPDUDOffset > ucMPDUHOffset)
11317 {
11318 usActualHLen = usMPDUDOffset - ucMPDUHOffset;
11319 }
11320
11321 if ( sizeof(w80211Header) < ucMPDUHLen )
11322 {
11323 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
11324 "Warning !: Check the header size for the Rx frame structure=%d received=%dn",
11325 sizeof(w80211Header), ucMPDUHLen));
11326 ucMPDUHLen = sizeof(w80211Header);
11327 }
11328
11329 vosStatus = vos_pkt_pop_head( vosDataBuff, &w80211Header, ucMPDUHLen);
11330 if ( VOS_STATUS_SUCCESS != vosStatus )
11331 {
11332 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11333 "WLAN TL: Failed to pop 80211 header from packet %d",
11334 vosStatus));
11335
11336 return vosStatus;
11337 }
11338 switch ( w80211Header.wFrmCtrl.fromDS )
11339 {
11340 case 0:
11341 if ( w80211Header.wFrmCtrl.toDS )
11342 {
11343 vos_mem_copy( w8023Header.vDA, w80211Header.vA3, VOS_MAC_ADDR_SIZE);
11344 vos_mem_copy( w8023Header.vSA, w80211Header.vA2, VOS_MAC_ADDR_SIZE);
11345 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
11346 "WLAN TL SoftAP: 802 3 DA %08x SA %08x",
11347 w8023Header.vDA, w8023Header.vSA));
11348 }
11349 else
11350 {
11351 vos_mem_copy( w8023Header.vDA, w80211Header.vA1, VOS_MAC_ADDR_SIZE);
11352 vos_mem_copy( w8023Header.vSA, w80211Header.vA2, VOS_MAC_ADDR_SIZE);
11353 }
11354 break;
11355 case 1:
11356 if ( w80211Header.wFrmCtrl.toDS )
11357 {
11358 vos_mem_copy( w8023Header.vDA, w80211Header.vA1, VOS_MAC_ADDR_SIZE);
11359 vos_mem_copy( w8023Header.vSA, w80211Header.vA2, VOS_MAC_ADDR_SIZE);
11360 }
11361 else
11362 {
11363 vos_mem_copy( w8023Header.vDA, w80211Header.vA1, VOS_MAC_ADDR_SIZE);
11364 vos_mem_copy( w8023Header.vSA, w80211Header.vA3, VOS_MAC_ADDR_SIZE);
11365 }
11366 break;
11367 }
11368 if( usActualHLen > ucMPDUHLen )
11369 {
11370 usDataStartOffset = usActualHLen - ucMPDUHLen;
11371 }
11372
11373 if ( 0 < usDataStartOffset )
11374 {
11375 vosStatus = vos_pkt_trim_head( vosDataBuff, usDataStartOffset );
11376
11377 if ( VOS_STATUS_SUCCESS != vosStatus )
11378 {
11379 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11380 "WLAN TL: Failed to trim header from packet %d",
11381 vosStatus));
11382 return vosStatus;
11383 }
11384 }
11385 // Extract the LLC header
11386 vosStatus = vos_pkt_pop_head( vosDataBuff, aucLLCHeader,
11387 WLANTL_LLC_HEADER_LEN);
11388
11389 if ( VOS_STATUS_SUCCESS != vosStatus )
11390 {
11391 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
11392 "WLAN TL: Failed to pop LLC header from packet %d",
11393 vosStatus));
11394
11395 return vosStatus;
11396 }
11397
11398 //Extract the length
11399 vos_mem_copy(&w8023Header.usLenType,
11400 &aucLLCHeader[WLANTL_LLC_HEADER_LEN - sizeof(w8023Header.usLenType)],
11401 sizeof(w8023Header.usLenType) );
11402
11403 vos_pkt_push_head(vosDataBuff, &w8023Header, sizeof(w8023Header));
11404 return VOS_STATUS_SUCCESS;
11405}
11406
Madan Mohan Koyyalamudia148e1e2012-11-30 14:52:59 -080011407/*==========================================================================
11408 FUNCTION WLANTL_FindFrameTypeBcMcUc
11409
11410 DESCRIPTION
11411 Utility function to find whether received frame is broadcast, multicast
11412 or unicast.
11413
11414 DEPENDENCIES
11415 The STA must be registered with TL before this function can be called.
11416
11417 PARAMETERS
11418
11419 IN
11420 pTLCb: pointer to the TL's control block
11421 ucSTAId: identifier of the station being processed
11422 vosDataBuff: pointer to the vos buffer
11423
11424 IN/OUT
11425 pucBcMcUc: pointer to buffer, will contain frame type on return
11426
11427 RETURN VALUE
11428 The result code associated with performing the operation
11429
11430 VOS_STATUS_E_INVAL: invalid input parameters
11431 VOS_STATUS_E_BADMSG: failed to extract info from data buffer
11432 VOS_STATUS_SUCCESS: success
11433
11434 SIDE EFFECTS
11435 None.
11436============================================================================*/
11437VOS_STATUS
11438WLANTL_FindFrameTypeBcMcUc
11439(
11440 WLANTL_CbType *pTLCb,
11441 v_U8_t ucSTAId,
11442 vos_pkt_t *vosDataBuff,
11443 v_U8_t *pucBcMcUc
11444)
11445{
11446 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
11447 v_PVOID_t aucBDHeader;
11448 v_PVOID_t pvPeekData;
11449 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
11450
11451 /*------------------------------------------------------------------------
11452 Sanity check
11453 ------------------------------------------------------------------------*/
11454 if ((NULL == pTLCb) ||
11455 (NULL == vosDataBuff) ||
11456 (NULL == pucBcMcUc))
11457 {
11458 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11459 "WLAN TL:Invalid parameter in WLANTL_FindFrameTypeBcMcUc"));
11460 return VOS_STATUS_E_INVAL;
11461 }
11462
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053011463 if ( NULL == pTLCb->atlSTAClients[ucSTAId] )
11464 {
11465 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11466 "WLAN TL:Client Memory was not allocated on %s", __func__));
11467 return VOS_STATUS_E_FAILURE;
11468 }
11469
Madan Mohan Koyyalamudia148e1e2012-11-30 14:52:59 -080011470 /*------------------------------------------------------------------------
11471 Extract BD header and check if valid
11472 ------------------------------------------------------------------------*/
11473 vosStatus = WDA_DS_PeekRxPacketInfo(vosDataBuff, (v_PVOID_t)&aucBDHeader, 0/*Swap BD*/ );
11474
11475 if (NULL == aucBDHeader)
11476 {
11477 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11478 "WLAN TL:WLANTL_FindFrameTypeBcMcUc - Cannot extract BD header"));
11479 VOS_ASSERT(0);
11480 return VOS_STATUS_E_BADMSG;
11481 }
11482
11483 if ((0 == WDA_GET_RX_FT_DONE(aucBDHeader)) &&
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053011484 (0 != pTLCb->atlSTAClients[ucSTAId]->wSTADesc.ucSwFrameRXXlation))
Madan Mohan Koyyalamudia148e1e2012-11-30 14:52:59 -080011485 {
11486 /* Its an 802.11 frame, extract MAC address 1 */
11487 TLLOG2(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
11488 "WLAN TL:WLANTL_FindFrameTypeBcMcUc - 802.11 frame, peeking Addr1"));
11489 vosStatus = vos_pkt_peek_data(vosDataBuff, WLANTL_MAC_ADDR_ALIGN(1),
11490 (v_PVOID_t)&pvPeekData, VOS_MAC_ADDR_SIZE);
11491 }
11492 else
11493 {
11494 /* Its an 802.3 frame, extract Destination MAC address */
11495 TLLOG2(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
11496 "WLAN TL:WLANTL_FindFrameTypeBcMcUc - 802.3 frame, peeking DA"));
11497 vosStatus = vos_pkt_peek_data(vosDataBuff, WLANTL_MAC_ADDR_ALIGN(0),
11498 (v_PVOID_t)&pvPeekData, VOS_MAC_ADDR_SIZE);
11499 }
11500
11501 if (VOS_STATUS_SUCCESS != vosStatus)
11502 {
11503 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11504 "WLAN TL:WLANTL_FindFrameTypeBcMcUc - Failed to peek MAC address"));
11505 return vosStatus;
11506 }
11507
11508 if (((tANI_U8 *)pvPeekData)[0] == 0xff)
11509 {
11510 *pucBcMcUc = WLANTL_FRAME_TYPE_BCAST;
11511 }
11512 else
11513 {
11514 if ((((tANI_U8 *)pvPeekData)[0] & 0x01) == 0x01)
11515 *pucBcMcUc = WLANTL_FRAME_TYPE_MCAST;
11516 else
11517 *pucBcMcUc = WLANTL_FRAME_TYPE_UCAST;
11518 }
11519
11520 TLLOG2(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
11521 "WLAN TL:WLANTL_FindFrameTypeBcMcUc - Addr1Byte1 is: %x",
11522 ((tANI_U8 *)pvPeekData)[0]));
11523
11524 return VOS_STATUS_SUCCESS;
11525}
11526
Jeff Johnson295189b2012-06-20 16:38:30 -070011527#if 0
11528#ifdef WLAN_PERF
11529/*==========================================================================
11530 FUNCTION WLANTL_FastHwFwdDataFrame
11531
11532 DESCRIPTION
11533 Fast path function to quickly forward a data frame if HAL determines BD
11534 signature computed here matches the signature inside current VOSS packet.
11535 If there is a match, HAL and TL fills in the swapped packet length into
11536 BD header and DxE header, respectively. Otherwise, packet goes back to
11537 normal (slow) path and a new BD signature would be tagged into BD in this
11538 VOSS packet later by the WLANHAL_FillTxBd() function.
11539
11540 DEPENDENCIES
11541
11542 PARAMETERS
11543
11544 IN
11545 pvosGCtx VOS context
11546 vosDataBuff Ptr to VOSS packet
11547 pMetaInfo For getting frame's TID
11548 pStaInfo For checking STA type
11549
11550 OUT
11551 pvosStatus returned status
11552 puFastFwdOK Flag to indicate whether frame could be fast forwarded
11553
11554 RETURN VALUE
11555 No return.
11556
11557 SIDE EFFECTS
11558
11559============================================================================*/
11560static void
11561WLANTL_FastHwFwdDataFrame
11562(
11563 v_PVOID_t pvosGCtx,
11564 vos_pkt_t* vosDataBuff,
11565 VOS_STATUS* pvosStatus,
11566 v_U32_t* puFastFwdOK,
11567 WLANTL_MetaInfoType* pMetaInfo,
11568 WLAN_STADescType* pStaInfo
11569
11570)
11571{
11572 v_PVOID_t pvPeekData;
11573 v_U8_t ucDxEBDWLANHeaderLen = WLANTL_BD_HEADER_LEN(0) + sizeof(WLANBAL_sDXEHeaderType);
11574 v_U8_t ucIsUnicast;
11575 WLANBAL_sDXEHeaderType *pDxEHeader;
11576 v_PVOID_t pvBDHeader;
11577 v_PVOID_t pucBuffPtr;
11578 v_U16_t usPktLen;
11579
11580 /*-----------------------------------------------------------------------
11581 Extract packet length
11582 -----------------------------------------------------------------------*/
11583
11584 vos_pkt_get_packet_length( vosDataBuff, &usPktLen);
11585
11586 /*-----------------------------------------------------------------------
11587 Extract MAC address
11588 -----------------------------------------------------------------------*/
11589 *pvosStatus = vos_pkt_peek_data( vosDataBuff,
11590 WLANTL_MAC_ADDR_ALIGN(0),
11591 (v_PVOID_t)&pvPeekData,
11592 VOS_MAC_ADDR_SIZE );
11593
11594 if ( VOS_STATUS_SUCCESS != *pvosStatus )
11595 {
11596 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11597 "WLAN TL:Failed while attempting to extract MAC Addr %d",
11598 *pvosStatus));
11599 *pvosStatus = VOS_STATUS_E_INVAL;
11600 return;
11601 }
11602
11603 /*-----------------------------------------------------------------------
11604 Reserve head room for DxE header, BD, and WLAN header
11605 -----------------------------------------------------------------------*/
11606
11607 vos_pkt_reserve_head( vosDataBuff, &pucBuffPtr,
11608 ucDxEBDWLANHeaderLen );
11609 if ( NULL == pucBuffPtr )
11610 {
11611 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Jeff Johnsonddec6482017-09-19 08:33:57 -070011612 "WLAN TL:No enough space in VOSS packet %pK for DxE/BD/WLAN header", vosDataBuff));
Jeff Johnson295189b2012-06-20 16:38:30 -070011613 *pvosStatus = VOS_STATUS_E_INVAL;
11614 return;
11615 }
11616 pDxEHeader = (WLANBAL_sDXEHeaderType *)pucBuffPtr;
11617 pvBDHeader = (v_PVOID_t) &pDxEHeader[1];
11618
11619 /* UMA Tx acceleration is enabled.
11620 * UMA would help convert frames to 802.11, fill partial BD fields and
11621 * construct LLC header. To further accelerate this kind of frames,
11622 * HAL would attempt to reuse the BD descriptor if the BD signature
11623 * matches to the saved BD descriptor.
11624 */
11625 if(pStaInfo->wSTAType == WLAN_STA_IBSS)
11626 ucIsUnicast = !(((tANI_U8 *)pvPeekData)[0] & 0x01);
11627 else
11628 ucIsUnicast = 1;
11629
11630 *puFastFwdOK = (v_U32_t) WLANHAL_TxBdFastFwd(pvosGCtx, pvPeekData, pMetaInfo->ucTID, ucIsUnicast, pvBDHeader, usPktLen );
11631
11632 /* Can't be fast forwarded. Trim the VOS head back to original location. */
11633 if(! *puFastFwdOK){
11634 vos_pkt_trim_head(vosDataBuff, ucDxEBDWLANHeaderLen);
11635 }else{
11636 /* could be fast forwarded. Now notify BAL DxE header filling could be completely skipped
11637 */
11638 v_U32_t uPacketSize = WLANTL_BD_HEADER_LEN(0) + usPktLen;
11639 vos_pkt_set_user_data_ptr( vosDataBuff, VOS_PKT_USER_DATA_ID_BAL,
11640 (v_PVOID_t)uPacketSize);
11641 pDxEHeader->size = SWAP_ENDIAN_UINT32(uPacketSize);
11642 }
11643 *pvosStatus = VOS_STATUS_SUCCESS;
11644 return;
11645}
11646#endif /*WLAN_PERF*/
11647#endif
11648
11649#if 0
11650/*==========================================================================
11651 FUNCTION WLANTL_PrepareBDHeader
11652
11653 DESCRIPTION
11654 Inline function for preparing BD header before HAL processing.
11655
11656 DEPENDENCIES
11657 Just notify HAL that suspend in TL is complete.
11658
11659 PARAMETERS
11660
11661 IN
11662 vosDataBuff: vos data buffer
11663 ucDisableFrmXtl: is frame xtl disabled
11664
11665 OUT
11666 ppvBDHeader: it will contain the BD header
11667 pvDestMacAdddr: it will contain the destination MAC address
11668 pvosStatus: status of the combined processing
11669 pusPktLen: packet len.
11670
11671 RETURN VALUE
11672 No return.
11673
11674 SIDE EFFECTS
11675
11676============================================================================*/
11677void
11678WLANTL_PrepareBDHeader
11679(
11680 vos_pkt_t* vosDataBuff,
11681 v_PVOID_t* ppvBDHeader,
11682 v_MACADDR_t* pvDestMacAdddr,
11683 v_U8_t ucDisableFrmXtl,
11684 VOS_STATUS* pvosStatus,
11685 v_U16_t* pusPktLen,
11686 v_U8_t ucQosEnabled,
11687 v_U8_t ucWDSEnabled,
11688 v_U8_t extraHeadSpace
11689)
11690{
11691 v_U8_t ucHeaderOffset;
11692 v_U8_t ucHeaderLen;
Jeff Johnson295189b2012-06-20 16:38:30 -070011693 v_U8_t ucBDHeaderLen = WLANTL_BD_HEADER_LEN(ucDisableFrmXtl);
11694
11695 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
11696 /*-------------------------------------------------------------------------
11697 Get header pointer from VOSS
11698 !!! make sure reserve head zeros out the memory
11699 -------------------------------------------------------------------------*/
11700 vos_pkt_get_packet_length( vosDataBuff, pusPktLen);
11701
11702 if ( WLANTL_MAC_HEADER_LEN(ucDisableFrmXtl) > *pusPktLen )
11703 {
11704 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11705 "WLAN TL: Length of the packet smaller than expected network"
11706 " header %d", *pusPktLen ));
11707
11708 *pvosStatus = VOS_STATUS_E_INVAL;
11709 return;
11710 }
11711
11712 vos_pkt_reserve_head( vosDataBuff, ppvBDHeader,
11713 ucBDHeaderLen );
11714 if ( NULL == *ppvBDHeader )
11715 {
11716 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11717 "WLAN TL:VOSS packet corrupted on Attach BD header"));
11718 *pvosStatus = VOS_STATUS_E_INVAL;
11719 return;
11720 }
11721
11722 /*-----------------------------------------------------------------------
11723 Extract MAC address
11724 -----------------------------------------------------------------------*/
Jeff Johnson295189b2012-06-20 16:38:30 -070011725 {
11726 v_SIZE_t usMacAddrSize = VOS_MAC_ADDR_SIZE;
11727 *pvosStatus = vos_pkt_extract_data( vosDataBuff,
11728 ucBDHeaderLen +
11729 WLANTL_MAC_ADDR_ALIGN(ucDisableFrmXtl),
11730 (v_PVOID_t)pvDestMacAdddr,
11731 &usMacAddrSize );
11732 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011733 if ( VOS_STATUS_SUCCESS != *pvosStatus )
11734 {
11735 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11736 "WLAN TL:Failed while attempting to extract MAC Addr %d",
11737 *pvosStatus));
11738 }
11739 else
11740 {
11741 /*---------------------------------------------------------------------
11742 Fill MPDU info fields:
11743 - MPDU data start offset
11744 - MPDU header start offset
11745 - MPDU header length
11746 - MPDU length - this is a 16b field - needs swapping
11747 --------------------------------------------------------------------*/
11748 ucHeaderOffset = ucBDHeaderLen;
11749 ucHeaderLen = WLANTL_MAC_HEADER_LEN(ucDisableFrmXtl);
11750
11751 if ( 0 != ucDisableFrmXtl )
11752 {
11753 if ( 0 != ucQosEnabled )
11754 {
11755 ucHeaderLen += WLANTL_802_11_HEADER_QOS_CTL;
11756 }
11757
11758 // Similar to Qos we need something for WDS format !
11759 if ( ucWDSEnabled != 0 )
11760 {
11761 // If we have frame translation enabled
11762 ucHeaderLen += WLANTL_802_11_HEADER_ADDR4_LEN;
11763 }
11764 if ( extraHeadSpace != 0 )
11765 {
11766 // Decrease the packet length with the extra padding after the header
11767 *pusPktLen = *pusPktLen - extraHeadSpace;
11768 }
11769 }
11770
11771 WLANHAL_TX_BD_SET_MPDU_HEADER_LEN( *ppvBDHeader, ucHeaderLen);
11772 WLANHAL_TX_BD_SET_MPDU_HEADER_OFFSET( *ppvBDHeader, ucHeaderOffset);
11773 WLANHAL_TX_BD_SET_MPDU_DATA_OFFSET( *ppvBDHeader,
11774 ucHeaderOffset + ucHeaderLen + extraHeadSpace);
11775 WLANHAL_TX_BD_SET_MPDU_LEN( *ppvBDHeader, *pusPktLen);
11776
11777 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
11778 "WLAN TL: VALUES ARE HLen=%x Hoff=%x doff=%x len=%x ex=%d",
11779 ucHeaderLen, ucHeaderOffset,
11780 (ucHeaderOffset + ucHeaderLen + extraHeadSpace),
11781 *pusPktLen, extraHeadSpace));
11782 }/* if peek MAC success*/
11783
11784}/* WLANTL_PrepareBDHeader */
11785#endif
11786
Jeff Johnson295189b2012-06-20 16:38:30 -070011787//THIS IS A HACK AND NEEDS TO BE FIXED FOR CONCURRENCY
11788/*==========================================================================
11789 FUNCTION WLAN_TLGetNextTxIds
11790
11791 DESCRIPTION
11792 Gets the next station and next AC in the list that should be served by the TL.
11793
11794 Multiple Station Scheduling and TL queue management.
11795
11796 4 HDD BC/MC data packet queue status is specified as Station 0's status. Weights used
11797 in WFQ algorith are initialized in WLANTL_OPEN and contained in tlConfigInfo field.
11798 Each station has fields of ucPktPending and AC mask to tell whether a AC has traffic
11799 or not.
11800
11801 Stations are served in a round-robin fashion from highest priority to lowest priority.
11802 The number of round-robin times of each prioirty equals to the WFQ weights and differetiates
11803 the traffic of different prioirty. As such, stations can not provide low priority packets if
11804 high priority packets are all served.
11805
11806 DEPENDENCIES
11807
11808 PARAMETERS
11809
11810 IN
11811 pvosGCtx: pointer to the global vos context; a handle to TL's
11812 control block can be extracted from its context
11813
11814 OUT
11815 pucSTAId: Station ID
11816
11817 RETURN VALUE
11818 The result code associated with performing the operation
11819
11820 VOS_STATUS_SUCCESS: Everything is good
11821
11822 SIDE EFFECTS
11823
11824 TL context contains currently served station ID in ucCurrentSTA field, currently served AC
11825 in uCurServedAC field, and unserved weights of current AC in uCurLeftWeight.
11826 When existing from the function, these three fields are changed accordingly.
11827
11828============================================================================*/
11829VOS_STATUS
11830WLAN_TLAPGetNextTxIds
11831(
11832 v_PVOID_t pvosGCtx,
11833 v_U8_t* pucSTAId
11834)
11835{
11836 WLANTL_CbType* pTLCb;
11837 v_U8_t ucACFilter = 1;
Sravan Kumar Kairamb0edc612016-10-26 13:55:24 +053011838 v_U8_t ucNextSTA, ucTempSTA;
Jeff Johnson295189b2012-06-20 16:38:30 -070011839 v_BOOL_t isServed = TRUE; //current round has find a packet or not
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +053011840 v_U8_t ucACLoopNum = WLANTL_AC_HIGH_PRIO + 1; //number of loop to go
Jeff Johnson295189b2012-06-20 16:38:30 -070011841 v_U8_t uFlowMask; // TX FlowMask from WDA
11842 uint8 ucACMask;
Sravan Kumar Kairamb0edc612016-10-26 13:55:24 +053011843 uint8 i = 0;
11844 uint8 j;
Sravan Kumar Kairam18017eb2017-01-03 14:58:13 +053011845 uint8 minWeightSta;
11846 uint32_t sta_bitmask = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070011847 /*------------------------------------------------------------------------
11848 Extract TL control block
11849 ------------------------------------------------------------------------*/
11850 //ENTER();
11851
11852 pTLCb = VOS_GET_TL_CB(pvosGCtx);
11853 if ( NULL == pTLCb )
11854 {
11855 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11856 "WLAN TL:Invalid TL pointer from pvosGCtx on WLAN_TLAPGetNextTxIds"));
11857 return VOS_STATUS_E_FAULT;
11858 }
11859
11860 if ( VOS_STATUS_SUCCESS != WDA_DS_GetTxFlowMask( pvosGCtx, &uFlowMask ) )
11861 {
11862 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11863 "WLAN TL:Failed to retrieve Flow control mask from WDA"));
11864 return VOS_STATUS_E_FAULT;
11865 }
11866
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +053011867 /* The flow mask does not differentiate between different ACs/Qs
11868 * since we use a single dxe channel for all ACs/Qs, hence it is
11869 * enough to check that there are dxe resources on data channel
11870 */
11871 uFlowMask &= WLANTL_DATA_FLOW_MASK;
11872
11873 if (0 == uFlowMask)
11874 {
11875 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11876 "WLAN TL: No resources to send packets"));
11877
11878 // Setting STA Id to invalid if mask is 0
11879 *pucSTAId = WLAN_MAX_STA_COUNT;
11880 return VOS_STATUS_E_FAULT;
11881 }
11882
Jeff Johnson295189b2012-06-20 16:38:30 -070011883 ucNextSTA = pTLCb->ucCurrentSTA;
11884
11885 ++ucNextSTA;
11886
11887 if ( WLAN_MAX_STA_COUNT <= ucNextSTA )
Jeff Johnson295189b2012-06-20 16:38:30 -070011888 ucNextSTA = 0;
Sravan Kumar Kairam715072e2017-03-10 17:12:43 +053011889
Jeff Johnson295189b2012-06-20 16:38:30 -070011890 isServed = FALSE;
11891 if ( 0 == pTLCb->ucCurLeftWeight )
11892 {
11893 //current prioirty is done
11894 if ( WLANTL_AC_BK == (WLANTL_ACEnumType)pTLCb->uCurServedAC )
11895 {
11896 //end of current VO, VI, BE, BK loop. Reset priority.
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +053011897 pTLCb->uCurServedAC = WLANTL_AC_HIGH_PRIO;
Jeff Johnson295189b2012-06-20 16:38:30 -070011898 }
11899 else
11900 {
11901 pTLCb->uCurServedAC --;
11902 }
11903
11904 pTLCb->ucCurLeftWeight = pTLCb->tlConfigInfo.ucAcWeights[pTLCb->uCurServedAC];
11905
11906 } // (0 == pTLCb->ucCurLeftWeight)
Jeff Johnson295189b2012-06-20 16:38:30 -070011907
Sravan Kumar Kairamb0edc612016-10-26 13:55:24 +053011908 ucTempSTA = ucNextSTA;
Sravan Kumar Kairam18017eb2017-01-03 14:58:13 +053011909 minWeightSta = ucNextSTA;
Sravan Kumar Kairamb0edc612016-10-26 13:55:24 +053011910
Jeff Johnson295189b2012-06-20 16:38:30 -070011911 //decide how many loops to go. if current loop is partial, do one extra to make sure
11912 //we cover every station
11913 if ((1 == pTLCb->ucCurLeftWeight) && (ucNextSTA != 0))
11914 {
11915 ucACLoopNum ++; // now is 5 loops
11916 }
11917
11918 /* Start with highest priority. ucNextSTA, pTLCb->uCurServedAC, pTLCb->ucCurLeftWeight
11919 all have previous values.*/
11920 for (; ucACLoopNum > 0; ucACLoopNum--)
11921 {
11922
11923 ucACFilter = 1 << pTLCb->uCurServedAC;
11924
11925 // pTLCb->ucCurLeftWeight keeps previous results.
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +053011926 for (; (pTLCb->ucCurLeftWeight > 0) ; pTLCb->ucCurLeftWeight-- )
Jeff Johnson295189b2012-06-20 16:38:30 -070011927 {
11928
11929 for ( ; ucNextSTA < WLAN_MAX_STA_COUNT; ucNextSTA ++ )
11930 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053011931 if(NULL == pTLCb->atlSTAClients[ucNextSTA])
11932 {
11933 continue;
11934 }
11935 WLAN_TL_AC_ARRAY_2_MASK (pTLCb->atlSTAClients[ucNextSTA], ucACMask, i);
Jeff Johnson295189b2012-06-20 16:38:30 -070011936
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053011937 if ( (0 == pTLCb->atlSTAClients[ucNextSTA]->ucExists) ||
11938 ((0 == pTLCb->atlSTAClients[ucNextSTA]->ucPktPending) && !(ucACMask)) ||
Jeff Johnson295189b2012-06-20 16:38:30 -070011939 (0 == (ucACMask & ucACFilter)) )
11940
11941 {
Tushnim Bhattacharyya39a8f182013-02-20 18:10:30 -080011942 //current station does not exist or have any packet to serve.
11943 continue;
11944 }
11945
Bhargav Shahfbaeca22016-07-13 10:27:35 +053011946 if ((WLANTL_STA_AUTHENTICATED != pTLCb->atlSTAClients[ucNextSTA]->tlState)
11947 || (pTLCb->atlSTAClients[ucNextSTA]->disassoc_progress == VOS_TRUE ))
Tushnim Bhattacharyya39a8f182013-02-20 18:10:30 -080011948 {
11949 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
11950 "%s Sta %d not in auth state so skipping it.",
11951 __func__, ucNextSTA));
Jeff Johnson295189b2012-06-20 16:38:30 -070011952 continue;
11953 }
11954
11955 //go to next station if current station can't send due to flow control
11956 //Station is allowed to send when it is not in LWM mode. When station is in LWM mode,
11957 //station is allowed to send only after FW reports FW memory is below threshold and on-fly
11958 //packets are less then allowed value
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053011959 if ( (TRUE == pTLCb->atlSTAClients[ucNextSTA]->ucLwmModeEnabled) &&
11960 ((FALSE == pTLCb->atlSTAClients[ucNextSTA]->ucLwmEventReported) ||
11961 (0 < pTLCb->atlSTAClients[ucNextSTA]->uBuffThresholdMax))
Jeff Johnson295189b2012-06-20 16:38:30 -070011962 )
11963 {
11964 continue;
11965 }
11966
Sravan Kumar Kairamb0edc612016-10-26 13:55:24 +053011967 /*
11968 * Initial weight is 0 is for all the stations. As part of FW TX stats
11969 * indication to host, good peer weight is updated to one and the
11970 * remaining peers weight is updated based on their RA rates and BTQM
11971 * queued frames length. TL skips fetching the packet until the station
11972 * has got chances equal to its weight.
11973 */
11974 if (pTLCb->atlSTAClients[ucNextSTA]->weight > WLANTL_GOOD_STA_WEIGHT) {
11975 if (pTLCb->atlSTAClients[ucNextSTA]->weight_count <=
Sravan Kumar Kairam18017eb2017-01-03 14:58:13 +053011976 pTLCb->atlSTAClients[ucNextSTA]->weight)
11977 {
11978 if (pTLCb->atlSTAClients[minWeightSta]->weight <= 1)
11979 minWeightSta = ucNextSTA;
11980 else if (pTLCb->atlSTAClients[ucNextSTA]->weight <
11981 pTLCb->atlSTAClients[minWeightSta]->weight) {
11982 minWeightSta = ucNextSTA;
11983 }
11984 sta_bitmask |= (1 << ucNextSTA);
Sravan Kumar Kairamb0edc612016-10-26 13:55:24 +053011985 pTLCb->atlSTAClients[ucNextSTA]->weight_count++;
11986 continue;
11987 }
11988 else
11989 pTLCb->atlSTAClients[ucNextSTA]->weight_count = 0;
11990 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011991
11992 // Find a station. Weight is updated already.
11993 *pucSTAId = ucNextSTA;
11994 pTLCb->ucCurrentSTA = ucNextSTA;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053011995 pTLCb->atlSTAClients[*pucSTAId]->ucCurrentAC = pTLCb->uCurServedAC;
Jeff Johnson295189b2012-06-20 16:38:30 -070011996
11997 TLLOG4(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_LOW,
11998 " TL serve one station AC: %d W: %d StaId: %d",
11999 pTLCb->uCurServedAC, pTLCb->ucCurLeftWeight, pTLCb->ucCurrentSTA ));
12000
Sravan Kumar Kairam715072e2017-03-10 17:12:43 +053012001 pTLCb->ucCurLeftWeight--;
Jeff Johnson295189b2012-06-20 16:38:30 -070012002 return VOS_STATUS_SUCCESS;
12003 } //STA loop
12004
Sravan Kumar Kairamb0edc612016-10-26 13:55:24 +053012005 for (j = 0; j < ucTempSTA; j++) {
12006 if (NULL == pTLCb->atlSTAClients[j])
12007 continue;
12008
12009 WLAN_TL_AC_ARRAY_2_MASK (pTLCb->atlSTAClients[j], ucACMask, i);
12010
12011 if ((0 == pTLCb->atlSTAClients[j]->ucExists) ||
12012 ((0 == pTLCb->atlSTAClients[j]->ucPktPending) && !(ucACMask)) ||
12013 (0 == (ucACMask & ucACFilter)))
12014 continue;
12015
12016 if ((WLANTL_STA_AUTHENTICATED != pTLCb->atlSTAClients[j]->tlState) ||
12017 (pTLCb->atlSTAClients[j]->disassoc_progress == VOS_TRUE)) {
12018 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
12019 "%s Sta %d not in auth state so skipping it.",
12020 __func__, ucNextSTA));
12021 continue;
12022 }
12023
12024 if ((TRUE == pTLCb->atlSTAClients[j]->ucLwmModeEnabled) &&
12025 ((FALSE == pTLCb->atlSTAClients[j]->ucLwmEventReported) ||
12026 (0 < pTLCb->atlSTAClients[j]->uBuffThresholdMax)))
12027 continue;
12028
12029 if (pTLCb->atlSTAClients[j]->weight > WLANTL_GOOD_STA_WEIGHT) {
12030 if (pTLCb->atlSTAClients[j]->weight_count <=
Sravan Kumar Kairam18017eb2017-01-03 14:58:13 +053012031 pTLCb->atlSTAClients[j]->weight)
12032 {
12033 if (pTLCb->atlSTAClients[minWeightSta]->weight <= 1)
12034 minWeightSta = j;
12035 else if (pTLCb->atlSTAClients[j]->weight <
12036 pTLCb->atlSTAClients[minWeightSta]->weight) {
12037 minWeightSta = j;
12038 }
12039 sta_bitmask |= (1 << j);
Sravan Kumar Kairamb0edc612016-10-26 13:55:24 +053012040 pTLCb->atlSTAClients[j]->weight_count++;
12041 continue;
12042 }
12043 else
12044 pTLCb->atlSTAClients[j]->weight_count = 0;
12045 }
12046
12047 *pucSTAId = j;
12048 pTLCb->ucCurrentSTA = j;
12049 pTLCb->atlSTAClients[*pucSTAId]->ucCurrentAC = pTLCb->uCurServedAC;
12050
12051 TLLOG4(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_LOW,
12052 " TL serve one station AC: %d W: %d StaId: %d",
12053 pTLCb->uCurServedAC, pTLCb->ucCurLeftWeight, pTLCb->ucCurrentSTA ));
Sravan Kumar Kairam715072e2017-03-10 17:12:43 +053012054 pTLCb->ucCurLeftWeight--;
Sravan Kumar Kairamb0edc612016-10-26 13:55:24 +053012055 return VOS_STATUS_SUCCESS;
12056 }
12057
Sravan Kumar Kairam18017eb2017-01-03 14:58:13 +053012058 /* Fecth packet from the stations with minimum weight among them */
12059 if (pTLCb->atlSTAClients[minWeightSta] &&
12060 pTLCb->atlSTAClients[minWeightSta]->ucPktPending)
12061 {
12062 *pucSTAId = minWeightSta;
12063 pTLCb->ucCurrentSTA = minWeightSta;
12064 pTLCb->atlSTAClients[*pucSTAId]->ucCurrentAC = pTLCb->uCurServedAC;
12065
12066 for (j = 0; sta_bitmask != 0; sta_bitmask >>= 1, j++)
12067 {
12068 if (0 == (sta_bitmask & 0x1))
12069 continue;
12070
12071 if (minWeightSta == j)
12072 continue;
12073 /* To ensure fairness between stations */
12074 pTLCb->atlSTAClients[j]->weight_count +=
12075 pTLCb->atlSTAClients[minWeightSta]->weight -
12076 pTLCb->atlSTAClients[minWeightSta]->weight_count;
12077 }
12078 pTLCb->atlSTAClients[minWeightSta]->weight_count = 0;
12079
12080 TLLOG4(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_LOW,
12081 " TL serve one station AC: %d W: %d StaId: %d",
12082 pTLCb->uCurServedAC, pTLCb->ucCurLeftWeight, pTLCb->ucCurrentSTA ));
Sravan Kumar Kairam715072e2017-03-10 17:12:43 +053012083 pTLCb->ucCurLeftWeight--;
Sravan Kumar Kairam18017eb2017-01-03 14:58:13 +053012084 return VOS_STATUS_SUCCESS;
12085 }
12086
Jeff Johnson295189b2012-06-20 16:38:30 -070012087 ucNextSTA = 0;
12088 if ( FALSE == isServed )
12089 {
12090 //current loop finds no packet.no need to repeat for the same priority
12091 break;
12092 }
12093 //current loop is partial loop. go for one more loop.
12094 isServed = FALSE;
12095
12096 } //Weight loop
12097
12098 if (WLANTL_AC_BK == pTLCb->uCurServedAC)
12099 {
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +053012100 pTLCb->uCurServedAC = WLANTL_AC_HIGH_PRIO;
Jeff Johnson295189b2012-06-20 16:38:30 -070012101 }
12102 else
12103 {
12104 pTLCb->uCurServedAC--;
12105 }
12106 pTLCb->ucCurLeftWeight = pTLCb->tlConfigInfo.ucAcWeights[pTLCb->uCurServedAC];
12107
12108 }// AC loop
12109
12110 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
Arif Hussainf2b00992013-11-17 21:46:15 -080012111 " TL can't find one station to serve" ));
Jeff Johnson295189b2012-06-20 16:38:30 -070012112
12113 pTLCb->uCurServedAC = WLANTL_AC_BK;
12114 pTLCb->ucCurLeftWeight = 1;
12115 //invalid number will be captured by caller
12116 pTLCb->ucCurrentSTA = WLAN_MAX_STA_COUNT;
12117
12118 *pucSTAId = pTLCb->ucCurrentSTA;
Jeff Johnson295189b2012-06-20 16:38:30 -070012119 return VOS_STATUS_E_FAULT;
12120}
12121
12122
12123/*==========================================================================
12124 FUNCTION WLAN_TLGetNextTxIds
12125
12126 DESCRIPTION
12127 Gets the next station and next AC in the list
12128
12129 DEPENDENCIES
12130
12131 PARAMETERS
12132
12133 IN
12134 pvosGCtx: pointer to the global vos context; a handle to TL's
12135 control block can be extracted from its context
12136
12137 OUT
12138 pucSTAId: Station ID
12139
12140
12141 RETURN VALUE
12142 The result code associated with performing the operation
12143
12144 VOS_STATUS_SUCCESS: Everything is good :)
12145
12146 SIDE EFFECTS
12147
12148============================================================================*/
12149VOS_STATUS
12150WLAN_TLGetNextTxIds
12151(
12152 v_PVOID_t pvosGCtx,
12153 v_U8_t* pucSTAId
12154)
12155{
12156 WLANTL_CbType* pTLCb;
12157 v_U8_t ucNextAC;
12158 v_U8_t ucNextSTA;
12159 v_U8_t ucCount;
12160 v_U8_t uFlowMask; // TX FlowMask from WDA
12161 v_U8_t ucACMask = 0;
12162 v_U8_t i = 0;
12163
12164 tBssSystemRole systemRole; //RG HACK to be removed
12165 tpAniSirGlobal pMac;
12166
12167 pMac = vos_get_context(VOS_MODULE_ID_PE, pvosGCtx);
12168 if ( NULL == pMac )
12169 {
12170 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070012171 "%s: Invalid pMac", __func__));
Jeff Johnson295189b2012-06-20 16:38:30 -070012172 return VOS_STATUS_E_FAULT;
12173 }
12174
12175 systemRole = wdaGetGlobalSystemRole(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -070012176
Jeff Johnson295189b2012-06-20 16:38:30 -070012177 /*------------------------------------------------------------------------
12178 Extract TL control block
12179 ------------------------------------------------------------------------*/
12180 pTLCb = VOS_GET_TL_CB(pvosGCtx);
12181 if ( NULL == pTLCb )
12182 {
12183 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
12184 "WLAN TL:Invalid TL pointer from pvosGCtx on WLAN_TLGetNextTxIds"));
12185 return VOS_STATUS_E_FAULT;
12186 }
12187
Sunil Ravid5406f22013-01-22 00:18:31 -080012188#ifdef FEATURE_WLAN_TDLS
Agarwal Ashishcd86f7b2014-06-16 17:11:58 +053012189 if ((eSYSTEM_AP_ROLE == systemRole) ||
Katya Nigam1fd24402015-02-16 14:52:19 +053012190 (eSYSTEM_STA_IN_IBSS_ROLE == systemRole) ||
Agarwal Ashishcd86f7b2014-06-16 17:11:58 +053012191 (vos_concurrent_open_sessions_running()) || pTLCb->ucTdlsPeerCount)
Sunil Ravid5406f22013-01-22 00:18:31 -080012192#else
Agarwal Ashishcd86f7b2014-06-16 17:11:58 +053012193 if ((eSYSTEM_AP_ROLE == systemRole) ||
Katya Nigam1fd24402015-02-16 14:52:19 +053012194 (eSYSTEM_STA_IN_IBSS_ROLE == systemRole) ||
Agarwal Ashishcd86f7b2014-06-16 17:11:58 +053012195 (vos_concurrent_open_sessions_running()))
Sunil Ravid5406f22013-01-22 00:18:31 -080012196#endif
12197 {
12198 return WLAN_TLAPGetNextTxIds(pvosGCtx,pucSTAId);
12199 }
12200
12201
Jeff Johnson295189b2012-06-20 16:38:30 -070012202 if ( VOS_STATUS_SUCCESS != WDA_DS_GetTxFlowMask( pvosGCtx, &uFlowMask ) )
12203 {
12204 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
12205 "WLAN TL:Failed to retrieve Flow control mask from WDA"));
12206 return VOS_STATUS_E_FAULT;
12207 }
12208
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +053012209 /* The flow mask does not differentiate between different ACs/Qs
12210 * since we use a single dxe channel for all ACs/Qs, hence it is
12211 * enough to check that there are dxe resources on data channel
12212 */
12213 uFlowMask &= WLANTL_DATA_FLOW_MASK;
12214
12215 if (0 == uFlowMask)
12216 {
12217 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
12218 "WLAN TL: No resources to send packets"));
12219
12220 // Setting STA id to invalid if mask is 0
12221 *pucSTAId = WLAN_MAX_STA_COUNT;
12222 return VOS_STATUS_E_FAULT;
12223 }
12224
Jeff Johnson295189b2012-06-20 16:38:30 -070012225 /*STA id - no priority yet implemented */
12226 /*-----------------------------------------------------------------------
12227 Choose the next STA for tx - for now go in a round robin fashion
12228 through all the stations that have pending packets
12229 -------------------------------------------------------------------------*/
12230 ucNextSTA = pTLCb->ucCurrentSTA;
12231
12232 pTLCb->ucCurrentSTA = WLAN_MAX_STA_COUNT;
12233 for ( ucCount = 0;
12234 ucCount < WLAN_MAX_STA_COUNT;
12235 ucCount++ )
12236 {
12237 ucNextSTA = ( (ucNextSTA+1) >= WLAN_MAX_STA_COUNT )?0:(ucNextSTA+1);
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053012238 if(NULL == pTLCb->atlSTAClients[ucNextSTA])
12239 {
12240 continue;
12241 }
Sravan Kumar Kairamb0edc612016-10-26 13:55:24 +053012242
12243 if ((pTLCb->atlSTAClients[ucNextSTA]->weight > WLANTL_GOOD_STA_WEIGHT) &&
12244 (pTLCb->atlSTAClients[ucNextSTA]->ucPktPending)) {
12245 if (pTLCb->atlSTAClients[ucNextSTA]->weight_count <=
12246 pTLCb->atlSTAClients[ucNextSTA]->weight) {
12247 pTLCb->atlSTAClients[ucNextSTA]->weight_count++;
12248 continue;
12249 }
12250 else
12251 pTLCb->atlSTAClients[ucNextSTA]->weight_count = 0;
12252 }
12253
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053012254 if (( pTLCb->atlSTAClients[ucNextSTA]->ucExists ) &&
12255 ( pTLCb->atlSTAClients[ucNextSTA]->ucPktPending ))
Jeff Johnson295189b2012-06-20 16:38:30 -070012256 {
Tushnim Bhattacharyya39a8f182013-02-20 18:10:30 -080012257 if (WLANTL_STA_AUTHENTICATED == pTLCb->atlSTAClients[ucNextSTA]->tlState)
12258 {
12259 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
12260 "STA ID: %d on WLAN_TLGetNextTxIds", *pucSTAId));
12261 pTLCb->ucCurrentSTA = ucNextSTA;
12262 break;
Tushnim Bhattacharyya5dd94562013-03-20 20:15:03 -070012263 }
12264 else
12265 {
Tushnim Bhattacharyya39a8f182013-02-20 18:10:30 -080012266 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
12267 "%s Sta %d is not in auth state, skipping this sta.",
12268 __func__, ucNextSTA));
Tushnim Bhattacharyya5dd94562013-03-20 20:15:03 -070012269 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012270 }
12271 }
12272
12273 *pucSTAId = pTLCb->ucCurrentSTA;
12274
12275 if ( WLANTL_STA_ID_INVALID( *pucSTAId ) )
12276 {
12277 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
12278 "WLAN TL:No station registered with TL at this point"));
12279
12280 return VOS_STATUS_E_FAULT;
12281
12282 }
12283
12284 /*Convert the array to a mask for easier operation*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053012285 WLAN_TL_AC_ARRAY_2_MASK( pTLCb->atlSTAClients[*pucSTAId], ucACMask, i);
Jeff Johnson295189b2012-06-20 16:38:30 -070012286
12287 if ( 0 == ucACMask )
12288 {
12289 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
12290 "WLAN TL: Mask 0 "
12291 "STA ID: %d on WLAN_TLGetNextTxIds", *pucSTAId));
12292
12293 /*setting STA id to invalid if mask is 0*/
12294 *pucSTAId = WLAN_MAX_STA_COUNT;
12295
12296 return VOS_STATUS_E_FAULT;
12297 }
12298
12299 /*-----------------------------------------------------------------------
12300 AC is updated whenever a packet is fetched from HDD -> the current
12301 weight of such an AC cannot be 0 -> in this case TL is expected to
12302 exit this function at this point during the main Tx loop
12303 -----------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053012304 if ( 0 < pTLCb->atlSTAClients[*pucSTAId]->ucCurrentWeight )
Jeff Johnson295189b2012-06-20 16:38:30 -070012305 {
12306 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
12307 "WLAN TL: Maintaining serviced AC to: %d for Weight: %d",
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053012308 pTLCb->atlSTAClients[*pucSTAId]->ucCurrentAC ,
12309 pTLCb->atlSTAClients[*pucSTAId]->ucCurrentWeight));
Jeff Johnson295189b2012-06-20 16:38:30 -070012310 return VOS_STATUS_SUCCESS;
12311 }
12312
12313 /*-----------------------------------------------------------------------
12314 Choose highest priority AC - !!! optimize me
12315 -----------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053012316 ucNextAC = pTLCb->atlSTAClients[*pucSTAId]->ucCurrentAC;
Jeff Johnson295189b2012-06-20 16:38:30 -070012317 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
12318 "Next AC: %d", ucNextAC));
12319
12320 while ( 0 != ucACMask )
12321 {
12322 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
12323 " AC Mask: %d Next: %d Res : %d",
12324 ucACMask, ( 1 << ucNextAC ), ( ucACMask & ( 1 << ucNextAC ))));
12325
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +053012326 if ( 0 != ( ucACMask & ( 1 << ucNextAC )))
Jeff Johnson295189b2012-06-20 16:38:30 -070012327 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053012328 pTLCb->atlSTAClients[*pucSTAId]->ucCurrentAC =
Jeff Johnson295189b2012-06-20 16:38:30 -070012329 (WLANTL_ACEnumType)ucNextAC;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053012330 pTLCb->atlSTAClients[*pucSTAId]->ucCurrentWeight =
Jeff Johnson295189b2012-06-20 16:38:30 -070012331 pTLCb->tlConfigInfo.ucAcWeights[ucNextAC];
12332
12333 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
12334 "WLAN TL: Switching serviced AC to: %d with Weight: %d",
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053012335 pTLCb->atlSTAClients[*pucSTAId]->ucCurrentAC ,
12336 pTLCb->atlSTAClients[*pucSTAId]->ucCurrentWeight));
Jeff Johnson295189b2012-06-20 16:38:30 -070012337 break;
12338 }
12339
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +053012340 if (ucNextAC == WLANTL_AC_BK)
12341 ucNextAC = WLANTL_AC_HIGH_PRIO;
12342 else
12343 ucNextAC--;
Jeff Johnson295189b2012-06-20 16:38:30 -070012344
12345 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
12346 "Next AC %d", ucNextAC));
Jeff Johnson295189b2012-06-20 16:38:30 -070012347 }
12348
12349 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
12350 " C AC: %d C W: %d",
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053012351 pTLCb->atlSTAClients[*pucSTAId]->ucCurrentAC,
12352 pTLCb->atlSTAClients[*pucSTAId]->ucCurrentWeight));
Jeff Johnson295189b2012-06-20 16:38:30 -070012353
12354 return VOS_STATUS_SUCCESS;
12355}/* WLAN_TLGetNextTxIds */
12356
Jeff Johnson295189b2012-06-20 16:38:30 -070012357
12358
12359/*==========================================================================
12360 DEFAULT HANDLERS: Registered at initialization with TL
12361 ==========================================================================*/
12362
12363/*==========================================================================
12364
12365 FUNCTION WLANTL_MgmtFrmRxDefaultCb
12366
12367 DESCRIPTION
12368 Default Mgmt Frm rx callback: asserts all the time. If this function gets
12369 called it means there is no registered rx cb pointer for Mgmt Frm.
12370
12371 DEPENDENCIES
12372
12373 PARAMETERS
12374 Not used.
12375
12376 RETURN VALUE
12377
12378 VOS_STATUS_E_FAILURE: Always FAILURE.
12379
12380============================================================================*/
12381VOS_STATUS
12382WLANTL_MgmtFrmRxDefaultCb
12383(
12384 v_PVOID_t pvosGCtx,
12385 v_PVOID_t vosBuff
12386)
12387{
12388 if ( NULL != vosBuff )
12389 {
12390 TLLOGP(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_FATAL,
12391 "WLAN TL:Fatal failure: No registered Mgmt Frm client on pkt RX"));
12392 /* Drop packet */
12393 vos_pkt_return_packet((vos_pkt_t *)vosBuff);
12394 }
12395
Jeff Johnson295189b2012-06-20 16:38:30 -070012396 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
12397 "WLAN TL: No registered Mgmt Frm client on pkt RX. Load/Unload in progress, Ignore"));
Jeff Johnson295189b2012-06-20 16:38:30 -070012398
12399 return VOS_STATUS_E_FAILURE;
12400}/*WLANTL_MgmtFrmRxDefaultCb*/
12401
12402/*==========================================================================
12403
Madan Mohan Koyyalamudi6c2977d2013-09-04 15:42:45 +053012404 FUNCTION WLANTL_BAPRxDefaultCb
Jeff Johnson295189b2012-06-20 16:38:30 -070012405
12406 DESCRIPTION
12407 Default BAP rx callback: asserts all the time. If this function gets
12408 called it means there is no registered rx cb pointer for BAP.
12409
12410 DEPENDENCIES
12411
12412 PARAMETERS
12413 Not used.
12414
12415 RETURN VALUE
12416
12417 VOS_STATUS_E_FAILURE: Always FAILURE.
12418
12419============================================================================*/
12420VOS_STATUS
12421WLANTL_BAPRxDefaultCb
12422(
12423 v_PVOID_t pvosGCtx,
12424 vos_pkt_t* vosDataBuff,
12425 WLANTL_BAPFrameEnumType frameType
12426)
12427{
12428 TLLOGP(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_FATAL,
12429 "WLAN TL:Fatal failure: No registered BAP client on BAP pkt RX"));
12430#ifndef BTAMP_TEST
12431 VOS_ASSERT(0);
12432#endif
12433 return VOS_STATUS_E_FAILURE;
12434}/*WLANTL_MgmtFrmRxDefaultCb*/
12435
12436/*==========================================================================
12437
12438 FUNCTION WLANTL_STARxDefaultCb
12439
12440 DESCRIPTION
12441 Default STA rx callback: asserts all the time. If this function gets
12442 called it means there is no registered rx cb pointer for station.
12443 (Mem corruption most likely, it should never happen)
12444
12445 DEPENDENCIES
12446
12447 PARAMETERS
12448 Not used.
12449
12450 RETURN VALUE
12451
12452 VOS_STATUS_E_FAILURE: Always FAILURE.
12453
12454============================================================================*/
12455VOS_STATUS
12456WLANTL_STARxDefaultCb
12457(
12458 v_PVOID_t pvosGCtx,
12459 vos_pkt_t* vosDataBuff,
12460 v_U8_t ucSTAId,
12461 WLANTL_RxMetaInfoType* pRxMetaInfo
12462)
12463{
12464 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
12465 "WLAN TL: No registered STA client rx cb for STAID: %d dropping pkt",
12466 ucSTAId));
12467 vos_pkt_return_packet(vosDataBuff);
Madan Mohan Koyyalamudi6c2977d2013-09-04 15:42:45 +053012468 return VOS_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012469}/*WLANTL_MgmtFrmRxDefaultCb*/
12470
12471
12472/*==========================================================================
12473
12474 FUNCTION WLANTL_STAFetchPktDefaultCb
12475
12476 DESCRIPTION
12477 Default fetch callback: asserts all the time. If this function gets
12478 called it means there is no registered fetch cb pointer for station.
12479 (Mem corruption most likely, it should never happen)
12480
12481 DEPENDENCIES
12482
12483 PARAMETERS
12484 Not used.
12485
12486 RETURN VALUE
12487
12488 VOS_STATUS_E_FAILURE: Always FAILURE.
12489
12490============================================================================*/
12491VOS_STATUS
12492WLANTL_STAFetchPktDefaultCb
12493(
12494 v_PVOID_t pvosGCtx,
12495 v_U8_t* pucSTAId,
12496 WLANTL_ACEnumType ucAC,
12497 vos_pkt_t** vosDataBuff,
12498 WLANTL_MetaInfoType* tlMetaInfo
12499)
12500{
12501 TLLOGP(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_FATAL,
12502 "WLAN TL:Fatal failure: No registered STA client on data pkt RX"));
12503 VOS_ASSERT(0);
12504 return VOS_STATUS_E_FAILURE;
12505}/*WLANTL_MgmtFrmRxDefaultCb*/
12506
12507/*==========================================================================
12508
12509 FUNCTION WLANTL_TxCompDefaultCb
12510
12511 DESCRIPTION
12512 Default tx complete handler. It will release the completed pkt to
12513 prevent memory leaks.
12514
12515 PARAMETERS
12516
12517 IN
12518 pvosGCtx: pointer to the global vos context; a handle to
12519 TL/HAL/PE/BAP/HDD control block can be extracted from
12520 its context
12521 vosDataBuff: pointer to the VOSS data buffer that was transmitted
12522 wTxSTAtus: status of the transmission
12523
12524
12525 RETURN VALUE
12526 The result code associated with performing the operation; please
12527 check vos_pkt_return_packet for possible error codes.
12528
12529 Please check vos_pkt_return_packet API for possible return values.
12530
12531============================================================================*/
12532VOS_STATUS
12533WLANTL_TxCompDefaultCb
12534(
12535 v_PVOID_t pvosGCtx,
12536 vos_pkt_t* vosDataBuff,
12537 VOS_STATUS wTxSTAtus
12538)
12539{
12540 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
12541 "WLAN TL:TXComp not registered, releasing pkt to prevent mem leak"));
12542 return vos_pkt_return_packet(vosDataBuff);
12543}/*WLANTL_TxCompDefaultCb*/
12544
12545
12546/*==========================================================================
12547 Cleanup functions
12548 ==========================================================================*/
12549
12550/*==========================================================================
12551
12552 FUNCTION WLANTL_CleanCB
12553
12554 DESCRIPTION
12555 Cleans TL control block
12556
12557 DEPENDENCIES
12558
12559 PARAMETERS
12560
12561 IN
12562 pTLCb: pointer to TL's control block
12563 ucEmpty: set if TL has to clean up the queues and release pedning pkts
12564
12565 RETURN VALUE
12566 The result code associated with performing the operation
12567
12568 VOS_STATUS_E_INVAL: invalid input parameters
12569 VOS_STATUS_SUCCESS: Everything is good :)
12570
12571 SIDE EFFECTS
12572
12573============================================================================*/
12574VOS_STATUS
12575WLANTL_CleanCB
12576(
12577 WLANTL_CbType* pTLCb,
12578 v_U8_t ucEmpty
12579)
12580{
12581 v_U8_t ucIndex;
12582 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
12583
12584 /*-------------------------------------------------------------------------
12585 Sanity check
12586 -------------------------------------------------------------------------*/
12587 if ( NULL == pTLCb )
12588 {
12589 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
12590 "WLAN TL:Invalid parameter sent on WLANTL_CleanCB"));
12591 return VOS_STATUS_E_INVAL;
12592 }
12593
12594 /* number of packets sent to BAL waiting for tx complete confirmation */
12595 pTLCb->usPendingTxCompleteCount = 0;
12596
12597 /* global suspend flag */
12598 vos_atomic_set_U8( &pTLCb->ucTxSuspended, 1);
12599
12600 /* resource flag */
12601 pTLCb->uResCount = 0;
12602
12603
12604 /*-------------------------------------------------------------------------
12605 Client stations
12606 -------------------------------------------------------------------------*/
12607 for ( ucIndex = 0; ucIndex < WLAN_MAX_STA_COUNT ; ucIndex++)
12608 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053012609 if(NULL != pTLCb->atlSTAClients[ucIndex])
12610 {
12611 WLANTL_CleanSTA( pTLCb->atlSTAClients[ucIndex], ucEmpty);
12612 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012613 }
12614
12615 /*-------------------------------------------------------------------------
12616 Management Frame client
12617 -------------------------------------------------------------------------*/
12618 pTLCb->tlMgmtFrmClient.ucExists = 0;
12619
12620 if ( ( 0 != ucEmpty) &&
12621 ( NULL != pTLCb->tlMgmtFrmClient.vosPendingDataBuff ))
12622 {
12623 vos_pkt_return_packet(pTLCb->tlMgmtFrmClient.vosPendingDataBuff);
12624 }
12625
12626 pTLCb->tlMgmtFrmClient.vosPendingDataBuff = NULL;
12627
12628 /* set to a default cb in order to prevent constant checking for NULL */
12629 pTLCb->tlMgmtFrmClient.pfnTlMgmtFrmRx = WLANTL_MgmtFrmRxDefaultCb;
12630
12631 /*-------------------------------------------------------------------------
12632 BT AMP client
12633 -------------------------------------------------------------------------*/
12634 pTLCb->tlBAPClient.ucExists = 0;
12635
12636 if (( 0 != ucEmpty) &&
12637 ( NULL != pTLCb->tlBAPClient.vosPendingDataBuff ))
12638 {
12639 vos_pkt_return_packet(pTLCb->tlBAPClient.vosPendingDataBuff);
12640 }
12641
12642 if (( 0 != ucEmpty) &&
12643 ( NULL != pTLCb->vosDummyBuf ))
12644 {
12645 vos_pkt_return_packet(pTLCb->vosDummyBuf);
12646 }
12647
12648 pTLCb->tlBAPClient.vosPendingDataBuff = NULL;
12649
12650 pTLCb->vosDummyBuf = NULL;
12651 pTLCb->vosTempBuf = NULL;
12652 pTLCb->ucCachedSTAId = WLAN_MAX_STA_COUNT;
12653
12654 /* set to a default cb in order to prevent constant checking for NULL */
12655 pTLCb->tlBAPClient.pfnTlBAPRx = WLANTL_BAPRxDefaultCb;
12656
12657 pTLCb->ucRegisteredStaId = WLAN_MAX_STA_COUNT;
12658
12659 return VOS_STATUS_SUCCESS;
12660
12661}/* WLANTL_CleanCB*/
12662
12663/*==========================================================================
12664
12665 FUNCTION WLANTL_CleanSTA
12666
12667 DESCRIPTION
12668 Cleans a station control block.
12669
12670 DEPENDENCIES
12671
12672 PARAMETERS
12673
12674 IN
12675 pvosGCtx: pointer to the global vos context; a handle to TL's
12676 control block can be extracted from its context
12677 ucEmpty: if set the queues and pending pkts will be emptyed
12678
12679 RETURN VALUE
12680 The result code associated with performing the operation
12681
12682 VOS_STATUS_E_INVAL: invalid input parameters
12683 VOS_STATUS_SUCCESS: Everything is good :)
12684
12685 SIDE EFFECTS
12686
12687============================================================================*/
12688VOS_STATUS
12689WLANTL_CleanSTA
12690(
12691 WLANTL_STAClientType* ptlSTAClient,
12692 v_U8_t ucEmpty
12693)
12694{
12695 v_U8_t ucIndex;
12696 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
12697
12698 /*-------------------------------------------------------------------------
12699 Sanity check
12700 -------------------------------------------------------------------------*/
12701 if ( NULL == ptlSTAClient )
12702 {
12703 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
12704 "WLAN TL:Invalid parameter sent on WLANTL_CleanSTA"));
12705 return VOS_STATUS_E_INVAL;
12706 }
12707
12708 /*------------------------------------------------------------------------
12709 Clear station from TL
12710 ------------------------------------------------------------------------*/
12711 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
12712 "WLAN TL: Clearing STA Client ID: %d, Empty flag: %d",
12713 ptlSTAClient->wSTADesc.ucSTAId, ucEmpty ));
12714
12715 ptlSTAClient->pfnSTARx = WLANTL_STARxDefaultCb;
12716 ptlSTAClient->pfnSTATxComp = WLANTL_TxCompDefaultCb;
12717 ptlSTAClient->pfnSTAFetchPkt = WLANTL_STAFetchPktDefaultCb;
12718
12719 ptlSTAClient->tlState = WLANTL_STA_INIT;
12720 ptlSTAClient->tlPri = WLANTL_STA_PRI_NORMAL;
12721
12722 vos_zero_macaddr( &ptlSTAClient->wSTADesc.vSTAMACAddress );
12723 vos_zero_macaddr( &ptlSTAClient->wSTADesc.vBSSIDforIBSS );
12724 vos_zero_macaddr( &ptlSTAClient->wSTADesc.vSelfMACAddress );
12725
12726 ptlSTAClient->wSTADesc.ucSTAId = 0;
12727 ptlSTAClient->wSTADesc.wSTAType = WLAN_STA_MAX;
12728
12729 ptlSTAClient->wSTADesc.ucQosEnabled = 0;
12730 ptlSTAClient->wSTADesc.ucAddRmvLLC = 0;
12731 ptlSTAClient->wSTADesc.ucSwFrameTXXlation = 0;
12732 ptlSTAClient->wSTADesc.ucSwFrameRXXlation = 0;
12733 ptlSTAClient->wSTADesc.ucProtectedFrame = 0;
Bhargav Shahfbaeca22016-07-13 10:27:35 +053012734 ptlSTAClient->disassoc_progress = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070012735 /*-------------------------------------------------------------------------
12736 AMSDU information for the STA
12737 -------------------------------------------------------------------------*/
12738 if ( ( 0 != ucEmpty ) &&
12739 ( NULL != ptlSTAClient->vosAMSDUChainRoot ))
12740 {
Madan Mohan Koyyalamudic0e5bd82012-09-18 17:12:27 -070012741 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_FATAL,
Jeff Johnson0298bd02013-11-14 19:58:38 -080012742 "WLAN TL:Non NULL vosAMSDUChainRoot on WLANTL_CleanSTA, "
Madan Mohan Koyyalamudic0e5bd82012-09-18 17:12:27 -070012743 "suspecting a memory corruption"));
12744
Jeff Johnson295189b2012-06-20 16:38:30 -070012745 }
12746
12747 ptlSTAClient->vosAMSDUChain = NULL;
12748 ptlSTAClient->vosAMSDUChainRoot = NULL;
12749
12750 vos_mem_zero( (v_PVOID_t)ptlSTAClient->aucMPDUHeader,
12751 WLANTL_MPDU_HEADER_LEN);
12752 ptlSTAClient->ucMPDUHeaderLen = 0;
12753
12754 /*-------------------------------------------------------------------------
12755 Reordering information for the STA
12756 -------------------------------------------------------------------------*/
12757 for ( ucIndex = 0; ucIndex < WLAN_MAX_TID ; ucIndex++)
12758 {
12759 if(0 == ptlSTAClient->atlBAReorderInfo[ucIndex].ucExists)
12760 {
12761 continue;
12762 }
12763 if(NULL != ptlSTAClient->atlBAReorderInfo[ucIndex].reorderBuffer)
12764 {
12765 ptlSTAClient->atlBAReorderInfo[ucIndex].reorderBuffer->isAvailable = VOS_TRUE;
12766 memset(&ptlSTAClient->atlBAReorderInfo[ucIndex].reorderBuffer->arrayBuffer[0], 0, WLANTL_MAX_WINSIZE * sizeof(v_PVOID_t));
12767 }
12768 vos_timer_destroy(&ptlSTAClient->atlBAReorderInfo[ucIndex].agingTimer);
12769 memset(&ptlSTAClient->atlBAReorderInfo[ucIndex], 0, sizeof(WLANTL_BAReorderType));
12770 }
12771
12772 /*-------------------------------------------------------------------------
12773 QOS information for the STA
12774 -------------------------------------------------------------------------*/
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +053012775 ptlSTAClient->ucCurrentAC = WLANTL_AC_HIGH_PRIO;
Jeff Johnson295189b2012-06-20 16:38:30 -070012776 ptlSTAClient->ucCurrentWeight = 0;
12777 ptlSTAClient->ucServicedAC = WLANTL_AC_BK;
12778
12779 vos_mem_zero( ptlSTAClient->aucACMask, sizeof(ptlSTAClient->aucACMask));
12780 vos_mem_zero( &ptlSTAClient->wUAPSDInfo, sizeof(ptlSTAClient->wUAPSDInfo));
12781
12782
12783 /*--------------------------------------------------------------------
12784 Stats info
12785 --------------------------------------------------------------------*/
12786 vos_mem_zero( ptlSTAClient->auRxCount,
12787 sizeof(ptlSTAClient->auRxCount[0])* WLAN_MAX_TID);
12788 vos_mem_zero( ptlSTAClient->auTxCount,
12789 sizeof(ptlSTAClient->auTxCount[0])* WLAN_MAX_TID);
12790 ptlSTAClient->rssiAvg = 0;
12791
12792 /*Tx not suspended and station fully registered*/
12793 vos_atomic_set_U8( &ptlSTAClient->ucTxSuspended, 0);
12794 vos_atomic_set_U8( &ptlSTAClient->ucNoMoreData, 1);
12795
12796 if ( 0 == ucEmpty )
12797 {
12798 ptlSTAClient->wSTADesc.ucUcastSig = WLAN_TL_INVALID_U_SIG;
12799 ptlSTAClient->wSTADesc.ucBcastSig = WLAN_TL_INVALID_B_SIG;
12800 }
12801
12802 ptlSTAClient->ucExists = 0;
12803
12804 /*--------------------------------------------------------------------
12805 Statistics info
12806 --------------------------------------------------------------------*/
12807 memset(&ptlSTAClient->trafficStatistics,
12808 0,
12809 sizeof(WLANTL_TRANSFER_STA_TYPE));
12810
12811 /*fix me!!: add new values from the TL Cb for cleanup */
12812 return VOS_STATUS_SUCCESS;
12813}/* WLANTL_CleanSTA */
12814
12815
12816/*==========================================================================
12817 FUNCTION WLANTL_EnableUAPSDForAC
12818
12819 DESCRIPTION
12820 Called by HDD to enable UAPSD. TL in turn calls WDA API to enable the
12821 logic in FW/SLM to start sending trigger frames. Previously TL had the
12822 trigger frame logic which later moved down to FW. Hence
12823 HDD -> TL -> WDA -> FW call flow.
12824
12825 DEPENDENCIES
12826 The TL must be initialized before this function can be called.
12827
12828 PARAMETERS
12829
12830 IN
12831 pvosGCtx: pointer to the global vos context; a handle to TL's
12832 control block can be extracted from its context
12833 ucSTAId: station Id
12834 ucAC: AC for which U-APSD is being enabled
12835 ucTid: TID for which U-APSD is setup
12836 ucUP: used to place in the trigger frame generation
12837 ucServiceInt: service interval used by TL to send trigger frames
12838 ucSuspendInt: suspend interval used by TL to determine that an
12839 app is idle and should start sending trigg frms less often
12840 wTSDir: direction of TSpec
12841
12842 RETURN VALUE
12843 The result code associated with performing the operation
12844
12845 VOS_STATUS_SUCCESS: Everything is good :)
12846
12847 SIDE EFFECTS
12848
12849============================================================================*/
12850VOS_STATUS
12851WLANTL_EnableUAPSDForAC
12852(
12853 v_PVOID_t pvosGCtx,
12854 v_U8_t ucSTAId,
12855 WLANTL_ACEnumType ucAC,
12856 v_U8_t ucTid,
12857 v_U8_t ucUP,
12858 v_U32_t uServiceInt,
12859 v_U32_t uSuspendInt,
12860 WLANTL_TSDirType wTSDir
12861)
12862{
12863
12864 WLANTL_CbType* pTLCb = NULL;
12865 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
12866 tUapsdInfo halUAPSDInfo;
12867 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
12868
12869 /*------------------------------------------------------------------------
12870 Sanity check
12871 Extract TL control block
12872 ------------------------------------------------------------------------*/
12873 pTLCb = VOS_GET_TL_CB(pvosGCtx);
12874 if (( NULL == pTLCb ) || WLANTL_STA_ID_INVALID( ucSTAId )
Gopichand Nakkala574f6d12013-06-27 19:38:43 +053012875 || WLANTL_AC_INVALID(ucAC))
Jeff Johnson295189b2012-06-20 16:38:30 -070012876 {
12877 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
12878 "WLAN TL:Invalid input params on WLANTL_EnableUAPSDForAC"
Jeff Johnsonddec6482017-09-19 08:33:57 -070012879 " TL: %pK STA: %d AC: %d",
Gopichand Nakkala574f6d12013-06-27 19:38:43 +053012880 pTLCb, ucSTAId, ucAC));
Jeff Johnson295189b2012-06-20 16:38:30 -070012881 return VOS_STATUS_E_FAULT;
12882 }
12883
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053012884 if ( NULL == pTLCb->atlSTAClients[ucSTAId] )
12885 {
12886 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
12887 "WLAN TL:Client Memory was not allocated on %s", __func__));
12888 return VOS_STATUS_E_FAILURE;
12889 }
12890
Jeff Johnson295189b2012-06-20 16:38:30 -070012891 /*Set this flag in order to remember that this is a trigger enabled AC*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053012892 pTLCb->atlSTAClients[ucSTAId]->wUAPSDInfo[ucAC].ucSet = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -070012893
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053012894#ifdef FEATURE_WLAN_TDLS
12895 if(pTLCb->atlSTAClients[ucSTAId]->wSTADesc.wSTAType != WLAN_STA_TDLS)
12896#endif
12897 {
12898 if( 0 == uServiceInt )
12899 {
12900 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi198ade32013-09-29 03:52:25 +053012901 "WLAN TL:Input params on WLANTL_EnableUAPSDForAC"
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053012902 " SI: %d", uServiceInt ));
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053012903 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012904
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053012905 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
12906 "WLAN TL:Enabling U-APSD in FW for STA: %d AC: %d SI: %d SPI: %d "
12907 "DI: %d",
12908 ucSTAId, ucAC, uServiceInt, uSuspendInt,
12909 pTLCb->tlConfigInfo.uDelayedTriggerFrmInt));
Jeff Johnson295189b2012-06-20 16:38:30 -070012910
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053012911 /*Save all info for HAL*/
12912 halUAPSDInfo.staidx = ucSTAId;
12913 halUAPSDInfo.ac = ucAC;
12914 halUAPSDInfo.up = ucUP;
12915 halUAPSDInfo.srvInterval = uServiceInt;
12916 halUAPSDInfo.susInterval = uSuspendInt;
12917 halUAPSDInfo.delayInterval = pTLCb->tlConfigInfo.uDelayedTriggerFrmInt;
12918
12919 /*Notify HAL*/
12920 vosStatus = WDA_EnableUapsdAcParams(pvosGCtx, ucSTAId, &halUAPSDInfo);
12921 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012922 return vosStatus;
12923
12924}/*WLANTL_EnableUAPSDForAC*/
12925
12926
12927/*==========================================================================
12928 FUNCTION WLANTL_DisableUAPSDForAC
12929
12930 DESCRIPTION
12931 Called by HDD to disable UAPSD. TL in turn calls WDA API to disable the
12932 logic in FW/SLM to stop sending trigger frames. Previously TL had the
12933 trigger frame logic which later moved down to FW. Hence
12934 HDD -> TL -> WDA -> FW call flow.
12935
12936 DEPENDENCIES
12937 The TL must be initialized before this function can be called.
12938
12939 PARAMETERS
12940
12941 IN
12942 pvosGCtx: pointer to the global vos context; a handle to TL's
12943 control block can be extracted from its context
12944 ucSTAId: station Id
12945 ucAC: AC for which U-APSD is being enabled
12946
12947
12948 RETURN VALUE
12949 The result code associated with performing the operation
12950
12951 VOS_STATUS_SUCCESS: Everything is good :)
12952
12953 SIDE EFFECTS
12954
12955============================================================================*/
12956VOS_STATUS
12957WLANTL_DisableUAPSDForAC
12958(
12959 v_PVOID_t pvosGCtx,
12960 v_U8_t ucSTAId,
12961 WLANTL_ACEnumType ucAC
12962)
12963{
12964 WLANTL_CbType* pTLCb;
12965 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
12966
12967 /*------------------------------------------------------------------------
12968 Sanity check
12969 Extract TL control block
12970 ------------------------------------------------------------------------*/
12971 pTLCb = VOS_GET_TL_CB(pvosGCtx);
12972 if (( NULL == pTLCb ) || WLANTL_STA_ID_INVALID( ucSTAId )
12973 || WLANTL_AC_INVALID(ucAC) )
12974 {
12975 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
12976 "WLAN TL:Invalid input params on WLANTL_DisableUAPSDForAC"
Jeff Johnsonddec6482017-09-19 08:33:57 -070012977 " TL: %pK STA: %d AC: %d", pTLCb, ucSTAId, ucAC ));
Jeff Johnson295189b2012-06-20 16:38:30 -070012978 return VOS_STATUS_E_FAULT;
12979 }
12980
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053012981 if ( NULL == pTLCb->atlSTAClients[ucSTAId] )
12982 {
12983 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
12984 "WLAN TL:Client Memory was not allocated on %s", __func__));
12985 return VOS_STATUS_E_FAILURE;
12986 }
12987
Jeff Johnson295189b2012-06-20 16:38:30 -070012988 /*Reset this flag as this is no longer a trigger enabled AC*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053012989 pTLCb->atlSTAClients[ucSTAId]->wUAPSDInfo[ucAC].ucSet = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -070012990
12991 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
12992 "WLAN TL:Disabling U-APSD in FW for STA: %d AC: %d ",
12993 ucSTAId, ucAC));
12994
12995 /*Notify HAL*/
12996 WDA_DisableUapsdAcParams(pvosGCtx, ucSTAId, ucAC);
12997
12998 return VOS_STATUS_SUCCESS;
12999}/* WLANTL_DisableUAPSDForAC */
13000
13001#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
13002/*==========================================================================
13003 FUNCTION WLANTL_RegRSSIIndicationCB
13004
13005 DESCRIPTION Registration function to get notification if RSSI cross
13006 threshold.
13007 Client should register threshold, direction, and notification
13008 callback function pointer
13009
13010 DEPENDENCIES NONE
13011
13012 PARAMETERS in pAdapter - Global handle
13013 in rssiValue - RSSI threshold value
13014 in triggerEvent - Cross direction should be notified
13015 UP, DOWN, and CROSS
13016 in crossCBFunction - Notification CB Function
13017 in usrCtxt - user context
13018
13019 RETURN VALUE VOS_STATUS
13020
13021 SIDE EFFECTS NONE
13022
13023============================================================================*/
13024VOS_STATUS WLANTL_RegRSSIIndicationCB
13025(
13026 v_PVOID_t pAdapter,
13027 v_S7_t rssiValue,
13028 v_U8_t triggerEvent,
13029 WLANTL_RSSICrossThresholdCBType crossCBFunction,
13030 VOS_MODULE_ID moduleID,
13031 v_PVOID_t usrCtxt
13032)
13033{
13034 VOS_STATUS status = VOS_STATUS_SUCCESS;
13035
13036 status = WLANTL_HSRegRSSIIndicationCB(pAdapter,
13037 rssiValue,
13038 triggerEvent,
13039 crossCBFunction,
13040 moduleID,
13041 usrCtxt);
13042
13043 return status;
13044}
13045
13046/*==========================================================================
13047 FUNCTION WLANTL_DeregRSSIIndicationCB
13048
13049 DESCRIPTION Remove specific threshold from list
13050
13051 DEPENDENCIES NONE
13052
13053 PARAMETERS in pAdapter - Global handle
13054 in rssiValue - RSSI threshold value
13055 in triggerEvent - Cross direction should be notified
13056 UP, DOWN, and CROSS
13057
13058 RETURN VALUE VOS_STATUS
13059
13060 SIDE EFFECTS NONE
13061
13062============================================================================*/
13063VOS_STATUS WLANTL_DeregRSSIIndicationCB
13064(
13065 v_PVOID_t pAdapter,
13066 v_S7_t rssiValue,
13067 v_U8_t triggerEvent,
13068 WLANTL_RSSICrossThresholdCBType crossCBFunction,
13069 VOS_MODULE_ID moduleID
13070)
13071{
13072 VOS_STATUS status = VOS_STATUS_SUCCESS;
13073
13074 status = WLANTL_HSDeregRSSIIndicationCB(pAdapter,
13075 rssiValue,
13076 triggerEvent,
13077 crossCBFunction,
13078 moduleID);
13079 return status;
13080}
13081
13082/*==========================================================================
13083 FUNCTION WLANTL_SetAlpha
13084
13085 DESCRIPTION ALPLA is weight value to calculate AVG RSSI
13086 avgRSSI = (ALPHA * historyRSSI) + ((10 - ALPHA) * newRSSI)
13087 avgRSSI has (ALPHA * 10)% of history RSSI weight and
13088 (10 - ALPHA)% of newRSSI weight
13089 This portion is dynamically configurable.
13090 Default is ?
13091
13092 DEPENDENCIES NONE
13093
13094 PARAMETERS in pAdapter - Global handle
13095 in valueAlpah - ALPHA
13096
13097 RETURN VALUE VOS_STATUS
13098
13099 SIDE EFFECTS NONE
13100
13101============================================================================*/
13102VOS_STATUS WLANTL_SetAlpha
13103(
13104 v_PVOID_t pAdapter,
13105 v_U8_t valueAlpha
13106)
13107{
13108 VOS_STATUS status = VOS_STATUS_SUCCESS;
13109
13110 status = WLANTL_HSSetAlpha(pAdapter, valueAlpha);
13111 return status;
13112}
13113
13114/*==========================================================================
13115
13116 FUNCTION
13117
13118 DESCRIPTION
13119
13120 PARAMETERS
13121
13122 RETURN VALUE
13123
13124============================================================================*/
13125VOS_STATUS WLANTL_BMPSRSSIRegionChangedNotification
13126(
13127 v_PVOID_t pAdapter,
13128 tpSirRSSINotification pRSSINotification
13129)
13130{
13131 VOS_STATUS status = VOS_STATUS_SUCCESS;
13132
13133 status = WLANTL_HSBMPSRSSIRegionChangedNotification(pAdapter, pRSSINotification);
13134 return status;
13135}
13136
13137/*==========================================================================
13138 FUNCTION WLANTL_RegGetTrafficStatus
13139
13140 DESCRIPTION Registration function for traffic status monitoring
13141 During measure period count data frames.
13142 If frame count is larger then IDLE threshold set as traffic ON
13143 or OFF.
13144 And traffic status is changed send report to client with
13145 registered callback function
13146
13147 DEPENDENCIES NONE
13148
13149 PARAMETERS in pAdapter - Global handle
13150 in idleThreshold - Traffic on or off threshold
13151 in measurePeriod - Traffic state check period
13152 in trfficStatusCB - traffic status changed notification
13153 CB function
13154 in usrCtxt - user context
13155
13156 RETURN VALUE VOS_STATUS
13157
13158 SIDE EFFECTS NONE
13159
13160============================================================================*/
13161VOS_STATUS WLANTL_RegGetTrafficStatus
13162(
13163 v_PVOID_t pAdapter,
13164 v_U32_t idleThreshold,
13165 v_U32_t measurePeriod,
13166 WLANTL_TrafficStatusChangedCBType trfficStatusCB,
13167 v_PVOID_t usrCtxt
13168)
13169{
13170 VOS_STATUS status = VOS_STATUS_SUCCESS;
13171
13172 status = WLANTL_HSRegGetTrafficStatus(pAdapter,
13173 idleThreshold,
13174 measurePeriod,
13175 trfficStatusCB,
13176 usrCtxt);
13177 return status;
13178}
13179#endif
13180/*==========================================================================
13181 FUNCTION WLANTL_GetStatistics
13182
13183 DESCRIPTION Get traffic statistics for identified station
13184
13185 DEPENDENCIES NONE
13186
13187 PARAMETERS in pAdapter - Global handle
13188 in statType - specific statistics field to reset
13189 out statBuffer - traffic statistics buffer
13190
13191 RETURN VALUE VOS_STATUS
13192
13193 SIDE EFFECTS NONE
13194
13195============================================================================*/
13196VOS_STATUS WLANTL_GetStatistics
13197(
13198 v_PVOID_t pAdapter,
13199 WLANTL_TRANSFER_STA_TYPE *statBuffer,
13200 v_U8_t STAid
13201)
13202{
13203 WLANTL_CbType *pTLCb = VOS_GET_TL_CB(pAdapter);
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053013204 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070013205 VOS_STATUS status = VOS_STATUS_SUCCESS;
13206 WLANTL_TRANSFER_STA_TYPE *statistics = NULL;
13207
13208 /*------------------------------------------------------------------------
13209 Sanity check
13210 Extract TL control block
13211 ------------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053013212 if ( NULL == pTLCb )
Jeff Johnson295189b2012-06-20 16:38:30 -070013213 {
13214 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
13215 "WLAN TL:Invalid TL pointer on WLANTL_GetStatistics"));
13216 return VOS_STATUS_E_FAULT;
13217 }
13218
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053013219 pClientSTA = pTLCb->atlSTAClients[STAid];
13220
13221 if ( NULL == pClientSTA )
13222 {
13223 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
13224 "WLAN TL:Client Memory was not allocated on %s", __func__));
13225 return VOS_STATUS_E_FAILURE;
13226 }
13227
13228 if(0 == pClientSTA->ucExists)
Jeff Johnson295189b2012-06-20 16:38:30 -070013229 {
13230 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
13231 "WLAN TL: %d STA ID does not exist", STAid));
13232 return VOS_STATUS_E_INVAL;
13233 }
13234
13235 if(NULL == statBuffer)
13236 {
13237 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
13238 "WLAN TL:Invalid TL statistics buffer pointer on WLANTL_GetStatistics"));
13239 return VOS_STATUS_E_INVAL;
13240 }
13241
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053013242 statistics = &pClientSTA->trafficStatistics;
Katya Nigam493ff652014-02-11 14:31:04 +053013243 vos_mem_copy(statBuffer, statistics, sizeof(WLANTL_TRANSFER_STA_TYPE));
Jeff Johnson295189b2012-06-20 16:38:30 -070013244
13245 return status;
13246}
13247
13248/*==========================================================================
13249 FUNCTION WLANTL_ResetStatistics
13250
13251 DESCRIPTION Reset statistics structure for identified station ID
13252 Reset means set values as 0
13253
13254 DEPENDENCIES NONE
13255
13256 PARAMETERS in pAdapter - Global handle
13257 in statType - specific statistics field to reset
13258
13259 RETURN VALUE VOS_STATUS
13260
13261 SIDE EFFECTS NONE
13262
13263============================================================================*/
13264VOS_STATUS WLANTL_ResetStatistics
13265(
13266 v_PVOID_t pAdapter,
13267 v_U8_t STAid
13268)
13269{
13270 WLANTL_CbType *pTLCb = VOS_GET_TL_CB(pAdapter);
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053013271 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070013272 VOS_STATUS status = VOS_STATUS_SUCCESS;
13273 WLANTL_TRANSFER_STA_TYPE *statistics = NULL;
13274
13275 /*------------------------------------------------------------------------
13276 Sanity check
13277 Extract TL control block
13278 ------------------------------------------------------------------------*/
13279 if (NULL == pTLCb)
13280 {
13281 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
13282 "WLAN TL:Invalid TL pointer on WLANTL_GetStatistics"));
13283 return VOS_STATUS_E_FAULT;
13284 }
13285
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053013286 pClientSTA = pTLCb->atlSTAClients[STAid];
13287
13288 if ( NULL == pClientSTA )
13289 {
13290 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
13291 "WLAN TL:Client Memory was not allocated on %s", __func__));
13292 return VOS_STATUS_E_FAILURE;
13293 }
13294
13295 if(0 == pClientSTA->ucExists)
Jeff Johnson295189b2012-06-20 16:38:30 -070013296 {
13297 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
13298 "WLAN TL: %d STA ID does not exist", STAid));
13299 return VOS_STATUS_E_INVAL;
13300 }
13301
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053013302 statistics = &pClientSTA->trafficStatistics;
Jeff Johnson295189b2012-06-20 16:38:30 -070013303 vos_mem_zero((v_VOID_t *)statistics, sizeof(WLANTL_TRANSFER_STA_TYPE));
13304
13305 return status;
13306}
13307
13308/*==========================================================================
13309 FUNCTION WLANTL_GetSpecStatistic
13310
13311 DESCRIPTION Get specific field within statistics structure for
13312 identified station ID
13313
13314 DEPENDENCIES NONE
13315
13316 PARAMETERS in pAdapter - Global handle
13317 in statType - specific statistics field to reset
13318 in STAid - Station ID
13319 out buffer - Statistic value
13320
13321 RETURN VALUE VOS_STATUS
13322
13323 SIDE EFFECTS NONE
13324
13325============================================================================*/
13326VOS_STATUS WLANTL_GetSpecStatistic
13327(
13328 v_PVOID_t pAdapter,
13329 WLANTL_TRANSFER_STATIC_TYPE statType,
13330 v_U32_t *buffer,
13331 v_U8_t STAid
13332)
13333{
13334 WLANTL_CbType *pTLCb = VOS_GET_TL_CB(pAdapter);
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053013335 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070013336 VOS_STATUS status = VOS_STATUS_SUCCESS;
13337 WLANTL_TRANSFER_STA_TYPE *statistics = NULL;
13338
13339 /*------------------------------------------------------------------------
13340 Sanity check
13341 Extract TL control block
13342 ------------------------------------------------------------------------*/
13343 if (NULL == pTLCb)
13344 {
13345 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
13346 "WLAN TL:Invalid TL pointer on WLANTL_GetStatistics"));
13347 return VOS_STATUS_E_FAULT;
13348 }
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053013349 pClientSTA = pTLCb->atlSTAClients[STAid];
Jeff Johnson295189b2012-06-20 16:38:30 -070013350
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053013351 if ( NULL == pClientSTA )
13352 {
13353 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
13354 "WLAN TL:Client Memory was not allocated on %s", __func__));
13355 return VOS_STATUS_E_FAILURE;
13356 }
13357
13358 if(0 == pClientSTA->ucExists)
Jeff Johnson295189b2012-06-20 16:38:30 -070013359 {
13360 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
13361 "WLAN TL: %d STA ID does not exist", STAid));
13362 return VOS_STATUS_E_INVAL;
13363 }
13364
13365 if(NULL == buffer)
13366 {
13367 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
13368 "WLAN TL:Invalid TL statistic buffer pointer on WLANTL_GetStatistics"));
13369 return VOS_STATUS_E_INVAL;
13370 }
13371
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053013372 statistics = &pClientSTA->trafficStatistics;
Jeff Johnson295189b2012-06-20 16:38:30 -070013373 switch(statType)
13374 {
13375 case WLANTL_STATIC_TX_UC_FCNT:
13376 *buffer = statistics->txUCFcnt;
13377 break;
13378
13379 case WLANTL_STATIC_TX_MC_FCNT:
13380 *buffer = statistics->txMCFcnt;
13381 break;
13382
13383 case WLANTL_STATIC_TX_BC_FCNT:
13384 *buffer = statistics->txBCFcnt;
13385 break;
13386
13387 case WLANTL_STATIC_TX_UC_BCNT:
13388 *buffer = statistics->txUCBcnt;
13389 break;
13390
13391 case WLANTL_STATIC_TX_MC_BCNT:
13392 *buffer = statistics->txMCBcnt;
13393 break;
13394
13395 case WLANTL_STATIC_TX_BC_BCNT:
13396 *buffer = statistics->txBCBcnt;
13397 break;
13398
13399 case WLANTL_STATIC_RX_UC_FCNT:
13400 *buffer = statistics->rxUCFcnt;
13401 break;
13402
13403 case WLANTL_STATIC_RX_MC_FCNT:
13404 *buffer = statistics->rxMCFcnt;
13405 break;
13406
13407 case WLANTL_STATIC_RX_BC_FCNT:
13408 *buffer = statistics->rxBCFcnt;
13409 break;
13410
13411 case WLANTL_STATIC_RX_UC_BCNT:
13412 *buffer = statistics->rxUCBcnt;
13413 break;
13414
13415 case WLANTL_STATIC_RX_MC_BCNT:
13416 *buffer = statistics->rxMCBcnt;
13417 break;
13418
13419 case WLANTL_STATIC_RX_BC_BCNT:
13420 *buffer = statistics->rxBCBcnt;
13421 break;
13422
13423 case WLANTL_STATIC_RX_BCNT:
13424 *buffer = statistics->rxBcnt;
13425 break;
13426
13427 case WLANTL_STATIC_RX_BCNT_CRC_OK:
13428 *buffer = statistics->rxBcntCRCok;
13429 break;
13430
13431 case WLANTL_STATIC_RX_RATE:
13432 *buffer = statistics->rxRate;
13433 break;
13434
13435 default:
13436 *buffer = 0;
13437 status = VOS_STATUS_E_INVAL;
13438 break;
13439 }
13440
13441
13442 return status;
13443}
13444
13445/*==========================================================================
13446 FUNCTION WLANTL_ResetSpecStatistic
13447
13448 DESCRIPTION Reset specific field within statistics structure for
13449 identified station ID
13450 Reset means set as 0
13451
13452 DEPENDENCIES NONE
13453
13454 PARAMETERS in pAdapter - Global handle
13455 in statType - specific statistics field to reset
13456 in STAid - Station ID
13457
13458 RETURN VALUE VOS_STATUS
13459
13460 SIDE EFFECTS NONE
13461
13462============================================================================*/
13463VOS_STATUS WLANTL_ResetSpecStatistic
13464(
13465 v_PVOID_t pAdapter,
13466 WLANTL_TRANSFER_STATIC_TYPE statType,
13467 v_U8_t STAid
13468)
13469{
13470 WLANTL_CbType *pTLCb = VOS_GET_TL_CB(pAdapter);
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053013471 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070013472 VOS_STATUS status = VOS_STATUS_SUCCESS;
13473 WLANTL_TRANSFER_STA_TYPE *statistics = NULL;
13474
13475 /*------------------------------------------------------------------------
13476 Sanity check
13477 Extract TL control block
13478 ------------------------------------------------------------------------*/
13479 if (NULL == pTLCb)
13480 {
13481 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
13482 "WLAN TL:Invalid TL pointer on WLANTL_GetStatistics"));
13483 return VOS_STATUS_E_FAULT;
13484 }
13485
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053013486 pClientSTA = pTLCb->atlSTAClients[STAid];
13487
13488 if ( NULL == pClientSTA )
13489 {
13490 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
13491 "WLAN TL:Client Memory was not allocated on %s", __func__));
13492 return VOS_STATUS_E_FAILURE;
13493 }
13494
13495 if(0 == pClientSTA->ucExists)
Jeff Johnson295189b2012-06-20 16:38:30 -070013496 {
13497 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
13498 "WLAN TL: %d STA ID does not exist", STAid));
13499 return VOS_STATUS_E_INVAL;
13500 }
13501
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053013502 statistics = &pClientSTA->trafficStatistics;
Jeff Johnson295189b2012-06-20 16:38:30 -070013503 switch(statType)
13504 {
13505 case WLANTL_STATIC_TX_UC_FCNT:
13506 statistics->txUCFcnt = 0;
13507 break;
13508
13509 case WLANTL_STATIC_TX_MC_FCNT:
13510 statistics->txMCFcnt = 0;
13511 break;
13512
13513 case WLANTL_STATIC_TX_BC_FCNT:
13514 statistics->txBCFcnt = 0;
13515 break;
13516
13517 case WLANTL_STATIC_TX_UC_BCNT:
13518 statistics->txUCBcnt = 0;
13519 break;
13520
13521 case WLANTL_STATIC_TX_MC_BCNT:
13522 statistics->txMCBcnt = 0;
13523 break;
13524
13525 case WLANTL_STATIC_TX_BC_BCNT:
13526 statistics->txBCBcnt = 0;
13527 break;
13528
13529 case WLANTL_STATIC_RX_UC_FCNT:
13530 statistics->rxUCFcnt = 0;
13531 break;
13532
13533 case WLANTL_STATIC_RX_MC_FCNT:
13534 statistics->rxMCFcnt = 0;
13535 break;
13536
13537 case WLANTL_STATIC_RX_BC_FCNT:
13538 statistics->rxBCFcnt = 0;
13539 break;
13540
13541 case WLANTL_STATIC_RX_UC_BCNT:
13542 statistics->rxUCBcnt = 0;
13543 break;
13544
13545 case WLANTL_STATIC_RX_MC_BCNT:
13546 statistics->rxMCBcnt = 0;
13547 break;
13548
13549 case WLANTL_STATIC_RX_BC_BCNT:
13550 statistics->rxBCBcnt = 0;
13551 break;
13552
13553 case WLANTL_STATIC_RX_BCNT:
13554 statistics->rxBcnt = 0;
13555 break;
13556
13557 case WLANTL_STATIC_RX_BCNT_CRC_OK:
13558 statistics->rxBcntCRCok = 0;
13559 break;
13560
13561 case WLANTL_STATIC_RX_RATE:
13562 statistics->rxRate = 0;
13563 break;
13564
13565 default:
13566 status = VOS_STATUS_E_INVAL;
13567 break;
13568 }
13569
13570 return status;
13571}
13572
13573
13574/*==========================================================================
13575
13576 FUNCTION
13577
13578 DESCRIPTION Read RSSI value out of a RX BD
13579
13580 PARAMETERS: Caller must validate all parameters
13581
13582 RETURN VALUE
13583
13584============================================================================*/
13585VOS_STATUS WLANTL_ReadRSSI
13586(
13587 v_PVOID_t pAdapter,
13588 v_PVOID_t pBDHeader,
13589 v_U8_t STAid
13590)
13591{
13592 WLANTL_CbType *tlCtxt = VOS_GET_TL_CB(pAdapter);
13593 v_S7_t currentRSSI, currentRSSI0, currentRSSI1;
13594
13595
13596 if(NULL == tlCtxt)
13597 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070013598 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR, "%s Invalid TL handle", __func__));
Jeff Johnson295189b2012-06-20 16:38:30 -070013599 return VOS_STATUS_E_INVAL;
13600 }
13601
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053013602 if ( NULL == tlCtxt->atlSTAClients[STAid] )
13603 {
13604 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
13605 "WLAN TL:Client Memory was not allocated on %s", __func__));
13606 return VOS_STATUS_E_FAILURE;
13607 }
13608
Jeff Johnson295189b2012-06-20 16:38:30 -070013609 currentRSSI0 = WLANTL_GETRSSI0(pBDHeader);
13610 currentRSSI1 = WLANTL_GETRSSI1(pBDHeader);
13611 currentRSSI = (currentRSSI0 > currentRSSI1) ? currentRSSI0 : currentRSSI1;
13612
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053013613 tlCtxt->atlSTAClients[STAid]->rssiAvg = currentRSSI;
Jeff Johnson295189b2012-06-20 16:38:30 -070013614
13615 return VOS_STATUS_SUCCESS;
13616}
13617
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053013618/*==========================================================================
13619
13620 FUNCTION
13621
13622 DESCRIPTION Read SNR value out of a RX BD
13623
13624 PARAMETERS: Caller must validate all parameters
13625
13626 RETURN VALUE
13627
13628============================================================================*/
13629VOS_STATUS WLANTL_ReadSNR
13630(
13631 v_PVOID_t pAdapter,
13632 v_PVOID_t pBDHeader,
13633 v_U8_t STAid
13634)
13635{
13636 WLANTL_CbType *tlCtxt = VOS_GET_TL_CB(pAdapter);
13637 v_S7_t currentSNR;
13638
13639
13640 if (NULL == tlCtxt)
13641 {
13642 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
13643 "%s Invalid TL handle", __func__));
13644 return VOS_STATUS_E_INVAL;
13645 }
13646
13647 if (NULL == tlCtxt->atlSTAClients[STAid])
13648 {
13649 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
13650 "WLAN TL:Client Memory was not allocated on %s", __func__));
13651 return VOS_STATUS_E_FAILURE;
13652 }
13653
13654 currentSNR = WLANTL_GETSNR(pBDHeader);
13655
Madan Mohan Koyyalamudi43acf032013-09-27 04:33:28 +053013656 /* SNR reported in the Buffer Descriptor is scaled up by 2(SNR*2),
13657 * Get the correct SNR value
13658 */
13659 currentSNR = currentSNR >> 1;
13660
13661 /* SNR reported by HW cannot be more than 35dB due to HW limitations */
13662 currentSNR = (WLANTL_MAX_HW_SNR > currentSNR ? currentSNR :
13663 WLANTL_MAX_HW_SNR);
13664
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053013665 TLLOG2(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
13666 "%s: snrsum: %d snridx: %d prevsnravg: %d",
13667 __func__,
13668 tlCtxt->atlSTAClients[STAid]->snrSum,
13669 tlCtxt->atlSTAClients[STAid]->snrIdx,
13670 tlCtxt->atlSTAClients[STAid]->prevSnrAvg));
13671
13672 /* The SNR returned for all purposes is the average SNR over
13673 * WLANTL_MAX_SNR_DATA_SMAPLES.When data samples
13674 * > WLANTL_MAX_SNR_DATA_SAMPLES are obtained,
13675 * store the average of the samples in prevSnrAvg
13676 * and start a new averaging window. The prevSnrAvg is used when
13677 * enough data samples are not available when applications
13678 * actually query for SNR.
13679 *
13680 * SEE: WLANTL_GetSnr()
13681 */
13682 if (tlCtxt->atlSTAClients[STAid]->snrIdx >= WLANTL_MAX_SNR_DATA_SAMPLES)
13683 {
13684 tlCtxt->atlSTAClients[STAid]->prevSnrAvg =
13685 tlCtxt->atlSTAClients[STAid]->snrSum /
13686 tlCtxt->atlSTAClients[STAid]->snrIdx;
13687 tlCtxt->atlSTAClients[STAid]->snrSum = 0;
13688 tlCtxt->atlSTAClients[STAid]->snrIdx = 0;
13689 }
13690 tlCtxt->atlSTAClients[STAid]->snrSum += currentSNR;
13691 tlCtxt->atlSTAClients[STAid]->snrIdx += 1;
13692
13693 return VOS_STATUS_SUCCESS;
13694}
Jeff Johnson295189b2012-06-20 16:38:30 -070013695
13696/*
13697 DESCRIPTION
13698 TL returns the weight currently maintained in TL.
13699 IN
13700 pvosGCtx: pointer to the global vos context; a handle to TL's
13701 or SME's control block can be extracted from its context
13702
13703 OUT
13704 pACWeights: Caller allocated memory for filling in weights
13705
13706 RETURN VALUE VOS_STATUS
13707*/
13708VOS_STATUS
13709WLANTL_GetACWeights
13710(
13711 v_PVOID_t pvosGCtx,
13712 v_U8_t* pACWeights
13713)
13714{
13715 WLANTL_CbType* pTLCb = NULL;
13716 v_U8_t ucIndex;
13717 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
13718
13719 /*------------------------------------------------------------------------
13720 Sanity check
13721 ------------------------------------------------------------------------*/
13722 if ( NULL == pACWeights )
13723 {
13724 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
13725 "WLAN TL:Invalid parameter sent on WLANTL_GetACWeights"));
13726 return VOS_STATUS_E_INVAL;
13727 }
13728
13729 /*------------------------------------------------------------------------
13730 Extract TL control block and check existance
13731 ------------------------------------------------------------------------*/
13732 pTLCb = VOS_GET_TL_CB(pvosGCtx);
13733 if ( NULL == pTLCb )
13734 {
13735 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
13736 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_GetACWeights"));
13737 return VOS_STATUS_E_FAULT;
13738 }
13739 for ( ucIndex = 0; ucIndex < WLANTL_MAX_AC ; ucIndex++)
13740 {
13741 pACWeights[ucIndex] = pTLCb->tlConfigInfo.ucAcWeights[ucIndex];
13742 }
13743
13744 return VOS_STATUS_SUCCESS;
13745}
13746
13747
13748
13749/*
13750 DESCRIPTION
13751 Change the weight currently maintained by TL.
13752 IN
13753 pvosGCtx: pointer to the global vos context; a handle to TL's
13754 or SME's control block can be extracted from its context
13755 pACWeights: Caller allocated memory contain the weights to use
13756
13757
13758 RETURN VALUE VOS_STATUS
13759*/
13760VOS_STATUS
13761WLANTL_SetACWeights
13762(
13763 v_PVOID_t pvosGCtx,
13764 v_U8_t* pACWeights
13765)
13766{
13767 WLANTL_CbType* pTLCb = NULL;
13768 v_U8_t ucIndex;
13769 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
13770
13771 /*------------------------------------------------------------------------
13772 Sanity check
13773 ------------------------------------------------------------------------*/
13774 if ( NULL == pACWeights )
13775 {
13776 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
13777 "WLAN TL:Invalid parameter sent on WLANTL_GetACWeights"));
13778 return VOS_STATUS_E_INVAL;
13779 }
13780
13781 /*------------------------------------------------------------------------
13782 Extract TL control block and check existance
13783 ------------------------------------------------------------------------*/
13784 pTLCb = VOS_GET_TL_CB(pvosGCtx);
13785 if ( NULL == pTLCb )
13786 {
13787 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
13788 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_GetACWeights"));
13789 return VOS_STATUS_E_FAULT;
13790 }
13791 for ( ucIndex = 0; ucIndex < WLANTL_MAX_AC ; ucIndex++)
13792 {
13793 pTLCb->tlConfigInfo.ucAcWeights[ucIndex] = pACWeights[ucIndex];
13794 }
13795
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +053013796 pTLCb->tlConfigInfo.ucAcWeights[WLANTL_AC_HIGH_PRIO] = pACWeights[WLANTL_AC_VO];
Jeff Johnson295189b2012-06-20 16:38:30 -070013797 return VOS_STATUS_SUCCESS;
13798}
13799
13800
13801/*==========================================================================
13802
13803 FUNCTION
13804
13805 DESCRIPTION
13806
13807 PARAMETERS
13808
13809 RETURN VALUE
13810
13811============================================================================*/
13812void WLANTL_PowerStateChangedCB
13813(
13814 v_PVOID_t pAdapter,
13815 tPmcState newState
13816)
13817{
13818 WLANTL_CbType *tlCtxt = VOS_GET_TL_CB(pAdapter);
13819
13820 if (NULL == tlCtxt)
13821 {
13822 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +053013823 "%s: Invalid TL Control Block", __func__ );
Jeff Johnson295189b2012-06-20 16:38:30 -070013824 return;
13825 }
13826
13827 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO, "Power state changed, new state is %d", newState );
13828 switch(newState)
13829 {
13830 case FULL_POWER:
13831 tlCtxt->isBMPS = VOS_FALSE;
13832 break;
13833
13834 case BMPS:
13835#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
13836 WLANTL_SetFWRSSIThresholds(pAdapter);
13837#endif
13838
13839 tlCtxt->isBMPS = VOS_TRUE;
13840 break;
13841
13842 case IMPS:
13843 case LOW_POWER:
13844 case REQUEST_BMPS:
13845 case REQUEST_FULL_POWER:
13846 case REQUEST_IMPS:
13847 case STOPPED:
13848 case REQUEST_START_UAPSD:
13849 case REQUEST_STOP_UAPSD:
13850 case UAPSD:
13851 case REQUEST_STANDBY:
13852 case STANDBY:
13853 case REQUEST_ENTER_WOWL:
13854 case REQUEST_EXIT_WOWL:
13855 case WOWL:
13856 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN, "Not handle this events %d", newState ));
13857 break;
13858
13859 default:
13860 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR, "Not a valid event %d", newState ));
13861 break;
13862 }
13863
13864 return;
13865}
13866/*==========================================================================
13867 FUNCTION WLANTL_GetEtherType
13868
13869 DESCRIPTION Extract Ether type information from the BD
13870
13871 DEPENDENCIES NONE
13872
13873 PARAMETERS in aucBDHeader - BD header
13874 in vosDataBuff - data buffer
13875 in ucMPDUHLen - MPDU header length
13876 out pUsEtherType - pointer to Ethertype
13877
13878 RETURN VALUE VOS_STATUS_SUCCESS : if the EtherType is successfully extracted
13879 VOS_STATUS_FAILURE : if the EtherType extraction failed and
13880 the packet was dropped
13881
13882 SIDE EFFECTS NONE
13883
13884============================================================================*/
13885static VOS_STATUS WLANTL_GetEtherType
13886(
13887 v_U8_t * aucBDHeader,
13888 vos_pkt_t * vosDataBuff,
13889 v_U8_t ucMPDUHLen,
13890 v_U16_t * pUsEtherType
13891)
13892{
13893 v_U8_t ucOffset;
13894 v_U16_t usEtherType = *pUsEtherType;
13895 v_SIZE_t usLLCSize = sizeof(usEtherType);
13896 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
13897
13898 /*------------------------------------------------------------------------
13899 Check if LLC is present - if not, TL is unable to determine type
13900 ------------------------------------------------------------------------*/
13901 if ( VOS_FALSE == WDA_IS_RX_LLC_PRESENT( aucBDHeader ) )
13902 {
13903 ucOffset = WLANTL_802_3_HEADER_LEN - sizeof(usEtherType);
13904 }
13905 else
13906 {
13907 ucOffset = ucMPDUHLen + WLANTL_LLC_PROTO_TYPE_OFFSET;
13908 }
13909
13910 /*------------------------------------------------------------------------
13911 Extract LLC type
13912 ------------------------------------------------------------------------*/
13913 vosStatus = vos_pkt_extract_data( vosDataBuff, ucOffset,
13914 (v_PVOID_t)&usEtherType, &usLLCSize);
13915
13916 if (( VOS_STATUS_SUCCESS != vosStatus ) ||
13917 ( sizeof(usEtherType) != usLLCSize ))
13918
13919 {
13920 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
13921 "WLAN TL:Error extracting Ether type from data packet"));
13922 /* Drop packet */
13923 vos_pkt_return_packet(vosDataBuff);
13924 vosStatus = VOS_STATUS_E_FAILURE;
13925 }
13926 else
13927 {
13928 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
13929 "WLAN TL:Ether type retrieved before endianess conv: %d",
13930 usEtherType));
13931
13932 usEtherType = vos_be16_to_cpu(usEtherType);
13933 *pUsEtherType = usEtherType;
13934
13935 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
13936 "WLAN TL:Ether type retrieved: %d", usEtherType));
13937 }
13938
13939 return vosStatus;
13940}
13941
Jeff Johnson295189b2012-06-20 16:38:30 -070013942/*==========================================================================
13943 FUNCTION WLANTL_GetSoftAPStatistics
13944
13945 DESCRIPTION Collect the cumulative statistics for all Softap stations
13946
13947 DEPENDENCIES NONE
13948
13949 PARAMETERS in pvosGCtx - Pointer to the global vos context
13950 bReset - If set TL statistics will be cleared after reading
13951 out statsSum - pointer to collected statistics
13952
13953 RETURN VALUE VOS_STATUS_SUCCESS : if the Statistics are successfully extracted
13954
13955 SIDE EFFECTS NONE
13956
13957============================================================================*/
13958VOS_STATUS WLANTL_GetSoftAPStatistics(v_PVOID_t pAdapter, WLANTL_TRANSFER_STA_TYPE *statsSum, v_BOOL_t bReset)
13959{
13960 v_U8_t i = 0;
13961 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
13962 WLANTL_CbType *pTLCb = VOS_GET_TL_CB(pAdapter);
13963 WLANTL_TRANSFER_STA_TYPE statBufferTemp;
13964 vos_mem_zero((v_VOID_t *)&statBufferTemp, sizeof(WLANTL_TRANSFER_STA_TYPE));
13965 vos_mem_zero((v_VOID_t *)statsSum, sizeof(WLANTL_TRANSFER_STA_TYPE));
13966
13967
13968 if ( NULL == pTLCb )
13969 {
13970 return VOS_STATUS_E_FAULT;
13971 }
13972
13973 // Sum up all the statistics for stations of Soft AP from TL
13974 for (i = 0; i < WLAN_MAX_STA_COUNT; i++)
13975 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053013976 if ( NULL == pTLCb->atlSTAClients[i])
13977 {
13978 continue;
13979 }
13980 if (pTLCb->atlSTAClients[i]->wSTADesc.wSTAType == WLAN_STA_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -070013981 {
13982 vosStatus = WLANTL_GetStatistics(pAdapter, &statBufferTemp, i);// Can include staId 1 because statistics not collected for it
13983
13984 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
13985 return VOS_STATUS_E_FAULT;
13986
13987 // Add to the counters
13988 statsSum->txUCFcnt += statBufferTemp.txUCFcnt;
13989 statsSum->txMCFcnt += statBufferTemp.txMCFcnt;
13990 statsSum->txBCFcnt += statBufferTemp.txBCFcnt;
13991 statsSum->txUCBcnt += statBufferTemp.txUCBcnt;
13992 statsSum->txMCBcnt += statBufferTemp.txMCBcnt;
13993 statsSum->txBCBcnt += statBufferTemp.txBCBcnt;
13994 statsSum->rxUCFcnt += statBufferTemp.rxUCFcnt;
13995 statsSum->rxMCFcnt += statBufferTemp.rxMCFcnt;
13996 statsSum->rxBCFcnt += statBufferTemp.rxBCFcnt;
13997 statsSum->rxUCBcnt += statBufferTemp.rxUCBcnt;
13998 statsSum->rxMCBcnt += statBufferTemp.rxMCBcnt;
13999 statsSum->rxBCBcnt += statBufferTemp.rxBCBcnt;
14000
14001 if (bReset)
14002 {
14003 vosStatus = WLANTL_ResetStatistics(pAdapter, i);
14004 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
14005 return VOS_STATUS_E_FAULT;
14006 }
14007 }
14008 }
14009
14010 return vosStatus;
14011}
Mohit Khanna698ba2a2012-12-04 15:08:18 -080014012
Jeff Johnson295189b2012-06-20 16:38:30 -070014013/*===============================================================================
14014 FUNCTION WLANTL_IsReplayPacket
14015
14016 DESCRIPTION This function does replay check for valid stations
14017
14018 DEPENDENCIES Validity of replay check must be done before the function
14019 is called
14020
14021 PARAMETERS currentReplayCounter current replay counter taken from RX BD
14022 previousReplayCounter previous replay counter taken from TL CB
14023
14024 RETRUN VOS_TRUE packet is a replay packet
14025 VOS_FALSE packet is not a replay packet
14026
14027 SIDE EFFECTS none
14028 ===============================================================================*/
14029v_BOOL_t
14030WLANTL_IsReplayPacket
14031(
14032 v_U64_t ullcurrentReplayCounter,
14033 v_U64_t ullpreviousReplayCounter
14034)
14035{
14036 /* Do the replay check by comparing previous received replay counter with
14037 current received replay counter*/
14038 if(ullpreviousReplayCounter < ullcurrentReplayCounter)
14039 {
14040 /* Valid packet not replay */
14041 return VOS_FALSE;
14042 }
14043 else
14044 {
14045
14046 /* Current packet number is less than or equal to previuos received
14047 packet no, this means current packet is replay packet */
14048 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
14049 "WLAN TL: Replay packet found with replay counter :[0x%llX]",ullcurrentReplayCounter);
14050
14051 return VOS_TRUE;
14052 }
14053}
14054
14055#if 0
14056/*===============================================================================
14057 FUNCTION WLANTL_GetReplayCounterFromRxBD
14058
14059 DESCRIPTION This function extracts 48-bit replay packet number from RX BD
14060
14061 DEPENDENCIES Validity of replay check must be done before the function
14062 is called
14063
14064 PARAMETERS pucRxHeader pointer to RX BD header
14065
14066 RETRUN v_U64_t Packet number extarcted from RX BD
14067
14068 SIDE EFFECTS none
14069 ===============================================================================*/
14070v_U64_t
14071WLANTL_GetReplayCounterFromRxBD
14072(
14073 v_U8_t *pucRxBDHeader
14074)
14075{
14076/* 48-bit replay counter is created as follows
14077 from RX BD 6 byte PMI command:
14078 Addr : AES/TKIP
14079 0x38 : pn3/tsc3
14080 0x39 : pn2/tsc2
14081 0x3a : pn1/tsc1
14082 0x3b : pn0/tsc0
14083
14084 0x3c : pn5/tsc5
14085 0x3d : pn4/tsc4 */
14086
14087#ifdef ANI_BIG_BYTE_ENDIAN
14088 v_U64_t ullcurrentReplayCounter = 0;
14089 /* Getting 48-bit replay counter from the RX BD */
14090 ullcurrentReplayCounter = WLANHAL_RX_BD_GET_PMICMD_20TO23(pucRxBDHeader);
14091 ullcurrentReplayCounter <<= 16;
14092 ullcurrentReplayCounter |= (( WLANHAL_RX_BD_GET_PMICMD_24TO25(pucRxBDHeader) & 0xFFFF0000) >> 16);
14093 return ullcurrentReplayCounter;
14094#else
14095 v_U64_t ullcurrentReplayCounter = 0;
14096 /* Getting 48-bit replay counter from the RX BD */
14097 ullcurrentReplayCounter = (WLANHAL_RX_BD_GET_PMICMD_24TO25(pucRxBDHeader) & 0x0000FFFF);
14098 ullcurrentReplayCounter <<= 32;
14099 ullcurrentReplayCounter |= WLANHAL_RX_BD_GET_PMICMD_20TO23(pucRxBDHeader);
14100 return ullcurrentReplayCounter;
14101#endif
14102}
14103#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070014104
14105/*===============================================================================
14106 FUNCTION WLANTL_PostResNeeded
14107
14108 DESCRIPTION This function posts message to TL to reserve BD/PDU memory
14109
14110 DEPENDENCIES None
14111
14112 PARAMETERS pvosGCtx
14113
14114 RETURN None
14115
14116 SIDE EFFECTS none
14117 ===============================================================================*/
14118
14119void WLANTL_PostResNeeded(v_PVOID_t pvosGCtx)
14120{
14121 vos_msg_t vosMsg;
14122
14123 vosMsg.reserved = 0;
14124 vosMsg.bodyptr = NULL;
14125 vosMsg.type = WLANTL_TX_RES_NEEDED;
14126 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
14127 "WLAN TL: BD/PDU available interrupt received, Posting message to TL");
14128 if(!VOS_IS_STATUS_SUCCESS(vos_tx_mq_serialize( VOS_MQ_ID_TL, &vosMsg)))
14129 {
14130 VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070014131 " %s fails to post message", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070014132 }
14133}
14134
14135/*===============================================================================
14136 FUNCTION WLANTL_UpdateRssiBmps
14137
14138 DESCRIPTION This function updates the TL's RSSI (in BMPS mode)
14139
14140 DEPENDENCIES None
14141
14142 PARAMETERS
14143
14144 pvosGCtx VOS context VOS Global context
14145 staId Station ID Station ID
14146 rssi RSSI (BMPS mode) RSSI in BMPS mode
14147
14148 RETURN None
14149
14150 SIDE EFFECTS none
14151 ===============================================================================*/
14152
14153void WLANTL_UpdateRssiBmps(v_PVOID_t pvosGCtx, v_U8_t staId, v_S7_t rssi)
14154{
14155 WLANTL_CbType* pTLCb = VOS_GET_TL_CB(pvosGCtx);
14156
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053014157 if (NULL != pTLCb && NULL != pTLCb->atlSTAClients[staId])
Jeff Johnson295189b2012-06-20 16:38:30 -070014158 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053014159 pTLCb->atlSTAClients[staId]->rssiAvgBmps = rssi;
Jeff Johnson295189b2012-06-20 16:38:30 -070014160 }
14161}
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053014162
14163/*===============================================================================
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053014164 FUNCTION WLANTL_UpdateSnrBmps
14165
14166 DESCRIPTION This function updates the TL's SNR (in BMPS mode)
14167
14168 DEPENDENCIES None
14169
14170 PARAMETERS
14171
14172 pvosGCtx VOS context VOS Global context
14173 staId Station ID Station ID
14174 snr SNR (BMPS mode) SNR in BMPS mode
14175
14176 RETURN None
14177
14178 SIDE EFFECTS none
14179 ===============================================================================*/
14180
14181void WLANTL_UpdateSnrBmps(v_PVOID_t pvosGCtx, v_U8_t staId, v_S7_t snr)
14182{
14183 WLANTL_CbType* pTLCb = VOS_GET_TL_CB(pvosGCtx);
14184
14185 if (NULL != pTLCb && NULL != pTLCb->atlSTAClients[staId])
14186 {
14187 pTLCb->atlSTAClients[staId]->snrAvgBmps = snr;
14188 }
14189}
14190
14191/*===============================================================================
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053014192 FUNCTION WLANTL_UpdateLinkCapacity
14193
14194 DESCRIPTION This function updates the STA's Link Capacity in TL
14195
14196 DEPENDENCIES None
14197
14198 PARAMETERS
14199
14200 pvosGCtx VOS context VOS Global context
14201 staId Station ID Station ID
14202 linkCapacity linkCapacity Link Capacity
14203
14204 RETURN None
14205
14206 SIDE EFFECTS none
14207 ===============================================================================*/
14208
14209void WLANTL_UpdateLinkCapacity(v_PVOID_t pvosGCtx, v_U8_t staId, v_U32_t linkCapacity)
14210{
14211 WLANTL_CbType* pTLCb = VOS_GET_TL_CB(pvosGCtx);
14212
14213 if (NULL != pTLCb && NULL != pTLCb->atlSTAClients[staId])
14214 {
14215 pTLCb->atlSTAClients[staId]->linkCapacity = linkCapacity;
14216 }
14217}
14218
14219
14220/*===========================================================================
14221
14222 FUNCTION WLANTL_GetSTALinkCapacity
14223
14224 DESCRIPTION
14225
14226 Returns Link Capacity of a particular STA.
14227
14228 DEPENDENCIES
14229
14230 A station must have been registered before its state can be retrieved.
14231
14232
14233 PARAMETERS
14234
14235 IN
14236 pvosGCtx: pointer to the global vos context; a handle to TL's
14237 control block can be extracted from its context
14238 ucSTAId: identifier of the station
14239
14240 OUT
14241 plinkCapacity: the current link capacity the connection to
14242 the given station
14243
14244
14245 RETURN VALUE
14246
14247 The result code associated with performing the operation
14248
14249 VOS_STATUS_E_INVAL: Input parameters are invalid
14250 VOS_STATUS_E_FAULT: Station ID is outside array boundaries or pointer to
14251 TL cb is NULL ; access would cause a page fault
14252 VOS_STATUS_E_EXISTS: Station was not registered
14253 VOS_STATUS_SUCCESS: Everything is good :)
14254
14255 SIDE EFFECTS
14256
14257============================================================================*/
14258VOS_STATUS
14259WLANTL_GetSTALinkCapacity
14260(
14261 v_PVOID_t pvosGCtx,
14262 v_U8_t ucSTAId,
14263 v_U32_t *plinkCapacity
14264)
14265{
14266 WLANTL_CbType* pTLCb = NULL;
14267 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
14268
14269 /*------------------------------------------------------------------------
14270 Sanity check
14271 ------------------------------------------------------------------------*/
14272 if ( NULL == plinkCapacity )
14273 {
14274 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
14275 FL("WLAN TL:Invalid parameter")));
14276 return VOS_STATUS_E_INVAL;
14277 }
14278
14279 if ( WLANTL_STA_ID_INVALID( ucSTAId ) )
14280 {
14281 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
14282 FL("WLAN TL:Invalid station id")));
14283 return VOS_STATUS_E_FAULT;
14284 }
14285
14286 /*------------------------------------------------------------------------
14287 Extract TL control block and check existance
14288 ------------------------------------------------------------------------*/
14289 pTLCb = VOS_GET_TL_CB(pvosGCtx);
14290 if ( NULL == pTLCb )
14291 {
14292 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
14293 FL("WLAN TL:Invalid TL pointer from pvosGCtx")));
14294 return VOS_STATUS_E_FAULT;
14295 }
14296
14297 if ( NULL == pTLCb->atlSTAClients[ucSTAId] )
14298 {
14299 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
14300 FL("WLAN TL:Client Memory was not allocated")));
14301 return VOS_STATUS_E_FAILURE;
14302 }
14303
14304 if ( 0 == pTLCb->atlSTAClients[ucSTAId]->ucExists )
14305 {
14306 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
14307 FL("WLAN TL:Station was not previously registered")));
14308 return VOS_STATUS_E_EXISTS;
14309 }
14310
14311 /*------------------------------------------------------------------------
14312 Get STA state
14313 ------------------------------------------------------------------------*/
14314 *plinkCapacity = pTLCb->atlSTAClients[ucSTAId]->linkCapacity;
14315
14316 return VOS_STATUS_SUCCESS;
14317}/* WLANTL_GetSTALinkCapacity */
Abhishek Singh00b71972016-01-07 10:51:04 +053014318
Sravan Kumar Kairam893801a2016-11-01 19:14:23 +053014319/*
14320 * WLANTL_ResetRxSSN - reset last rx ssn
14321 * @pvosGCtx: global vos context
14322 * @ucSTAId: station id
14323 *
14324 * This function resets the last ssn of all tids of the station
14325 * for whom BA reorder session exists.
14326 *
14327 * Return: none
14328 */
14329void WLANTL_ResetRxSSN(v_PVOID_t pvosGCtx, uint8_t ucSTAId)
14330{
14331 WLANTL_CbType* pTLCb = NULL;
14332 WLANTL_STAClientType* pClientSTA = NULL;
14333 uint8_t i;
14334
14335 if (WLANTL_STA_ID_INVALID(ucSTAId)) {
14336 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
14337 "WLAN TL:Invalid station id requested WLANTL_ResetRxSSN"));
14338 return;
14339 }
14340
14341 pTLCb = VOS_GET_TL_CB(pvosGCtx);
14342 if (NULL == pTLCb) {
14343 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
14344 "WLAN TL:Invalid TL pointer from pvosGCtx WLANTL_ResetRxSSN"));
14345 return;
14346 }
14347
14348 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
14349
14350 for (i = 0; i < WLAN_MAX_TID ; i++) {
14351 if (0 == pClientSTA->atlBAReorderInfo[i].ucExists) {
14352 continue;
14353 }
14354 TLLOG1(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
14355 "WLAN TL: Last RxSSN reset to zero for tid %d", i));
14356 pClientSTA->atlBAReorderInfo[i].LastSN = 0;
14357 }
14358}
Abhishek Singh00b71972016-01-07 10:51:04 +053014359
Sravan Kumar Kairama97e2372016-11-11 17:20:03 +053014360void WLANTL_SetDataPktFilter(v_PVOID_t pvosGCtx, uint8_t ucSTAId, bool flag)
14361{
14362 WLANTL_CbType* pTLCb = NULL;
14363 WLANTL_STAClientType* pClientSTA = NULL;
14364 uint8_t i;
14365
14366 if (WLANTL_STA_ID_INVALID(ucSTAId)) {
14367 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
14368 "%s: Invalid station id requested", __func__));
14369 return;
14370 }
14371
14372 pTLCb = VOS_GET_TL_CB(pvosGCtx);
14373 if (NULL == pTLCb) {
14374 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
14375 "%s: Invalid TL pointer from pvosGCtx", __func__));
14376 return;
14377 }
14378
14379 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
14380
14381 for (i = 0; i < WLAN_MAX_TID ; i++) {
14382 if (0 == pClientSTA->atlBAReorderInfo[i].ucExists)
14383 continue;
14384
14385 TLLOG1(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
14386 "WLAN TL: Last RxSSN reset to zero for tid %d", i));
14387 pClientSTA->atlBAReorderInfo[i].set_data_filter = flag;
14388 }
14389}
14390
Sravan Kumar Kairam60b8cf02016-12-12 16:22:09 +053014391/**
14392 * WLANTL_ShiftArrByOne() - utility function to shift array by one
14393 * @arr: pointer to array
14394 * @len: length of the array
14395 *
14396 * Caller responsibility to provide the correct length of the array
14397 * other may leads to bugs.
14398 *
14399 * Return: void
14400 */
14401static void WLANTL_ShiftArrByOne(uint32_t *arr, uint8_t len)
14402{
14403 int i;
14404 for (i = 0; i < len - 1; i ++)
14405 arr[i] = arr[i + 1];
14406 arr[i] = 0;
14407}
14408
14409/**
14410 * WLANTL_SampleTx() - collect tx samples
14411 * @data: TL context pointer
14412 *
14413 * This function records the last five tx bytes sent samples
14414 * collected after tx_bytes_timer expire.
14415 *
14416 * Return: void
14417 */
14418void WLANTL_SampleTx(void *data)
14419{
14420 WLANTL_CbType* pTLCb = (WLANTL_CbType *)data;
14421 WLANTL_STAClientType* pClientSTA = NULL;
14422 uint8_t count = pTLCb->sample_count;
14423 uint8_t i;
14424
14425 for ( i = 0; i < WLAN_MAX_STA_COUNT; i++) {
14426 if (NULL != pTLCb->atlSTAClients[i] &&
14427 pTLCb->atlSTAClients[i]->ucExists) {
14428 pClientSTA = pTLCb->atlSTAClients[i];
14429
14430 if (count > (WLANTL_SAMPLE_COUNT - 1)) {
14431 count = WLANTL_SAMPLE_COUNT - 1;
14432 pClientSTA->tx_samples_sum -= pClientSTA->tx_sample[0];
14433 WLANTL_ShiftArrByOne(pClientSTA->tx_sample, WLANTL_SAMPLE_COUNT);
14434 }
14435
14436 pClientSTA->tx_sample[count] = pClientSTA->tx_frames;
14437 pClientSTA->tx_samples_sum += pClientSTA->tx_sample[count];
14438 pClientSTA->tx_frames = 0;
14439 count++;
14440 pTLCb->sample_count = count;
14441 }
14442 }
14443
14444 vos_timer_start(&pTLCb->tx_frames_timer, WLANTL_SAMPLE_INTERVAL);
14445}
Sravan Kumar Kairam091e5b62017-01-23 14:14:20 +053014446
14447/**
14448 * WLANTL_EnablePreAssocCaching() - Enable caching EAPOL frames
14449 *
14450 * Return: None
14451 *
14452 */
14453void WLANTL_EnablePreAssocCaching(void)
14454{
14455 v_PVOID_t pvosGCtx= vos_get_global_context(VOS_MODULE_ID_TL,NULL);
14456 WLANTL_CbType* pTLCb = VOS_GET_TL_CB(pvosGCtx);
14457 if (NULL == pTLCb ) {
14458 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
14459 "%s: Invalid TL pointer for global context", __func__));
14460 return;
14461 }
14462
14463 pTLCb->vosEapolCachedFrame = NULL;
14464 pTLCb->preassoc_caching = true;
14465}
14466
14467/**
14468 * WLANTL_ForwardPreAssoc() - forward cached eapol frames
14469 * @flag: Value to forward or flush
14470 *
14471 * Return: vos status
14472 *
14473 */
14474static VOS_STATUS WLANTL_ForwardPreAssoc(bool flag)
14475{
14476 vos_msg_t sMessage;
14477
14478 VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
14479 " ---- Serializing TL for forwarding pre assoc cache frames");
14480
14481 vos_mem_zero( &sMessage, sizeof(vos_msg_t));
14482 sMessage.type = WLANTL_RX_FWD_PRE_ASSOC_CACHED;
14483 sMessage.bodyval = flag;
14484
14485 return vos_rx_mq_serialize(VOS_MQ_ID_TL, &sMessage);
14486}
14487
14488/**
14489 * WLANTL_PreAssocForward() - forward cached eapol frames
14490 * @flag: Value to forward or flush
14491 *
14492 * Return: None
14493 *
14494 */
14495void WLANTL_PreAssocForward(bool flag)
14496{
14497 if(!VOS_IS_STATUS_SUCCESS(WLANTL_ForwardPreAssoc(flag)))
14498 {
14499 VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
14500 " %s fails to forward packets", __func__);
14501 }
14502}
14503
14504/**
14505 * WLANTL_RegisterFwdEapol() - register call back to forward cached eapol frame
14506 * @pvosGCtx : pointer to vos global context
14507 * @pfnFwdEapol: call back function pointer
14508 *
14509 * Return: None
14510 *
14511 */
14512void WLANTL_RegisterFwdEapol(v_PVOID_t pvosGCtx,
14513 WLANTL_FwdEapolCBType pfnFwdEapol)
14514{
14515 WLANTL_CbType* pTLCb = NULL;
14516 pTLCb = VOS_GET_TL_CB(pvosGCtx);
14517
Sravan Kumar Kairamb31fa3b2018-03-12 15:44:11 +053014518 if (pTLCb)
14519 pTLCb->pfnEapolFwd = pfnFwdEapol;
Sravan Kumar Kairam091e5b62017-01-23 14:14:20 +053014520}
14521
Sravan Kumar Kairamd9e8cbb2017-01-17 12:17:28 +053014522 /**
14523 * WLANTL_SetARPFWDatapath() - keep or remove FW in data path for ARP
14524 *
14525 * @flag: value to keep or remove FW from data path
14526 *
14527 * Return: void
14528 */
14529void WLANTL_SetARPFWDatapath(void * pvosGCtx, bool flag)
14530{
14531
14532 WLANTL_CbType* pTLCb = NULL;
14533
14534 pTLCb = VOS_GET_TL_CB(pvosGCtx);
14535 if (NULL == pTLCb) {
14536 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
14537 "%s: Invalid TL pointer from pvosGCtx", __func__));
14538 return;
14539 }
14540
14541 pTLCb->track_arp = flag;
14542
14543}
14544
Hanumanth Reddy Pothula57323632017-12-06 17:55:09 +053014545v_U16_t wlan_tl_get_sta_rx_rate(void *pvosGCtx, uint8_t ucSTAId)
14546{
14547 WLANTL_CbType* pTLCb = NULL;
14548 v_U16_t rate = 0;
14549
14550 pTLCb = VOS_GET_TL_CB(pvosGCtx);
14551 if (NULL == pTLCb) {
14552 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
14553 "%s: Invalid TL pointer from pvosGCtx", __func__));
14554 return rate;
14555 }
14556
14557 if (pTLCb->atlSTAClients[ucSTAId]->ucExists)
14558 rate = vos_get_rate_from_rateidx(
14559 pTLCb->atlSTAClients[ucSTAId]->rate_idx);
14560
14561 return rate;
14562}
14563
Sravan Kumar Kairame0e78442017-09-18 18:00:53 +053014564void WLANTL_GetSAPStaRSSi(void *pvosGCtx, uint8_t ucSTAId, s8 *rssi)
14565{
14566 WLANTL_CbType* pTLCb = NULL;
14567 uint8_t count;
14568
14569 pTLCb = VOS_GET_TL_CB(pvosGCtx);
14570 if (NULL == pTLCb) {
14571 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
14572 "%s: Invalid TL pointer from pvosGCtx", __func__));
14573 return;
14574 }
14575
14576 count = pTLCb->atlSTAClients[ucSTAId]->rssi_sample_cnt;
14577 count < WLANTL_RSSI_SAMPLE_CNT ? count++ : count;
14578
14579 *rssi = pTLCb->atlSTAClients[ucSTAId]->rssi_sample_sum / count;
14580}
14581
Sravan Kumar Kairam8bb90ca2017-11-01 19:00:23 +053014582void WLANTL_SetKeySeqCounter(void *pvosGCtx, u64 counter, uint8_t staid)
14583{
14584 WLANTL_CbType* pTLCb = NULL;
14585 uint8_t i;
14586
14587 pTLCb = VOS_GET_TL_CB(pvosGCtx);
14588 if (NULL == pTLCb) {
14589 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
14590 "%s: Invalid TL pointer from pvosGCtx", __func__));
14591 return;
14592 }
14593
14594 if (WLANTL_STA_ID_INVALID(staid)) {
14595 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
14596 "%s: Invalid Sta id passed", __func__));
14597 return;
14598 }
14599
14600 if (NULL == pTLCb->atlSTAClients[staid]) {
14601 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
14602 "%s: Station context is NULL", __func__));
14603 return;
14604 }
14605
14606 for(i = 0; i < WLANTL_MAX_TID; i++)
14607 pTLCb->atlSTAClients[staid]->ullReplayCounter[i] = counter;
14608}
14609
Abhishek Singh00b71972016-01-07 10:51:04 +053014610#ifdef WLAN_FEATURE_RMC
14611VOS_STATUS WLANTL_RmcInit
14612(
14613 v_PVOID_t pAdapter
14614)
14615{
14616 WLANTL_CbType *pTLCb = VOS_GET_TL_CB(pAdapter);
14617 VOS_STATUS status = VOS_STATUS_SUCCESS;
14618 tANI_U8 count;
14619
14620 /*sanity check*/
14621 if (NULL == pTLCb)
14622 {
14623 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
14624 "Invalid TL handle"));
14625 return VOS_STATUS_E_INVAL;
14626 }
14627
14628 for ( count = 0; count < WLANTL_RMC_HASH_TABLE_SIZE; count++ )
14629 {
14630 pTLCb->rmcSession[count] = NULL;
14631 }
14632
14633 vos_lock_init(&pTLCb->rmcLock);
14634
14635 pTLCb->multicastDuplicateDetectionEnabled = 1;
14636 pTLCb->rmcDataPathEnabled = 0;
14637
14638 return status;
14639}
14640
14641
14642VOS_STATUS WLANTL_RmcDeInit
14643(
14644 v_PVOID_t pAdapter
14645)
14646{
14647 WLANTL_CbType *pTLCb = VOS_GET_TL_CB(pAdapter);
14648 VOS_STATUS status = VOS_STATUS_SUCCESS;
14649 tANI_U8 count;
14650 WLANTL_RMC_SESSION *pNode;
14651 WLANTL_RMC_SESSION *pPrev;
14652
14653 /*sanity check*/
14654 if (NULL == pTLCb)
14655 {
14656 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
14657 "Invalid TL handle"));
14658 return VOS_STATUS_E_INVAL;
14659 }
14660
14661 for ( count = 0; count < WLANTL_RMC_HASH_TABLE_SIZE; count++ )
14662 {
14663 pNode = pTLCb->rmcSession[count];
14664 while (pNode)
14665 {
14666 pPrev = pNode;
14667 pNode = pNode->next;
14668 vos_mem_free((v_VOID_t * )pPrev);
14669 }
14670 }
14671
14672 vos_lock_destroy(&pTLCb->rmcLock);
14673
14674 return status;
14675}
14676
14677
14678tANI_U8 WLANTL_RmcHashRmcSession ( v_MACADDR_t *pMcastAddr )
14679{
14680 tANI_U32 sum;
14681 tANI_U8 hash;
14682
14683 sum = (pMcastAddr->bytes[0] + pMcastAddr->bytes[1] + pMcastAddr->bytes[2] +
14684 pMcastAddr->bytes[3] + pMcastAddr->bytes[4] + pMcastAddr->bytes[5]);
14685
14686 hash = (tANI_U8)(sum & ((WLANTL_RMC_HASH_TABLE_SIZE - 1)));
14687
14688 return hash;
14689}
14690
14691
14692WLANTL_RMC_SESSION* WLANTL_RmcLookUpRmcSession
14693(
14694 WLANTL_RMC_SESSION *rmcSession[],
14695 v_MACADDR_t *pMcastAddr
14696)
14697{
14698 WLANTL_RMC_SESSION *pNode;
14699 tANI_U8 index;
14700
14701 /*sanity check*/
14702 if (NULL == pMcastAddr)
14703 {
14704 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Jeff Johnsonddec6482017-09-19 08:33:57 -070014705 "Sanity check failed pMcastAddr %pK", pMcastAddr));
Abhishek Singh00b71972016-01-07 10:51:04 +053014706 return NULL;
14707 }
14708
14709 index = WLANTL_RmcHashRmcSession(pMcastAddr);
14710 pNode = rmcSession[index];
14711 while ( pNode )
14712 {
14713 if (vos_is_macaddr_equal( &(pNode->rmcAddr), pMcastAddr))
14714 {
14715 return pNode;
14716 }
14717 pNode = pNode->next;
14718 }
14719
14720 return NULL;
14721}
14722
14723WLANTL_RMC_SESSION *WLANTL_RmcAddRmcSession
14724(
14725 WLANTL_RMC_SESSION *rmcSession[],
14726 v_MACADDR_t *pMcastAddr
14727)
14728{
14729 WLANTL_RMC_SESSION *pNode;
14730 tANI_U8 index;
14731
14732 index = WLANTL_RmcHashRmcSession(pMcastAddr);
14733 pNode = WLANTL_RmcLookUpRmcSession(rmcSession, pMcastAddr);
14734 if ( NULL != pNode )
14735 {
14736 /*already exists*/
14737 return NULL;
14738 }
14739 else
14740 {
14741 pNode = (WLANTL_RMC_SESSION *)vos_mem_malloc(sizeof(*pNode));
14742 if (pNode)
14743 {
14744 vos_mem_copy( &(pNode->rmcAddr), pMcastAddr,
14745 sizeof(pNode->rmcAddr) );
14746 pNode->next = rmcSession[index];
14747 rmcSession[index] = pNode;
14748 return pNode;
14749 }
14750 else
14751 {
14752 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14753 "%s: vos_mem_malloc failed can't enable RMC session",
14754 __func__);
14755 return NULL;
14756 }
14757 }
14758}
14759
14760tANI_U8
14761WLANTL_RmcDeleteRmcSession
14762(
14763 WLANTL_RMC_SESSION *rmcSession[],
14764 v_MACADDR_t *pMcastAddr
14765)
14766{
14767 WLANTL_RMC_SESSION *pHead;
14768 WLANTL_RMC_SESSION *pNode;
14769 WLANTL_RMC_SESSION *pPrev;
14770 tANI_U8 index;
14771
14772 index = WLANTL_RmcHashRmcSession(pMcastAddr);
14773 pHead = pNode = rmcSession[index];
14774 while (pNode)
14775 {
14776 if (vos_is_macaddr_equal( &(pNode->rmcAddr), pMcastAddr))
14777 {
14778 if (pHead == pNode)
14779 {
14780 rmcSession[index] = pNode->next;
14781 }
14782 else
14783 {
14784 pPrev->next = pNode->next;
14785 }
14786 vos_mem_free((v_VOID_t * )pNode);
14787 return 1;
14788 }
14789 pPrev = pNode;
14790 pNode = pNode->next;
14791 }
14792
14793 return 0;
14794}
14795
14796VOS_STATUS
14797WLANTL_ProcessRmcCommand
14798(
14799 WLANTL_CbType* pTLCb,
14800 v_MACADDR_t *pMcastAddr,
14801 tANI_U32 command
14802)
14803{
14804 VOS_STATUS status;
14805 tANI_U32 count;
14806 tANI_U32 rmcActive;
14807
14808 if (!VOS_IS_STATUS_SUCCESS(vos_lock_acquire( &(pTLCb->rmcLock))))
14809 {
14810 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
14811 "%s Get Lock Fail", __func__));
14812 return VOS_STATUS_E_FAILURE;
14813 }
14814
14815 /*add or delete node from active rmc hash table*/
14816 if (command)
14817 {
14818 /*add requested rmc session in active rmc session list*/
14819 if (WLANTL_RmcAddRmcSession(pTLCb->rmcSession, pMcastAddr))
14820 {
14821 TLLOGE( VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
14822 "RMC session " MAC_ADDRESS_STR " added in TL hash table",
14823 MAC_ADDR_ARRAY(pMcastAddr->bytes) ) );
14824 pTLCb->rmcDataPathEnabled = TRUE;
14825 status = VOS_STATUS_SUCCESS;
14826 }
14827 else
14828 {
14829 TLLOGE( VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
14830 "RMC session " MAC_ADDRESS_STR " already exists in TL hash"
14831 " table", MAC_ADDR_ARRAY(pMcastAddr->bytes) ) );
14832 status = VOS_STATUS_E_FAILURE;
14833 }
14834 }
14835 else
14836 {
14837 /*delete requested rmc session from active rmc session list*/
14838 if (WLANTL_RmcDeleteRmcSession(pTLCb->rmcSession, pMcastAddr))
14839 {
14840 TLLOGE( VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
14841 "RMC session " MAC_ADDRESS_STR " deleted from TL hash table",
14842 MAC_ADDR_ARRAY(pMcastAddr->bytes)) );
14843 status = VOS_STATUS_SUCCESS;
14844 rmcActive = FALSE;
14845 for ( count = 0; count < WLANTL_RMC_HASH_TABLE_SIZE; count++ )
14846 {
14847 if (pTLCb->rmcSession[count])
14848 {
14849 rmcActive = TRUE;
14850 break;
14851 }
14852 }
14853 if (TRUE == rmcActive)
14854 {
14855 pTLCb->rmcDataPathEnabled = TRUE;
14856 }
14857 else
14858 {
14859 pTLCb->rmcDataPathEnabled = FALSE;
14860 }
14861 }
14862 else
14863 {
14864 TLLOGE( VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
14865 "RMC session " MAC_ADDRESS_STR " doesn't exist in TL hash"
14866 " table", MAC_ADDR_ARRAY(pMcastAddr->bytes) ) );
14867 status = VOS_STATUS_E_FAILURE;
14868 }
14869 }
14870
14871 if (!VOS_IS_STATUS_SUCCESS(vos_lock_release(&(pTLCb->rmcLock))))
14872 {
14873 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
14874 "%s Release Lock Fail", __func__));
14875 return VOS_STATUS_E_FAILURE;
14876 }
14877
14878 return status;
14879}/* End of WLANTL_ProcessRmcCommand */
14880
14881VOS_STATUS
14882WLANTL_EnableRMC
14883(
14884 v_PVOID_t pvosGCtx,
14885 v_MACADDR_t *pMcastTransmitterAddr
14886)
14887{
14888 WLANTL_CbType* pTLCb;
14889 VOS_STATUS status;
14890
14891 /*sanity check*/
14892 if ( (NULL == pvosGCtx) || (NULL == pMcastTransmitterAddr) )
14893 {
14894 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Jeff Johnsonddec6482017-09-19 08:33:57 -070014895 "WLAN TL %s: Sanity check failed pvosGCtx %pK aMcastAddr %pK",
Abhishek Singh00b71972016-01-07 10:51:04 +053014896 __func__, pvosGCtx, pMcastTransmitterAddr));
14897 return VOS_STATUS_E_FAILURE;
14898 }
14899
14900 /*sanity check*/
14901 pTLCb = VOS_GET_TL_CB(pvosGCtx);
14902 if ( NULL == pTLCb )
14903 {
14904 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
14905 "WLAN TL %s: pTLCb is NULL", __func__));
14906 return VOS_STATUS_E_FAILURE;
14907 }
14908
14909 status = WLANTL_ProcessRmcCommand(pTLCb, pMcastTransmitterAddr , 1);
14910
14911 return status;
14912} /* End of WLANTL_EnableRMC */
14913
14914
14915VOS_STATUS
14916WLANTL_DisableRMC
14917(
14918 v_PVOID_t pvosGCtx,
14919 v_MACADDR_t *pMcastTransmitterAddr
14920)
14921{
14922 WLANTL_CbType* pTLCb;
14923 VOS_STATUS status;
14924
14925 /*Sanity check*/
14926 if ((NULL == pvosGCtx) || (NULL == pMcastTransmitterAddr))
14927 {
14928 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Jeff Johnsonddec6482017-09-19 08:33:57 -070014929 "WLAN TL %s: Sanity check failed pvosGCtx %pK aMcastAddr %pK",
Abhishek Singh00b71972016-01-07 10:51:04 +053014930 __func__, pvosGCtx, pMcastTransmitterAddr));
14931 return VOS_STATUS_E_FAILURE;
14932 }
14933
14934 /*Sanity check*/
14935 pTLCb = VOS_GET_TL_CB(pvosGCtx);
14936 if (NULL == pTLCb)
14937 {
14938 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
14939 "WLAN TL %s: pTLCb is NULL", __func__));
14940 return VOS_STATUS_E_FAILURE;
14941 }
14942
14943 status = WLANTL_ProcessRmcCommand(pTLCb, pMcastTransmitterAddr, 0);
14944
14945 return status;
14946} /* End of WLANTL_DisableRMC */
14947
14948
14949/*=============================================================================
14950 Duplicate Multicast Detection Functions
14951==============================================================================*/
14952
14953/*=============================================================================
14954 FUNCTION WLANTL_IsDuplicateMcastFrm
14955
14956 DESCRIPTION
14957 This function checks for duplicast multicast frames and drops them.
14958
14959 DEPENDENCIES
14960
14961 PARAMETERS
14962
14963 IN
14964
14965 pClientSTA : Pointer to WLANTL_STAClientType
14966 aucBDHeader : Pointer to BD header
14967
14968 RETURN VALUE
14969
14970 VOS_FALSE: This frame is not a duplicate
14971
14972 VOS_TRUE: This frame is a duplicate
14973
14974==============================================================================*/
14975v_U8_t
14976WLANTL_IsDuplicateMcastFrm
14977(
14978 WLANTL_STAClientType *pClientSTA,
14979 vos_pkt_t *vosDataBuff
14980)
14981{
14982 v_U8_t duplicate = VOS_FALSE;
14983 WLANTL_RMC_SESSION *pNode;
14984 v_U16_t usSeqCtrl;
14985 v_MACADDR_t mcastAddr;
14986 VOS_STATUS vosStatus;
14987 v_PVOID_t pvPeekData;
14988
14989 /* Get address 1 of Data Frame */
14990 vosStatus = vos_pkt_peek_data(vosDataBuff, WLANTL_MAC_ADDR_ALIGN(1),
14991 (v_PVOID_t)&pvPeekData, VOS_MAC_ADDR_SIZE);
14992
14993 if ( VOS_STATUS_SUCCESS != vosStatus )
14994 {
14995 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
14996 "WLAN TL: Failed to get Addr 1 of 80211 header from packet %d",
14997 vosStatus));
14998 return VOS_FALSE;
14999 }
15000
15001 /* Copy address 1 of Data Frame */
15002 vos_mem_copy(&mcastAddr.bytes, pvPeekData, VOS_MAC_ADDR_SIZE);
15003
15004 /*
15005 * We perform duplicate detection for only multicast data frames
15006 */
15007 if (vos_is_macaddr_group(&mcastAddr) &&
15008 !vos_is_macaddr_broadcast(&mcastAddr))
15009 {
15010 /* Get sequence control of Data Frame */
15011 vosStatus = vos_pkt_peek_data(vosDataBuff,
15012 (WLANTL_MAC_ADDR_ALIGN(1) + (3 * VOS_MAC_ADDR_SIZE)),
15013 (v_PVOID_t)&pvPeekData, sizeof(v_U16_t));
15014
15015 if ( VOS_STATUS_SUCCESS != vosStatus )
15016 {
15017 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
15018 "WLAN TL: Failed to get Sequence Control from packet %d",
15019 vosStatus));
15020 return VOS_FALSE;
15021 }
15022
15023 /* Copy sequence control from the Data Frame */
15024 usSeqCtrl = *(v_U16_t *)pvPeekData;
15025
15026 if (!VOS_IS_STATUS_SUCCESS(vos_lock_acquire(&(pClientSTA->mcLock))))
15027 {
15028 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
15029 "%s Get Lock Fail", __func__));
15030 return VOS_FALSE;
15031 }
15032
15033 pNode = WLANTL_RmcLookUpRmcSession(pClientSTA->mcastSession,
15034 &mcastAddr);
15035 if (NULL == pNode)
15036 {
15037 /* If the session does not exist, add it. */
15038 pNode = WLANTL_RmcAddRmcSession(pClientSTA->mcastSession,
15039 &mcastAddr);
15040 /* If we could not add a entry, skip duplicate detection */
15041 if (NULL == pNode)
15042 {
15043 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
15044 "%s Failed to add multicast session", __func__));
15045 if (!VOS_IS_STATUS_SUCCESS
15046 (vos_lock_release(&(pClientSTA->mcLock))))
15047 {
15048 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
15049 "%s Release Lock Fail", __func__));
15050 }
15051 return VOS_FALSE;
15052 }
15053 /* Initialize the sequence control value. */
15054 pNode->mcSeqCtl = usSeqCtrl;
15055 }
15056 else
15057 {
15058 /*
15059 * Check if the sequence number of this frame matches the last
15060 * we have seen.
15061 */
15062 if (pNode->mcSeqCtl == usSeqCtrl)
15063 {
15064 pNode->rxMCDupcnt++;
15065 TLLOG1(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
15066 "%s Rx Multicast Duplicate %d " MAC_ADDRESS_STR
15067 " (Seq %x)", __func__,
15068 pNode->rxMCDupcnt, MAC_ADDR_ARRAY(mcastAddr.bytes),
15069 usSeqCtrl));
15070 duplicate = VOS_TRUE;
15071 }
15072 else
15073 {
15074 /* Update the last seen sequence number */
15075 pNode->mcSeqCtl = usSeqCtrl;
15076 }
15077 }
15078
15079 if (!VOS_IS_STATUS_SUCCESS (vos_lock_release(&(pClientSTA->mcLock))))
15080 {
15081 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
15082 "%s Release Lock Fail", __func__));
15083 }
15084 }
15085
15086 return duplicate;
15087}
15088
15089/*=============================================================================
15090 FUNCTION WLANTL_McastDeleteAllEntries
15091
15092 DESCRIPTION
15093 This function removes all multicast entries used for duplicate detection
15094
15095 DEPENDENCIES
15096
15097 PARAMETERS
15098
15099 IN
15100
15101 pClientSTA : Pointer to WLANTL_STAClientType
15102
15103 RETURN VALUE
15104
15105 None
15106
15107==============================================================================*/
15108void
15109WLANTL_McastDeleteAllEntries(WLANTL_STAClientType * pClientSTA)
15110{
15111 WLANTL_RMC_SESSION *pNode, **head;
15112 int index;
15113
15114 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
15115 "%s Deleting all multicast entries", __func__));
15116
15117 if (!VOS_IS_STATUS_SUCCESS(vos_lock_acquire(&(pClientSTA->mcLock))))
15118 {
15119 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
15120 "%s Get Lock Fail", __func__));
15121 return;
15122 }
15123
15124 for (index = 0; index < WLANTL_RMC_HASH_TABLE_SIZE; index++)
15125 {
15126 head = &pClientSTA->mcastSession[index];
15127
15128 pNode = *head;
15129
15130 while (pNode)
15131 {
15132 *head = pNode->next;
15133 /* free the group entry */
15134 vos_mem_free(pNode);
15135 pNode = *head;
15136 }
15137 }
15138
15139 if (!VOS_IS_STATUS_SUCCESS (vos_lock_release(&(pClientSTA->mcLock))))
15140 {
15141 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
15142 "%s Release Lock Fail", __func__));
15143 }
15144}
15145
15146/*=============================================================================
15147 FUNCTION WLANTL_SetMcastDuplicateDetection
15148
15149 DESCRIPTION
15150 This function sets multicate duplicate detection operation.
15151 If enable is 1, the detection is enabled, else it is disabled.
15152
15153 DEPENDENCIES
15154
15155 PARAMETERS
15156
15157 IN
15158
15159 pvosGCtx : Pointer to VOS global context
15160 enable : Boolean to enable or disable
15161
15162 RETURN VALUE
15163 The result code associated with performing the operation
15164
15165 VOS_STATUS_E_FAULT: Sanity check on input failed
15166
15167 VOS_STATUS_SUCCESS: Everything is good :)
15168
15169 Other return values are possible coming from the called functions.
15170 Please check API for additional info.
15171
15172 SIDE EFFECTS
15173
15174==============================================================================*/
15175VOS_STATUS
15176WLANTL_SetMcastDuplicateDetection
15177(
15178 v_PVOID_t pvosGCtx,
15179 v_U8_t enable
15180)
15181{
15182 WLANTL_CbType* pTLCb;
15183
15184 /*Sanity check*/
15185 if (NULL == pvosGCtx)
15186 {
15187 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Jeff Johnsonddec6482017-09-19 08:33:57 -070015188 "WLAN TL %s: Sanity check failed pvosGCtx %pK",
Abhishek Singh00b71972016-01-07 10:51:04 +053015189 __func__, pvosGCtx));
15190 return VOS_STATUS_E_FAILURE;
15191 }
15192
15193 /*Sanity check*/
15194 pTLCb = VOS_GET_TL_CB(pvosGCtx);
15195 if (NULL == pTLCb)
15196 {
15197 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
15198 "WLAN TL %s: pTLCb is NULL", __func__));
15199 return VOS_STATUS_E_FAILURE;
15200 }
15201
15202 switch (enable)
15203 {
15204 default:
15205 /*
15206 * Any value other than 0 or 1 is used to dump the
15207 * duplicate count.
15208 */
15209 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
15210 "WLAN TL %s: Multicast Duplicate Count %d",
15211 __func__, pTLCb->mcastDupCnt));
15212 break;
15213 case 0:
15214 case 1:
15215 pTLCb->multicastDuplicateDetectionEnabled = enable;
15216 break;
15217 }
15218
15219 return VOS_STATUS_SUCCESS;
15220}
15221
15222#endif /* WLAN_FEATURE_RMC */