blob: 6846f66efb1c3b6c4e593b77582120c20c49ecc7 [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
725 /*------------------------------------------------------------------------
726 Allocate internal resources
727 ------------------------------------------------------------------------*/
728 vos_pkt_get_packet(&pTLCb->vosDummyBuf, VOS_PKT_TYPE_RX_RAW, 1, 1,
729 1/*true*/,NULL, NULL);
730
731 WLANTL_InitBAReorderBuffer(pvosGCtx);
732#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
733 /* Initialize Handoff support modue
734 * RSSI measure and Traffic state monitoring */
735 status = WLANTL_HSInit(pvosGCtx);
736 if(!VOS_IS_STATUS_SUCCESS(status))
737 {
738 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
739 "Handoff support module init fail"));
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +0530740 WLANTL_FreeClientMemory(pTLCb->atlSTAClients);
Sushant Kaushikf4a27972015-04-16 16:48:00 +0530741 vos_mem_vfree(pTLCb->reorderBufferPool);
Jeff Johnson295189b2012-06-20 16:38:30 -0700742 vos_free_context(pvosGCtx, VOS_MODULE_ID_TL, pTLCb);
743 return status;
744 }
745#endif
746
Abhishek Singh00b71972016-01-07 10:51:04 +0530747#ifdef WLAN_FEATURE_RMC
748 status = WLANTL_RmcInit(pvosGCtx);
749 if (!VOS_IS_STATUS_SUCCESS(status))
750 {
751 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
752 "RMC module init fail"));
753 return status;
754 }
755#endif
756
Jeff Johnson295189b2012-06-20 16:38:30 -0700757 pTLCb->isBMPS = VOS_FALSE;
758 pmcRegisterDeviceStateUpdateInd( smeContext,
759 WLANTL_PowerStateChangedCB, pvosGCtx );
760
761 return VOS_STATUS_SUCCESS;
762}/* WLANTL_Open */
763
764/*==========================================================================
765
766 FUNCTION WLANTL_Start
767
768 DESCRIPTION
769 Called by HDD as part of the overall start procedure. TL will use this
770 call to register with BAL as a transport layer entity.
771
772 DEPENDENCIES
773
774 PARAMETERS
775
776 IN
777 pvosGCtx: pointer to the global vos context; a handle to TL's
778 control block can be extracted from its context
779
780 RETURN VALUE
781 The result code associated with performing the operation
782
783 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a page
784 fault
785 VOS_STATUS_SUCCESS: Everything is good :)
786
787 Other codes can be returned as a result of a BAL failure; see BAL API
788 for more info
789
790 SIDE EFFECTS
791
792============================================================================*/
793VOS_STATUS
794WLANTL_Start
795(
796 v_PVOID_t pvosGCtx
797)
798{
799 WLANTL_CbType* pTLCb = NULL;
800 v_U32_t uResCount = WDA_TLI_MIN_RES_DATA;
801 VOS_STATUS vosStatus;
802 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
803
804 /*------------------------------------------------------------------------
805 Sanity check
806 Extract TL control block
807 ------------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +0530808 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -0700809 pTLCb = VOS_GET_TL_CB(pvosGCtx);
810 if ( NULL == pTLCb )
811 {
812 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
813 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_Start"));
814 return VOS_STATUS_E_FAULT;
815 }
816
817 /*------------------------------------------------------------------------
818 Register with WDA as transport layer client
819 Request resources for tx from bus
820 ------------------------------------------------------------------------*/
821 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
822 "WLAN TL:WLAN TL:WLANTL_Start"));
823
Katya Nigam42e16e82014-02-04 16:28:55 +0530824 tlTraceInit();
Jeff Johnson295189b2012-06-20 16:38:30 -0700825 vosStatus = WDA_DS_Register( pvosGCtx,
826 WLANTL_TxComp,
827 WLANTL_RxFrames,
828 WLANTL_GetFrames,
829 WLANTL_ResourceCB,
830 WDA_TLI_MIN_RES_DATA,
831 pvosGCtx,
832 &uResCount );
833
834 if ( VOS_STATUS_SUCCESS != vosStatus )
835 {
836 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
837 "WLAN TL:TL failed to register with BAL/WDA, Err: %d",
838 vosStatus));
839 return vosStatus;
840 }
841
842 /* Enable transmission */
843 vos_atomic_set_U8( &pTLCb->ucTxSuspended, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700844 pTLCb->uResCount = uResCount;
Sravan Kumar Kairam60b8cf02016-12-12 16:22:09 +0530845
846 vos_timer_start(&pTLCb->tx_frames_timer, WLANTL_SAMPLE_INTERVAL);
847
Jeff Johnson295189b2012-06-20 16:38:30 -0700848 return VOS_STATUS_SUCCESS;
849}/* WLANTL_Start */
850
851/*==========================================================================
852
853 FUNCTION WLANTL_Stop
854
855 DESCRIPTION
856 Called by HDD to stop operation in TL, before close. TL will suspend all
857 frame transfer operation and will wait for the close request to clean up
858 its resources.
859
860 DEPENDENCIES
861
862 PARAMETERS
863
864 IN
865 pvosGCtx: pointer to the global vos context; a handle to TL's
866 control block can be extracted from its context
867
868 RETURN VALUE
869 The result code associated with performing the operation
870
871 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a page
872 fault
873 VOS_STATUS_SUCCESS: Everything is good :)
874
875 SIDE EFFECTS
876
877============================================================================*/
878VOS_STATUS
879WLANTL_Stop
880(
881 v_PVOID_t pvosGCtx
882)
883{
884 WLANTL_CbType* pTLCb = NULL;
885 v_U8_t ucIndex;
886 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
887
888 /*------------------------------------------------------------------------
889 Sanity check
890 Extract TL control block
891 ------------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +0530892 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -0700893 pTLCb = VOS_GET_TL_CB(pvosGCtx);
894 if ( NULL == pTLCb )
895 {
896 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
897 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_ChangeSTAState"));
898 return VOS_STATUS_E_FAULT;
899 }
900
901 /*------------------------------------------------------------------------
902 Stop TL and empty Station list
903 ------------------------------------------------------------------------*/
904 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
905 "WLAN TL:WLANTL_Stop"));
906
907 /* Disable transmission */
908 vos_atomic_set_U8( &pTLCb->ucTxSuspended, 1);
909
910 if ( NULL != pTLCb->tlMgmtFrmClient.vosPendingDataBuff )
911 {
912 vos_pkt_return_packet(pTLCb->tlMgmtFrmClient.vosPendingDataBuff);
913 pTLCb->tlMgmtFrmClient.vosPendingDataBuff = NULL;
914 }
915
916 if ( NULL != pTLCb->tlBAPClient.vosPendingDataBuff )
917 {
918 vos_pkt_return_packet(pTLCb->tlBAPClient.vosPendingDataBuff);
919 pTLCb->tlBAPClient.vosPendingDataBuff = NULL;
920 }
921
922#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
923 if(VOS_STATUS_SUCCESS != WLANTL_HSStop(pvosGCtx))
924 {
925 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
926 "Handoff Support module stop fail"));
927 }
928#endif
929
Sravan Kumar Kairam60b8cf02016-12-12 16:22:09 +0530930 if (VOS_TIMER_STATE_STOPPED !=
931 vos_timer_getCurrentState(&pTLCb->tx_frames_timer))
932 vos_timer_stop(&pTLCb->tx_frames_timer);
933
Jeff Johnson295189b2012-06-20 16:38:30 -0700934 /*-------------------------------------------------------------------------
935 Clean client stations
936 -------------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +0530937 for ( ucIndex = 0; ucIndex < WLAN_MAX_STA_COUNT; ucIndex++)
Jeff Johnson295189b2012-06-20 16:38:30 -0700938 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +0530939 if ( NULL != pTLCb->atlSTAClients[ucIndex] )
940 {
941 WLANTL_CleanSTA(pTLCb->atlSTAClients[ucIndex], 1 /*empty all queues*/);
942 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700943 }
944
945
946 return VOS_STATUS_SUCCESS;
947}/* WLANTL_Stop */
948
949/*==========================================================================
950
951 FUNCTION WLANTL_Close
952
953 DESCRIPTION
954 Called by HDD during general driver close procedure. TL will clean up
955 all the internal resources.
956
957 DEPENDENCIES
958
959 PARAMETERS
960
961 IN
962 pvosGCtx: pointer to the global vos context; a handle to TL's
963 control block can be extracted from its context
964
965 RETURN VALUE
966 The result code associated with performing the operation
967
968 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a page
969 fault
970 VOS_STATUS_SUCCESS: Everything is good :)
971
972 SIDE EFFECTS
973
974============================================================================*/
975VOS_STATUS
976WLANTL_Close
977(
978 v_PVOID_t pvosGCtx
979)
980{
981 WLANTL_CbType* pTLCb = NULL;
982 tHalHandle smeContext;
983 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
984
985 /*------------------------------------------------------------------------
986 Sanity check
987 Extract TL control block
988 ------------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +0530989 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -0700990 pTLCb = VOS_GET_TL_CB(pvosGCtx);
991 if ( NULL == pTLCb )
992 {
993 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
994 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_ChangeSTAState"));
995 return VOS_STATUS_E_FAULT;
996 }
997 /*------------------------------------------------------------------------
998 Deregister from PMC
999 ------------------------------------------------------------------------*/
1000 smeContext = vos_get_context(VOS_MODULE_ID_SME, pvosGCtx);
1001 if ( NULL == smeContext )
1002 {
1003 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001004 "%s: Invalid smeContext", __func__));
Jeff Johnson295189b2012-06-20 16:38:30 -07001005 // continue so that we can cleanup as much as possible
1006 }
1007 else
1008 {
1009 pmcDeregisterDeviceStateUpdateInd( smeContext, WLANTL_PowerStateChangedCB );
1010 }
1011
1012#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
1013 if(VOS_STATUS_SUCCESS != WLANTL_HSDeInit(pvosGCtx))
1014 {
1015 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
1016 "Handoff Support module DeInit fail"));
1017 }
1018#endif
1019
Abhishek Singh00b71972016-01-07 10:51:04 +05301020#ifdef WLAN_FEATURE_RMC
1021 if(VOS_STATUS_SUCCESS != WLANTL_RmcDeInit(pvosGCtx))
1022 {
1023 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
1024 "RMC module DeInit fail"));
1025 }
1026#endif
1027
Sravan Kumar Kairam60b8cf02016-12-12 16:22:09 +05301028 if (VOS_TIMER_STATE_RUNNING ==
1029 vos_timer_getCurrentState(&pTLCb->tx_frames_timer)) {
1030 vos_timer_stop(&pTLCb->tx_frames_timer);
1031 }
1032 if (!VOS_IS_STATUS_SUCCESS(vos_timer_destroy(&pTLCb->tx_frames_timer))) {
1033 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1034 "%s: Cannot deallocate TX frames sample timer", __func__));
1035 }
1036
Jeff Johnson295189b2012-06-20 16:38:30 -07001037 /*------------------------------------------------------------------------
1038 Cleanup TL control block.
1039 ------------------------------------------------------------------------*/
1040 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
1041 "WLAN TL: WLANTL_Close"));
1042 WLANTL_CleanCB(pTLCb, 1 /* empty queues/lists/pkts if any*/);
1043
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301044 WLANTL_FreeClientMemory(pTLCb->atlSTAClients);
1045
Sushant Kaushikf4a27972015-04-16 16:48:00 +05301046 vos_mem_vfree(pTLCb->reorderBufferPool);
Jeff Johnson295189b2012-06-20 16:38:30 -07001047
1048 /*------------------------------------------------------------------------
1049 Free TL context from VOSS global
1050 ------------------------------------------------------------------------*/
1051 vos_free_context(pvosGCtx, VOS_MODULE_ID_TL, pTLCb);
1052 return VOS_STATUS_SUCCESS;
1053}/* WLANTL_Close */
1054
1055/*----------------------------------------------------------------------------
1056 INTERACTION WITH HDD
1057 ---------------------------------------------------------------------------*/
1058/*==========================================================================
1059
1060 FUNCTION WLANTL_ConfigureSwFrameTXXlationForAll
1061
1062 DESCRIPTION
1063 Function to disable/enable frame translation for all association stations.
1064
1065 DEPENDENCIES
1066
1067 PARAMETERS
1068 IN
1069 pvosGCtx: VOS context
1070 EnableFrameXlation TRUE means enable SW translation for all stations.
1071 .
1072
1073 RETURN VALUE
1074
1075 void.
1076
1077============================================================================*/
1078void
1079WLANTL_ConfigureSwFrameTXXlationForAll
1080(
1081 v_PVOID_t pvosGCtx,
1082 v_BOOL_t enableFrameXlation
1083)
1084{
1085 v_U8_t ucIndex;
1086 /*------------------------------------------------------------------------
1087 Extract TL control block
1088 ------------------------------------------------------------------------*/
1089 WLANTL_CbType* pTLCb = VOS_GET_TL_CB(pvosGCtx);
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301090 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07001091 if ( NULL == pTLCb )
1092 {
1093 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1094 "WLAN TL:Invalid TL pointer from pvosGCtx on "
1095 "WLANTL_ConfigureSwFrameTXXlationForAll"));
1096 return;
1097 }
1098
1099 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
1100 "WLANTL_ConfigureSwFrameTXXlationForAll: Configure SW frameXlation %d",
1101 enableFrameXlation));
1102
1103 for ( ucIndex = 0; ucIndex < WLAN_MAX_TID; ucIndex++)
1104 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301105 pClientSTA = pTLCb->atlSTAClients[ucIndex];
1106 if ( NULL != pClientSTA && 0 != pClientSTA->ucExists )
Jeff Johnson295189b2012-06-20 16:38:30 -07001107 {
1108#ifdef WLAN_SOFTAP_VSTA_FEATURE
1109 // if this station was not allocated resources to perform HW-based
1110 // TX frame translation then force SW-based TX frame translation
1111 // otherwise use the frame translation supplied by the client
1112 if (!WDA_IsHwFrameTxTranslationCapable(pvosGCtx, ucIndex))
1113 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301114 pClientSTA->wSTADesc.ucSwFrameTXXlation = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07001115 }
1116 else
1117#endif
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301118 pClientSTA->wSTADesc.ucSwFrameTXXlation = enableFrameXlation;
Jeff Johnson295189b2012-06-20 16:38:30 -07001119 }
1120 }
1121}
1122
1123/*===========================================================================
1124
1125 FUNCTION WLANTL_StartForwarding
1126
1127 DESCRIPTION
1128
1129 This function is used to ask serialization through TX thread of the
1130 cached frame forwarding (if statation has been registered in the mean while)
1131 or flushing (if station has not been registered by the time)
1132
1133 In case of forwarding, upper layer is only required to call WLANTL_RegisterSTAClient()
1134 and doesn't need to call this function explicitly. TL will handle this inside
1135 WLANTL_RegisterSTAClient().
1136
1137 In case of flushing, upper layer is required to call this function explicitly
1138
1139 DEPENDENCIES
1140
1141 TL must have been initialized before this gets called.
1142
1143
1144 PARAMETERS
1145
1146 ucSTAId: station id
1147
1148 RETURN VALUE
1149
1150 The result code associated with performing the operation
1151 Please check return values of vos_tx_mq_serialize.
1152
1153 SIDE EFFECTS
1154 If TL was asked to perform WLANTL_CacheSTAFrame() in WLANTL_RxFrames(),
1155 either WLANTL_RegisterSTAClient() or this function must be called
1156 within reasonable time. Otherwise, TL will keep cached vos buffer until
1157 one of this function is called, and may end up with system buffer exhasution.
1158
1159 It's an upper layer's responsibility to call this function in case of
1160 flushing
1161
1162============================================================================*/
1163
1164VOS_STATUS
1165WLANTL_StartForwarding
1166(
1167 v_U8_t ucSTAId,
1168 v_U8_t ucUcastSig,
1169 v_U8_t ucBcastSig
1170)
1171{
1172 vos_msg_t sMessage;
1173 v_U32_t uData;
1174 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
1175
1176 /* Signal the OS to serialize our event */
1177 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
1178 "Serializing TL Start Forwarding Cached for control STA %d",
1179 ucSTAId );
1180
1181 vos_mem_zero( &sMessage, sizeof(vos_msg_t) );
1182
1183 uData = ucSTAId | (ucUcastSig << 8 ) | (ucBcastSig << 16);
Jeff Johnsond86c05a2013-11-10 18:50:34 -08001184 sMessage.bodyval = uData;
Katya Nigam664f5032014-05-05 12:24:32 +05301185 sMessage.type = WLANTL_RX_FWD_CACHED;
Jeff Johnson295189b2012-06-20 16:38:30 -07001186
Katya Nigam664f5032014-05-05 12:24:32 +05301187 return vos_rx_mq_serialize(VOS_MQ_ID_TL, &sMessage);
Jeff Johnson295189b2012-06-20 16:38:30 -07001188
1189} /* WLANTL_StartForwarding() */
1190
1191/*===========================================================================
1192
Katya Nigam63902932014-06-26 19:04:23 +05301193 FUNCTION WLANTL_EnableCaching
1194
1195 DESCRIPTION
1196
1197 This function is used to enable caching only when assoc/reassoc req is send.
1198 that is cache packets only for such STA ID.
1199
1200
1201 DEPENDENCIES
1202
1203 TL must have been initialized before this gets called.
1204
1205
1206 PARAMETERS
1207
1208 staId: station id
1209
1210 RETURN VALUE
1211
1212 none
1213
1214============================================================================*/
1215void WLANTL_EnableCaching(v_U8_t staId)
1216{
1217 v_PVOID_t pvosGCtx= vos_get_global_context(VOS_MODULE_ID_TL,NULL);
1218 WLANTL_CbType* pTLCb = VOS_GET_TL_CB(pvosGCtx);
1219 if ( NULL == pTLCb )
1220 {
1221 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1222 "WLAN TL:Invalid TL pointer from pvosGCtx on "
1223 "WLANTL_EnableCaching"));
1224 return;
1225 }
1226 pTLCb->atlSTAClients[staId]->enableCaching = 1;
1227}
1228
1229/*===========================================================================
1230
Jeff Johnson295189b2012-06-20 16:38:30 -07001231 FUNCTION WLANTL_AssocFailed
1232
1233 DESCRIPTION
1234
1235 This function is used by PE to notify TL that cache needs to flushed'
1236 when association is not successfully completed
1237
1238 Internally, TL post a message to TX_Thread to serialize the request to
1239 keep lock-free mechanism.
1240
1241
1242 DEPENDENCIES
1243
1244 TL must have been initialized before this gets called.
1245
1246
1247 PARAMETERS
1248
1249 ucSTAId: station id
1250
1251 RETURN VALUE
1252
1253 none
1254
1255 SIDE EFFECTS
1256 There may be race condition that PE call this API and send another association
1257 request immediately with same staId before TX_thread can process the message.
1258
1259 To avoid this, we might need PE to wait for TX_thread process the message,
1260 but this is not currently implemented.
1261
1262============================================================================*/
1263void WLANTL_AssocFailed(v_U8_t staId)
1264{
1265 // flushing frames and forwarding frames uses the same message
1266 // the only difference is what happens when the message is processed
1267 // if the STA exist, the frames will be forwarded
1268 // and if it doesn't exist, the frames will be flushed
1269 // in this case we know it won't exist so the DPU index signature values don't matter
Mihir Sheteae6f02b2014-04-11 19:49:21 +05301270 MTRACE(vos_trace(VOS_MODULE_ID_TL, TRACE_CODE_TL_ASSOC_FAILED,
1271 staId, 0));
1272
Jeff Johnson295189b2012-06-20 16:38:30 -07001273 if(!VOS_IS_STATUS_SUCCESS(WLANTL_StartForwarding(staId,0,0)))
1274 {
1275 VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Mihir Sheteb7337272014-04-11 15:53:08 +05301276 " %s fails to start forwarding (staId %d)", __func__, staId);
Jeff Johnson295189b2012-06-20 16:38:30 -07001277 }
1278}
Nirav Shah4f765af2015-01-21 19:51:30 +05301279
Nirav Shah4b53d4b2015-05-08 05:35:00 -07001280 /*===========================================================================
Jeff Johnson295189b2012-06-20 16:38:30 -07001281
1282 FUNCTION WLANTL_Finish_ULA
1283
1284 DESCRIPTION
1285 This function is used by HDD to notify TL to finish Upper layer authentication
1286 incase the last EAPOL packet is pending in the TL queue.
1287 To avoid the race condition between sme set key and the last EAPOL packet
1288 the HDD module calls this function just before calling the sme_RoamSetKey.
1289
1290 DEPENDENCIES
1291
1292 TL must have been initialized before this gets called.
Nirav Shah4f765af2015-01-21 19:51:30 +05301293
Jeff Johnson295189b2012-06-20 16:38:30 -07001294 PARAMETERS
1295
Nirav Shah4b53d4b2015-05-08 05:35:00 -07001296 callbackRoutine: HDD Callback function.
1297 callbackContext : HDD userdata context.
Nirav Shah4f765af2015-01-21 19:51:30 +05301298
Jeff Johnson295189b2012-06-20 16:38:30 -07001299 RETURN VALUE
1300
1301 VOS_STATUS_SUCCESS/VOS_STATUS_FAILURE
Nirav Shah4f765af2015-01-21 19:51:30 +05301302
Jeff Johnson295189b2012-06-20 16:38:30 -07001303 SIDE EFFECTS
Nirav Shah4f765af2015-01-21 19:51:30 +05301304
Jeff Johnson295189b2012-06-20 16:38:30 -07001305============================================================================*/
1306
1307VOS_STATUS WLANTL_Finish_ULA( void (*callbackRoutine) (void *callbackContext),
Nirav Shah4b53d4b2015-05-08 05:35:00 -07001308 void *callbackContext)
Jeff Johnson295189b2012-06-20 16:38:30 -07001309{
Nirav Shah4b53d4b2015-05-08 05:35:00 -07001310 return WDA_DS_FinishULA( callbackRoutine, callbackContext);
Nirav Shah4f765af2015-01-21 19:51:30 +05301311}
Jeff Johnson295189b2012-06-20 16:38:30 -07001312
Nirav Shah4b53d4b2015-05-08 05:35:00 -07001313
Jeff Johnson295189b2012-06-20 16:38:30 -07001314/*===========================================================================
1315
1316 FUNCTION WLANTL_RegisterSTAClient
1317
1318 DESCRIPTION
1319
1320 This function is used by HDD to register as a client for data services
1321 with TL. HDD will call this API for each new station that it adds,
1322 thus having the flexibility of registering different callback for each
1323 STA it services.
1324
1325 DEPENDENCIES
1326
1327 TL must have been initialized before this gets called.
1328
1329 Restriction:
1330 Main thread will have higher priority that Tx and Rx threads thus
1331 guaranteeing that a station will be added before any data can be
1332 received for it. (This enables TL to be lock free)
1333
1334 PARAMETERS
1335
1336 pvosGCtx: pointer to the global vos context; a handle to TL's
1337 control block can be extracted from its context
1338 pfnStARx: function pointer to the receive packet handler from HDD
1339 pfnSTATxComp: function pointer to the transmit complete confirmation
1340 handler from HDD
1341 pfnSTAFetchPkt: function pointer to the packet retrieval routine in HDD
1342 wSTADescType: STA Descriptor, contains information related to the
1343 new added STA
1344
1345 RETURN VALUE
1346
1347 The result code associated with performing the operation
1348
1349 VOS_STATUS_E_INVAL: Input parameters are invalid
1350 VOS_STATUS_E_FAULT: Station ID is outside array boundaries or pointer to
1351 TL cb is NULL ; access would cause a page fault
1352 VOS_STATUS_E_EXISTS: Station was already registered
1353 VOS_STATUS_SUCCESS: Everything is good :)
1354
1355 SIDE EFFECTS
1356
1357============================================================================*/
1358VOS_STATUS
1359WLANTL_RegisterSTAClient
1360(
1361 v_PVOID_t pvosGCtx,
1362 WLANTL_STARxCBType pfnSTARx,
1363 WLANTL_TxCompCBType pfnSTATxComp,
1364 WLANTL_STAFetchPktCBType pfnSTAFetchPkt,
1365 WLAN_STADescType* pwSTADescType,
1366 v_S7_t rssi
1367)
1368{
1369 WLANTL_CbType* pTLCb = NULL;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301370 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07001371 v_U8_t ucTid = 0;/*Local variable to clear previous replay counters of STA on all TIDs*/
Hanumantha Reddy Pothulaee001fc2015-05-26 15:21:53 +05301372 v_U32_t istoggleArpEnb = 0;
1373 tpAniSirGlobal pMac;
Jeff Johnson295189b2012-06-20 16:38:30 -07001374 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
1375
1376 /*------------------------------------------------------------------------
1377 Sanity check
1378 ------------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301379 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -07001380 if (( NULL == pwSTADescType ) || ( NULL == pfnSTARx ) ||
1381 ( NULL == pfnSTAFetchPkt ))
1382 {
1383 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1384 "WLAN TL:Invalid parameter sent on WLANTL_RegisterSTAClient"));
1385 return VOS_STATUS_E_INVAL;
1386 }
1387
1388 if ( WLANTL_STA_ID_INVALID( pwSTADescType->ucSTAId ) )
1389 {
1390 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1391 "WLAN TL:Invalid station id requested on WLANTL_RegisterSTAClient"));
1392 return VOS_STATUS_E_FAULT;
1393 }
1394
1395 /*------------------------------------------------------------------------
1396 Extract TL control block
1397 ------------------------------------------------------------------------*/
1398 pTLCb = VOS_GET_TL_CB(pvosGCtx);
1399 if ( NULL == pTLCb )
1400 {
1401 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1402 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_RegisterSTAClient"));
1403 return VOS_STATUS_E_FAULT;
1404 }
1405
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301406 //Code for checking and allocating memory for new STA
1407 if ( NULL == pTLCb->atlSTAClients[pwSTADescType->ucSTAId] ){
1408 pTLCb->atlSTAClients[pwSTADescType->ucSTAId] = vos_mem_malloc(sizeof(WLANTL_STAClientType));
1409 if ( NULL == pTLCb->atlSTAClients[pwSTADescType->ucSTAId] ){
1410 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1411 "WLAN TL: STA Client memory allocation failed in WLANTL_RegisterSTAClient"));
1412 return VOS_STATUS_E_FAILURE;
1413 }
1414 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
1415 "WLAN TL: STA Client memory allocation in WLANTL_RegisterSTAClient"));
1416 vos_mem_zero((v_VOID_t *) pTLCb->atlSTAClients[pwSTADescType->ucSTAId],sizeof(WLANTL_STAClientType));
1417 }
1418
1419 //Assigning the pointer to local variable for easy access in future
1420 pClientSTA = pTLCb->atlSTAClients[pwSTADescType->ucSTAId];
1421 if ( 0 != pClientSTA->ucExists )
Jeff Johnson295189b2012-06-20 16:38:30 -07001422 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301423 pClientSTA->ucExists++;
Jeff Johnson295189b2012-06-20 16:38:30 -07001424 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1425 "WLAN TL:Station was already registered on WLANTL_RegisterSTAClient"));
1426 return VOS_STATUS_E_EXISTS;
1427 }
1428
1429 /*------------------------------------------------------------------------
1430 Register station with TL
1431 ------------------------------------------------------------------------*/
Katya Nigam42e16e82014-02-04 16:28:55 +05301432 MTRACE(vos_trace(VOS_MODULE_ID_TL, TRACE_CODE_TL_REGISTER_STA_CLIENT,
1433 pwSTADescType->ucSTAId, (unsigned )
1434 (*(pwSTADescType->vSTAMACAddress.bytes+2)<<24 |
1435 *(pwSTADescType->vSTAMACAddress.bytes+3)<<16 |
1436 *(pwSTADescType->vSTAMACAddress.bytes+4)<<8 |
1437 *(pwSTADescType->vSTAMACAddress.bytes+5))));
1438
Jeff Johnson295189b2012-06-20 16:38:30 -07001439 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
1440 "WLAN TL:Registering STA Client ID: %d", pwSTADescType->ucSTAId ));
1441
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301442 pClientSTA->pfnSTARx = pfnSTARx;
1443 pClientSTA->pfnSTAFetchPkt = pfnSTAFetchPkt;
Jeff Johnson295189b2012-06-20 16:38:30 -07001444
1445 /* Only register if different from NULL - TL default Tx Comp Cb will
1446 release the vos packet */
1447 if ( NULL != pfnSTATxComp )
1448 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301449 pClientSTA->pfnSTATxComp = pfnSTATxComp;
Jeff Johnson295189b2012-06-20 16:38:30 -07001450 }
1451
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301452 pClientSTA->tlState = WLANTL_STA_INIT;
1453 pClientSTA->tlPri = WLANTL_STA_PRI_NORMAL;
1454 pClientSTA->wSTADesc.ucSTAId = pwSTADescType->ucSTAId;
Gopichand Nakkala8b54e912013-03-11 10:44:21 +05301455 pClientSTA->ptkInstalled = 0;
Bhargav Shahfbaeca22016-07-13 10:27:35 +05301456 pClientSTA->disassoc_progress = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001457
Hanumantha Reddy Pothulaee001fc2015-05-26 15:21:53 +05301458 pMac = vos_get_context(VOS_MODULE_ID_PE, pvosGCtx);
1459 if ( NULL != pMac )
1460 {
1461 wlan_cfgGetInt(pMac, WNI_CFG_TOGGLE_ARP_BDRATES, &istoggleArpEnb);
1462 }
Hanumantha Reddy Pothulae5ab23d2015-09-14 18:08:24 +05301463 pClientSTA->arpRate = istoggleArpEnb ? ENABLE_ARP_TOGGLE : DISABLE_ARP_TOGGLE;
1464 pClientSTA->arpOnWQ5 = istoggleArpEnb == SEND_ARP_ON_WQ5;
Hanumantha Reddy Pothulaee001fc2015-05-26 15:21:53 +05301465
Jeff Johnson295189b2012-06-20 16:38:30 -07001466 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
Hanumantha Reddy Pothulaee001fc2015-05-26 15:21:53 +05301467 "WLAN TL:Registering STA Client ID: %d with UC %d and BC %d toggleArp :%hhu",
1468 pwSTADescType->ucSTAId, pwSTADescType->ucUcastSig,
1469 pwSTADescType->ucBcastSig, pClientSTA->arpRate));
Jeff Johnson295189b2012-06-20 16:38:30 -07001470
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301471 pClientSTA->wSTADesc.wSTAType = pwSTADescType->wSTAType;
Jeff Johnson295189b2012-06-20 16:38:30 -07001472
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301473 pClientSTA->wSTADesc.ucQosEnabled = pwSTADescType->ucQosEnabled;
Jeff Johnson295189b2012-06-20 16:38:30 -07001474
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301475 pClientSTA->wSTADesc.ucAddRmvLLC = pwSTADescType->ucAddRmvLLC;
Jeff Johnson295189b2012-06-20 16:38:30 -07001476
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301477 pClientSTA->wSTADesc.ucProtectedFrame = pwSTADescType->ucProtectedFrame;
Jeff Johnson295189b2012-06-20 16:38:30 -07001478
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001479#ifdef FEATURE_WLAN_ESE
1480 pClientSTA->wSTADesc.ucIsEseSta = pwSTADescType->ucIsEseSta;
Jeff Johnson295189b2012-06-20 16:38:30 -07001481
1482 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001483 "WLAN TL:Registering STA Client ID: %d QoS %d Add LLC %d ProtFrame %d EseSta %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07001484 pwSTADescType->ucSTAId,
1485 pwSTADescType->ucQosEnabled,
1486 pwSTADescType->ucAddRmvLLC,
1487 pwSTADescType->ucProtectedFrame,
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001488 pwSTADescType->ucIsEseSta));
Jeff Johnson295189b2012-06-20 16:38:30 -07001489#else
1490
1491 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
1492 "WLAN TL:Registering STA Client ID: %d QoS %d Add LLC %d ProtFrame %d",
1493 pwSTADescType->ucSTAId,
1494 pwSTADescType->ucQosEnabled,
1495 pwSTADescType->ucAddRmvLLC,
1496 pwSTADescType->ucProtectedFrame));
1497
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001498#endif //FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07001499#ifdef WLAN_SOFTAP_VSTA_FEATURE
1500 // if this station was not allocated resources to perform HW-based
1501 // TX frame translation then force SW-based TX frame translation
1502 // otherwise use the frame translation supplied by the client
1503
1504 if (!WDA_IsHwFrameTxTranslationCapable(pvosGCtx, pwSTADescType->ucSTAId)
1505 || ( WLAN_STA_BT_AMP == pwSTADescType->wSTAType))
1506 {
1507 pwSTADescType->ucSwFrameTXXlation = 1;
1508 }
1509#endif
1510
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301511 pClientSTA->wSTADesc.ucSwFrameTXXlation = pwSTADescType->ucSwFrameTXXlation;
1512 pClientSTA->wSTADesc.ucSwFrameRXXlation = pwSTADescType->ucSwFrameRXXlation;
Jeff Johnson295189b2012-06-20 16:38:30 -07001513
1514#ifdef FEATURE_WLAN_WAPI
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301515 pClientSTA->wSTADesc.ucIsWapiSta = pwSTADescType->ucIsWapiSta;
Jeff Johnson295189b2012-06-20 16:38:30 -07001516#endif /* FEATURE_WLAN_WAPI */
1517
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301518 vos_copy_macaddr( &pClientSTA->wSTADesc.vSTAMACAddress, &pwSTADescType->vSTAMACAddress);
Jeff Johnson295189b2012-06-20 16:38:30 -07001519
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301520 vos_copy_macaddr( &pClientSTA->wSTADesc.vBSSIDforIBSS, &pwSTADescType->vBSSIDforIBSS);
Jeff Johnson295189b2012-06-20 16:38:30 -07001521
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301522 vos_copy_macaddr( &pClientSTA->wSTADesc.vSelfMACAddress, &pwSTADescType->vSelfMACAddress);
Jeff Johnson295189b2012-06-20 16:38:30 -07001523
Jeff Johnson295189b2012-06-20 16:38:30 -07001524 /* In volans release L replay check is done at TL */
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301525 pClientSTA->ucIsReplayCheckValid = pwSTADescType->ucIsReplayCheckValid;
1526 pClientSTA->ulTotalReplayPacketsDetected = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001527/*Clear replay counters of the STA on all TIDs*/
1528 for(ucTid = 0; ucTid < WLANTL_MAX_TID ; ucTid++)
1529 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301530 pClientSTA->ullReplayCounter[ucTid] = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001531 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001532
1533 /*--------------------------------------------------------------------
1534 Set the AC for the registered station to the highest priority AC
1535 Even if this AC is not supported by the station, correction will be
1536 made in the main TL loop after the supported mask is properly
1537 updated in the pending packets call
1538 --------------------------------------------------------------------*/
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05301539 pClientSTA->ucCurrentAC = WLANTL_AC_HIGH_PRIO;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301540 pClientSTA->ucCurrentWeight = 0;
1541 pClientSTA->ucServicedAC = WLANTL_AC_BK;
1542 pClientSTA->ucEapolPktPending = 0;
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -07001543
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301544 vos_mem_zero( pClientSTA->aucACMask, sizeof(pClientSTA->aucACMask));
Jeff Johnson295189b2012-06-20 16:38:30 -07001545
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301546 vos_mem_zero( &pClientSTA->wUAPSDInfo, sizeof(pClientSTA->wUAPSDInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -07001547
1548 /*--------------------------------------------------------------------
1549 Reordering info and AMSDU de-aggregation
1550 --------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301551 vos_mem_zero( pClientSTA->atlBAReorderInfo,
1552 sizeof(pClientSTA->atlBAReorderInfo[0])*
Jeff Johnson295189b2012-06-20 16:38:30 -07001553 WLAN_MAX_TID);
1554
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301555 vos_mem_zero( pClientSTA->aucMPDUHeader,
Jeff Johnson295189b2012-06-20 16:38:30 -07001556 WLANTL_MPDU_HEADER_LEN);
1557
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301558 pClientSTA->ucMPDUHeaderLen = 0;
1559 pClientSTA->vosAMSDUChain = NULL;
1560 pClientSTA->vosAMSDUChainRoot = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07001561
1562
Leo Chang6b6faaf2014-01-24 21:21:26 -08001563 /* Reorder LOCK
1564 * During handle normal RX frame within RX thread,
1565 * if MC thread try to preempt, ADDBA, DELBA, TIMER
1566 * Context should be protected from race */
1567 for (ucTid = 0; ucTid < WLAN_MAX_TID ; ucTid++)
1568 {
1569 if (!VOS_IS_STATUS_SUCCESS(
1570 vos_lock_init(&pClientSTA->atlBAReorderInfo[ucTid].reorderLock)))
1571 {
1572 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1573 "Lock Init Fail"));
1574 return VOS_STATUS_E_FAILURE;
1575 }
1576 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001577 /*--------------------------------------------------------------------
1578 Stats info
1579 --------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301580 vos_mem_zero( pClientSTA->auRxCount,
1581 sizeof(pClientSTA->auRxCount[0])*
Jeff Johnson295189b2012-06-20 16:38:30 -07001582 WLAN_MAX_TID);
1583
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301584 vos_mem_zero( pClientSTA->auTxCount,
1585 sizeof(pClientSTA->auRxCount[0])*
Jeff Johnson295189b2012-06-20 16:38:30 -07001586 WLAN_MAX_TID);
1587 /* Initial RSSI is always reported as zero because TL doesnt have enough
1588 data to calculate RSSI. So to avoid reporting zero, we are initializing
1589 RSSI with RSSI saved in BssDescription during scanning. */
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301590 pClientSTA->rssiAvg = rssi;
Bhargav Shah0b23d202015-07-10 17:14:34 +05301591 pClientSTA->rssiAvgBmps = rssi;
Shailender Karmuchi13c0d082013-03-26 14:41:39 -07001592#ifdef FEATURE_WLAN_TDLS
1593 if(WLAN_STA_TDLS == pClientSTA->wSTADesc.wSTAType)
1594 {
1595 /* If client is TDLS, use TDLS specific alpha */
1596 pClientSTA->rssiAlpha = WLANTL_HO_TDLS_ALPHA;
1597 }
1598 else
1599 {
1600 pClientSTA->rssiAlpha = WLANTL_HO_DEFAULT_ALPHA;
1601 }
1602#else
1603 pClientSTA->rssiAlpha = WLANTL_HO_DEFAULT_ALPHA;
1604#endif /* FEATURE_WLAN_TDLS */
Dino Mycle3b9536d2014-07-09 22:05:24 +05301605#ifdef WLAN_FEATURE_LINK_LAYER_STATS
1606 pClientSTA->rssiDataAlpha = WLANTL_HO_DEFAULT_ALPHA;
1607 pClientSTA->interfaceStats.accessCategoryStats[0].ac = WLANTL_AC_BK;
1608 pClientSTA->interfaceStats.accessCategoryStats[1].ac = WLANTL_AC_BE;
1609 pClientSTA->interfaceStats.accessCategoryStats[2].ac = WLANTL_AC_VI;
1610 pClientSTA->interfaceStats.accessCategoryStats[3].ac = WLANTL_AC_VO;
1611#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001612
1613 /*Tx not suspended and station fully registered*/
1614 vos_atomic_set_U8(
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301615 &pClientSTA->ucTxSuspended, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07001616
1617 /* Used until multiple station support will be added*/
1618 pTLCb->ucRegisteredStaId = pwSTADescType->ucSTAId;
1619
1620 /* Save the BAP station ID for future usage */
1621 if ( WLAN_STA_BT_AMP == pwSTADescType->wSTAType )
1622 {
1623 pTLCb->tlBAPClient.ucBAPSTAId = pwSTADescType->ucSTAId;
1624 }
1625
1626 /*------------------------------------------------------------------------
1627 Statistics info
1628 -----------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301629 memset(&pClientSTA->trafficStatistics,
Jeff Johnson295189b2012-06-20 16:38:30 -07001630 0, sizeof(WLANTL_TRANSFER_STA_TYPE));
1631
1632
1633 /*------------------------------------------------------------------------
1634 Start with the state suggested by client caller
1635 -----------------------------------------------------------------------*/
Madan Mohan Koyylamudi64258222013-01-30 14:35:10 +05301636 pClientSTA->tlState = pwSTADescType->ucInitState;
Jeff Johnson295189b2012-06-20 16:38:30 -07001637 /*-----------------------------------------------------------------------
1638 After all the init is complete we can mark the existance flag
1639 ----------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301640 pClientSTA->ucExists++;
Jeff Johnson295189b2012-06-20 16:38:30 -07001641
Jeff Johnson295189b2012-06-20 16:38:30 -07001642 //flow control fields init
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301643 pClientSTA->ucLwmModeEnabled = FALSE;
1644 pClientSTA->ucLwmEventReported = FALSE;
1645 pClientSTA->bmuMemConsumed = 0;
1646 pClientSTA->uIngress_length = 0;
1647 pClientSTA->uBuffThresholdMax = WLANTL_STA_BMU_THRESHOLD_MAX;
Jeff Johnson295189b2012-06-20 16:38:30 -07001648
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301649 pClientSTA->uLwmThreshold = WLANTL_STA_BMU_THRESHOLD_MAX / 3;
Jeff Johnson295189b2012-06-20 16:38:30 -07001650
1651 //@@@ HDDSOFTAP does not queue unregistered packet for now
1652 if ( WLAN_STA_SOFTAP != pwSTADescType->wSTAType )
1653 {
Jeff Johnson295189b2012-06-20 16:38:30 -07001654 /*------------------------------------------------------------------------
1655 Forward received frames while STA was not yet registered
1656 - ----------------------------------------------------------------------*/
1657 if(!VOS_IS_STATUS_SUCCESS(WLANTL_StartForwarding( pwSTADescType->ucSTAId,
1658 pwSTADescType->ucUcastSig,
1659 pwSTADescType->ucBcastSig)))
1660 {
1661 VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001662 " %s fails to start forwarding", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001663 }
Sunil Ravid5406f22013-01-22 00:18:31 -08001664#ifdef FEATURE_WLAN_TDLS
1665 if( WLAN_STA_TDLS == pwSTADescType->wSTAType )
1666 pTLCb->ucTdlsPeerCount++;
1667#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001668 }
Abhishek Singh00b71972016-01-07 10:51:04 +05301669#ifdef WLAN_FEATURE_RMC
1670 vos_lock_init(&pClientSTA->mcLock);
1671#endif /* WLAN_FEATURE_RMC */
1672
Jeff Johnson295189b2012-06-20 16:38:30 -07001673 return VOS_STATUS_SUCCESS;
1674}/* WLANTL_RegisterSTAClient */
1675
1676/*===========================================================================
1677
1678 FUNCTION WLANTL_ClearSTAClient
1679
1680 DESCRIPTION
1681
1682 HDD will call this API when it no longer needs data services for the
1683 particular station.
1684
1685 DEPENDENCIES
1686
1687 A station must have been registered before the clear registration is
1688 called.
1689
1690 PARAMETERS
1691
1692 pvosGCtx: pointer to the global vos context; a handle to TL's
1693 control block can be extracted from its context
1694 ucSTAId: identifier for the STA to be cleared
1695
1696 RETURN VALUE
1697
1698 The result code associated with performing the operation
1699
1700 VOS_STATUS_E_FAULT: Station ID is outside array boundaries or pointer to
1701 TL cb is NULL ; access would cause a page fault
1702 VOS_STATUS_E_EXISTS: Station was not registered
1703 VOS_STATUS_SUCCESS: Everything is good :)
1704
1705 SIDE EFFECTS
1706
1707============================================================================*/
1708VOS_STATUS
1709WLANTL_ClearSTAClient
1710(
1711 v_PVOID_t pvosGCtx,
1712 v_U8_t ucSTAId
1713)
1714{
1715 WLANTL_CbType* pTLCb = NULL;
1716 v_U8_t ucIndex;
1717 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
1718
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301719 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -07001720 /*------------------------------------------------------------------------
1721 Sanity check
1722 ------------------------------------------------------------------------*/
1723 if ( WLANTL_STA_ID_INVALID( ucSTAId ) )
1724 {
1725 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1726 "WLAN TL:Invalid station id requested on WLANTL_ClearSTAClient"));
1727 return VOS_STATUS_E_FAULT;
1728 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001729 /*------------------------------------------------------------------------
1730 Extract TL control block
1731 ------------------------------------------------------------------------*/
1732 pTLCb = VOS_GET_TL_CB(pvosGCtx);
1733 if ( NULL == pTLCb )
1734 {
1735 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1736 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_ClearSTAClient"));
1737 return VOS_STATUS_E_FAULT;
1738 }
1739
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301740 if ( NULL == pTLCb->atlSTAClients[ucSTAId] )
1741 {
1742 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1743 "WLAN TL:Client Memory was not allocated on %s", __func__));
1744 return VOS_STATUS_E_FAILURE;
1745 }
1746
1747 if ( 0 == pTLCb->atlSTAClients[ucSTAId]->ucExists )
Jeff Johnson295189b2012-06-20 16:38:30 -07001748 {
1749 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1750 "WLAN TL:Station was not previously registered on WLANTL_ClearSTAClient"));
Siddharth Bhalaef8ee12014-04-02 00:09:45 +05301751 /* Clean packets cached for the STA */
1752 WLANTL_StartForwarding(ucSTAId,0,0);
Jeff Johnson295189b2012-06-20 16:38:30 -07001753 return VOS_STATUS_E_EXISTS;
1754 }
1755
1756 /* Delete BA sessions on all TID's */
Leo Chang6b6faaf2014-01-24 21:21:26 -08001757 for (ucIndex = 0; ucIndex < WLAN_MAX_TID ; ucIndex++)
Jeff Johnson295189b2012-06-20 16:38:30 -07001758 {
Leo Chang6b6faaf2014-01-24 21:21:26 -08001759 WLANTL_BaSessionDel(pvosGCtx, ucSTAId, ucIndex);
1760 vos_lock_destroy(&pTLCb->atlSTAClients[ucSTAId]->atlBAReorderInfo[ucIndex].reorderLock);
Jeff Johnson295189b2012-06-20 16:38:30 -07001761 }
1762
Sunil Ravid5406f22013-01-22 00:18:31 -08001763#ifdef FEATURE_WLAN_TDLS
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301764 /* decrement ucTdlsPeerCount only if it is non-zero */
1765 if(WLAN_STA_TDLS == pTLCb->atlSTAClients[ucSTAId]->wSTADesc.wSTAType
Sunil Ravid5406f22013-01-22 00:18:31 -08001766 && pTLCb->ucTdlsPeerCount)
1767 pTLCb->ucTdlsPeerCount--;
1768#endif
1769
Jeff Johnson295189b2012-06-20 16:38:30 -07001770 /*------------------------------------------------------------------------
1771 Clear station
1772 ------------------------------------------------------------------------*/
1773 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
1774 "WLAN TL:Clearing STA Client ID: %d", ucSTAId ));
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301775 WLANTL_CleanSTA(pTLCb->atlSTAClients[ucSTAId], 1 /*empty packets*/);
Jeff Johnson295189b2012-06-20 16:38:30 -07001776
Abhishek Singh00b71972016-01-07 10:51:04 +05301777#ifdef WLAN_FEATURE_RMC
1778 /*--------------------------------------------------------------------
1779 Delete multicast entries for duplicate detection
1780 --------------------------------------------------------------------*/
1781 WLANTL_McastDeleteAllEntries(pTLCb->atlSTAClients[ucSTAId]);
1782
1783 vos_lock_destroy(&pTLCb->atlSTAClients[ucSTAId]->mcLock);
1784#endif /* WLAN_FEATURE_RMC */
1785
Jeff Johnson295189b2012-06-20 16:38:30 -07001786 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
1787 "WLAN TL:Clearing STA Reset History RSSI and Region number"));
1788 pTLCb->hoSupport.currentHOState.historyRSSI = 0;
1789 pTLCb->hoSupport.currentHOState.regionNumber = 0;
1790
1791 return VOS_STATUS_SUCCESS;
1792}/* WLANTL_ClearSTAClient */
1793
1794/*===========================================================================
1795
1796 FUNCTION WLANTL_ChangeSTAState
1797
1798 DESCRIPTION
1799
1800 HDD will make this notification whenever a change occurs in the
1801 connectivity state of a particular STA.
1802
1803 DEPENDENCIES
1804
1805 A station must have been registered before the change state can be
1806 called.
1807
1808 RESTRICTION: A station is being notified as authenticated before the
1809 keys are installed in HW. This way if a frame is received
1810 before the keys are installed DPU will drop that frame.
1811
1812 Main thread has higher priority that Tx and Rx threads thus guaranteeing
1813 the following:
1814 - a station will be in assoc state in TL before TL receives any data
1815 for it
1816
1817 PARAMETERS
1818
1819 pvosGCtx: pointer to the global vos context; a handle to TL's
1820 control block can be extracted from its context
1821 ucSTAId: identifier for the STA that is pending transmission
1822 tlSTAState: the new state of the connection to the given station
1823
1824
1825 RETURN VALUE
1826
1827 The result code associated with performing the operation
1828
1829 VOS_STATUS_E_INVAL: Input parameters are invalid
1830 VOS_STATUS_E_FAULT: Station ID is outside array boundaries or pointer to
1831 TL cb is NULL ; access would cause a page fault
1832 VOS_STATUS_E_EXISTS: Station was not registered
1833 VOS_STATUS_SUCCESS: Everything is good :)
1834
1835 SIDE EFFECTS
1836
1837============================================================================*/
1838VOS_STATUS
1839WLANTL_ChangeSTAState
1840(
1841 v_PVOID_t pvosGCtx,
1842 v_U8_t ucSTAId,
1843 WLANTL_STAStateType tlSTAState
1844)
1845{
1846 WLANTL_CbType* pTLCb = NULL;
1847 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
1848
1849 /*------------------------------------------------------------------------
1850 Sanity check
1851 ------------------------------------------------------------------------*/
1852 if ( tlSTAState >= WLANTL_STA_MAX_STATE )
1853 {
1854 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1855 "WLAN TL:Invalid parameter sent on WLANTL_ChangeSTAState"));
1856 return VOS_STATUS_E_INVAL;
1857 }
1858
1859 if ( WLANTL_STA_ID_INVALID( ucSTAId ) )
1860 {
1861 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1862 "WLAN TL:Invalid station id requested on WLANTL_ChangeSTAState"));
1863 return VOS_STATUS_E_FAULT;
1864 }
1865
1866 /*------------------------------------------------------------------------
1867 Extract TL control block and check existance
1868 ------------------------------------------------------------------------*/
1869 pTLCb = VOS_GET_TL_CB(pvosGCtx);
1870 if ( NULL == pTLCb )
1871 {
1872 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1873 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_ChangeSTAState"));
1874 return VOS_STATUS_E_FAULT;
1875 }
1876
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301877 if ( NULL == pTLCb->atlSTAClients[ucSTAId] )
1878 {
1879 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1880 "WLAN TL:Client Memory was not allocated on %s", __func__));
1881 return VOS_STATUS_E_FAILURE;
1882 }
1883
1884 if ( 0 == pTLCb->atlSTAClients[ucSTAId]->ucExists )
Jeff Johnson295189b2012-06-20 16:38:30 -07001885 {
1886 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1887 "WLAN TL:Station was not previously registered on WLANTL_ChangeSTAState"));
1888 return VOS_STATUS_E_EXISTS;
1889 }
1890
1891 /*------------------------------------------------------------------------
1892 Change STA state
1893 No need to lock this operation, see restrictions above
1894 ------------------------------------------------------------------------*/
1895 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
1896 "WLAN TL:Changing state for STA Client ID: %d from %d to %d",
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301897 ucSTAId, pTLCb->atlSTAClients[ucSTAId]->tlState, tlSTAState));
Jeff Johnson295189b2012-06-20 16:38:30 -07001898
Katya Nigam42e16e82014-02-04 16:28:55 +05301899 MTRACE(vos_trace(VOS_MODULE_ID_TL,
1900 TRACE_CODE_TL_STA_STATE, ucSTAId,tlSTAState ));
1901
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301902 pTLCb->atlSTAClients[ucSTAId]->tlState = tlSTAState;
Jeff Johnson295189b2012-06-20 16:38:30 -07001903
1904 return VOS_STATUS_SUCCESS;
1905}/* WLANTL_ChangeSTAState */
1906
1907/*===========================================================================
1908
Agarwal Ashish16020c42014-12-29 22:01:11 +05301909 FUNCTION WLANTL_UpdateTdlsSTAClient
1910
1911 DESCRIPTION
1912
1913 HDD will call this API when ENABLE_LINK happens and HDD want to
1914 register QoS or other params for TDLS peers.
1915
1916 DEPENDENCIES
1917
1918 A station must have been registered before the WMM/QOS registration is
1919 called.
1920
1921 PARAMETERS
1922
1923 pvosGCtx: pointer to the global vos context; a handle to TL's
1924 control block can be extracted from its context
1925 wSTADescType: STA Descriptor, contains information related to the
1926 new added STA
1927
1928 RETURN VALUE
1929
1930 The result code associated with performing the operation
1931
1932 VOS_STATUS_E_FAULT: Station ID is outside array boundaries or pointer to
1933 TL cb is NULL ; access would cause a page fault
1934 VOS_STATUS_E_EXISTS: Station was not registered
1935 VOS_STATUS_SUCCESS: Everything is good :)
1936
1937 SIDE EFFECTS
1938
1939============================================================================*/
1940
1941VOS_STATUS
1942WLANTL_UpdateTdlsSTAClient
1943(
1944 v_PVOID_t pvosGCtx,
1945 WLAN_STADescType* pwSTADescType
1946)
1947{
1948 WLANTL_CbType* pTLCb = NULL;
1949 WLANTL_STAClientType* pClientSTA = NULL;
1950 /*------------------------------------------------------------------------
1951 Extract TL control block
1952 ------------------------------------------------------------------------*/
1953 pTLCb = VOS_GET_TL_CB(pvosGCtx);
1954 if ( NULL == pTLCb || ( WLAN_MAX_STA_COUNT <= pwSTADescType->ucSTAId))
1955 {
1956 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1957 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_UpdateTdlsSTAClient"));
1958 return VOS_STATUS_E_FAULT;
1959 }
1960
1961 pClientSTA = pTLCb->atlSTAClients[pwSTADescType->ucSTAId];
1962 if ((NULL == pClientSTA) || 0 == pClientSTA->ucExists)
1963 {
1964 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1965 "WLAN TL:Station not exists"));
1966 return VOS_STATUS_E_FAILURE;
1967 }
1968
1969 pClientSTA->wSTADesc.ucQosEnabled = pwSTADescType->ucQosEnabled;
1970
Masti, Narayanraddic754cdc2015-12-24 18:22:36 +05301971 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
1972 "WLAN TL: %s: ucQosEnabled of pwSTADescType: %d"
1973 "pClientSTA->wSTADesc: %d",
1974 __func__, pwSTADescType->ucQosEnabled,
1975 pClientSTA->wSTADesc.ucQosEnabled));
1976
Agarwal Ashish16020c42014-12-29 22:01:11 +05301977 return VOS_STATUS_SUCCESS;
1978
1979}
1980
Katya Nigame7b69a82015-04-28 15:24:06 +05301981VOS_STATUS WLANTL_SetMonRxCbk(v_PVOID_t pvosGCtx, WLANTL_MonRxCBType pfnMonRx)
1982{
1983 WLANTL_CbType* pTLCb = NULL ;
1984 pTLCb = VOS_GET_TL_CB(pvosGCtx);
1985 if ( NULL == pTLCb )
1986 {
1987 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1988 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_RegisterSTAClient"));
1989 return VOS_STATUS_E_FAULT;
1990 }
1991 pTLCb->pfnMonRx = pfnMonRx;
1992 return VOS_STATUS_SUCCESS;
1993}
1994
1995void WLANTL_SetIsConversionReq(v_PVOID_t pvosGCtx, v_BOOL_t isConversionReq)
1996{
1997 WLANTL_CbType* pTLCb = NULL ;
1998 pTLCb = VOS_GET_TL_CB(pvosGCtx);
1999 if ( NULL == pTLCb )
2000 {
2001 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2002 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_RegisterSTAClient"));
2003 return;
2004 }
2005 pTLCb->isConversionReq = isConversionReq;
2006 return;
2007}
2008
Agarwal Ashish16020c42014-12-29 22:01:11 +05302009
2010/*===========================================================================
2011
Gopichand Nakkala8b54e912013-03-11 10:44:21 +05302012 FUNCTION WLANTL_STAPtkInstalled
2013
2014 DESCRIPTION
2015
2016 HDD will make this notification whenever PTK is installed for the STA
2017
2018 DEPENDENCIES
2019
2020 A station must have been registered before the change state can be
2021 called.
2022
2023 PARAMETERS
2024
2025 pvosGCtx: pointer to the global vos context; a handle to TL's
2026 control block can be extracted from its context
2027 ucSTAId: identifier for the STA for which Pairwise key is
2028 installed
2029
2030 RETURN VALUE
2031
2032 The result code associated with performing the operation
2033
2034 VOS_STATUS_E_FAULT: Station ID is outside array boundaries or pointer to
2035 TL cb is NULL ; access would cause a page fault
2036 VOS_STATUS_E_EXISTS: Station was not registered
2037 VOS_STATUS_SUCCESS: Everything is good :)
2038
2039 SIDE EFFECTS
2040
2041============================================================================*/
2042VOS_STATUS
2043WLANTL_STAPtkInstalled
2044(
2045 v_PVOID_t pvosGCtx,
2046 v_U8_t ucSTAId
2047)
2048{
2049 WLANTL_CbType* pTLCb = NULL;
2050 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
2051
2052 /*------------------------------------------------------------------------
2053 Sanity check
2054 ------------------------------------------------------------------------*/
2055
2056 if ( WLANTL_STA_ID_INVALID( ucSTAId ) )
2057 {
2058 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2059 "WLAN TL:Invalid station id requested on WLANTL_ChangeSTAState"));
2060 return VOS_STATUS_E_FAULT;
2061 }
2062
2063 /*------------------------------------------------------------------------
2064 Extract TL control block and check existance
2065 ------------------------------------------------------------------------*/
2066 pTLCb = VOS_GET_TL_CB(pvosGCtx);
2067 if ( NULL == pTLCb )
2068 {
2069 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2070 FL("WLAN TL:Invalid TL pointer from pvosGCtx")));
2071 return VOS_STATUS_E_FAULT;
2072 }
2073
2074 if ( NULL == pTLCb->atlSTAClients[ucSTAId] )
2075 {
2076 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2077 FL("WLAN TL:Client Memory was not allocated")));
2078 return VOS_STATUS_E_FAILURE;
2079 }
2080
2081 if ( 0 == pTLCb->atlSTAClients[ucSTAId]->ucExists )
2082 {
2083 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2084 FL("WLAN TL:Station was not previously registered")));
2085 return VOS_STATUS_E_EXISTS;
2086 }
2087
2088 pTLCb->atlSTAClients[ucSTAId]->ptkInstalled = 1;
2089
2090 return VOS_STATUS_SUCCESS;
2091}/* WLANTL_STAPtkInstalled */
2092
2093/*===========================================================================
2094
Madan Mohan Koyyalamudifc1d1fe2012-10-18 15:07:12 -07002095 FUNCTION WLANTL_GetSTAState
2096
2097 DESCRIPTION
2098
2099 Returns connectivity state of a particular STA.
2100
2101 DEPENDENCIES
2102
2103 A station must have been registered before its state can be retrieved.
2104
2105
2106 PARAMETERS
2107
2108 IN
2109 pvosGCtx: pointer to the global vos context; a handle to TL's
2110 control block can be extracted from its context
2111 ucSTAId: identifier of the station
2112
2113 OUT
2114 ptlSTAState: the current state of the connection to the given station
2115
2116
2117 RETURN VALUE
2118
2119 The result code associated with performing the operation
2120
2121 VOS_STATUS_E_INVAL: Input parameters are invalid
2122 VOS_STATUS_E_FAULT: Station ID is outside array boundaries or pointer to
2123 TL cb is NULL ; access would cause a page fault
2124 VOS_STATUS_E_EXISTS: Station was not registered
2125 VOS_STATUS_SUCCESS: Everything is good :)
2126
2127 SIDE EFFECTS
2128
2129============================================================================*/
2130VOS_STATUS
2131WLANTL_GetSTAState
2132(
2133 v_PVOID_t pvosGCtx,
2134 v_U8_t ucSTAId,
2135 WLANTL_STAStateType *ptlSTAState
2136)
2137{
2138 WLANTL_CbType* pTLCb = NULL;
2139 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
2140
2141 /*------------------------------------------------------------------------
2142 Sanity check
2143 ------------------------------------------------------------------------*/
2144 if ( NULL == ptlSTAState )
2145 {
2146 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2147 "WLAN TL:Invalid parameter sent on WLANTL_GetSTAState"));
2148 return VOS_STATUS_E_INVAL;
2149 }
2150
2151 if ( WLANTL_STA_ID_INVALID( ucSTAId ) )
2152 {
2153 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2154 "WLAN TL:Invalid station id requested on WLANTL_GetSTAState"));
2155 return VOS_STATUS_E_FAULT;
2156 }
2157
2158 /*------------------------------------------------------------------------
2159 Extract TL control block and check existance
2160 ------------------------------------------------------------------------*/
2161 pTLCb = VOS_GET_TL_CB(pvosGCtx);
2162 if ( NULL == pTLCb )
2163 {
2164 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2165 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_GetSTAState"));
2166 return VOS_STATUS_E_FAULT;
2167 }
2168
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302169 if ( NULL == pTLCb->atlSTAClients[ucSTAId] )
2170 {
2171 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2172 "WLAN TL:Client Memory was not allocated on %s", __func__));
2173 return VOS_STATUS_E_FAILURE;
2174 }
2175
2176 if ( 0 == pTLCb->atlSTAClients[ucSTAId]->ucExists )
Madan Mohan Koyyalamudifc1d1fe2012-10-18 15:07:12 -07002177 {
Sunil Ravid5406f22013-01-22 00:18:31 -08002178 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
Madan Mohan Koyyalamudifc1d1fe2012-10-18 15:07:12 -07002179 "WLAN TL:Station was not previously registered on WLANTL_GetSTAState"));
2180 return VOS_STATUS_E_EXISTS;
2181 }
2182
2183 /*------------------------------------------------------------------------
2184 Get STA state
2185 ------------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302186 *ptlSTAState = pTLCb->atlSTAClients[ucSTAId]->tlState;
Madan Mohan Koyyalamudifc1d1fe2012-10-18 15:07:12 -07002187
2188 return VOS_STATUS_SUCCESS;
2189}/* WLANTL_GetSTAState */
2190
Shailender Karmuchia734f332013-04-19 14:02:48 -07002191/*==========================================================================
2192 FUNCTION WLANTL_UpdateSTABssIdforIBSS
2193
2194 DESCRIPTION
2195 HDD will call this API to update the BSSID for this Station.
2196
2197 DEPENDENCIES
2198 The HDD Should registered the staID with TL before calling this function.
2199
2200 PARAMETERS
2201
2202 IN
2203 pvosGCtx: Pointer to the global vos context; a handle to TL's
2204 or WDA's control block can be extracted from its context
2205 IN
2206 ucSTAId The Station ID for Bssid to be updated
2207 IN
2208 pBssid BSSID to be updated
2209
2210 RETURN VALUE
2211 The result code associated with performing the operation
2212
2213 VOS_STATUS_E_INVAL: Input parameters are invalid
2214 VOS_STATUS_E_FAULT: Station ID is outside array boundaries or pointer to
2215 TL cb is NULL ; access would cause a page fault
2216 VOS_STATUS_E_EXISTS: Station was not registered
2217 VOS_STATUS_SUCCESS: Everything is good :)
2218
2219 SIDE EFFECTS
2220============================================================================*/
2221
2222
2223VOS_STATUS
2224WLANTL_UpdateSTABssIdforIBSS
2225(
2226 v_PVOID_t pvosGCtx,
2227 v_U8_t ucSTAId,
2228 v_U8_t *pBssid
2229)
2230{
2231 WLANTL_CbType* pTLCb = NULL;
2232 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
2233
2234 /*------------------------------------------------------------------------
2235 Sanity check
2236 ------------------------------------------------------------------------*/
2237 if ( WLANTL_STA_ID_INVALID( ucSTAId ) )
2238 {
2239 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2240 "WLAN TL:Invalid station id requested %s", __func__));
2241 return VOS_STATUS_E_FAULT;
2242 }
2243
2244 /*------------------------------------------------------------------------
2245 Extract TL control block and check existance
2246 ------------------------------------------------------------------------*/
2247 pTLCb = VOS_GET_TL_CB(pvosGCtx);
2248 if ( NULL == pTLCb )
2249 {
2250 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2251 "WLAN TL:Invalid TL pointer from pvosGCtx %s", __func__));
2252 return VOS_STATUS_E_FAULT;
2253 }
2254
2255 if ( NULL == pTLCb->atlSTAClients[ucSTAId] )
2256 {
2257 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2258 "WLAN TL:Client Memory was not allocated on %s", __func__));
2259 return VOS_STATUS_E_FAILURE;
2260 }
2261
2262 if ( 0 == pTLCb->atlSTAClients[ucSTAId]->ucExists )
2263 {
2264 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
2265 "WLAN TL:Station was not previously registered %s", __func__));
2266 return VOS_STATUS_E_EXISTS;
2267 }
2268
2269 /*------------------------------------------------------------------------
2270 Update the IBSS BSSID
2271 ------------------------------------------------------------------------*/
2272 vos_mem_copy( &pTLCb->atlSTAClients[ucSTAId]->wSTADesc.vBSSIDforIBSS,
2273 pBssid, sizeof(v_MACADDR_t));
2274
2275 return VOS_STATUS_SUCCESS;
2276}
2277
Madan Mohan Koyyalamudifc1d1fe2012-10-18 15:07:12 -07002278/*===========================================================================
2279
Jeff Johnson295189b2012-06-20 16:38:30 -07002280 FUNCTION WLANTL_STAPktPending
2281
2282 DESCRIPTION
2283
2284 HDD will call this API when a packet is pending transmission in its
2285 queues.
2286
2287 DEPENDENCIES
2288
2289 A station must have been registered before the packet pending
2290 notification can be sent.
2291
2292 RESTRICTION: TL will not count packets for pending notification.
2293 HDD is expected to send the notification only when
2294 non-empty event gets triggered. Worst case scenario
2295 is that TL might end up making a call when Hdds
2296 queues are actually empty.
2297
2298 PARAMETERS
2299
2300 pvosGCtx: pointer to the global vos context; a handle to TL's
2301 control block can be extracted from its context
2302 ucSTAId: identifier for the STA that is pending transmission
2303
2304 RETURN VALUE
2305
2306 The result code associated with performing the operation
2307
2308 VOS_STATUS_E_INVAL: Input parameters are invalid
2309 VOS_STATUS_E_FAULT: Station ID is outside array boundaries or pointer
2310 to TL cb is NULL ; access would cause a page fault
2311 VOS_STATUS_E_EXISTS: Station was not registered
2312 VOS_STATUS_SUCCESS: Everything is good :)
2313
2314 SIDE EFFECTS
2315
2316============================================================================*/
2317VOS_STATUS
2318WLANTL_STAPktPending
2319(
2320 v_PVOID_t pvosGCtx,
2321 v_U8_t ucSTAId,
2322 WLANTL_ACEnumType ucAc
2323)
2324{
2325 WLANTL_CbType* pTLCb = NULL;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302326 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002327 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
2328
2329 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
2330 "WLAN TL:Packet pending indication for STA: %d AC: %d", ucSTAId, ucAc);
2331
2332 /*------------------------------------------------------------------------
2333 Sanity check
2334 ------------------------------------------------------------------------*/
2335 if ( WLANTL_STA_ID_INVALID( ucSTAId ) )
2336 {
2337 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2338 "WLAN TL:Invalid station id requested on WLANTL_STAPktPending"));
2339 return VOS_STATUS_E_FAULT;
2340 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002341 /*------------------------------------------------------------------------
2342 Extract TL control block and check existance
2343 ------------------------------------------------------------------------*/
2344 pTLCb = VOS_GET_TL_CB(pvosGCtx);
2345 if ( NULL == pTLCb )
2346 {
2347 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2348 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_STAPktPending"));
2349 return VOS_STATUS_E_FAULT;
2350 }
2351
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302352 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
2353
2354 if ( NULL == pClientSTA )
2355 {
2356 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2357 "WLAN TL:Client Memory was not allocated on %s", __func__));
2358 return VOS_STATUS_E_FAILURE;
2359 }
2360
2361 if ( 0 == pClientSTA->ucExists )
Jeff Johnson295189b2012-06-20 16:38:30 -07002362 {
Katya Nigamb130d572014-11-24 16:38:16 +05302363 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07002364 "WLAN TL:Station was not previously registered on WLANTL_STAPktPending"));
2365 return VOS_STATUS_E_EXISTS;
2366 }
2367
2368 /*---------------------------------------------------------------------
2369 Temporary fix to enable TL to fetch packets when multiple peers join
2370 an IBSS. To fix CR177301. Needs to go away when the actual fix of
2371 going through all STA's in round robin fashion gets merged in from
2372 BT AMP branch.
2373 --------------------------------------------------------------------*/
2374 pTLCb->ucRegisteredStaId = ucSTAId;
2375
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302376 if( WLANTL_STA_CONNECTED == pClientSTA->tlState )
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -07002377 { /* EAPOL_HI_PRIORITY : need to find out whether EAPOL is pending before
2378 WLANTL_FetchPacket()/WLANTL_TxConn() is called.
2379 change STA_AUTHENTICATED != tlState to CONNECTED == tlState
2380 to make sure TL is indeed waiting for EAPOL.
2381 Just in the case when STA got disconnected shortly after connectection */
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302382 pClientSTA->ucEapolPktPending = 1;
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -07002383
Katya Nigam42e16e82014-02-04 16:28:55 +05302384 MTRACE(vos_trace(VOS_MODULE_ID_TL,
2385 TRACE_CODE_TL_EAPOL_PKT_PENDING, ucSTAId, ucAc));
2386
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -07002387 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07002388 "WLAN TL:Packet pending indication for STA: %d AC: %d State: %d",
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302389 ucSTAId, ucAc, pClientSTA->tlState);
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07002390 }
2391
Jeff Johnson295189b2012-06-20 16:38:30 -07002392 /*-----------------------------------------------------------------------
2393 Enable this AC in the AC mask in order for TL to start servicing it
2394 Set packet pending flag
2395 To avoid race condition, serialize the updation of AC and AC mask
2396 through WLANTL_TX_STAID_AC_IND message.
2397 -----------------------------------------------------------------------*/
Jeff Johnson295189b2012-06-20 16:38:30 -07002398
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302399 pClientSTA->aucACMask[ucAc] = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07002400
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302401 vos_atomic_set_U8( &pClientSTA->ucPktPending, 1);
Jeff Johnson295189b2012-06-20 16:38:30 -07002402
2403 /*------------------------------------------------------------------------
2404 Check if there are enough resources for transmission and tx is not
2405 suspended.
2406 ------------------------------------------------------------------------*/
Nirav Shah4b53d4b2015-05-08 05:35:00 -07002407 if (( pTLCb->uResCount >= WDA_TLI_MIN_RES_DATA ) &&
2408 ( 0 == pTLCb->ucTxSuspended ))
Jeff Johnson295189b2012-06-20 16:38:30 -07002409 {
Katya Nigam42e16e82014-02-04 16:28:55 +05302410
Jeff Johnson295189b2012-06-20 16:38:30 -07002411 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
2412 "Issuing Xmit start request to BAL"));
2413 WDA_DS_StartXmit(pvosGCtx);
2414 }
2415 else
2416 {
2417 /*---------------------------------------------------------------------
2418 No error code is sent because TL will resume tx autonomously if
2419 resources become available or tx gets resumed
2420 ---------------------------------------------------------------------*/
Madan Mohan Koyyalamudi179e6fe2012-10-15 15:31:08 -07002421 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
Jeff Johnson295189b2012-06-20 16:38:30 -07002422 "WLAN TL:Request to send but condition not met. Res: %d,Suspend: %d",
Madan Mohan Koyyalamudi48139e32012-10-11 14:43:56 -07002423 pTLCb->uResCount, pTLCb->ucTxSuspended );
Jeff Johnson295189b2012-06-20 16:38:30 -07002424 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002425 return VOS_STATUS_SUCCESS;
2426}/* WLANTL_STAPktPending */
2427
2428/*==========================================================================
2429
2430 FUNCTION WLANTL_SetSTAPriority
2431
2432 DESCRIPTION
2433
2434 TL exposes this API to allow upper layers a rough control over the
2435 priority of transmission for a given station when supporting multiple
2436 connections.
2437
2438 DEPENDENCIES
2439
2440 A station must have been registered before the change in priority can be
2441 called.
2442
2443 PARAMETERS
2444
2445 pvosGCtx: pointer to the global vos context; a handle to TL's
2446 control block can be extracted from its context
2447 ucSTAId: identifier for the STA that has to change priority
2448
2449 RETURN VALUE
2450
2451 The result code associated with performing the operation
2452
2453 VOS_STATUS_E_INVAL: Input parameters are invalid
2454 VOS_STATUS_E_FAULT: Station ID is outside array boundaries or pointer
2455 to TL cb is NULL ; access would cause a page fault
2456 VOS_STATUS_E_EXISTS: Station was not registered
2457 VOS_STATUS_SUCCESS: Everything is good :)
2458
2459 SIDE EFFECTS
2460
2461============================================================================*/
2462VOS_STATUS
2463WLANTL_SetSTAPriority
2464(
2465 v_PVOID_t pvosGCtx,
2466 v_U8_t ucSTAId,
2467 WLANTL_STAPriorityType tlSTAPri
2468)
2469{
2470 WLANTL_CbType* pTLCb = NULL;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302471 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002472 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
2473
2474 /*------------------------------------------------------------------------
2475 Sanity check
2476 ------------------------------------------------------------------------*/
2477 if ( WLANTL_STA_ID_INVALID( ucSTAId ) )
2478 {
2479 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2480 "WLAN TL:Invalid station id requested on WLANTL_SetSTAPriority"));
2481 return VOS_STATUS_E_FAULT;
2482 }
2483
2484 /*------------------------------------------------------------------------
2485 Extract TL control block
2486 ------------------------------------------------------------------------*/
2487 pTLCb = VOS_GET_TL_CB(pvosGCtx);
2488 if ( NULL == pTLCb )
2489 {
2490 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2491 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_SetSTAPriority"));
2492 return VOS_STATUS_E_FAULT;
2493 }
2494
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302495 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
2496
2497 if ( NULL == pClientSTA )
2498 {
2499 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2500 "WLAN TL:Client Memory was not allocated on %s", __func__));
2501 return VOS_STATUS_E_FAILURE;
2502 }
2503
2504 if ( 0 == pClientSTA->ucExists )
Jeff Johnson295189b2012-06-20 16:38:30 -07002505 {
2506 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2507 "WLAN TL:Station was not previously registered on WLANTL_SetSTAPriority"));
2508 return VOS_STATUS_E_EXISTS;
2509 }
2510
2511 /*------------------------------------------------------------------------
2512 Re-analize if lock is needed when adding multiple stations
2513 ------------------------------------------------------------------------*/
2514 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
2515 "WLAN TL:Changing state for STA Pri ID: %d from %d to %d",
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302516 ucSTAId, pClientSTA->tlPri, tlSTAPri));
2517 pClientSTA->tlPri = tlSTAPri;
Jeff Johnson295189b2012-06-20 16:38:30 -07002518
2519 return VOS_STATUS_SUCCESS;
2520}/* WLANTL_SetSTAPriority */
2521
2522
2523/*----------------------------------------------------------------------------
2524 INTERACTION WITH BAP
2525 ---------------------------------------------------------------------------*/
2526
2527/*==========================================================================
2528
2529 FUNCTION WLANTL_RegisterBAPClient
2530
2531 DESCRIPTION
2532 Called by SME to register itself as client for non-data BT-AMP packets.
2533
2534 DEPENDENCIES
2535 TL must be initialized before this function can be called.
2536
2537 PARAMETERS
2538
2539 IN
2540 pvosGCtx: pointer to the global vos context; a handle to TL's
2541 or SME's control block can be extracted from its context
2542 pfnTlBAPRxFrm: pointer to the receive processing routine for non-data
2543 BT-AMP packets
2544 pfnFlushOpCompleteCb:
2545 pointer to the call back function, for the Flush operation
2546 completion.
2547
2548
2549 RETURN VALUE
2550
2551 The result code associated with performing the operation
2552
2553 VOS_STATUS_E_INVAL: Input parameters are invalid
2554 VOS_STATUS_E_FAULT: Station ID is outside array boundaries or pointer
2555 to TL cb is NULL ; access would cause a page fault
2556 VOS_STATUS_E_EXISTS: BAL client was already registered
2557 VOS_STATUS_SUCCESS: Everything is good :)
2558
2559 SIDE EFFECTS
2560
2561============================================================================*/
2562VOS_STATUS
2563WLANTL_RegisterBAPClient
2564(
2565 v_PVOID_t pvosGCtx,
2566 WLANTL_BAPRxCBType pfnTlBAPRxFrm,
2567 WLANTL_FlushOpCompCBType pfnFlushOpCompleteCb
2568)
2569{
2570 WLANTL_CbType* pTLCb = NULL;
2571 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
2572
2573 /*------------------------------------------------------------------------
2574 Sanity check
2575 ------------------------------------------------------------------------*/
2576 if ( NULL == pfnTlBAPRxFrm )
2577 {
2578 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2579 "WLAN TL:Invalid parameter sent on WLANTL_RegisterBAPClient"));
2580 return VOS_STATUS_E_INVAL;
2581 }
2582
2583 if ( NULL == pfnFlushOpCompleteCb )
2584 {
2585 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2586 "Invalid Flush Complete Cb parameter sent on WLANTL_RegisterBAPClient"));
2587 return VOS_STATUS_E_INVAL;
2588 }
2589
2590 /*------------------------------------------------------------------------
2591 Extract TL control block
2592 ------------------------------------------------------------------------*/
2593 pTLCb = VOS_GET_TL_CB(pvosGCtx);
2594 if ( NULL == pTLCb )
2595 {
2596 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2597 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_RegisterBAPClient"));
2598 return VOS_STATUS_E_FAULT;
2599 }
2600
2601 /*------------------------------------------------------------------------
2602 Make sure this is the first registration attempt
2603 ------------------------------------------------------------------------*/
2604 if ( 0 != pTLCb->tlBAPClient.ucExists )
2605 {
2606 pTLCb->tlBAPClient.ucExists++;
2607 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2608 "WLAN TL:BAP client was already registered"));
2609 return VOS_STATUS_E_EXISTS;
2610 }
2611
2612 /*------------------------------------------------------------------------
2613 Register station with TL
2614 ------------------------------------------------------------------------*/
2615 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
2616 "WLAN TL:Registering BAP Client" ));
2617
2618 pTLCb->tlBAPClient.ucExists++;
2619
2620 if ( NULL != pfnTlBAPRxFrm )
2621 {
2622 pTLCb->tlBAPClient.pfnTlBAPRx = pfnTlBAPRxFrm;
2623 }
2624
2625 pTLCb->tlBAPClient.pfnFlushOpCompleteCb = pfnFlushOpCompleteCb;
2626
2627 pTLCb->tlBAPClient.vosPendingDataBuff = NULL;
2628
2629 return VOS_STATUS_SUCCESS;
2630}/* WLANTL_RegisterBAPClient */
2631
2632
2633/*==========================================================================
2634
2635 FUNCTION WLANTL_TxBAPFrm
2636
2637 DESCRIPTION
2638 BAP calls this when it wants to send a frame to the module
2639
2640 DEPENDENCIES
2641 BAP must be registered with TL before this function can be called.
2642
2643 RESTRICTION: BAP CANNOT push any packets to TL until it did not receive
2644 a tx complete from the previous packet, that means BAP
2645 sends one packet, wait for tx complete and then
2646 sends another one
2647
2648 If BAP sends another packet before TL manages to process the
2649 previously sent packet call will end in failure
2650
2651 PARAMETERS
2652
2653 IN
2654 pvosGCtx: pointer to the global vos context; a handle to TL's
2655 or BAP's control block can be extracted from its context
2656 vosDataBuff: pointer to the vOSS buffer containing the packet to be
2657 transmitted
2658 pMetaInfo: meta information about the packet
2659 pfnTlBAPTxComp: pointer to a transmit complete routine for notifying
2660 the result of the operation over the bus
2661
2662 RETURN VALUE
2663 The result code associated with performing the operation
2664
2665 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
2666 page fault
2667 VOS_STATUS_E_EXISTS: BAL client was not yet registered
2668 VOS_STATUS_E_BUSY: The previous BT-AMP packet was not yet transmitted
2669 VOS_STATUS_SUCCESS: Everything is good :)
2670
2671 Other failure messages may be returned from the BD header handling
2672 routines, please check apropriate API for more info.
2673
2674 SIDE EFFECTS
2675
2676============================================================================*/
2677VOS_STATUS
2678WLANTL_TxBAPFrm
2679(
2680 v_PVOID_t pvosGCtx,
2681 vos_pkt_t* vosDataBuff,
2682 WLANTL_MetaInfoType* pMetaInfo,
2683 WLANTL_TxCompCBType pfnTlBAPTxComp
2684)
2685{
2686 WLANTL_CbType* pTLCb = NULL;
2687 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
2688 v_MACADDR_t vDestMacAddr;
2689 v_U16_t usPktLen;
2690 v_U8_t ucStaId = 0;
2691 v_U8_t extraHeadSpace = 0;
2692 v_U8_t ucWDSEnabled = 0;
2693 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
2694
2695 /*------------------------------------------------------------------------
2696 Sanity check
2697 Extract TL control block
2698 ------------------------------------------------------------------------*/
2699 pTLCb = VOS_GET_TL_CB(pvosGCtx);
2700 if ( NULL == pTLCb )
2701 {
2702 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2703 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_TxBAPFrm"));
2704 return VOS_STATUS_E_FAULT;
2705 }
2706
2707 /*------------------------------------------------------------------------
2708 Ensure that BAP client was registered previously
2709 ------------------------------------------------------------------------*/
2710 if (( 0 == pTLCb->tlBAPClient.ucExists ) ||
2711 ( WLANTL_STA_ID_INVALID(pTLCb->tlBAPClient.ucBAPSTAId) ))
2712 {
2713 pTLCb->tlBAPClient.ucExists++;
2714 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2715 "WLAN TL:BAP client not register on WLANTL_TxBAPFrm"));
2716 return VOS_STATUS_E_EXISTS;
2717 }
2718
2719 /*------------------------------------------------------------------------
2720 Check if any BT-AMP Frm is pending
2721 ------------------------------------------------------------------------*/
2722 if ( NULL != pTLCb->tlBAPClient.vosPendingDataBuff )
2723 {
2724 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2725 "WLAN TL:BT-AMP Frame already pending tx in TL on WLANTL_TxBAPFrm"));
2726 return VOS_STATUS_E_BUSY;
2727 }
2728
2729 /*------------------------------------------------------------------------
2730 Save buffer and notify BAL; no lock is needed if the above restriction
2731 is met
2732 Save the tx complete fnct pointer as tl specific data in the vos buffer
2733 ------------------------------------------------------------------------*/
2734
2735 /*------------------------------------------------------------------------
2736 Translate 802.3 frame to 802.11
2737 ------------------------------------------------------------------------*/
2738 ucStaId = pTLCb->tlBAPClient.ucBAPSTAId;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302739 if ( NULL == pTLCb->atlSTAClients[ucStaId] )
2740 {
2741 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2742 "WLAN TL:Client Memory was not allocated on %s", __func__));
2743 return VOS_STATUS_E_FAILURE;
2744 }
2745 if (( 0 == pMetaInfo->ucDisableFrmXtl ) &&
2746 ( 0 != pTLCb->atlSTAClients[ucStaId]->wSTADesc.ucSwFrameTXXlation ))
Jeff Johnson295189b2012-06-20 16:38:30 -07002747 {
Kiran Venkatappacab0d352012-12-17 13:09:22 -08002748 vosStatus = WLANTL_Translate8023To80211Header( vosDataBuff, &vosStatus,
2749 pTLCb, &ucStaId,
Ravi Joshid0699502013-07-08 15:48:47 -07002750 pMetaInfo, &ucWDSEnabled,
2751 &extraHeadSpace);
Jeff Johnson295189b2012-06-20 16:38:30 -07002752
2753 if ( VOS_STATUS_SUCCESS != vosStatus )
2754 {
2755 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2756 "WLAN TL:Error when translating header WLANTL_TxBAPFrm"));
2757
2758 return vosStatus;
2759 }
2760
2761 pMetaInfo->ucDisableFrmXtl = 1;
2762 }
2763
2764 /*-------------------------------------------------------------------------
2765 Call HAL to fill BD header
2766 -------------------------------------------------------------------------*/
2767
2768 /* Adding Type, SubType which was missing for EAPOL from BAP */
2769 pMetaInfo->ucType |= (WLANTL_80211_DATA_TYPE << 4);
2770 pMetaInfo->ucType |= (WLANTL_80211_DATA_QOS_SUBTYPE);
2771
2772 vosStatus = WDA_DS_BuildTxPacketInfo( pvosGCtx, vosDataBuff ,
2773 &vDestMacAddr, pMetaInfo->ucDisableFrmXtl,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302774 &usPktLen, pTLCb->atlSTAClients[ucStaId]->wSTADesc.ucQosEnabled,
Jeff Johnson295189b2012-06-20 16:38:30 -07002775 ucWDSEnabled, extraHeadSpace, pMetaInfo->ucType,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302776 &pTLCb->atlSTAClients[ucStaId]->wSTADesc.vSelfMACAddress,
Jeff Johnson295189b2012-06-20 16:38:30 -07002777 pMetaInfo->ucTID, 0 /* No ACK */, pMetaInfo->usTimeStamp,
Sravan Kumar Kairamd9e8cbb2017-01-17 12:17:28 +05302778 pMetaInfo->ucIsEapol || pMetaInfo->ucIsWai, pMetaInfo->ucIsArp,
2779 pMetaInfo->ucUP, pMetaInfo->ucTxBdToken);
Jeff Johnson295189b2012-06-20 16:38:30 -07002780
2781 if ( VOS_STATUS_SUCCESS != vosStatus )
2782 {
2783 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2784 "WLAN TL:Failed while building TX header %d", vosStatus));
2785 return vosStatus;
2786 }
2787
2788 if ( NULL != pfnTlBAPTxComp )
2789 {
2790 vos_pkt_set_user_data_ptr( vosDataBuff, VOS_PKT_USER_DATA_ID_TL,
2791 (v_PVOID_t)pfnTlBAPTxComp);
2792 }
2793 else
2794 {
2795 vos_pkt_set_user_data_ptr( vosDataBuff, VOS_PKT_USER_DATA_ID_TL,
2796 (v_PVOID_t)WLANTL_TxCompDefaultCb);
2797
2798 }
2799
Arun Kumar Khandavalli0af8d3c2014-02-07 18:05:11 +05302800 vos_atomic_set( (uintptr_t*)&pTLCb->tlBAPClient.vosPendingDataBuff,
2801 (uintptr_t)vosDataBuff);
Jeff Johnson295189b2012-06-20 16:38:30 -07002802
2803 /*------------------------------------------------------------------------
2804 Check if thre are enough resources for transmission and tx is not
2805 suspended.
2806 ------------------------------------------------------------------------*/
2807 if (( pTLCb->uResCount >= WDA_TLI_MIN_RES_BAP ) &&
2808 ( 0 == pTLCb->ucTxSuspended ))
2809 {
2810 WDA_DS_StartXmit(pvosGCtx);
2811 }
2812 else
2813 {
2814 /*---------------------------------------------------------------------
2815 No error code is sent because TL will resume tx autonomously if
2816 resources become available or tx gets resumed
2817 ---------------------------------------------------------------------*/
2818 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
2819 "WLAN TL:Request to send from BAP but condition not met.Res: %d,"
2820 "Suspend: %d", pTLCb->uResCount, pTLCb->ucTxSuspended ));
2821 }
2822
2823 return VOS_STATUS_SUCCESS;
2824}/* WLANTL_TxBAPFrm */
2825
2826
2827/*----------------------------------------------------------------------------
2828 INTERACTION WITH SME
2829 ---------------------------------------------------------------------------*/
2830
2831/*==========================================================================
2832
2833 FUNCTION WLANTL_GetRssi
2834
2835 DESCRIPTION
2836 TL will extract the RSSI information from every data packet from the
2837 ongoing traffic and will store it. It will provide the result to SME
2838 upon request.
2839
2840 DEPENDENCIES
2841
2842 WARNING: the read and write of this value will not be protected
2843 by locks, therefore the information obtained after a read
2844 might not always be consistent.
2845
2846 PARAMETERS
2847
2848 IN
2849 pvosGCtx: pointer to the global vos context; a handle to TL's
2850 or SME's control block can be extracted from its context
2851 ucSTAId: station identifier for the requested value
2852
2853 OUT
2854 puRssi: the average value of the RSSI
2855
2856
2857 RETURN VALUE
2858 The result code associated with performing the operation
2859
2860 VOS_STATUS_E_INVAL: Input parameters are invalid
2861 VOS_STATUS_E_FAULT: Station ID is outside array boundaries or pointer
2862 to TL cb is NULL ; access would cause a page fault
2863 VOS_STATUS_E_EXISTS: STA was not yet registered
2864 VOS_STATUS_SUCCESS: Everything is good :)
2865
2866 SIDE EFFECTS
2867
2868============================================================================*/
2869VOS_STATUS
2870WLANTL_GetRssi
2871(
2872 v_PVOID_t pvosGCtx,
2873 v_U8_t ucSTAId,
2874 v_S7_t* pRssi
2875)
2876{
2877 WLANTL_CbType* pTLCb = NULL;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302878 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002879 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
2880
2881 /*------------------------------------------------------------------------
2882 Sanity check
2883 ------------------------------------------------------------------------*/
2884 if ( NULL == pRssi )
2885 {
2886 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2887 "WLAN TL:Invalid parameter sent on WLANTL_GetRssi"));
2888 return VOS_STATUS_E_INVAL;
2889 }
2890
2891 if ( WLANTL_STA_ID_INVALID( ucSTAId ) )
2892 {
2893 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2894 "WLAN TL:Invalid station id requested on WLANTL_GetRssi"));
2895 return VOS_STATUS_E_FAULT;
2896 }
2897
2898 /*------------------------------------------------------------------------
2899 Extract TL control block and check existance
2900 ------------------------------------------------------------------------*/
2901 pTLCb = VOS_GET_TL_CB(pvosGCtx);
2902 if ( NULL == pTLCb )
2903 {
2904 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2905 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_GetRssi"));
2906 return VOS_STATUS_E_FAULT;
2907 }
2908
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302909 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
2910
2911 if ( NULL == pClientSTA )
2912 {
2913 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2914 "WLAN TL:Client Memory was not allocated on %s", __func__));
2915 return VOS_STATUS_E_FAILURE;
2916 }
2917
2918 if ( 0 == pClientSTA->ucExists )
Jeff Johnson295189b2012-06-20 16:38:30 -07002919 {
2920 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2921 "WLAN TL:Station was not previously registered on WLANTL_GetRssi"));
2922 return VOS_STATUS_E_EXISTS;
2923 }
2924
2925 /*------------------------------------------------------------------------
2926 Copy will not be locked; please read restriction
2927 ------------------------------------------------------------------------*/
Katya Nigam5c2e5f62013-11-15 19:19:11 +05302928 if(pTLCb->isBMPS || IS_ACTIVEMODE_OFFLOAD_FEATURE_ENABLE)
Jeff Johnson295189b2012-06-20 16:38:30 -07002929 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302930 *pRssi = pClientSTA->rssiAvgBmps;
Jeff Johnson295189b2012-06-20 16:38:30 -07002931 /* Check If RSSI is zero because we are reading rssAvgBmps updated by HAL in
2932 previous GetStatsRequest. It may be updated as zero by Hal because EnterBmps
2933 might not have happend by that time. Hence reading the most recent Rssi
2934 calcluated by TL*/
2935 if(0 == *pRssi)
2936 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302937 *pRssi = pClientSTA->rssiAvg;
Jeff Johnson295189b2012-06-20 16:38:30 -07002938 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002939 }
2940 else
2941 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302942 *pRssi = pClientSTA->rssiAvg;
Jeff Johnson295189b2012-06-20 16:38:30 -07002943 }
2944
2945 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
Jeff Johnson32d95a32012-09-10 13:15:23 -07002946 "WLAN TL:WLANTL_GetRssi for STA: %d RSSI: %d%s",
2947 ucSTAId, *pRssi,
2948 pTLCb->isBMPS ? " in BMPS" : ""));
Jeff Johnson295189b2012-06-20 16:38:30 -07002949
2950 return VOS_STATUS_SUCCESS;
2951}/* WLANTL_GetRssi */
2952
2953/*==========================================================================
2954
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05302955 FUNCTION WLANTL_GetSnr
2956
2957 DESCRIPTION
2958 TL will extract the SNR information from every data packet from the
2959 ongoing traffic and will store it. It will provide the result to SME
2960 upon request.
2961
2962 DEPENDENCIES
2963
2964 WARNING: the read and write of this value will not be protected
2965 by locks, therefore the information obtained after a read
2966 might not always be consistent.
2967
2968 PARAMETERS
2969
2970 IN
2971 pvosGCtx: pointer to the global vos context; a handle to TL's
2972 or SME's control block can be extracted from its context
2973 ucSTAId: station identifier for the requested value
2974
2975 OUT
2976 pSnr: the average value of the SNR
2977
2978
2979 RETURN VALUE
2980 The result code associated with performing the operation
2981
2982 VOS_STATUS_E_INVAL: Input parameters are invalid
2983 VOS_STATUS_E_FAULT: Station ID is outside array boundaries or pointer
2984 to TL cb is NULL ; access would cause a page fault
2985 VOS_STATUS_E_EXISTS: STA was not yet registered
2986 VOS_STATUS_SUCCESS: Everything is good :)
2987
2988 SIDE EFFECTS
2989
2990============================================================================*/
2991VOS_STATUS
2992WLANTL_GetSnr
2993(
2994 tANI_U8 ucSTAId,
2995 tANI_S8* pSnr
2996)
2997{
2998 WLANTL_CbType* pTLCb = NULL;
2999 WLANTL_STAClientType* pClientSTA = NULL;
3000 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
3001
3002 /*------------------------------------------------------------------------
3003 Sanity check
3004 ------------------------------------------------------------------------*/
3005 if (NULL == pSnr)
3006 {
3007 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3008 "WLAN TL:Invalid parameter sent on %s", __func__));
3009 return VOS_STATUS_E_INVAL;
3010 }
3011
3012 if (WLANTL_STA_ID_INVALID(ucSTAId))
3013 {
3014 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3015 "WLAN TL:Invalid station id requested on %s", __func__));
3016 return VOS_STATUS_E_FAULT;
3017 }
3018
3019 /*------------------------------------------------------------------------
3020 Extract TL control block and check existance
3021 ------------------------------------------------------------------------*/
3022 pTLCb = VOS_GET_TL_CB(vos_get_global_context(VOS_MODULE_ID_TL, NULL));
3023 if (NULL == pTLCb)
3024 {
3025 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3026 "WLAN TL:Invalid TL pointer from pvosGCtx on %s", __func__));
3027 return VOS_STATUS_E_FAULT;
3028 }
3029
3030 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
3031
3032 if (NULL == pClientSTA)
3033 {
3034 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3035 "WLAN TL:Client Memory was not allocated on %s", __func__));
3036 return VOS_STATUS_E_FAILURE;
3037 }
3038
3039 if (0 == pClientSTA->ucExists)
3040 {
3041 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3042 "WLAN TL:Station was not previously registered on %s", __func__));
3043 return VOS_STATUS_E_EXISTS;
3044 }
3045
3046 /*------------------------------------------------------------------------
3047 Copy will not be locked; please read restriction
3048 ------------------------------------------------------------------------*/
3049 if (pTLCb->isBMPS)
3050 {
3051 *pSnr = pClientSTA->snrAvgBmps;
3052 }
3053 else
3054 {
3055 /* SNR is averaged over WLANTL_MAX_SNR_DATA_SAMPLES, if there are not enough
3056 * data samples (snridx) to calculate the average then return the
3057 * average for the window of prevoius 20 packets. And if there aren't
3058 * enough samples and the average for previous window of 20 packets is
3059 * not available then return a predefined value
3060 *
3061 * NOTE: the SNR_HACK_BMPS value is defined to 127, documents from HW
3062 * team reveal that the SNR value has a ceiling well below 127 dBm,
3063 * so if SNR has value of 127 the userspace applications can know that
3064 * the SNR has not been computed yet because enough data was not
3065 * available for SNR calculation
3066 */
3067 if (pClientSTA->snrIdx > (WLANTL_MAX_SNR_DATA_SAMPLES/2)
3068 || !(pClientSTA->prevSnrAvg))
3069 {
3070 *pSnr = pClientSTA->snrSum / pClientSTA->snrIdx;
3071 }
3072 else if (pClientSTA->prevSnrAvg)
3073 {
3074 *pSnr = pClientSTA->prevSnrAvg;
3075 }
3076 else
3077 {
3078 *pSnr = SNR_HACK_BMPS;
3079 }
3080 }
3081
3082 VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
3083 "WLAN TL:WLANTL_GetSnr for STA: %d SNR: %d%s",
3084 ucSTAId, *pSnr,
3085 pTLCb->isBMPS ? " in BMPS" : "");
3086
3087 return VOS_STATUS_SUCCESS;
3088}/* WLANTL_GetSnr */
3089/*==========================================================================
3090
Jeff Johnson295189b2012-06-20 16:38:30 -07003091 FUNCTION WLANTL_GetLinkQuality
3092
3093 DESCRIPTION
3094 TL will extract the SNR information from every data packet from the
3095 ongoing traffic and will store it. It will provide the result to SME
3096 upon request.
3097
3098 DEPENDENCIES
3099
3100 WARNING: the read and write of this value will not be protected
3101 by locks, therefore the information obtained after a read
3102 might not always be consistent.
3103
3104 PARAMETERS
3105
3106 IN
3107 pvosGCtx: pointer to the global vos context; a handle to TL's
3108 or SME's control block can be extracted from its context
3109 ucSTAId: station identifier for the requested value
3110
3111 OUT
3112 puLinkQuality: the average value of the SNR
3113
3114
3115 RETURN VALUE
3116 The result code associated with performing the operation
3117
3118 VOS_STATUS_E_INVAL: Input parameters are invalid
3119 VOS_STATUS_E_FAULT: Station ID is outside array boundaries or pointer
3120 to TL cb is NULL ; access would cause a page fault
3121 VOS_STATUS_E_EXISTS: STA was not yet registered
3122 VOS_STATUS_SUCCESS: Everything is good :)
3123
3124 SIDE EFFECTS
3125
3126============================================================================*/
3127VOS_STATUS
3128WLANTL_GetLinkQuality
3129(
3130 v_PVOID_t pvosGCtx,
3131 v_U8_t ucSTAId,
3132 v_U32_t* puLinkQuality
3133)
3134{
3135 WLANTL_CbType* pTLCb = NULL;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05303136 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07003137
3138 /*------------------------------------------------------------------------
3139 Sanity check
3140 ------------------------------------------------------------------------*/
3141 if ( NULL == puLinkQuality )
3142 {
3143 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3144 "Invalid parameter sent on WLANTL_GetLinkQuality"));
3145 return VOS_STATUS_E_INVAL;
3146 }
3147
3148 if ( WLANTL_STA_ID_INVALID( ucSTAId ) )
3149 {
3150 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3151 "Invalid station id requested on WLANTL_GetLinkQuality"));
3152 return VOS_STATUS_E_FAULT;
3153 }
3154
3155 /*------------------------------------------------------------------------
3156 Extract TL control block and check existance
3157 ------------------------------------------------------------------------*/
3158 pTLCb = VOS_GET_TL_CB(pvosGCtx);
3159 if ( NULL == pTLCb )
3160 {
3161 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3162 "Invalid TL pointer from pvosGCtx on WLANTL_GetLinkQuality"));
3163 return VOS_STATUS_E_FAULT;
3164 }
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05303165 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
Jeff Johnson295189b2012-06-20 16:38:30 -07003166
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05303167 if ( NULL == pClientSTA )
3168 {
3169 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3170 "WLAN TL:Client Memory was not allocated on %s", __func__));
3171 return VOS_STATUS_E_FAILURE;
3172 }
3173
3174 if ( 0 == pClientSTA->ucExists )
Jeff Johnson295189b2012-06-20 16:38:30 -07003175 {
3176 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3177 "Station was not previously registered on WLANTL_GetLinkQuality"));
3178 return VOS_STATUS_E_EXISTS;
3179 }
3180
3181 /*------------------------------------------------------------------------
3182 Copy will not be locked; please read restriction
3183 ------------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05303184 *puLinkQuality = pClientSTA->uLinkQualityAvg;
Jeff Johnson295189b2012-06-20 16:38:30 -07003185
3186 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
3187 "WLANTL_GetLinkQuality for STA: %d LinkQuality: %d", ucSTAId, *puLinkQuality));
3188
3189 return VOS_STATUS_SUCCESS;
3190}/* WLANTL_GetLinkQuality */
3191
3192/*==========================================================================
3193
3194 FUNCTION WLANTL_FlushStaTID
3195
3196 DESCRIPTION
3197 TL provides this API as an interface to SME (BAP) layer. TL inturn posts a
3198 message to HAL. This API is called by the SME inorder to perform a flush
3199 operation.
3200
3201 DEPENDENCIES
3202
3203 PARAMETERS
3204
3205 IN
3206 pvosGCtx: pointer to the global vos context; a handle to TL's
3207 or SME's control block can be extracted from its context
3208 ucSTAId: station identifier for the requested value
3209 ucTid: Tspec ID for the new BA session
3210
3211 OUT
3212 The response for this post is received in the main thread, via a response
3213 message from HAL to TL.
3214
3215 RETURN VALUE
3216 VOS_STATUS_SUCCESS: Everything is good :)
3217
3218 SIDE EFFECTS
3219============================================================================*/
3220VOS_STATUS
3221WLANTL_FlushStaTID
3222(
3223 v_PVOID_t pvosGCtx,
3224 v_U8_t ucSTAId,
3225 v_U8_t ucTid
3226)
3227{
3228 WLANTL_CbType* pTLCb = NULL;
3229 tpFlushACReq FlushACReqPtr = NULL;
3230 vos_msg_t vosMessage;
3231
3232
3233 if ( WLANTL_STA_ID_INVALID( ucSTAId ) )
3234 {
3235 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3236 "Invalid station id requested on WLANTL_FlushStaTID"));
3237 return VOS_STATUS_E_FAULT;
3238 }
3239
3240 /*------------------------------------------------------------------------
3241 Extract TL control block and check existance
3242 ------------------------------------------------------------------------*/
3243 pTLCb = VOS_GET_TL_CB(pvosGCtx);
3244 if ( NULL == pTLCb )
3245 {
3246 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3247 "Invalid TL pointer from pvosGCtx on WLANTL_FlushStaTID"));
3248 return VOS_STATUS_E_FAULT;
3249 }
3250
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05303251 if ( NULL == pTLCb->atlSTAClients[ucSTAId] )
3252 {
3253 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3254 "WLAN TL:Client Memory was not allocated on %s", __func__));
3255 return VOS_STATUS_E_FAILURE;
3256 }
3257
3258 if ( 0 == pTLCb->atlSTAClients[ucSTAId]->ucExists )
Jeff Johnson295189b2012-06-20 16:38:30 -07003259 {
3260 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3261 "Station was not previously registered on WLANTL_FlushStaTID"));
3262 return VOS_STATUS_E_EXISTS;
3263 }
3264
3265 /*------------------------------------------------------------------------
3266 We need to post a message with the STA, TID value to HAL. HAL performs the flush
3267 ------------------------------------------------------------------------*/
3268 FlushACReqPtr = vos_mem_malloc(sizeof(tFlushACReq));
3269
3270 if ( NULL == FlushACReqPtr )
3271 {
3272 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3273 "WLAN TL: fatal failure, cannot allocate Flush Req structure"));
3274 VOS_ASSERT(0);
3275 return VOS_STATUS_E_NOMEM;
3276 }
3277
3278 // Start constructing the message for HAL
3279 FlushACReqPtr->mesgType = SIR_TL_HAL_FLUSH_AC_REQ;
3280 FlushACReqPtr->mesgLen = sizeof(tFlushACReq);
3281 FlushACReqPtr->mesgLen = sizeof(tFlushACReq);
3282 FlushACReqPtr->ucSTAId = ucSTAId;
3283 FlushACReqPtr->ucTid = ucTid;
3284
3285 vosMessage.type = WDA_TL_FLUSH_AC_REQ;
3286 vosMessage.bodyptr = (void *)FlushACReqPtr;
3287
3288 vos_mq_post_message(VOS_MQ_ID_WDA, &vosMessage);
3289 return VOS_STATUS_SUCCESS;
3290}
3291
3292
3293/*----------------------------------------------------------------------------
3294 INTERACTION WITH PE
3295 ---------------------------------------------------------------------------*/
Siddharth Bhal4551b102014-10-09 21:36:36 +05303296/*==========================================================================
Jeff Johnson295189b2012-06-20 16:38:30 -07003297
Siddharth Bhal4551b102014-10-09 21:36:36 +05303298 FUNCTION WLANTL_updateSpoofMacAddr
3299
3300 DESCRIPTION
3301 Called by HDD to update macaddr
3302
3303 DEPENDENCIES
3304 TL must be initialized before this API can be called.
3305
3306 PARAMETERS
3307
3308 IN
3309 pvosGCtx: pointer to the global vos context; a handle to
3310 TL's control block can be extracted from its context
3311 spoofMacAddr: spoofed mac adderess
3312 selfMacAddr: self Mac Address
3313
3314 RETURN VALUE
3315 The result code associated with performing the operation
3316
3317 VOS_STATUS_E_INVAL: Input parameters are invalid
3318 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
3319 page fault
3320 VOS_STATUS_SUCCESS: Everything is good :)
3321
3322 SIDE EFFECTS
3323
3324============================================================================*/
3325VOS_STATUS
3326WLANTL_updateSpoofMacAddr
3327(
3328 v_PVOID_t pvosGCtx,
3329 v_MACADDR_t* spoofMacAddr,
3330 v_MACADDR_t* selfMacAddr
3331)
3332{
3333 WLANTL_CbType* pTLCb = NULL;
3334 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
3335
3336 /*------------------------------------------------------------------------
Siddharth Bhal4551b102014-10-09 21:36:36 +05303337 Extract TL control block
3338 ------------------------------------------------------------------------*/
3339 pTLCb = VOS_GET_TL_CB(pvosGCtx);
3340 if ( NULL == pTLCb )
3341 {
3342 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3343 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_ChangeSTAState");
3344 return VOS_STATUS_E_FAULT;
3345 }
3346
3347 vos_mem_copy(pTLCb->spoofMacAddr.selfMac.bytes, selfMacAddr,
3348 VOS_MAC_ADDRESS_LEN);
3349 vos_mem_copy(pTLCb->spoofMacAddr.spoofMac.bytes, spoofMacAddr,
3350 VOS_MAC_ADDRESS_LEN);
3351
3352 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_LOW,
3353 "TL: SelfSTA mac Addr for current Scan "MAC_ADDRESS_STR,
3354 MAC_ADDR_ARRAY(pTLCb->spoofMacAddr.selfMac.bytes));
3355
3356 return VOS_STATUS_SUCCESS;
3357}/* WLANTL_updateSpoofMacAddr */
Jeff Johnson295189b2012-06-20 16:38:30 -07003358/*==========================================================================
3359
3360 FUNCTION WLANTL_RegisterMgmtFrmClient
3361
3362 DESCRIPTION
3363 Called by PE to register as a client for management frames delivery.
3364
3365 DEPENDENCIES
3366 TL must be initialized before this API can be called.
3367
3368 PARAMETERS
3369
3370 IN
3371 pvosGCtx: pointer to the global vos context; a handle to
3372 TL's control block can be extracted from its context
3373 pfnTlMgmtFrmRx: pointer to the receive processing routine for
3374 management frames
3375
3376 RETURN VALUE
3377 The result code associated with performing the operation
3378
3379 VOS_STATUS_E_INVAL: Input parameters are invalid
3380 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
3381 page fault
3382 VOS_STATUS_E_EXISTS: Mgmt Frame client was already registered
3383 VOS_STATUS_SUCCESS: Everything is good :)
3384
3385 SIDE EFFECTS
3386
3387============================================================================*/
3388VOS_STATUS
3389WLANTL_RegisterMgmtFrmClient
3390(
3391 v_PVOID_t pvosGCtx,
3392 WLANTL_MgmtFrmRxCBType pfnTlMgmtFrmRx
3393)
3394{
3395 WLANTL_CbType* pTLCb = NULL;
3396 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
3397
3398 /*------------------------------------------------------------------------
3399 Sanity check
3400 ------------------------------------------------------------------------*/
3401 if ( NULL == pfnTlMgmtFrmRx )
3402 {
3403 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3404 "WLAN TL:Invalid parameter sent on WLANTL_RegisterMgmtFrmClient"));
3405 return VOS_STATUS_E_INVAL;
3406 }
3407
3408 /*------------------------------------------------------------------------
3409 Extract TL control block
3410 ------------------------------------------------------------------------*/
3411 pTLCb = VOS_GET_TL_CB(pvosGCtx);
3412 if ( NULL == pTLCb )
3413 {
3414 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3415 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_ChangeSTAState"));
3416 return VOS_STATUS_E_FAULT;
3417 }
3418
3419 /*------------------------------------------------------------------------
3420 Make sure this is the first registration attempt
3421 ------------------------------------------------------------------------*/
3422 if ( 0 != pTLCb->tlMgmtFrmClient.ucExists )
3423 {
3424 pTLCb->tlMgmtFrmClient.ucExists++;
3425 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3426 "WLAN TL:Management frame client was already registered"));
3427 return VOS_STATUS_E_EXISTS;
3428 }
3429
3430 /*------------------------------------------------------------------------
3431 Register station with TL
3432 ------------------------------------------------------------------------*/
3433 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
3434 "WLAN TL:Registering Management Frame Client" ));
3435
3436 pTLCb->tlMgmtFrmClient.ucExists++;
3437
3438 if ( NULL != pfnTlMgmtFrmRx )
3439 {
3440 pTLCb->tlMgmtFrmClient.pfnTlMgmtFrmRx = pfnTlMgmtFrmRx;
3441 }
3442
3443 pTLCb->tlMgmtFrmClient.vosPendingDataBuff = NULL;
3444
3445 return VOS_STATUS_SUCCESS;
3446}/* WLANTL_RegisterMgmtFrmClient */
3447
3448/*==========================================================================
3449
3450 FUNCTION WLANTL_DeRegisterMgmtFrmClient
3451
3452 DESCRIPTION
3453 Called by PE to deregister as a client for management frames delivery.
3454
3455 DEPENDENCIES
3456 TL must be initialized before this API can be called.
3457
3458 PARAMETERS
3459
3460 IN
3461 pvosGCtx: pointer to the global vos context; a handle to
3462 TL's control block can be extracted from its context
3463 RETURN VALUE
3464 The result code associated with performing the operation
3465
3466 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
3467 page fault
3468 VOS_STATUS_E_EXISTS: Mgmt Frame client was never registered
3469 VOS_STATUS_SUCCESS: Everything is good :)
3470
3471 SIDE EFFECTS
3472
3473============================================================================*/
3474VOS_STATUS
3475WLANTL_DeRegisterMgmtFrmClient
3476(
3477 v_PVOID_t pvosGCtx
3478)
3479{
3480 WLANTL_CbType* pTLCb = NULL;
3481 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
3482
3483 /*------------------------------------------------------------------------
3484 Extract TL control block
3485 ------------------------------------------------------------------------*/
3486 pTLCb = VOS_GET_TL_CB(pvosGCtx);
3487 if ( NULL == pTLCb )
3488 {
3489 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3490 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_ChangeSTAState"));
3491 return VOS_STATUS_E_FAULT;
3492 }
3493
3494 /*------------------------------------------------------------------------
3495 Make sure this is the first registration attempt
3496 ------------------------------------------------------------------------*/
3497 if ( 0 == pTLCb->tlMgmtFrmClient.ucExists )
3498 {
3499 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3500 "WLAN TL:Management frame client was never registered"));
3501 return VOS_STATUS_E_EXISTS;
3502 }
3503
3504 /*------------------------------------------------------------------------
3505 Clear registration with TL
3506 ------------------------------------------------------------------------*/
3507 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
3508 "WLAN TL:Deregistering Management Frame Client" ));
3509
3510 pTLCb->tlMgmtFrmClient.pfnTlMgmtFrmRx = WLANTL_MgmtFrmRxDefaultCb;
3511 if ( NULL != pTLCb->tlMgmtFrmClient.vosPendingDataBuff)
3512 {
3513 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
3514 "WLAN TL:Management cache buffer not empty on deregistering"
3515 " - dropping packet" ));
3516 vos_pkt_return_packet(pTLCb->tlMgmtFrmClient.vosPendingDataBuff);
3517
3518 pTLCb->tlMgmtFrmClient.vosPendingDataBuff = NULL;
3519 }
3520
3521 pTLCb->tlMgmtFrmClient.ucExists = 0;
3522
3523 return VOS_STATUS_SUCCESS;
3524}/* WLANTL_RegisterMgmtFrmClient */
3525
3526/*==========================================================================
3527
3528 FUNCTION WLANTL_TxMgmtFrm
3529
3530 DESCRIPTION
3531 Called by PE when it want to send out a management frame.
3532 HAL will also use this API for the few frames it sends out, they are not
3533 management frames howevere it is accepted that an exception will be
3534 allowed ONLY for the usage of HAL.
3535 Generic data frames SHOULD NOT travel through this function.
3536
3537 DEPENDENCIES
3538 TL must be initialized before this API can be called.
3539
3540 RESTRICTION: If PE sends another packet before TL manages to process the
3541 previously sent packet call will end in failure
3542
3543 Frames comming through here must be 802.11 frames, frame
3544 translation in UMA will be automatically disabled.
3545
3546 PARAMETERS
3547
3548 IN
3549 pvosGCtx: pointer to the global vos context;a handle to TL's
3550 control block can be extracted from its context
3551 vosFrmBuf: pointer to a vOSS buffer containing the management
3552 frame to be transmitted
3553 usFrmLen: the length of the frame to be transmitted; information
3554 is already included in the vOSS buffer
3555 wFrmType: the type of the frame being transmitted
3556 tid: tid used to transmit this frame
3557 pfnCompTxFunc: function pointer to the transmit complete routine
3558 pvBDHeader: pointer to the BD header, if NULL it means it was not
3559 yet constructed and it lies within TL's responsibility
3560 to do so; if not NULL it is expected that it was
3561 already packed inside the vos packet
3562 ucAckResponse: flag notifying it an interrupt is needed for the
3563 acknowledgement received when the frame is sent out
3564 the air and ; the interrupt will be processed by HAL,
3565 only one such frame can be pending in the system at
3566 one time.
3567
3568
3569 RETURN VALUE
3570 The result code associated with performing the operation
3571
3572 VOS_STATUS_E_INVAL: Input parameters are invalid
3573 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
3574 page fault
3575 VOS_STATUS_E_EXISTS: Mgmt Frame client was not yet registered
3576 VOS_STATUS_E_BUSY: The previous Mgmt packet was not yet transmitted
3577 VOS_STATUS_SUCCESS: Everything is good :)
3578
3579 Other failure messages may be returned from the BD header handling
3580 routines, please check apropriate API for more info.
3581
3582 SIDE EFFECTS
3583
3584============================================================================*/
3585VOS_STATUS
3586WLANTL_TxMgmtFrm
3587(
3588 v_PVOID_t pvosGCtx,
3589 vos_pkt_t* vosFrmBuf,
3590 v_U16_t usFrmLen,
3591 v_U8_t wFrmType,
3592 v_U8_t ucTid,
3593 WLANTL_TxCompCBType pfnCompTxFunc,
3594 v_PVOID_t pvBDHeader,
Ganesh Kondabattini10e67352015-03-16 17:41:57 +05303595 v_U32_t ucAckResponse,
3596 v_U32_t ucTxBdToken
Jeff Johnson295189b2012-06-20 16:38:30 -07003597)
3598{
3599 WLANTL_CbType* pTLCb = NULL;
3600 v_MACADDR_t vDestMacAddr;
3601 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
3602 v_U16_t usPktLen;
3603 v_U32_t usTimeStamp = 0;
3604 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
3605
3606 /*------------------------------------------------------------------------
3607 Sanity check
3608 ------------------------------------------------------------------------*/
3609 if ( NULL == vosFrmBuf )
3610 {
3611 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3612 "WLAN TL:Invalid parameter sent on WLANTL_TxMgmtFrm"));
3613 return VOS_STATUS_E_INVAL;
3614 }
3615
3616 /*------------------------------------------------------------------------
3617 Extract TL control block
3618 ------------------------------------------------------------------------*/
3619 pTLCb = VOS_GET_TL_CB(pvosGCtx);
3620 if ( NULL == pTLCb )
3621 {
3622 TLLOGP(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_FATAL,
3623 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_TxMgmtFrm"));
3624 return VOS_STATUS_E_FAULT;
3625 }
3626
3627 /*------------------------------------------------------------------------
3628 Ensure that management frame client was previously registered
3629 ------------------------------------------------------------------------*/
3630 if ( 0 == pTLCb->tlMgmtFrmClient.ucExists )
3631 {
3632 pTLCb->tlMgmtFrmClient.ucExists++;
3633 TLLOGP(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_FATAL,
3634 "WLAN TL:Management Frame client not register on WLANTL_TxMgmtFrm"));
3635 return VOS_STATUS_E_EXISTS;
3636 }
3637
3638 /*------------------------------------------------------------------------
3639 Check if any Mgmt Frm is pending
3640 ------------------------------------------------------------------------*/
3641 //vosTempBuff = pTLCb->tlMgmtFrmClient.vosPendingDataBuff;
3642 if ( NULL != pTLCb->tlMgmtFrmClient.vosPendingDataBuff )
3643 {
3644
3645 TLLOGP(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_FATAL,
3646 "WLAN TL:Management Frame already pending tx in TL: failing old one"));
3647
3648
3649 /*Failing the tx for the previous packet enqued by PE*/
Arun Kumar Khandavalli0af8d3c2014-02-07 18:05:11 +05303650 //vos_atomic_set( (uintptr_t*)&pTLCb->tlMgmtFrmClient.vosPendingDataBuff,
3651 // (uintptr_t)NULL);
Jeff Johnson295189b2012-06-20 16:38:30 -07003652
3653 //vos_pkt_get_user_data_ptr( vosTempBuff, VOS_PKT_USER_DATA_ID_TL,
3654 // (v_PVOID_t)&pfnTxComp);
3655
3656 /*it should never be NULL - default handler should be registered if none*/
3657 //if ( NULL == pfnTxComp )
3658 //{
3659 // VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3660 // "NULL pointer to Tx Complete on WLANTL_TxMgmtFrm");
3661 // VOS_ASSERT(0);
3662 // return VOS_STATUS_E_FAULT;
3663 //}
3664
3665 //pfnTxComp( pvosGCtx, vosTempBuff, VOS_STATUS_E_RESOURCES );
3666 //return VOS_STATUS_E_BUSY;
3667
3668
3669 //pfnCompTxFunc( pvosGCtx, vosFrmBuf, VOS_STATUS_E_RESOURCES);
3670 return VOS_STATUS_E_RESOURCES;
3671 }
3672
3673
3674 /*------------------------------------------------------------------------
3675 Check if BD header was build, if not construct
3676 ------------------------------------------------------------------------*/
3677 if ( NULL == pvBDHeader )
3678 {
3679 v_MACADDR_t* pvAddr2MacAddr;
3680 v_U8_t uQosHdr = VOS_FALSE;
3681
3682 /* Get address 2 of Mangement Frame to give to WLANHAL_FillTxBd */
3683 vosStatus = vos_pkt_peek_data( vosFrmBuf,
3684 WLANTL_MAC_ADDR_ALIGN(1) + VOS_MAC_ADDR_SIZE,
3685 (v_PVOID_t)&pvAddr2MacAddr, VOS_MAC_ADDR_SIZE);
3686
3687 if ( VOS_STATUS_SUCCESS != vosStatus )
3688 {
3689 TLLOGP(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_FATAL,
3690 "WLAN TL:Failed while attempting to get addr2 %d", vosStatus));
3691 return vosStatus;
3692 }
Gopichand Nakkala0f3eb5c2013-05-07 16:48:38 +05303693
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003694 /* ESE IAPP/TDLS Frame which are data frames but technically used
Jeff Johnson295189b2012-06-20 16:38:30 -07003695 * for management functionality comes through route.
3696 */
3697 if (WLANTL_IS_QOS_DATA_FRAME(wFrmType)) \
3698 {
3699 uQosHdr = VOS_TRUE;
3700 }
Siddharth Bhal4551b102014-10-09 21:36:36 +05303701
3702 if (WLANTL_IS_PROBE_REQ(wFrmType))
3703 {
3704 if (VOS_TRUE == vos_mem_compare((v_VOID_t*) pvAddr2MacAddr,
3705 (v_VOID_t*) &pTLCb->spoofMacAddr.spoofMac, VOS_MAC_ADDRESS_LEN))
3706 {
3707 pvAddr2MacAddr = (v_PVOID_t)pTLCb->spoofMacAddr.selfMac.bytes;
3708 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
3709 "TL: using self sta addr to get staidx for spoofed probe req "
3710 MAC_ADDRESS_STR, MAC_ADDR_ARRAY(pvAddr2MacAddr->bytes));
3711 }
3712 }
3713
Jeff Johnson295189b2012-06-20 16:38:30 -07003714 /*----------------------------------------------------------------------
3715 Call WDA to build TX header
3716 ----------------------------------------------------------------------*/
3717 vosStatus = WDA_DS_BuildTxPacketInfo( pvosGCtx, vosFrmBuf , &vDestMacAddr,
3718 1 /* always 802.11 frames*/, &usPktLen, uQosHdr /*qos not enabled !!!*/,
Siddharth Bhal4551b102014-10-09 21:36:36 +05303719 0 /* WDS off */, 0, wFrmType, pvAddr2MacAddr, ucTid,
Sravan Kumar Kairamd9e8cbb2017-01-17 12:17:28 +05303720 ucAckResponse, usTimeStamp, 0, 0, 0, ucTxBdToken);
Jeff Johnson295189b2012-06-20 16:38:30 -07003721
3722
3723 if ( !VOS_IS_STATUS_SUCCESS(vosStatus) )
3724 {
3725 TLLOGP(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_FATAL,
3726 "WLAN TL:Failed while attempting to build TX header %d", vosStatus));
3727 return vosStatus;
3728 }
3729 }/* if BD header not present */
3730
3731 /*------------------------------------------------------------------------
3732 Save buffer and notify BAL; no lock is needed if the above restriction
3733 is met
3734 Save the tx complete fnct pointer as tl specific data in the vos buffer
3735 ------------------------------------------------------------------------*/
3736 if ( NULL != pfnCompTxFunc )
3737 {
3738 vos_pkt_set_user_data_ptr( vosFrmBuf, VOS_PKT_USER_DATA_ID_TL,
3739 (v_PVOID_t)pfnCompTxFunc);
3740 }
3741 else
3742 {
3743 vos_pkt_set_user_data_ptr( vosFrmBuf, VOS_PKT_USER_DATA_ID_TL,
3744 (v_PVOID_t)WLANTL_TxCompDefaultCb);
3745
3746 }
Arun Kumar Khandavalli0af8d3c2014-02-07 18:05:11 +05303747 vos_atomic_set( (uintptr_t*)&pTLCb->tlMgmtFrmClient.vosPendingDataBuff,
3748 (uintptr_t)vosFrmBuf);
Jeff Johnson295189b2012-06-20 16:38:30 -07003749
3750 /*------------------------------------------------------------------------
3751 Check if thre are enough resources for transmission and tx is not
3752 suspended.
3753 ------------------------------------------------------------------------*/
3754 if ( pTLCb->uResCount >= WDA_TLI_MIN_RES_MF )
3755 {
3756 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
3757 "WLAN TL:Issuing Xmit start request to BAL for MGMT"));
3758 vosStatus = WDA_DS_StartXmit(pvosGCtx);
3759 if(VOS_STATUS_SUCCESS != vosStatus)
3760 {
3761 TLLOGP(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_FATAL,
3762 "WLAN TL:WDA_DS_StartXmit fails. vosStatus %d", vosStatus));
Arun Kumar Khandavalli0af8d3c2014-02-07 18:05:11 +05303763 vos_atomic_set( (uintptr_t*)&pTLCb->tlMgmtFrmClient.vosPendingDataBuff,0);
Jeff Johnson295189b2012-06-20 16:38:30 -07003764 }
3765 return vosStatus;
3766
3767 }
3768 else
3769 {
3770 /*---------------------------------------------------------------------
3771 No error code is sent because TL will resume tx autonomously if
3772 resources become available or tx gets resumed
3773 ---------------------------------------------------------------------*/
3774 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
3775 "WLAN TL:Request to send for Mgmt Frm but condition not met. Res: %d",
3776 pTLCb->uResCount));
3777 }
3778
3779 return VOS_STATUS_SUCCESS;
3780}/* WLANTL_TxMgmtFrm */
3781
3782/*----------------------------------------------------------------------------
3783 INTERACTION WITH HAL
3784 ---------------------------------------------------------------------------*/
3785
3786/*==========================================================================
3787
3788 FUNCTION WLANTL_ResetNotification
3789
3790 DESCRIPTION
3791 HAL notifies TL when the module is being reset.
3792 Currently not used.
3793
3794 DEPENDENCIES
3795
3796 PARAMETERS
3797
3798 IN
3799 pvosGCtx: pointer to the global vos context; a handle to TL's
3800 control block can be extracted from its context
3801
3802
3803 RETURN VALUE
3804 The result code associated with performing the operation
3805
3806 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
3807 page fault
3808 VOS_STATUS_SUCCESS: Everything is good :)
3809
3810 SIDE EFFECTS
3811
3812============================================================================*/
3813VOS_STATUS
3814WLANTL_ResetNotification
3815(
3816 v_PVOID_t pvosGCtx
3817)
3818{
3819 WLANTL_CbType* pTLCb = NULL;
3820 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
3821
3822 /*------------------------------------------------------------------------
3823 Sanity check
3824 Extract TL control block
3825 ------------------------------------------------------------------------*/
3826 pTLCb = VOS_GET_TL_CB(pvosGCtx);
3827 if ( NULL == pTLCb )
3828 {
3829 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3830 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_ResetNotification"));
3831 return VOS_STATUS_E_FAULT;
3832 }
3833
3834 WLANTL_CleanCB(pTLCb, 1 /*empty all queues and pending packets*/);
3835 return VOS_STATUS_SUCCESS;
3836}/* WLANTL_ResetNotification */
3837
3838/*==========================================================================
3839
3840 FUNCTION WLANTL_SuspendDataTx
3841
3842 DESCRIPTION
3843 HAL calls this API when it wishes to suspend transmission for a
3844 particular STA.
3845
3846 DEPENDENCIES
3847 The STA for which the request is made must be first registered with
3848 TL by HDD.
3849
3850 RESTRICTION: In case of a suspend, the flag write and read will not be
3851 locked: worst case scenario one more packet can get
3852 through before the flag gets updated (we can make this
3853 write atomic as well to guarantee consistency)
3854
3855 PARAMETERS
3856
3857 IN
3858 pvosGCtx: pointer to the global vos context; a handle to TL's
3859 control block can be extracted from its context
3860 pucSTAId: identifier of the station for which the request is made;
3861 a value of NULL assumes suspend on all active station
3862 pfnSuspendTxCB: pointer to the suspend result notification in case the
3863 call is asynchronous
3864
3865
3866 RETURN VALUE
3867 The result code associated with performing the operation
3868
3869 VOS_STATUS_E_FAULT: Station ID is outside array boundaries or pointer
3870 to TL cb is NULL ; access would cause a page fault
3871 VOS_STATUS_E_EXISTS: Station was not registered
3872 VOS_STATUS_SUCCESS: Everything is good :)
3873
3874 SIDE EFFECTS
3875
3876============================================================================*/
3877
3878VOS_STATUS
3879WLANTL_SuspendDataTx
3880(
3881 v_PVOID_t pvosGCtx,
3882 v_U8_t* pucSTAId,
3883 WLANTL_SuspendCBType pfnSuspendTx
3884)
3885{
3886 WLANTL_CbType* pTLCb = NULL;
3887 vos_msg_t vosMsg;
Jeff Johnson295189b2012-06-20 16:38:30 -07003888
3889 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
3890
3891 /*------------------------------------------------------------------------
3892 Sanity check
3893 Extract TL control block
3894 ------------------------------------------------------------------------*/
3895 pTLCb = VOS_GET_TL_CB(pvosGCtx);
Hoonki Lee14621352013-04-16 17:51:19 -07003896 if ( NULL == pTLCb )
Jeff Johnson295189b2012-06-20 16:38:30 -07003897 {
3898 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3899 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_SuspendDataTx"));
3900 return VOS_STATUS_E_FAULT;
3901 }
3902
3903 /*------------------------------------------------------------------------
3904 Check the type of request: generic suspend, or per station suspend
3905 ------------------------------------------------------------------------*/
Hoonki Lee14621352013-04-16 17:51:19 -07003906 if (NULL == pucSTAId)
Jeff Johnson295189b2012-06-20 16:38:30 -07003907 {
3908 /* General Suspend Request received */
3909 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
3910 "WLAN TL:General suspend requested"));
Hoonki Lee14621352013-04-16 17:51:19 -07003911 vos_atomic_set_U8( &pTLCb->ucTxSuspended, 1);
Jeff Johnson295189b2012-06-20 16:38:30 -07003912 vosMsg.reserved = WLAN_MAX_STA_COUNT;
3913 }
3914 else
3915 {
Hoonki Lee14621352013-04-16 17:51:19 -07003916 if ( WLANTL_STA_ID_INVALID( *pucSTAId ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07003917 {
Hoonki Lee14621352013-04-16 17:51:19 -07003918 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3919 "WLAN TL:Invalid station id %d requested on WLANTL_SuspendDataTx", *pucSTAId));
3920 return VOS_STATUS_E_FAULT;
3921 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003922
Gopichand Nakkalae5fef6c2013-06-19 18:04:23 +05303923 if ( NULL == pTLCb->atlSTAClients[*pucSTAId] )
3924 {
3925 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3926 "WLAN TL:Invalid pTLCb->atlSTAClients pointer for STA Id :%d on "
3927 "WLANTL_SuspendDataTx", *pucSTAId));
3928 return VOS_STATUS_E_FAULT;
3929 }
3930
3931 if ( 0 == pTLCb->atlSTAClients[*pucSTAId]->ucExists )
Hoonki Lee14621352013-04-16 17:51:19 -07003932 {
3933 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3934 "WLAN TL:Station %d was not previously registered on WLANTL_SuspendDataTx", *pucSTAId));
3935 return VOS_STATUS_E_EXISTS;
3936 }
3937
3938 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
3939 "WLAN TL:Suspend request for station: %d", *pucSTAId));
3940 vos_atomic_set_U8( &pTLCb->atlSTAClients[*pucSTAId]->ucTxSuspended, 1);
Jeff Johnson295189b2012-06-20 16:38:30 -07003941 vosMsg.reserved = *pucSTAId;
3942 }
3943
3944 /*------------------------------------------------------------------------
3945 Serialize request through TX thread
3946 ------------------------------------------------------------------------*/
3947 vosMsg.type = WLANTL_TX_SIG_SUSPEND;
3948 vosMsg.bodyptr = (v_PVOID_t)pfnSuspendTx;
3949
Katya Nigam42e16e82014-02-04 16:28:55 +05303950 MTRACE(vos_trace(VOS_MODULE_ID_TL, TRACE_CODE_TL_SUSPEND_DATA_TX,
3951 vosMsg.reserved , 0 ));
3952
Jeff Johnson295189b2012-06-20 16:38:30 -07003953 if(!VOS_IS_STATUS_SUCCESS(vos_tx_mq_serialize( VOS_MQ_ID_TL, &vosMsg)))
3954 {
3955 VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003956 " %s fails to post message", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003957 }
3958
3959 return VOS_STATUS_SUCCESS;
3960}/* WLANTL_SuspendDataTx */
3961
3962/*==========================================================================
3963
3964 FUNCTION WLANTL_ResumeDataTx
3965
3966 DESCRIPTION
3967 Called by HAL to resume data transmission for a given STA.
3968
3969 WARNING: If a station was individually suspended a global resume will
3970 not resume that station
3971
3972 DEPENDENCIES
3973
3974 PARAMETERS
3975
3976 IN
3977 pvosGCtx: pointer to the global vos context; a handle to TL's
3978 control block can be extracted from its context
3979 pucSTAId: identifier of the station which is being resumed; NULL
3980 translates into global resume
3981
3982 RETURN VALUE
3983 The result code associated with performing the operation
3984
3985 VOS_STATUS_E_FAULT: Station ID is outside array boundaries or pointer
3986 to TL cb is NULL ; access would cause a page fault
3987 VOS_STATUS_E_EXISTS: Station was not registered
3988 VOS_STATUS_SUCCESS: Everything is good :)
3989
3990 SIDE EFFECTS
3991
3992============================================================================*/
3993
3994VOS_STATUS
3995WLANTL_ResumeDataTx
3996(
3997 v_PVOID_t pvosGCtx,
3998 v_U8_t* pucSTAId
3999)
4000{
4001 WLANTL_CbType* pTLCb = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004002 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
4003
4004 /*------------------------------------------------------------------------
4005 Sanity check
4006 Extract TL control block
4007 ------------------------------------------------------------------------*/
4008 pTLCb = VOS_GET_TL_CB(pvosGCtx);
Hoonki Lee14621352013-04-16 17:51:19 -07004009 if ( NULL == pTLCb )
Jeff Johnson295189b2012-06-20 16:38:30 -07004010 {
4011 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
4012 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_ResumeDataTx"));
4013 return VOS_STATUS_E_FAULT;
4014 }
4015
Jeff Johnson295189b2012-06-20 16:38:30 -07004016 /*------------------------------------------------------------------------
4017 Check to see the type of resume
4018 ------------------------------------------------------------------------*/
Hoonki Lee14621352013-04-16 17:51:19 -07004019 if ( NULL == pucSTAId )
Jeff Johnson295189b2012-06-20 16:38:30 -07004020 {
Katya Nigam42e16e82014-02-04 16:28:55 +05304021 MTRACE(vos_trace(VOS_MODULE_ID_TL, TRACE_CODE_TL_RESUME_DATA_TX,
4022 41 , 0 ));
4023
Jeff Johnson295189b2012-06-20 16:38:30 -07004024 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
4025 "WLAN TL:General resume requested"));
4026 vos_atomic_set_U8( &pTLCb->ucTxSuspended, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004027 }
4028 else
4029 {
Katya Nigam42e16e82014-02-04 16:28:55 +05304030 MTRACE(vos_trace(VOS_MODULE_ID_TL, TRACE_CODE_TL_RESUME_DATA_TX,
4031 *pucSTAId , 0 ));
4032
Hoonki Lee14621352013-04-16 17:51:19 -07004033 if ( WLANTL_STA_ID_INVALID( *pucSTAId ))
Jeff Johnson295189b2012-06-20 16:38:30 -07004034 {
Hoonki Lee14621352013-04-16 17:51:19 -07004035 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
4036 "WLAN TL:Invalid station id %d requested on WLANTL_ResumeDataTx", *pucSTAId));
4037 return VOS_STATUS_E_FAULT;
4038 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004039
Gopichand Nakkalae5fef6c2013-06-19 18:04:23 +05304040 if ( NULL == pTLCb->atlSTAClients[*pucSTAId] )
4041 {
4042 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
4043 "WLAN TL:Invalid pTLCb->atlSTAClients pointer for STA Id :%d on "
4044 "WLANTL_ResumeDataTx", *pucSTAId));
4045 return VOS_STATUS_E_FAULT;
4046 }
4047
4048 if ( 0 == pTLCb->atlSTAClients[*pucSTAId]->ucExists )
Hoonki Lee14621352013-04-16 17:51:19 -07004049 {
4050 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
4051 "WLAN TL:Station %d was not previously registered on WLANTL_ResumeDataTx", *pucSTAId));
4052 return VOS_STATUS_E_EXISTS;
4053 }
4054
4055 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
4056 "WLAN TL:Resume request for station: %d", *pucSTAId));
4057 vos_atomic_set_U8( &pTLCb->atlSTAClients[*pucSTAId]->ucTxSuspended, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004058 }
4059
4060 /*------------------------------------------------------------------------
4061 Resuming transmission
4062 ------------------------------------------------------------------------*/
Hoonki Lee14621352013-04-16 17:51:19 -07004063 if (( pTLCb->uResCount >= WDA_TLI_MIN_RES_MF ) &&
4064 ( 0 == pTLCb->ucTxSuspended ))
Jeff Johnson295189b2012-06-20 16:38:30 -07004065 {
4066 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
4067 "WLAN TL:Resuming transmission"));
4068 return WDA_DS_StartXmit(pvosGCtx);
4069 }
4070
4071 return VOS_STATUS_SUCCESS;
4072}/* WLANTL_ResumeDataTx */
4073
4074/*==========================================================================
4075 FUNCTION WLANTL_SuspendCB
4076
4077 DESCRIPTION
4078 Callback function for serializing Suspend signal through Tx thread
4079
4080 DEPENDENCIES
4081 Just notify HAL that suspend in TL is complete.
4082
4083 PARAMETERS
4084
4085 IN
4086 pvosGCtx: pointer to the global vos context; a handle to TL's
4087 control block can be extracted from its context
4088 pUserData: user data sent with the callback
4089
4090 RETURN VALUE
4091 The result code associated with performing the operation
4092
4093 VOS_STATUS_E_INVAL: invalid input parameters
4094 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
4095 page fault
4096 VOS_STATUS_SUCCESS: Everything is good :)
4097
4098
4099 SIDE EFFECTS
4100
4101============================================================================*/
4102VOS_STATUS
4103WLANTL_SuspendCB
4104(
4105 v_PVOID_t pvosGCtx,
4106 WLANTL_SuspendCBType pfnSuspendCB,
4107 v_U16_t usReserved
4108)
4109{
4110 WLANTL_CbType* pTLCb = NULL;
4111 v_U8_t ucSTAId = (v_U8_t)usReserved;
4112 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
4113
4114 /*------------------------------------------------------------------------
4115 Sanity check
4116 ------------------------------------------------------------------------*/
4117 if ( NULL == pfnSuspendCB )
4118 {
4119 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
4120 "WLAN TL: No Call back processing requested WLANTL_SuspendCB"));
4121 return VOS_STATUS_SUCCESS;
4122 }
4123
4124 /*------------------------------------------------------------------------
4125 Extract TL control block
4126 ------------------------------------------------------------------------*/
4127 pTLCb = VOS_GET_TL_CB(pvosGCtx);
4128 if ( NULL == pTLCb )
4129 {
4130 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
4131 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_SuspendCB"));
4132 return VOS_STATUS_E_FAULT;
4133 }
4134
4135 if ( WLANTL_STA_ID_INVALID( ucSTAId ) )
4136 {
4137 pfnSuspendCB(pvosGCtx, NULL, VOS_STATUS_SUCCESS);
4138 }
4139 else
4140 {
4141 pfnSuspendCB(pvosGCtx, &ucSTAId, VOS_STATUS_SUCCESS);
4142 }
4143
4144 return VOS_STATUS_SUCCESS;
4145}/*WLANTL_SuspendCB*/
4146
4147
4148/*----------------------------------------------------------------------------
4149 CLIENT INDEPENDENT INTERFACE
4150 ---------------------------------------------------------------------------*/
4151
4152/*==========================================================================
4153
4154 FUNCTION WLANTL_GetTxPktCount
4155
4156 DESCRIPTION
4157 TL will provide the number of transmitted packets counted per
4158 STA per TID.
4159
4160 DEPENDENCIES
4161
4162 PARAMETERS
4163
4164 IN
4165 pvosGCtx: pointer to the global vos context; a handle to TL's
4166 control block can be extracted from its context
4167 ucSTAId: identifier of the station
4168 ucTid: identifier of the tspec
4169
4170 OUT
4171 puTxPktCount: the number of packets tx packet for this STA and TID
4172
4173 RETURN VALUE
4174 The result code associated with performing the operation
4175
4176 VOS_STATUS_E_INVAL: Input parameters are invalid
4177 VOS_STATUS_E_FAULT: Station ID is outside array boundaries or pointer
4178 to TL cb is NULL ; access would cause a page fault
4179 VOS_STATUS_E_EXISTS: Station was not registered
4180 VOS_STATUS_SUCCESS: Everything is good :)
4181
4182 SIDE EFFECTS
4183
4184============================================================================*/
4185VOS_STATUS
4186WLANTL_GetTxPktCount
4187(
4188 v_PVOID_t pvosGCtx,
4189 v_U8_t ucSTAId,
4190 v_U8_t ucTid,
4191 v_U32_t* puTxPktCount
4192)
4193{
4194 WLANTL_CbType* pTLCb = NULL;
4195 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
4196
4197 /*------------------------------------------------------------------------
4198 Sanity check
4199 ------------------------------------------------------------------------*/
4200 if ( NULL == puTxPktCount )
4201 {
4202 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
4203 "WLAN TL:Invalid parameter sent on WLANTL_GetTxPktCount"));
4204 return VOS_STATUS_E_INVAL;
4205 }
4206
4207 if ( WLANTL_STA_ID_INVALID( ucSTAId ) || WLANTL_TID_INVALID( ucTid) )
4208 {
4209 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
4210 "WLAN TL:Invalid station id %d/tid %d requested on WLANTL_GetTxPktCount",
4211 ucSTAId, ucTid));
4212 return VOS_STATUS_E_FAULT;
4213 }
4214
4215 /*------------------------------------------------------------------------
4216 Extract TL control block and check if station exists
4217 ------------------------------------------------------------------------*/
4218 pTLCb = VOS_GET_TL_CB(pvosGCtx);
4219 if ( NULL == pTLCb )
4220 {
4221 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
4222 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_GetTxPktCount"));
4223 return VOS_STATUS_E_FAULT;
4224 }
4225
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304226 if ( NULL == pTLCb->atlSTAClients[ucSTAId] )
4227 {
4228 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
4229 "WLAN TL:Client Memory was not allocated on %s", __func__));
4230 return VOS_STATUS_E_FAILURE;
4231 }
4232
4233 if ( 0 == pTLCb->atlSTAClients[ucSTAId]->ucExists )
Jeff Johnson295189b2012-06-20 16:38:30 -07004234 {
4235 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
4236 "WLAN TL:Station was not previously registered on WLANTL_GetTxPktCount %d",
4237 ucSTAId));
4238 return VOS_STATUS_E_EXISTS;
4239 }
4240
4241 /*------------------------------------------------------------------------
4242 Return data
4243 ------------------------------------------------------------------------*/
4244 //VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_MED,
4245 // "WLAN TL:Requested tx packet count for STA: %d, TID: %d",
4246 // ucSTAId, ucTid);
4247
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304248 *puTxPktCount = pTLCb->atlSTAClients[ucSTAId]->auTxCount[ucTid];
Jeff Johnson295189b2012-06-20 16:38:30 -07004249
4250 return VOS_STATUS_SUCCESS;
4251}/* WLANTL_GetTxPktCount */
4252
4253/*==========================================================================
4254
4255 FUNCTION WLANTL_GetRxPktCount
4256
4257 DESCRIPTION
4258 TL will provide the number of received packets counted per
4259 STA per TID.
4260
4261 DEPENDENCIES
4262
4263 PARAMETERS
4264
4265 IN
4266 pvosGCtx: pointer to the global vos context; a handle to TL's
4267 control block can be extracted from its context
4268 ucSTAId: identifier of the station
4269 ucTid: identifier of the tspec
4270
4271 OUT
4272 puTxPktCount: the number of packets rx packet for this STA and TID
4273
4274 RETURN VALUE
4275 The result code associated with performing the operation
4276
4277 VOS_STATUS_E_INVAL: Input parameters are invalid
4278 VOS_STATUS_E_FAULT: Station ID is outside array boundaries or pointer
4279 to TL cb is NULL ; access would cause a page fault
4280 VOS_STATUS_E_EXISTS: Station was not registered
4281 VOS_STATUS_SUCCESS: Everything is good :)
4282
4283 SIDE EFFECTS
4284
4285============================================================================*/
4286VOS_STATUS
4287WLANTL_GetRxPktCount
4288(
4289 v_PVOID_t pvosGCtx,
4290 v_U8_t ucSTAId,
4291 v_U8_t ucTid,
4292 v_U32_t* puRxPktCount
4293)
4294{
4295 WLANTL_CbType* pTLCb = NULL;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304296 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004297 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
4298
4299 /*------------------------------------------------------------------------
4300 Sanity check
4301 ------------------------------------------------------------------------*/
4302 if ( NULL == puRxPktCount )
4303 {
4304 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
4305 "WLAN TL:Invalid parameter sent on WLANTL_GetRxPktCount"));
4306 return VOS_STATUS_E_INVAL;
4307 }
4308
4309 if ( WLANTL_STA_ID_INVALID( ucSTAId ) || WLANTL_TID_INVALID( ucTid) )
4310 {
4311 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
4312 "WLAN TL:Invalid station id %d/tid %d requested on WLANTL_GetRxPktCount",
4313 ucSTAId, ucTid));
4314 return VOS_STATUS_E_FAULT;
4315 }
4316
4317 /*------------------------------------------------------------------------
4318 Extract TL control block and existance
4319 ------------------------------------------------------------------------*/
4320 pTLCb = VOS_GET_TL_CB(pvosGCtx);
4321 if ( NULL == pTLCb )
4322 {
4323 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
4324 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_GetRxPktCount"));
4325 return VOS_STATUS_E_FAULT;
4326 }
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304327 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
Jeff Johnson295189b2012-06-20 16:38:30 -07004328
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304329 if ( NULL == pClientSTA )
4330 {
4331 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
4332 "WLAN TL:Client Memory was not allocated on %s", __func__));
4333 return VOS_STATUS_E_FAILURE;
4334 }
4335
4336 if ( 0 == pClientSTA->ucExists )
Jeff Johnson295189b2012-06-20 16:38:30 -07004337 {
4338 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
4339 "WLAN TL:Station was not previously registered on WLANTL_GetRxPktCount"));
4340 return VOS_STATUS_E_EXISTS;
4341 }
4342
4343 /*------------------------------------------------------------------------
4344 Return data
4345 ------------------------------------------------------------------------*/
4346 TLLOG3(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_MED,
4347 "WLAN TL:Requested rx packet count for STA: %d, TID: %d",
4348 ucSTAId, ucTid));
4349
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304350 *puRxPktCount = pClientSTA->auRxCount[ucTid];
Jeff Johnson295189b2012-06-20 16:38:30 -07004351
4352 return VOS_STATUS_SUCCESS;
4353}/* WLANTL_GetRxPktCount */
4354
Jeff Johnson295189b2012-06-20 16:38:30 -07004355VOS_STATUS
4356WLANTL_TxFCFrame
4357(
4358 v_PVOID_t pvosGCtx
4359);
Karthick S79bbe822015-07-14 15:28:08 +05304360
4361/*==========================================================================
4362
4363 FUNCTION WLANTL_IsEAPOLPending
4364
4365 DESCRIPTION
4366
4367 HDD calls this function when hdd_tx_timeout occurs. This checks whether
4368 EAPOL is pending.
4369
4370 DEPENDENCIES
4371
4372 HDD must have registered with TL at least one STA before this function
4373 can be called.
4374
4375 PARAMETERS
4376
4377 IN
4378 pvosGCtx: pointer to the global vos context
4379
4380 RETURN VALUE
4381
4382 The result code associated with performing the operation
4383
4384 Success : Indicates EAPOL frame is pending and sta is in connected state
4385
4386 Failure : EAPOL frame is not pending
4387
4388 SIDE EFFECTS
4389============================================================================*/
4390VOS_STATUS
4391WLANTL_IsEAPOLPending
4392(
4393 v_PVOID_t pvosGCtx
4394)
4395{
4396 WLANTL_CbType* pTLCb = NULL;
4397 v_U32_t i = 0;
4398 /*------------------------------------------------------------------------
4399 Sanity check
4400 Extract TL control block
4401 ------------------------------------------------------------------------*/
4402 pTLCb = VOS_GET_TL_CB(pvosGCtx);
4403 if (NULL == pTLCb)
4404 {
4405 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
4406 "WLAN TL:Invalid TL pointer for pvosGCtx"));
4407 return VOS_STATUS_E_FAILURE;
4408 }
4409 /*---------------------------------------------------------------------
4410 Check to see if there was any EAPOL packet is pending
4411 *--------------------------------------------------------------------*/
4412 for ( i = 0; i < WLAN_MAX_STA_COUNT; i++)
4413 {
4414 if ((NULL != pTLCb->atlSTAClients[i]) &&
4415 (pTLCb->atlSTAClients[i]->ucExists) &&
4416 (0 == pTLCb->atlSTAClients[i]->ucTxSuspended) &&
4417 (WLANTL_STA_CONNECTED == pTLCb->atlSTAClients[i]->tlState) &&
4418 (pTLCb->atlSTAClients[i]->ucPktPending)
4419 )
4420 return VOS_STATUS_SUCCESS;
4421 }
4422 return VOS_STATUS_E_FAILURE;
4423}
4424
Jeff Johnson295189b2012-06-20 16:38:30 -07004425/*============================================================================
4426 TL INTERNAL API DEFINITION
4427============================================================================*/
4428
4429/*==========================================================================
4430
4431 FUNCTION WLANTL_GetFrames
4432
4433 DESCRIPTION
4434
4435 BAL calls this function at the request of the lower bus interface.
4436 When this request is being received TL will retrieve packets from HDD
4437 in accordance with the priority rules and the count supplied by BAL.
4438
4439 DEPENDENCIES
4440
4441 HDD must have registered with TL at least one STA before this function
4442 can be called.
4443
4444 PARAMETERS
4445
4446 IN
4447 pvosGCtx: pointer to the global vos context; a handle to TL's
4448 or BAL's control block can be extracted from its context
4449 uSize: maximum size accepted by the lower layer
4450 uFlowMask TX flow control mask for Prima. Each bit is defined as
4451 WDA_TXFlowEnumType
4452
4453 OUT
4454 vosDataBuff: it will contain a pointer to the first buffer supplied
4455 by TL, if there is more than one packet supplied, TL
4456 will chain them through vOSS buffers
4457
4458 RETURN VALUE
4459
4460 The result code associated with performing the operation
4461
4462 1 or more: number of required resources if there are still frames to fetch
4463 0 : error or HDD queues are drained
4464
4465 SIDE EFFECTS
4466
4467 NOTE
4468
4469 Featurized uFlowMask. If we want to remove featurization, we need to change
4470 BAL on Volans.
4471
4472============================================================================*/
4473v_U32_t
4474WLANTL_GetFrames
4475(
4476 v_PVOID_t pvosGCtx,
4477 vos_pkt_t **ppFrameDataBuff,
4478 v_U32_t uSize,
Jeff Johnson295189b2012-06-20 16:38:30 -07004479 v_U8_t uFlowMask,
Jeff Johnson295189b2012-06-20 16:38:30 -07004480 v_BOOL_t* pbUrgent
4481)
4482{
4483 vos_pkt_t** pvosDataBuff = (vos_pkt_t**)ppFrameDataBuff;
4484 WLANTL_CbType* pTLCb = NULL;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304485 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004486 v_U32_t uRemaining = uSize;
4487 vos_pkt_t* vosRoot;
4488 vos_pkt_t* vosTempBuf;
4489 WLANTL_STAFuncType pfnSTAFsm;
4490 v_U16_t usPktLen;
4491 v_U32_t uResLen;
4492 v_U8_t ucSTAId;
4493 v_U8_t ucAC;
4494 vos_pkt_t* vosDataBuff;
4495 v_U32_t uTotalPktLen;
4496 v_U32_t i=0;
Tushnim Bhattacharyya39a8f182013-02-20 18:10:30 -08004497 v_U32_t j=0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004498 v_U32_t ucResult = 0;
4499 VOS_STATUS vosStatus;
4500 WLANTL_STAEventType wSTAEvent;
4501 tBssSystemRole systemRole;
4502 tpAniSirGlobal pMac;
4503 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
4504
4505 /*------------------------------------------------------------------------
4506 Sanity check
4507 Extract TL control block
4508 ------------------------------------------------------------------------*/
4509 pTLCb = VOS_GET_TL_CB(pvosGCtx);
4510 if (( NULL == pTLCb ) || ( NULL == pvosDataBuff ))
4511 {
4512 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
4513 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_ChangeSTAState"));
4514 return ucResult;
4515 }
4516
4517 pMac = vos_get_context(VOS_MODULE_ID_PE, pvosGCtx);
4518 if ( NULL == pMac )
4519 {
4520 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004521 "%s: Invalid pMac", __func__));
Jeff Johnson295189b2012-06-20 16:38:30 -07004522 return ucResult;
4523 }
4524
4525 vosDataBuff = pTLCb->vosDummyBuf; /* Just to avoid checking for NULL at
4526 each iteration */
4527
Jeff Johnson295189b2012-06-20 16:38:30 -07004528 pTLCb->uResCount = uSize;
Jeff Johnson295189b2012-06-20 16:38:30 -07004529
4530 /*-----------------------------------------------------------------------
4531 Save the root as we will walk this chain as we fill it
4532 -----------------------------------------------------------------------*/
4533 vosRoot = vosDataBuff;
4534
4535 /*-----------------------------------------------------------------------
4536 There is still data - until FSM function says otherwise
4537 -----------------------------------------------------------------------*/
4538 pTLCb->bUrgent = FALSE;
4539
Jeff Johnson295189b2012-06-20 16:38:30 -07004540 while (( pTLCb->tlConfigInfo.uMinFramesProcThres < pTLCb->uResCount ) &&
4541 ( 0 < uRemaining ))
Jeff Johnson295189b2012-06-20 16:38:30 -07004542 {
4543 systemRole = wdaGetGlobalSystemRole(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -07004544#ifdef WLAN_SOFTAP_FLOWCTRL_EN
4545/* FIXME: The code has been disabled since it is creating issues in power save */
4546 if (eSYSTEM_AP_ROLE == systemRole)
4547 {
4548 if (pTLCb->done_once == 0 && NULL == pTLCb->vosTxFCBuf)
4549 {
4550 WLANTL_TxFCFrame (pvosGCtx);
4551 pTLCb->done_once ++;
4552 }
4553 }
4554 if ( NULL != pTLCb->vosTxFCBuf )
4555 {
4556 //there is flow control packet waiting to be sent
4557 WDA_TLI_PROCESS_FRAME_LEN( pTLCb->vosTxFCBuf, usPktLen, uResLen, uTotalPktLen);
4558
4559 if ( ( pTLCb->uResCount > uResLen ) &&
Jeff Johnson9b5dc4d2013-02-22 21:28:47 -08004560 ( uRemaining > uTotalPktLen ) &&
4561 ( uFlowMask & ( 1 << WDA_TXFLOW_FC ) ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07004562 {
4563 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
4564 "WLAN TL:Chaining FC frame first on GetFrame"));
4565
4566 vos_pkt_chain_packet( vosDataBuff, pTLCb->vosTxFCBuf, 1 /*true*/ );
4567
Arun Kumar Khandavalli0af8d3c2014-02-07 18:05:11 +05304568 vos_atomic_set( (uintptr_t*)&pTLCb->vosTxFCBuf, (uintptr_t) NULL);
Jeff Johnson295189b2012-06-20 16:38:30 -07004569
4570 /*FC frames cannot be delayed*/
4571 pTLCb->bUrgent = TRUE;
4572
4573 /*Update remaining len from SSC */
4574 uRemaining -= (usPktLen + WDA_DXE_HEADER_SIZE);
4575
4576 /*Update resource count */
4577 pTLCb->uResCount -= uResLen;
4578 }
4579 else
4580 {
4581 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004582 "WLAN TL:send fc out of source %s", __func__));
Jeff Johnson295189b2012-06-20 16:38:30 -07004583 ucResult = ( pTLCb->uResCount > uResLen )?VOS_TRUE:VOS_FALSE;
4584 break; /* Out of resources or reached max len */
4585 }
4586 }
4587 else
4588#endif //WLAN_SOFTAP_FLOWCTRL_EN
Jeff Johnson295189b2012-06-20 16:38:30 -07004589
Jeff Johnson9b5dc4d2013-02-22 21:28:47 -08004590 if (( NULL != pTLCb->tlMgmtFrmClient.vosPendingDataBuff ) &&
4591 ( uFlowMask & ( 1 << WDA_TXFLOW_MGMT ) ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07004592 {
4593 WDA_TLI_PROCESS_FRAME_LEN( pTLCb->tlMgmtFrmClient.vosPendingDataBuff,
4594 usPktLen, uResLen, uTotalPktLen);
4595
Manjunathappa Prakashfb585462013-12-23 19:07:07 -08004596 if (usPktLen > WLANTL_MAX_ALLOWED_LEN)
4597 {
4598 usPktLen = WLANTL_MAX_ALLOWED_LEN;
4599 VOS_ASSERT(0);
4600 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004601
4602 if ( ( pTLCb->uResCount > uResLen ) &&
Jeff Johnson9b5dc4d2013-02-22 21:28:47 -08004603 ( uRemaining > uTotalPktLen ) &&
4604 ( uFlowMask & ( 1 << WDA_TXFLOW_MGMT ) ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07004605 {
4606 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
4607 "WLAN TL:Chaining management frame on GetFrame"));
4608
4609 vos_pkt_chain_packet( vosDataBuff,
4610 pTLCb->tlMgmtFrmClient.vosPendingDataBuff,
4611 1 /*true*/ );
4612
Arun Kumar Khandavalli0af8d3c2014-02-07 18:05:11 +05304613 vos_atomic_set( (uintptr_t*)&pTLCb->tlMgmtFrmClient.
4614 vosPendingDataBuff, (uintptr_t)NULL);
Jeff Johnson295189b2012-06-20 16:38:30 -07004615
4616 /*management frames cannot be delayed*/
4617 pTLCb->bUrgent = TRUE;
4618
4619 /*Update remaining len from SSC */
4620 uRemaining -= (usPktLen + WDA_DXE_HEADER_SIZE);
4621
4622 /*Update resource count */
4623 pTLCb->uResCount -= uResLen;
4624 }
4625 else
4626 {
4627 ucResult = ( pTLCb->uResCount > uResLen )?VOS_TRUE:VOS_FALSE;
4628 break; /* Out of resources or reached max len */
4629 }
4630 }
4631 else if (( pTLCb->tlBAPClient.vosPendingDataBuff ) &&
4632 ( WDA_TLI_MIN_RES_BAP <= pTLCb->uResCount ) &&
Gopichand Nakkala7e48ca72012-12-31 14:15:07 -08004633 ( 0 == pTLCb->ucTxSuspended ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07004634 {
4635 WDA_TLI_PROCESS_FRAME_LEN( pTLCb->tlBAPClient.vosPendingDataBuff,
4636 usPktLen, uResLen, uTotalPktLen);
4637
Manjunathappa Prakashfb585462013-12-23 19:07:07 -08004638 if (usPktLen > WLANTL_MAX_ALLOWED_LEN)
4639 {
4640 usPktLen = WLANTL_MAX_ALLOWED_LEN;
4641 VOS_ASSERT(0);
4642 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004643
4644 if ( ( pTLCb->uResCount > (uResLen + WDA_TLI_MIN_RES_MF ) ) &&
4645 ( uRemaining > uTotalPktLen ))
4646 {
4647 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
4648 "WLAN TL:Chaining BT-AMP frame on GetFrame"));
4649
4650 vos_pkt_chain_packet( vosDataBuff,
4651 pTLCb->tlBAPClient.vosPendingDataBuff,
4652 1 /*true*/ );
4653
4654 /*BAP frames cannot be delayed*/
4655 pTLCb->bUrgent = TRUE;
4656
Arun Kumar Khandavalli0af8d3c2014-02-07 18:05:11 +05304657 vos_atomic_set( (uintptr_t*)&pTLCb->tlBAPClient.vosPendingDataBuff,
4658 (uintptr_t) NULL);
Jeff Johnson295189b2012-06-20 16:38:30 -07004659
4660 /*Update remaining len from SSC */
4661 uRemaining -= (usPktLen + WDA_DXE_HEADER_SIZE);
4662
4663 /*Update resource count */
4664 pTLCb->uResCount -= uResLen;
4665 }
4666 else
4667 {
Jeff Johnson295189b2012-06-20 16:38:30 -07004668 ucResult = uResLen + WDA_TLI_MIN_RES_MF;
Jeff Johnson295189b2012-06-20 16:38:30 -07004669 break; /* Out of resources or reached max len */
4670 }
4671 }
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -07004672 /* note: this feature implemented only after WLAN_INGETRATED_SOC */
4673 /* search 'EAPOL_HI_PRIORITY' will show EAPOL HI_PRIORITY change in TL and WDI
4674 by default, EAPOL will be treated as higher priority, which means
4675 use mgmt_pool and DXE_TX_HI prority channel.
4676 this is introduced to address EAPOL failure under high background traffic
4677 with multi-channel concurrent mode. But this change works in SCC or standalone, too.
4678 see CR#387009 and WCNSOS-8
4679 */
4680 else if (( WDA_TLI_MIN_RES_MF <= pTLCb->uResCount )&&
4681 ( 0 == pTLCb->ucTxSuspended ) &&
4682 ( uFlowMask & ( 1 << WDA_TXFLOW_MGMT ) )
4683 )
4684 {
4685 vosTempBuf = NULL;
4686 /*---------------------------------------------------------------------
4687 Check to see if there was any EAPOL packet is pending
4688 *--------------------------------------------------------------------*/
4689 for ( i = 0; i < WLAN_MAX_STA_COUNT; i++)
4690 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304691 if ((NULL != pTLCb->atlSTAClients[i]) &&
4692 (pTLCb->atlSTAClients[i]->ucExists) &&
4693 (0 == pTLCb->atlSTAClients[i]->ucTxSuspended) &&
Tushnim Bhattacharyya39a8f182013-02-20 18:10:30 -08004694 (WLANTL_STA_CONNECTED == pTLCb->atlSTAClients[i]->tlState) &&
4695 (pTLCb->atlSTAClients[i]->ucPktPending)
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -07004696 )
4697 break;
4698 }
4699
4700 if (i >= WLAN_MAX_STA_COUNT)
4701 {
4702 /* No More to Serve Exit Get Frames */
4703 break;
4704 }
4705 /* Serve EAPOL frame with HI_FLOW_MASK */
4706 ucSTAId = i;
4707
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304708 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
4709
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05304710 MTRACE(vos_trace(VOS_MODULE_ID_TL,
4711 TRACE_CODE_TL_GET_FRAMES_EAPOL, ucSTAId, pClientSTA->tlState));
4712
4713 if (pClientSTA->wSTADesc.wSTAType == WLAN_STA_INFRA)
4714 {
4715 if(0 != pClientSTA->aucACMask[WLANTL_AC_HIGH_PRIO])
4716 {
4717 pClientSTA->ucCurrentAC = WLANTL_AC_HIGH_PRIO;
4718 pTLCb->uCurServedAC = WLANTL_AC_HIGH_PRIO;
4719 }
4720 else
4721 break;
4722 }
4723 else
4724 {
4725 for (j = WLANTL_MAX_AC ; j > 0; j--)
4726 {
4727 if (0 != pClientSTA->aucACMask[j-1])
4728 {
4729 pClientSTA->ucCurrentAC = j-1;
4730 pTLCb->uCurServedAC = j-1;
4731 break;
4732 }
4733 }
4734 }
4735
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -07004736 wSTAEvent = WLANTL_TX_EVENT;
4737
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304738 pfnSTAFsm = tlSTAFsm[pClientSTA->tlState].
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -07004739 pfnSTATbl[wSTAEvent];
4740
4741 if ( NULL != pfnSTAFsm )
4742 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304743 pClientSTA->ucNoMoreData = 0;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004744 vosStatus = pfnSTAFsm( pvosGCtx, ucSTAId, &vosTempBuf, VOS_FALSE);
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -07004745
4746 if (( VOS_STATUS_SUCCESS != vosStatus ) &&
4747 ( NULL != vosTempBuf ))
4748 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304749 pClientSTA->pfnSTATxComp( pvosGCtx, vosTempBuf, vosStatus );
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -07004750 vosTempBuf = NULL;
4751 break;
4752 }/* status success*/
4753 }
4754
4755 if (NULL != vosTempBuf)
4756 {
4757 WDA_TLI_PROCESS_FRAME_LEN( vosTempBuf, usPktLen, uResLen, uTotalPktLen);
4758
Manjunathappa Prakashfb585462013-12-23 19:07:07 -08004759 if (usPktLen > WLANTL_MAX_ALLOWED_LEN)
4760 {
4761 usPktLen = WLANTL_MAX_ALLOWED_LEN;
4762 VOS_ASSERT(0);
4763 }
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -07004764
4765 TLLOG4(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_LOW,
4766 "WLAN TL:Resources needed by frame: %d", uResLen));
4767
4768 if ( ( pTLCb->uResCount >= (uResLen + WDA_TLI_MIN_RES_MF ) ) &&
4769 ( uRemaining > uTotalPktLen )
4770 )
4771 {
4772 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
4773 "WLAN TL:Chaining data frame on GetFrame"));
4774
4775 vos_pkt_chain_packet( vosDataBuff, vosTempBuf, 1 /*true*/ );
4776
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -07004777 /*EAPOL frame cannot be delayed*/
4778 pTLCb->bUrgent = TRUE;
4779
4780 vosTempBuf = NULL;
4781
4782 /*Update remaining len from SSC */
4783 uRemaining -= (usPktLen + WDA_DXE_HEADER_SIZE);
4784
4785 /*Update resource count */
4786 pTLCb->uResCount -= uResLen;
4787
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -07004788 //fow control update
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304789 pClientSTA->uIngress_length += uResLen;
4790 pClientSTA->uBuffThresholdMax = (pClientSTA->uBuffThresholdMax >= uResLen) ?
4791 (pClientSTA->uBuffThresholdMax - uResLen) : 0;
Tushnim Bhattacharyya39a8f182013-02-20 18:10:30 -08004792 pClientSTA->ucEapolPktPending = 0;
4793 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
4794 "WLAN TL:GetFrames STA: %d EAPOLPktPending %d",
4795 ucSTAId, pClientSTA->ucEapolPktPending);
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -07004796 }
4797 }
4798 else
4799 { // no EAPOL frames exit Get frames
Tushnim Bhattacharyya39a8f182013-02-20 18:10:30 -08004800 TLLOG2(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
4801 "WLAN TL:GetFrames STA: %d, no EAPOL frame, continue.",
4802 ucSTAId));
4803 continue;
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -07004804 }
4805 }
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -07004806
Jeff Johnson9b5dc4d2013-02-22 21:28:47 -08004807 else if (( WDA_TLI_MIN_RES_DATA <= pTLCb->uResCount ) &&
4808 ( 0 == pTLCb->ucTxSuspended ) &&
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05304809 ( uFlowMask & WLANTL_DATA_FLOW_MASK))
Jeff Johnson295189b2012-06-20 16:38:30 -07004810 {
4811 /*---------------------------------------------------------------------
4812 Check to see if there was any packet left behind previously due to
4813 size constraints
4814 ---------------------------------------------------------------------*/
4815 vosTempBuf = NULL;
4816
4817 if ( NULL != pTLCb->vosTempBuf )
4818 {
4819 vosTempBuf = pTLCb->vosTempBuf;
4820 pTLCb->vosTempBuf = NULL;
4821 ucSTAId = pTLCb->ucCachedSTAId;
4822 ucAC = pTLCb->ucCachedAC;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304823
4824 if ( NULL == pTLCb->atlSTAClients[ucSTAId] )
4825 {
4826 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
4827 "WLAN TL:Client Memory was not allocated on %s", __func__));
Madan Mohan Koyylamudi64258222013-01-30 14:35:10 +05304828 continue;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304829 }
4830
4831 pTLCb->atlSTAClients[ucSTAId]->ucNoMoreData = 0;
Madan Mohan Koyylamudi64258222013-01-30 14:35:10 +05304832 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
Jeff Johnson295189b2012-06-20 16:38:30 -07004833
4834 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
4835 "WLAN TL:Chaining cached data frame on GetFrame"));
4836 }
4837 else
4838 {
4839 WLAN_TLGetNextTxIds( pvosGCtx, &ucSTAId);
4840 if (ucSTAId >= WLAN_MAX_STA_COUNT)
4841 {
4842 /* Packets start coming in even after insmod Without *
4843 starting Hostapd or Interface being up *
4844 During which cases STAID is invaled and hence
4845 the check. HalMsg_ScnaComplete Triggers */
4846
4847 break;
4848 }
4849 /* ucCurrentAC should have correct AC to be served by calling
4850 WLAN_TLGetNextTxIds */
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304851 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304852 if ( NULL == pClientSTA )
4853 {
4854 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
4855 "WLAN TL:Client Memory was not allocated on %s", __func__));
Madan Mohan Koyylamudi64258222013-01-30 14:35:10 +05304856 continue;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304857 }
4858
4859 ucAC = pClientSTA->ucCurrentAC;
4860
4861 pClientSTA->ucNoMoreData = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07004862 TLLOG4(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_LOW,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004863 "WLAN TL: %s get one data frame, station ID %d ", __func__, ucSTAId));
Jeff Johnson295189b2012-06-20 16:38:30 -07004864 /*-------------------------------------------------------------------
4865 Check to see that STA is valid and tx is not suspended
4866 -------------------------------------------------------------------*/
4867 if ( ( ! WLANTL_STA_ID_INVALID( ucSTAId ) ) &&
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304868 ( 0 == pClientSTA->ucTxSuspended ) &&
4869 ( 0 == pClientSTA->fcStaTxDisabled) )
Jeff Johnson295189b2012-06-20 16:38:30 -07004870 {
4871 TLLOG4(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_LOW,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004872 "WLAN TL: %s sta id valid and not suspended ",__func__));
Jeff Johnson295189b2012-06-20 16:38:30 -07004873 wSTAEvent = WLANTL_TX_EVENT;
4874
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304875 pfnSTAFsm = tlSTAFsm[pClientSTA->tlState].
Jeff Johnson295189b2012-06-20 16:38:30 -07004876 pfnSTATbl[wSTAEvent];
4877
4878 if ( NULL != pfnSTAFsm )
4879 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304880 pClientSTA->ucNoMoreData = 0;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004881 vosStatus = pfnSTAFsm( pvosGCtx, ucSTAId, &vosTempBuf, VOS_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07004882
4883 if (( VOS_STATUS_SUCCESS != vosStatus ) &&
4884 ( NULL != vosTempBuf ))
4885 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304886 pClientSTA->pfnSTATxComp( pvosGCtx,
Jeff Johnson295189b2012-06-20 16:38:30 -07004887 vosTempBuf,
4888 vosStatus );
4889 vosTempBuf = NULL;
4890 }/* status success*/
4891 }/*NULL function state*/
4892 }/* valid STA id and ! suspended*/
4893 else
4894 {
4895 if ( ! WLANTL_STA_ID_INVALID( ucSTAId ) )
4896 {
4897 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
4898 "WLAN TL:Not fetching frame because suspended for sta ID %d",
4899 ucSTAId));
4900 }
4901 }
4902 }/* data */
4903
4904 if ( NULL != vosTempBuf )
4905 {
4906 WDA_TLI_PROCESS_FRAME_LEN( vosTempBuf, usPktLen, uResLen, uTotalPktLen);
4907
Manjunathappa Prakashfb585462013-12-23 19:07:07 -08004908 if (usPktLen > WLANTL_MAX_ALLOWED_LEN)
4909 {
4910 usPktLen = WLANTL_MAX_ALLOWED_LEN;
4911 VOS_ASSERT(0);
4912 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004913
4914 TLLOG4(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_LOW,
4915 "WLAN TL:Resources needed by frame: %d", uResLen));
4916
4917 if ( ( pTLCb->uResCount >= (uResLen + WDA_TLI_MIN_RES_BAP ) ) &&
Jeff Johnson9b5dc4d2013-02-22 21:28:47 -08004918 ( uRemaining > uTotalPktLen ) &&
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05304919 ( uFlowMask & WLANTL_DATA_FLOW_MASK ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07004920 {
4921 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
4922 "WLAN TL:Chaining data frame on GetFrame"));
4923
4924 vos_pkt_chain_packet( vosDataBuff, vosTempBuf, 1 /*true*/ );
4925 vosTempBuf = NULL;
4926
4927 /*Update remaining len from SSC */
4928 uRemaining -= (usPktLen + WDA_DXE_HEADER_SIZE);
4929
4930 /*Update resource count */
4931 pTLCb->uResCount -= uResLen;
4932
Jeff Johnson295189b2012-06-20 16:38:30 -07004933 //fow control update
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304934 pClientSTA->uIngress_length += uResLen;
4935 pClientSTA->uBuffThresholdMax = (pClientSTA->uBuffThresholdMax >= uResLen) ?
4936 (pClientSTA->uBuffThresholdMax - uResLen) : 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004937
Sravan Kumar Kairam60b8cf02016-12-12 16:22:09 +05304938 pClientSTA->tx_frames ++;
4939
Jeff Johnson295189b2012-06-20 16:38:30 -07004940 }
4941 else
4942 {
4943 /* Store this for later tx - already fetched from HDD */
4944 pTLCb->vosTempBuf = vosTempBuf;
4945 pTLCb->ucCachedSTAId = ucSTAId;
4946 pTLCb->ucCachedAC = ucAC;
Jeff Johnson295189b2012-06-20 16:38:30 -07004947 ucResult = uResLen + WDA_TLI_MIN_RES_BAP;
4948 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
4949 "min %d res required by TL.", ucResult ));
Jeff Johnson295189b2012-06-20 16:38:30 -07004950 break; /* Out of resources or reached max len */
4951 }
4952 }
4953 else
4954 {
4955 for ( i = 0; i < WLAN_MAX_STA_COUNT; i++)
4956 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304957 if (NULL != pTLCb->atlSTAClients[i] && (pTLCb->atlSTAClients[i]->ucExists) &&
Bhargav Shahfbaeca22016-07-13 10:27:35 +05304958 (pTLCb->atlSTAClients[i]->ucPktPending) &&
4959 (pTLCb->atlSTAClients[i]->disassoc_progress == VOS_FALSE))
Jeff Johnson295189b2012-06-20 16:38:30 -07004960 {
4961 /* There is station to be Served */
4962 break;
4963 }
4964 }
4965 if (i >= WLAN_MAX_STA_COUNT)
4966 {
4967 /* No More to Serve Exit Get Frames */
4968 break;
4969 }
4970 else
4971 {
4972 /* More to be Served */
4973 continue;
4974 }
4975 }
4976 }
4977 else
4978 {
4979 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
4980 "WLAN TL:Returning from GetFrame: resources = %d suspended = %d",
4981 pTLCb->uResCount, pTLCb->ucTxSuspended));
Jeff Johnson295189b2012-06-20 16:38:30 -07004982 /* TL is starving even when DXE is not in low resource condition
4983 Return min resource number required and Let DXE deceide what to do */
4984 if(( 0 == pTLCb->ucTxSuspended ) &&
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05304985 ( uFlowMask & WLANTL_DATA_FLOW_MASK ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07004986 {
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07004987 TLLOG1(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -07004988 "WLAN TL:Returning from GetFrame: resources = %d",
4989 pTLCb->uResCount));
4990 ucResult = WDA_TLI_MIN_RES_DATA;
4991 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004992 break; /*out of min data resources*/
4993 }
4994
4995 pTLCb->usPendingTxCompleteCount++;
4996 /* Move data buffer up one packet */
4997 vos_pkt_walk_packet_chain( vosDataBuff, &vosDataBuff, 0/*false*/ );
4998 }
4999
5000 /*----------------------------------------------------------------------
5001 Packet chain starts at root + 1
5002 ----------------------------------------------------------------------*/
5003 vos_pkt_walk_packet_chain( vosRoot, &vosDataBuff, 1/*true*/ );
5004
5005 *pvosDataBuff = vosDataBuff;
Manjunathappa Prakashfb585462013-12-23 19:07:07 -08005006 if (pbUrgent)
5007 {
5008 *pbUrgent = pTLCb->bUrgent;
5009 }
5010 else
5011 {
5012 VOS_ASSERT( pbUrgent );
5013 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005014 return ucResult;
5015}/* WLANTL_GetFrames */
5016
5017
5018/*==========================================================================
5019
5020 FUNCTION WLANTL_TxComp
5021
5022 DESCRIPTION
5023 It is being called by BAL upon asynchronous notification of the packet
5024 or packets being sent over the bus.
5025
5026 DEPENDENCIES
5027 Tx complete cannot be called without a previous transmit.
5028
5029 PARAMETERS
5030
5031 IN
5032 pvosGCtx: pointer to the global vos context; a handle to TL's
5033 or BAL's control block can be extracted from its context
5034 vosDataBuff: it will contain a pointer to the first buffer for which
5035 the BAL report is being made, if there is more then one
5036 packet they will be chained using vOSS buffers.
5037 wTxStatus: the status of the transmitted packet, see above chapter
5038 on HDD interaction for a list of possible values
5039
5040 RETURN VALUE
5041 The result code associated with performing the operation
5042
5043 VOS_STATUS_E_INVAL: Input parameters are invalid
5044 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
5045 page fault
5046 VOS_STATUS_E_EXISTS: Station was not registered
5047 VOS_STATUS_SUCCESS: Everything is good :)
5048
5049 SIDE EFFECTS
5050
5051============================================================================*/
5052VOS_STATUS
5053WLANTL_TxComp
5054(
5055 v_PVOID_t pvosGCtx,
5056 vos_pkt_t *pFrameDataBuff,
5057 VOS_STATUS wTxStatus
5058)
5059{
5060 vos_pkt_t* vosDataBuff = (vos_pkt_t*)pFrameDataBuff;
5061 WLANTL_CbType* pTLCb = NULL;
5062 WLANTL_TxCompCBType pfnTxComp = NULL;
5063 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07005064 vos_pkt_t* vosTempTx = NULL;
5065
5066 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
5067
5068 /*------------------------------------------------------------------------
5069 Sanity check
5070 ------------------------------------------------------------------------*/
5071 if ( NULL == vosDataBuff )
5072 {
5073 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
5074 "WLAN TL:Extraneous NULL data pointer on WLANTL_TxComp"));
5075 return VOS_STATUS_E_INVAL;
5076 }
5077
5078 /*------------------------------------------------------------------------
5079 Extract TL control block
5080 ------------------------------------------------------------------------*/
5081 pTLCb = VOS_GET_TL_CB(pvosGCtx);
5082 if ( NULL == pTLCb )
5083 {
5084 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
5085 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_TxComp"));
5086 return VOS_STATUS_E_FAULT;
5087 }
5088
5089 while ((0 < pTLCb->usPendingTxCompleteCount) &&
5090 ( VOS_STATUS_SUCCESS == vosStatus ) &&
5091 ( NULL != vosDataBuff))
5092 {
5093 vos_pkt_get_user_data_ptr( vosDataBuff, VOS_PKT_USER_DATA_ID_TL,
5094 (v_PVOID_t)&pfnTxComp);
5095
5096 /*it should never be NULL - default handler should be registered if none*/
5097 if ( NULL == pfnTxComp )
5098 {
5099 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
5100 "WLAN TL:NULL pointer to Tx Complete on WLANTL_TxComp"));
5101 VOS_ASSERT(0);
5102 return VOS_STATUS_E_FAULT;
5103 }
5104
5105 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
Jeff Johnsonddec6482017-09-19 08:33:57 -07005106 "WLAN TL:Calling Tx complete for pkt %pK in function %pK",
Jeff Johnson295189b2012-06-20 16:38:30 -07005107 vosDataBuff, pfnTxComp));
5108
5109 vosTempTx = vosDataBuff;
5110 vosStatus = vos_pkt_walk_packet_chain( vosDataBuff,
5111 &vosDataBuff, 1/*true*/);
5112
5113 pfnTxComp( pvosGCtx, vosTempTx, wTxStatus );
5114
5115 pTLCb->usPendingTxCompleteCount--;
5116 }
5117
Jeff Johnson295189b2012-06-20 16:38:30 -07005118
5119 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
5120 "WLAN TL: current TL values are: resources = %d "
5121 "pTLCb->usPendingTxCompleteCount = %d",
5122 pTLCb->uResCount, pTLCb->usPendingTxCompleteCount));
5123
5124 return VOS_STATUS_SUCCESS;
5125}/* WLANTL_TxComp */
5126
5127/*==========================================================================
5128
5129 FUNCTION WLANTL_CacheSTAFrame
5130
5131 DESCRIPTION
5132 Internal utility function for for caching incoming data frames that do
5133 not have a registered station yet.
5134
5135 DEPENDENCIES
5136 TL must be initiailized before this function gets called.
5137 In order to benefit from thsi caching, the components must ensure that
5138 they will only register with TL at the moment when they are fully setup
5139 and ready to receive incoming data
5140
5141 PARAMETERS
5142
5143 IN
5144
5145 pTLCb: TL control block
5146 ucSTAId: station id
5147 vosTempBuff: the data packet
5148 uDPUSig: DPU signature of the incoming packet
5149 bBcast: true if packet had the MC/BC bit set
5150
5151 RETURN VALUE
5152 The result code associated with performing the operation
5153
5154 VOS_STATUS_E_FAULT: pointer to TL cb is NULL or STA Id invalid ; access
5155 would cause a page fault
5156 VOS_STATUS_SUCCESS: Everything is good :)
5157
5158 SIDE EFFECTS
5159
5160============================================================================*/
5161static VOS_STATUS
5162WLANTL_CacheSTAFrame
5163(
5164 WLANTL_CbType* pTLCb,
5165 v_U8_t ucSTAId,
5166 vos_pkt_t* vosTempBuff,
5167 v_U32_t uDPUSig,
5168 v_U8_t bBcast,
5169 v_U8_t ucFrmType
5170)
5171{
5172 v_U8_t ucUcastSig;
5173 v_U8_t ucBcastSig;
5174 v_BOOL_t bOldSTAPkt;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05305175 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005176 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
5177
5178 /*-------------------------------------------------------------------------
5179 Sanity check
5180 -------------------------------------------------------------------------*/
5181 if (( NULL == pTLCb ) || ( NULL == vosTempBuff ) )
5182 {
5183 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Jeff Johnsonddec6482017-09-19 08:33:57 -07005184 "WLAN TL: Invalid input pointer on WLANTL_CacheSTAFrame TL %pK"
5185 " Packet %pK", pTLCb, vosTempBuff ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005186 return VOS_STATUS_E_FAULT;
5187 }
5188
5189 if ( WLANTL_STA_ID_INVALID( ucSTAId ) )
5190 {
5191 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
5192 "WLAN TL:Invalid station id requested on WLANTL_CacheSTAFrame"));
5193 return VOS_STATUS_E_FAULT;
5194 }
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05305195 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
5196
5197 if ( NULL == pClientSTA )
5198 {
5199 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
5200 "WLAN TL:Client Memory was not allocated on %s", __func__));
5201 return VOS_STATUS_E_FAILURE;
5202 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005203
5204 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
5205 "WLAN TL:Attempting to cache pkt for STA %d, BD DPU Sig: %d with sig UC: %d, BC: %d",
5206 ucSTAId, uDPUSig,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05305207 pClientSTA->wSTADesc.ucUcastSig,
5208 pClientSTA->wSTADesc.ucBcastSig));
Jeff Johnson295189b2012-06-20 16:38:30 -07005209
5210 if(WLANTL_IS_CTRL_FRAME(ucFrmType))
5211 {
5212 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
5213 "WLAN TL: No need to cache CTRL frame. Dropping"));
5214 vos_pkt_return_packet(vosTempBuff);
5215 return VOS_STATUS_SUCCESS;
5216 }
5217
5218 /*-------------------------------------------------------------------------
5219 Check if the packet that we are trying to cache belongs to the old
5220 registered station (if any) or the new (potentially)upcoming station
5221
5222 - If the STA with this Id was never registered with TL - the signature
5223 will be invalid;
5224 - If the STA was previously registered TL will have cached the former
5225 set of DPU signatures
5226 -------------------------------------------------------------------------*/
5227 if ( bBcast )
5228 {
5229 ucBcastSig = (v_U8_t)uDPUSig;
5230 bOldSTAPkt = (( WLAN_TL_INVALID_B_SIG !=
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05305231 pClientSTA->wSTADesc.ucBcastSig ) &&
5232 ( ucBcastSig == pClientSTA->wSTADesc.ucBcastSig ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005233 }
5234 else
5235 {
5236 ucUcastSig = (v_U8_t)uDPUSig;
5237 bOldSTAPkt = (( WLAN_TL_INVALID_U_SIG !=
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05305238 pClientSTA->wSTADesc.ucUcastSig ) &&
5239 ( ucUcastSig == pClientSTA->wSTADesc.ucUcastSig ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005240 }
5241
5242 /*------------------------------------------------------------------------
5243 If the value of the DPU SIG matches the old, this packet will not
5244 be cached as it belonged to the former association
5245 In case the SIG does not match - this is a packet for a potentially new
5246 associated station
5247 -------------------------------------------------------------------------*/
Varun Reddy Yeturua39b9902013-01-18 15:48:32 -08005248 if ( bOldSTAPkt || bBcast )
Jeff Johnson295189b2012-06-20 16:38:30 -07005249 {
5250 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
5251 "WLAN TL:Data packet matches old sig for sig DPU: %d UC: %d, "
5252 "BC: %d - dropping",
5253 uDPUSig,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05305254 pClientSTA->wSTADesc.ucUcastSig,
5255 pClientSTA->wSTADesc.ucBcastSig));
Jeff Johnson295189b2012-06-20 16:38:30 -07005256 vos_pkt_return_packet(vosTempBuff);
5257 }
5258 else
5259 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05305260 if ( NULL == pClientSTA->vosBegCachedFrame )
Jeff Johnson295189b2012-06-20 16:38:30 -07005261 {
5262 /*this is the first frame that we are caching */
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05305263 pClientSTA->vosBegCachedFrame = vosTempBuff;
Mihir Sheteb7337272014-04-11 15:53:08 +05305264
5265 pClientSTA->tlCacheInfo.cacheInitTime = vos_timer_get_system_time();
5266 pClientSTA->tlCacheInfo.cacheDoneTime =
5267 pClientSTA->tlCacheInfo.cacheInitTime;
5268 pClientSTA->tlCacheInfo.cacheSize = 1;
5269
Mihir Sheteae6f02b2014-04-11 19:49:21 +05305270 MTRACE(vos_trace(VOS_MODULE_ID_TL, TRACE_CODE_TL_CACHE_FRAME,
5271 ucSTAId, pClientSTA->tlCacheInfo.cacheSize));
5272
Jeff Johnson295189b2012-06-20 16:38:30 -07005273 }
5274 else
5275 {
5276 /*this is a subsequent frame that we are caching: chain to the end */
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05305277 vos_pkt_chain_packet(pClientSTA->vosEndCachedFrame,
Jeff Johnson295189b2012-06-20 16:38:30 -07005278 vosTempBuff, VOS_TRUE);
Mihir Sheteb7337272014-04-11 15:53:08 +05305279
5280 pClientSTA->tlCacheInfo.cacheDoneTime = vos_timer_get_system_time();
5281 pClientSTA->tlCacheInfo.cacheSize ++;
5282
5283 if (pClientSTA->tlCacheInfo.cacheSize % WLANTL_CACHE_TRACE_WATERMARK == 0)
5284 {
5285 VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
5286 "%s: Cache High watermark for staid:%d (%d)",
5287 __func__,ucSTAId, pClientSTA->tlCacheInfo.cacheSize);
Mihir Sheteae6f02b2014-04-11 19:49:21 +05305288 MTRACE(vos_trace(VOS_MODULE_ID_TL, TRACE_CODE_TL_CACHE_FRAME,
5289 ucSTAId, pClientSTA->tlCacheInfo.cacheSize));
Mihir Sheteb7337272014-04-11 15:53:08 +05305290 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005291 }
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05305292 pClientSTA->vosEndCachedFrame = vosTempBuff;
Jeff Johnson295189b2012-06-20 16:38:30 -07005293 }/*else new packet*/
5294
5295 return VOS_STATUS_SUCCESS;
5296}/*WLANTL_CacheSTAFrame*/
5297
5298/*==========================================================================
5299
5300 FUNCTION WLANTL_FlushCachedFrames
5301
5302 DESCRIPTION
5303 Internal utility function used by TL to flush the station cache
5304
5305 DEPENDENCIES
5306 TL must be initiailized before this function gets called.
5307
5308 PARAMETERS
5309
5310 IN
5311
5312 vosDataBuff: it will contain a pointer to the first cached buffer
5313 received,
5314
5315 RETURN VALUE
5316 The result code associated with performing the operation
5317
5318 VOS_STATUS_SUCCESS: Everything is good :)
5319
5320 SIDE EFFECTS
5321
5322 NOTE
5323 This function doesn't re-initialize vosDataBuff to NULL. It's caller's
5324 responsibility to do so, if required, after this function call.
5325 Because of this restriction, we decide to make this function to static
5326 so that upper layer doesn't need to be aware of this restriction.
5327
5328============================================================================*/
5329static VOS_STATUS
5330WLANTL_FlushCachedFrames
5331(
5332 vos_pkt_t* vosDataBuff
5333)
5334{
5335 /*----------------------------------------------------------------------
5336 Return the entire chain to vos if there are indeed cache frames
5337 ----------------------------------------------------------------------*/
5338 if ( NULL != vosDataBuff )
5339 {
5340 vos_pkt_return_packet(vosDataBuff);
5341 }
5342
5343 return VOS_STATUS_SUCCESS;
5344}/*WLANTL_FlushCachedFrames*/
5345
5346/*==========================================================================
5347
5348 FUNCTION WLANTL_ForwardSTAFrames
5349
5350 DESCRIPTION
5351 Internal utility function for either forwarding cached data to the station after
5352 the station has been registered, or flushing cached data if the station has not
5353 been registered.
5354
5355
5356 DEPENDENCIES
5357 TL must be initiailized before this function gets called.
5358
5359 PARAMETERS
5360
5361 IN
5362
5363 pTLCb: TL control block
5364 ucSTAId: station id
5365
5366 RETURN VALUE
5367 The result code associated with performing the operation
5368
5369 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
5370 page fault
5371 VOS_STATUS_SUCCESS: Everything is good :)
5372
5373 SIDE EFFECTS
5374 This function doesn't re-initialize vosDataBuff to NULL. It's caller's
5375 responsibility to do so, if required, after this function call.
5376 Because of this restriction, we decide to make this function to static
5377 so that upper layer doesn't need to be aware of this restriction.
5378
5379============================================================================*/
5380static VOS_STATUS
5381WLANTL_ForwardSTAFrames
5382(
5383 void* pvosGCtx,
5384 v_U8_t ucSTAId,
5385 v_U8_t ucUcastSig,
5386 v_U8_t ucBcastSig
5387)
5388{
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05305389 WLANTL_CbType* pTLCb = NULL;
5390 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005391 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
5392
5393 /*-------------------------------------------------------------------------
5394 Sanity check
5395 -------------------------------------------------------------------------*/
5396 pTLCb = VOS_GET_TL_CB(pvosGCtx);
5397 if ( NULL == pTLCb )
5398 {
5399 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Jeff Johnsonddec6482017-09-19 08:33:57 -07005400 "WLAN TL: Invalid input pointer on WLANTL_ForwardSTAFrames TL %pK",
Jeff Johnson295189b2012-06-20 16:38:30 -07005401 pTLCb ));
5402 return VOS_STATUS_E_FAULT;
5403 }
5404
5405 if ( WLANTL_STA_ID_INVALID( ucSTAId ) )
5406 {
5407 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
5408 "WLAN TL:Invalid station id requested on WLANTL_ForwardSTAFrames"));
5409 return VOS_STATUS_E_FAULT;
5410 }
5411
5412 //WLAN_TL_LOCK_STA_CACHE(pTLCb->atlSTAClients[ucSTAId]);
5413
5414 /*------------------------------------------------------------------------
5415 Check if station has not been registered in the mean while
5416 if not registered, flush cached frames.
5417 ------------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05305418 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
5419
5420 if ( NULL == pClientSTA )
5421 {
5422 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
5423 "WLAN TL:Client Memory was not allocated on %s", __func__));
5424 return VOS_STATUS_E_FAILURE;
5425 }
5426
5427 if ( 0 == pClientSTA->ucExists )
Jeff Johnson295189b2012-06-20 16:38:30 -07005428 {
5429 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
5430 "WLAN TL:Station has been deleted for STA %d - flushing cache", ucSTAId));
Mihir Sheteae6f02b2014-04-11 19:49:21 +05305431 MTRACE(vos_trace(VOS_MODULE_ID_TL, TRACE_CODE_TL_FLUSH_CACHED_FRAMES,
5432 ucSTAId, pClientSTA->tlCacheInfo.cacheSize));
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05305433 WLANTL_FlushCachedFrames(pClientSTA->vosBegCachedFrame);
Jeff Johnson295189b2012-06-20 16:38:30 -07005434 goto done;
5435 }
5436
5437 /*------------------------------------------------------------------------
5438 Forwarding cache frames received while the station was in the process
5439 of being registered with the rest of the SW components
5440
5441 Access to the cache must be locked; similarly updating the signature and
5442 the existence flag must be synchronized because these values are checked
5443 during cached
5444 ------------------------------------------------------------------------*/
5445 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
5446 "WLAN TL:Preparing to fwd packets for STA %d", ucSTAId));
5447
5448 /*-----------------------------------------------------------------------
5449 Save the new signature values
5450 ------------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05305451 pClientSTA->wSTADesc.ucUcastSig = ucUcastSig;
5452 pClientSTA->wSTADesc.ucBcastSig = ucBcastSig;
Jeff Johnson295189b2012-06-20 16:38:30 -07005453
5454 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
5455 "WLAN TL:Fwd-ing packets for STA %d UC %d BC %d",
5456 ucSTAId, ucUcastSig, ucBcastSig));
5457
5458 /*-------------------------------------------------------------------------
5459 Check to see if we have any cached data to forward
5460 -------------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05305461 if ( NULL != pClientSTA->vosBegCachedFrame )
Jeff Johnson295189b2012-06-20 16:38:30 -07005462 {
5463 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
5464 "WLAN TL: Fwd-ing Cached packets for station %d", ucSTAId ));
5465
5466 WLANTL_RxCachedFrames( pTLCb,
5467 ucSTAId,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05305468 pClientSTA->vosBegCachedFrame);
Jeff Johnson295189b2012-06-20 16:38:30 -07005469 }
5470 else
5471 {
5472 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
5473 "WLAN TL: NO cached packets for station %d", ucSTAId ));
5474 }
5475
5476done:
5477 /*-------------------------------------------------------------------------
5478 Clear the station cache
5479 -------------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05305480 pClientSTA->vosBegCachedFrame = NULL;
5481 pClientSTA->vosEndCachedFrame = NULL;
Mihir Sheteb7337272014-04-11 15:53:08 +05305482 pClientSTA->tlCacheInfo.cacheSize = 0;
5483 pClientSTA->tlCacheInfo.cacheClearTime = vos_timer_get_system_time();
Jeff Johnson295189b2012-06-20 16:38:30 -07005484
5485 /*-----------------------------------------------------------------------
5486 After all the init is complete we can mark the existance flag
5487 ----------------------------------------------------------------------*/
Katya Nigam63902932014-06-26 19:04:23 +05305488 pClientSTA->enableCaching = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005489
5490 //WLAN_TL_UNLOCK_STA_CACHE(pTLCb->atlSTAClients[ucSTAId]);
5491 return VOS_STATUS_SUCCESS;
5492
5493}/*WLANTL_ForwardSTAFrames*/
5494
5495
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005496#if defined(FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_ESE_UPLOAD)
Jeff Johnson295189b2012-06-20 16:38:30 -07005497/*==========================================================================
5498
5499 FUNCTION WLANTL_IsIAPPFrame
5500
5501 DESCRIPTION
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005502 Internal utility function for detecting incoming ESE IAPP frames
Jeff Johnson295189b2012-06-20 16:38:30 -07005503
5504 DEPENDENCIES
5505
5506 PARAMETERS
5507
5508 IN
5509
5510 pvBDHeader: pointer to the BD header
5511 vosTempBuff: the data packet
5512
5513 IN/OUT
5514 pFirstDataPktArrived: static from caller function; used for rssi
5515 computation
5516 RETURN VALUE
5517 The result code associated with performing the operation
5518
5519 VOS_TRUE: It is a IAPP frame
5520 VOS_FALSE: It is NOT IAPP frame
5521
5522 SIDE EFFECTS
5523
5524============================================================================*/
5525v_BOOL_t
5526WLANTL_IsIAPPFrame
5527(
5528 v_PVOID_t pvBDHeader,
5529 vos_pkt_t* vosTempBuff
5530)
5531{
5532 v_U16_t usMPDUDOffset;
5533 v_U8_t ucOffset;
5534 v_U8_t ucSnapHdr[WLANTL_LLC_SNAP_SIZE];
5535 v_SIZE_t usSnapHdrSize = WLANTL_LLC_SNAP_SIZE;
5536 VOS_STATUS vosStatus;
5537
5538 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
5539
5540 /*------------------------------------------------------------------------
5541 Check if OUI field is present.
5542 -------------------------------------------------------------------------*/
5543 if ( VOS_FALSE == WDA_IS_RX_LLC_PRESENT(pvBDHeader) )
5544 {
5545 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
5546 "WLAN TL:LLC header removed, cannot determine BT-AMP type -"
5547 "dropping pkt"));
5548 /* Drop packet */
5549 vos_pkt_return_packet(vosTempBuff);
5550 return VOS_TRUE;
5551 }
5552 usMPDUDOffset = (v_U8_t)WDA_GET_RX_MPDU_DATA_OFFSET(pvBDHeader);
5553 ucOffset = (v_U8_t)usMPDUDOffset + WLANTL_LLC_SNAP_OFFSET;
5554
5555 vosStatus = vos_pkt_extract_data( vosTempBuff, ucOffset,
5556 (v_PVOID_t)ucSnapHdr, &usSnapHdrSize);
5557
5558 if (( VOS_STATUS_SUCCESS != vosStatus))
5559 {
5560 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
5561 "Unable to extract Snap Hdr of data packet -"
5562 "dropping pkt"));
5563 return VOS_FALSE;
5564 }
5565
5566 /*------------------------------------------------------------------------
5567 Check if this is IAPP frame by matching Aironet Snap hdr.
5568 -------------------------------------------------------------------------*/
5569 // Compare returns 1 if values are same and 0
5570 // if not the same.
5571 if (( WLANTL_LLC_SNAP_SIZE != usSnapHdrSize ) ||
5572 ( 0 == vos_mem_compare(ucSnapHdr, (v_PVOID_t)WLANTL_AIRONET_SNAP_HEADER,
5573 WLANTL_LLC_SNAP_SIZE ) ))
5574 {
5575 return VOS_FALSE;
5576 }
5577
5578 return VOS_TRUE;
5579
5580}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005581#endif //FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07005582
5583/*==========================================================================
5584
5585 FUNCTION WLANTL_ProcessBAPFrame
5586
5587 DESCRIPTION
5588 Internal utility function for processing incoming BT-AMP frames
5589
5590 DEPENDENCIES
5591 TL must be initiailized before this function gets called.
5592 Bothe the BT-AMP station and the BAP Ctrl path must have been previously
5593 registered with TL.
5594
5595 PARAMETERS
5596
5597 IN
5598
5599 pvBDHeader: pointer to the BD header
5600 vosTempBuff: the data packet
5601 pTLCb: TL control block
5602 ucSTAId: station id
5603
5604 IN/OUT
5605 pFirstDataPktArrived: static from caller function; used for rssi
5606 computation
5607 RETURN VALUE
5608 The result code associated with performing the operation
5609
5610 VOS_STATUS_E_INVAL: Input parameters are invalid
5611 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
5612 page fault
5613 VOS_STATUS_SUCCESS: Everything is good :)
5614
5615 SIDE EFFECTS
5616
5617============================================================================*/
5618v_BOOL_t
5619WLANTL_ProcessBAPFrame
5620(
5621 v_PVOID_t pvBDHeader,
5622 vos_pkt_t* vosTempBuff,
5623 WLANTL_CbType* pTLCb,
5624 v_U8_t* pFirstDataPktArrived,
5625 v_U8_t ucSTAId
5626)
5627{
5628 v_U16_t usMPDUDOffset;
5629 v_U8_t ucOffset;
5630 v_U8_t ucOUI[WLANTL_LLC_OUI_SIZE];
5631 v_SIZE_t usOUISize = WLANTL_LLC_OUI_SIZE;
5632 VOS_STATUS vosStatus;
5633 v_U16_t usType;
5634 v_SIZE_t usTypeLen = sizeof(usType);
5635 v_U8_t ucMPDUHOffset;
5636 v_U8_t ucMPDUHLen = 0;
5637 v_U16_t usActualHLen = 0;
5638
5639 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
5640
5641 /*------------------------------------------------------------------------
5642 Extract OUI and type from LLC and validate; if non-data send to BAP
5643 -------------------------------------------------------------------------*/
5644 if ( VOS_FALSE == WDA_IS_RX_LLC_PRESENT(pvBDHeader) )
5645 {
5646 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
5647 "WLAN TL:LLC header removed, cannot determine BT-AMP type -"
5648 "dropping pkt"));
5649 /* Drop packet */
5650 vos_pkt_return_packet(vosTempBuff);
5651 return VOS_TRUE;
5652 }
5653
5654 usMPDUDOffset = (v_U8_t)WDA_GET_RX_MPDU_DATA_OFFSET(pvBDHeader);
5655 ucMPDUHOffset = (v_U8_t)WDA_GET_RX_MPDU_HEADER_OFFSET(pvBDHeader);
5656 ucMPDUHLen = (v_U8_t)WDA_GET_RX_MPDU_HEADER_LEN(pvBDHeader);
5657 ucOffset = (v_U8_t)usMPDUDOffset + WLANTL_LLC_OUI_OFFSET;
5658
5659 vosStatus = vos_pkt_extract_data( vosTempBuff, ucOffset,
5660 (v_PVOID_t)ucOUI, &usOUISize);
5661
5662#if 0
5663 // Compare returns 1 if values are same and 0
5664 // if not the same.
5665 if (( WLANTL_LLC_OUI_SIZE != usOUISize ) ||
5666 ( 0 == vos_mem_compare(ucOUI, (v_PVOID_t)WLANTL_BT_AMP_OUI,
5667 WLANTL_LLC_OUI_SIZE ) ))
5668 {
5669 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
5670 "LLC header points to diff OUI in BT-AMP station -"
5671 "dropping pkt"));
5672 /* Drop packet */
5673 vos_pkt_return_packet(vosTempBuff);
5674 return VOS_TRUE;
5675 }
5676#endif
5677 /*------------------------------------------------------------------------
5678 Extract LLC OUI and ensure that this is indeed a BT-AMP frame
5679 ------------------------------------------------------------------------*/
5680 vosStatus = vos_pkt_extract_data( vosTempBuff,
5681 ucOffset + WLANTL_LLC_OUI_SIZE,
5682 (v_PVOID_t)&usType, &usTypeLen);
5683
5684 if (( VOS_STATUS_SUCCESS != vosStatus) ||
5685 ( sizeof(usType) != usTypeLen ))
5686 {
5687 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
5688 "Unable to extract type on incoming BAP packet -"
5689 "dropping pkt"));
5690 /* Drop packet */
5691 vos_pkt_return_packet(vosTempBuff);
5692 return VOS_TRUE;
5693 }
5694
5695 /*------------------------------------------------------------------------
5696 Check if this is BT-AMP data or ctrl packet(RSN, LinkSvision, ActivityR)
5697 ------------------------------------------------------------------------*/
5698 usType = vos_be16_to_cpu(usType);
5699
5700 if (WLANTL_BAP_IS_NON_DATA_PKT_TYPE(usType))
5701 {
5702 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
5703 "WLAN TL:Non-data packet received over BT-AMP link: %d, => BAP",
5704 usType));
5705
5706 /*Flatten packet as BAP expects to be able to peek*/
5707 if ( VOS_STATUS_SUCCESS != vos_pkt_flatten_rx_pkt(&vosTempBuff))
5708 {
5709 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
5710 "WLAN TL:Cannot flatten BT-AMP packet - dropping"));
5711 /* Drop packet */
5712 vos_pkt_return_packet(vosTempBuff);
5713 return VOS_TRUE;
5714 }
5715
5716 /* Send packet to BAP client*/
Jeff Johnson295189b2012-06-20 16:38:30 -07005717 if ( VOS_STATUS_SUCCESS != WDA_DS_TrimRxPacketInfo( vosTempBuff ) )
5718 {
5719 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
5720 "WLAN TL:BD header corrupted - dropping packet"));
5721 /* Drop packet */
5722 vos_pkt_return_packet(vosTempBuff);
5723 return VOS_TRUE;
5724 }
5725
5726 if ( 0 == WDA_GET_RX_FT_DONE(pvBDHeader) )
5727 {
5728 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
5729 "Non-data packet received over BT-AMP link: Sending it for "
5730 "frame Translation"));
5731
5732 if (usMPDUDOffset > ucMPDUHOffset)
5733 {
5734 usActualHLen = usMPDUDOffset - ucMPDUHOffset;
5735 }
5736
5737 /* software frame translation for BTAMP WDS.*/
5738 WLANTL_Translate80211To8023Header( vosTempBuff, &vosStatus, usActualHLen,
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005739 ucMPDUHLen, pTLCb,ucSTAId, VOS_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07005740
5741 }
5742 if (pTLCb->tlBAPClient.pfnTlBAPRx)
5743 pTLCb->tlBAPClient.pfnTlBAPRx( vos_get_global_context(VOS_MODULE_ID_TL,pTLCb),
5744 vosTempBuff,
5745 (WLANTL_BAPFrameEnumType)usType );
Manjunathappa Prakashfb585462013-12-23 19:07:07 -08005746 else
5747 {
5748 VOS_ASSERT(0);
5749 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005750
5751 return VOS_TRUE;
5752 }
5753 else
5754 {
5755 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
5756 "WLAN TL: BAP DATA packet received over BT-AMP link: %d, => BAP",
5757 usType));
5758 /*!!!FIX ME!!*/
5759 #if 0
5760 /*--------------------------------------------------------------------
5761 For data packet collect phy stats RSSI and Link Quality
5762 Calculate the RSSI average and save it. Continuous average is done.
5763 --------------------------------------------------------------------*/
5764 if ( *pFirstDataPktArrived == 0)
5765 {
5766 pTLCb->atlSTAClients[ucSTAId].rssiAvg =
5767 WLANHAL_GET_RSSI_AVERAGE( pvBDHeader );
5768 pTLCb->atlSTAClients[ucSTAId].uLinkQualityAvg =
5769 WLANHAL_RX_BD_GET_SNR( pvBDHeader );
5770
5771 // Rcvd 1st pkt, start average from next time
5772 *pFirstDataPktArrived = 1;
5773 }
5774 else
5775 {
5776 pTLCb->atlSTAClients[ucSTAId].rssiAvg =
5777 (WLANHAL_GET_RSSI_AVERAGE( pvBDHeader ) +
5778 pTLCb->atlSTAClients[ucSTAId].rssiAvg)/2;
5779 pTLCb->atlSTAClients[ucSTAId].uLinkQualityAvg =
5780 (WLANHAL_RX_BD_GET_SNR( pvBDHeader ) +
5781 pTLCb->atlSTAClients[ucSTAId].uLinkQualityAvg)/2;
5782 }/*Else, first data packet*/
5783 #endif
5784 }/*BT-AMP data packet*/
5785
5786 return VOS_FALSE;
5787}/*WLANTL_ProcessBAPFrame*/
5788
Jeff Johnson295189b2012-06-20 16:38:30 -07005789
5790/*==========================================================================
5791
5792 FUNCTION WLANTL_ProcessFCFrame
5793
5794 DESCRIPTION
5795 Internal utility function for processing incoming Flow Control frames. Enable
5796 or disable LWM mode based on the information.
5797
5798 DEPENDENCIES
5799 TL must be initiailized before this function gets called.
5800 FW sends up special flow control frame.
5801
5802 PARAMETERS
5803
5804 IN
5805 pvosGCtx pointer to vos global context
5806 pvBDHeader: pointer to the BD header
5807 pTLCb: TL control block
5808 pvBDHeader pointer to BD header.
5809
5810 IN/OUT
5811 pFirstDataPktArrived: static from caller function; used for rssi
5812 computation
5813 RETURN VALUE
5814 The result code associated with performing the operation
5815
5816 VOS_STATUS_E_INVAL: Input frame are invalid
5817 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
5818 page fault
5819 VOS_STATUS_SUCCESS: Everything is good :)
5820
5821 SIDE EFFECTS
5822 The ingress and egress of each station will be updated. If needed, LWM mode will
5823 be enabled or disabled based on the flow control algorithm.
5824
5825============================================================================*/
5826v_BOOL_t
5827WLANTL_ProcessFCFrame
5828(
5829 v_PVOID_t pvosGCtx,
5830 vos_pkt_t* pvosDataBuff,
5831 v_PVOID_t pvBDHeader
5832)
5833{
5834#if 1 //enable processing of only fcStaTxDisabled bitmap for now. the else part is old better qos code.
5835 // need to revisit the old code for full implementation.
Hoonki Lee14621352013-04-16 17:51:19 -07005836 v_U8_t ucSTAId;
5837 v_U16_t ucStaValidBitmap;
5838 v_U16_t ucStaTxDisabledBitmap;
5839 WLANTL_CbType* pTLCb = NULL;
5840 #ifdef TL_DEBUG_FC
5841 v_U32_t rxTimeStamp;
5842 v_U32_t curTick;
5843 #endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005844 /*------------------------------------------------------------------------
Hoonki Lee14621352013-04-16 17:51:19 -07005845 Extract TL control block
Jeff Johnson295189b2012-06-20 16:38:30 -07005846 ------------------------------------------------------------------------*/
5847 pTLCb = VOS_GET_TL_CB(pvosGCtx);
5848 if ( NULL == pTLCb )
5849 {
5850 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
5851 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_SuspendDataTx"));
5852 return VOS_STATUS_E_FAULT;
5853 }
Hoonki Lee14621352013-04-16 17:51:19 -07005854 ucStaValidBitmap = WDA_GET_RX_FC_VALID_STA_MASK(pvBDHeader);
5855 ucStaTxDisabledBitmap = WDA_GET_RX_FC_STA_TX_DISABLED_BITMAP(pvBDHeader);
5856#ifdef TL_DEBUG_FC
5857 rxTimeStamp = WDA_GET_RX_TIMESTAMP(pvBDHeader);
5858 /* hard code of MTU_GLOBAL_TIMER_ADDR to calculate the time between generated and processed */
5859 wpalReadRegister(0x03081400+0x1D4, &curTick);
Jeff Johnson295189b2012-06-20 16:38:30 -07005860
Jeff Johnson295189b2012-06-20 16:38:30 -07005861 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Arif Hussainf2b00992013-11-17 21:46:15 -08005862 "%ld (%ld-%ld): Disabled %x Valid %x", curTick > rxTimeStamp ? curTick - rxTimeStamp : rxTimeStamp - (0xFFFFFFFF - curTick),
Hoonki Lee14621352013-04-16 17:51:19 -07005863 curTick, rxTimeStamp, ucStaTxDisabledBitmap, ucStaValidBitmap));
5864#endif
5865 for(ucSTAId = 0; ucStaValidBitmap != 0; ucStaValidBitmap >>=1, ucStaTxDisabledBitmap >>= 1, ucSTAId ++)
Jeff Johnson295189b2012-06-20 16:38:30 -07005866 {
Hoonki Lee14621352013-04-16 17:51:19 -07005867 if ( (0 == (ucStaValidBitmap & 0x1)) || (pTLCb->atlSTAClients[ucSTAId] && (0 == pTLCb->atlSTAClients[ucSTAId]->ucExists)) )
5868 continue;
5869
5870 if (ucStaTxDisabledBitmap & 0x1)
5871 {
5872 WLANTL_SuspendDataTx(pvosGCtx, &ucSTAId, NULL);
5873 }
5874 else
5875 {
5876 WLANTL_ResumeDataTx(pvosGCtx, &ucSTAId);
5877 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005878 }
5879
5880#else
5881 VOS_STATUS vosStatus;
5882 tpHalFcRxBd pvFcRxBd = NULL;
5883 v_U8_t ucBitCheck = 0x1;
5884 v_U8_t ucStaValid = 0;
5885 v_U8_t ucSTAId = 0;
5886
5887 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
5888 "Received FC Response");
5889 if ( (NULL == pTLCb) || (NULL == pvosDataBuff))
5890 {
5891 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Arif Hussainf2b00992013-11-17 21:46:15 -08005892 "WLAN TL:Invalid pointer in %s", __func__));
Jeff Johnson295189b2012-06-20 16:38:30 -07005893 return VOS_STATUS_E_FAULT;
5894 }
5895 vosStatus = vos_pkt_peek_data( pvosDataBuff, 0, (v_PVOID_t)&pvFcRxBd,
5896 sizeof(tHalFcRxBd));
5897
5898 if ( (VOS_STATUS_SUCCESS != vosStatus) || (NULL == pvFcRxBd) )
5899 {
5900 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
5901 "WLAN TL:wrong FC Rx packet"));
5902 return VOS_STATUS_E_INVAL;
5903 }
5904
5905 // need to swap bytes in the FC contents.
5906 WLANHAL_SwapFcRxBd(&pvFcRxBd->fcSTATxQLen[0]);
5907
5908 //logic to enable/disable LWM mode for each station
5909 for( ucStaValid = (v_U8_t)pvFcRxBd->fcSTAValidMask; ucStaValid; ucStaValid >>= 1, ucBitCheck <<= 1, ucSTAId ++)
5910 {
5911 if ( (0 == (ucStaValid & 0x1)) || (0 == pTLCb->atlSTAClients[ucSTAId].ucExists) )
5912 {
5913 continue;
5914 }
5915
5916 if ( pvFcRxBd->fcSTAThreshIndMask & ucBitCheck )
5917 {
5918 //LWM event is reported by FW. Able to fetch more packet
5919 if( pTLCb->atlSTAClients[ucSTAId].ucLwmModeEnabled )
5920 {
5921 //Now memory usage is below LWM. Station can send more packets.
5922 pTLCb->atlSTAClients[ucSTAId].ucLwmEventReported = TRUE;
5923 }
5924 else
5925 {
5926 TLLOG4(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_LOW,
Arif Hussainf2b00992013-11-17 21:46:15 -08005927 "WLAN TL: FW report LWM event but the station %d is not in LWM mode", ucSTAId));
Jeff Johnson295189b2012-06-20 16:38:30 -07005928 }
5929 }
5930
5931 //calculate uEgress_length/uIngress_length only after receiving enough packets
5932 if (WLANTL_LWM_INGRESS_SAMPLE_THRESHOLD <= pTLCb->atlSTAClients[ucSTAId].uIngress_length)
5933 {
5934 //check memory usage info to see whether LWM mode should be enabled for the station
5935 v_U32_t uEgress_length = pTLCb->atlSTAClients[ucSTAId].uIngress_length +
5936 pTLCb->atlSTAClients[ucSTAId].bmuMemConsumed - pvFcRxBd->fcSTATxQLen[ucSTAId];
5937
5938 //if ((float)uEgress_length/(float)pTLCb->atlSTAClients[ucSTAId].uIngress_length
5939 // <= WLANTL_LWM_EGRESS_INGRESS_THRESHOLD)
5940 if ( (pTLCb->atlSTAClients[ucSTAId].uIngress_length > uEgress_length) &&
5941 ((pTLCb->atlSTAClients[ucSTAId].uIngress_length - uEgress_length ) >=
5942 (pTLCb->atlSTAClients[ucSTAId].uIngress_length >> 2))
5943 )
5944 {
5945 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
Arif Hussainf2b00992013-11-17 21:46:15 -08005946 "WLAN TL:Enable LWM mode for station %d", ucSTAId));
Jeff Johnson295189b2012-06-20 16:38:30 -07005947 pTLCb->atlSTAClients[ucSTAId].ucLwmModeEnabled = TRUE;
5948 }
5949 else
5950 {
5951 if( pTLCb->atlSTAClients[ucSTAId].ucLwmModeEnabled )
5952 {
5953 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
Arif Hussainf2b00992013-11-17 21:46:15 -08005954 "WLAN TL:Disable LWM mode for station %d", ucSTAId));
Jeff Johnson295189b2012-06-20 16:38:30 -07005955 pTLCb->atlSTAClients[ucSTAId].ucLwmModeEnabled = FALSE;
5956 }
5957
5958 }
5959
5960 //remember memory usage in FW starting from this round
5961 pTLCb->atlSTAClients[ucSTAId].bmuMemConsumed = pvFcRxBd->fcSTATxQLen[ucSTAId];
5962 pTLCb->atlSTAClients[ucSTAId].uIngress_length = 0;
5963 } //(WLANTL_LWM_INGRESS_SAMPLE_THRESHOLD <= pTLCb->atlSTAClients[ucSTAId].uIngress_length)
5964
5965 if( pTLCb->atlSTAClients[ucSTAId].ucLwmModeEnabled )
5966 {
5967 //always update current maximum allowed memeory usage
5968 pTLCb->atlSTAClients[ucSTAId].uBuffThresholdMax = WLANTL_STA_BMU_THRESHOLD_MAX -
5969 pvFcRxBd->fcSTATxQLen[ucSTAId];
5970 }
5971
5972 }
5973#endif
5974
5975 return VOS_STATUS_SUCCESS;
5976}
Jeff Johnson295189b2012-06-20 16:38:30 -07005977
Sravan Kumar Kairamb0edc612016-10-26 13:55:24 +05305978/**
5979 * WLANTL_FlowControl() - TX Flow control
5980 * @pTLCb: TL context pointer
5981 * @pvosDataBuff: Firmware indication data buffer
5982 *
5983 * This function implenets the algorithm to flow control TX traffic in case
5984 * of SAP and SAP + STA concurrency.
5985 *
5986 * Algorithm goal is to fetch more packets from good peer than bad peer by
5987 * introducing weights for each station connected. Weight of each station is
5988 * calcutated by taking ratio of max RA rate of the peers to its rate. If the
5989 * ratio is less than two based on number of queued frames in the station BTQM
5990 * weight is modified. If the queued frames reaches the defined threshold weight
5991 * is assigned as four. Here weight is inversely proportional to the number of
5992 * packets fetch.
5993 *
5994 * Return true if flow controlled or false otherwise.
5995 */
5996static bool WLANTL_FlowControl(WLANTL_CbType* pTLCb, vos_pkt_t* pvosDataBuff)
5997{
5998 WLANTL_FlowControlInfo *fc_data = NULL;
5999 WLANTL_PerStaFlowControlParam *sta_fc_params = NULL;
6000 uint8_t num_stas;
6001 struct sk_buff *skb = NULL;
6002 uint16_t data_len;
6003 uint8_t *staid;
6004 uint16_t max_rate = 0;
6005 uint8_t i;
6006
6007 vos_pkt_get_packet_length(pvosDataBuff, &data_len);
6008 if (!data_len) {
6009 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6010 "%s: Null fw indication data", __func__));
6011 return false;
6012 }
6013
6014 vos_pkt_get_os_packet(pvosDataBuff, (v_VOID_t **)&skb, 0);
6015 fc_data = (WLANTL_FlowControlInfo *)skb->data;
6016 num_stas = fc_data->num_stas;
6017 if (!num_stas) {
6018 TLLOG1(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
6019 "%s: No connected stations", __func__));
6020 return true;
6021 }
6022
6023 /* Skip flow control for one connected station */
6024 if (1 == num_stas)
6025 return true;
6026
6027 staid = (uint8_t *)vos_mem_malloc(WLAN_MAX_STA_COUNT);
6028 if (!staid) {
6029 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6030 "%s: mem allocation failure", __func__));
6031 return false;
6032 }
6033 vos_mem_set((uint8_t *)staid, WLAN_MAX_STA_COUNT, 0);
6034
6035 sta_fc_params = (WLANTL_PerStaFlowControlParam *)(&fc_data->num_stas + 1);
6036
6037 for(i = 0; i < num_stas; i ++, sta_fc_params ++) {
6038 staid[i] = sta_fc_params->sta_id;
6039
6040 if (!pTLCb->atlSTAClients[staid[i]])
6041 continue;
6042
6043 pTLCb->atlSTAClients[staid[i]]->per = sta_fc_params->avg_per;
6044 pTLCb->atlSTAClients[staid[i]]->queue = sta_fc_params->queue_len;
6045 pTLCb->atlSTAClients[staid[i]]->trate = sta_fc_params->rate;
6046 max_rate = max_rate > pTLCb->atlSTAClients[staid[i]]->trate ?
6047 max_rate : pTLCb->atlSTAClients[staid[i]]->trate;
6048
6049 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
6050 "%s: sta_id:%d in:%d queue:%d avg_per:%d rate:%d", __func__,
6051 staid[i], pTLCb->atlSTAClients[staid[i]]->tx_samples_sum,
6052 pTLCb->atlSTAClients[staid[i]]->queue,
6053 pTLCb->atlSTAClients[staid[i]]->per,
6054 pTLCb->atlSTAClients[staid[i]]->trate));
6055 }
6056
6057 for (i = 0; i < num_stas; i++) {
6058 pTLCb->atlSTAClients[staid[i]]->weight =
6059 max_rate/pTLCb->atlSTAClients[staid[i]]->trate;
Sravan Kumar Kairamd482a2b2017-02-09 17:44:58 +05306060 if (pTLCb->atlSTAClients[staid[i]]->weight >=
6061 WLANTL_RATE_RATIO_THRESHOLD) {
6062 if (!pTLCb->atlSTAClients[staid[i]]->set_flag) {
Sravan Kumar Kairamb0edc612016-10-26 13:55:24 +05306063 vos_set_hdd_bad_sta(staid[i]);
6064 pTLCb->atlSTAClients[staid[i]]->set_flag = true;
Sravan Kumar Kairamd482a2b2017-02-09 17:44:58 +05306065 }
6066 /**
6067 * If station's link becomes very bad rssi below -90dbm then because
6068 * of high PER rate high number of packets are stuck in BTQM which is
6069 * affecting the good peers throughput. So throttle further the bad
6070 * link traffic.
6071 */
6072 if ((pTLCb->atlSTAClients[staid[i]]->weight >
6073 WLANTL_WEIGHT_THRESHOLD) &&
6074 (pTLCb->atlSTAClients[staid[i]]->queue >
6075 WLANTL_QUEUE_THRESHOLD))
6076 pTLCb->atlSTAClients[staid[i]]->weight *= 2;
Sravan Kumar Kairamb0edc612016-10-26 13:55:24 +05306077 }
6078 if (pTLCb->atlSTAClients[staid[i]]->weight <
6079 WLANTL_RATE_RATIO_THRESHOLD) {
Sravan Kumar Kairamd482a2b2017-02-09 17:44:58 +05306080 if (pTLCb->atlSTAClients[staid[i]]->per >= WLANTL_PER_THRESHOLD &&
Sravan Kumar Kairam7ce69332017-02-15 15:41:43 +05306081 pTLCb->atlSTAClients[staid[i]]->queue > WLANTL_QUEUE_THRESHOLD
6082 && !pTLCb->atlSTAClients[staid[i]]->set_flag) {
6083 pTLCb->atlSTAClients[staid[i]]->weight *= 2;
6084 vos_set_hdd_bad_sta(staid[i]);
6085 pTLCb->atlSTAClients[staid[i]]->set_flag = true;
Sravan Kumar Kairam416a0c22017-01-02 22:58:09 +05306086 }
6087 else if (pTLCb->atlSTAClients[staid[i]]->set_flag) {
Sravan Kumar Kairamb0edc612016-10-26 13:55:24 +05306088 vos_reset_hdd_bad_sta(staid[i]);
6089 pTLCb->atlSTAClients[staid[i]]->set_flag = false;
6090 }
6091 }
6092 }
6093 vos_mem_free(staid);
6094 return true;
6095}
Jeff Johnson295189b2012-06-20 16:38:30 -07006096
Sravan Kumar Kairam091e5b62017-01-23 14:14:20 +05306097/**
6098 * WLANTL_CacheEapol() - cache eapol frames
6099 * @pTLCb : pointer to TL context
6100 * @vosTempBuff: pointer to vos packet buff
6101 *
6102 * Return: None
6103 *
6104 */
6105static void WLANTL_CacheEapol(WLANTL_CbType* pTLCb, vos_pkt_t* vosTempBuff)
6106{
6107 if ((NULL == pTLCb) || (NULL == vosTempBuff))
6108 {
6109 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6110 "%s: Invalid input pointer", __func__));
6111 return;
6112 }
6113
6114 if (NULL == pTLCb->vosEapolCachedFrame) {
6115 TLLOG1(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
6116 "%s: Cache Eapol frame", __func__));
6117 pTLCb->vosEapolCachedFrame = vosTempBuff;
6118 }
Sravan Kumar Kairam2e44dd42017-02-13 18:31:09 +05306119 else {
6120 TLLOG1(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
6121 "%s: Drop duplicate EAPOL frame", __func__));
6122 vos_pkt_return_packet(vosTempBuff);
6123 }
Sravan Kumar Kairam091e5b62017-01-23 14:14:20 +05306124}
6125
Sravan Kumar Kairame0e78442017-09-18 18:00:53 +05306126/**
6127 * WLANTL_SampleRxRSSI() - Collect RX rssi samples
6128 * @pTLCb: TL context pointer
6129 * @pBDHeader: RX Meta data pointer
6130 * @sta_id: Station ID
6131 *
6132 * This function records the last twenty RX RSSI samples
6133 *
6134 * Return: void
6135 */
6136static void WLANTL_SampleRxRSSI(WLANTL_CbType* pTLCb, void * pBDHeader,
6137 uint8_t sta_id)
6138{
6139 WLANTL_STAClientType *pClientSTA = pTLCb->atlSTAClients[sta_id];
6140 uint8_t count = pClientSTA->rssi_sample_cnt;
6141 uint8_t old_idx = pClientSTA->rssi_stale_idx;
6142 s8 curr_RSSI, curr_RSSI0, curr_RSSI1;
6143
6144 curr_RSSI0 = WLANTL_GETRSSI0(pBDHeader);
6145 curr_RSSI1 = WLANTL_GETRSSI1(pBDHeader);
6146
6147 curr_RSSI = (curr_RSSI0 > curr_RSSI1) ? curr_RSSI0 : curr_RSSI1;
6148
6149 if (count >= WLANTL_RSSI_SAMPLE_CNT) {
6150 pClientSTA->rssi_sample_sum -= pClientSTA->rssi_sample[old_idx];
6151 pClientSTA->rssi_sample[old_idx] = curr_RSSI;
6152 pClientSTA->rssi_sample_sum += pClientSTA->rssi_sample[old_idx];
6153 old_idx >= WLANTL_RSSI_SAMPLE_CNT ? old_idx = 0 : old_idx++;
6154 pClientSTA->rssi_stale_idx = old_idx;
6155 } else {
6156 pClientSTA->rssi_sample[count] = curr_RSSI;
6157 pClientSTA->rssi_sample_sum += pClientSTA->rssi_sample[count];
6158 pClientSTA->rssi_sample_cnt++;
6159 }
6160}
6161
Alok Kumarda6c8882017-12-08 11:11:59 +05306162/**
6163 * WLANTL_StaMonRX - Send packets to monitor mode
6164 * @pTLCb: TL context pointer
6165 * @pFrame: Rx buffer pointer
6166 * @pBDHeader: RX Meta data pointer
6167 * @sta_id: Station ID
6168 *
6169 * Return: true if RX monitor mode or false otherwise
6170 */
6171static bool WLANTL_StaMonRX(WLANTL_CbType* pTLCb, vos_pkt_t *pFrame,
6172 WDI_DS_RxMetaInfoType *pRxMetadata,
6173 uint8_t sta_id)
6174{
6175 WLANTL_STAClientType *pClientSTA = NULL;
6176 tpSirMacMgmtHdr pHdr = NULL;
6177 v_MACADDR_t *peerMacAddr = NULL;
6178 uint8_t i = 0;
Rajeev Kumar Sirasanagandla8701da32018-02-05 16:59:08 +05306179 uint8_t addr1_index = WDA_GET_RX_ADDR1_IDX(pRxMetadata);
6180 bool tp_data = false;
Alok Kumarda6c8882017-12-08 11:11:59 +05306181
6182 pHdr = (tpSirMacMgmtHdr)pRxMetadata->mpduHeaderPtr;
Rajeev Kumar Sirasanagandla8701da32018-02-05 16:59:08 +05306183 peerMacAddr = (v_MACADDR_t *)pHdr->da;
Alok Kumarda6c8882017-12-08 11:11:59 +05306184
Rajeev Kumar Sirasanagandla8701da32018-02-05 16:59:08 +05306185 if (vos_check_monitor_state() == false)
6186 return false;
6187
6188 if ((addr1_index == 254) &&
6189 WLANTL_IS_DATA_FRAME(WDA_GET_RX_TYPE_SUBTYPE(pRxMetadata)) &&
6190 !pRxMetadata->bcast) {
6191 tp_data = true;
6192 } else if (WLANTL_STA_ID_MONIFACE(sta_id) == 0) {
6193 return false;
6194 }
6195
6196 if (WLANTL_IS_MGMT_FRAME(WDA_GET_RX_TYPE_SUBTYPE(pRxMetadata)) || tp_data) {
Alok Kumarda6c8882017-12-08 11:11:59 +05306197
6198 if (pRxMetadata->bcast)
6199 return false;
6200
6201 for (i = 0; i < WLAN_MAX_STA_COUNT; i++) {
6202 if (NULL == pTLCb->atlSTAClients[i])
6203 continue;
6204 if (0 == pTLCb->atlSTAClients[i]->ucExists)
6205 continue;
6206 if (WLANTL_STA_AUTHENTICATED == pTLCb->atlSTAClients[i]->tlState)
6207 break;
6208 }
6209
Rajeev Kumar Sirasanagandla8701da32018-02-05 16:59:08 +05306210 if (i == WLAN_MAX_STA_COUNT) {
6211 if (tp_data)
6212 return true;
6213
Alok Kumarda6c8882017-12-08 11:11:59 +05306214 return false;
Rajeev Kumar Sirasanagandla8701da32018-02-05 16:59:08 +05306215 }
Alok Kumarda6c8882017-12-08 11:11:59 +05306216
6217 pClientSTA = pTLCb->atlSTAClients[i];
Alok Kumarda6c8882017-12-08 11:11:59 +05306218
6219 if (vos_is_macaddr_equal(peerMacAddr,
Rajeev Kumar Sirasanagandla8701da32018-02-05 16:59:08 +05306220 &pClientSTA->wSTADesc.vSelfMACAddress))
6221 return false;
6222
6223 if (vos_is_macaddr_equal(peerMacAddr, &pTLCb->spoofMacAddr.spoofMac) &&
6224 !tp_data)
Alok Kumarda6c8882017-12-08 11:11:59 +05306225 return false;
6226 }
6227
6228 return true;
6229}
6230
Jeff Johnson295189b2012-06-20 16:38:30 -07006231/*==========================================================================
6232
6233 FUNCTION WLANTL_RxFrames
6234
6235 DESCRIPTION
6236 Callback registered by TL and called by BAL when a packet is received
6237 over the bus. Upon the call of this function TL will make the necessary
6238 decision with regards to the forwarding or queuing of this packet and
6239 the layer it needs to be delivered to.
6240
6241 DEPENDENCIES
6242 TL must be initiailized before this function gets called.
6243 If the frame carried is a data frame then the station for which it is
6244 destined to must have been previously registered with TL.
6245
6246 PARAMETERS
6247
6248 IN
6249 pvosGCtx: pointer to the global vos context; a handle to TL's
6250 or BAL's control block can be extracted from its context
6251
6252 vosDataBuff: it will contain a pointer to the first buffer received,
6253 if there is more then one packet they will be chained
6254 using vOSS buffers.
6255
6256 RETURN VALUE
6257 The result code associated with performing the operation
6258
6259 VOS_STATUS_E_INVAL: Input parameters are invalid
6260 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
6261 page fault
6262 VOS_STATUS_SUCCESS: Everything is good :)
6263
6264 SIDE EFFECTS
6265
6266============================================================================*/
6267VOS_STATUS
6268WLANTL_RxFrames
6269(
6270 v_PVOID_t pvosGCtx,
6271 vos_pkt_t *pFrameDataBuff
6272)
6273{
6274 vos_pkt_t* vosDataBuff = (vos_pkt_t*)pFrameDataBuff;
6275 WLANTL_CbType* pTLCb = NULL;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306276 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07006277 WLANTL_STAFuncType pfnSTAFsm;
6278 vos_pkt_t* vosTempBuff;
6279 v_U8_t ucSTAId;
6280 VOS_STATUS vosStatus;
6281 v_U8_t ucFrmType;
6282 v_PVOID_t pvBDHeader = NULL;
6283 WLANTL_STAEventType wSTAEvent = WLANTL_RX_EVENT;
6284 v_U8_t ucTid = 0;
6285 v_BOOL_t broadcast = VOS_FALSE;
6286 v_BOOL_t selfBcastLoopback = VOS_FALSE;
Madan Mohan Koyyalamudidfd6aa82012-10-18 20:18:43 -07006287 static v_U8_t first_data_pkt_arrived;
Jeff Johnson295189b2012-06-20 16:38:30 -07006288 v_U32_t uDPUSig;
Jeff Johnson295189b2012-06-20 16:38:30 -07006289 v_U16_t usPktLen;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07006290 v_BOOL_t bForwardIAPPwithLLC = VOS_FALSE;
Dino Mycle3b9536d2014-07-09 22:05:24 +05306291#ifdef WLAN_FEATURE_LINK_LAYER_STATS
6292 v_S7_t currentAvgRSSI = 0;
6293 v_U8_t ac;
Dino Mycle3b9536d2014-07-09 22:05:24 +05306294#endif
Sravan Kumar Kairam2e44dd42017-02-13 18:31:09 +05306295 uint8_t ucMPDUHLen;
Sravan Kumar Kairam091e5b62017-01-23 14:14:20 +05306296 uint16_t seq_no;
Sravan Kumar Kairam04f093a2017-11-16 19:59:05 +05306297 u64 pn_num;
Sravan Kumar Kairam2e44dd42017-02-13 18:31:09 +05306298 uint16_t usEtherType = 0;
Alok Kumarda6c8882017-12-08 11:11:59 +05306299 bool sta_mon_data = false;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07006300
Jeff Johnson295189b2012-06-20 16:38:30 -07006301 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
6302
6303 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
6304 "WLAN TL:TL Receive Frames called"));
6305
6306 /*------------------------------------------------------------------------
6307 Sanity check
6308 ------------------------------------------------------------------------*/
6309 if ( NULL == vosDataBuff )
6310 {
6311 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6312 "WLAN TL:Invalid parameter sent on WLANTL_RxFrames"));
6313 return VOS_STATUS_E_INVAL;
6314 }
6315
Katya Nigam3802f202013-12-16 19:27:14 +05306316 /*------------------------------------------------------------------------
6317 Popolaute timestamp as the time when packet arrives
6318 ---------------------------------------------------------------------- */
6319 vosDataBuff->timestamp = vos_timer_get_system_ticks();
6320
Jeff Johnson295189b2012-06-20 16:38:30 -07006321 /*------------------------------------------------------------------------
6322 Extract TL control block
6323 ------------------------------------------------------------------------*/
6324 pTLCb = VOS_GET_TL_CB(pvosGCtx);
6325 if ( NULL == pTLCb )
6326 {
6327 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6328 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_ChangeSTAState"));
6329 return VOS_STATUS_E_FAULT;
6330 }
6331
6332 /*---------------------------------------------------------------------
6333 Save the initial buffer - this is the first received buffer
6334 ---------------------------------------------------------------------*/
6335 vosTempBuff = vosDataBuff;
6336
Sravan Kumar Kairam4ea1c422017-02-21 11:59:13 +05306337 while (NULL != vosDataBuff)
Jeff Johnson295189b2012-06-20 16:38:30 -07006338 {
Madan Mohan Koyyalamudia148e1e2012-11-30 14:52:59 -08006339 broadcast = VOS_FALSE;
6340 selfBcastLoopback = VOS_FALSE;
6341
Jeff Johnson295189b2012-06-20 16:38:30 -07006342 vos_pkt_walk_packet_chain( vosDataBuff, &vosDataBuff, 1/*true*/ );
6343
6344 /*---------------------------------------------------------------------
6345 Peek at BD header - do not remove
6346 !!! Optimize me: only part of header is needed; not entire one
6347 ---------------------------------------------------------------------*/
6348 vosStatus = WDA_DS_PeekRxPacketInfo( vosTempBuff, (v_PVOID_t)&pvBDHeader, 1/*Swap BD*/ );
6349
6350 if ( NULL == pvBDHeader )
6351 {
6352 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6353 "WLAN TL:Cannot extract BD header"));
6354 /* Drop packet */
6355 vos_pkt_return_packet(vosTempBuff);
6356 vosTempBuff = vosDataBuff;
6357 continue;
6358 }
6359
Jeff Johnson295189b2012-06-20 16:38:30 -07006360 /*---------------------------------------------------------------------
Alok Kumarda6c8882017-12-08 11:11:59 +05306361 Check if frame is for monitor interface
6362 ---------------------------------------------------------------------*/
6363 ucSTAId = (v_U8_t)WDA_GET_RX_STAID(pvBDHeader);
6364
6365 sta_mon_data = WLANTL_StaMonRX(pTLCb, vosTempBuff, pvBDHeader, ucSTAId);
6366
6367 if (vos_get_conparam() == VOS_MONITOR_MODE || sta_mon_data)
6368 {
6369 sta_mon_data = false;
6370
6371 if( pTLCb->isConversionReq )
6372 WLANTL_MonTranslate80211To8023Header(vosTempBuff, pTLCb);
6373
6374 pTLCb->pfnMonRx(pvosGCtx, vosTempBuff, pTLCb->isConversionReq);
6375 vosTempBuff = vosDataBuff;
6376 continue;
6377 }
6378
6379 /*---------------------------------------------------------------------
Jeff Johnson295189b2012-06-20 16:38:30 -07006380 Check if FC frame reported from FW
6381 ---------------------------------------------------------------------*/
6382 if(WDA_IS_RX_FC(pvBDHeader))
6383 {
6384 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
6385 "WLAN TL:receive one FC frame"));
6386
Sravan Kumar Kairamb0edc612016-10-26 13:55:24 +05306387 WLANTL_FlowControl(pTLCb, vosTempBuff);
6388
Jeff Johnson295189b2012-06-20 16:38:30 -07006389 /* Drop packet */
6390 vos_pkt_return_packet(vosTempBuff);
6391 vosTempBuff = vosDataBuff;
6392 continue;
6393 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006394
6395 /* AMSDU HW bug fix
6396 * After 2nd AMSDU subframe HW could not handle BD correctly
6397 * HAL workaround is needed */
6398 if(WDA_GET_RX_ASF(pvBDHeader))
6399 {
6400 WDA_DS_RxAmsduBdFix(pvosGCtx, pvBDHeader);
6401 }
6402
6403 /*---------------------------------------------------------------------
6404 Extract frame control field from 802.11 header if present
6405 (frame translation not done)
6406 ---------------------------------------------------------------------*/
6407
6408 vosStatus = WDA_DS_GetFrameTypeSubType( pvosGCtx, vosTempBuff,
6409 pvBDHeader, &ucFrmType );
6410 if ( VOS_STATUS_SUCCESS != vosStatus )
6411 {
6412 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6413 "WLAN TL:Cannot extract Frame Control Field"));
6414 /* Drop packet */
6415 vos_pkt_return_packet(vosTempBuff);
6416 vosTempBuff = vosDataBuff;
6417 continue;
6418 }
6419
Jeff Johnson295189b2012-06-20 16:38:30 -07006420 vos_pkt_get_packet_length(vosTempBuff, &usPktLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07006421
6422 /*---------------------------------------------------------------------
6423 Check if management and send to PE
6424 ---------------------------------------------------------------------*/
6425
Deepthi Gowrie89de132015-05-14 12:23:57 +05306426 if ( WLANTL_IS_MGMT_FRAME(ucFrmType))
Jeff Johnson295189b2012-06-20 16:38:30 -07006427 {
6428 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
6429 "WLAN TL:Sending packet to management client"));
6430 if ( VOS_STATUS_SUCCESS != vos_pkt_flatten_rx_pkt(&vosTempBuff))
6431 {
6432 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6433 "WLAN TL:Cannot flatten packet - dropping"));
6434 /* Drop packet */
6435 vos_pkt_return_packet(vosTempBuff);
6436 vosTempBuff = vosDataBuff;
6437 continue;
6438 }
6439 ucSTAId = (v_U8_t)WDA_GET_RX_STAID( pvBDHeader );
6440 /* Read RSSI and update */
6441 if(!WLANTL_STA_ID_INVALID(ucSTAId))
6442 {
6443#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
6444 /* Read RSSI and update */
6445 vosStatus = WLANTL_HSHandleRXFrame(pvosGCtx,
6446 WLANTL_MGMT_FRAME_TYPE,
6447 pvBDHeader,
6448 ucSTAId,
6449 VOS_FALSE,
6450 NULL);
6451#else
6452 vosStatus = WLANTL_ReadRSSI(pvosGCtx, pvBDHeader, ucSTAId);
6453#endif
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05306454 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
6455 {
6456 TLLOGW(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
6457 "Handle RX Management Frame fail within Handoff "
6458 "support module"));
6459 /* Do Not Drop packet at here
6460 * Revisit why HO module return fail
6461 * vos_pkt_return_packet(vosTempBuff);
6462 * vosTempBuff = vosDataBuff;
6463 * continue;
6464 */
6465 }
6466 vosStatus = WLANTL_ReadSNR(pvosGCtx, pvBDHeader, ucSTAId);
6467
6468 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
6469 {
6470 TLLOGW(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
6471 FL("Failed to Read SNR")));
6472 }
Dino Mycle3b9536d2014-07-09 22:05:24 +05306473#ifdef WLAN_FEATURE_LINK_LAYER_STATS
6474 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
6475 if ( NULL != pClientSTA)
6476 {
6477 pClientSTA->interfaceStats.mgmtRx++;
Dino Mycle3b9536d2014-07-09 22:05:24 +05306478 }
6479#endif
Sravan Kumar Kairame0e78442017-09-18 18:00:53 +05306480
6481 WLANTL_SampleRxRSSI(pTLCb, pvBDHeader, ucSTAId);
6482
Jeff Johnson295189b2012-06-20 16:38:30 -07006483 }
6484
Jeff Johnson295189b2012-06-20 16:38:30 -07006485 pTLCb->tlMgmtFrmClient.pfnTlMgmtFrmRx( pvosGCtx, vosTempBuff);
6486 }
6487 else /* Data Frame */
6488 {
6489 ucSTAId = (v_U8_t)WDA_GET_RX_STAID( pvBDHeader );
6490 ucTid = (v_U8_t)WDA_GET_RX_TID( pvBDHeader );
Sravan Kumar Kairam091e5b62017-01-23 14:14:20 +05306491 uDPUSig = WDA_GET_RX_DPUSIG(pvBDHeader);
Sravan Kumar Kairam2e44dd42017-02-13 18:31:09 +05306492 ucMPDUHLen = (uint8_t)WDA_GET_RX_MPDU_HEADER_LEN(pvBDHeader);
Sravan Kumar Kairam091e5b62017-01-23 14:14:20 +05306493 seq_no = (uint16_t)WDA_GET_RX_REORDER_CUR_PKT_SEQ_NO(pvBDHeader);
Sravan Kumar Kairam04f093a2017-11-16 19:59:05 +05306494 pn_num = WDA_GET_RX_REPLAY_COUNT(pvBDHeader);
6495
6496 vosTempBuff->pn_num = pn_num;
Jeff Johnson295189b2012-06-20 16:38:30 -07006497
6498 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
6499 "WLAN TL:Data packet received for STA %d", ucSTAId));
6500
6501 /*------------------------------------------------------------------
6502 This should be corrected when multipe sta support is added !!!
6503 for now bcast frames will be sent to the last registered STA
6504 ------------------------------------------------------------------*/
6505 if ( WDA_IS_RX_BCAST(pvBDHeader))
6506 {
6507 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
6508 "WLAN TL:TL rx Bcast frame - sending to last registered station"));
6509 broadcast = VOS_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006510 /*-------------------------------------------------------------------
6511 If Addr1 is b/mcast, but Addr3 is our own self MAC, it is a b/mcast
6512 pkt we sent looping back to us. To be dropped if we are non BTAMP
6513 -------------------------------------------------------------------*/
6514 if( WLANHAL_RX_BD_ADDR3_SELF_IDX ==
6515 (v_U8_t)WDA_GET_RX_ADDR3_IDX( pvBDHeader ))
6516 {
6517 selfBcastLoopback = VOS_TRUE;
6518 }
6519 }/*if bcast*/
6520
Sravan Kumar Kairam091e5b62017-01-23 14:14:20 +05306521 /* Pre assoc cache eapol */
6522 if (pTLCb->preassoc_caching)
6523 {
Sravan Kumar Kairam2e44dd42017-02-13 18:31:09 +05306524 WLANTL_GetEtherType(pvBDHeader,vosTempBuff, ucMPDUHLen, &usEtherType);
6525 if (WLANTL_LLC_8021X_TYPE != usEtherType)
6526 {
6527 VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
6528 "%s: RX Frame not EAPOL EtherType %d",
6529 __func__, usEtherType);
6530 vos_pkt_return_packet(vosTempBuff);
6531 }
6532 else
6533 {
6534 WLANTL_CacheEapol(pTLCb, vosTempBuff);
6535 TLLOG1(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
6536 "WLAN TL:TL preassoc_caching is enabled seq No: %d", seq_no));
6537 }
6538
Sravan Kumar Kairam091e5b62017-01-23 14:14:20 +05306539 vosTempBuff = vosDataBuff;
6540 continue;
6541 }
6542
Sravan Kumar Kairam09a5e0b2016-05-03 13:17:42 +05306543 if (WLANTL_STA_ID_INVALID(ucSTAId))
Jeff Johnson295189b2012-06-20 16:38:30 -07006544 {
6545 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
Sravan Kumar Kairam09a5e0b2016-05-03 13:17:42 +05306546 "WLAN TL:STAId %d. Invalid STA ID dropping pkt",
6547 ucSTAId));
Jeff Johnson295189b2012-06-20 16:38:30 -07006548 /* Drop packet */
6549 vos_pkt_return_packet(vosTempBuff);
6550 vosTempBuff = vosDataBuff;
6551 continue;
6552 }
6553
Sravan Kumar Kairam09a5e0b2016-05-03 13:17:42 +05306554 if (WLANTL_TID_INVALID( ucTid)) {
6555 /* There is a possibility AP uses wrong TID. In that case to avoid
6556 dropping EAPOL packet in the driver use TID to zero.*/
6557 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
6558 "WLAN TL:Invalid Tid: %d Frame type: %d", ucTid, ucFrmType);
Paul Zhangda6dd252016-08-11 13:51:49 +08006559 WDA_GET_RX_TID( pvBDHeader ) = 0;
Sravan Kumar Kairam09a5e0b2016-05-03 13:17:42 +05306560 ucTid = 0;
6561 }
6562
jagadeesh99d8e632015-04-27 13:21:24 +05306563#ifdef WLAN_FEATURE_LINK_LAYER_STATS
6564 ac = WLANTL_TID_2_AC[ucTid];
6565#endif
6566
Jeff Johnson295189b2012-06-20 16:38:30 -07006567 /*----------------------------------------------------------------------
6568 No need to lock cache access because cache manipulation only happens
6569 in the transport thread/task context
6570 - These frames are to be forwarded to the station upon registration
6571 which happens in the main thread context
6572 The caching here can happen in either Tx or Rx thread depending
6573 on the current SSC scheduling
6574 - also we need to make sure that the frames in the cache are fwd-ed to
6575 the station before the new incoming ones
6576 -----------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306577 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
6578 if (NULL == pClientSTA)
6579 {
6580 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
6581 "WLAN TL:STA not allocated memory. Dropping packet"));
6582 vos_pkt_return_packet(vosTempBuff);
6583 vosTempBuff = vosDataBuff;
6584 continue;
6585 }
6586
Hoonki Lee5305c3a2013-04-29 23:28:59 -07006587#ifdef FEATURE_WLAN_TDLS
6588 if (( pClientSTA->ucExists ) &&
6589 (WLAN_STA_TDLS == pClientSTA->wSTADesc.wSTAType) &&
6590 (pClientSTA->ucTxSuspended))
6591 vos_atomic_set_U8( &pClientSTA->ucTxSuspended, 0 );
6592 else if ( !broadcast && (pClientSTA->ucExists == 0 ) )
6593 {
6594 tpSirMacMgmtHdr pMacHeader = WDA_GET_RX_MAC_HEADER( pvBDHeader );
6595
6596 /* from the direct peer while it is not registered to TL yet */
6597 if ( (pMacHeader->fc.fromDS == 0) &&
6598 (pMacHeader->fc.toDS == 0) )
6599 {
6600 v_U8_t ucAddr3STAId;
6601
6602 ucAddr3STAId = WDA_GET_RX_ADDR3_IDX(pvBDHeader);
6603
6604 if ( WLANTL_STA_ID_INVALID(ucAddr3STAId) )
6605 {
6606 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
6607 "WLAN TL:STA ID %d invalid - dropping pkt", ucAddr3STAId));
6608 /* Drop packet */
6609 vos_pkt_return_packet(vosTempBuff);
6610 vosTempBuff = vosDataBuff;
6611 continue;
6612 }
6613
6614 if (!(pTLCb->atlSTAClients[ucAddr3STAId] && pTLCb->atlSTAClients[ucAddr3STAId]->ucExists &&
6615 (WLAN_STA_INFRA == pTLCb->atlSTAClients[ucAddr3STAId]->wSTADesc.wSTAType) &&
6616 (WLANTL_STA_AUTHENTICATED == pTLCb->atlSTAClients[ucAddr3STAId]->tlState)))
6617 {
6618 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
Arif Hussainf2b00992013-11-17 21:46:15 -08006619 "%s: staId %d addr3Id %d tlState %d. Unkown Receiver/Transmitter Dropping packet", __func__,
Hoonki Lee5305c3a2013-04-29 23:28:59 -07006620 ucSTAId, ucAddr3STAId, pTLCb->atlSTAClients[ucAddr3STAId]->tlState));
6621 vos_pkt_return_packet(vosTempBuff);
6622 vosTempBuff = vosDataBuff;
6623 continue;
6624 }
6625 else
6626 {
6627 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
Arif Hussainf2b00992013-11-17 21:46:15 -08006628 "%s: staId %d doesn't exist, but mapped to AP staId %d", __func__,
Hoonki Lee5305c3a2013-04-29 23:28:59 -07006629 ucSTAId, ucAddr3STAId));
6630 ucSTAId = ucAddr3STAId;
6631 pClientSTA = pTLCb->atlSTAClients[ucAddr3STAId];
6632 }
6633 }
6634 }
6635#endif
6636
Katya Nigam63902932014-06-26 19:04:23 +05306637 if (( pClientSTA->enableCaching == 1 ) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07006638 /*Dont buffer Broadcast/Multicast frames. If AP transmits bursts of Broadcast/Multicast data frames,
6639 * libra buffers all Broadcast/Multicast packets after authentication with AP,
6640 * So it will lead to low resource condition in Rx Data Path.*/
Katya Nigam63902932014-06-26 19:04:23 +05306641 ( WDA_IS_RX_BCAST(pvBDHeader) == 0 ))
Jeff Johnson295189b2012-06-20 16:38:30 -07006642 {
Katya Nigam6201c3e2014-05-27 17:51:42 +05306643 if( WDA_IsSelfSTA(pvosGCtx,ucSTAId))
6644 {
6645 //drop packet for Self STA index
6646 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
6647 "%s: Packet dropped for Self STA with staId %d ", __func__, ucSTAId ));
6648
6649 vos_pkt_return_packet(vosTempBuff);
6650 vosTempBuff = vosDataBuff;
6651 continue;
6652 }
Sravan Kumar Kairam091e5b62017-01-23 14:14:20 +05306653 /* Station has not yet been registered with TL - cache the frame */
Hoonki Lee5305c3a2013-04-29 23:28:59 -07006654 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
Arif Hussainf2b00992013-11-17 21:46:15 -08006655 "%s: staId %d exist %d tlState %d cache rx frame", __func__, ucSTAId,
Hoonki Lee5305c3a2013-04-29 23:28:59 -07006656 pClientSTA->ucExists, pClientSTA->tlState));
Jeff Johnson295189b2012-06-20 16:38:30 -07006657 WLANTL_CacheSTAFrame( pTLCb, ucSTAId, vosTempBuff, uDPUSig, broadcast, ucFrmType);
6658 vosTempBuff = vosDataBuff;
6659 continue;
6660 }
6661
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08006662#ifdef FEATURE_WLAN_ESE_UPLOAD
6663 if ((pClientSTA->wSTADesc.ucIsEseSta)|| broadcast)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07006664 {
6665 /*--------------------------------------------------------------------
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08006666 Filter the IAPP frames for ESE connection;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07006667 if data it will return false and it
6668 will be routed through the regular data path
6669 --------------------------------------------------------------------*/
6670 if ( WLANTL_IsIAPPFrame(pvBDHeader,
6671 vosTempBuff))
6672 {
6673 bForwardIAPPwithLLC = VOS_TRUE;
6674 }
6675 }
6676#endif
6677
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08006678#if defined(FEATURE_WLAN_ESE) && !defined(FEATURE_WLAN_ESE_UPLOAD)
6679 if ((pClientSTA->wSTADesc.ucIsEseSta)|| broadcast)
Jeff Johnson295189b2012-06-20 16:38:30 -07006680 {
6681 /*--------------------------------------------------------------------
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08006682 Filter the IAPP frames for ESE connection;
Jeff Johnson295189b2012-06-20 16:38:30 -07006683 if data it will return false and it
6684 will be routed through the regular data path
6685 --------------------------------------------------------------------*/
6686 if ( WLANTL_IsIAPPFrame(pvBDHeader,
6687 vosTempBuff))
6688 {
6689 if ( VOS_STATUS_SUCCESS != vos_pkt_flatten_rx_pkt(&vosTempBuff))
6690 {
6691 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6692 "WLAN TL:Cannot flatten packet - dropping"));
6693 /* Drop packet */
6694 vos_pkt_return_packet(vosTempBuff);
6695 } else {
6696
6697 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08006698 "WLAN TL: Received ESE IAPP Frame"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006699
6700 pTLCb->tlMgmtFrmClient.pfnTlMgmtFrmRx( pvosGCtx, vosTempBuff);
6701 }
6702 vosTempBuff = vosDataBuff;
6703 continue;
6704 }
6705 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08006706#endif /* defined(FEATURE_WLAN_ESE) && !defined(FEATURE_WLAN_ESE_UPLOAD) */
Jeff Johnson295189b2012-06-20 16:38:30 -07006707
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306708 if ( WLAN_STA_BT_AMP == pClientSTA->wSTADesc.wSTAType )
Jeff Johnson295189b2012-06-20 16:38:30 -07006709 {
6710 /*--------------------------------------------------------------------
6711 Process the ctrl BAP frame; if data it will return false and it
6712 will be routed through the regular data path
6713 --------------------------------------------------------------------*/
6714 if ( WLANTL_ProcessBAPFrame( pvBDHeader,
6715 vosTempBuff,
6716 pTLCb,
6717 &first_data_pkt_arrived,
6718 ucSTAId))
6719 {
6720 vosTempBuff = vosDataBuff;
6721 continue;
6722 }
6723 }/*if BT-AMP station*/
6724 else if(selfBcastLoopback == VOS_TRUE)
6725 {
6726 /* Drop packet */
6727 vos_pkt_return_packet(vosTempBuff);
6728 vosTempBuff = vosDataBuff;
6729 continue;
6730 }
6731
6732 /*---------------------------------------------------------------------
6733 Data packet received, send to state machine
6734 ---------------------------------------------------------------------*/
6735 wSTAEvent = WLANTL_RX_EVENT;
6736
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306737 pfnSTAFsm = tlSTAFsm[pClientSTA->tlState].
Jeff Johnson295189b2012-06-20 16:38:30 -07006738 pfnSTATbl[wSTAEvent];
6739
6740 if ( NULL != pfnSTAFsm )
6741 {
6742#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
6743 /* Read RSSI and update */
6744 vosStatus = WLANTL_HSHandleRXFrame(pvosGCtx,
6745 WLANTL_DATA_FRAME_TYPE,
6746 pvBDHeader,
6747 ucSTAId,
6748 broadcast,
6749 vosTempBuff);
6750 broadcast = VOS_FALSE;
6751#else
6752 vosStatus = WLANTL_ReadRSSI(pvosGCtx, pvBDHeader, ucSTAId);
Kiet Lam47325522014-03-10 11:50:46 -07006753#endif
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05306754 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
Jeff Johnson295189b2012-06-20 16:38:30 -07006755 {
6756 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
6757 "Handle RX Data Frame fail within Handoff support module"));
6758 /* Do Not Drop packet at here
6759 * Revisit why HO module return fail
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05306760 * vos_pkt_return_packet(vosTempBuff);
6761 * vosTempBuff = vosDataBuff;
6762 * continue;
Jeff Johnson295189b2012-06-20 16:38:30 -07006763 */
6764 }
Dino Mycle3b9536d2014-07-09 22:05:24 +05306765#ifdef WLAN_FEATURE_LINK_LAYER_STATS
6766 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
6767 if ( NULL != pClientSTA)
6768 {
6769 tpSirMacMgmtHdr pMacHeader = WDA_GET_RX_MAC_HEADER( pvBDHeader );
Mahesh A Saptasagarbbdcf122014-10-28 20:57:11 +05306770 if (!IS_BROADCAST_ADD(pMacHeader->da) && IS_MULTICAST_ADD(pMacHeader->da))
Dino Mycle3b9536d2014-07-09 22:05:24 +05306771 {
6772 pClientSTA->interfaceStats.accessCategoryStats[ac].rxMcast++;
6773 }
6774
6775 WLANTL_HSGetDataRSSI(pvosGCtx, pvBDHeader, ucSTAId,
6776 &currentAvgRSSI);
6777 pClientSTA->interfaceStats.rssiData = currentAvgRSSI;
6778
6779 pClientSTA->interfaceStats.accessCategoryStats[ac].rxMpdu++;
6780 if (WDA_IS_RX_AN_AMPDU (pvBDHeader))
6781 {
6782 pClientSTA->interfaceStats.accessCategoryStats[ac].rxAmpdu++;
6783 }
6784 }
6785
6786
6787#endif
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05306788 vosStatus = WLANTL_ReadSNR(pvosGCtx, pvBDHeader, ucSTAId);
6789
6790 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
6791 {
6792 TLLOGW(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
6793 FL("Failed to Read SNR")));
6794 }
6795
Sravan Kumar Kairame0e78442017-09-18 18:00:53 +05306796 WLANTL_SampleRxRSSI(pTLCb, pvBDHeader, ucSTAId);
6797
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07006798 pfnSTAFsm( pvosGCtx, ucSTAId, &vosTempBuff, bForwardIAPPwithLLC);
Jeff Johnson295189b2012-06-20 16:38:30 -07006799 }
6800 else
6801 {
6802 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
6803 "WLAN TL:NULL state function, STA:%d, State: %d- dropping packet",
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306804 ucSTAId, pClientSTA->tlState));
Jeff Johnson295189b2012-06-20 16:38:30 -07006805 /* Drop packet */
6806 vos_pkt_return_packet(vosTempBuff);
6807 vosTempBuff = vosDataBuff;
6808 continue;
6809 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006810 }/* else data frame*/
6811
6812 vosTempBuff = vosDataBuff;
6813 }/*while chain*/
6814
6815 return VOS_STATUS_SUCCESS;
6816}/* WLANTL_RxFrames */
6817
Dino Mycle3b9536d2014-07-09 22:05:24 +05306818#ifdef WLAN_FEATURE_LINK_LAYER_STATS
6819/*==========================================================================
6820
6821 FUNCTION WLANTL_CollectInterfaceStats
6822
6823 DESCRIPTION
6824 Utility function used by TL to send the statitics
6825
6826 DEPENDENCIES
6827
6828
6829 PARAMETERS
6830
6831 IN
6832
6833 ucSTAId: station for which the statistics need to collected
6834
6835 vosDataBuff: it will contain the pointer to the corresponding
6836 structure
6837
6838 RETURN VALUE
6839 The result code associated with performing the operation
6840
6841 VOS_STATUS_E_INVAL: Input parameters are invalid
6842 VOS_STATUS_SUCCESS: Everything is good :)
6843
6844 SIDE EFFECTS
6845
6846============================================================================*/
6847VOS_STATUS
6848WLANTL_CollectInterfaceStats
6849(
6850 v_PVOID_t pvosGCtx,
6851 v_U8_t ucSTAId,
6852 WLANTL_InterfaceStatsType *vosDataBuff
6853)
6854{
6855 WLANTL_CbType* pTLCb = NULL;
6856 /*------------------------------------------------------------------------
6857 Sanity check
6858 ------------------------------------------------------------------------*/
6859 if ( WLANTL_STA_ID_INVALID( ucSTAId ) )
6860 {
6861 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6862 "WLAN TL:Invalid station id requested on WLANTL_CollectStats"));
6863 return VOS_STATUS_E_FAULT;
6864 }
6865 /*------------------------------------------------------------------------
6866 Extract TL control block
6867 ------------------------------------------------------------------------*/
6868 pTLCb = VOS_GET_TL_CB(pvosGCtx);
6869 if ( NULL == pTLCb )
6870 {
6871 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6872 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_CollectStats"));
6873 return VOS_STATUS_E_FAULT;
6874 }
6875
6876 if ( NULL == pTLCb->atlSTAClients[ucSTAId] )
6877 {
6878 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6879 "WLAN TL:Client Memory was not allocated on %s", __func__));
6880 return VOS_STATUS_E_FAILURE;
6881 }
Srinivas Dasari98947432014-11-07 19:41:24 +05306882 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
6883 "WLAN TL: collect WIFI_STATS_IFACE results"));
6884
Dino Mycle3b9536d2014-07-09 22:05:24 +05306885 vos_mem_copy(vosDataBuff, &pTLCb->atlSTAClients[ucSTAId]->interfaceStats,
6886 sizeof(WLANTL_InterfaceStatsType));
6887 return VOS_STATUS_SUCCESS;
6888}
6889
Srinivas Dasari98947432014-11-07 19:41:24 +05306890/*==========================================================================
6891
6892 FUNCTION WLANTL_ClearInterfaceStats
6893
6894 DESCRIPTION
6895 Utility function used by TL to clear the statitics
6896
6897 DEPENDENCIES
6898
6899
6900 PARAMETERS
6901
6902 IN
6903
6904 ucSTAId: station for which the statistics need to collected
6905
6906 RETURN VALUE
6907 The result code associated with performing the operation
6908
6909 VOS_STATUS_E_INVAL: Input parameters are invalid
6910 VOS_STATUS_SUCCESS: Everything is good :)
6911
6912 SIDE EFFECTS
6913
6914============================================================================*/
6915VOS_STATUS
6916WLANTL_ClearInterfaceStats
6917(
6918 v_PVOID_t pvosGCtx,
6919 v_U8_t ucSTAId,
6920 v_U8_t statsClearReqMask
6921)
6922{
6923 WLANTL_CbType* pTLCb = NULL;
6924 WLANTL_STAClientType* pClientSTA = NULL;
6925 /*------------------------------------------------------------------------
6926 Sanity check
6927 ------------------------------------------------------------------------*/
6928 if ( WLANTL_STA_ID_INVALID( ucSTAId ) )
6929 {
6930 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6931 "WLAN TL:Invalid station id requested on WLANTL_CollectStats"));
6932 return VOS_STATUS_E_FAULT;
6933 }
6934 /*------------------------------------------------------------------------
6935 Extract TL control block
6936 ------------------------------------------------------------------------*/
6937 pTLCb = VOS_GET_TL_CB(pvosGCtx);
6938 if ( NULL == pTLCb )
6939 {
6940 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
6941 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_CollectStats"));
6942 return VOS_STATUS_E_FAULT;
6943 }
6944
6945 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
6946 if ( NULL == pClientSTA )
6947 {
6948 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
6949 "WLAN TL:Client Memory was not allocated on %s", __func__));
6950 return VOS_STATUS_E_FAILURE;
6951 }
6952
6953 if ((statsClearReqMask & WIFI_STATS_IFACE_AC) ||
6954 (statsClearReqMask & WIFI_STATS_IFACE)) {
6955 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
6956 "WLAN TL:cleared WIFI_STATS_IFACE_AC results"));
6957 pClientSTA->interfaceStats.accessCategoryStats[0].rxMcast = 0;
6958 pClientSTA->interfaceStats.accessCategoryStats[1].rxMcast = 0;
6959 pClientSTA->interfaceStats.accessCategoryStats[2].rxMcast = 0;
6960 pClientSTA->interfaceStats.accessCategoryStats[3].rxMcast = 0;
6961
6962 pClientSTA->interfaceStats.accessCategoryStats[0].rxMpdu = 0;
6963 pClientSTA->interfaceStats.accessCategoryStats[1].rxMpdu = 0;
6964 pClientSTA->interfaceStats.accessCategoryStats[2].rxMpdu = 0;
6965 pClientSTA->interfaceStats.accessCategoryStats[3].rxMpdu = 0;
6966
6967 pClientSTA->interfaceStats.accessCategoryStats[0].rxAmpdu = 0;
6968 pClientSTA->interfaceStats.accessCategoryStats[1].rxAmpdu = 0;
6969 pClientSTA->interfaceStats.accessCategoryStats[2].rxAmpdu = 0;
6970 pClientSTA->interfaceStats.accessCategoryStats[3].rxAmpdu = 0;
6971 }
6972
6973 if (statsClearReqMask & WIFI_STATS_IFACE) {
6974 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
6975 "WLAN TL:cleared WIFI_STATS_IFACE results"));
6976 pClientSTA->interfaceStats.mgmtRx = 0;
6977 pClientSTA->interfaceStats.rssiData = 0;
6978 return VOS_STATUS_SUCCESS;
6979 }
6980
6981 return VOS_STATUS_SUCCESS;
6982}
6983
Dino Mycle3b9536d2014-07-09 22:05:24 +05306984#endif /* WLAN_FEATURE_LINK_LAYER_STATS */
Jeff Johnson295189b2012-06-20 16:38:30 -07006985
6986/*==========================================================================
6987
6988 FUNCTION WLANTL_RxCachedFrames
6989
6990 DESCRIPTION
6991 Utility function used by TL to forward the cached frames to a particular
6992 station;
6993
6994 DEPENDENCIES
6995 TL must be initiailized before this function gets called.
6996 If the frame carried is a data frame then the station for which it is
6997 destined to must have been previously registered with TL.
6998
6999 PARAMETERS
7000
7001 IN
7002 pTLCb: pointer to TL handle
7003
7004 ucSTAId: station for which we need to forward the packets
7005
7006 vosDataBuff: it will contain a pointer to the first cached buffer
7007 received, if there is more then one packet they will be
7008 chained using vOSS buffers.
7009
7010 RETURN VALUE
7011 The result code associated with performing the operation
7012
7013 VOS_STATUS_E_INVAL: Input parameters are invalid
7014 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
7015 page fault
7016 VOS_STATUS_SUCCESS: Everything is good :)
7017
7018 SIDE EFFECTS
7019
7020============================================================================*/
7021VOS_STATUS
7022WLANTL_RxCachedFrames
7023(
7024 WLANTL_CbType* pTLCb,
7025 v_U8_t ucSTAId,
7026 vos_pkt_t* vosDataBuff
7027)
7028{
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307029 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07007030 WLANTL_STAFuncType pfnSTAFsm;
7031 vos_pkt_t* vosTempBuff;
7032 VOS_STATUS vosStatus;
7033 v_PVOID_t pvBDHeader = NULL;
7034 WLANTL_STAEventType wSTAEvent = WLANTL_RX_EVENT;
7035 v_U8_t ucTid = 0;
7036 v_BOOL_t broadcast = VOS_FALSE;
7037 v_BOOL_t bSigMatch = VOS_FALSE;
7038 v_BOOL_t selfBcastLoopback = VOS_FALSE;
Madan Mohan Koyyalamudidfd6aa82012-10-18 20:18:43 -07007039 static v_U8_t first_data_pkt_arrived;
Jeff Johnson295189b2012-06-20 16:38:30 -07007040 v_U32_t uDPUSig;
7041 v_U8_t ucUcastSig;
7042 v_U8_t ucBcastSig;
7043 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
7044
7045 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
7046 "WLAN TL:TL Receive Cached Frames called"));
7047
7048 /*------------------------------------------------------------------------
7049 Sanity check
7050 ------------------------------------------------------------------------*/
7051 if ( NULL == vosDataBuff )
7052 {
7053 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7054 "WLAN TL:Invalid parameter sent on WLANTL_RxFrames"));
7055 return VOS_STATUS_E_INVAL;
7056 }
7057
Mihir Sheteae6f02b2014-04-11 19:49:21 +05307058 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
7059
7060 if ( NULL == pClientSTA )
7061 {
7062 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7063 "WLAN TL:Client Memory was not allocated on %s", __func__));
7064 return VOS_STATUS_E_FAILURE;
7065 }
7066
7067 MTRACE(vos_trace(VOS_MODULE_ID_TL, TRACE_CODE_TL_FORWARD_CACHED_FRAMES,
7068 ucSTAId, 1<<16 | pClientSTA->tlCacheInfo.cacheSize));
7069
Jeff Johnson295189b2012-06-20 16:38:30 -07007070 /*---------------------------------------------------------------------
7071 Save the initial buffer - this is the first received buffer
7072 ---------------------------------------------------------------------*/
7073 vosTempBuff = vosDataBuff;
7074
7075 while ( NULL != vosTempBuff )
7076 {
Madan Mohan Koyyalamudia148e1e2012-11-30 14:52:59 -08007077 broadcast = VOS_FALSE;
7078 selfBcastLoopback = VOS_FALSE;
7079
Jeff Johnson295189b2012-06-20 16:38:30 -07007080 vos_pkt_walk_packet_chain( vosDataBuff, &vosDataBuff, 1/*true*/ );
7081
7082 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
7083 "WLAN TL:Sending new cached packet to station %d", ucSTAId));
7084 /*---------------------------------------------------------------------
7085 Peek at BD header - do not remove
7086 !!! Optimize me: only part of header is needed; not entire one
7087 ---------------------------------------------------------------------*/
7088 vosStatus = WDA_DS_PeekRxPacketInfo( vosTempBuff, (v_PVOID_t)&pvBDHeader, 0 );
7089
7090 if ( NULL == pvBDHeader )
7091 {
7092 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7093 "WLAN TL:Cannot extract BD header"));
7094 /* Drop packet */
7095 vos_pkt_return_packet(vosTempBuff);
7096 vosTempBuff = vosDataBuff;
7097 continue;
7098 }
7099
7100 uDPUSig = WDA_GET_RX_DPUSIG( pvBDHeader );
7101
7102 /* AMSDU HW bug fix
7103 * After 2nd AMSDU subframe HW could not handle BD correctly
7104 * HAL workaround is needed */
7105 if(WDA_GET_RX_ASF(pvBDHeader))
7106 {
7107 WDA_DS_RxAmsduBdFix(vos_get_global_context(VOS_MODULE_ID_TL,pTLCb),
7108 pvBDHeader);
7109 }
7110
7111 ucTid = (v_U8_t)WDA_GET_RX_TID( pvBDHeader );
7112
7113 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
7114 "WLAN TL:Data packet cached for STA %d", ucSTAId);
7115
7116 /*------------------------------------------------------------------
7117 This should be corrected when multipe sta support is added !!!
7118 for now bcast frames will be sent to the last registered STA
7119 ------------------------------------------------------------------*/
7120 if ( WDA_IS_RX_BCAST(pvBDHeader))
7121 {
7122 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
7123 "WLAN TL:TL rx Bcast frame "));
7124 broadcast = VOS_TRUE;
7125
7126 /* If Addr1 is b/mcast, but Addr3 is our own self MAC, it is a b/mcast
7127 * pkt we sent looping back to us. To be dropped if we are non BTAMP
7128 */
7129 if( WLANHAL_RX_BD_ADDR3_SELF_IDX ==
7130 (v_U8_t)WDA_GET_RX_ADDR3_IDX( pvBDHeader ))
7131 {
7132 selfBcastLoopback = VOS_TRUE;
7133 }
7134 }/*if bcast*/
7135
7136 /*-------------------------------------------------------------------------
7137 Check if the packet that we cached matches the DPU signature of the
7138 newly added station
7139 -------------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307140 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
7141
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307142 if ( NULL == pClientSTA )
7143 {
7144 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7145 "WLAN TL:Client Memory was not allocated on %s", __func__));
7146 return VOS_STATUS_E_FAILURE;
7147 }
7148
Jeff Johnson295189b2012-06-20 16:38:30 -07007149 if ( broadcast )
7150 {
7151 ucBcastSig = (v_U8_t)uDPUSig;
7152 bSigMatch = (( WLAN_TL_INVALID_B_SIG !=
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307153 pClientSTA->wSTADesc.ucBcastSig ) &&
7154 ( ucBcastSig == pClientSTA->wSTADesc.ucBcastSig ));
Jeff Johnson295189b2012-06-20 16:38:30 -07007155 }
7156 else
7157 {
7158 ucUcastSig = (v_U8_t)uDPUSig;
7159 bSigMatch = (( WLAN_TL_INVALID_U_SIG !=
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307160 pClientSTA->wSTADesc.ucUcastSig ) &&
7161 ( ucUcastSig == pClientSTA->wSTADesc.ucUcastSig ));
Jeff Johnson295189b2012-06-20 16:38:30 -07007162 }
7163
7164 /*-------------------------------------------------------------------------
7165 If the packet doesn't match - drop it
7166 -------------------------------------------------------------------------*/
7167 if ( !bSigMatch )
7168 {
Rajesh Chauhana6b08f42013-06-18 19:01:26 -07007169 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_MED,
Jeff Johnson295189b2012-06-20 16:38:30 -07007170 "WLAN TL: Cached packet does not match DPU Sig of the new STA - drop "
7171 " DPU Sig %d UC %d BC %d B %d",
7172 uDPUSig,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307173 pClientSTA->wSTADesc.ucUcastSig,
Rajesh Chauhana6b08f42013-06-18 19:01:26 -07007174 pClientSTA->wSTADesc.ucBcastSig,
Jeff Johnson295189b2012-06-20 16:38:30 -07007175 broadcast));
7176
7177 /* Drop packet */
7178 vos_pkt_return_packet(vosTempBuff);
7179 vosTempBuff = vosDataBuff;
7180 continue;
7181
7182 }/*if signature mismatch*/
7183
7184 /*------------------------------------------------------------------------
7185 Check if BT-AMP frame:
7186 - additional processing needed in this case to separate BT-AMP date
7187 from BT-AMP Ctrl path
7188 ------------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307189 if ( WLAN_STA_BT_AMP == pClientSTA->wSTADesc.wSTAType )
Jeff Johnson295189b2012-06-20 16:38:30 -07007190 {
7191 /*--------------------------------------------------------------------
7192 Process the ctrl BAP frame; if data it will return false and it
7193 will be routed through the regular data path
7194 --------------------------------------------------------------------*/
7195 if ( WLANTL_ProcessBAPFrame( pvBDHeader,
7196 vosTempBuff,
7197 pTLCb,
7198 &first_data_pkt_arrived,
7199 ucSTAId))
7200 {
7201 vosTempBuff = vosDataBuff;
7202 continue;
7203 }
7204 }/*if BT-AMP station*/
7205 else if(selfBcastLoopback == VOS_TRUE)
7206 {
7207 /* Drop packet */
7208 vos_pkt_return_packet(vosTempBuff);
7209 vosTempBuff = vosDataBuff;
7210 continue;
7211 }
7212
7213 /*---------------------------------------------------------------------
7214 Data packet received, send to state machine
7215 ---------------------------------------------------------------------*/
7216 wSTAEvent = WLANTL_RX_EVENT;
7217
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307218 pfnSTAFsm = tlSTAFsm[pClientSTA->tlState].
Jeff Johnson295189b2012-06-20 16:38:30 -07007219 pfnSTATbl[wSTAEvent];
7220
7221 if ( NULL != pfnSTAFsm )
7222 {
7223#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
7224 /* Read RSSI and update */
7225 vosStatus = WLANTL_HSHandleRXFrame(vos_get_global_context(
7226 VOS_MODULE_ID_TL,pTLCb),
7227 WLANTL_DATA_FRAME_TYPE,
7228 pvBDHeader,
7229 ucSTAId,
7230 broadcast,
7231 vosTempBuff);
7232 broadcast = VOS_FALSE;
7233#else
7234 vosStatus = WLANTL_ReadRSSI(vos_get_global_context(VOS_MODULE_ID_TL,pTLCb), pvBDHeader, ucSTAId);
Kiet Lam47325522014-03-10 11:50:46 -07007235#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007236 if(!VOS_IS_STATUS_SUCCESS(vosStatus))
7237 {
7238 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7239 "Handle RX Data Frame fail within Handoff support module"));
7240 /* Do Not Drop packet at here
7241 * Revisit why HO module return fail
7242 vos_pkt_return_packet(vosTempBuff);
7243 vosTempBuff = vosDataBuff;
7244 continue;
7245 */
7246 }
7247 pfnSTAFsm( vos_get_global_context(VOS_MODULE_ID_TL,pTLCb), ucSTAId,
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07007248 &vosTempBuff, VOS_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07007249 }
7250 else
7251 {
7252 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7253 "WLAN TL:NULL state function, STA:%d, State: %d- dropping packet",
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307254 ucSTAId, pClientSTA->tlState));
Jeff Johnson295189b2012-06-20 16:38:30 -07007255 /* Drop packet */
7256 vos_pkt_return_packet(vosTempBuff);
7257 vosTempBuff = vosDataBuff;
7258 continue;
7259 }
7260
7261 vosTempBuff = vosDataBuff;
7262 }/*while chain*/
7263
7264 return VOS_STATUS_SUCCESS;
7265}/* WLANTL_RxCachedFrames */
7266
Sravan Kumar Kairam091e5b62017-01-23 14:14:20 +05307267/**
7268 * WLANTL_ForwardPkts() - forward cached eapol frames
7269 * @pvosGCtx: pointer to vos global context
7270 * @data: value to indicate either forward or flush
7271 *
7272 * Return: None
7273 *
7274 */
7275static VOS_STATUS WLANTL_ForwardPkts(void* pvosGCtx, uint32_t data)
7276{
7277 WLANTL_CbType* pTLCb = NULL;
7278
7279 pTLCb = VOS_GET_TL_CB(pvosGCtx);
7280 if (NULL == pTLCb) {
7281 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7282 "%s: Invalid input pointer", __func__));
7283 return VOS_STATUS_E_FAULT;
7284 }
7285
7286 if (!data) {
7287 TLLOG2(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
7288 "%s: Pre assoc fail flush cache", __func__));
7289 WLANTL_FlushCachedFrames(pTLCb->vosEapolCachedFrame);
7290 goto done;
7291 }
7292
7293 /* forward packets to HDD */
7294 if (NULL != pTLCb->vosEapolCachedFrame) {
7295 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
7296 "%s: forward pre assoc cached frames", __func__));
7297 WLANTL_MonTranslate80211To8023Header(pTLCb->vosEapolCachedFrame, pTLCb);
7298 pTLCb->pfnEapolFwd(pvosGCtx, pTLCb->vosEapolCachedFrame);
7299 }
7300
7301done:
7302 pTLCb->vosEapolCachedFrame = NULL;
7303 pTLCb->preassoc_caching = false;
7304
7305 return VOS_STATUS_SUCCESS;
7306}
7307
Jeff Johnson295189b2012-06-20 16:38:30 -07007308/*==========================================================================
Katya Nigam664f5032014-05-05 12:24:32 +05307309 FUNCTION WLANTL_RxProcessMsg
7310
7311 DESCRIPTION
7312 Called by VOSS when a message was serialized for TL through the
7313 rx thread/task.
7314
7315 DEPENDENCIES
7316 The TL must be initialized before this function can be called.
7317
7318 PARAMETERS
7319
7320 IN
7321 pvosGCtx: pointer to the global vos context; a handle to TL's
7322 control block can be extracted from its context
7323 message: type and content of the message
7324
7325
7326 RETURN VALUE
7327 The result code associated with performing the operation
7328
7329 VOS_STATUS_E_INVAL: invalid input parameters
7330 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
7331 page fault
7332 VOS_STATUS_SUCCESS: Everything is good :)
7333
7334 Other values can be returned as a result of a function call, please check
7335 corresponding API for more info.
7336 SIDE EFFECTS
7337
7338============================================================================*/
7339VOS_STATUS
7340WLANTL_RxProcessMsg
7341(
7342 v_PVOID_t pvosGCtx,
7343 vos_msg_t* message
7344)
7345{
7346 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
7347 v_U32_t uData;
7348 v_U8_t ucSTAId;
7349 v_U8_t ucUcastSig;
7350 v_U8_t ucBcastSig;
7351
7352 /*------------------------------------------------------------------------
7353 Sanity check
7354 ------------------------------------------------------------------------*/
7355 if ( NULL == message )
7356 {
7357 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7358 "WLAN TL:Invalid parameter sent on WLANTL_RxProcessMessage"));
7359 return VOS_STATUS_E_INVAL;
7360 }
7361
7362 /*------------------------------------------------------------------------
7363 Process message
7364 ------------------------------------------------------------------------*/
7365 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
7366 "WLAN TL:Received message: %d through rx flow", message->type));
7367
7368 switch( message->type )
7369 {
7370
7371 case WLANTL_RX_FWD_CACHED:
7372 /*---------------------------------------------------------------------
7373 The data sent with the message has the following structure:
7374 | 00 | ucBcastSignature | ucUcastSignature | ucSTAID |
7375 each field above is one byte
7376 ---------------------------------------------------------------------*/
7377 uData = message->bodyval;
7378 ucSTAId = ( uData & 0x000000FF);
7379 ucUcastSig = ( uData & 0x0000FF00)>>8;
7380 ucBcastSig = (v_U8_t)(( uData & 0x00FF0000)>>16);
7381 vosStatus = WLANTL_ForwardSTAFrames( pvosGCtx, ucSTAId,
7382 ucUcastSig, ucBcastSig);
7383 break;
7384
Sravan Kumar Kairam091e5b62017-01-23 14:14:20 +05307385 case WLANTL_RX_FWD_PRE_ASSOC_CACHED:
7386 uData = message->bodyval;
7387 vosStatus = WLANTL_ForwardPkts(pvosGCtx, uData);
7388 break;
7389
Katya Nigam664f5032014-05-05 12:24:32 +05307390 default:
7391 /*no processing for now*/
7392 break;
7393 }
7394
7395 return VOS_STATUS_SUCCESS;
7396}
7397
7398
7399/*==========================================================================
Jeff Johnson295189b2012-06-20 16:38:30 -07007400 FUNCTION WLANTL_ResourceCB
7401
7402 DESCRIPTION
7403 Called by the TL when it has packets available for transmission.
7404
7405 DEPENDENCIES
7406 The TL must be registered with BAL before this function can be called.
7407
7408 PARAMETERS
7409
7410 IN
7411 pvosGCtx: pointer to the global vos context; a handle to TL's
7412 or BAL's control block can be extracted from its context
7413
7414 RETURN VALUE
7415 The result code associated with performing the operation
7416
7417 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
7418 page fault
7419 VOS_STATUS_SUCCESS: Everything is good :)
7420
7421 SIDE EFFECTS
7422
7423============================================================================*/
7424VOS_STATUS
7425WLANTL_ResourceCB
7426(
7427 v_PVOID_t pvosGCtx,
7428 v_U32_t uCount
7429)
7430{
7431 WLANTL_CbType* pTLCb = NULL;
7432 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
7433
7434 /*------------------------------------------------------------------------
7435 Sanity check
7436 Extract TL control block
7437 ------------------------------------------------------------------------*/
7438 pTLCb = VOS_GET_TL_CB(pvosGCtx);
7439 if ( NULL == pTLCb )
7440 {
7441 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7442 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_ChangeSTAState"));
7443 return VOS_STATUS_E_FAULT;
7444 }
7445
7446 pTLCb->uResCount = uCount;
7447
7448
7449 /*-----------------------------------------------------------------------
7450 Resume Tx if enough res and not suspended
7451 -----------------------------------------------------------------------*/
7452 if (( pTLCb->uResCount >= WDA_TLI_MIN_RES_MF ) &&
7453 ( 0 == pTLCb->ucTxSuspended ))
7454 {
7455 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
7456 "WLAN TL:Issuing Xmit start request to BAL for avail res ASYNC"));
7457 return WDA_DS_StartXmit(pvosGCtx);
7458 }
7459
7460 return VOS_STATUS_SUCCESS;
7461}/* WLANTL_ResourceCB */
7462
7463
Gopichand Nakkala11acd112012-12-31 16:04:04 -08007464/*==========================================================================
7465 FUNCTION WLANTL_IsTxXmitPending
7466
7467 DESCRIPTION
7468 Called by the WDA when it wants to know whether WDA_DS_TX_START_XMIT msg
7469 is pending in TL msg queue
7470
7471 DEPENDENCIES
7472 The TL must be registered with WDA before this function can be called.
7473
7474 PARAMETERS
7475
7476 IN
7477 pvosGCtx: pointer to the global vos context; a handle to TL's
7478 or WDA's control block can be extracted from its context
7479
7480 RETURN VALUE
7481 The result code associated with performing the operation
7482
7483 0: No WDA_DS_TX_START_XMIT msg pending
7484 1: Msg WDA_DS_TX_START_XMIT already pending in TL msg queue
7485
7486 SIDE EFFECTS
7487
7488============================================================================*/
7489v_BOOL_t
7490WLANTL_IsTxXmitPending
7491(
7492 v_PVOID_t pvosGCtx
7493)
7494{
7495
7496 WLANTL_CbType* pTLCb = NULL;
7497 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
7498
7499 /*------------------------------------------------------------------------
7500 Sanity check
7501 Extract TL control block
7502 ------------------------------------------------------------------------*/
7503 pTLCb = VOS_GET_TL_CB(pvosGCtx);
7504 if ( NULL == pTLCb )
7505 {
7506 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_FATAL,
7507 "WLAN TL:Invalid TL pointer from pvosGCtx in WLANTL_IsTxXmitPending "));
7508 return FALSE;
7509 }
7510
7511 return pTLCb->isTxTranmitMsgPending;
7512
7513}/*WLANTL_IsTxXmitPending */
7514
7515/*==========================================================================
7516 FUNCTION WLANTL_SetTxXmitPending
7517
7518 DESCRIPTION
7519 Called by the WDA when it wants to indicate that WDA_DS_TX_START_XMIT msg
7520 is pending in TL msg queue
7521
7522 DEPENDENCIES
7523 The TL must be registered with WDA before this function can be called.
7524
7525 PARAMETERS
7526
7527 IN
7528 pvosGCtx: pointer to the global vos context; a handle to TL's
7529 or WDA's control block can be extracted from its context
7530
7531 RETURN VALUE None
7532
7533 SIDE EFFECTS
7534
7535============================================================================*/
7536
7537v_VOID_t
7538WLANTL_SetTxXmitPending
7539(
7540 v_PVOID_t pvosGCtx
7541)
7542{
7543
7544 WLANTL_CbType* pTLCb = NULL;
7545 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
7546
7547 /*------------------------------------------------------------------------
7548 Sanity check
7549 Extract TL control block
7550 ------------------------------------------------------------------------*/
7551 pTLCb = VOS_GET_TL_CB(pvosGCtx);
7552 if ( NULL == pTLCb )
7553 {
7554 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_FATAL,
7555 "WLAN TL:Invalid TL pointer from pvosGCtx in WLANTL_SetTxXmitPending"));
7556 return;
7557 }
7558
7559 pTLCb->isTxTranmitMsgPending = 1;
7560 return;
7561
7562}/*WLANTL_SetTxXmitPending */
7563
7564/*==========================================================================
7565 FUNCTION WLANTL_ClearTxXmitPending
7566
7567 DESCRIPTION
7568 Called by the WDA when it wants to indicate that no WDA_DS_TX_START_XMIT msg
7569 is pending in TL msg queue
7570
7571 DEPENDENCIES
7572 The TL must be registered with WDA before this function can be called.
7573
7574 PARAMETERS
7575
7576 IN
7577 pvosGCtx: pointer to the global vos context; a handle to TL's
7578 or WDA's control block can be extracted from its context
7579
7580 RETURN VALUE None
7581
7582 SIDE EFFECTS
7583
7584============================================================================*/
7585
7586v_VOID_t
7587WLANTL_ClearTxXmitPending
7588(
7589 v_PVOID_t pvosGCtx
7590)
7591{
7592
7593 WLANTL_CbType* pTLCb = NULL;
7594 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
7595
7596 /*------------------------------------------------------------------------
7597 Sanity check
7598 Extract TL control block
7599 ------------------------------------------------------------------------*/
7600 pTLCb = VOS_GET_TL_CB(pvosGCtx);
7601 if ( NULL == pTLCb )
7602 {
7603 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_FATAL,
7604 "WLAN TL:Invalid TL pointer from pvosGCtx in WLANTL_ClearTxXmitPending "));
7605 return;
7606 }
7607
7608 pTLCb->isTxTranmitMsgPending = 0;
7609 return;
7610}/*WLANTL_ClearTxXmitPending */
7611
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307612/*==========================================================================
7613 FUNCTION WLANTL_TxThreadDebugHandler
7614
7615 DESCRIPTION
7616 Printing TL Snapshot dump, processed under TxThread context, currently
7617 information regarding the global TlCb struture. Dumps information related
7618 to per active STA connection currently in use by TL.
7619
7620 DEPENDENCIES
7621 The TL must be initialized before this gets called.
7622
7623 PARAMETERS
7624
7625 IN
7626 pvosGCtx: pointer to the global vos context; a handle to TL's
7627 or WDA's control block can be extracted from its context
7628
7629 RETURN VALUE None
7630
7631 SIDE EFFECTS
7632
7633============================================================================*/
7634
7635v_VOID_t
7636WLANTL_TxThreadDebugHandler
7637(
7638 v_PVOID_t *pVosContext
7639)
7640{
7641 WLANTL_CbType* pTLCb = NULL;
7642 WLANTL_STAClientType* pClientSTA = NULL;
7643 int i = 0;
Mihir Shete5d148f12014-12-16 17:54:49 +05307644 v_U8_t uFlowMask; // TX FlowMask from WDA
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307645
7646 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_FATAL,
7647 "WLAN TL: %s Enter ", __func__));
7648
7649 pTLCb = VOS_GET_TL_CB(pVosContext);
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307650
7651 if ( NULL == pVosContext || NULL == pTLCb )
7652 {
7653 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7654 "Global VoS Context or TL Context are NULL"));
7655 return;
7656 }
7657
Mihir Shete5d148f12014-12-16 17:54:49 +05307658 if (VOS_STATUS_SUCCESS == WDA_DS_GetTxFlowMask(pVosContext, &uFlowMask))
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307659 {
7660 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Mihir Shete5d148f12014-12-16 17:54:49 +05307661 "WDA uTxFlowMask: 0x%x", uFlowMask));
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307662 }
Mihir Shete5d148f12014-12-16 17:54:49 +05307663
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307664 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7665 "************************TL DUMP INFORMATION**************"));
7666
7667 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7668 "uDelayedTriggerFrmInt:%d\tuMinFramesProcThres:%d",
7669 pTLCb->tlConfigInfo.uDelayedTriggerFrmInt,
7670 pTLCb->tlConfigInfo.uMinFramesProcThres));
7671
7672 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7673 "Management Frame Client exists: %d",
7674 pTLCb->tlMgmtFrmClient.ucExists));
7675 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7676 "usPendingTxCompleteCount: %d\tucTxSuspended: %d",
7677 pTLCb->usPendingTxCompleteCount,
7678 pTLCb->ucTxSuspended));
7679
7680 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7681 "uResCount: %d", pTLCb->uResCount));
7682
7683 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7684 "ucRegisteredStaId: %d\tucCurrentSTA: %d",
7685 pTLCb->ucRegisteredStaId, pTLCb->ucCurrentSTA));
7686
7687 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7688 "UrgentFrameProcessing: %s\tuFramesProcThres: %d",
7689 (pTLCb->bUrgent?"True":"False"), pTLCb->uFramesProcThres));
7690
7691 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7692 "isTxTranmitMsgPending: %d\t isBMPS: %s",
7693 pTLCb->isTxTranmitMsgPending, pTLCb->isBMPS?"True":"False"));
7694
7695#ifdef FEATURE_WLAN_TDLS
7696 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7697 "TDLS Peer Count: %d", pTLCb->ucTdlsPeerCount));
7698#endif
7699
Mukul Sharma252582d2015-10-23 16:47:36 +05307700 TLLOG1(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307701 "++++++++++++++++++++Registerd Client Information++++++++++"));
7702
7703 for ( i =0; i<WLAN_MAX_STA_COUNT; i++ )
7704 {
7705 pClientSTA = pTLCb->atlSTAClients[i];
7706 if( NULL == pClientSTA || 0 == pClientSTA->ucExists)
7707 {
7708 continue;
7709 }
7710
Mukul Sharma252582d2015-10-23 16:47:36 +05307711 TLLOG1(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307712 "######################STA Index: %d ############################",i));
Mukul Sharma252582d2015-10-23 16:47:36 +05307713 TLLOG1(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO, "WLAN_STADescType:"));
7714 TLLOG1(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307715 "STAId: %d\t STA MAC Address: %pM", pClientSTA->wSTADesc.ucSTAId,
7716 pClientSTA->wSTADesc.vSTAMACAddress.bytes));
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 "STA Type: %d\tProtectedFrame: %d",
7719 pClientSTA->wSTADesc.wSTAType, pClientSTA->wSTADesc.ucProtectedFrame));
Mukul Sharma252582d2015-10-23 16:47:36 +05307720 TLLOG1(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307721 "QoS: %d\tRxFrameTrans: %d\tTxFrameTrans: %d",
7722 pClientSTA->wSTADesc.ucQosEnabled, pClientSTA->wSTADesc.ucSwFrameRXXlation,
7723 pClientSTA->wSTADesc.ucSwFrameTXXlation));
Mukul Sharma252582d2015-10-23 16:47:36 +05307724 TLLOG1(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307725 "ucUcastSig: %d\tucBcastSig: %d", pClientSTA->wSTADesc.ucUcastSig,
7726 pClientSTA->wSTADesc.ucBcastSig));
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 "ClientIndex: %d\t Exists: %d", i, pClientSTA->ucExists));
Mukul Sharma252582d2015-10-23 16:47:36 +05307730 TLLOG1(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307731 "TL State: %d\t TL Priority: %d", pClientSTA->tlState,
7732 pClientSTA->tlPri));
Mukul Sharma252582d2015-10-23 16:47:36 +05307733 TLLOG1(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307734 "ucTxSuspended: %d\tucPktPending: %d", pClientSTA->ucTxSuspended,
7735 pClientSTA->ucPktPending));
Mukul Sharma252582d2015-10-23 16:47:36 +05307736 TLLOG1(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307737 "ucEAPOLPktPending: %d\tucNoMoreData: %d",
7738 pClientSTA->ucEapolPktPending, pClientSTA->ucNoMoreData));
Mukul Sharma252582d2015-10-23 16:47:36 +05307739 TLLOG1(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Katya Nigam63902932014-06-26 19:04:23 +05307740 "enableCaching: %d\t fcStaTxDisabled: %d", pClientSTA->enableCaching,
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307741 pClientSTA->fcStaTxDisabled));
Mukul Sharma252582d2015-10-23 16:47:36 +05307742 TLLOG1(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307743 "ucCurrentAC: %d\tucServicedAC: %d", pClientSTA->ucCurrentAC,
7744 pClientSTA->ucServicedAC));
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 "TID: %d\tautTxCount[0]: %d\tauRxCount[0]: %d",0, pClientSTA->auTxCount[0],
7747 pClientSTA->auRxCount[0]));
Mukul Sharma252582d2015-10-23 16:47:36 +05307748 TLLOG1(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307749 "aucAcMask[0]: %d\taucAcMask[1]: %d\taucAcMask[2]: %d\taucAcMask[3]: %d\t",
7750 pClientSTA->aucACMask[0], pClientSTA->aucACMask[1],
7751 pClientSTA->aucACMask[2], pClientSTA->aucACMask[3]));
7752 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Mukul Sharma252582d2015-10-23 16:47:36 +05307753
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307754 "ucCurrentWeight: %d", pClientSTA->ucCurrentWeight));
7755
7756 if( WLAN_STA_SOFTAP == pClientSTA->wSTADesc.wSTAType)
7757 {
mukul sharma2cdb8ea2015-10-01 14:53:38 +05307758 TLLOG1(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307759 "TrafficStatistics for SOFTAP Station:"));
mukul sharma2cdb8ea2015-10-01 14:53:38 +05307760 TLLOG1(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307761 "RUF=%d\tRMF=%d\tRBF=%d", pClientSTA->trafficStatistics.rxUCFcnt,
7762 pClientSTA->trafficStatistics.rxMCFcnt,
7763 pClientSTA->trafficStatistics.rxBCFcnt));
mukul sharma2cdb8ea2015-10-01 14:53:38 +05307764 TLLOG1(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307765 "RUB=%d\tRMB=%d\tRBB=%d", pClientSTA->trafficStatistics.rxUCBcnt,
7766 pClientSTA->trafficStatistics.rxMCBcnt,
7767 pClientSTA->trafficStatistics.rxBCBcnt));
mukul sharma2cdb8ea2015-10-01 14:53:38 +05307768 TLLOG1(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307769 "TUF=%d\tTMF=%d\tTBF=%d", pClientSTA->trafficStatistics.txUCFcnt,
7770 pClientSTA->trafficStatistics.txMCFcnt,
7771 pClientSTA->trafficStatistics.txBCFcnt));
mukul sharma2cdb8ea2015-10-01 14:53:38 +05307772 TLLOG1(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307773 "TUB=%d\tTMB=%d\tTBB=%d", pClientSTA->trafficStatistics.txUCBcnt,
7774 pClientSTA->trafficStatistics.txMCBcnt,
7775 pClientSTA->trafficStatistics.txBCBcnt));
7776 }
mukul sharma2cdb8ea2015-10-01 14:53:38 +05307777
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307778 }
7779 return;
7780}
7781
7782/*==========================================================================
Mihir Shetefd62d9d2014-08-06 15:08:21 +05307783 FUNCTION WLANTL_FatalErrorHandler
7784
7785 DESCRIPTION
7786 Handle Fatal errors detected on the TX path.
7787 Currently issues SSR to recover from the error.
7788
7789 DEPENDENCIES
7790 The TL must be initialized before this gets called.
7791
7792 PARAMETERS
7793
7794 IN
7795 pvosGCtx: pointer to the global vos context; a handle to TL's
7796 or WDA's control block can be extracted from its context
7797
7798 RETURN VALUE None
7799
7800 SIDE EFFECTS
7801
7802============================================================================*/
7803v_VOID_t
7804WLANTL_FatalErrorHandler
7805(
7806 v_PVOID_t *pVosContext
7807)
7808{
7809
7810 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_FATAL,
7811 "WLAN TL: %s Enter ", __func__));
7812
7813 if ( NULL == pVosContext )
7814 {
7815 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7816 "%s: Global VoS Context or TL Context are NULL",
7817 __func__));
7818 return;
7819 }
7820
7821 /*
7822 * Issue SSR. vos_wlanRestart has tight checks to make sure that
7823 * we do not send an FIQ if previous FIQ is not processed
7824 */
Anurag Chouhanf0d0ba12018-02-09 15:13:43 +05307825 vos_wlanRestart(VOS_REASON_UNSPECIFIED);
Mihir Shetefd62d9d2014-08-06 15:08:21 +05307826}
7827
7828/*==========================================================================
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307829 FUNCTION WLANTL_TLDebugMessage
7830
7831 DESCRIPTION
7832 Post a TL Snapshot request, posts message in TxThread.
7833
7834 DEPENDENCIES
7835 The TL must be initialized before this gets called.
7836
7837 PARAMETERS
7838
7839 IN
7840 displaySnapshot Boolean showing whether to dump the snapshot or not.
7841
7842 RETURN VALUE None
7843
7844 SIDE EFFECTS
7845
7846============================================================================*/
7847
7848v_VOID_t
7849WLANTL_TLDebugMessage
7850(
Mihir Shete327c2ab2014-11-13 15:17:02 +05307851 v_U32_t debugFlags
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307852)
7853{
7854 vos_msg_t vosMsg;
7855 VOS_STATUS status;
7856
Mihir Shete327c2ab2014-11-13 15:17:02 +05307857 if(debugFlags & WLANTL_DEBUG_TX_SNAPSHOT)
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307858 {
7859 vosMsg.reserved = 0;
7860 vosMsg.bodyptr = NULL;
7861 vosMsg.type = WLANTL_TX_SNAPSHOT;
7862
7863 status = vos_tx_mq_serialize( VOS_MODULE_ID_TL, &vosMsg);
7864 if(status != VOS_STATUS_SUCCESS)
7865 {
7866 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR, "TX Msg Posting Failed with status: %d",status));
7867 return;
7868 }
7869 }
Mihir Shete327c2ab2014-11-13 15:17:02 +05307870 if (debugFlags & WLANTL_DEBUG_FW_CLEANUP)
7871 {
7872 vosMsg.reserved = 0;
7873 vosMsg.bodyptr = NULL;
7874 vosMsg.type = WLANTL_TX_FW_DEBUG;
7875
7876 status = vos_tx_mq_serialize( VOS_MODULE_ID_TL, &vosMsg);
7877 if(status != VOS_STATUS_SUCCESS)
7878 {
7879 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR, "TX Msg Posting Failed with status: %d",status));
7880 return;
7881 }
7882 }
Sravan Kumar Kairame9d186c2015-11-27 23:37:02 +05307883 if(debugFlags & WLANTL_DEBUG_KICKDXE)
7884 {
7885 vosMsg.reserved = 0;
7886 vosMsg.bodyptr = NULL;
7887 vosMsg.type = WLANTL_TX_KICKDXE;
7888
7889 status = vos_tx_mq_serialize( VOS_MODULE_ID_TL, &vosMsg);
7890 if(status != VOS_STATUS_SUCCESS)
7891 {
7892 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR, "TX Msg Posting Failed with status: %d",status));
7893 return;
7894 }
7895 }
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307896 return;
7897}
Jeff Johnson295189b2012-06-20 16:38:30 -07007898
Mihir Shetefd62d9d2014-08-06 15:08:21 +05307899/*==========================================================================
7900 FUNCTION WLANTL_FatalError
7901
7902 DESCRIPTION
7903 Fatal error reported in TX path, post an event to TX Thread for further
7904 handling
7905
7906 DEPENDENCIES
7907 The TL must be initialized before this gets called.
7908
7909 PARAMETERS
7910
7911 VOID
7912
7913 RETURN VALUE None
7914
7915 SIDE EFFECTS
7916
7917============================================================================*/
7918
7919v_VOID_t
7920WLANTL_FatalError
7921(
7922 v_VOID_t
7923)
7924{
7925 vos_msg_t vosMsg;
7926 VOS_STATUS status;
7927
7928 vosMsg.reserved = 0;
7929 vosMsg.bodyptr = NULL;
7930 vosMsg.type = WLANTL_TX_FATAL_ERROR;
7931
7932 status = vos_tx_mq_serialize( VOS_MODULE_ID_TL, &vosMsg);
7933 if(status != VOS_STATUS_SUCCESS)
7934 {
7935 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7936 "%s: TX Msg Posting Failed with status: %d",
7937 __func__,status));
7938 }
7939 return;
7940}
Jeff Johnson295189b2012-06-20 16:38:30 -07007941/*============================================================================
7942 TL STATE MACHINE
7943============================================================================*/
7944
7945/*==========================================================================
7946 FUNCTION WLANTL_STATxConn
7947
7948 DESCRIPTION
7949 Transmit in connected state - only EAPOL and WAI packets allowed
7950
7951 DEPENDENCIES
7952 The STA must be registered with TL before this function can be called.
7953
7954 PARAMETERS
7955
7956 IN
7957 pvosGCtx: pointer to the global vos context; a handle to TL's
7958 control block can be extracted from its context
7959 ucSTAId: identifier of the station being processed
7960 vosDataBuff: pointer to the tx vos buffer
7961
7962 RETURN VALUE
7963 The result code associated with performing the operation
7964
7965 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
7966 page fault
7967 VOS_STATUS_SUCCESS: Everything is good :)
7968
7969 Other return values are possible coming from the called functions.
7970 Please check API for additional info.
7971
7972 SIDE EFFECTS
7973
7974============================================================================*/
7975VOS_STATUS
7976WLANTL_STATxConn
7977(
7978 v_PVOID_t pvosGCtx,
7979 v_U8_t ucSTAId,
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07007980 vos_pkt_t** pvosDataBuff,
7981 v_BOOL_t bForwardIAPPwithLLC
Jeff Johnson295189b2012-06-20 16:38:30 -07007982)
7983{
7984 v_U16_t usPktLen;
7985 VOS_STATUS vosStatus;
7986 v_MACADDR_t vDestMacAddr;
7987 vos_pkt_t* vosDataBuff = NULL;
7988 WLANTL_CbType* pTLCb = NULL;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307989 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07007990 WLANTL_MetaInfoType tlMetaInfo;
7991 v_U8_t ucTypeSubtype = 0;
7992 v_U8_t ucTid;
7993 v_U8_t extraHeadSpace = 0;
7994 v_U8_t ucWDSEnabled = 0;
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07007995 v_U8_t ucAC, ucACMask, i;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05307996 v_U32_t txFlag = HAL_TX_NO_ENCRYPTION_MASK;
Jeff Johnson295189b2012-06-20 16:38:30 -07007997 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
7998
7999 /*------------------------------------------------------------------------
8000 Sanity check
8001 Extract TL control block
8002 ------------------------------------------------------------------------*/
8003 pTLCb = VOS_GET_TL_CB(pvosGCtx);
8004 if ( NULL == pTLCb )
8005 {
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07008006 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8007 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_STATxConn");
Jeff Johnson295189b2012-06-20 16:38:30 -07008008 *pvosDataBuff = NULL;
8009 return VOS_STATUS_E_FAULT;
8010 }
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308011 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
8012
8013 if ( NULL == pClientSTA )
8014 {
8015 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8016 "WLAN TL:Client Memory was not allocated on %s", __func__));
8017 return VOS_STATUS_E_FAILURE;
8018 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008019
8020 /*-------------------------------------------------------------------
8021 Disable AC temporary - if successfull retrieve re-enable
8022 The order is justified because of the possible scenario
8023 - TL tryes to fetch packet for AC and it returns NULL
8024 - TL analyzes the data it has received to see if there are
8025 any more pkts available for AC -> if not TL will disable AC
8026 - however it is possible that while analyzing results TL got
8027 preempted by a pending indication where the mask was again set
8028 TL will not check again and as a result when it resumes
8029 execution it will disable AC
8030 To prevent this the AC will be disabled here and if retrieve
8031 is successfull it will be re-enabled
8032 -------------------------------------------------------------------*/
8033
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07008034
8035 //LTI:pTLCb->atlSTAClients[ucSTAId].
8036 //LTI: aucACMask[pTLCb->atlSTAClients[ucSTAId].ucCurrentAC] = 0;
8037
8038 /*------------------------------------------------------------------------
8039 Fetch packet from HDD
8040 ------------------------------------------------------------------------*/
Sunil Ravid5406f22013-01-22 00:18:31 -08008041#ifdef FEATURE_WLAN_TDLS
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308042 if ((WLAN_STA_SOFTAP != pClientSTA->wSTADesc.wSTAType) &&
Agarwal Ashishcd86f7b2014-06-16 17:11:58 +05308043 !(vos_concurrent_open_sessions_running()) &&
Sunil Ravid5406f22013-01-22 00:18:31 -08008044 !pTLCb->ucTdlsPeerCount)
8045 {
8046#else
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308047 if ((WLAN_STA_SOFTAP != pClientSTA->wSTADesc.wSTAType) &&
Agarwal Ashishcd86f7b2014-06-16 17:11:58 +05308048 !(vos_concurrent_open_sessions_running()))
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07008049 {
Sunil Ravid5406f22013-01-22 00:18:31 -08008050#endif
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308051 ucAC = pClientSTA->ucCurrentAC;
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07008052
8053 /*-------------------------------------------------------------------
8054 Disable AC temporary - if successfull retrieve re-enable
8055 The order is justified because of the possible scenario
8056 - TL tryes to fetch packet for AC and it returns NULL
8057 - TL analyzes the data it has received to see if there are
8058 any more pkts available for AC -> if not TL will disable AC
8059 - however it is possible that while analyzing results TL got
8060 preempted by a pending indication where the mask was again set
8061 TL will not check again and as a result when it resumes
8062 execution it will disable AC
8063 To prevent this the AC will be disabled here and if retrieve
8064 is successfull it will be re-enabled
8065 -------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308066 pClientSTA->aucACMask[ucAC] = 0;
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07008067 }
8068 else
8069 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308070 //softap case
8071 ucAC = pTLCb->uCurServedAC;
8072 pClientSTA->aucACMask[ucAC] = 0;
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07008073 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008074
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308075 /*You make an initial assumption that HDD has no more data and if the
Jeff Johnson295189b2012-06-20 16:38:30 -07008076 assumption was wrong you reset the flags to their original state
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308077 This will prevent from exposing a race condition between checking with HDD
Jeff Johnson295189b2012-06-20 16:38:30 -07008078 for packets and setting the flags to false*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308079 //LTI: vos_atomic_set_U8( &pTLCb->atlSTAClients[ucSTAId].ucPktPending, 0);
8080 //LTI: pTLCb->atlSTAClients[ucSTAId].ucNoMoreData = 1;
8081 vos_atomic_set_U8( &pClientSTA->ucPktPending, 0);
8082 WLAN_TL_AC_ARRAY_2_MASK( pClientSTA, ucACMask, i);
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308083 /*You make an initial assumption that HDD has no more data and if the
8084 assumption was wrong you reset the flags to their original state
8085 This will prevent from exposing a race condition between checking with HDD
8086 for packets and setting the flags to false*/
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07008087 if ( 0 == ucACMask )
8088 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308089 pClientSTA->ucNoMoreData = 1;
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07008090 }
8091 else
8092 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308093 vos_atomic_set_U8( &pClientSTA->ucPktPending, 1);
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07008094 }
8095
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07008096
Madan Mohan Koyyalamudid93f4942012-10-05 15:05:40 -07008097 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07008098 "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 +05308099 ucAC, ucACMask, pClientSTA->ucPktPending);
Jeff Johnson295189b2012-06-20 16:38:30 -07008100
8101 /*------------------------------------------------------------------------
8102 Fetch tx packet from HDD
8103 ------------------------------------------------------------------------*/
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07008104
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308105 vosStatus = pClientSTA->pfnSTAFetchPkt( pvosGCtx,
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07008106 &ucSTAId,
8107 ucAC,
8108 &vosDataBuff, &tlMetaInfo );
Jeff Johnson295189b2012-06-20 16:38:30 -07008109
8110 if (( VOS_STATUS_SUCCESS != vosStatus ) || ( NULL == vosDataBuff ))
8111 {
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07008112 TLLOG1(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -07008113 "WLAN TL:No more data at HDD status %d", vosStatus));
8114 *pvosDataBuff = NULL;
8115
8116 /*--------------------------------------------------------------------
8117 Reset AC for the serviced station to the highest priority AC
8118 -> due to no more data at the station
8119 Even if this AC is not supported by the station, correction will be
8120 made in the main TL loop
8121 --------------------------------------------------------------------*/
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05308122 pClientSTA->ucCurrentAC = WLANTL_AC_HIGH_PRIO;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308123 pClientSTA->ucCurrentWeight = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07008124
Madan Mohan Koyyalamudid8000342012-11-08 14:55:26 -08008125 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07008126 "WLAN TL: WLANTL_STATxConn no more packets in HDD for AC: %d AC Mask: %d",
8127 ucAC, ucACMask);
8128
Jeff Johnson295189b2012-06-20 16:38:30 -07008129 return vosStatus;
8130 }
8131
8132 /*There are still packets in HDD - set back the pending packets and
8133 the no more data assumption*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308134 vos_atomic_set_U8( &pClientSTA->ucPktPending, 1);
8135 pClientSTA->ucNoMoreData = 0;
8136 pClientSTA->aucACMask[ucAC] = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07008137
Jeff Johnson295189b2012-06-20 16:38:30 -07008138#ifdef WLAN_PERF
8139 vos_pkt_set_user_data_ptr( vosDataBuff, VOS_PKT_USER_DATA_ID_BAL,
8140 (v_PVOID_t)0);
8141
8142#endif /*WLAN_PERF*/
8143
8144
8145#ifdef FEATURE_WLAN_WAPI
8146 /*------------------------------------------------------------------------
8147 If the packet is neither an Eapol packet nor a WAI packet then drop it
8148 ------------------------------------------------------------------------*/
8149 if ( 0 == tlMetaInfo.ucIsEapol && 0 == tlMetaInfo.ucIsWai )
8150 {
Madan Mohan Koyyalamudid93f4942012-10-05 15:05:40 -07008151 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -07008152 "WLAN TL:Only EAPOL or WAI packets allowed before authentication"));
8153
8154 /* Fail tx for packet */
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308155 pClientSTA->pfnSTATxComp( pvosGCtx, vosDataBuff,
Jeff Johnson295189b2012-06-20 16:38:30 -07008156 VOS_STATUS_E_BADMSG);
8157 vosDataBuff = NULL;
8158 *pvosDataBuff = NULL;
8159 return VOS_STATUS_SUCCESS;
8160 }
8161#else
8162 if ( 0 == tlMetaInfo.ucIsEapol )
8163 {
8164 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
8165 "WLAN TL:Received non EAPOL packet before authentication"));
8166
8167 /* Fail tx for packet */
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308168 pClientSTA->pfnSTATxComp( pvosGCtx, vosDataBuff,
Jeff Johnson295189b2012-06-20 16:38:30 -07008169 VOS_STATUS_E_BADMSG);
8170 vosDataBuff = NULL;
8171 *pvosDataBuff = NULL;
8172 return VOS_STATUS_SUCCESS;
8173 }
8174#endif /* FEATURE_WLAN_WAPI */
8175
8176 /*-------------------------------------------------------------------------
8177 Check TID
8178 -------------------------------------------------------------------------*/
8179 ucTid = tlMetaInfo.ucTID;
8180
8181 /*Make sure TID is valid*/
8182 if ( WLANTL_TID_INVALID(ucTid))
8183 {
Rajesh Chauhan2df40bf2013-08-22 11:26:12 -07008184 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
Jeff Johnson295189b2012-06-20 16:38:30 -07008185 "WLAN TL:Invalid TID sent in meta info %d - defaulting to 0 (BE)",
8186 ucTid));
8187 ucTid = 0;
8188 }
8189
8190 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
8191 "WLAN TL:Attaching BD header to pkt on WLANTL_STATxConn"));
8192
8193#ifdef FEATURE_WLAN_WAPI
8194 /*------------------------------------------------------------------------
8195 Translate 802.3 frame to 802.11 if Frame translation is enabled or if
8196 frame is a WAI frame.
8197 ------------------------------------------------------------------------*/
8198 if ( ( 1 == tlMetaInfo.ucIsWai ) ||
8199 ( 0 == tlMetaInfo.ucDisableFrmXtl ) )
8200#else
8201 /*------------------------------------------------------------------------
8202 Translate 802.3 frame to 802.11 if Frame translation is enabled
8203 ------------------------------------------------------------------------*/
8204 if ( ( 0 == tlMetaInfo.ucDisableFrmXtl ) &&
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308205 ( 0 != pClientSTA->wSTADesc.ucSwFrameTXXlation) )
Jeff Johnson295189b2012-06-20 16:38:30 -07008206#endif //#ifdef FEATURE_WLAN_WAPI
8207 {
Kiran Venkatappacab0d352012-12-17 13:09:22 -08008208 vosStatus = WLANTL_Translate8023To80211Header( vosDataBuff, &vosStatus,
8209 pTLCb, &ucSTAId,
Ravi Joshid0699502013-07-08 15:48:47 -07008210 &tlMetaInfo, &ucWDSEnabled,
8211 &extraHeadSpace);
Jeff Johnson295189b2012-06-20 16:38:30 -07008212 if ( VOS_STATUS_SUCCESS != vosStatus )
8213 {
8214 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8215 "WLAN TL:Error when translating header WLANTL_STATxConn"));
8216
8217 return vosStatus;
8218 }
8219
8220 tlMetaInfo.ucDisableFrmXtl = 1;
8221 }
8222
8223 /*-------------------------------------------------------------------------
8224 Call HAL to fill BD header
8225 -------------------------------------------------------------------------*/
8226 ucTypeSubtype |= (WLANTL_80211_DATA_TYPE << 4);
8227
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308228 if ( pClientSTA->wSTADesc.ucQosEnabled )
Jeff Johnson295189b2012-06-20 16:38:30 -07008229 {
8230 ucTypeSubtype |= (WLANTL_80211_DATA_QOS_SUBTYPE);
8231 }
8232
Gopichand Nakkala8b54e912013-03-11 10:44:21 +05308233#ifdef FEATURE_WLAN_WAPI
8234 /* TL State does not transition to AUTHENTICATED till GTK is installed, So in
8235 * case of WPA where GTK handshake is done after the 4 way handshake, the
8236 * unicast 2/2 EAPOL packet from the STA->AP has to be encrypted even before
8237 * the TL is in authenticated state. Since the PTK has been installed
8238 * already (after the 4 way handshake) we make sure that all traffic
8239 * is encrypted henceforth.(Note: TL is still not in AUTHENTICATED state so
8240 * we will only allow EAPOL data or WAI in case of WAPI)
8241 */
8242 if (tlMetaInfo.ucIsEapol && pClientSTA->ptkInstalled)
8243 {
8244 txFlag = 0;
8245 }
8246#else
8247 if (pClientSTA->ptkInstalled)
8248 {
8249 txFlag = 0;
8250 }
8251#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07008252
8253 vosStatus = (VOS_STATUS)WDA_DS_BuildTxPacketInfo( pvosGCtx, vosDataBuff , &vDestMacAddr,
8254 tlMetaInfo.ucDisableFrmXtl, &usPktLen,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308255 pClientSTA->wSTADesc.ucQosEnabled, ucWDSEnabled,
Jeff Johnson295189b2012-06-20 16:38:30 -07008256 extraHeadSpace,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308257 ucTypeSubtype, &pClientSTA->wSTADesc.vSelfMACAddress,
Gopichand Nakkala8b54e912013-03-11 10:44:21 +05308258 ucTid, txFlag,
Sravan Kumar Kairamd9e8cbb2017-01-17 12:17:28 +05308259 tlMetaInfo.usTimeStamp, tlMetaInfo.ucIsEapol || tlMetaInfo.ucIsWai,
8260 tlMetaInfo.ucIsArp, tlMetaInfo.ucUP, tlMetaInfo.ucTxBdToken);
Jeff Johnson295189b2012-06-20 16:38:30 -07008261
8262 if ( VOS_STATUS_SUCCESS != vosStatus )
8263 {
8264 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8265 "WLAN TL:Failed while attempting to fill BD %d", vosStatus));
8266 *pvosDataBuff = NULL;
8267 return vosStatus;
8268 }
8269
8270 /*-----------------------------------------------------------------------
8271 Update tx counter for BA session query for tx side
8272 !1 - should this be done for EAPOL frames?
8273 -----------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308274 pClientSTA->auTxCount[ucTid]++;
Jeff Johnson295189b2012-06-20 16:38:30 -07008275
8276 vos_pkt_set_user_data_ptr( vosDataBuff, VOS_PKT_USER_DATA_ID_TL,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308277 (v_PVOID_t)pClientSTA->pfnSTATxComp );
Jeff Johnson295189b2012-06-20 16:38:30 -07008278
8279 /*------------------------------------------------------------------------
8280 Save data to input pointer for TL core
8281 ------------------------------------------------------------------------*/
8282 *pvosDataBuff = vosDataBuff;
8283 /*security frames cannot be delayed*/
8284 pTLCb->bUrgent = TRUE;
8285
Jeff Johnson295189b2012-06-20 16:38:30 -07008286 /* TX Statistics */
8287 if (!(tlMetaInfo.ucBcast || tlMetaInfo.ucMcast))
8288 {
8289 /* This is TX UC frame */
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308290 pClientSTA->trafficStatistics.txUCFcnt++;
8291 pClientSTA->trafficStatistics.txUCBcnt += usPktLen;
Jeff Johnson295189b2012-06-20 16:38:30 -07008292 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008293
8294 return VOS_STATUS_SUCCESS;
8295}/* WLANTL_STATxConn */
8296
8297
8298/*==========================================================================
8299 FUNCTION WLANTL_STATxAuth
8300
8301 DESCRIPTION
8302 Transmit in authenticated state - all data allowed
8303
8304 DEPENDENCIES
8305 The STA must be registered with TL before this function can be called.
8306
8307 PARAMETERS
8308
8309 IN
8310 pvosGCtx: pointer to the global vos context; a handle to TL's
8311 control block can be extracted from its context
8312 ucSTAId: identifier of the station being processed
8313 vosDataBuff: pointer to the tx vos buffer
8314
8315 RETURN VALUE
8316 The result code associated with performing the operation
8317
8318 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
8319 page fault
8320 VOS_STATUS_SUCCESS: Everything is good :)
8321
8322 Other return values are possible coming from the called functions.
8323 Please check API for additional info.
8324
8325 SIDE EFFECTS
8326
8327============================================================================*/
8328VOS_STATUS
8329WLANTL_STATxAuth
8330(
8331 v_PVOID_t pvosGCtx,
8332 v_U8_t ucSTAId,
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07008333 vos_pkt_t** pvosDataBuff,
8334 v_BOOL_t bForwardIAPPwithLLC
Jeff Johnson295189b2012-06-20 16:38:30 -07008335)
8336{
8337 v_U16_t usPktLen;
8338 VOS_STATUS vosStatus;
8339 v_MACADDR_t vDestMacAddr;
8340 vos_pkt_t* vosDataBuff = NULL;
8341 WLANTL_CbType* pTLCb = NULL;
8342 WLANTL_MetaInfoType tlMetaInfo;
8343 v_U8_t ucTypeSubtype = 0;
8344 WLANTL_ACEnumType ucAC;
8345 WLANTL_ACEnumType ucNextAC;
8346 v_U8_t ucTid;
8347 v_U8_t ucSwFrmXtl = 0;
8348 v_U8_t extraHeadSpace = 0;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308349 WLANTL_STAClientType *pStaClient = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07008350 v_U8_t ucWDSEnabled = 0;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05308351 v_U32_t ucTxFlag = 0;
Abhishek Singh45e68fe2014-12-11 12:55:59 +05308352 v_U8_t ucACMask, i;
Jeff Johnson295189b2012-06-20 16:38:30 -07008353 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
8354
8355 /*------------------------------------------------------------------------
8356 Sanity check
8357 Extract TL control block
8358 ------------------------------------------------------------------------*/
8359 pTLCb = VOS_GET_TL_CB(pvosGCtx);
8360 if (( NULL == pTLCb ) || ( NULL == pvosDataBuff ))
8361 {
8362 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Jeff Johnsonddec6482017-09-19 08:33:57 -07008363 "WLAN TL:Invalid input params on WLANTL_STATxAuth TL %pK DB %pK",
Jeff Johnson295189b2012-06-20 16:38:30 -07008364 pTLCb, pvosDataBuff));
8365 if (NULL != pvosDataBuff)
8366 {
8367 *pvosDataBuff = NULL;
8368 }
8369 if(NULL != pTLCb)
8370 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308371 if ( NULL == pTLCb->atlSTAClients[ucSTAId] )
8372 {
8373 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8374 "WLAN TL:Client Memory was not allocated on %s", __func__));
8375 return VOS_STATUS_E_FAILURE;
8376 }
8377 pTLCb->atlSTAClients[ucSTAId]->ucNoMoreData = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07008378 }
8379 return VOS_STATUS_E_FAULT;
8380 }
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308381 pStaClient = pTLCb->atlSTAClients[ucSTAId];
Jeff Johnson295189b2012-06-20 16:38:30 -07008382
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308383 if ( NULL == pStaClient )
8384 {
8385 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8386 "WLAN TL:Client Memory was not allocated on %s", __func__));
8387 return VOS_STATUS_E_FAILURE;
8388 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008389
8390 vos_mem_zero(&tlMetaInfo, sizeof(tlMetaInfo));
8391 /*------------------------------------------------------------------------
8392 Fetch packet from HDD
8393 ------------------------------------------------------------------------*/
Sunil Ravid5406f22013-01-22 00:18:31 -08008394#ifdef FEATURE_WLAN_TDLS
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308395 if ((WLAN_STA_SOFTAP != pStaClient->wSTADesc.wSTAType) &&
Agarwal Ashishcd86f7b2014-06-16 17:11:58 +05308396 (!vos_concurrent_open_sessions_running()) &&
Sunil Ravid5406f22013-01-22 00:18:31 -08008397 !pTLCb->ucTdlsPeerCount)
8398 {
8399#else
Jeff Johnson295189b2012-06-20 16:38:30 -07008400 if ((WLAN_STA_SOFTAP != pStaClient->wSTADesc.wSTAType) &&
Agarwal Ashishcd86f7b2014-06-16 17:11:58 +05308401 (!vos_concurrent_open_sessions_running()))
Jeff Johnson295189b2012-06-20 16:38:30 -07008402 {
8403#endif
8404 ucAC = pStaClient->ucCurrentAC;
8405
8406 /*-------------------------------------------------------------------
8407 Disable AC temporary - if successfull retrieve re-enable
8408 The order is justified because of the possible scenario
8409 - TL tryes to fetch packet for AC and it returns NULL
8410 - TL analyzes the data it has received to see if there are
8411 any more pkts available for AC -> if not TL will disable AC
8412 - however it is possible that while analyzing results TL got
8413 preempted by a pending indication where the mask was again set
8414 TL will not check again and as a result when it resumes
8415 execution it will disable AC
8416 To prevent this the AC will be disabled here and if retrieve
8417 is successfull it will be re-enabled
8418 -------------------------------------------------------------------*/
8419 pStaClient->aucACMask[pStaClient->ucCurrentAC] = 0;
8420
8421 // don't reset it, as other AC queues in HDD may have packets
8422 //vos_atomic_set_U8( &pStaClient->ucPktPending, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07008423 }
8424 else
8425 {
8426 //softap case
8427 ucAC = pTLCb->uCurServedAC;
8428 pStaClient->aucACMask[ucAC] = 0;
8429
8430 //vos_atomic_set_U8( &pStaClient->ucPktPending, 0);
8431 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008432
8433 WLAN_TL_AC_ARRAY_2_MASK( pStaClient, ucACMask, i);
Jeff Johnson295189b2012-06-20 16:38:30 -07008434 /*You make an initial assumption that HDD has no more data and if the
8435 assumption was wrong you reset the flags to their original state
8436 This will prevent from exposing a race condition between checking with HDD
8437 for packets and setting the flags to false*/
8438 if ( 0 == ucACMask )
8439 {
8440 vos_atomic_set_U8( &pStaClient->ucPktPending, 0);
8441 pStaClient->ucNoMoreData = 1;
8442 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008443
8444 vosStatus = pStaClient->pfnSTAFetchPkt( pvosGCtx,
8445 &ucSTAId,
8446 ucAC,
8447 &vosDataBuff, &tlMetaInfo );
8448
8449
8450 if (( VOS_STATUS_SUCCESS != vosStatus ) || ( NULL == vosDataBuff ))
8451 {
8452
8453 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05308454 "WLAN TL:Failed while attempting to fetch pkt from HDD QId:%d status:%d",
8455 ucAC, vosStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07008456 *pvosDataBuff = NULL;
8457 /*--------------------------------------------------------------------
8458 Reset AC for the serviced station to the highest priority AC
8459 -> due to no more data at the station
8460 Even if this AC is not supported by the station, correction will be
8461 made in the main TL loop
8462 --------------------------------------------------------------------*/
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05308463 pStaClient->ucCurrentAC = WLANTL_AC_HIGH_PRIO;
Jeff Johnson295189b2012-06-20 16:38:30 -07008464 pStaClient->ucCurrentWeight = 0;
8465
8466 return vosStatus;
8467 }
8468
Jeff Johnsone7245742012-09-05 17:12:55 -07008469 WLANTL_StatHandleTXFrame(pvosGCtx, ucSTAId, vosDataBuff, NULL, &tlMetaInfo);
Jeff Johnsone7245742012-09-05 17:12:55 -07008470
Jeff Johnson295189b2012-06-20 16:38:30 -07008471 /*There are still packets in HDD - set back the pending packets and
8472 the no more data assumption*/
8473 vos_atomic_set_U8( &pStaClient->ucPktPending, 1);
8474 pStaClient->ucNoMoreData = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07008475
Jeff Johnson295189b2012-06-20 16:38:30 -07008476 if (WLAN_STA_SOFTAP != pStaClient->wSTADesc.wSTAType)
8477 {
Jeff Johnson295189b2012-06-20 16:38:30 -07008478 // don't need to set it, as we don't reset it in this function.
8479 //vos_atomic_set_U8( &pTLCb->atlSTAClients[ucSTAId].ucPktPending, 1);
Jeff Johnson295189b2012-06-20 16:38:30 -07008480 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008481
8482#ifdef WLAN_PERF
8483 vos_pkt_set_user_data_ptr( vosDataBuff, VOS_PKT_USER_DATA_ID_BAL,
8484 (v_PVOID_t)0);
8485#endif /*WLAN_PERF*/
8486
8487 /*-------------------------------------------------------------------------
8488 Check TID
8489 -------------------------------------------------------------------------*/
8490 ucTid = tlMetaInfo.ucTID;
8491
8492 /*Make sure TID is valid*/
8493 if ( WLANTL_TID_INVALID(ucTid))
8494 {
Rajesh Chauhan2df40bf2013-08-22 11:26:12 -07008495 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
Jeff Johnson295189b2012-06-20 16:38:30 -07008496 "WLAN TL:Invalid TID sent in meta info %d - defaulting to 0 (BE)",
8497 ucTid));
8498 ucTid = 0;
8499 }
8500
8501 /*Save for UAPSD timer consideration*/
8502 pStaClient->ucServicedAC = ucAC;
8503
8504 if ( ucAC == pStaClient->ucCurrentAC )
8505 {
8506 pStaClient->aucACMask[pStaClient->ucCurrentAC] = 1;
8507 pStaClient->ucCurrentWeight--;
8508 }
8509 else
8510 {
8511 pStaClient->ucCurrentAC = ucAC;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308512 pStaClient->ucCurrentWeight = pTLCb->tlConfigInfo.ucAcWeights[ucAC] - 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07008513
8514 pStaClient->aucACMask[pStaClient->ucCurrentAC] = 1;
8515
8516 }
8517
Jeff Johnson295189b2012-06-20 16:38:30 -07008518 if (WLAN_STA_SOFTAP != pStaClient->wSTADesc.wSTAType)
8519 {
Jeff Johnson295189b2012-06-20 16:38:30 -07008520 if ( 0 == pStaClient->ucCurrentWeight )
8521 {
8522 WLANTL_ACEnumType tempAC = ucAC;
8523 /*-----------------------------------------------------------------------
8524 Choose next AC - !!! optimize me
8525 -----------------------------------------------------------------------*/
8526 while ( 0 != ucACMask )
8527 {
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05308528 if(tempAC == WLANTL_AC_BK)
8529 ucNextAC = WLANTL_AC_HIGH_PRIO;
8530 else
8531 ucNextAC = (tempAC - 1);
8532
Jeff Johnson295189b2012-06-20 16:38:30 -07008533 if ( 0 != pStaClient->aucACMask[ucNextAC] )
8534 {
8535 pStaClient->ucCurrentAC = ucNextAC;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308536 pStaClient->ucCurrentWeight = pTLCb->tlConfigInfo.ucAcWeights[ucNextAC];
Jeff Johnson295189b2012-06-20 16:38:30 -07008537
8538 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
8539 "WLAN TL: Changing serviced AC to: %d with Weight: %d",
8540 pStaClient->ucCurrentAC ,
8541 pStaClient->ucCurrentWeight));
8542 break;
8543 }
8544 tempAC = ucNextAC;
8545 }
8546 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008547 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008548
8549 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
8550 "WLAN TL:Attaching BD header to pkt on WLANTL_STATxAuth"));
8551
8552 /*------------------------------------------------------------------------
8553 Translate 802.3 frame to 802.11
8554 ------------------------------------------------------------------------*/
8555 if ( 0 == tlMetaInfo.ucDisableFrmXtl )
8556 {
8557 /* Needs frame translation */
8558 // if the client has not enabled SW-only frame translation
8559 // and if the frame is a unicast frame
8560 // (HW frame translation does not support multiple broadcast domains
8561 // so we use SW frame translation for broadcast/multicast frames)
8562#ifdef FEATURE_WLAN_WAPI
8563 // and if the frame is not a WAPI frame
8564#endif
8565 // then use HW_based frame translation
8566
8567 if ( ( 0 == pStaClient->wSTADesc.ucSwFrameTXXlation ) &&
8568 ( 0 == tlMetaInfo.ucBcast ) &&
8569 ( 0 == tlMetaInfo.ucMcast )
8570#ifdef FEATURE_WLAN_WAPI
8571 && ( tlMetaInfo.ucIsWai != 1 )
8572#endif
8573 )
8574 {
8575#ifdef WLAN_PERF
8576 v_U32_t uFastFwdOK = 0;
8577
8578 /* HW based translation. See if the frame could be fast forwarded */
8579 WDA_TLI_FastHwFwdDataFrame( pvosGCtx, vosDataBuff , &vosStatus,
8580 &uFastFwdOK, &tlMetaInfo, &pStaClient->wSTADesc);
8581
8582 if( VOS_STATUS_SUCCESS == vosStatus )
8583 {
8584 if(uFastFwdOK)
8585 {
8586 /* Packet could be fast forwarded now */
8587 vos_pkt_set_user_data_ptr( vosDataBuff, VOS_PKT_USER_DATA_ID_TL,
8588 (v_PVOID_t)pStaClient->pfnSTATxComp );
8589
8590 *pvosDataBuff = vosDataBuff;
8591
8592 /* TODO: Do we really need to update WLANTL_HSHandleTXFrame()
8593 stats for every pkt? */
8594 pStaClient->auTxCount[tlMetaInfo.ucTID]++;
8595 return vosStatus;
8596 }
8597 /* can't be fast forwarded, fall through normal (slow) path. */
8598 }
8599 else
8600 {
8601
8602 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8603 "WLAN TL:Failed while attempting to fastFwd BD %d", vosStatus));
8604 *pvosDataBuff = NULL;
8605 return vosStatus;
8606 }
8607#endif /*WLAN_PERF*/
8608 }
8609 else
8610 {
8611 /* SW based translation */
8612
Kiran Venkatappacab0d352012-12-17 13:09:22 -08008613 vosStatus = WLANTL_Translate8023To80211Header( vosDataBuff, &vosStatus,
8614 pTLCb, &ucSTAId,
Ravi Joshid0699502013-07-08 15:48:47 -07008615 &tlMetaInfo, &ucWDSEnabled,
8616 &extraHeadSpace);
Jeff Johnson295189b2012-06-20 16:38:30 -07008617 if ( VOS_STATUS_SUCCESS != vosStatus )
8618 {
8619 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8620 "WLAN TL:Error when translating header WLANTL_STATxAuth"));
8621 return vosStatus;
8622 }
8623
8624 TLLOG4(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_LOW,
Arif Hussainf2b00992013-11-17 21:46:15 -08008625 "WLAN TL software translation success"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008626 ucSwFrmXtl = 1;
8627 tlMetaInfo.ucDisableFrmXtl = 1;
8628 }
8629 }
Gopichand Nakkala574f6d12013-06-27 19:38:43 +05308630#ifdef FEATURE_WLAN_TDLS
8631 /*In case of TDLS, if the packet is destined to TDLS STA ucSTAId may
8632 change. so update the pStaClient accordingly */
8633 pStaClient = pTLCb->atlSTAClients[ucSTAId];
Jeff Johnson295189b2012-06-20 16:38:30 -07008634
Gopichand Nakkala574f6d12013-06-27 19:38:43 +05308635 if ( NULL == pStaClient )
8636 {
8637 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8638 "pStaClient is NULL %s", __func__));
8639 return VOS_STATUS_E_FAILURE;
8640 }
8641#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07008642 /*-------------------------------------------------------------------------
8643 Call HAL to fill BD header
8644 -------------------------------------------------------------------------*/
8645 ucTypeSubtype |= (WLANTL_80211_DATA_TYPE << 4);
8646
8647 if ( pStaClient->wSTADesc.ucQosEnabled )
8648 {
8649 ucTypeSubtype |= (WLANTL_80211_DATA_QOS_SUBTYPE);
8650 }
8651
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05308652 /* ucAC now points to TL Q ID with a new queue added in TL,
8653 * hence look for the uapsd info for the correct AC that
8654 * this packet belongs to.
8655 */
8656 ucTxFlag = (0 != pStaClient->wUAPSDInfo[tlMetaInfo.ac].ucSet)?
Jeff Johnson295189b2012-06-20 16:38:30 -07008657 HAL_TRIGGER_ENABLED_AC_MASK:0;
8658
8659#ifdef FEATURE_WLAN_WAPI
8660 if ( pStaClient->wSTADesc.ucIsWapiSta == 1 )
8661 {
8662#ifdef LIBRA_WAPI_SUPPORT
8663 ucTxFlag = ucTxFlag | HAL_WAPI_STA_MASK;
8664#endif //LIBRA_WAPI_SUPPORT
8665 if ( tlMetaInfo.ucIsWai == 1 )
8666 {
8667 ucTxFlag = ucTxFlag | HAL_TX_NO_ENCRYPTION_MASK;
8668 }
8669 }
8670#endif /* FEATURE_WLAN_WAPI */
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008671#ifdef FEATURE_WLAN_TDLS
8672 if ( pStaClient->wSTADesc.wSTAType == WLAN_STA_TDLS )
8673 {
8674 ucTxFlag = ucTxFlag | HAL_TDLS_PEER_STA_MASK;
8675 }
8676#endif /* FEATURE_WLAN_TDLS */
Abhishek Singhfa011222014-04-14 10:57:08 +05308677 if( tlMetaInfo.ucIsArp )
8678 {
Sravan Kumar Kairamd9e8cbb2017-01-17 12:17:28 +05308679 if (pTLCb->track_arp)
8680 {
8681 if (vos_check_arp_target_ip(vosDataBuff))
8682 {
8683 ucTxFlag |= HAL_USE_FW_IN_TX_PATH;
8684 ucTxFlag |= HAL_TXCOMP_REQUESTED_MASK;
8685 tlMetaInfo.ucTxBdToken = ++ pTLCb->txbd_token;
8686 }
8687 }
8688
Hanumantha Reddy Pothulae5ab23d2015-09-14 18:08:24 +05308689 if (pStaClient->arpOnWQ5)
8690 {
8691 ucTxFlag |= HAL_USE_FW_IN_TX_PATH;
8692 }
Hanumantha Reddy Pothulaee001fc2015-05-26 15:21:53 +05308693 if (pStaClient->arpRate == 0)
8694 {
8695 ucTxFlag |= HAL_USE_BD_RATE_1_MASK;
8696 }
8697 else if (pStaClient->arpRate == 1 || pStaClient->arpRate == 3)
8698 {
8699 pStaClient->arpRate ^= 0x2;
8700 ucTxFlag |= HAL_USE_BD_RATE_1_MASK<<(pStaClient->arpRate-1);
8701 }
8702 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
8703 "arp pkt sending on BD rate: %hhu", pStaClient->arpRate));
Abhishek Singhfa011222014-04-14 10:57:08 +05308704 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008705
8706 vosStatus = (VOS_STATUS)WDA_DS_BuildTxPacketInfo( pvosGCtx,
8707 vosDataBuff , &vDestMacAddr,
8708 tlMetaInfo.ucDisableFrmXtl, &usPktLen,
8709 pStaClient->wSTADesc.ucQosEnabled, ucWDSEnabled,
8710 extraHeadSpace,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308711 ucTypeSubtype, &pStaClient->wSTADesc.vSelfMACAddress,
Jeff Johnson295189b2012-06-20 16:38:30 -07008712 ucTid, ucTxFlag, tlMetaInfo.usTimeStamp,
Sravan Kumar Kairamd9e8cbb2017-01-17 12:17:28 +05308713 tlMetaInfo.ucIsEapol, tlMetaInfo.ucIsArp, tlMetaInfo.ucUP,
Ganesh Kondabattini10e67352015-03-16 17:41:57 +05308714 tlMetaInfo.ucTxBdToken);
Jeff Johnson295189b2012-06-20 16:38:30 -07008715
8716 if(!VOS_IS_STATUS_SUCCESS(vosStatus))
8717 {
8718 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8719 "Fill TX BD Error status %d", vosStatus));
8720
8721 return vosStatus;
8722 }
8723
Jeff Johnson295189b2012-06-20 16:38:30 -07008724 /* TX Statistics */
8725 if (!(tlMetaInfo.ucBcast || tlMetaInfo.ucMcast))
8726 {
8727 /* This is TX UC frame */
8728 pStaClient->trafficStatistics.txUCFcnt++;
8729 pStaClient->trafficStatistics.txUCBcnt += usPktLen;
8730 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008731
Kiran Venkatappacab0d352012-12-17 13:09:22 -08008732#ifndef FEATURE_WLAN_TDLS
Jeff Johnson295189b2012-06-20 16:38:30 -07008733 /*-----------------------------------------------------------------------
8734 Update tx counter for BA session query for tx side
8735 -----------------------------------------------------------------------*/
8736 pStaClient->auTxCount[ucTid]++;
Kiran Venkatappacab0d352012-12-17 13:09:22 -08008737#else
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308738 pTLCb->atlSTAClients[ucSTAId]->auTxCount[ucTid]++;
Kiran Venkatappacab0d352012-12-17 13:09:22 -08008739#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07008740
8741 /* This code is to send traffic with lower priority AC when we does not
8742 get admitted to send it. Today HAL does not downgrade AC so this code
8743 does not get executed.(In other words, HAL doesnÂ’t change tid. The if
8744 statement is always false.)
8745 NOTE: In the case of LA downgrade occurs in HDD (that was the change
8746 Phani made during WMM-AC plugfest). If WM & BMP also took this approach,
8747 then there will be no need for any AC downgrade logic in TL/WDI. */
8748#if 0
8749 if (( ucTid != tlMetaInfo.ucTID ) &&
8750 ( 0 != pStaClient->wSTADesc.ucQosEnabled ) &&
8751 ( 0 != ucSwFrmXtl ))
8752 {
8753 /*---------------------------------------------------------------------
8754 !! FIX me: Once downgrading is clear put in the proper change
8755 ---------------------------------------------------------------------*/
8756 ucQCOffset = WLANHAL_TX_BD_HEADER_SIZE + WLANTL_802_11_HEADER_LEN;
8757
8758 //!!!Fix this replace peek with extract
8759 vos_pkt_peek_data( vosDataBuff, ucQCOffset,(v_PVOID_t)&pucQosCtrl,
8760 sizeof(*pucQosCtrl));
8761 *pucQosCtrl = ucTid; //? proper byte order
8762 }
8763#endif
8764
8765 if ( VOS_STATUS_SUCCESS != vosStatus )
8766 {
8767 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8768 "WLAN TL:Failed while attempting to fill BD %d", vosStatus));
8769 *pvosDataBuff = NULL;
8770 return vosStatus;
8771 }
8772
8773 vos_pkt_set_user_data_ptr( vosDataBuff, VOS_PKT_USER_DATA_ID_TL,
8774 (v_PVOID_t)pStaClient->pfnSTATxComp );
8775
8776 *pvosDataBuff = vosDataBuff;
8777
8778 /*BE & BK can be delayed, VO and VI not frames cannot be delayed*/
8779 if ( pStaClient->ucServicedAC > WLANTL_AC_BE )
8780 {
8781 pTLCb->bUrgent= TRUE;
8782 }
8783
8784 return VOS_STATUS_SUCCESS;
8785}/* WLANTL_STATxAuth */
8786
8787/*==========================================================================
8788 FUNCTION WLANTL_STATxDisc
8789
8790 DESCRIPTION
8791 Transmit in disconnected state - no data allowed
8792
8793 DEPENDENCIES
8794 The STA must be registered with TL before this function can be called.
8795
8796 PARAMETERS
8797
8798 IN
8799 pvosGCtx: pointer to the global vos context; a handle to TL's
8800 control block can be extracted from its context
8801 ucSTAId: identifier of the station being processed
8802 vosDataBuff: pointer to the tx vos buffer
8803
8804 RETURN VALUE
8805 The result code associated with performing the operation
8806
8807 VOS_STATUS_SUCCESS: Everything is good :)
8808
8809 SIDE EFFECTS
8810
8811============================================================================*/
8812VOS_STATUS
8813WLANTL_STATxDisc
8814(
8815 v_PVOID_t pvosGCtx,
8816 v_U8_t ucSTAId,
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07008817 vos_pkt_t** pvosDataBuff,
8818 v_BOOL_t bForwardIAPPwithLLC
Jeff Johnson295189b2012-06-20 16:38:30 -07008819)
8820{
8821 WLANTL_CbType* pTLCb = NULL;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308822 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07008823 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
8824
Jeff Johnson295189b2012-06-20 16:38:30 -07008825 /*------------------------------------------------------------------------
8826 Sanity check
8827 Extract TL control block
8828 ------------------------------------------------------------------------*/
8829 pTLCb = VOS_GET_TL_CB(pvosGCtx);
8830 if ( NULL == pTLCb )
8831 {
8832 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8833 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_STATxAuth"));
8834 *pvosDataBuff = NULL;
8835 return VOS_STATUS_E_FAULT;
8836 }
8837
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308838 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
8839
8840 if ( NULL == pClientSTA )
8841 {
8842 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8843 "WLAN TL:Client Memory was not allocated on %s", __func__));
8844 return VOS_STATUS_E_FAILURE;
8845 }
8846
Jeff Johnson295189b2012-06-20 16:38:30 -07008847 /*------------------------------------------------------------------------
8848 Error
8849 ------------------------------------------------------------------------*/
8850 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
8851 "WLAN TL:Packet should not be transmitted in state disconnected ignoring"
8852 " request"));
8853
8854 *pvosDataBuff = NULL;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308855 pClientSTA->ucNoMoreData = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07008856
8857 //Should not be anything pending in disconnect state
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308858 vos_atomic_set_U8( &pClientSTA->ucPktPending, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07008859
8860 return VOS_STATUS_SUCCESS;
8861}/* WLANTL_STATxDisc */
8862
8863/*==========================================================================
8864 FUNCTION WLANTL_STARxConn
8865
8866 DESCRIPTION
8867 Receive in connected state - only EAPOL
8868
8869 DEPENDENCIES
8870 The STA must be registered with TL before this function can be called.
8871
8872 PARAMETERS
8873
8874 IN
8875 pvosGCtx: pointer to the global vos context; a handle to TL's
8876 control block can be extracted from its context
8877 ucSTAId: identifier of the station being processed
8878 vosDataBuff: pointer to the tx/rx vos buffer
8879
8880 RETURN VALUE
8881 The result code associated with performing the operation
8882
8883 VOS_STATUS_E_INVAL: invalid input parameters
8884 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
8885 page fault
8886 VOS_STATUS_SUCCESS: Everything is good :)
8887
8888 SIDE EFFECTS
8889
8890============================================================================*/
8891VOS_STATUS
8892WLANTL_STARxConn
8893(
8894 v_PVOID_t pvosGCtx,
8895 v_U8_t ucSTAId,
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07008896 vos_pkt_t** pvosDataBuff,
8897 v_BOOL_t bForwardIAPPwithLLC
Jeff Johnson295189b2012-06-20 16:38:30 -07008898)
8899{
8900 WLANTL_CbType* pTLCb = NULL;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308901 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07008902 v_U16_t usEtherType = 0;
8903 v_U16_t usPktLen;
8904 v_U8_t ucMPDUHOffset;
8905 v_U16_t usMPDUDOffset;
8906 v_U16_t usMPDULen;
8907 v_U8_t ucMPDUHLen;
8908 v_U16_t usActualHLen = 0;
8909 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
8910 vos_pkt_t* vosDataBuff;
8911 v_PVOID_t aucBDHeader;
8912 v_U8_t ucTid;
8913 WLANTL_RxMetaInfoType wRxMetaInfo;
8914 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
8915
8916 /*------------------------------------------------------------------------
8917 Sanity check
8918 ------------------------------------------------------------------------*/
8919 if (( NULL == pvosDataBuff ) || ( NULL == ( vosDataBuff = *pvosDataBuff )))
8920 {
8921 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8922 "WLAN TL:Invalid parameter sent on WLANTL_STARxConn"));
8923 return VOS_STATUS_E_INVAL;
8924 }
8925
8926 /*------------------------------------------------------------------------
8927 Extract TL control block
8928 ------------------------------------------------------------------------*/
8929 pTLCb = VOS_GET_TL_CB(pvosGCtx);
8930 if ( NULL == pTLCb )
8931 {
8932 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8933 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_ChangeSTAState"));
8934 return VOS_STATUS_E_FAULT;
8935 }
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308936 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
8937
8938 if ( NULL == pClientSTA )
8939 {
8940 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8941 "WLAN TL:Client Memory was not allocated on %s", __func__));
8942 return VOS_STATUS_E_FAILURE;
8943 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008944
8945 /*------------------------------------------------------------------------
8946 Extract BD header and check if valid
8947 ------------------------------------------------------------------------*/
8948 vosStatus = WDA_DS_PeekRxPacketInfo( vosDataBuff, (v_PVOID_t)&aucBDHeader, 0/*Swap BD*/ );
8949
8950 if ( NULL == aucBDHeader )
8951 {
8952 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8953 "WLAN TL:Cannot extract BD header"));
8954 VOS_ASSERT( 0 );
8955 return VOS_STATUS_E_FAULT;
8956 }
8957
8958
8959 ucMPDUHOffset = (v_U8_t)WDA_GET_RX_MPDU_HEADER_OFFSET(aucBDHeader);
8960 usMPDUDOffset = (v_U16_t)WDA_GET_RX_MPDU_DATA_OFFSET(aucBDHeader);
8961 usMPDULen = (v_U16_t)WDA_GET_RX_MPDU_LEN(aucBDHeader);
8962 ucMPDUHLen = (v_U8_t)WDA_GET_RX_MPDU_HEADER_LEN(aucBDHeader);
8963 ucTid = (v_U8_t)WDA_GET_RX_TID(aucBDHeader);
8964
8965 vos_pkt_get_packet_length( vosDataBuff, &usPktLen);
8966
8967 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
8968 "WLAN TL:BD header processing data: HO %d DO %d Len %d HLen %d",
8969 ucMPDUHOffset, usMPDUDOffset, usMPDULen, ucMPDUHLen));
8970
8971 /*It will cut out the 802.11 header if not used*/
8972 if ( VOS_STATUS_SUCCESS != WDA_DS_TrimRxPacketInfo( vosDataBuff ) )
8973 {
8974 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
8975 "WLAN TL:BD header corrupted - dropping packet"));
8976 /* Drop packet */
8977 vos_pkt_return_packet(vosDataBuff);
8978 return VOS_STATUS_SUCCESS;
8979 }
8980
8981 vosStatus = WLANTL_GetEtherType(aucBDHeader,vosDataBuff,ucMPDUHLen,&usEtherType);
8982
8983 if( VOS_IS_STATUS_SUCCESS(vosStatus) )
8984 {
8985#ifdef FEATURE_WLAN_WAPI
8986 /* If frame is neither an EAPOL frame nor a WAI frame then we drop the frame*/
8987 /* TODO: Do we need a check to see if we are in WAPI mode? If not is it possible */
8988 /* that we get an EAPOL packet in WAPI mode or vice versa? */
8989 if ( WLANTL_LLC_8021X_TYPE != usEtherType && WLANTL_LLC_WAI_TYPE != usEtherType )
8990 {
Sunil Ravid5406f22013-01-22 00:18:31 -08008991 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07008992 "WLAN TL:RX Frame not EAPOL or WAI EtherType %d - dropping", usEtherType );
Jeff Johnson295189b2012-06-20 16:38:30 -07008993 /* Drop packet */
8994 vos_pkt_return_packet(vosDataBuff);
8995 }
8996#else
8997 if ( WLANTL_LLC_8021X_TYPE != usEtherType )
8998 {
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07008999 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9000 "WLAN TL:RX Frame not EAPOL EtherType %d - dropping", usEtherType);
Jeff Johnson295189b2012-06-20 16:38:30 -07009001 /* Drop packet */
9002 vos_pkt_return_packet(vosDataBuff);
9003 }
9004#endif /* FEATURE_WLAN_WAPI */
9005 else /* Frame is an EAPOL frame or a WAI frame*/
9006 {
Katya Nigam42e16e82014-02-04 16:28:55 +05309007 MTRACE(vos_trace(VOS_MODULE_ID_TL,
9008 TRACE_CODE_TL_RX_CONN_EAPOL, ucSTAId, usEtherType ));
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07009009
Madan Mohan Koyyalamudid8000342012-11-08 14:55:26 -08009010 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07009011 "WLAN TL:RX Frame EAPOL EtherType %d - processing", usEtherType);
9012
Jeff Johnson295189b2012-06-20 16:38:30 -07009013 if (( 0 == WDA_GET_RX_FT_DONE(aucBDHeader) ) &&
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309014 ( 0 != pClientSTA->wSTADesc.ucSwFrameRXXlation))
Jeff Johnson295189b2012-06-20 16:38:30 -07009015 {
9016 if (usMPDUDOffset > ucMPDUHOffset)
9017 {
9018 usActualHLen = usMPDUDOffset - ucMPDUHOffset;
9019 }
9020
9021 vosStatus = WLANTL_Translate80211To8023Header( vosDataBuff, &vosStatus, usActualHLen,
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009022 ucMPDUHLen, pTLCb, ucSTAId, bForwardIAPPwithLLC);
Jeff Johnson295189b2012-06-20 16:38:30 -07009023
9024 if ( VOS_STATUS_SUCCESS != vosStatus )
9025 {
Kaushik, Sushante386ee12014-05-01 15:50:52 +05309026 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
Jeff Johnson295189b2012-06-20 16:38:30 -07009027 "WLAN TL:Failed to translate from 802.11 to 802.3 - dropping"));
9028 /* Drop packet */
9029 vos_pkt_return_packet(vosDataBuff);
9030 return vosStatus;
9031 }
9032 }
9033 /*-------------------------------------------------------------------
9034 Increment receive counter
9035 -------------------------------------------------------------------*/
Madan Mohan Koyyalamudic0e5bd82012-09-18 17:12:27 -07009036 if ( !WLANTL_TID_INVALID( ucTid) )
9037 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309038 pClientSTA->auRxCount[ucTid]++;
Madan Mohan Koyyalamudic0e5bd82012-09-18 17:12:27 -07009039 }
9040 else
9041 {
9042 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9043 "WLAN TL:Invalid tid %d (Station ID %d) on %s",
9044 ucTid, ucSTAId, __func__));
Hanumantha Reddy Pothula0de10802016-02-11 17:29:27 +05309045 vos_pkt_return_packet(vosDataBuff);
9046 return VOS_STATUS_E_FAILURE;
Madan Mohan Koyyalamudic0e5bd82012-09-18 17:12:27 -07009047 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009048
9049 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
9050 "WLAN TL:Sending EAPoL frame to station %d AC %d", ucSTAId, ucTid));
9051
9052 /*-------------------------------------------------------------------
9053 !!!Assuming TID = UP mapping
9054 -------------------------------------------------------------------*/
9055 wRxMetaInfo.ucUP = ucTid;
9056
Jeff Johnson295189b2012-06-20 16:38:30 -07009057 TLLOG4(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_LOW,
Arif Hussainf2b00992013-11-17 21:46:15 -08009058 "WLAN TL %s:Sending data chain to station", __func__));
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309059 if ( WLAN_STA_SOFTAP == pClientSTA->wSTADesc.wSTAType )
Jeff Johnson295189b2012-06-20 16:38:30 -07009060 {
9061 wRxMetaInfo.ucDesSTAId = WLAN_RX_SAP_SELF_STA_ID;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309062 pClientSTA->pfnSTARx( pvosGCtx, vosDataBuff, ucSTAId,
Jeff Johnson295189b2012-06-20 16:38:30 -07009063 &wRxMetaInfo );
9064 }
9065 else
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309066 pClientSTA->pfnSTARx( pvosGCtx, vosDataBuff, ucSTAId,
Jeff Johnson295189b2012-06-20 16:38:30 -07009067 &wRxMetaInfo );
9068 }/*EAPOL frame or WAI frame*/
9069 }/*vos status success*/
9070
9071 return VOS_STATUS_SUCCESS;
9072}/* WLANTL_STARxConn */
9073
Jeff Johnson295189b2012-06-20 16:38:30 -07009074/*==========================================================================
9075 FUNCTION WLANTL_FwdPktToHDD
9076
9077 DESCRIPTION
9078 Determine the Destation Station ID and route the Frame to Upper Layer
9079
9080 DEPENDENCIES
9081
9082 PARAMETERS
9083
9084 IN
9085 pvosGCtx: pointer to the global vos context; a handle to TL's
9086 control block can be extracted from its context
9087 ucSTAId: identifier of the station being processed
9088 vosDataBuff: pointer to the rx vos buffer
9089
9090 RETURN VALUE
9091 The result code associated with performing the operation
9092
9093 VOS_STATUS_E_INVAL: invalid input parameters
9094 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
9095 page fault
9096 VOS_STATUS_SUCCESS: Everything is good :)
9097
9098 SIDE EFFECTS
9099
9100============================================================================*/
9101
9102VOS_STATUS
9103WLANTL_FwdPktToHDD
9104(
9105 v_PVOID_t pvosGCtx,
9106 vos_pkt_t* pvosDataBuff,
9107 v_U8_t ucSTAId
9108)
9109{
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309110 v_MACADDR_t DestMacAddress;
9111 v_MACADDR_t *pDestMacAddress = &DestMacAddress;
9112 v_SIZE_t usMacAddSize = VOS_MAC_ADDR_SIZE;
Jeff Johnson295189b2012-06-20 16:38:30 -07009113 WLANTL_CbType* pTLCb = NULL;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309114 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07009115 vos_pkt_t* vosDataBuff ;
9116 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
Girish Gowli93e3edd2014-05-01 15:42:31 +05309117 v_U32_t* STAMetaInfoPtr;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309118 vos_pkt_t* vosNextDataBuff ;
9119 v_U8_t ucDesSTAId;
Jeff Johnson295189b2012-06-20 16:38:30 -07009120 WLANTL_RxMetaInfoType wRxMetaInfo;
9121
Jeff Johnson295189b2012-06-20 16:38:30 -07009122 /*------------------------------------------------------------------------
9123 Sanity check
9124 ------------------------------------------------------------------------*/
9125 if (( NULL == pvosDataBuff ) || ( NULL == ( vosDataBuff = pvosDataBuff )))
9126 {
9127 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9128 "WLAN TL:Invalid parameter sent on WLANTL_FwdPktToHdd"));
9129 return VOS_STATUS_E_INVAL;
9130 }
9131
9132 /*------------------------------------------------------------------------
9133 Extract TL control block
9134 ------------------------------------------------------------------------*/
9135 pTLCb = VOS_GET_TL_CB(pvosGCtx);
9136 if ( NULL == pTLCb )
9137 {
9138 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9139 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_FwdPktToHdd"));
9140 return VOS_STATUS_E_FAULT;
9141 }
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309142
Tushnim Bhattacharyya5dd94562013-03-20 20:15:03 -07009143 if(WLANTL_STA_ID_INVALID(ucSTAId))
9144 {
9145 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,"ucSTAId %d is not valid",
9146 ucSTAId));
9147 return VOS_STATUS_E_INVAL;
9148 }
9149
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309150 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
9151
9152 if ( NULL == pClientSTA )
9153 {
9154 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9155 "WLAN TL:Client Memory was not allocated on %s", __func__));
9156 return VOS_STATUS_E_FAILURE;
9157 }
9158
Jeff Johnson295189b2012-06-20 16:38:30 -07009159 /* This the change required for SoftAp to handle Reordered Buffer. Since a STA
9160 may have packets destined to multiple destinations we have to process each packet
9161 at a time and determine its Destination. So the Voschain provided by Reorder code
9162 is unchain and forwarded to Upper Layer after Determining the Destination */
9163
9164 vosDataBuff = pvosDataBuff;
9165 while (vosDataBuff != NULL)
9166 {
9167 vos_pkt_walk_packet_chain( vosDataBuff, &vosNextDataBuff, 1/*true*/ );
9168 vos_pkt_get_user_data_ptr( vosDataBuff, VOS_PKT_USER_DATA_ID_TL,
Girish Gowli93e3edd2014-05-01 15:42:31 +05309169 (v_PVOID_t *)&STAMetaInfoPtr );
9170 wRxMetaInfo.ucUP = (v_U8_t)((uintptr_t)STAMetaInfoPtr & WLANTL_AC_MASK);
9171 ucDesSTAId = (v_U8_t)(((uintptr_t)STAMetaInfoPtr) >> WLANTL_STAID_OFFSET);
Jeff Johnson295189b2012-06-20 16:38:30 -07009172
9173 vosStatus = vos_pkt_extract_data( vosDataBuff, 0, (v_VOID_t *)pDestMacAddress, &usMacAddSize);
9174 if ( VOS_STATUS_SUCCESS != vosStatus )
9175 {
9176 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Arif Hussainf2b00992013-11-17 21:46:15 -08009177 "WLAN TL: recv corrupted data packet"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009178 vos_pkt_return_packet(vosDataBuff);
9179 return vosStatus;
9180 }
9181
Arif Hussaina7c8e412013-11-20 11:06:42 -08009182 TLLOG4(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_LOW,
9183 "station mac "MAC_ADDRESS_STR,
9184 MAC_ADDR_ARRAY(pDestMacAddress->bytes)));
Jeff Johnson295189b2012-06-20 16:38:30 -07009185
9186 if (vos_is_macaddr_broadcast( pDestMacAddress ) || vos_is_macaddr_group(pDestMacAddress))
9187 {
9188 // destination is mc/bc station
9189 ucDesSTAId = WLAN_RX_BCMC_STA_ID;
9190 TLLOG4(VOS_TRACE( VOS_MODULE_ID_HDD_SOFTAP, VOS_TRACE_LEVEL_INFO_LOW,
Arif Hussainf2b00992013-11-17 21:46:15 -08009191 "%s: BC/MC packet, id %d", __func__, WLAN_RX_BCMC_STA_ID));
Jeff Johnson295189b2012-06-20 16:38:30 -07009192 }
9193 else
9194 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309195 if (vos_is_macaddr_equal(pDestMacAddress, &pClientSTA->wSTADesc.vSelfMACAddress))
Jeff Johnson295189b2012-06-20 16:38:30 -07009196 {
9197 // destination is AP itself
9198 ucDesSTAId = WLAN_RX_SAP_SELF_STA_ID;
9199 TLLOG4(VOS_TRACE( VOS_MODULE_ID_HDD_SOFTAP, VOS_TRACE_LEVEL_INFO_LOW,
Arif Hussainf2b00992013-11-17 21:46:15 -08009200 "%s: packet to AP itself, id %d", __func__, WLAN_RX_SAP_SELF_STA_ID));
Jeff Johnson295189b2012-06-20 16:38:30 -07009201 }
Madan Mohan Koyylamudi64258222013-01-30 14:35:10 +05309202 else if (( WLAN_MAX_STA_COUNT <= ucDesSTAId ) || (NULL != pTLCb->atlSTAClients[ucDesSTAId] && pTLCb->atlSTAClients[ucDesSTAId]->ucExists == 0))
Jeff Johnson295189b2012-06-20 16:38:30 -07009203 {
9204 // destination station is something else
9205 TLLOG4(VOS_TRACE( VOS_MODULE_ID_HDD_SOFTAP, VOS_TRACE_LEVEL_INFO_LOW,
Arif Hussainf2b00992013-11-17 21:46:15 -08009206 "%s: get an station index larger than WLAN_MAX_STA_COUNT %d", __func__, ucDesSTAId));
Jeff Johnson295189b2012-06-20 16:38:30 -07009207 ucDesSTAId = WLAN_RX_SAP_SELF_STA_ID;
9208 }
9209
9210
9211 //loopback unicast station comes here
9212 }
9213
Girish Gowli93e3edd2014-05-01 15:42:31 +05309214 wRxMetaInfo.ucUP = (v_U8_t)((uintptr_t)STAMetaInfoPtr & WLANTL_AC_MASK);
Jeff Johnson295189b2012-06-20 16:38:30 -07009215 wRxMetaInfo.ucDesSTAId = ucDesSTAId;
9216
Madan Mohan Koyyalamudi6c2977d2013-09-04 15:42:45 +05309217 vosStatus = pClientSTA->pfnSTARx( pvosGCtx, vosDataBuff, ucDesSTAId,
Jeff Johnson295189b2012-06-20 16:38:30 -07009218 &wRxMetaInfo );
Madan Mohan Koyyalamudi6c2977d2013-09-04 15:42:45 +05309219 if ( VOS_STATUS_SUCCESS != vosStatus )
9220 {
9221 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Arif Hussainf2b00992013-11-17 21:46:15 -08009222 "WLAN TL: failed to send pkt to HDD"));
Madan Mohan Koyyalamudi6c2977d2013-09-04 15:42:45 +05309223 vos_pkt_return_packet(vosDataBuff);
9224
9225 return vosStatus;
9226 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009227 vosDataBuff = vosNextDataBuff;
9228 }
9229 return VOS_STATUS_SUCCESS;
9230}
Jeff Johnson295189b2012-06-20 16:38:30 -07009231
Kapil Guptad90b3862016-06-25 00:42:49 +05309232#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
9233void WLANTL_StopRxRateMonitor(v_PVOID_t pvosGCtx)
9234{
9235 WLANTL_CbType *pTLCb = VOS_GET_TL_CB(pvosGCtx);
9236 if (!pTLCb)
9237 return;
9238 pTLCb->gDsRxRoamStats.running = eWLAN_PAL_FALSE;
9239}
9240
9241void WLANTL_StartRxRateMonitor(v_PVOID_t pvosGCtx, v_U8_t staId,
9242 v_U16_t minRate,
9243 v_U16_t maxRate, v_U8_t minPercentage,
9244 v_U16_t minPktRequired, void *hHal,
9245 v_U64_t timeToWait,
9246 void (*triggerRoamScanfn) (void *, v_U8_t))
9247{
9248
9249 WLANTL_CbType *pTLCb = VOS_GET_TL_CB(pvosGCtx);
9250 if (!pTLCb)
9251 return;
9252
9253 pTLCb->gDsRxRoamStats.running = eWLAN_PAL_TRUE;
9254 pTLCb->gDsRxRoamStats.index = 0;
9255 pTLCb->gDsRxRoamStats.lastTriggerTime = jiffies_to_msecs(jiffies);
9256 pTLCb->gDsRxRoamStats.maxRate = maxRate;
9257 pTLCb->gDsRxRoamStats.minRate = minRate;
9258 pTLCb->gDsRxRoamStats.staId = staId;
9259 pTLCb->gDsRxRoamStats.minPercentage = minPercentage;
9260 pTLCb->gDsRxRoamStats.timeToWait = timeToWait * 1000;
9261 pTLCb->gDsRxRoamStats.intialPktToStart = 0;
9262 pTLCb->gDsRxRoamStats.minPktRequired = minPktRequired;
9263 pTLCb->gDsRxRoamStats.triggerRoamScanfn = triggerRoamScanfn;
9264 pTLCb->gDsRxRoamStats.hHal = hHal;
9265 vos_mem_zero(pTLCb->gDsRxRoamStats.rxRoamStats, ROAM_MAX_INDEX_NUM *
9266 sizeof(WLANTL_RoamTrafficStatsType));
9267 VOS_TRACE(VOS_MODULE_ID_WDI, VOS_TRACE_LEVEL_DEBUG,
9268 "staId=%d, minRate=%d maxRate=%d minPercentage=%d minPktRequired=%d",
9269 staId, minRate, maxRate, minPercentage, minPktRequired);
9270}
9271
9272void static WLANTL_ClearAllRoamStats(WLANTL_CbType *pTLCb)
9273{
9274 pTLCb->gDsRxRoamStats.index = 0;
9275 pTLCb->gDsRxRoamStats.totalPkt = 0;
9276 pTLCb->gDsRxRoamStats.lowRatePkt = 0;
9277 pTLCb->gDsRxRoamStats.intialPktToStart = 0;
9278 vos_mem_zero(pTLCb->gDsRxRoamStats.rxRoamStats, ROAM_MAX_INDEX_NUM *
9279 sizeof(WLANTL_RoamTrafficStatsType));
9280}
9281
9282/*
9283 * WLANTL_ClearRoamStatsTillIndex : This API will clear older data
9284 * at the indexes.
9285 *
9286 * Since its a circular buffer we don't know if we are filling
9287 * data first time or some older data was already present at
9288 * the index. In that case we should clear the older data from
9289 * current index to new index and subtract this data from
9290 * global count as well before filling new one.
9291 */
9292static inline void WLANTL_ClearRoamStatsTillIndex(WLANTL_CbType *pTLCb,
9293 v_U8_t newIndex)
9294{
9295 while (pTLCb->gDsRxRoamStats.index < newIndex)
9296 {
9297 pTLCb->gDsRxRoamStats.index++;
9298 pTLCb->gDsRxRoamStats.totalPkt -=
9299 pTLCb->gDsRxRoamStats.
9300 rxRoamStats[pTLCb->gDsRxRoamStats.index].totalPktRcvd;
9301 pTLCb->gDsRxRoamStats.lowRatePkt -=
9302 pTLCb->gDsRxRoamStats.
9303 rxRoamStats[pTLCb->gDsRxRoamStats.index].lowRateRxPacketsRcvd;
9304 pTLCb->gDsRxRoamStats.
9305 rxRoamStats[pTLCb->gDsRxRoamStats.index].totalPktRcvd = 0;
9306 pTLCb->gDsRxRoamStats.
9307 rxRoamStats[pTLCb->gDsRxRoamStats.index].lowRateRxPacketsRcvd = 0;
9308 }
9309}
9310
9311
9312static void WLANTL_ClearOldPERStats(WLANTL_CbType *pTLCb, v_U8_t incrementCnt)
9313{
9314 v_U8_t newIndex;
9315
9316 newIndex = (pTLCb->gDsRxRoamStats.index + incrementCnt) %
9317 ROAM_MAX_INDEX_NUM;
9318
9319 /* We have crossed the max limit of buffer, clear the stats
9320 * till ROAM_MAX_INDEX_NUM and set index as 0 */
9321 if ((pTLCb->gDsRxRoamStats.index + incrementCnt) >=
9322 ROAM_MAX_INDEX_NUM)
9323 {
9324 WLANTL_ClearRoamStatsTillIndex(pTLCb, ROAM_MAX_INDEX_NUM - 1);
9325 pTLCb->gDsRxRoamStats.index = -1;
9326 }
9327 /* Clear the stats from current index till new index */
9328 WLANTL_ClearRoamStatsTillIndex(pTLCb, newIndex);
9329}
9330
9331/*
9332 * This API implements a circular buffer to store rate stats for a station to
9333 * trigger PER based roam scan.
9334 * API will start monitoring only if DUT gets continues packets which are below
9335 * configured rate. In the upper rates, this should have minimal effect on data
9336 * throughput.
9337 *
9338 * This API will store stats in a circular buffer of size ROAM_MAX_INDEX_NUM
9339 * where each index will have time duration of ROAM_PER_INDEX_TIME.
9340 * Using a buffer instead of counter will help to maintain stats of time
9341 * duration ROAM_PER_INDEX_TIME * ROAM_MAX_INDEX_NUM. Whenever host gets a new
9342 * packet, it will remove last ROAM_PER_INDEX_TIME duration of packets from
9343 * global entry and index entry and fill new data.
9344 *
9345 * Global stats of data also be maintained so that host need not to parse whole
9346 * buffer while checking the trigger condition
9347 * Each of the index will be having the packets stats at duration of
9348 * ROAM_PER_INDEX_TIME from the first packet which arrived in that.
9349 * Global index will be used to calculate new index position to fill once host
9350 * gets a packet.
9351 */
9352static void WLANTL_updatePERStats(WLANTL_CbType *pTLCb,
9353 v_U8_t rateIndex)
9354{
Sravan Kumar Kairamd634cc92016-08-26 16:36:09 +05309355 v_U8_t incrementCnt = 0;
Kapil Guptad90b3862016-06-25 00:42:49 +05309356 v_U64_t currentTime, timeDifference;
9357
9358 /*
9359 * Host will start monitoring Rx rates only if it gets
9360 * MIN_PKTS_TO_START_MONTIOR number of pkts continuously below min rate
9361 * This will make sure we never do this much processing in high
9362 * rates/throughput cases
9363 */
9364
9365 if(pTLCb->gDsRxRoamStats.intialPktToStart < MIN_PKTS_TO_START_MONTIOR)
9366 {
9367 if (gTLRateInfo[rateIndex].phyRate < pTLCb->gDsRxRoamStats.minRate)
9368 pTLCb->gDsRxRoamStats.intialPktToStart++;
9369 else
9370 pTLCb->gDsRxRoamStats.intialPktToStart = 0;
9371 return;
9372 }
9373
9374 currentTime = jiffies_to_msecs(jiffies);
9375 /*
9376 * scan was triggered in last timeToWait time duration
9377 * Wait for timeToWait before monitoring again.
9378 */
9379 if((currentTime - pTLCb->gDsRxRoamStats.lastTriggerTime) <
9380 pTLCb->gDsRxRoamStats.timeToWait)
9381 return;
9382
9383 /* paket above max rate, clear current stats and montior again */
9384 if (gTLRateInfo[rateIndex].phyRate >=
9385 pTLCb->gDsRxRoamStats.maxRate)
9386 {
9387 WLANTL_ClearAllRoamStats(pTLCb);
9388 /* Stop any PER based scan if going on */
9389 pTLCb->gDsRxRoamStats.
9390 triggerRoamScanfn(pTLCb->gDsRxRoamStats.hHal, 0);
9391 return;
9392 }
9393
9394 timeDifference = currentTime -
9395 pTLCb->gDsRxRoamStats.rxRoamStats[pTLCb->gDsRxRoamStats.index].time;
9396
9397 if (timeDifference)
Kapil Guptafe5d92a2016-07-12 18:05:24 +05309398 incrementCnt = do_div(timeDifference, ROAM_PER_INDEX_TIME);
Kapil Guptad90b3862016-06-25 00:42:49 +05309399
9400 /* More that ROAM_PER_INDEX_TIME has esclapsed,
9401 * fill data at new index */
9402 if (incrementCnt)
9403 {
9404 if (incrementCnt > ROAM_MAX_INDEX_NUM)
9405 {
9406 /*
9407 * Clear all stats, these are older than
9408 * ROAM_MAX_INDEX_NUM * ROAM_PER_INDEX_TIME (Max buffer time)
9409 */
9410 WLANTL_ClearAllRoamStats(pTLCb);
9411 pTLCb->gDsRxRoamStats.index = 0;
9412 }
9413 else
9414 WLANTL_ClearOldPERStats(pTLCb, incrementCnt);
9415
9416 pTLCb->gDsRxRoamStats.rxRoamStats
9417 [pTLCb->gDsRxRoamStats.index].time = currentTime;
9418 }
9419
9420 /* If pkt rate below minRate, increment low pkts counts */
9421 if (gTLRateInfo[rateIndex].phyRate <
9422 pTLCb->gDsRxRoamStats.minRate)
9423 {
9424 pTLCb->gDsRxRoamStats.
9425 rxRoamStats[pTLCb->gDsRxRoamStats.index].
9426 lowRateRxPacketsRcvd++;
9427 pTLCb->gDsRxRoamStats.lowRatePkt++;
9428 }
9429 /* Increment total pkts counts */
9430 pTLCb->gDsRxRoamStats.
9431 rxRoamStats[pTLCb->gDsRxRoamStats.index].totalPktRcvd++;
9432 pTLCb->gDsRxRoamStats.totalPkt++;
9433
9434 /* Check if we have reached threshold value to trigger a roam scan */
9435 if ((pTLCb->gDsRxRoamStats.totalPkt != 0) &&
9436 (pTLCb->gDsRxRoamStats.totalPkt >
9437 pTLCb->gDsRxRoamStats.minPktRequired)&&
Kapil Guptafe5d92a2016-07-12 18:05:24 +05309438 ((pTLCb->gDsRxRoamStats.lowRatePkt * 100) >
9439 (pTLCb->gDsRxRoamStats.totalPkt *
9440 pTLCb->gDsRxRoamStats.minPercentage)))
Kapil Guptad90b3862016-06-25 00:42:49 +05309441 {
9442 /* callback handler to trigger a roam scan */
9443 if (pTLCb->gDsRxRoamStats.triggerRoamScanfn)
9444 pTLCb->gDsRxRoamStats.
9445 triggerRoamScanfn(pTLCb->gDsRxRoamStats.hHal, 1);
9446
9447 VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_DEBUG,
9448 "PER Roam: triggerring roam scan totalPkt =%lu lowRatePkt %lu minPktRequired %u minPercentage %d",
9449 (long unsigned int) pTLCb->gDsRxRoamStats.totalPkt,
9450 (long unsigned int) pTLCb->gDsRxRoamStats.lowRatePkt,
9451 (unsigned int) pTLCb->gDsRxRoamStats.minPktRequired,
9452 pTLCb->gDsRxRoamStats.minPercentage);
9453
9454 WLANTL_ClearAllRoamStats(pTLCb);
9455 /* save current time as last trigger time */
9456 pTLCb->gDsRxRoamStats.lastTriggerTime = currentTime;
9457 }
9458}
9459#endif
9460
Jeff Johnson295189b2012-06-20 16:38:30 -07009461/*==========================================================================
9462 FUNCTION WLANTL_STARxAuth
9463
9464 DESCRIPTION
9465 Receive in authenticated state - all data allowed
9466
9467 DEPENDENCIES
9468 The STA must be registered with TL before this function can be called.
9469
9470 PARAMETERS
9471
9472 IN
9473 pvosGCtx: pointer to the global vos context; a handle to TL's
9474 control block can be extracted from its context
9475 ucSTAId: identifier of the station being processed
9476 vosDataBuff: pointer to the rx vos buffer
9477
9478 RETURN VALUE
9479 The result code associated with performing the operation
9480
9481 VOS_STATUS_E_INVAL: invalid input parameters
9482 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
9483 page fault
9484 VOS_STATUS_SUCCESS: Everything is good :)
9485
9486 SIDE EFFECTS
9487
9488============================================================================*/
9489VOS_STATUS
9490WLANTL_STARxAuth
9491(
9492 v_PVOID_t pvosGCtx,
9493 v_U8_t ucSTAId,
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009494 vos_pkt_t** pvosDataBuff,
9495 v_BOOL_t bForwardIAPPwithLLC
Jeff Johnson295189b2012-06-20 16:38:30 -07009496)
9497{
9498 WLANTL_CbType* pTLCb = NULL;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309499 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07009500 v_U8_t ucAsf; /* AMSDU sub frame */
9501 v_U16_t usMPDUDOffset;
9502 v_U8_t ucMPDUHOffset;
9503 v_U16_t usMPDULen;
9504 v_U8_t ucMPDUHLen;
9505 v_U16_t usActualHLen = 0;
9506 v_U8_t ucTid;
Kapil Guptad90b3862016-06-25 00:42:49 +05309507#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
9508 v_U8_t rxRate;
9509 v_U8_t type;
9510#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009511#ifdef FEATURE_WLAN_WAPI
Jeff Johnsone0343db2013-04-03 16:39:24 -07009512 v_U16_t usEtherType = 0;
Abhishek Singh3c47c6c2015-06-15 11:36:08 +05309513 tSirMacMgmtHdr *hdr;
Jeff Johnson295189b2012-06-20 16:38:30 -07009514#endif
9515 v_U16_t usPktLen;
9516 vos_pkt_t* vosDataBuff ;
9517 v_PVOID_t aucBDHeader;
9518 VOS_STATUS vosStatus;
9519 WLANTL_RxMetaInfoType wRxMetaInfo;
Madan Mohan Koyyalamudidfd6aa82012-10-18 20:18:43 -07009520 static v_U8_t ucPMPDUHLen;
Girish Gowli93e3edd2014-05-01 15:42:31 +05309521 v_U32_t* STAMetaInfoPtr;
Jeff Johnson295189b2012-06-20 16:38:30 -07009522 v_U8_t ucEsf=0; /* first subframe of AMSDU flag */
9523 v_U64_t ullcurrentReplayCounter=0; /*current replay counter*/
9524 v_U64_t ullpreviousReplayCounter=0; /*previous replay counter*/
9525 v_U16_t ucUnicastBroadcastType=0; /*It denotes whether received frame is UC or BC*/
Madan Mohan Koyyalamudi4fe30172012-10-18 20:13:40 -07009526 struct _BARFrmStruct *pBarFrame = NULL;
9527
Jeff Johnson295189b2012-06-20 16:38:30 -07009528 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
9529
9530 /*------------------------------------------------------------------------
9531 Sanity check
9532 ------------------------------------------------------------------------*/
9533 if (( NULL == pvosDataBuff ) || ( NULL == ( vosDataBuff = *pvosDataBuff )))
9534 {
9535 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9536 "WLAN TL:Invalid parameter sent on WLANTL_STARxAuth"));
9537 return VOS_STATUS_E_INVAL;
9538 }
9539
9540 /*------------------------------------------------------------------------
9541 Extract TL control block
9542 ------------------------------------------------------------------------*/
9543 pTLCb = VOS_GET_TL_CB(pvosGCtx);
9544 if ( NULL == pTLCb )
9545 {
9546 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9547 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_STARxAuth"));
9548 return VOS_STATUS_E_FAULT;
9549 }
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309550 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
9551
9552 if ( NULL == pClientSTA )
9553 {
9554 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9555 "WLAN TL:Client Memory was not allocated on %s", __func__));
9556 return VOS_STATUS_E_FAILURE;
9557 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009558
9559 /*------------------------------------------------------------------------
9560 Extract BD header and check if valid
9561 ------------------------------------------------------------------------*/
9562 WDA_DS_PeekRxPacketInfo( vosDataBuff, (v_PVOID_t)&aucBDHeader, 0 );
9563
9564 ucMPDUHOffset = (v_U8_t)WDA_GET_RX_MPDU_HEADER_OFFSET(aucBDHeader);
9565 usMPDUDOffset = (v_U16_t)WDA_GET_RX_MPDU_DATA_OFFSET(aucBDHeader);
9566 usMPDULen = (v_U16_t)WDA_GET_RX_MPDU_LEN(aucBDHeader);
9567 ucMPDUHLen = (v_U8_t)WDA_GET_RX_MPDU_HEADER_LEN(aucBDHeader);
9568 ucTid = (v_U8_t)WDA_GET_RX_TID(aucBDHeader);
Kapil Guptad90b3862016-06-25 00:42:49 +05309569#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
9570 rxRate = (v_U8_t)WDA_GET_RX_MAC_RATE_IDX(aucBDHeader);
9571 type = (v_U8_t)WDA_GET_RX_TYPE(aucBDHeader);
9572#endif
Hanumanth Reddy Pothula57323632017-12-06 17:55:09 +05309573 pClientSTA->rate_idx = (v_U8_t)WDA_GET_RX_MAC_RATE_IDX(aucBDHeader);
Jeff Johnson295189b2012-06-20 16:38:30 -07009574
Madan Mohan Koyyalamudi4fe30172012-10-18 20:13:40 -07009575 /* Fix for a hardware bug.
9576 * H/W does not update the tid field in BD header for BAR frames.
9577 * Fix is to read the tid field from MAC header of BAR frame */
9578 if( (WDA_GET_RX_TYPE(aucBDHeader) == SIR_MAC_CTRL_FRAME) &&
9579 (WDA_GET_RX_SUBTYPE(aucBDHeader) == SIR_MAC_CTRL_BAR))
9580 {
9581 pBarFrame = (struct _BARFrmStruct *)(WDA_GET_RX_MAC_HEADER(aucBDHeader));
9582 ucTid = pBarFrame->barControl.numTID;
9583 }
9584
Jeff Johnson295189b2012-06-20 16:38:30 -07009585 /*Host based replay check is needed for unicast data frames*/
9586 ucUnicastBroadcastType = (v_U16_t)WDA_IS_RX_BCAST(aucBDHeader);
Jeff Johnson295189b2012-06-20 16:38:30 -07009587 if(0 != ucMPDUHLen)
9588 {
9589 ucPMPDUHLen = ucMPDUHLen;
9590 }
9591
9592 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
9593 "WLAN TL:BD header processing data: HO %d DO %d Len %d HLen %d"
9594 " Tid %d BD %d",
9595 ucMPDUHOffset, usMPDUDOffset, usMPDULen, ucMPDUHLen, ucTid,
9596 WLANHAL_RX_BD_HEADER_SIZE));
9597
9598 vos_pkt_get_packet_length( vosDataBuff, &usPktLen);
9599
9600 if ( VOS_STATUS_SUCCESS != WDA_DS_TrimRxPacketInfo( vosDataBuff ) )
9601 {
9602 if((WDA_GET_RX_ASF(aucBDHeader) && !WDA_GET_RX_ESF(aucBDHeader)))
9603 {
9604 /* AMSDU case, ucMPDUHOffset = 0
9605 * it should be hancdled seperatly */
9606 if(( usMPDUDOffset > ucMPDUHOffset ) &&
9607 ( usMPDULen >= ucMPDUHLen ) && ( usPktLen >= usMPDULen ) &&
9608 ( !WLANTL_TID_INVALID(ucTid) ))
9609 {
9610 ucMPDUHOffset = usMPDUDOffset - WLANTL_MPDU_HEADER_LEN;
9611 }
9612 else
9613 {
9614 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
9615 "WLAN TL:BD header corrupted - dropping packet"));
9616 /* Drop packet */
9617 vos_pkt_return_packet(vosDataBuff);
9618 return VOS_STATUS_SUCCESS;
9619 }
9620 }
9621 else
9622 {
9623 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
9624 "WLAN TL:BD header corrupted - dropping packet"));
9625 /* Drop packet */
9626 vos_pkt_return_packet(vosDataBuff);
9627 return VOS_STATUS_SUCCESS;
9628 }
9629 }
9630
Abhishek Singh00b71972016-01-07 10:51:04 +05309631#ifdef WLAN_FEATURE_RMC
9632 if (pTLCb->multicastDuplicateDetectionEnabled &&
9633 (WLAN_STA_IBSS == pClientSTA->wSTADesc.wSTAType) &&
9634 WLANTL_IS_DATA_FRAME(WDA_GET_RX_TYPE_SUBTYPE(aucBDHeader)))
9635 {
9636 /*
9637 * Multicast duplicate detection is only for frames received in
9638 * IBSS mode.
9639 */
9640 if (VOS_TRUE == WLANTL_IsDuplicateMcastFrm(pClientSTA, vosDataBuff))
9641 {
9642 pTLCb->mcastDupCnt++;
9643 /* Duplicate multicast data packet, drop the packet */
9644 vos_pkt_return_packet(vosDataBuff);
9645 return VOS_STATUS_SUCCESS;
9646 }
9647 }
9648#endif /* WLAN_FEATURE_RMC */
9649
Jeff Johnson295189b2012-06-20 16:38:30 -07009650#ifdef FEATURE_WLAN_WAPI
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309651 if ( pClientSTA->wSTADesc.ucIsWapiSta )
Jeff Johnson295189b2012-06-20 16:38:30 -07009652 {
9653 vosStatus = WLANTL_GetEtherType(aucBDHeader, vosDataBuff, ucMPDUHLen, &usEtherType);
9654 if( VOS_IS_STATUS_SUCCESS(vosStatus) )
9655 {
9656 if ( WLANTL_LLC_WAI_TYPE == usEtherType )
Abhishek Singh3c47c6c2015-06-15 11:36:08 +05309657 {
9658 hdr = WDA_GET_RX_MAC_HEADER(aucBDHeader);
9659 if ( hdr->fc.wep )
Jeff Johnson295189b2012-06-20 16:38:30 -07009660 {
9661 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9662 "WLAN TL:WAI frame was received encrypted - dropping"));
9663 /* Drop packet */
9664 /*Temporary fix added to fix wapi rekey issue*/
Abhishek Singh3c47c6c2015-06-15 11:36:08 +05309665 vos_pkt_return_packet(vosDataBuff);
9666 return vosStatus; //returning success
Jeff Johnson295189b2012-06-20 16:38:30 -07009667 }
9668 }
9669 else
9670 {
9671 if ( WLANHAL_RX_IS_UNPROTECTED_WPI_FRAME(aucBDHeader) )
9672 {
9673 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9674 "WLAN TL:Non-WAI frame was received unencrypted - dropping"));
9675 /* Drop packet */
9676 vos_pkt_return_packet(vosDataBuff);
9677 return vosStatus; //returning success
9678 }
9679 }
9680 }
9681 else //could not extract EtherType - this should not happen
9682 {
9683 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009684 "WLAN TL:Could not extract EtherType"));
9685 //Packet is already freed
Jeff Johnson295189b2012-06-20 16:38:30 -07009686 return vosStatus; //returning failure
Jeff Johnson295189b2012-06-20 16:38:30 -07009687 }
9688 }
9689#endif /* FEATURE_WLAN_WAPI */
9690
9691 /*----------------------------------------------------------------------
9692 Increment receive counter
9693 !! not sure this is the best place to increase this - pkt might be
9694 dropped below or delayed in TL's queues
9695 - will leave it here for now
9696 ------------------------------------------------------------------------*/
Madan Mohan Koyyalamudic0e5bd82012-09-18 17:12:27 -07009697 if ( !WLANTL_TID_INVALID( ucTid) )
9698 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309699 pClientSTA->auRxCount[ucTid]++;
Madan Mohan Koyyalamudic0e5bd82012-09-18 17:12:27 -07009700 }
9701 else
9702 {
9703 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9704 "WLAN TL:Invalid tid %d (Station ID %d) on %s",
9705 ucTid, ucSTAId, __func__));
Hanumantha Reddy Pothula0de10802016-02-11 17:29:27 +05309706 vos_pkt_return_packet(vosDataBuff);
9707 return VOS_STATUS_E_FAILURE;
Madan Mohan Koyyalamudic0e5bd82012-09-18 17:12:27 -07009708 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009709
Kapil Guptad90b3862016-06-25 00:42:49 +05309710#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
9711 if (pTLCb->gDsRxRoamStats.running &&
9712 (ucSTAId == pTLCb->gDsRxRoamStats.staId) &&
9713 (rxRate < WLANTL_MAX_RATE_NUM) && (type == SIR_MAC_DATA_FRAME))
9714 {
9715 WLANTL_updatePERStats(pTLCb, rxRate);
9716 }
9717#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009718 /*------------------------------------------------------------------------
9719 Check if AMSDU and send for processing if so
9720 ------------------------------------------------------------------------*/
9721 ucAsf = (v_U8_t)WDA_GET_RX_ASF(aucBDHeader);
9722
9723 if ( 0 != ucAsf )
9724 {
9725 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
9726 "WLAN TL:Packet is AMSDU sub frame - sending for completion"));
9727 vosStatus = WLANTL_AMSDUProcess( pvosGCtx, &vosDataBuff, aucBDHeader, ucSTAId,
9728 ucMPDUHLen, usMPDULen );
9729 if(NULL == vosDataBuff)
9730 {
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009731 //Packet is already freed
Jeff Johnson295189b2012-06-20 16:38:30 -07009732 return VOS_STATUS_SUCCESS;
9733 }
9734 }
9735 /* After AMSDU header handled
9736 * AMSDU frame just same with normal frames */
9737 /*-------------------------------------------------------------------
9738 Translating header if necesary
9739 !! Fix me: rmv comments below
9740 ----------------------------------------------------------------------*/
9741 if (( 0 == WDA_GET_RX_FT_DONE(aucBDHeader) ) &&
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309742 ( 0 != pClientSTA->wSTADesc.ucSwFrameRXXlation) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07009743 ( WLANTL_IS_DATA_FRAME(WDA_GET_RX_TYPE_SUBTYPE(aucBDHeader)) ))
9744 {
9745 if(0 == ucMPDUHLen)
9746 {
9747 ucMPDUHLen = ucPMPDUHLen;
9748 }
9749 if (usMPDUDOffset > ucMPDUHOffset)
9750 {
9751 usActualHLen = usMPDUDOffset - ucMPDUHOffset;
9752 }
9753 vosStatus = WLANTL_Translate80211To8023Header( vosDataBuff, &vosStatus, usActualHLen,
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009754 ucMPDUHLen, pTLCb, ucSTAId, bForwardIAPPwithLLC);
Jeff Johnson295189b2012-06-20 16:38:30 -07009755
9756 if ( VOS_STATUS_SUCCESS != vosStatus )
9757 {
Kaushik, Sushante386ee12014-05-01 15:50:52 +05309758 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
Jeff Johnson295189b2012-06-20 16:38:30 -07009759 "WLAN TL:Failed to translate from 802.11 to 802.3 - dropping"));
9760 /* Drop packet */
9761 vos_pkt_return_packet(vosDataBuff);
9762 return vosStatus;
9763 }
9764 }
9765 /* Softap requires additional Info such as Destination STAID and Access
9766 Category. Voschain or Buffer returned by BA would be unchain and this
9767 Meta Data would help in routing the packets to appropriate Destination */
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309768 if( WLAN_STA_SOFTAP == pClientSTA->wSTADesc.wSTAType)
Jeff Johnson295189b2012-06-20 16:38:30 -07009769 {
Arun Kumar Khandavalli37cfc222014-01-09 22:32:40 +05309770 STAMetaInfoPtr = (v_U32_t *)(uintptr_t)(ucTid | (WDA_GET_RX_ADDR3_IDX(aucBDHeader) << WLANTL_STAID_OFFSET));
Jeff Johnson295189b2012-06-20 16:38:30 -07009771 vos_pkt_set_user_data_ptr( vosDataBuff, VOS_PKT_USER_DATA_ID_TL,
9772 (v_PVOID_t)STAMetaInfoPtr);
9773 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009774
9775 /*------------------------------------------------------------------------
9776 Check to see if re-ordering session is in place
9777 ------------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309778 if ( 0 != pClientSTA->atlBAReorderInfo[ucTid].ucExists )
Jeff Johnson295189b2012-06-20 16:38:30 -07009779 {
9780 WLANTL_MSDUReorder( pTLCb, &vosDataBuff, aucBDHeader, ucSTAId, ucTid );
9781 }
9782
Sravan Kumar Kairam04f093a2017-11-16 19:59:05 +05309783if(WLANTL_IS_DATA_FRAME(WDA_GET_RX_TYPE_SUBTYPE(aucBDHeader)) &&
9784 (0 == ucUnicastBroadcastType)
Jeff Johnson295189b2012-06-20 16:38:30 -07009785#ifdef FEATURE_ON_CHIP_REORDERING
9786 && (WLANHAL_IsOnChipReorderingEnabledForTID(pvosGCtx, ucSTAId, ucTid) != TRUE)
9787#endif
9788)
9789{
9790 /* replay check code : check whether replay check is needed or not */
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309791 if(VOS_TRUE == pClientSTA->ucIsReplayCheckValid)
Jeff Johnson295189b2012-06-20 16:38:30 -07009792 {
9793 /* replay check is needed for the station */
9794
9795 /* check whether frame is AMSDU frame */
9796 if ( 0 != ucAsf )
9797 {
9798 /* Since virgo can't send AMSDU frames this leg of the code
9799 was not tested properly, it needs to be tested properly*/
9800 /* Frame is AMSDU frame. As per 802.11n only first
9801 subframe will have replay counter */
9802 ucEsf = WDA_GET_RX_ESF( aucBDHeader );
9803 if( 0 != ucEsf )
9804 {
9805 v_BOOL_t status;
9806 /* Getting 48-bit replay counter from the RX BD */
9807 ullcurrentReplayCounter = WDA_DS_GetReplayCounter(aucBDHeader);
9808
9809 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Arif Hussainf2b00992013-11-17 21:46:15 -08009810 "WLAN TL: AMSDU currentReplayCounter [0x%llX]",ullcurrentReplayCounter);
Jeff Johnson295189b2012-06-20 16:38:30 -07009811
9812 /* Getting 48-bit previous replay counter from TL control block */
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309813 ullpreviousReplayCounter = pClientSTA->ullReplayCounter[ucTid];
Jeff Johnson295189b2012-06-20 16:38:30 -07009814
9815 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Arif Hussainf2b00992013-11-17 21:46:15 -08009816 "WLAN TL: AMSDU previousReplayCounter [0x%llX]",ullpreviousReplayCounter);
Jeff Johnson295189b2012-06-20 16:38:30 -07009817
9818 /* It is first subframe of AMSDU thus it
9819 conatains replay counter perform the
9820 replay check for this first subframe*/
9821 status = WLANTL_IsReplayPacket( ullcurrentReplayCounter, ullpreviousReplayCounter);
9822 if(VOS_FALSE == status)
9823 {
9824 /* Not a replay paket, update previous replay counter in TL CB */
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309825 pClientSTA->ullReplayCounter[ucTid] = ullcurrentReplayCounter;
Jeff Johnson295189b2012-06-20 16:38:30 -07009826 }
9827 else
9828 {
9829 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Arif Hussainf2b00992013-11-17 21:46:15 -08009830 "WLAN TL: AMSDU Drop the replay packet with PN : [0x%llX]",ullcurrentReplayCounter);
Jeff Johnson295189b2012-06-20 16:38:30 -07009831
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309832 pClientSTA->ulTotalReplayPacketsDetected++;
Jeff Johnson295189b2012-06-20 16:38:30 -07009833 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Arif Hussainf2b00992013-11-17 21:46:15 -08009834 "WLAN TL: AMSDU total dropped replay packets on STA ID %X is [0x%X]",
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309835 ucSTAId, pClientSTA->ulTotalReplayPacketsDetected);
Jeff Johnson295189b2012-06-20 16:38:30 -07009836
9837 /* Drop the packet */
9838 vos_pkt_return_packet(vosDataBuff);
9839 return VOS_STATUS_SUCCESS;
9840 }
9841 }
9842 }
9843 else
9844 {
9845 v_BOOL_t status;
9846
9847 /* Getting 48-bit replay counter from the RX BD */
9848 ullcurrentReplayCounter = WDA_DS_GetReplayCounter(aucBDHeader);
9849
9850 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Arif Hussainf2b00992013-11-17 21:46:15 -08009851 "WLAN TL: Non-AMSDU currentReplayCounter [0x%llX]",ullcurrentReplayCounter);
Jeff Johnson295189b2012-06-20 16:38:30 -07009852
9853 /* Getting 48-bit previous replay counter from TL control block */
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309854 ullpreviousReplayCounter = pClientSTA->ullReplayCounter[ucTid];
Jeff Johnson295189b2012-06-20 16:38:30 -07009855
9856 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Arif Hussainf2b00992013-11-17 21:46:15 -08009857 "WLAN TL: Non-AMSDU previousReplayCounter [0x%llX]",ullpreviousReplayCounter);
Jeff Johnson295189b2012-06-20 16:38:30 -07009858
9859 /* It is not AMSDU frame so perform
9860 reaply check for each packet, as
Sravan Kumar Kairam04f093a2017-11-16 19:59:05 +05309861 each packet contains valid replay counter*/
9862 if (vosDataBuff != NULL) {
9863 if (vos_is_pkt_chain(vosDataBuff)) {
9864 WLANTL_ReorderReplayCheck(pClientSTA, &vosDataBuff, ucTid);
9865 } else {
9866 status = WLANTL_IsReplayPacket(ullcurrentReplayCounter,
9867 ullpreviousReplayCounter);
9868 if(VOS_FALSE == status) {
9869 /* Not a replay paket, update previous replay counter in TL CB */
9870 pClientSTA->ullReplayCounter[ucTid] = ullcurrentReplayCounter;
9871 } else {
9872 VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9873 "WLAN TL: Non AMSDU Drop replay packet with PN: [0x%llX], prevPN: [0x%llx]",
9874 ullcurrentReplayCounter, ullpreviousReplayCounter);
Jeff Johnson295189b2012-06-20 16:38:30 -07009875
Sravan Kumar Kairam04f093a2017-11-16 19:59:05 +05309876 pClientSTA->ulTotalReplayPacketsDetected++;
9877 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9878 "WLAN TL: Non AMSDU total dropped replay packets on STA ID %X is [0x%X]",
9879 ucSTAId, pClientSTA->ulTotalReplayPacketsDetected);
Jeff Johnson295189b2012-06-20 16:38:30 -07009880
Sravan Kumar Kairam04f093a2017-11-16 19:59:05 +05309881 /* Repaly packet, drop the packet */
9882 vos_pkt_return_packet(vosDataBuff);
9883 return VOS_STATUS_SUCCESS;
9884 }
9885 }
9886 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009887 }
Sravan Kumar Kairam04f093a2017-11-16 19:59:05 +05309888 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009889}
Sravan Kumar Kairam04f093a2017-11-16 19:59:05 +05309890
Jeff Johnson295189b2012-06-20 16:38:30 -07009891/*It is a broadast packet DPU has already done replay check for
9892 broadcast packets no need to do replay check of these packets*/
Jeff Johnson295189b2012-06-20 16:38:30 -07009893
9894 if ( NULL != vosDataBuff )
9895 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309896 if( WLAN_STA_SOFTAP == pClientSTA->wSTADesc.wSTAType)
Jeff Johnson295189b2012-06-20 16:38:30 -07009897 {
9898 WLANTL_FwdPktToHDD( pvosGCtx, vosDataBuff, ucSTAId );
9899 }
9900 else
Jeff Johnson295189b2012-06-20 16:38:30 -07009901 {
9902 wRxMetaInfo.ucUP = ucTid;
Shailender Karmuchi13c0d082013-03-26 14:41:39 -07009903 wRxMetaInfo.rssiAvg = pClientSTA->rssiAvg;
Gopichand Nakkala4a2fc1a2013-05-17 16:59:39 +05309904#ifdef FEATURE_WLAN_TDLS
9905 if (WLAN_STA_TDLS == pClientSTA->wSTADesc.wSTAType)
9906 {
9907 wRxMetaInfo.isStaTdls = TRUE;
9908 }
9909 else
9910 {
9911 wRxMetaInfo.isStaTdls = FALSE;
9912 }
9913#endif
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309914 pClientSTA->pfnSTARx( pvosGCtx, vosDataBuff, ucSTAId,
Jeff Johnson295189b2012-06-20 16:38:30 -07009915 &wRxMetaInfo );
9916 }
9917 }/* if not NULL */
9918
9919 return VOS_STATUS_SUCCESS;
9920}/* WLANTL_STARxAuth */
9921
9922
9923/*==========================================================================
9924 FUNCTION WLANTL_STARxDisc
9925
9926 DESCRIPTION
9927 Receive in disconnected state - no data allowed
9928
9929 DEPENDENCIES
9930 The STA must be registered with TL before this function can be called.
9931
9932 PARAMETERS
9933
9934 IN
9935 pvosGCtx: pointer to the global vos context; a handle to TL's
9936 control block can be extracted from its context
9937 ucSTAId: identifier of the station being processed
9938 vosDataBuff: pointer to the rx vos buffer
9939
9940 RETURN VALUE
9941 The result code associated with performing the operation
9942
9943 VOS_STATUS_SUCCESS: Everything is good :)
9944
9945 SIDE EFFECTS
9946
9947============================================================================*/
9948VOS_STATUS
9949WLANTL_STARxDisc
9950(
9951 v_PVOID_t pvosGCtx,
9952 v_U8_t ucSTAId,
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009953 vos_pkt_t** pvosDataBuff,
9954 v_BOOL_t bForwardIAPPwithLLC
Jeff Johnson295189b2012-06-20 16:38:30 -07009955)
9956{
9957 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
9958
9959 /*------------------------------------------------------------------------
9960 Sanity check
9961 ------------------------------------------------------------------------*/
9962 if (( NULL == pvosDataBuff ) || ( NULL == *pvosDataBuff ))
9963 {
9964 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9965 "WLAN TL:Invalid parameter sent on WLANTL_STARxDisc"));
9966 return VOS_STATUS_E_INVAL;
9967 }
9968
9969 /*------------------------------------------------------------------------
9970 Error - drop packet
9971 ------------------------------------------------------------------------*/
9972 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9973 "WLAN TL:Packet should not be received in state disconnected"
9974 " - dropping"));
9975 vos_pkt_return_packet(*pvosDataBuff);
9976 *pvosDataBuff = NULL;
9977
9978 return VOS_STATUS_SUCCESS;
9979}/* WLANTL_STARxDisc */
9980
9981/*==========================================================================
9982 Processing main loops for MAIN and TX threads
9983 ==========================================================================*/
9984
9985/*==========================================================================
9986 FUNCTION WLANTL_McProcessMsg
9987
9988 DESCRIPTION
9989 Called by VOSS when a message was serialized for TL through the
9990 main thread/task.
9991
9992 DEPENDENCIES
9993 The TL must be initialized before this function can be called.
9994
9995 PARAMETERS
9996
9997 IN
9998 pvosGCtx: pointer to the global vos context; a handle to TL's
9999 control block can be extracted from its context
10000 message: type and content of the message
10001
10002
10003 RETURN VALUE
10004 The result code associated with performing the operation
10005
10006 VOS_STATUS_E_INVAL: invalid input parameters
10007 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
10008 page fault
10009 VOS_STATUS_SUCCESS: Everything is good :)
10010
10011 SIDE EFFECTS
10012
10013============================================================================*/
10014VOS_STATUS
10015WLANTL_McProcessMsg
10016(
10017 v_PVOID_t pvosGCtx,
10018 vos_msg_t* message
10019)
10020{
10021 WLANTL_CbType* pTLCb = NULL;
10022 tAddBAInd* ptAddBaInd = NULL;
10023 tDelBAInd* ptDelBaInd = NULL;
10024 tAddBARsp* ptAddBaRsp = NULL;
10025 vos_msg_t vosMessage;
10026 VOS_STATUS vosStatus;
10027 tpFlushACRsp FlushACRspPtr;
10028 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
10029
10030 /*------------------------------------------------------------------------
10031 Sanity check
10032 ------------------------------------------------------------------------*/
10033 if ( NULL == message )
10034 {
10035 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
10036 "WLAN TL:Invalid parameter sent on WLANTL_ProcessMainMessage"));
10037 return VOS_STATUS_E_INVAL;
10038 }
10039
10040 /*------------------------------------------------------------------------
10041 Extract TL control block
10042 ------------------------------------------------------------------------*/
10043 pTLCb = VOS_GET_TL_CB(pvosGCtx);
10044 if ( NULL == pTLCb )
10045 {
10046 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
10047 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_ProcessMainMessage"));
10048 return VOS_STATUS_E_FAULT;
10049 }
10050
10051 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
10052 "WLAN TL:Received message: %d through main flow", message->type));
10053
10054 switch( message->type )
10055 {
10056 case WDA_TL_FLUSH_AC_RSP:
10057 // Extract the message from the message body
10058 FlushACRspPtr = (tpFlushACRsp)(message->bodyptr);
10059 // Make sure the call back function is not null.
Tushnim Bhattacharyya5dd94562013-03-20 20:15:03 -070010060 if ( NULL == pTLCb->tlBAPClient.pfnFlushOpCompleteCb )
10061 {
10062 VOS_ASSERT(0);
10063 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
10064 "WLAN TL:Invalid TL pointer pfnFlushOpCompleteCb"));
10065 return VOS_STATUS_E_FAULT;
10066 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010067
10068 TLLOG2(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
10069 "Received message: Flush complete received by TL"));
10070
10071 // Since we have the response back from HAL, just call the BAP client
10072 // registered call back from TL. There is only 1 possible
10073 // BAP client. So directly reference tlBAPClient
10074 pTLCb->tlBAPClient.pfnFlushOpCompleteCb( pvosGCtx,
10075 FlushACRspPtr->ucSTAId,
10076 FlushACRspPtr->ucTid, FlushACRspPtr->status );
10077
10078 // Free the PAL memory, we are done with it.
10079 TLLOG2(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
Jeff Johnsonddec6482017-09-19 08:33:57 -070010080 "Flush complete received by TL: Freeing %pK", FlushACRspPtr));
Jeff Johnson295189b2012-06-20 16:38:30 -070010081 vos_mem_free((v_VOID_t *)FlushACRspPtr);
10082 break;
10083
10084 case WDA_HDD_ADDBA_REQ:
10085 ptAddBaInd = (tAddBAInd*)(message->bodyptr);
10086 vosStatus = WLANTL_BaSessionAdd( pvosGCtx,
10087 ptAddBaInd->baSession.baSessionID,
10088 ptAddBaInd->baSession.STAID,
10089 ptAddBaInd->baSession.baTID,
10090 (v_U32_t)ptAddBaInd->baSession.baBufferSize,
10091 ptAddBaInd->baSession.winSize,
10092 ptAddBaInd->baSession.SSN);
10093 ptAddBaRsp = vos_mem_malloc(sizeof(*ptAddBaRsp));
10094
10095 if ( NULL == ptAddBaRsp )
10096 {
10097 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
10098 "WLAN TL: fatal failure, cannot allocate BA Rsp structure"));
10099 VOS_ASSERT(0);
10100 return VOS_STATUS_E_NOMEM;
10101 }
10102
10103 if ( VOS_STATUS_SUCCESS == vosStatus )
10104 {
10105 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
10106 "WLAN TL: Sending success indication to HAL for ADD BA"));
10107 /*Send success*/
10108 ptAddBaRsp->mesgType = WDA_HDD_ADDBA_RSP;
10109 vosMessage.type = WDA_HDD_ADDBA_RSP;
10110 }
10111 else
10112 {
10113 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
10114 "WLAN TL: Sending failure indication to HAL for ADD BA"));
10115
10116 /*Send failure*/
10117 ptAddBaRsp->mesgType = WDA_BA_FAIL_IND;
10118 vosMessage.type = WDA_BA_FAIL_IND;
10119 }
10120
10121 ptAddBaRsp->mesgLen = sizeof(tAddBARsp);
10122 ptAddBaRsp->baSessionID = ptAddBaInd->baSession.baSessionID;
10123 /* This is default, reply win size has to be handled BA module, FIX THIS */
10124 ptAddBaRsp->replyWinSize = WLANTL_MAX_WINSIZE;
10125 vosMessage.bodyptr = ptAddBaRsp;
10126
10127 vos_mq_post_message( VOS_MQ_ID_WDA, &vosMessage );
10128 WLANTL_McFreeMsg (pvosGCtx, message);
10129 break;
10130 case WDA_DELETEBA_IND:
10131 ptDelBaInd = (tDelBAInd*)(message->bodyptr);
10132 vosStatus = WLANTL_BaSessionDel(pvosGCtx,
10133 ptDelBaInd->staIdx,
10134 ptDelBaInd->baTID);
10135
10136 if ( VOS_STATUS_SUCCESS != vosStatus )
10137 {
10138 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
10139 "WLAN TL: Failed to del BA session STA:%d TID:%d Status :%d",
10140 ptDelBaInd->staIdx,
10141 ptDelBaInd->baTID,
10142 vosStatus));
10143 }
10144 WLANTL_McFreeMsg (pvosGCtx, message);
10145 break;
10146 default:
10147 /*no processing for now*/
10148 break;
10149 }
10150
10151 return VOS_STATUS_SUCCESS;
10152}/* WLANTL_ProcessMainMessage */
10153
10154/*==========================================================================
10155 FUNCTION WLANTL_McFreeMsg
10156
10157 DESCRIPTION
10158 Called by VOSS to free a given TL message on the Main thread when there
10159 are messages pending in the queue when the whole system is been reset.
10160 For now, TL does not allocate any body so this function shout translate
10161 into a NOOP
10162
10163 DEPENDENCIES
10164 The TL must be initialized before this function can be called.
10165
10166 PARAMETERS
10167
10168 IN
10169 pvosGCtx: pointer to the global vos context; a handle to TL's
10170 control block can be extracted from its context
10171 message: type and content of the message
10172
10173
10174 RETURN VALUE
10175 The result code associated with performing the operation
10176
10177 VOS_STATUS_SUCCESS: Everything is good :)
10178
10179 SIDE EFFECTS
10180
10181============================================================================*/
10182VOS_STATUS
10183WLANTL_McFreeMsg
10184(
10185 v_PVOID_t pvosGCtx,
10186 vos_msg_t* message
10187)
10188{
10189 WLANTL_CbType* pTLCb = NULL;
10190 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
10191
10192 /*------------------------------------------------------------------------
10193 Sanity check
10194 ------------------------------------------------------------------------*/
10195 if ( NULL == message )
10196 {
10197 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
10198 "WLAN TL:Invalid parameter sent on WLANTL_McFreeMsg"));
10199 return VOS_STATUS_E_INVAL;
10200 }
10201
10202 /*------------------------------------------------------------------------
10203 Extract TL control block
10204 ------------------------------------------------------------------------*/
10205 pTLCb = VOS_GET_TL_CB(pvosGCtx);
10206 if ( NULL == pTLCb )
10207 {
10208 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
10209 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_McFreeMsg"));
10210 return VOS_STATUS_E_FAULT;
10211 }
10212
10213 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
10214 "WLAN TL:Received message: %d through main free", message->type));
10215
10216 switch( message->type )
10217 {
10218 case WDA_HDD_ADDBA_REQ:
10219 case WDA_DELETEBA_IND:
10220 /*vos free body pointer*/
10221 vos_mem_free(message->bodyptr);
10222 message->bodyptr = NULL;
10223 break;
10224 default:
10225 /*no processing for now*/
10226 break;
10227 }
10228
10229 return VOS_STATUS_SUCCESS;
10230}/*WLANTL_McFreeMsg*/
10231
10232/*==========================================================================
10233 FUNCTION WLANTL_TxProcessMsg
10234
10235 DESCRIPTION
10236 Called by VOSS when a message was serialized for TL through the
10237 tx thread/task.
10238
10239 DEPENDENCIES
10240 The TL must be initialized before this function can be called.
10241
10242 PARAMETERS
10243
10244 IN
10245 pvosGCtx: pointer to the global vos context; a handle to TL's
10246 control block can be extracted from its context
10247 message: type and content of the message
10248
10249
10250 RETURN VALUE
10251 The result code associated with performing the operation
10252
10253 VOS_STATUS_E_INVAL: invalid input parameters
10254 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
10255 page fault
10256 VOS_STATUS_SUCCESS: Everything is good :)
10257
10258 Other values can be returned as a result of a function call, please check
10259 corresponding API for more info.
10260 SIDE EFFECTS
10261
10262============================================================================*/
10263VOS_STATUS
10264WLANTL_TxProcessMsg
10265(
10266 v_PVOID_t pvosGCtx,
10267 vos_msg_t* message
10268)
10269{
10270 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070010271 void (*callbackRoutine) (void *callbackContext);
10272 void *callbackContext;
Jeff Johnson295189b2012-06-20 16:38:30 -070010273 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
10274
10275 /*------------------------------------------------------------------------
10276 Sanity check
10277 ------------------------------------------------------------------------*/
10278 if ( NULL == message )
10279 {
10280 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
10281 "WLAN TL:Invalid parameter sent on WLANTL_ProcessTxMessage"));
10282 return VOS_STATUS_E_INVAL;
10283 }
10284
10285 /*------------------------------------------------------------------------
10286 Process message
10287 ------------------------------------------------------------------------*/
10288 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
10289 "WLAN TL:Received message: %d through tx flow", message->type));
10290
10291 switch( message->type )
10292 {
10293 case WLANTL_TX_SIG_SUSPEND:
10294 vosStatus = WLANTL_SuspendCB( pvosGCtx,
10295 (WLANTL_SuspendCBType)message->bodyptr,
10296 message->reserved);
10297 break;
10298 case WLANTL_TX_RES_NEEDED:
10299 vosStatus = WLANTL_GetTxResourcesCB( pvosGCtx );
10300 break;
Katya Nigam664f5032014-05-05 12:24:32 +053010301
Jeff Johnson295189b2012-06-20 16:38:30 -070010302 case WDA_DS_TX_START_XMIT:
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +053010303 WLANTL_ClearTxXmitPending(pvosGCtx);
10304 vosStatus = WDA_DS_TxFrames( pvosGCtx );
Jeff Johnson295189b2012-06-20 16:38:30 -070010305 break;
10306
10307 case WDA_DS_FINISH_ULA:
Arun Kumar Khandavalli8d1979d2014-01-09 21:12:25 +053010308 callbackContext = message->bodyptr;
10309 callbackRoutine = message->callback;
10310 if ( NULL != callbackRoutine )
10311 {
10312 callbackRoutine(callbackContext);
10313 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010314 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010315
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +053010316 case WLANTL_TX_SNAPSHOT:
10317 /*Dumping TL State and then continuing to print
10318 the DXE Dump*/
10319 WLANTL_TxThreadDebugHandler(pvosGCtx);
10320 WDA_TransportChannelDebug(NULL, VOS_TRUE, VOS_FALSE);
10321 break;
10322
Mihir Shetefd62d9d2014-08-06 15:08:21 +053010323 case WLANTL_TX_FATAL_ERROR:
10324 WLANTL_FatalErrorHandler(pvosGCtx);
10325 break;
10326
Mihir Shete327c2ab2014-11-13 15:17:02 +053010327 case WLANTL_TX_FW_DEBUG:
Siddharth Bhal68115602015-01-18 20:44:55 +053010328 vos_fwDumpReq(274, 0, 0, 0, 0, 1); //Async event
Mihir Shete327c2ab2014-11-13 15:17:02 +053010329 break;
10330
Sravan Kumar Kairame9d186c2015-11-27 23:37:02 +053010331 case WLANTL_TX_KICKDXE:
10332 WDA_TransportKickDxe();
10333 break;
10334
Jeff Johnson295189b2012-06-20 16:38:30 -070010335 default:
10336 /*no processing for now*/
10337 break;
10338 }
10339
10340 return vosStatus;
10341}/* WLANTL_TxProcessMsg */
10342
10343/*==========================================================================
10344 FUNCTION WLANTL_McFreeMsg
10345
10346 DESCRIPTION
10347 Called by VOSS to free a given TL message on the Main thread when there
10348 are messages pending in the queue when the whole system is been reset.
10349 For now, TL does not allocate any body so this function shout translate
10350 into a NOOP
10351
10352 DEPENDENCIES
10353 The TL must be initialized before this function can be called.
10354
10355 PARAMETERS
10356
10357 IN
10358 pvosGCtx: pointer to the global vos context; a handle to TL's
10359 control block can be extracted from its context
10360 message: type and content of the message
10361
10362
10363 RETURN VALUE
10364 The result code associated with performing the operation
10365
10366 VOS_STATUS_SUCCESS: Everything is good :)
10367
10368 SIDE EFFECTS
10369
10370============================================================================*/
10371VOS_STATUS
10372WLANTL_TxFreeMsg
10373(
10374 v_PVOID_t pvosGCtx,
10375 vos_msg_t* message
10376)
10377{
10378 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
10379
10380 /*Nothing to do for now!!!*/
10381 return VOS_STATUS_SUCCESS;
10382}/*WLANTL_TxFreeMsg*/
10383
Jeff Johnson295189b2012-06-20 16:38:30 -070010384/*==========================================================================
10385
10386 FUNCTION WLANTL_TxFCFrame
10387
10388 DESCRIPTION
10389 Internal utility function to send FC frame. Enable
10390 or disable LWM mode based on the information.
10391
10392 DEPENDENCIES
10393 TL must be initiailized before this function gets called.
10394 FW sends up special flow control frame.
10395
10396 PARAMETERS
10397
10398 IN
10399 pvosGCtx: pointer to the global vos context; a handle to TL's
10400 control block can be extracted from its context
10401
10402 RETURN VALUE
10403 The result code associated with performing the operation
10404
10405 VOS_STATUS_E_INVAL: Input pointers are NULL.
10406 VOS_STATUS_E_FAULT: Something is wrong.
10407 VOS_STATUS_SUCCESS: Everything is good.
10408
10409 SIDE EFFECTS
10410 Newly formed FC frame is generated and waits to be transmitted. Previously unsent frame will
10411 be released.
10412
10413============================================================================*/
10414VOS_STATUS
10415WLANTL_TxFCFrame
10416(
10417 v_PVOID_t pvosGCtx
10418)
10419{
10420#if 0
10421 WLANTL_CbType* pTLCb = NULL;
10422 VOS_STATUS vosStatus;
10423 tpHalFcTxBd pvFcTxBd = NULL;
10424 vos_pkt_t * pPacket = NULL;
10425 v_U8_t ucSTAId = 0;
10426 v_U8_t ucBitCheck = 1;
10427
10428 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070010429 "WLAN TL: Send FC frame %s", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070010430
10431 /*------------------------------------------------------------------------
10432 Sanity check
10433 ------------------------------------------------------------------------*/
10434 if ( NULL == pvosGCtx )
10435 {
10436 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070010437 "WLAN TL:Invalid parameter %s", __func__));
Jeff Johnson295189b2012-06-20 16:38:30 -070010438 return VOS_STATUS_E_INVAL;
10439 }
10440 /*------------------------------------------------------------------------
10441 Extract TL control block
10442 ------------------------------------------------------------------------*/
10443 pTLCb = VOS_GET_TL_CB(pvosGCtx);
10444
10445 if (NULL == pTLCb)
10446 {
10447 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070010448 "WLAN TL:Invalid pointer in %s \n", __func__));
Jeff Johnson295189b2012-06-20 16:38:30 -070010449 return VOS_STATUS_E_INVAL;
10450 }
10451
10452 //Get one voss packet
10453 vosStatus = vos_pkt_get_packet( &pPacket, VOS_PKT_TYPE_TX_802_11_MGMT, sizeof(tHalFcTxBd), 1,
10454 VOS_FALSE, NULL, NULL );
10455
10456 if ( VOS_STATUS_SUCCESS != vosStatus )
10457 {
10458 return VOS_STATUS_E_INVAL;
10459 }
10460
10461 vosStatus = vos_pkt_reserve_head( pPacket, (void *)&pvFcTxBd, sizeof(tHalFcTxBd));
10462
10463 if( VOS_STATUS_SUCCESS != vosStatus )
10464 {
10465 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070010466 "%s: failed to reserve FC TX BD %d\n",__func__, sizeof(tHalFcTxBd)));
Jeff Johnson295189b2012-06-20 16:38:30 -070010467 vos_pkt_return_packet( pPacket );
10468 return VOS_STATUS_E_FAULT;
10469 }
10470
10471 //Generate most recent tlFCInfo. Most fields are correct.
10472 pTLCb->tlFCInfo.fcSTAThreshEnabledMask = 0;
10473 pTLCb->tlFCInfo.fcSTATxMoreDataMask = 0;
10474 for( ucSTAId = 0, ucBitCheck = 1 ; ucSTAId < WLAN_MAX_STA_COUNT; ucBitCheck <<= 1, ucSTAId ++)
10475 {
10476 if (0 == pTLCb->atlSTAClients[ucSTAId].ucExists)
10477 {
10478 continue;
10479 }
10480
10481 if (pTLCb->atlSTAClients[ucSTAId].ucPktPending)
10482 {
10483 pTLCb->tlFCInfo.fcSTATxMoreDataMask |= ucBitCheck;
10484 }
10485
10486 if ( (pTLCb->atlSTAClients[ucSTAId].ucLwmModeEnabled) &&
10487 (pTLCb->atlSTAClients[ucSTAId].bmuMemConsumed > pTLCb->atlSTAClients[ucSTAId].uLwmThreshold))
10488 {
10489 pTLCb->tlFCInfo.fcSTAThreshEnabledMask |= ucBitCheck;
10490
10491 pTLCb->tlFCInfo.fcSTAThresh[ucSTAId] = (tANI_U8)pTLCb->atlSTAClients[ucSTAId].uLwmThreshold;
10492
10493 pTLCb->atlSTAClients[ucSTAId].ucLwmEventReported = FALSE;
10494 }
10495
10496 }
10497
10498 //request immediate feedback
10499 pTLCb->tlFCInfo.fcConfig |= 0x4;
10500
10501 //fill in BD to sent
10502 vosStatus = WLANHAL_FillFcTxBd(pvosGCtx, &pTLCb->tlFCInfo, (void *)pvFcTxBd);
10503
10504 if( VOS_STATUS_SUCCESS != vosStatus )
10505 {
10506 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070010507 "%s: Fill FC TX BD unsuccessful\n", __func__));
Jeff Johnson295189b2012-06-20 16:38:30 -070010508 vos_pkt_return_packet( pPacket );
10509 return VOS_STATUS_E_FAULT;
10510 }
10511
10512 if (NULL != pTLCb->vosTxFCBuf)
10513 {
10514 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070010515 "%s: Previous FC TX BD not sent\n", __func__));
Jeff Johnson295189b2012-06-20 16:38:30 -070010516 vos_pkt_return_packet(pTLCb->vosTxFCBuf);
10517 }
10518
10519 pTLCb->vosTxFCBuf = pPacket;
10520
10521 vos_pkt_set_user_data_ptr( pPacket, VOS_PKT_USER_DATA_ID_TL,
10522 (v_PVOID_t)WLANTL_TxCompDefaultCb);
10523 vosStatus = WDA_DS_StartXmit(pvosGCtx);
10524
10525 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070010526 "WLAN TL: send FC frame leave %s", __func__));
Jeff Johnson295189b2012-06-20 16:38:30 -070010527#endif
10528 return VOS_STATUS_SUCCESS;
10529}
10530
Jeff Johnson295189b2012-06-20 16:38:30 -070010531
10532/*==========================================================================
10533 FUNCTION WLANTL_GetTxResourcesCB
10534
10535 DESCRIPTION
10536 Processing function for Resource needed signal. A request will be issued
10537 to BAL to get more tx resources.
10538
10539 DEPENDENCIES
10540 The TL must be initialized before this function can be called.
10541
10542 PARAMETERS
10543
10544 IN
10545 pvosGCtx: pointer to the global vos context; a handle to TL's
10546 control block can be extracted from its context
10547
10548
10549 RETURN VALUE
10550 The result code associated with performing the operation
10551
10552 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
10553 page fault
10554 VOS_STATUS_SUCCESS: Everything is good :)
10555
10556 Other values can be returned as a result of a function call, please check
10557 corresponding API for more info.
10558 SIDE EFFECTS
10559
10560============================================================================*/
10561VOS_STATUS
10562WLANTL_GetTxResourcesCB
10563(
10564 v_PVOID_t pvosGCtx
10565)
10566{
10567 WLANTL_CbType* pTLCb = NULL;
10568 v_U32_t uResCount = WDA_TLI_MIN_RES_DATA;
10569 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
10570 v_U8_t ucMgmt = 0;
10571 v_U8_t ucBAP = 0;
10572 v_U8_t ucData = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070010573#ifdef WLAN_SOFTAP_FLOWCTRL_EN
10574 tBssSystemRole systemRole;
10575 tpAniSirGlobal pMac;
10576#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010577 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
10578 /*------------------------------------------------------------------------
10579 Extract TL control block
10580 ------------------------------------------------------------------------*/
10581 pTLCb = VOS_GET_TL_CB(pvosGCtx);
10582 if ( NULL == pTLCb )
10583 {
10584 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
10585 "WLAN TL:Invalid TL pointer from pvosGCtx on"
10586 " WLANTL_ProcessTxMessage"));
10587 return VOS_STATUS_E_FAULT;
10588 }
10589
10590 /*------------------------------------------------------------------------
10591 Get tx resources from BAL
10592 ------------------------------------------------------------------------*/
10593 vosStatus = WDA_DS_GetTxResources( pvosGCtx, &uResCount );
10594
10595 if ( (VOS_STATUS_SUCCESS != vosStatus) && (VOS_STATUS_E_RESOURCES != vosStatus))
10596 {
10597 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
10598 "WLAN TL:TL failed to get resources from BAL, Err: %d",
10599 vosStatus));
10600 return vosStatus;
10601 }
10602
10603 /* Currently only Linux BAL returns the E_RESOURCES error code when it is running
10604 out of BD/PDUs. To make use of this interrupt for throughput enhancement, similar
10605 changes should be done in BAL code of AMSS and WM */
10606 if (VOS_STATUS_E_RESOURCES == vosStatus)
10607 {
10608#ifdef VOLANS_PERF
10609 WLANHAL_EnableIdleBdPduInterrupt(pvosGCtx, (tANI_U8)bdPduInterruptGetThreshold);
10610 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
10611 "WLAN TL: Enabling Idle BD/PDU interrupt, Current resources = %d", uResCount);
10612#else
10613 return VOS_STATUS_E_FAILURE;
10614#endif
10615 }
10616
10617 pTLCb->uResCount = uResCount;
10618
10619
Jeff Johnson295189b2012-06-20 16:38:30 -070010620#ifdef WLAN_SOFTAP_FLOWCTRL_EN
10621 /* FIXME: disabled since creating issues in power-save, needs to be addressed */
10622 pTLCb->sendFCFrame ++;
10623 pMac = vos_get_context(VOS_MODULE_ID_WDA, pvosGCtx);
10624 systemRole = wdaGetGlobalSystemRole(pMac);
10625 if (eSYSTEM_AP_ROLE == systemRole)
10626 {
10627 if (pTLCb->sendFCFrame % 16 == 0)
10628 {
10629 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
10630 "Transmit FC"));
10631 WLANTL_TxFCFrame (pvosGCtx);
10632 }
10633 }
10634#endif //WLAN_SOFTAP_FLOWCTRL_EN
Jeff Johnson295189b2012-06-20 16:38:30 -070010635
10636 ucData = ( pTLCb->uResCount >= WDA_TLI_MIN_RES_DATA );
10637 ucBAP = ( pTLCb->uResCount >= WDA_TLI_MIN_RES_BAP ) &&
10638 ( NULL != pTLCb->tlBAPClient.vosPendingDataBuff );
10639 ucMgmt = ( pTLCb->uResCount >= WDA_TLI_MIN_RES_MF ) &&
10640 ( NULL != pTLCb->tlMgmtFrmClient.vosPendingDataBuff );
10641
10642 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
10643 "WLAN TL: Eval Resume tx Res: %d DATA: %d BAP: %d MGMT: %d",
10644 pTLCb->uResCount, ucData, ucBAP, ucMgmt));
10645
10646 if (( 0 == pTLCb->ucTxSuspended ) &&
10647 (( 0 != ucData ) || ( 0 != ucMgmt ) || ( 0 != ucBAP ) ) )
10648 {
10649 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
10650 "Issuing Xmit start request to BAL for avail res SYNC"));
10651 vosStatus =WDA_DS_StartXmit(pvosGCtx);
10652 }
10653 return vosStatus;
10654}/*WLANTL_GetTxResourcesCB*/
10655
10656/*==========================================================================
10657 Utility functions
10658 ==========================================================================*/
10659
10660/*==========================================================================
10661 FUNCTION WLANTL_Translate8023To80211Header
10662
10663 DESCRIPTION
10664 Inline function for translating and 802.11 header into an 802.3 header.
10665
10666 DEPENDENCIES
10667
10668
10669 PARAMETERS
10670
10671 IN
10672 pTLCb: TL control block
Kiran Venkatappaa044eb92012-12-17 15:48:49 -080010673 IN/OUT
10674 ucStaId: station ID. Incase of TDLS, this returns actual TDLS
10675 station ID used
Jeff Johnson295189b2012-06-20 16:38:30 -070010676
10677 IN/OUT
10678 vosDataBuff: vos data buffer, will contain the new header on output
10679
10680 OUT
10681 pvosStatus: status of the operation
10682
10683 RETURN VALUE
10684
10685 VOS_STATUS_SUCCESS: Everything is good :)
10686
10687 Other error codes might be returned from the vos api used in the function
10688 please check those return values.
10689
10690 SIDE EFFECTS
10691
10692============================================================================*/
Kiran Venkatappacab0d352012-12-17 13:09:22 -080010693VOS_STATUS
10694WLANTL_Translate8023To80211Header
10695(
10696 vos_pkt_t* vosDataBuff,
10697 VOS_STATUS* pvosStatus,
10698 WLANTL_CbType* pTLCb,
10699 v_U8_t *pucStaId,
Ravi Joshid0699502013-07-08 15:48:47 -070010700 WLANTL_MetaInfoType *tlMetaInfo,
Kiran Venkatappacab0d352012-12-17 13:09:22 -080010701 v_U8_t *ucWDSEnabled,
10702 v_U8_t *extraHeadSpace
10703)
Jeff Johnson295189b2012-06-20 16:38:30 -070010704{
10705 WLANTL_8023HeaderType w8023Header;
10706 WLANTL_80211HeaderType *pw80211Header; // Allocate an aligned BD and then fill it.
10707 VOS_STATUS vosStatus;
10708 v_U8_t MandatoryucHeaderSize = WLAN80211_MANDATORY_HEADER_SIZE;
10709 v_U8_t ucHeaderSize = 0;
10710 v_VOID_t *ppvBDHeader = NULL;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053010711 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070010712 v_U8_t ucQoSOffset = WLAN80211_MANDATORY_HEADER_SIZE;
Kiran Venkatappacab0d352012-12-17 13:09:22 -080010713 v_U8_t ucStaId;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010714#ifdef FEATURE_WLAN_ESE_UPLOAD
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070010715 v_BOOL_t bIAPPTxwithLLC = VOS_FALSE;
10716 v_SIZE_t wIAPPSnapSize = WLANTL_LLC_HEADER_LEN;
10717 v_U8_t wIAPPSnap[WLANTL_LLC_HEADER_LEN] = {0};
10718#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010719 *ucWDSEnabled = 0; // default WDS off.
10720 vosStatus = vos_pkt_pop_head( vosDataBuff, &w8023Header,
10721 sizeof(w8023Header));
10722
10723 if ( VOS_STATUS_SUCCESS != vosStatus )
10724 {
10725 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
10726 "WLAN TL: Packet pop header fails on WLANTL_Translate8023To80211Header"));
10727 return vosStatus;
10728 }
10729
Kiran Venkatappacab0d352012-12-17 13:09:22 -080010730 if( NULL == pucStaId )
10731 {
10732 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
10733 "WLAN TL: Invalid pointer for StaId"));
10734 return VOS_STATUS_E_INVAL;
10735 }
10736 ucStaId = *pucStaId;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053010737 pClientSTA = pTLCb->atlSTAClients[ucStaId];
10738
10739 if ( NULL == pClientSTA )
10740 {
10741 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
10742 "WLAN TL:Client Memory was not allocated on %s", __func__));
10743 return VOS_STATUS_E_FAILURE;
10744 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080010745
Kiran Venkatappaa044eb92012-12-17 15:48:49 -080010746#ifdef FEATURE_WLAN_TDLS
10747
Madan Mohan Koyylamudi64258222013-01-30 14:35:10 +053010748 if ( WLAN_STA_INFRA == pTLCb->atlSTAClients[ucStaId]->wSTADesc.wSTAType
10749 && pTLCb->ucTdlsPeerCount )
Kiran Venkatappacab0d352012-12-17 13:09:22 -080010750 {
10751 v_U8_t ucIndex = 0;
10752 for ( ucIndex = 0; ucIndex < WLAN_MAX_STA_COUNT ; ucIndex++)
10753 {
Madan Mohan Koyylamudi64258222013-01-30 14:35:10 +053010754 if ( ucIndex != ucStaId && pTLCb->atlSTAClients[ucIndex] && pTLCb->atlSTAClients[ucIndex]->ucExists &&
Gopichand Nakkala471708b2013-06-04 20:03:01 +053010755 (pTLCb->atlSTAClients[ucIndex]->tlState == WLANTL_STA_AUTHENTICATED) &&
10756 (!pTLCb->atlSTAClients[ucIndex]->ucTxSuspended) &&
Madan Mohan Koyylamudi64258222013-01-30 14:35:10 +053010757 vos_mem_compare( (void*)pTLCb->atlSTAClients[ucIndex]->wSTADesc.vSTAMACAddress.bytes,
Kiran Venkatappacab0d352012-12-17 13:09:22 -080010758 (void*)w8023Header.vDA, 6) )
10759 {
10760 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_LOW,
10761 "WLAN TL: Got a TDLS station. Using that index"));
10762 ucStaId = ucIndex;
10763 *pucStaId = ucStaId;
Madan Mohan Koyylamudi64258222013-01-30 14:35:10 +053010764 pClientSTA = pTLCb->atlSTAClients[ucStaId];
10765 if ( NULL == pClientSTA )
10766 {
10767 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
10768 "WLAN TL:Client Memory was not allocated on %s", __func__));
10769 return VOS_STATUS_E_FAILURE;
10770 }
Kiran Venkatappacab0d352012-12-17 13:09:22 -080010771 break;
10772 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080010773 }
Kiran Venkatappacab0d352012-12-17 13:09:22 -080010774 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080010775#endif
10776
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010777#ifdef FEATURE_WLAN_ESE_UPLOAD
10778if ((0 == w8023Header.usLenType) && (pClientSTA->wSTADesc.ucIsEseSta))
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070010779{
10780 vos_pkt_extract_data(vosDataBuff,0,&wIAPPSnap[0],&wIAPPSnapSize);
10781 if (vos_mem_compare(wIAPPSnap,WLANTL_AIRONET_SNAP_HEADER,WLANTL_LLC_HEADER_LEN))
10782 {
10783 /*The SNAP and the protocol type are already in the data buffer.
10784 They are filled by the application (wpa_supplicant). So, Skip Adding LLC below.*/
10785 bIAPPTxwithLLC = VOS_TRUE;
10786 }
10787 else
10788 {
10789 bIAPPTxwithLLC = VOS_FALSE;
10790 }
10791}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010792#endif /* FEATURE_WLAN_ESE_UPLOAD */
Jeff Johnson295189b2012-06-20 16:38:30 -070010793
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070010794 if ((0 != pClientSTA->wSTADesc.ucAddRmvLLC)
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010795#ifdef FEATURE_WLAN_ESE_UPLOAD
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070010796 && (!bIAPPTxwithLLC)
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010797#endif /* FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070010798 )
Jeff Johnson295189b2012-06-20 16:38:30 -070010799 {
10800 /* Push the length */
10801 vosStatus = vos_pkt_push_head(vosDataBuff,
10802 &w8023Header.usLenType, sizeof(w8023Header.usLenType));
10803
10804 if ( VOS_STATUS_SUCCESS != vosStatus )
10805 {
10806 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
10807 "WLAN TL: Packet push ether type fails on"
10808 " WLANTL_Translate8023To80211Header"));
10809 return vosStatus;
10810 }
10811
10812#ifdef BTAMP_TEST
10813 // The STA side will execute this, a hack to test BTAMP by using the
10814 // infra setup. On real BTAMP this will come from BAP itself.
10815 {
10816 static v_U8_t WLANTL_BT_AMP_LLC_HEADER[] = {0xAA, 0xAA, 0x03, 0x00, 0x19, 0x58 };
10817 vosStatus = vos_pkt_push_head(vosDataBuff, WLANTL_BT_AMP_LLC_HEADER,
10818 sizeof(WLANTL_BT_AMP_LLC_HEADER));
10819
10820 if ( VOS_STATUS_SUCCESS != vosStatus )
10821 {
10822 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
10823 "WLAN TL: Packet push LLC header fails on"
10824 " WLANTL_Translate8023To80211Header"));
10825 return vosStatus;
10826 }
10827 }
10828#else
10829 vosStatus = vos_pkt_push_head(vosDataBuff, WLANTL_LLC_HEADER,
10830 sizeof(WLANTL_LLC_HEADER));
10831
10832 if ( VOS_STATUS_SUCCESS != vosStatus )
10833 {
10834 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
10835 "WLAN TL: Packet push LLC header fails on"
10836 " WLANTL_Translate8023To80211Header"));
10837 return vosStatus;
10838 }
10839#endif
10840 }/*If add LLC is enabled*/
10841 else
10842 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010843#ifdef FEATURE_WLAN_ESE_UPLOAD
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070010844 bIAPPTxwithLLC = VOS_FALSE; /*Reset the Flag here to start afresh with the next TX pkt*/
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010845#endif /* FEATURE_WLAN_ESE_UPLOAD */
Jeff Johnson295189b2012-06-20 16:38:30 -070010846 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
10847 "WLAN TL: STA Client registered to not remove LLC"
10848 " WLANTL_Translate8023To80211Header"));
10849 }
10850
10851#ifdef BTAMP_TEST
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053010852 pClientSTA->wSTADesc.wSTAType = WLAN_STA_BT_AMP;
Jeff Johnson295189b2012-06-20 16:38:30 -070010853#endif
10854
10855 // Find the space required for the 802.11 header format
10856 // based on the frame control fields.
10857 ucHeaderSize = MandatoryucHeaderSize;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053010858 if (pClientSTA->wSTADesc.ucQosEnabled)
Jeff Johnson295189b2012-06-20 16:38:30 -070010859 {
10860 ucHeaderSize += sizeof(pw80211Header->usQosCtrl);
10861 }
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053010862 if (pClientSTA->wSTADesc.wSTAType == WLAN_STA_BT_AMP)
Jeff Johnson295189b2012-06-20 16:38:30 -070010863 {
10864 ucHeaderSize += sizeof(pw80211Header->optvA4);
Jeff Johnson295189b2012-06-20 16:38:30 -070010865 ucQoSOffset += sizeof(pw80211Header->optvA4);
Jeff Johnson295189b2012-06-20 16:38:30 -070010866 }
10867
10868 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
10869 " WLANTL_Translate8023To80211Header : Header size = %d ", ucHeaderSize));
10870
10871 vos_pkt_reserve_head( vosDataBuff, &ppvBDHeader, ucHeaderSize );
10872 if ( NULL == ppvBDHeader )
10873 {
10874 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
10875 "WLAN TL:VOSS packet corrupted "));
10876 *pvosStatus = VOS_STATUS_E_INVAL;
10877 return *pvosStatus;
10878 }
10879
Jeff Johnson295189b2012-06-20 16:38:30 -070010880
10881 // OK now we have the space. Fill the 80211 header
10882 /* Fill A2 */
10883 pw80211Header = (WLANTL_80211HeaderType *)(ppvBDHeader);
10884 // only clear the required space.
10885 vos_mem_set( pw80211Header, ucHeaderSize, 0 );
10886 vos_mem_copy( pw80211Header->vA2, w8023Header.vSA, VOS_MAC_ADDR_SIZE);
10887
10888
10889#ifdef FEATURE_WLAN_WAPI
Gopichand Nakkala8b54e912013-03-11 10:44:21 +053010890 if (( WLANTL_STA_AUTHENTICATED == pClientSTA->tlState ||
Abhishek Singh8cecdaa2015-05-22 14:46:40 +053010891 pClientSTA->ptkInstalled ) && (tlMetaInfo->ucIsWai != 1))
Jeff Johnson295189b2012-06-20 16:38:30 -070010892#else
Gopichand Nakkala8b54e912013-03-11 10:44:21 +053010893 if ( WLANTL_STA_AUTHENTICATED == pClientSTA->tlState ||
10894 pClientSTA->ptkInstalled )
Jeff Johnson295189b2012-06-20 16:38:30 -070010895#endif
10896 {
10897 pw80211Header->wFrmCtrl.wep =
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053010898 pClientSTA->wSTADesc.ucProtectedFrame;
Jeff Johnson295189b2012-06-20 16:38:30 -070010899 }
10900
10901 pw80211Header->usDurationId = 0;
10902 pw80211Header->usSeqCtrl = 0;
10903
10904 pw80211Header->wFrmCtrl.type = WLANTL_80211_DATA_TYPE;
10905
10906
10907
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053010908 if(pClientSTA->wSTADesc.ucQosEnabled)
Jeff Johnson295189b2012-06-20 16:38:30 -070010909 {
10910 pw80211Header->wFrmCtrl.subType = WLANTL_80211_DATA_QOS_SUBTYPE;
10911
Ravi Joshid0699502013-07-08 15:48:47 -070010912 *((v_U16_t *)((v_U8_t *)ppvBDHeader + ucQoSOffset)) = tlMetaInfo->ucUP;
Jeff Johnson295189b2012-06-20 16:38:30 -070010913
10914 }
10915 else
10916 {
10917 pw80211Header->wFrmCtrl.subType = 0;
Agarwal Ashish8b343f12015-01-08 20:06:44 +053010918 tlMetaInfo->ucUP = 0;
10919 tlMetaInfo->ucTID = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070010920
10921 // NO NO NO - there is not enough memory allocated to write the QOS ctrl
10922 // field, it will overwrite the first 2 bytes of the data packet(LLC header)
10923 // pw80211Header->usQosCtrl = 0;
10924 }
10925
10926
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053010927 switch( pClientSTA->wSTADesc.wSTAType )
Jeff Johnson295189b2012-06-20 16:38:30 -070010928 {
Ravi Joshid0699502013-07-08 15:48:47 -070010929 case WLAN_STA_IBSS:
Jeff Johnson295189b2012-06-20 16:38:30 -070010930 pw80211Header->wFrmCtrl.toDS = 0;
10931 pw80211Header->wFrmCtrl.fromDS = 0;
Ravi Joshid0699502013-07-08 15:48:47 -070010932
Abhishek Singh45e68fe2014-12-11 12:55:59 +053010933 vos_copy_macaddr( (v_MACADDR_t*)&pw80211Header->vA1,
Ravi Joshid0699502013-07-08 15:48:47 -070010934 (v_MACADDR_t*)&w8023Header.vDA);
Jeff Johnson295189b2012-06-20 16:38:30 -070010935 vos_mem_copy( pw80211Header->vA3,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053010936 &pClientSTA->wSTADesc.vBSSIDforIBSS ,
Jeff Johnson295189b2012-06-20 16:38:30 -070010937 VOS_MAC_ADDR_SIZE);
10938 break;
10939
Ravi Joshid0699502013-07-08 15:48:47 -070010940 case WLAN_STA_BT_AMP:
Jeff Johnson295189b2012-06-20 16:38:30 -070010941 *ucWDSEnabled = 1; // WDS on.
10942 pw80211Header->wFrmCtrl.toDS = 1;
10943 pw80211Header->wFrmCtrl.fromDS = 1;
10944 vos_copy_macaddr( (v_MACADDR_t*)&pw80211Header->vA1,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053010945 &pClientSTA->wSTADesc.vSTAMACAddress);
Jeff Johnson295189b2012-06-20 16:38:30 -070010946 vos_mem_copy( pw80211Header->vA2,
Ravi Joshid0699502013-07-08 15:48:47 -070010947 w8023Header.vSA, VOS_MAC_ADDR_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -070010948 vos_copy_macaddr( (v_MACADDR_t*)&pw80211Header->vA3,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053010949 &pClientSTA->wSTADesc.vSTAMACAddress);
Jeff Johnson295189b2012-06-20 16:38:30 -070010950 /* fill the optional A4 header */
10951 vos_mem_copy( pw80211Header->optvA4,
Ravi Joshid0699502013-07-08 15:48:47 -070010952 w8023Header.vSA, VOS_MAC_ADDR_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -070010953 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
Arif Hussainf2b00992013-11-17 21:46:15 -080010954 "BTAMP CASE NOW ---------staid=%d",
Ravi Joshid0699502013-07-08 15:48:47 -070010955 ucStaId));
Jeff Johnson295189b2012-06-20 16:38:30 -070010956 break;
10957
Ravi Joshid0699502013-07-08 15:48:47 -070010958 case WLAN_STA_SOFTAP:
Jeff Johnson295189b2012-06-20 16:38:30 -070010959 *ucWDSEnabled = 0; // WDS off.
10960 pw80211Header->wFrmCtrl.toDS = 0;
10961 pw80211Header->wFrmCtrl.fromDS = 1;
10962 /*Copy the DA to A1*/
10963 vos_mem_copy( pw80211Header->vA1, w8023Header.vDA , VOS_MAC_ADDR_SIZE);
10964 vos_copy_macaddr( (v_MACADDR_t*)&pw80211Header->vA2,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053010965 &pClientSTA->wSTADesc.vSelfMACAddress);
Jeff Johnson295189b2012-06-20 16:38:30 -070010966 vos_mem_copy( pw80211Header->vA3,
Ravi Joshid0699502013-07-08 15:48:47 -070010967 w8023Header.vSA, VOS_MAC_ADDR_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -070010968 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
Arif Hussainf2b00992013-11-17 21:46:15 -080010969 "sw 802 to 80211 softap case ---------staid=%d",
Ravi Joshid0699502013-07-08 15:48:47 -070010970 ucStaId));
Jeff Johnson295189b2012-06-20 16:38:30 -070010971 break;
Mohit Khanna698ba2a2012-12-04 15:08:18 -080010972#ifdef FEATURE_WLAN_TDLS
Ravi Joshid0699502013-07-08 15:48:47 -070010973 case WLAN_STA_TDLS:
Mohit Khanna698ba2a2012-12-04 15:08:18 -080010974 pw80211Header->wFrmCtrl.toDS = 0;
10975 pw80211Header->wFrmCtrl.fromDS = 0;
10976 /*Fix me*/
10977 vos_copy_macaddr( (v_MACADDR_t*)&pw80211Header->vA1,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053010978 &pClientSTA->wSTADesc.vSTAMACAddress);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080010979 vos_mem_copy( pw80211Header->vA3,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053010980 &pClientSTA->wSTADesc.vBSSIDforIBSS ,
Mohit Khanna698ba2a2012-12-04 15:08:18 -080010981 VOS_MAC_ADDR_SIZE);
10982 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
Arif Hussainf2b00992013-11-17 21:46:15 -080010983 ("TL:TDLS CASE NOW ---------staid=%d"), ucStaId);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080010984 break;
10985#endif
Ravi Joshid0699502013-07-08 15:48:47 -070010986 case WLAN_STA_INFRA:
10987 default:
Jeff Johnson295189b2012-06-20 16:38:30 -070010988 pw80211Header->wFrmCtrl.toDS = 1;
10989 pw80211Header->wFrmCtrl.fromDS = 0;
10990 vos_copy_macaddr( (v_MACADDR_t*)&pw80211Header->vA1,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053010991 &pClientSTA->wSTADesc.vSTAMACAddress);
Jeff Johnson295189b2012-06-20 16:38:30 -070010992 vos_mem_copy( pw80211Header->vA3, w8023Header.vDA , VOS_MAC_ADDR_SIZE);
10993 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
Arif Hussainf2b00992013-11-17 21:46:15 -080010994 "REGULAR INFRA LINK CASE---------staid=%d",
Ravi Joshid0699502013-07-08 15:48:47 -070010995 ucStaId));
Jeff Johnson295189b2012-06-20 16:38:30 -070010996 break;
10997 }
10998 // OK now we have the space. Fill the 80211 header
10999 /* Fill A2 */
11000 pw80211Header = (WLANTL_80211HeaderType *)(ppvBDHeader);
11001 return VOS_STATUS_SUCCESS;
11002}/*WLANTL_Translate8023To80211Header*/
11003
11004
11005/*=============================================================================
11006 BEGIN LOG FUNCTION !!! Remove me or clean me
11007=============================================================================*/
Ravi Kumar Vaishnavb7652402013-01-18 19:05:15 -080011008#if 0 //def WLANTL_DEBUG
Jeff Johnson295189b2012-06-20 16:38:30 -070011009
11010#define WLANTL_DEBUG_FRAME_BYTE_PER_LINE 16
11011#define WLANTL_DEBUG_FRAME_BYTE_PER_BYTE 4
11012
11013static v_VOID_t WLANTL_DebugFrame
11014(
11015 v_PVOID_t dataPointer,
11016 v_U32_t dataSize
11017)
11018{
11019 v_U8_t lineBuffer[WLANTL_DEBUG_FRAME_BYTE_PER_LINE];
11020 v_U32_t numLines;
11021 v_U32_t numBytes;
11022 v_U32_t idx;
11023 v_U8_t *linePointer;
11024
11025 numLines = dataSize / WLANTL_DEBUG_FRAME_BYTE_PER_LINE;
11026 numBytes = dataSize % WLANTL_DEBUG_FRAME_BYTE_PER_LINE;
11027 linePointer = (v_U8_t *)dataPointer;
11028
Jeff Johnsonddec6482017-09-19 08:33:57 -070011029 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 -070011030 for(idx = 0; idx < numLines; idx++)
11031 {
11032 memset(lineBuffer, 0, WLANTL_DEBUG_FRAME_BYTE_PER_LINE);
11033 memcpy(lineBuffer, linePointer, WLANTL_DEBUG_FRAME_BYTE_PER_LINE);
11034 TLLOGE(VOS_TRACE(VOS_MODULE_ID_SAL, VOS_TRACE_LEVEL_ERROR,
11035 "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",
11036 lineBuffer[0], lineBuffer[1], lineBuffer[2], lineBuffer[3], lineBuffer[4], lineBuffer[5], lineBuffer[6], lineBuffer[7],
11037 lineBuffer[8], lineBuffer[9], lineBuffer[10], lineBuffer[11], lineBuffer[12], lineBuffer[13], lineBuffer[14], lineBuffer[15]));
11038 linePointer += WLANTL_DEBUG_FRAME_BYTE_PER_LINE;
11039 }
11040
11041 if(0 == numBytes)
11042 return;
11043
11044 memset(lineBuffer, 0, WLANTL_DEBUG_FRAME_BYTE_PER_LINE);
11045 memcpy(lineBuffer, linePointer, numBytes);
11046 for(idx = 0; idx < WLANTL_DEBUG_FRAME_BYTE_PER_LINE / WLANTL_DEBUG_FRAME_BYTE_PER_BYTE; idx++)
11047 {
11048 TLLOGE(VOS_TRACE(VOS_MODULE_ID_SAL, VOS_TRACE_LEVEL_ERROR, "WLAN TL:0x%2x 0x%2x 0x%2x 0x%2x",
11049 lineBuffer[idx * WLANTL_DEBUG_FRAME_BYTE_PER_BYTE], lineBuffer[1 + idx * WLANTL_DEBUG_FRAME_BYTE_PER_BYTE],
11050 lineBuffer[2 + idx * WLANTL_DEBUG_FRAME_BYTE_PER_BYTE], lineBuffer[3 + idx * WLANTL_DEBUG_FRAME_BYTE_PER_BYTE]));
11051 if(((idx + 1) * WLANTL_DEBUG_FRAME_BYTE_PER_BYTE) >= numBytes)
11052 break;
11053 }
11054
11055 return;
11056}
11057#endif
11058
11059/*=============================================================================
11060 END LOG FUNCTION
11061=============================================================================*/
11062
11063/*==========================================================================
11064 FUNCTION WLANTL_Translate80211To8023Header
11065
11066 DESCRIPTION
11067 Inline function for translating and 802.11 header into an 802.3 header.
11068
11069 DEPENDENCIES
11070
11071
11072 PARAMETERS
11073
11074 IN
11075 pTLCb: TL control block
11076 ucStaId: station ID
11077 ucHeaderLen: Length of the header from BD
11078 ucActualHLen: Length of header including padding or any other trailers
11079
11080 IN/OUT
11081 vosDataBuff: vos data buffer, will contain the new header on output
11082
11083 OUT
11084 pvosStatus: status of the operation
11085
11086 RETURN VALUE
11087
11088 The result code associated with performing the operation
11089 VOS_STATUS_SUCCESS: Everything is good :)
11090
11091 SIDE EFFECTS
11092
11093============================================================================*/
11094VOS_STATUS
11095WLANTL_Translate80211To8023Header
11096(
11097 vos_pkt_t* vosDataBuff,
11098 VOS_STATUS* pvosStatus,
11099 v_U16_t usActualHLen,
11100 v_U8_t ucHeaderLen,
11101 WLANTL_CbType* pTLCb,
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070011102 v_U8_t ucSTAId,
11103 v_BOOL_t bForwardIAPPwithLLC
Jeff Johnson295189b2012-06-20 16:38:30 -070011104)
11105{
11106 WLANTL_8023HeaderType w8023Header;
11107 WLANTL_80211HeaderType w80211Header;
11108 v_U8_t aucLLCHeader[WLANTL_LLC_HEADER_LEN];
11109 VOS_STATUS vosStatus;
11110 v_U16_t usDataStartOffset = 0;
11111 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
11112
11113 if ( sizeof(w80211Header) < ucHeaderLen )
11114 {
11115 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
11116 "Warning !: Check the header size for the Rx frame structure=%d received=%dn",
11117 sizeof(w80211Header), ucHeaderLen));
11118 ucHeaderLen = sizeof(w80211Header);
11119 }
11120
11121 // This will take care of headers of all sizes, 3 address, 3 addr QOS,
11122 // WDS non-QOS and WDS QoS etc. We have space for all in the 802.11 header structure.
11123 vosStatus = vos_pkt_pop_head( vosDataBuff, &w80211Header, ucHeaderLen);
11124
11125 if ( VOS_STATUS_SUCCESS != vosStatus )
11126 {
11127 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11128 "WLAN TL: Failed to pop 80211 header from packet %d",
11129 vosStatus));
11130
11131 return vosStatus;
11132 }
11133
11134 switch ( w80211Header.wFrmCtrl.fromDS )
11135 {
11136 case 0:
Jeff Johnson295189b2012-06-20 16:38:30 -070011137 if ( w80211Header.wFrmCtrl.toDS )
11138 {
11139 //SoftAP AP mode
11140 vos_mem_copy( w8023Header.vDA, w80211Header.vA3, VOS_MAC_ADDR_SIZE);
11141 vos_mem_copy( w8023Header.vSA, w80211Header.vA2, VOS_MAC_ADDR_SIZE);
11142 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
Arif Hussainf2b00992013-11-17 21:46:15 -080011143 "WLAN TL SoftAP: 802 3 DA %08x SA %08x",
Jeff Johnson295189b2012-06-20 16:38:30 -070011144 w8023Header.vDA, w8023Header.vSA));
11145 }
11146 else
11147 {
11148 /* IBSS */
11149 vos_mem_copy( w8023Header.vDA, w80211Header.vA1, VOS_MAC_ADDR_SIZE);
11150 vos_mem_copy( w8023Header.vSA, w80211Header.vA2, VOS_MAC_ADDR_SIZE);
11151 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011152 break;
11153 case 1:
11154 if ( w80211Header.wFrmCtrl.toDS )
11155 {
11156 /* BT-AMP case */
11157 vos_mem_copy( w8023Header.vDA, w80211Header.vA1, VOS_MAC_ADDR_SIZE);
11158 vos_mem_copy( w8023Header.vSA, w80211Header.vA2, VOS_MAC_ADDR_SIZE);
11159 }
11160 else
11161 { /* Infra */
11162 vos_mem_copy( w8023Header.vDA, w80211Header.vA1, VOS_MAC_ADDR_SIZE);
11163 vos_mem_copy( w8023Header.vSA, w80211Header.vA3, VOS_MAC_ADDR_SIZE);
11164 }
11165 break;
11166 }
11167
11168 if( usActualHLen > ucHeaderLen )
11169 {
11170 usDataStartOffset = usActualHLen - ucHeaderLen;
11171 }
11172
11173 if ( 0 < usDataStartOffset )
11174 {
11175 vosStatus = vos_pkt_trim_head( vosDataBuff, usDataStartOffset );
11176
11177 if ( VOS_STATUS_SUCCESS != vosStatus )
11178 {
11179 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11180 "WLAN TL: Failed to trim header from packet %d",
11181 vosStatus));
11182 return vosStatus;
11183 }
11184 }
11185
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053011186 if ( NULL == pTLCb->atlSTAClients[ucSTAId] )
11187 {
11188 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11189 "WLAN TL:Client Memory was not allocated on %s", __func__));
11190 return VOS_STATUS_E_FAILURE;
11191 }
11192
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070011193 if ( 0 != pTLCb->atlSTAClients[ucSTAId]->wSTADesc.ucAddRmvLLC
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080011194#ifdef FEATURE_WLAN_ESE_UPLOAD
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070011195 && (!bForwardIAPPwithLLC)
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080011196#endif /* FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070011197 )
Jeff Johnson295189b2012-06-20 16:38:30 -070011198 {
11199 // Extract the LLC header
11200 vosStatus = vos_pkt_pop_head( vosDataBuff, aucLLCHeader,
11201 WLANTL_LLC_HEADER_LEN);
11202
11203 if ( VOS_STATUS_SUCCESS != vosStatus )
11204 {
Kaushik, Sushante386ee12014-05-01 15:50:52 +053011205 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
Jeff Johnson295189b2012-06-20 16:38:30 -070011206 "WLAN TL: Failed to pop LLC header from packet %d",
11207 vosStatus));
11208
11209 return vosStatus;
11210 }
11211
11212 //Extract the length
11213 vos_mem_copy(&w8023Header.usLenType,
11214 &aucLLCHeader[WLANTL_LLC_HEADER_LEN - sizeof(w8023Header.usLenType)],
11215 sizeof(w8023Header.usLenType) );
11216 }
11217 else
11218 {
11219 vosStatus = vos_pkt_get_packet_length(vosDataBuff,
11220 &w8023Header.usLenType);
11221
11222 if ( VOS_STATUS_SUCCESS != vosStatus )
11223 {
11224 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11225 "WLAN TL: Failed to get packet length %d",
11226 vosStatus));
11227
11228 return vosStatus;
11229 }
11230
11231 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
11232 "WLAN TL: BTAMP len (ethertype) fld = %d",
11233 w8023Header.usLenType));
11234 w8023Header.usLenType = vos_cpu_to_be16(w8023Header.usLenType);
11235 }
11236
11237 vos_pkt_push_head(vosDataBuff, &w8023Header, sizeof(w8023Header));
11238
11239#ifdef BTAMP_TEST
11240 {
11241 // AP side will execute this.
11242 v_U8_t *temp_w8023Header = NULL;
11243 vosStatus = vos_pkt_peek_data( vosDataBuff, 0,
11244 &temp_w8023Header, sizeof(w8023Header) );
11245 }
11246#endif
11247#if 0 /*TL_DEBUG*/
11248 vos_pkt_get_packet_length(vosDataBuff, &usLen);
11249 vos_pkt_pop_head( vosDataBuff, aucData, usLen);
11250
11251 WLANTL_DebugFrame(aucData, usLen);
11252
11253 vos_pkt_push_head(vosDataBuff, aucData, usLen);
11254
11255#endif
11256
11257 *pvosStatus = VOS_STATUS_SUCCESS;
11258
11259 return VOS_STATUS_SUCCESS;
11260}/*WLANTL_Translate80211To8023Header*/
11261
Katya Nigame7b69a82015-04-28 15:24:06 +053011262VOS_STATUS
11263WLANTL_MonTranslate80211To8023Header
11264(
11265 vos_pkt_t* vosDataBuff,
11266 WLANTL_CbType* pTLCb
11267)
11268{
11269 v_U16_t usMPDUDOffset;
11270 v_U8_t ucMPDUHOffset;
11271 v_U8_t ucMPDUHLen;
11272 v_U16_t usActualHLen = 0;
11273 v_U16_t usDataStartOffset = 0;
11274 v_PVOID_t aucBDHeader;
11275 WLANTL_8023HeaderType w8023Header;
11276 WLANTL_80211HeaderType w80211Header;
11277 VOS_STATUS vosStatus;
11278 v_U8_t aucLLCHeader[WLANTL_LLC_HEADER_LEN];
11279
11280 WDA_DS_PeekRxPacketInfo( vosDataBuff, (v_PVOID_t)&aucBDHeader, 0 );
11281 ucMPDUHOffset = (v_U8_t)WDA_GET_RX_MPDU_HEADER_OFFSET(aucBDHeader);
11282 usMPDUDOffset = (v_U16_t)WDA_GET_RX_MPDU_DATA_OFFSET(aucBDHeader);
11283 ucMPDUHLen = (v_U8_t)WDA_GET_RX_MPDU_HEADER_LEN(aucBDHeader);
11284 if (usMPDUDOffset > ucMPDUHOffset)
11285 {
11286 usActualHLen = usMPDUDOffset - ucMPDUHOffset;
11287 }
11288
11289 if ( sizeof(w80211Header) < ucMPDUHLen )
11290 {
11291 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
11292 "Warning !: Check the header size for the Rx frame structure=%d received=%dn",
11293 sizeof(w80211Header), ucMPDUHLen));
11294 ucMPDUHLen = sizeof(w80211Header);
11295 }
11296
11297 vosStatus = vos_pkt_pop_head( vosDataBuff, &w80211Header, ucMPDUHLen);
11298 if ( VOS_STATUS_SUCCESS != vosStatus )
11299 {
11300 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11301 "WLAN TL: Failed to pop 80211 header from packet %d",
11302 vosStatus));
11303
11304 return vosStatus;
11305 }
11306 switch ( w80211Header.wFrmCtrl.fromDS )
11307 {
11308 case 0:
11309 if ( w80211Header.wFrmCtrl.toDS )
11310 {
11311 vos_mem_copy( w8023Header.vDA, w80211Header.vA3, VOS_MAC_ADDR_SIZE);
11312 vos_mem_copy( w8023Header.vSA, w80211Header.vA2, VOS_MAC_ADDR_SIZE);
11313 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
11314 "WLAN TL SoftAP: 802 3 DA %08x SA %08x",
11315 w8023Header.vDA, w8023Header.vSA));
11316 }
11317 else
11318 {
11319 vos_mem_copy( w8023Header.vDA, w80211Header.vA1, VOS_MAC_ADDR_SIZE);
11320 vos_mem_copy( w8023Header.vSA, w80211Header.vA2, VOS_MAC_ADDR_SIZE);
11321 }
11322 break;
11323 case 1:
11324 if ( w80211Header.wFrmCtrl.toDS )
11325 {
11326 vos_mem_copy( w8023Header.vDA, w80211Header.vA1, VOS_MAC_ADDR_SIZE);
11327 vos_mem_copy( w8023Header.vSA, w80211Header.vA2, VOS_MAC_ADDR_SIZE);
11328 }
11329 else
11330 {
11331 vos_mem_copy( w8023Header.vDA, w80211Header.vA1, VOS_MAC_ADDR_SIZE);
11332 vos_mem_copy( w8023Header.vSA, w80211Header.vA3, VOS_MAC_ADDR_SIZE);
11333 }
11334 break;
11335 }
11336 if( usActualHLen > ucMPDUHLen )
11337 {
11338 usDataStartOffset = usActualHLen - ucMPDUHLen;
11339 }
11340
11341 if ( 0 < usDataStartOffset )
11342 {
11343 vosStatus = vos_pkt_trim_head( vosDataBuff, usDataStartOffset );
11344
11345 if ( VOS_STATUS_SUCCESS != vosStatus )
11346 {
11347 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11348 "WLAN TL: Failed to trim header from packet %d",
11349 vosStatus));
11350 return vosStatus;
11351 }
11352 }
11353 // Extract the LLC header
11354 vosStatus = vos_pkt_pop_head( vosDataBuff, aucLLCHeader,
11355 WLANTL_LLC_HEADER_LEN);
11356
11357 if ( VOS_STATUS_SUCCESS != vosStatus )
11358 {
11359 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
11360 "WLAN TL: Failed to pop LLC header from packet %d",
11361 vosStatus));
11362
11363 return vosStatus;
11364 }
11365
11366 //Extract the length
11367 vos_mem_copy(&w8023Header.usLenType,
11368 &aucLLCHeader[WLANTL_LLC_HEADER_LEN - sizeof(w8023Header.usLenType)],
11369 sizeof(w8023Header.usLenType) );
11370
11371 vos_pkt_push_head(vosDataBuff, &w8023Header, sizeof(w8023Header));
11372 return VOS_STATUS_SUCCESS;
11373}
11374
Madan Mohan Koyyalamudia148e1e2012-11-30 14:52:59 -080011375/*==========================================================================
11376 FUNCTION WLANTL_FindFrameTypeBcMcUc
11377
11378 DESCRIPTION
11379 Utility function to find whether received frame is broadcast, multicast
11380 or unicast.
11381
11382 DEPENDENCIES
11383 The STA must be registered with TL before this function can be called.
11384
11385 PARAMETERS
11386
11387 IN
11388 pTLCb: pointer to the TL's control block
11389 ucSTAId: identifier of the station being processed
11390 vosDataBuff: pointer to the vos buffer
11391
11392 IN/OUT
11393 pucBcMcUc: pointer to buffer, will contain frame type on return
11394
11395 RETURN VALUE
11396 The result code associated with performing the operation
11397
11398 VOS_STATUS_E_INVAL: invalid input parameters
11399 VOS_STATUS_E_BADMSG: failed to extract info from data buffer
11400 VOS_STATUS_SUCCESS: success
11401
11402 SIDE EFFECTS
11403 None.
11404============================================================================*/
11405VOS_STATUS
11406WLANTL_FindFrameTypeBcMcUc
11407(
11408 WLANTL_CbType *pTLCb,
11409 v_U8_t ucSTAId,
11410 vos_pkt_t *vosDataBuff,
11411 v_U8_t *pucBcMcUc
11412)
11413{
11414 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
11415 v_PVOID_t aucBDHeader;
11416 v_PVOID_t pvPeekData;
11417 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
11418
11419 /*------------------------------------------------------------------------
11420 Sanity check
11421 ------------------------------------------------------------------------*/
11422 if ((NULL == pTLCb) ||
11423 (NULL == vosDataBuff) ||
11424 (NULL == pucBcMcUc))
11425 {
11426 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11427 "WLAN TL:Invalid parameter in WLANTL_FindFrameTypeBcMcUc"));
11428 return VOS_STATUS_E_INVAL;
11429 }
11430
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053011431 if ( NULL == pTLCb->atlSTAClients[ucSTAId] )
11432 {
11433 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11434 "WLAN TL:Client Memory was not allocated on %s", __func__));
11435 return VOS_STATUS_E_FAILURE;
11436 }
11437
Madan Mohan Koyyalamudia148e1e2012-11-30 14:52:59 -080011438 /*------------------------------------------------------------------------
11439 Extract BD header and check if valid
11440 ------------------------------------------------------------------------*/
11441 vosStatus = WDA_DS_PeekRxPacketInfo(vosDataBuff, (v_PVOID_t)&aucBDHeader, 0/*Swap BD*/ );
11442
11443 if (NULL == aucBDHeader)
11444 {
11445 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11446 "WLAN TL:WLANTL_FindFrameTypeBcMcUc - Cannot extract BD header"));
11447 VOS_ASSERT(0);
11448 return VOS_STATUS_E_BADMSG;
11449 }
11450
11451 if ((0 == WDA_GET_RX_FT_DONE(aucBDHeader)) &&
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053011452 (0 != pTLCb->atlSTAClients[ucSTAId]->wSTADesc.ucSwFrameRXXlation))
Madan Mohan Koyyalamudia148e1e2012-11-30 14:52:59 -080011453 {
11454 /* Its an 802.11 frame, extract MAC address 1 */
11455 TLLOG2(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
11456 "WLAN TL:WLANTL_FindFrameTypeBcMcUc - 802.11 frame, peeking Addr1"));
11457 vosStatus = vos_pkt_peek_data(vosDataBuff, WLANTL_MAC_ADDR_ALIGN(1),
11458 (v_PVOID_t)&pvPeekData, VOS_MAC_ADDR_SIZE);
11459 }
11460 else
11461 {
11462 /* Its an 802.3 frame, extract Destination MAC address */
11463 TLLOG2(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
11464 "WLAN TL:WLANTL_FindFrameTypeBcMcUc - 802.3 frame, peeking DA"));
11465 vosStatus = vos_pkt_peek_data(vosDataBuff, WLANTL_MAC_ADDR_ALIGN(0),
11466 (v_PVOID_t)&pvPeekData, VOS_MAC_ADDR_SIZE);
11467 }
11468
11469 if (VOS_STATUS_SUCCESS != vosStatus)
11470 {
11471 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11472 "WLAN TL:WLANTL_FindFrameTypeBcMcUc - Failed to peek MAC address"));
11473 return vosStatus;
11474 }
11475
11476 if (((tANI_U8 *)pvPeekData)[0] == 0xff)
11477 {
11478 *pucBcMcUc = WLANTL_FRAME_TYPE_BCAST;
11479 }
11480 else
11481 {
11482 if ((((tANI_U8 *)pvPeekData)[0] & 0x01) == 0x01)
11483 *pucBcMcUc = WLANTL_FRAME_TYPE_MCAST;
11484 else
11485 *pucBcMcUc = WLANTL_FRAME_TYPE_UCAST;
11486 }
11487
11488 TLLOG2(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
11489 "WLAN TL:WLANTL_FindFrameTypeBcMcUc - Addr1Byte1 is: %x",
11490 ((tANI_U8 *)pvPeekData)[0]));
11491
11492 return VOS_STATUS_SUCCESS;
11493}
11494
Jeff Johnson295189b2012-06-20 16:38:30 -070011495#if 0
11496#ifdef WLAN_PERF
11497/*==========================================================================
11498 FUNCTION WLANTL_FastHwFwdDataFrame
11499
11500 DESCRIPTION
11501 Fast path function to quickly forward a data frame if HAL determines BD
11502 signature computed here matches the signature inside current VOSS packet.
11503 If there is a match, HAL and TL fills in the swapped packet length into
11504 BD header and DxE header, respectively. Otherwise, packet goes back to
11505 normal (slow) path and a new BD signature would be tagged into BD in this
11506 VOSS packet later by the WLANHAL_FillTxBd() function.
11507
11508 DEPENDENCIES
11509
11510 PARAMETERS
11511
11512 IN
11513 pvosGCtx VOS context
11514 vosDataBuff Ptr to VOSS packet
11515 pMetaInfo For getting frame's TID
11516 pStaInfo For checking STA type
11517
11518 OUT
11519 pvosStatus returned status
11520 puFastFwdOK Flag to indicate whether frame could be fast forwarded
11521
11522 RETURN VALUE
11523 No return.
11524
11525 SIDE EFFECTS
11526
11527============================================================================*/
11528static void
11529WLANTL_FastHwFwdDataFrame
11530(
11531 v_PVOID_t pvosGCtx,
11532 vos_pkt_t* vosDataBuff,
11533 VOS_STATUS* pvosStatus,
11534 v_U32_t* puFastFwdOK,
11535 WLANTL_MetaInfoType* pMetaInfo,
11536 WLAN_STADescType* pStaInfo
11537
11538)
11539{
11540 v_PVOID_t pvPeekData;
11541 v_U8_t ucDxEBDWLANHeaderLen = WLANTL_BD_HEADER_LEN(0) + sizeof(WLANBAL_sDXEHeaderType);
11542 v_U8_t ucIsUnicast;
11543 WLANBAL_sDXEHeaderType *pDxEHeader;
11544 v_PVOID_t pvBDHeader;
11545 v_PVOID_t pucBuffPtr;
11546 v_U16_t usPktLen;
11547
11548 /*-----------------------------------------------------------------------
11549 Extract packet length
11550 -----------------------------------------------------------------------*/
11551
11552 vos_pkt_get_packet_length( vosDataBuff, &usPktLen);
11553
11554 /*-----------------------------------------------------------------------
11555 Extract MAC address
11556 -----------------------------------------------------------------------*/
11557 *pvosStatus = vos_pkt_peek_data( vosDataBuff,
11558 WLANTL_MAC_ADDR_ALIGN(0),
11559 (v_PVOID_t)&pvPeekData,
11560 VOS_MAC_ADDR_SIZE );
11561
11562 if ( VOS_STATUS_SUCCESS != *pvosStatus )
11563 {
11564 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11565 "WLAN TL:Failed while attempting to extract MAC Addr %d",
11566 *pvosStatus));
11567 *pvosStatus = VOS_STATUS_E_INVAL;
11568 return;
11569 }
11570
11571 /*-----------------------------------------------------------------------
11572 Reserve head room for DxE header, BD, and WLAN header
11573 -----------------------------------------------------------------------*/
11574
11575 vos_pkt_reserve_head( vosDataBuff, &pucBuffPtr,
11576 ucDxEBDWLANHeaderLen );
11577 if ( NULL == pucBuffPtr )
11578 {
11579 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Jeff Johnsonddec6482017-09-19 08:33:57 -070011580 "WLAN TL:No enough space in VOSS packet %pK for DxE/BD/WLAN header", vosDataBuff));
Jeff Johnson295189b2012-06-20 16:38:30 -070011581 *pvosStatus = VOS_STATUS_E_INVAL;
11582 return;
11583 }
11584 pDxEHeader = (WLANBAL_sDXEHeaderType *)pucBuffPtr;
11585 pvBDHeader = (v_PVOID_t) &pDxEHeader[1];
11586
11587 /* UMA Tx acceleration is enabled.
11588 * UMA would help convert frames to 802.11, fill partial BD fields and
11589 * construct LLC header. To further accelerate this kind of frames,
11590 * HAL would attempt to reuse the BD descriptor if the BD signature
11591 * matches to the saved BD descriptor.
11592 */
11593 if(pStaInfo->wSTAType == WLAN_STA_IBSS)
11594 ucIsUnicast = !(((tANI_U8 *)pvPeekData)[0] & 0x01);
11595 else
11596 ucIsUnicast = 1;
11597
11598 *puFastFwdOK = (v_U32_t) WLANHAL_TxBdFastFwd(pvosGCtx, pvPeekData, pMetaInfo->ucTID, ucIsUnicast, pvBDHeader, usPktLen );
11599
11600 /* Can't be fast forwarded. Trim the VOS head back to original location. */
11601 if(! *puFastFwdOK){
11602 vos_pkt_trim_head(vosDataBuff, ucDxEBDWLANHeaderLen);
11603 }else{
11604 /* could be fast forwarded. Now notify BAL DxE header filling could be completely skipped
11605 */
11606 v_U32_t uPacketSize = WLANTL_BD_HEADER_LEN(0) + usPktLen;
11607 vos_pkt_set_user_data_ptr( vosDataBuff, VOS_PKT_USER_DATA_ID_BAL,
11608 (v_PVOID_t)uPacketSize);
11609 pDxEHeader->size = SWAP_ENDIAN_UINT32(uPacketSize);
11610 }
11611 *pvosStatus = VOS_STATUS_SUCCESS;
11612 return;
11613}
11614#endif /*WLAN_PERF*/
11615#endif
11616
11617#if 0
11618/*==========================================================================
11619 FUNCTION WLANTL_PrepareBDHeader
11620
11621 DESCRIPTION
11622 Inline function for preparing BD header before HAL processing.
11623
11624 DEPENDENCIES
11625 Just notify HAL that suspend in TL is complete.
11626
11627 PARAMETERS
11628
11629 IN
11630 vosDataBuff: vos data buffer
11631 ucDisableFrmXtl: is frame xtl disabled
11632
11633 OUT
11634 ppvBDHeader: it will contain the BD header
11635 pvDestMacAdddr: it will contain the destination MAC address
11636 pvosStatus: status of the combined processing
11637 pusPktLen: packet len.
11638
11639 RETURN VALUE
11640 No return.
11641
11642 SIDE EFFECTS
11643
11644============================================================================*/
11645void
11646WLANTL_PrepareBDHeader
11647(
11648 vos_pkt_t* vosDataBuff,
11649 v_PVOID_t* ppvBDHeader,
11650 v_MACADDR_t* pvDestMacAdddr,
11651 v_U8_t ucDisableFrmXtl,
11652 VOS_STATUS* pvosStatus,
11653 v_U16_t* pusPktLen,
11654 v_U8_t ucQosEnabled,
11655 v_U8_t ucWDSEnabled,
11656 v_U8_t extraHeadSpace
11657)
11658{
11659 v_U8_t ucHeaderOffset;
11660 v_U8_t ucHeaderLen;
Jeff Johnson295189b2012-06-20 16:38:30 -070011661 v_U8_t ucBDHeaderLen = WLANTL_BD_HEADER_LEN(ucDisableFrmXtl);
11662
11663 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
11664 /*-------------------------------------------------------------------------
11665 Get header pointer from VOSS
11666 !!! make sure reserve head zeros out the memory
11667 -------------------------------------------------------------------------*/
11668 vos_pkt_get_packet_length( vosDataBuff, pusPktLen);
11669
11670 if ( WLANTL_MAC_HEADER_LEN(ucDisableFrmXtl) > *pusPktLen )
11671 {
11672 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11673 "WLAN TL: Length of the packet smaller than expected network"
11674 " header %d", *pusPktLen ));
11675
11676 *pvosStatus = VOS_STATUS_E_INVAL;
11677 return;
11678 }
11679
11680 vos_pkt_reserve_head( vosDataBuff, ppvBDHeader,
11681 ucBDHeaderLen );
11682 if ( NULL == *ppvBDHeader )
11683 {
11684 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11685 "WLAN TL:VOSS packet corrupted on Attach BD header"));
11686 *pvosStatus = VOS_STATUS_E_INVAL;
11687 return;
11688 }
11689
11690 /*-----------------------------------------------------------------------
11691 Extract MAC address
11692 -----------------------------------------------------------------------*/
Jeff Johnson295189b2012-06-20 16:38:30 -070011693 {
11694 v_SIZE_t usMacAddrSize = VOS_MAC_ADDR_SIZE;
11695 *pvosStatus = vos_pkt_extract_data( vosDataBuff,
11696 ucBDHeaderLen +
11697 WLANTL_MAC_ADDR_ALIGN(ucDisableFrmXtl),
11698 (v_PVOID_t)pvDestMacAdddr,
11699 &usMacAddrSize );
11700 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011701 if ( VOS_STATUS_SUCCESS != *pvosStatus )
11702 {
11703 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11704 "WLAN TL:Failed while attempting to extract MAC Addr %d",
11705 *pvosStatus));
11706 }
11707 else
11708 {
11709 /*---------------------------------------------------------------------
11710 Fill MPDU info fields:
11711 - MPDU data start offset
11712 - MPDU header start offset
11713 - MPDU header length
11714 - MPDU length - this is a 16b field - needs swapping
11715 --------------------------------------------------------------------*/
11716 ucHeaderOffset = ucBDHeaderLen;
11717 ucHeaderLen = WLANTL_MAC_HEADER_LEN(ucDisableFrmXtl);
11718
11719 if ( 0 != ucDisableFrmXtl )
11720 {
11721 if ( 0 != ucQosEnabled )
11722 {
11723 ucHeaderLen += WLANTL_802_11_HEADER_QOS_CTL;
11724 }
11725
11726 // Similar to Qos we need something for WDS format !
11727 if ( ucWDSEnabled != 0 )
11728 {
11729 // If we have frame translation enabled
11730 ucHeaderLen += WLANTL_802_11_HEADER_ADDR4_LEN;
11731 }
11732 if ( extraHeadSpace != 0 )
11733 {
11734 // Decrease the packet length with the extra padding after the header
11735 *pusPktLen = *pusPktLen - extraHeadSpace;
11736 }
11737 }
11738
11739 WLANHAL_TX_BD_SET_MPDU_HEADER_LEN( *ppvBDHeader, ucHeaderLen);
11740 WLANHAL_TX_BD_SET_MPDU_HEADER_OFFSET( *ppvBDHeader, ucHeaderOffset);
11741 WLANHAL_TX_BD_SET_MPDU_DATA_OFFSET( *ppvBDHeader,
11742 ucHeaderOffset + ucHeaderLen + extraHeadSpace);
11743 WLANHAL_TX_BD_SET_MPDU_LEN( *ppvBDHeader, *pusPktLen);
11744
11745 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
11746 "WLAN TL: VALUES ARE HLen=%x Hoff=%x doff=%x len=%x ex=%d",
11747 ucHeaderLen, ucHeaderOffset,
11748 (ucHeaderOffset + ucHeaderLen + extraHeadSpace),
11749 *pusPktLen, extraHeadSpace));
11750 }/* if peek MAC success*/
11751
11752}/* WLANTL_PrepareBDHeader */
11753#endif
11754
Jeff Johnson295189b2012-06-20 16:38:30 -070011755//THIS IS A HACK AND NEEDS TO BE FIXED FOR CONCURRENCY
11756/*==========================================================================
11757 FUNCTION WLAN_TLGetNextTxIds
11758
11759 DESCRIPTION
11760 Gets the next station and next AC in the list that should be served by the TL.
11761
11762 Multiple Station Scheduling and TL queue management.
11763
11764 4 HDD BC/MC data packet queue status is specified as Station 0's status. Weights used
11765 in WFQ algorith are initialized in WLANTL_OPEN and contained in tlConfigInfo field.
11766 Each station has fields of ucPktPending and AC mask to tell whether a AC has traffic
11767 or not.
11768
11769 Stations are served in a round-robin fashion from highest priority to lowest priority.
11770 The number of round-robin times of each prioirty equals to the WFQ weights and differetiates
11771 the traffic of different prioirty. As such, stations can not provide low priority packets if
11772 high priority packets are all served.
11773
11774 DEPENDENCIES
11775
11776 PARAMETERS
11777
11778 IN
11779 pvosGCtx: pointer to the global vos context; a handle to TL's
11780 control block can be extracted from its context
11781
11782 OUT
11783 pucSTAId: Station ID
11784
11785 RETURN VALUE
11786 The result code associated with performing the operation
11787
11788 VOS_STATUS_SUCCESS: Everything is good
11789
11790 SIDE EFFECTS
11791
11792 TL context contains currently served station ID in ucCurrentSTA field, currently served AC
11793 in uCurServedAC field, and unserved weights of current AC in uCurLeftWeight.
11794 When existing from the function, these three fields are changed accordingly.
11795
11796============================================================================*/
11797VOS_STATUS
11798WLAN_TLAPGetNextTxIds
11799(
11800 v_PVOID_t pvosGCtx,
11801 v_U8_t* pucSTAId
11802)
11803{
11804 WLANTL_CbType* pTLCb;
11805 v_U8_t ucACFilter = 1;
Sravan Kumar Kairamb0edc612016-10-26 13:55:24 +053011806 v_U8_t ucNextSTA, ucTempSTA;
Jeff Johnson295189b2012-06-20 16:38:30 -070011807 v_BOOL_t isServed = TRUE; //current round has find a packet or not
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +053011808 v_U8_t ucACLoopNum = WLANTL_AC_HIGH_PRIO + 1; //number of loop to go
Jeff Johnson295189b2012-06-20 16:38:30 -070011809 v_U8_t uFlowMask; // TX FlowMask from WDA
11810 uint8 ucACMask;
Sravan Kumar Kairamb0edc612016-10-26 13:55:24 +053011811 uint8 i = 0;
11812 uint8 j;
Sravan Kumar Kairam18017eb2017-01-03 14:58:13 +053011813 uint8 minWeightSta;
11814 uint32_t sta_bitmask = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070011815 /*------------------------------------------------------------------------
11816 Extract TL control block
11817 ------------------------------------------------------------------------*/
11818 //ENTER();
11819
11820 pTLCb = VOS_GET_TL_CB(pvosGCtx);
11821 if ( NULL == pTLCb )
11822 {
11823 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11824 "WLAN TL:Invalid TL pointer from pvosGCtx on WLAN_TLAPGetNextTxIds"));
11825 return VOS_STATUS_E_FAULT;
11826 }
11827
11828 if ( VOS_STATUS_SUCCESS != WDA_DS_GetTxFlowMask( pvosGCtx, &uFlowMask ) )
11829 {
11830 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11831 "WLAN TL:Failed to retrieve Flow control mask from WDA"));
11832 return VOS_STATUS_E_FAULT;
11833 }
11834
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +053011835 /* The flow mask does not differentiate between different ACs/Qs
11836 * since we use a single dxe channel for all ACs/Qs, hence it is
11837 * enough to check that there are dxe resources on data channel
11838 */
11839 uFlowMask &= WLANTL_DATA_FLOW_MASK;
11840
11841 if (0 == uFlowMask)
11842 {
11843 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11844 "WLAN TL: No resources to send packets"));
11845
11846 // Setting STA Id to invalid if mask is 0
11847 *pucSTAId = WLAN_MAX_STA_COUNT;
11848 return VOS_STATUS_E_FAULT;
11849 }
11850
Jeff Johnson295189b2012-06-20 16:38:30 -070011851 ucNextSTA = pTLCb->ucCurrentSTA;
11852
11853 ++ucNextSTA;
11854
11855 if ( WLAN_MAX_STA_COUNT <= ucNextSTA )
Jeff Johnson295189b2012-06-20 16:38:30 -070011856 ucNextSTA = 0;
Sravan Kumar Kairam715072e2017-03-10 17:12:43 +053011857
Jeff Johnson295189b2012-06-20 16:38:30 -070011858 isServed = FALSE;
11859 if ( 0 == pTLCb->ucCurLeftWeight )
11860 {
11861 //current prioirty is done
11862 if ( WLANTL_AC_BK == (WLANTL_ACEnumType)pTLCb->uCurServedAC )
11863 {
11864 //end of current VO, VI, BE, BK loop. Reset priority.
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +053011865 pTLCb->uCurServedAC = WLANTL_AC_HIGH_PRIO;
Jeff Johnson295189b2012-06-20 16:38:30 -070011866 }
11867 else
11868 {
11869 pTLCb->uCurServedAC --;
11870 }
11871
11872 pTLCb->ucCurLeftWeight = pTLCb->tlConfigInfo.ucAcWeights[pTLCb->uCurServedAC];
11873
11874 } // (0 == pTLCb->ucCurLeftWeight)
Jeff Johnson295189b2012-06-20 16:38:30 -070011875
Sravan Kumar Kairamb0edc612016-10-26 13:55:24 +053011876 ucTempSTA = ucNextSTA;
Sravan Kumar Kairam18017eb2017-01-03 14:58:13 +053011877 minWeightSta = ucNextSTA;
Sravan Kumar Kairamb0edc612016-10-26 13:55:24 +053011878
Jeff Johnson295189b2012-06-20 16:38:30 -070011879 //decide how many loops to go. if current loop is partial, do one extra to make sure
11880 //we cover every station
11881 if ((1 == pTLCb->ucCurLeftWeight) && (ucNextSTA != 0))
11882 {
11883 ucACLoopNum ++; // now is 5 loops
11884 }
11885
11886 /* Start with highest priority. ucNextSTA, pTLCb->uCurServedAC, pTLCb->ucCurLeftWeight
11887 all have previous values.*/
11888 for (; ucACLoopNum > 0; ucACLoopNum--)
11889 {
11890
11891 ucACFilter = 1 << pTLCb->uCurServedAC;
11892
11893 // pTLCb->ucCurLeftWeight keeps previous results.
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +053011894 for (; (pTLCb->ucCurLeftWeight > 0) ; pTLCb->ucCurLeftWeight-- )
Jeff Johnson295189b2012-06-20 16:38:30 -070011895 {
11896
11897 for ( ; ucNextSTA < WLAN_MAX_STA_COUNT; ucNextSTA ++ )
11898 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053011899 if(NULL == pTLCb->atlSTAClients[ucNextSTA])
11900 {
11901 continue;
11902 }
11903 WLAN_TL_AC_ARRAY_2_MASK (pTLCb->atlSTAClients[ucNextSTA], ucACMask, i);
Jeff Johnson295189b2012-06-20 16:38:30 -070011904
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053011905 if ( (0 == pTLCb->atlSTAClients[ucNextSTA]->ucExists) ||
11906 ((0 == pTLCb->atlSTAClients[ucNextSTA]->ucPktPending) && !(ucACMask)) ||
Jeff Johnson295189b2012-06-20 16:38:30 -070011907 (0 == (ucACMask & ucACFilter)) )
11908
11909 {
Tushnim Bhattacharyya39a8f182013-02-20 18:10:30 -080011910 //current station does not exist or have any packet to serve.
11911 continue;
11912 }
11913
Bhargav Shahfbaeca22016-07-13 10:27:35 +053011914 if ((WLANTL_STA_AUTHENTICATED != pTLCb->atlSTAClients[ucNextSTA]->tlState)
11915 || (pTLCb->atlSTAClients[ucNextSTA]->disassoc_progress == VOS_TRUE ))
Tushnim Bhattacharyya39a8f182013-02-20 18:10:30 -080011916 {
11917 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
11918 "%s Sta %d not in auth state so skipping it.",
11919 __func__, ucNextSTA));
Jeff Johnson295189b2012-06-20 16:38:30 -070011920 continue;
11921 }
11922
11923 //go to next station if current station can't send due to flow control
11924 //Station is allowed to send when it is not in LWM mode. When station is in LWM mode,
11925 //station is allowed to send only after FW reports FW memory is below threshold and on-fly
11926 //packets are less then allowed value
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053011927 if ( (TRUE == pTLCb->atlSTAClients[ucNextSTA]->ucLwmModeEnabled) &&
11928 ((FALSE == pTLCb->atlSTAClients[ucNextSTA]->ucLwmEventReported) ||
11929 (0 < pTLCb->atlSTAClients[ucNextSTA]->uBuffThresholdMax))
Jeff Johnson295189b2012-06-20 16:38:30 -070011930 )
11931 {
11932 continue;
11933 }
11934
Sravan Kumar Kairamb0edc612016-10-26 13:55:24 +053011935 /*
11936 * Initial weight is 0 is for all the stations. As part of FW TX stats
11937 * indication to host, good peer weight is updated to one and the
11938 * remaining peers weight is updated based on their RA rates and BTQM
11939 * queued frames length. TL skips fetching the packet until the station
11940 * has got chances equal to its weight.
11941 */
11942 if (pTLCb->atlSTAClients[ucNextSTA]->weight > WLANTL_GOOD_STA_WEIGHT) {
11943 if (pTLCb->atlSTAClients[ucNextSTA]->weight_count <=
Sravan Kumar Kairam18017eb2017-01-03 14:58:13 +053011944 pTLCb->atlSTAClients[ucNextSTA]->weight)
11945 {
11946 if (pTLCb->atlSTAClients[minWeightSta]->weight <= 1)
11947 minWeightSta = ucNextSTA;
11948 else if (pTLCb->atlSTAClients[ucNextSTA]->weight <
11949 pTLCb->atlSTAClients[minWeightSta]->weight) {
11950 minWeightSta = ucNextSTA;
11951 }
11952 sta_bitmask |= (1 << ucNextSTA);
Sravan Kumar Kairamb0edc612016-10-26 13:55:24 +053011953 pTLCb->atlSTAClients[ucNextSTA]->weight_count++;
11954 continue;
11955 }
11956 else
11957 pTLCb->atlSTAClients[ucNextSTA]->weight_count = 0;
11958 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011959
11960 // Find a station. Weight is updated already.
11961 *pucSTAId = ucNextSTA;
11962 pTLCb->ucCurrentSTA = ucNextSTA;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053011963 pTLCb->atlSTAClients[*pucSTAId]->ucCurrentAC = pTLCb->uCurServedAC;
Jeff Johnson295189b2012-06-20 16:38:30 -070011964
11965 TLLOG4(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_LOW,
11966 " TL serve one station AC: %d W: %d StaId: %d",
11967 pTLCb->uCurServedAC, pTLCb->ucCurLeftWeight, pTLCb->ucCurrentSTA ));
11968
Sravan Kumar Kairam715072e2017-03-10 17:12:43 +053011969 pTLCb->ucCurLeftWeight--;
Jeff Johnson295189b2012-06-20 16:38:30 -070011970 return VOS_STATUS_SUCCESS;
11971 } //STA loop
11972
Sravan Kumar Kairamb0edc612016-10-26 13:55:24 +053011973 for (j = 0; j < ucTempSTA; j++) {
11974 if (NULL == pTLCb->atlSTAClients[j])
11975 continue;
11976
11977 WLAN_TL_AC_ARRAY_2_MASK (pTLCb->atlSTAClients[j], ucACMask, i);
11978
11979 if ((0 == pTLCb->atlSTAClients[j]->ucExists) ||
11980 ((0 == pTLCb->atlSTAClients[j]->ucPktPending) && !(ucACMask)) ||
11981 (0 == (ucACMask & ucACFilter)))
11982 continue;
11983
11984 if ((WLANTL_STA_AUTHENTICATED != pTLCb->atlSTAClients[j]->tlState) ||
11985 (pTLCb->atlSTAClients[j]->disassoc_progress == VOS_TRUE)) {
11986 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
11987 "%s Sta %d not in auth state so skipping it.",
11988 __func__, ucNextSTA));
11989 continue;
11990 }
11991
11992 if ((TRUE == pTLCb->atlSTAClients[j]->ucLwmModeEnabled) &&
11993 ((FALSE == pTLCb->atlSTAClients[j]->ucLwmEventReported) ||
11994 (0 < pTLCb->atlSTAClients[j]->uBuffThresholdMax)))
11995 continue;
11996
11997 if (pTLCb->atlSTAClients[j]->weight > WLANTL_GOOD_STA_WEIGHT) {
11998 if (pTLCb->atlSTAClients[j]->weight_count <=
Sravan Kumar Kairam18017eb2017-01-03 14:58:13 +053011999 pTLCb->atlSTAClients[j]->weight)
12000 {
12001 if (pTLCb->atlSTAClients[minWeightSta]->weight <= 1)
12002 minWeightSta = j;
12003 else if (pTLCb->atlSTAClients[j]->weight <
12004 pTLCb->atlSTAClients[minWeightSta]->weight) {
12005 minWeightSta = j;
12006 }
12007 sta_bitmask |= (1 << j);
Sravan Kumar Kairamb0edc612016-10-26 13:55:24 +053012008 pTLCb->atlSTAClients[j]->weight_count++;
12009 continue;
12010 }
12011 else
12012 pTLCb->atlSTAClients[j]->weight_count = 0;
12013 }
12014
12015 *pucSTAId = j;
12016 pTLCb->ucCurrentSTA = j;
12017 pTLCb->atlSTAClients[*pucSTAId]->ucCurrentAC = pTLCb->uCurServedAC;
12018
12019 TLLOG4(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_LOW,
12020 " TL serve one station AC: %d W: %d StaId: %d",
12021 pTLCb->uCurServedAC, pTLCb->ucCurLeftWeight, pTLCb->ucCurrentSTA ));
Sravan Kumar Kairam715072e2017-03-10 17:12:43 +053012022 pTLCb->ucCurLeftWeight--;
Sravan Kumar Kairamb0edc612016-10-26 13:55:24 +053012023 return VOS_STATUS_SUCCESS;
12024 }
12025
Sravan Kumar Kairam18017eb2017-01-03 14:58:13 +053012026 /* Fecth packet from the stations with minimum weight among them */
12027 if (pTLCb->atlSTAClients[minWeightSta] &&
12028 pTLCb->atlSTAClients[minWeightSta]->ucPktPending)
12029 {
12030 *pucSTAId = minWeightSta;
12031 pTLCb->ucCurrentSTA = minWeightSta;
12032 pTLCb->atlSTAClients[*pucSTAId]->ucCurrentAC = pTLCb->uCurServedAC;
12033
12034 for (j = 0; sta_bitmask != 0; sta_bitmask >>= 1, j++)
12035 {
12036 if (0 == (sta_bitmask & 0x1))
12037 continue;
12038
12039 if (minWeightSta == j)
12040 continue;
12041 /* To ensure fairness between stations */
12042 pTLCb->atlSTAClients[j]->weight_count +=
12043 pTLCb->atlSTAClients[minWeightSta]->weight -
12044 pTLCb->atlSTAClients[minWeightSta]->weight_count;
12045 }
12046 pTLCb->atlSTAClients[minWeightSta]->weight_count = 0;
12047
12048 TLLOG4(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_LOW,
12049 " TL serve one station AC: %d W: %d StaId: %d",
12050 pTLCb->uCurServedAC, pTLCb->ucCurLeftWeight, pTLCb->ucCurrentSTA ));
Sravan Kumar Kairam715072e2017-03-10 17:12:43 +053012051 pTLCb->ucCurLeftWeight--;
Sravan Kumar Kairam18017eb2017-01-03 14:58:13 +053012052 return VOS_STATUS_SUCCESS;
12053 }
12054
Jeff Johnson295189b2012-06-20 16:38:30 -070012055 ucNextSTA = 0;
12056 if ( FALSE == isServed )
12057 {
12058 //current loop finds no packet.no need to repeat for the same priority
12059 break;
12060 }
12061 //current loop is partial loop. go for one more loop.
12062 isServed = FALSE;
12063
12064 } //Weight loop
12065
12066 if (WLANTL_AC_BK == pTLCb->uCurServedAC)
12067 {
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +053012068 pTLCb->uCurServedAC = WLANTL_AC_HIGH_PRIO;
Jeff Johnson295189b2012-06-20 16:38:30 -070012069 }
12070 else
12071 {
12072 pTLCb->uCurServedAC--;
12073 }
12074 pTLCb->ucCurLeftWeight = pTLCb->tlConfigInfo.ucAcWeights[pTLCb->uCurServedAC];
12075
12076 }// AC loop
12077
12078 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
Arif Hussainf2b00992013-11-17 21:46:15 -080012079 " TL can't find one station to serve" ));
Jeff Johnson295189b2012-06-20 16:38:30 -070012080
12081 pTLCb->uCurServedAC = WLANTL_AC_BK;
12082 pTLCb->ucCurLeftWeight = 1;
12083 //invalid number will be captured by caller
12084 pTLCb->ucCurrentSTA = WLAN_MAX_STA_COUNT;
12085
12086 *pucSTAId = pTLCb->ucCurrentSTA;
Jeff Johnson295189b2012-06-20 16:38:30 -070012087 return VOS_STATUS_E_FAULT;
12088}
12089
12090
12091/*==========================================================================
12092 FUNCTION WLAN_TLGetNextTxIds
12093
12094 DESCRIPTION
12095 Gets the next station and next AC in the list
12096
12097 DEPENDENCIES
12098
12099 PARAMETERS
12100
12101 IN
12102 pvosGCtx: pointer to the global vos context; a handle to TL's
12103 control block can be extracted from its context
12104
12105 OUT
12106 pucSTAId: Station ID
12107
12108
12109 RETURN VALUE
12110 The result code associated with performing the operation
12111
12112 VOS_STATUS_SUCCESS: Everything is good :)
12113
12114 SIDE EFFECTS
12115
12116============================================================================*/
12117VOS_STATUS
12118WLAN_TLGetNextTxIds
12119(
12120 v_PVOID_t pvosGCtx,
12121 v_U8_t* pucSTAId
12122)
12123{
12124 WLANTL_CbType* pTLCb;
12125 v_U8_t ucNextAC;
12126 v_U8_t ucNextSTA;
12127 v_U8_t ucCount;
12128 v_U8_t uFlowMask; // TX FlowMask from WDA
12129 v_U8_t ucACMask = 0;
12130 v_U8_t i = 0;
12131
12132 tBssSystemRole systemRole; //RG HACK to be removed
12133 tpAniSirGlobal pMac;
12134
12135 pMac = vos_get_context(VOS_MODULE_ID_PE, pvosGCtx);
12136 if ( NULL == pMac )
12137 {
12138 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070012139 "%s: Invalid pMac", __func__));
Jeff Johnson295189b2012-06-20 16:38:30 -070012140 return VOS_STATUS_E_FAULT;
12141 }
12142
12143 systemRole = wdaGetGlobalSystemRole(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -070012144
Jeff Johnson295189b2012-06-20 16:38:30 -070012145 /*------------------------------------------------------------------------
12146 Extract TL control block
12147 ------------------------------------------------------------------------*/
12148 pTLCb = VOS_GET_TL_CB(pvosGCtx);
12149 if ( NULL == pTLCb )
12150 {
12151 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
12152 "WLAN TL:Invalid TL pointer from pvosGCtx on WLAN_TLGetNextTxIds"));
12153 return VOS_STATUS_E_FAULT;
12154 }
12155
Sunil Ravid5406f22013-01-22 00:18:31 -080012156#ifdef FEATURE_WLAN_TDLS
Agarwal Ashishcd86f7b2014-06-16 17:11:58 +053012157 if ((eSYSTEM_AP_ROLE == systemRole) ||
Katya Nigam1fd24402015-02-16 14:52:19 +053012158 (eSYSTEM_STA_IN_IBSS_ROLE == systemRole) ||
Agarwal Ashishcd86f7b2014-06-16 17:11:58 +053012159 (vos_concurrent_open_sessions_running()) || pTLCb->ucTdlsPeerCount)
Sunil Ravid5406f22013-01-22 00:18:31 -080012160#else
Agarwal Ashishcd86f7b2014-06-16 17:11:58 +053012161 if ((eSYSTEM_AP_ROLE == systemRole) ||
Katya Nigam1fd24402015-02-16 14:52:19 +053012162 (eSYSTEM_STA_IN_IBSS_ROLE == systemRole) ||
Agarwal Ashishcd86f7b2014-06-16 17:11:58 +053012163 (vos_concurrent_open_sessions_running()))
Sunil Ravid5406f22013-01-22 00:18:31 -080012164#endif
12165 {
12166 return WLAN_TLAPGetNextTxIds(pvosGCtx,pucSTAId);
12167 }
12168
12169
Jeff Johnson295189b2012-06-20 16:38:30 -070012170 if ( VOS_STATUS_SUCCESS != WDA_DS_GetTxFlowMask( pvosGCtx, &uFlowMask ) )
12171 {
12172 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
12173 "WLAN TL:Failed to retrieve Flow control mask from WDA"));
12174 return VOS_STATUS_E_FAULT;
12175 }
12176
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +053012177 /* The flow mask does not differentiate between different ACs/Qs
12178 * since we use a single dxe channel for all ACs/Qs, hence it is
12179 * enough to check that there are dxe resources on data channel
12180 */
12181 uFlowMask &= WLANTL_DATA_FLOW_MASK;
12182
12183 if (0 == uFlowMask)
12184 {
12185 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
12186 "WLAN TL: No resources to send packets"));
12187
12188 // Setting STA id to invalid if mask is 0
12189 *pucSTAId = WLAN_MAX_STA_COUNT;
12190 return VOS_STATUS_E_FAULT;
12191 }
12192
Jeff Johnson295189b2012-06-20 16:38:30 -070012193 /*STA id - no priority yet implemented */
12194 /*-----------------------------------------------------------------------
12195 Choose the next STA for tx - for now go in a round robin fashion
12196 through all the stations that have pending packets
12197 -------------------------------------------------------------------------*/
12198 ucNextSTA = pTLCb->ucCurrentSTA;
12199
12200 pTLCb->ucCurrentSTA = WLAN_MAX_STA_COUNT;
12201 for ( ucCount = 0;
12202 ucCount < WLAN_MAX_STA_COUNT;
12203 ucCount++ )
12204 {
12205 ucNextSTA = ( (ucNextSTA+1) >= WLAN_MAX_STA_COUNT )?0:(ucNextSTA+1);
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053012206 if(NULL == pTLCb->atlSTAClients[ucNextSTA])
12207 {
12208 continue;
12209 }
Sravan Kumar Kairamb0edc612016-10-26 13:55:24 +053012210
12211 if ((pTLCb->atlSTAClients[ucNextSTA]->weight > WLANTL_GOOD_STA_WEIGHT) &&
12212 (pTLCb->atlSTAClients[ucNextSTA]->ucPktPending)) {
12213 if (pTLCb->atlSTAClients[ucNextSTA]->weight_count <=
12214 pTLCb->atlSTAClients[ucNextSTA]->weight) {
12215 pTLCb->atlSTAClients[ucNextSTA]->weight_count++;
12216 continue;
12217 }
12218 else
12219 pTLCb->atlSTAClients[ucNextSTA]->weight_count = 0;
12220 }
12221
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053012222 if (( pTLCb->atlSTAClients[ucNextSTA]->ucExists ) &&
12223 ( pTLCb->atlSTAClients[ucNextSTA]->ucPktPending ))
Jeff Johnson295189b2012-06-20 16:38:30 -070012224 {
Tushnim Bhattacharyya39a8f182013-02-20 18:10:30 -080012225 if (WLANTL_STA_AUTHENTICATED == pTLCb->atlSTAClients[ucNextSTA]->tlState)
12226 {
12227 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
12228 "STA ID: %d on WLAN_TLGetNextTxIds", *pucSTAId));
12229 pTLCb->ucCurrentSTA = ucNextSTA;
12230 break;
Tushnim Bhattacharyya5dd94562013-03-20 20:15:03 -070012231 }
12232 else
12233 {
Tushnim Bhattacharyya39a8f182013-02-20 18:10:30 -080012234 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
12235 "%s Sta %d is not in auth state, skipping this sta.",
12236 __func__, ucNextSTA));
Tushnim Bhattacharyya5dd94562013-03-20 20:15:03 -070012237 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012238 }
12239 }
12240
12241 *pucSTAId = pTLCb->ucCurrentSTA;
12242
12243 if ( WLANTL_STA_ID_INVALID( *pucSTAId ) )
12244 {
12245 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
12246 "WLAN TL:No station registered with TL at this point"));
12247
12248 return VOS_STATUS_E_FAULT;
12249
12250 }
12251
12252 /*Convert the array to a mask for easier operation*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053012253 WLAN_TL_AC_ARRAY_2_MASK( pTLCb->atlSTAClients[*pucSTAId], ucACMask, i);
Jeff Johnson295189b2012-06-20 16:38:30 -070012254
12255 if ( 0 == ucACMask )
12256 {
12257 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
12258 "WLAN TL: Mask 0 "
12259 "STA ID: %d on WLAN_TLGetNextTxIds", *pucSTAId));
12260
12261 /*setting STA id to invalid if mask is 0*/
12262 *pucSTAId = WLAN_MAX_STA_COUNT;
12263
12264 return VOS_STATUS_E_FAULT;
12265 }
12266
12267 /*-----------------------------------------------------------------------
12268 AC is updated whenever a packet is fetched from HDD -> the current
12269 weight of such an AC cannot be 0 -> in this case TL is expected to
12270 exit this function at this point during the main Tx loop
12271 -----------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053012272 if ( 0 < pTLCb->atlSTAClients[*pucSTAId]->ucCurrentWeight )
Jeff Johnson295189b2012-06-20 16:38:30 -070012273 {
12274 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
12275 "WLAN TL: Maintaining serviced AC to: %d for Weight: %d",
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053012276 pTLCb->atlSTAClients[*pucSTAId]->ucCurrentAC ,
12277 pTLCb->atlSTAClients[*pucSTAId]->ucCurrentWeight));
Jeff Johnson295189b2012-06-20 16:38:30 -070012278 return VOS_STATUS_SUCCESS;
12279 }
12280
12281 /*-----------------------------------------------------------------------
12282 Choose highest priority AC - !!! optimize me
12283 -----------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053012284 ucNextAC = pTLCb->atlSTAClients[*pucSTAId]->ucCurrentAC;
Jeff Johnson295189b2012-06-20 16:38:30 -070012285 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
12286 "Next AC: %d", ucNextAC));
12287
12288 while ( 0 != ucACMask )
12289 {
12290 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
12291 " AC Mask: %d Next: %d Res : %d",
12292 ucACMask, ( 1 << ucNextAC ), ( ucACMask & ( 1 << ucNextAC ))));
12293
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +053012294 if ( 0 != ( ucACMask & ( 1 << ucNextAC )))
Jeff Johnson295189b2012-06-20 16:38:30 -070012295 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053012296 pTLCb->atlSTAClients[*pucSTAId]->ucCurrentAC =
Jeff Johnson295189b2012-06-20 16:38:30 -070012297 (WLANTL_ACEnumType)ucNextAC;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053012298 pTLCb->atlSTAClients[*pucSTAId]->ucCurrentWeight =
Jeff Johnson295189b2012-06-20 16:38:30 -070012299 pTLCb->tlConfigInfo.ucAcWeights[ucNextAC];
12300
12301 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
12302 "WLAN TL: Switching serviced AC to: %d with Weight: %d",
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053012303 pTLCb->atlSTAClients[*pucSTAId]->ucCurrentAC ,
12304 pTLCb->atlSTAClients[*pucSTAId]->ucCurrentWeight));
Jeff Johnson295189b2012-06-20 16:38:30 -070012305 break;
12306 }
12307
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +053012308 if (ucNextAC == WLANTL_AC_BK)
12309 ucNextAC = WLANTL_AC_HIGH_PRIO;
12310 else
12311 ucNextAC--;
Jeff Johnson295189b2012-06-20 16:38:30 -070012312
12313 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
12314 "Next AC %d", ucNextAC));
Jeff Johnson295189b2012-06-20 16:38:30 -070012315 }
12316
12317 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
12318 " C AC: %d C W: %d",
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053012319 pTLCb->atlSTAClients[*pucSTAId]->ucCurrentAC,
12320 pTLCb->atlSTAClients[*pucSTAId]->ucCurrentWeight));
Jeff Johnson295189b2012-06-20 16:38:30 -070012321
12322 return VOS_STATUS_SUCCESS;
12323}/* WLAN_TLGetNextTxIds */
12324
Jeff Johnson295189b2012-06-20 16:38:30 -070012325
12326
12327/*==========================================================================
12328 DEFAULT HANDLERS: Registered at initialization with TL
12329 ==========================================================================*/
12330
12331/*==========================================================================
12332
12333 FUNCTION WLANTL_MgmtFrmRxDefaultCb
12334
12335 DESCRIPTION
12336 Default Mgmt Frm rx callback: asserts all the time. If this function gets
12337 called it means there is no registered rx cb pointer for Mgmt Frm.
12338
12339 DEPENDENCIES
12340
12341 PARAMETERS
12342 Not used.
12343
12344 RETURN VALUE
12345
12346 VOS_STATUS_E_FAILURE: Always FAILURE.
12347
12348============================================================================*/
12349VOS_STATUS
12350WLANTL_MgmtFrmRxDefaultCb
12351(
12352 v_PVOID_t pvosGCtx,
12353 v_PVOID_t vosBuff
12354)
12355{
12356 if ( NULL != vosBuff )
12357 {
12358 TLLOGP(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_FATAL,
12359 "WLAN TL:Fatal failure: No registered Mgmt Frm client on pkt RX"));
12360 /* Drop packet */
12361 vos_pkt_return_packet((vos_pkt_t *)vosBuff);
12362 }
12363
Jeff Johnson295189b2012-06-20 16:38:30 -070012364 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
12365 "WLAN TL: No registered Mgmt Frm client on pkt RX. Load/Unload in progress, Ignore"));
Jeff Johnson295189b2012-06-20 16:38:30 -070012366
12367 return VOS_STATUS_E_FAILURE;
12368}/*WLANTL_MgmtFrmRxDefaultCb*/
12369
12370/*==========================================================================
12371
Madan Mohan Koyyalamudi6c2977d2013-09-04 15:42:45 +053012372 FUNCTION WLANTL_BAPRxDefaultCb
Jeff Johnson295189b2012-06-20 16:38:30 -070012373
12374 DESCRIPTION
12375 Default BAP rx callback: asserts all the time. If this function gets
12376 called it means there is no registered rx cb pointer for BAP.
12377
12378 DEPENDENCIES
12379
12380 PARAMETERS
12381 Not used.
12382
12383 RETURN VALUE
12384
12385 VOS_STATUS_E_FAILURE: Always FAILURE.
12386
12387============================================================================*/
12388VOS_STATUS
12389WLANTL_BAPRxDefaultCb
12390(
12391 v_PVOID_t pvosGCtx,
12392 vos_pkt_t* vosDataBuff,
12393 WLANTL_BAPFrameEnumType frameType
12394)
12395{
12396 TLLOGP(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_FATAL,
12397 "WLAN TL:Fatal failure: No registered BAP client on BAP pkt RX"));
12398#ifndef BTAMP_TEST
12399 VOS_ASSERT(0);
12400#endif
12401 return VOS_STATUS_E_FAILURE;
12402}/*WLANTL_MgmtFrmRxDefaultCb*/
12403
12404/*==========================================================================
12405
12406 FUNCTION WLANTL_STARxDefaultCb
12407
12408 DESCRIPTION
12409 Default STA rx callback: asserts all the time. If this function gets
12410 called it means there is no registered rx cb pointer for station.
12411 (Mem corruption most likely, it should never happen)
12412
12413 DEPENDENCIES
12414
12415 PARAMETERS
12416 Not used.
12417
12418 RETURN VALUE
12419
12420 VOS_STATUS_E_FAILURE: Always FAILURE.
12421
12422============================================================================*/
12423VOS_STATUS
12424WLANTL_STARxDefaultCb
12425(
12426 v_PVOID_t pvosGCtx,
12427 vos_pkt_t* vosDataBuff,
12428 v_U8_t ucSTAId,
12429 WLANTL_RxMetaInfoType* pRxMetaInfo
12430)
12431{
12432 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
12433 "WLAN TL: No registered STA client rx cb for STAID: %d dropping pkt",
12434 ucSTAId));
12435 vos_pkt_return_packet(vosDataBuff);
Madan Mohan Koyyalamudi6c2977d2013-09-04 15:42:45 +053012436 return VOS_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012437}/*WLANTL_MgmtFrmRxDefaultCb*/
12438
12439
12440/*==========================================================================
12441
12442 FUNCTION WLANTL_STAFetchPktDefaultCb
12443
12444 DESCRIPTION
12445 Default fetch callback: asserts all the time. If this function gets
12446 called it means there is no registered fetch cb pointer for station.
12447 (Mem corruption most likely, it should never happen)
12448
12449 DEPENDENCIES
12450
12451 PARAMETERS
12452 Not used.
12453
12454 RETURN VALUE
12455
12456 VOS_STATUS_E_FAILURE: Always FAILURE.
12457
12458============================================================================*/
12459VOS_STATUS
12460WLANTL_STAFetchPktDefaultCb
12461(
12462 v_PVOID_t pvosGCtx,
12463 v_U8_t* pucSTAId,
12464 WLANTL_ACEnumType ucAC,
12465 vos_pkt_t** vosDataBuff,
12466 WLANTL_MetaInfoType* tlMetaInfo
12467)
12468{
12469 TLLOGP(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_FATAL,
12470 "WLAN TL:Fatal failure: No registered STA client on data pkt RX"));
12471 VOS_ASSERT(0);
12472 return VOS_STATUS_E_FAILURE;
12473}/*WLANTL_MgmtFrmRxDefaultCb*/
12474
12475/*==========================================================================
12476
12477 FUNCTION WLANTL_TxCompDefaultCb
12478
12479 DESCRIPTION
12480 Default tx complete handler. It will release the completed pkt to
12481 prevent memory leaks.
12482
12483 PARAMETERS
12484
12485 IN
12486 pvosGCtx: pointer to the global vos context; a handle to
12487 TL/HAL/PE/BAP/HDD control block can be extracted from
12488 its context
12489 vosDataBuff: pointer to the VOSS data buffer that was transmitted
12490 wTxSTAtus: status of the transmission
12491
12492
12493 RETURN VALUE
12494 The result code associated with performing the operation; please
12495 check vos_pkt_return_packet for possible error codes.
12496
12497 Please check vos_pkt_return_packet API for possible return values.
12498
12499============================================================================*/
12500VOS_STATUS
12501WLANTL_TxCompDefaultCb
12502(
12503 v_PVOID_t pvosGCtx,
12504 vos_pkt_t* vosDataBuff,
12505 VOS_STATUS wTxSTAtus
12506)
12507{
12508 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
12509 "WLAN TL:TXComp not registered, releasing pkt to prevent mem leak"));
12510 return vos_pkt_return_packet(vosDataBuff);
12511}/*WLANTL_TxCompDefaultCb*/
12512
12513
12514/*==========================================================================
12515 Cleanup functions
12516 ==========================================================================*/
12517
12518/*==========================================================================
12519
12520 FUNCTION WLANTL_CleanCB
12521
12522 DESCRIPTION
12523 Cleans TL control block
12524
12525 DEPENDENCIES
12526
12527 PARAMETERS
12528
12529 IN
12530 pTLCb: pointer to TL's control block
12531 ucEmpty: set if TL has to clean up the queues and release pedning pkts
12532
12533 RETURN VALUE
12534 The result code associated with performing the operation
12535
12536 VOS_STATUS_E_INVAL: invalid input parameters
12537 VOS_STATUS_SUCCESS: Everything is good :)
12538
12539 SIDE EFFECTS
12540
12541============================================================================*/
12542VOS_STATUS
12543WLANTL_CleanCB
12544(
12545 WLANTL_CbType* pTLCb,
12546 v_U8_t ucEmpty
12547)
12548{
12549 v_U8_t ucIndex;
12550 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
12551
12552 /*-------------------------------------------------------------------------
12553 Sanity check
12554 -------------------------------------------------------------------------*/
12555 if ( NULL == pTLCb )
12556 {
12557 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
12558 "WLAN TL:Invalid parameter sent on WLANTL_CleanCB"));
12559 return VOS_STATUS_E_INVAL;
12560 }
12561
12562 /* number of packets sent to BAL waiting for tx complete confirmation */
12563 pTLCb->usPendingTxCompleteCount = 0;
12564
12565 /* global suspend flag */
12566 vos_atomic_set_U8( &pTLCb->ucTxSuspended, 1);
12567
12568 /* resource flag */
12569 pTLCb->uResCount = 0;
12570
12571
12572 /*-------------------------------------------------------------------------
12573 Client stations
12574 -------------------------------------------------------------------------*/
12575 for ( ucIndex = 0; ucIndex < WLAN_MAX_STA_COUNT ; ucIndex++)
12576 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053012577 if(NULL != pTLCb->atlSTAClients[ucIndex])
12578 {
12579 WLANTL_CleanSTA( pTLCb->atlSTAClients[ucIndex], ucEmpty);
12580 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012581 }
12582
12583 /*-------------------------------------------------------------------------
12584 Management Frame client
12585 -------------------------------------------------------------------------*/
12586 pTLCb->tlMgmtFrmClient.ucExists = 0;
12587
12588 if ( ( 0 != ucEmpty) &&
12589 ( NULL != pTLCb->tlMgmtFrmClient.vosPendingDataBuff ))
12590 {
12591 vos_pkt_return_packet(pTLCb->tlMgmtFrmClient.vosPendingDataBuff);
12592 }
12593
12594 pTLCb->tlMgmtFrmClient.vosPendingDataBuff = NULL;
12595
12596 /* set to a default cb in order to prevent constant checking for NULL */
12597 pTLCb->tlMgmtFrmClient.pfnTlMgmtFrmRx = WLANTL_MgmtFrmRxDefaultCb;
12598
12599 /*-------------------------------------------------------------------------
12600 BT AMP client
12601 -------------------------------------------------------------------------*/
12602 pTLCb->tlBAPClient.ucExists = 0;
12603
12604 if (( 0 != ucEmpty) &&
12605 ( NULL != pTLCb->tlBAPClient.vosPendingDataBuff ))
12606 {
12607 vos_pkt_return_packet(pTLCb->tlBAPClient.vosPendingDataBuff);
12608 }
12609
12610 if (( 0 != ucEmpty) &&
12611 ( NULL != pTLCb->vosDummyBuf ))
12612 {
12613 vos_pkt_return_packet(pTLCb->vosDummyBuf);
12614 }
12615
12616 pTLCb->tlBAPClient.vosPendingDataBuff = NULL;
12617
12618 pTLCb->vosDummyBuf = NULL;
12619 pTLCb->vosTempBuf = NULL;
12620 pTLCb->ucCachedSTAId = WLAN_MAX_STA_COUNT;
12621
12622 /* set to a default cb in order to prevent constant checking for NULL */
12623 pTLCb->tlBAPClient.pfnTlBAPRx = WLANTL_BAPRxDefaultCb;
12624
12625 pTLCb->ucRegisteredStaId = WLAN_MAX_STA_COUNT;
12626
12627 return VOS_STATUS_SUCCESS;
12628
12629}/* WLANTL_CleanCB*/
12630
12631/*==========================================================================
12632
12633 FUNCTION WLANTL_CleanSTA
12634
12635 DESCRIPTION
12636 Cleans a station control block.
12637
12638 DEPENDENCIES
12639
12640 PARAMETERS
12641
12642 IN
12643 pvosGCtx: pointer to the global vos context; a handle to TL's
12644 control block can be extracted from its context
12645 ucEmpty: if set the queues and pending pkts will be emptyed
12646
12647 RETURN VALUE
12648 The result code associated with performing the operation
12649
12650 VOS_STATUS_E_INVAL: invalid input parameters
12651 VOS_STATUS_SUCCESS: Everything is good :)
12652
12653 SIDE EFFECTS
12654
12655============================================================================*/
12656VOS_STATUS
12657WLANTL_CleanSTA
12658(
12659 WLANTL_STAClientType* ptlSTAClient,
12660 v_U8_t ucEmpty
12661)
12662{
12663 v_U8_t ucIndex;
12664 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
12665
12666 /*-------------------------------------------------------------------------
12667 Sanity check
12668 -------------------------------------------------------------------------*/
12669 if ( NULL == ptlSTAClient )
12670 {
12671 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
12672 "WLAN TL:Invalid parameter sent on WLANTL_CleanSTA"));
12673 return VOS_STATUS_E_INVAL;
12674 }
12675
12676 /*------------------------------------------------------------------------
12677 Clear station from TL
12678 ------------------------------------------------------------------------*/
12679 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
12680 "WLAN TL: Clearing STA Client ID: %d, Empty flag: %d",
12681 ptlSTAClient->wSTADesc.ucSTAId, ucEmpty ));
12682
12683 ptlSTAClient->pfnSTARx = WLANTL_STARxDefaultCb;
12684 ptlSTAClient->pfnSTATxComp = WLANTL_TxCompDefaultCb;
12685 ptlSTAClient->pfnSTAFetchPkt = WLANTL_STAFetchPktDefaultCb;
12686
12687 ptlSTAClient->tlState = WLANTL_STA_INIT;
12688 ptlSTAClient->tlPri = WLANTL_STA_PRI_NORMAL;
12689
12690 vos_zero_macaddr( &ptlSTAClient->wSTADesc.vSTAMACAddress );
12691 vos_zero_macaddr( &ptlSTAClient->wSTADesc.vBSSIDforIBSS );
12692 vos_zero_macaddr( &ptlSTAClient->wSTADesc.vSelfMACAddress );
12693
12694 ptlSTAClient->wSTADesc.ucSTAId = 0;
12695 ptlSTAClient->wSTADesc.wSTAType = WLAN_STA_MAX;
12696
12697 ptlSTAClient->wSTADesc.ucQosEnabled = 0;
12698 ptlSTAClient->wSTADesc.ucAddRmvLLC = 0;
12699 ptlSTAClient->wSTADesc.ucSwFrameTXXlation = 0;
12700 ptlSTAClient->wSTADesc.ucSwFrameRXXlation = 0;
12701 ptlSTAClient->wSTADesc.ucProtectedFrame = 0;
Bhargav Shahfbaeca22016-07-13 10:27:35 +053012702 ptlSTAClient->disassoc_progress = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070012703 /*-------------------------------------------------------------------------
12704 AMSDU information for the STA
12705 -------------------------------------------------------------------------*/
12706 if ( ( 0 != ucEmpty ) &&
12707 ( NULL != ptlSTAClient->vosAMSDUChainRoot ))
12708 {
Madan Mohan Koyyalamudic0e5bd82012-09-18 17:12:27 -070012709 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_FATAL,
Jeff Johnson0298bd02013-11-14 19:58:38 -080012710 "WLAN TL:Non NULL vosAMSDUChainRoot on WLANTL_CleanSTA, "
Madan Mohan Koyyalamudic0e5bd82012-09-18 17:12:27 -070012711 "suspecting a memory corruption"));
12712
Jeff Johnson295189b2012-06-20 16:38:30 -070012713 }
12714
12715 ptlSTAClient->vosAMSDUChain = NULL;
12716 ptlSTAClient->vosAMSDUChainRoot = NULL;
12717
12718 vos_mem_zero( (v_PVOID_t)ptlSTAClient->aucMPDUHeader,
12719 WLANTL_MPDU_HEADER_LEN);
12720 ptlSTAClient->ucMPDUHeaderLen = 0;
12721
12722 /*-------------------------------------------------------------------------
12723 Reordering information for the STA
12724 -------------------------------------------------------------------------*/
12725 for ( ucIndex = 0; ucIndex < WLAN_MAX_TID ; ucIndex++)
12726 {
12727 if(0 == ptlSTAClient->atlBAReorderInfo[ucIndex].ucExists)
12728 {
12729 continue;
12730 }
12731 if(NULL != ptlSTAClient->atlBAReorderInfo[ucIndex].reorderBuffer)
12732 {
12733 ptlSTAClient->atlBAReorderInfo[ucIndex].reorderBuffer->isAvailable = VOS_TRUE;
12734 memset(&ptlSTAClient->atlBAReorderInfo[ucIndex].reorderBuffer->arrayBuffer[0], 0, WLANTL_MAX_WINSIZE * sizeof(v_PVOID_t));
12735 }
12736 vos_timer_destroy(&ptlSTAClient->atlBAReorderInfo[ucIndex].agingTimer);
12737 memset(&ptlSTAClient->atlBAReorderInfo[ucIndex], 0, sizeof(WLANTL_BAReorderType));
12738 }
12739
12740 /*-------------------------------------------------------------------------
12741 QOS information for the STA
12742 -------------------------------------------------------------------------*/
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +053012743 ptlSTAClient->ucCurrentAC = WLANTL_AC_HIGH_PRIO;
Jeff Johnson295189b2012-06-20 16:38:30 -070012744 ptlSTAClient->ucCurrentWeight = 0;
12745 ptlSTAClient->ucServicedAC = WLANTL_AC_BK;
12746
12747 vos_mem_zero( ptlSTAClient->aucACMask, sizeof(ptlSTAClient->aucACMask));
12748 vos_mem_zero( &ptlSTAClient->wUAPSDInfo, sizeof(ptlSTAClient->wUAPSDInfo));
12749
12750
12751 /*--------------------------------------------------------------------
12752 Stats info
12753 --------------------------------------------------------------------*/
12754 vos_mem_zero( ptlSTAClient->auRxCount,
12755 sizeof(ptlSTAClient->auRxCount[0])* WLAN_MAX_TID);
12756 vos_mem_zero( ptlSTAClient->auTxCount,
12757 sizeof(ptlSTAClient->auTxCount[0])* WLAN_MAX_TID);
12758 ptlSTAClient->rssiAvg = 0;
12759
12760 /*Tx not suspended and station fully registered*/
12761 vos_atomic_set_U8( &ptlSTAClient->ucTxSuspended, 0);
12762 vos_atomic_set_U8( &ptlSTAClient->ucNoMoreData, 1);
12763
12764 if ( 0 == ucEmpty )
12765 {
12766 ptlSTAClient->wSTADesc.ucUcastSig = WLAN_TL_INVALID_U_SIG;
12767 ptlSTAClient->wSTADesc.ucBcastSig = WLAN_TL_INVALID_B_SIG;
12768 }
12769
12770 ptlSTAClient->ucExists = 0;
12771
12772 /*--------------------------------------------------------------------
12773 Statistics info
12774 --------------------------------------------------------------------*/
12775 memset(&ptlSTAClient->trafficStatistics,
12776 0,
12777 sizeof(WLANTL_TRANSFER_STA_TYPE));
12778
12779 /*fix me!!: add new values from the TL Cb for cleanup */
12780 return VOS_STATUS_SUCCESS;
12781}/* WLANTL_CleanSTA */
12782
12783
12784/*==========================================================================
12785 FUNCTION WLANTL_EnableUAPSDForAC
12786
12787 DESCRIPTION
12788 Called by HDD to enable UAPSD. TL in turn calls WDA API to enable the
12789 logic in FW/SLM to start sending trigger frames. Previously TL had the
12790 trigger frame logic which later moved down to FW. Hence
12791 HDD -> TL -> WDA -> FW call flow.
12792
12793 DEPENDENCIES
12794 The TL must be initialized before this function can be called.
12795
12796 PARAMETERS
12797
12798 IN
12799 pvosGCtx: pointer to the global vos context; a handle to TL's
12800 control block can be extracted from its context
12801 ucSTAId: station Id
12802 ucAC: AC for which U-APSD is being enabled
12803 ucTid: TID for which U-APSD is setup
12804 ucUP: used to place in the trigger frame generation
12805 ucServiceInt: service interval used by TL to send trigger frames
12806 ucSuspendInt: suspend interval used by TL to determine that an
12807 app is idle and should start sending trigg frms less often
12808 wTSDir: direction of TSpec
12809
12810 RETURN VALUE
12811 The result code associated with performing the operation
12812
12813 VOS_STATUS_SUCCESS: Everything is good :)
12814
12815 SIDE EFFECTS
12816
12817============================================================================*/
12818VOS_STATUS
12819WLANTL_EnableUAPSDForAC
12820(
12821 v_PVOID_t pvosGCtx,
12822 v_U8_t ucSTAId,
12823 WLANTL_ACEnumType ucAC,
12824 v_U8_t ucTid,
12825 v_U8_t ucUP,
12826 v_U32_t uServiceInt,
12827 v_U32_t uSuspendInt,
12828 WLANTL_TSDirType wTSDir
12829)
12830{
12831
12832 WLANTL_CbType* pTLCb = NULL;
12833 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
12834 tUapsdInfo halUAPSDInfo;
12835 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
12836
12837 /*------------------------------------------------------------------------
12838 Sanity check
12839 Extract TL control block
12840 ------------------------------------------------------------------------*/
12841 pTLCb = VOS_GET_TL_CB(pvosGCtx);
12842 if (( NULL == pTLCb ) || WLANTL_STA_ID_INVALID( ucSTAId )
Gopichand Nakkala574f6d12013-06-27 19:38:43 +053012843 || WLANTL_AC_INVALID(ucAC))
Jeff Johnson295189b2012-06-20 16:38:30 -070012844 {
12845 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
12846 "WLAN TL:Invalid input params on WLANTL_EnableUAPSDForAC"
Jeff Johnsonddec6482017-09-19 08:33:57 -070012847 " TL: %pK STA: %d AC: %d",
Gopichand Nakkala574f6d12013-06-27 19:38:43 +053012848 pTLCb, ucSTAId, ucAC));
Jeff Johnson295189b2012-06-20 16:38:30 -070012849 return VOS_STATUS_E_FAULT;
12850 }
12851
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053012852 if ( NULL == pTLCb->atlSTAClients[ucSTAId] )
12853 {
12854 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
12855 "WLAN TL:Client Memory was not allocated on %s", __func__));
12856 return VOS_STATUS_E_FAILURE;
12857 }
12858
Jeff Johnson295189b2012-06-20 16:38:30 -070012859 /*Set this flag in order to remember that this is a trigger enabled AC*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053012860 pTLCb->atlSTAClients[ucSTAId]->wUAPSDInfo[ucAC].ucSet = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -070012861
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053012862#ifdef FEATURE_WLAN_TDLS
12863 if(pTLCb->atlSTAClients[ucSTAId]->wSTADesc.wSTAType != WLAN_STA_TDLS)
12864#endif
12865 {
12866 if( 0 == uServiceInt )
12867 {
12868 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi198ade32013-09-29 03:52:25 +053012869 "WLAN TL:Input params on WLANTL_EnableUAPSDForAC"
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053012870 " SI: %d", uServiceInt ));
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053012871 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012872
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053012873 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
12874 "WLAN TL:Enabling U-APSD in FW for STA: %d AC: %d SI: %d SPI: %d "
12875 "DI: %d",
12876 ucSTAId, ucAC, uServiceInt, uSuspendInt,
12877 pTLCb->tlConfigInfo.uDelayedTriggerFrmInt));
Jeff Johnson295189b2012-06-20 16:38:30 -070012878
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053012879 /*Save all info for HAL*/
12880 halUAPSDInfo.staidx = ucSTAId;
12881 halUAPSDInfo.ac = ucAC;
12882 halUAPSDInfo.up = ucUP;
12883 halUAPSDInfo.srvInterval = uServiceInt;
12884 halUAPSDInfo.susInterval = uSuspendInt;
12885 halUAPSDInfo.delayInterval = pTLCb->tlConfigInfo.uDelayedTriggerFrmInt;
12886
12887 /*Notify HAL*/
12888 vosStatus = WDA_EnableUapsdAcParams(pvosGCtx, ucSTAId, &halUAPSDInfo);
12889 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012890 return vosStatus;
12891
12892}/*WLANTL_EnableUAPSDForAC*/
12893
12894
12895/*==========================================================================
12896 FUNCTION WLANTL_DisableUAPSDForAC
12897
12898 DESCRIPTION
12899 Called by HDD to disable UAPSD. TL in turn calls WDA API to disable the
12900 logic in FW/SLM to stop sending trigger frames. Previously TL had the
12901 trigger frame logic which later moved down to FW. Hence
12902 HDD -> TL -> WDA -> FW call flow.
12903
12904 DEPENDENCIES
12905 The TL must be initialized before this function can be called.
12906
12907 PARAMETERS
12908
12909 IN
12910 pvosGCtx: pointer to the global vos context; a handle to TL's
12911 control block can be extracted from its context
12912 ucSTAId: station Id
12913 ucAC: AC for which U-APSD is being enabled
12914
12915
12916 RETURN VALUE
12917 The result code associated with performing the operation
12918
12919 VOS_STATUS_SUCCESS: Everything is good :)
12920
12921 SIDE EFFECTS
12922
12923============================================================================*/
12924VOS_STATUS
12925WLANTL_DisableUAPSDForAC
12926(
12927 v_PVOID_t pvosGCtx,
12928 v_U8_t ucSTAId,
12929 WLANTL_ACEnumType ucAC
12930)
12931{
12932 WLANTL_CbType* pTLCb;
12933 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
12934
12935 /*------------------------------------------------------------------------
12936 Sanity check
12937 Extract TL control block
12938 ------------------------------------------------------------------------*/
12939 pTLCb = VOS_GET_TL_CB(pvosGCtx);
12940 if (( NULL == pTLCb ) || WLANTL_STA_ID_INVALID( ucSTAId )
12941 || WLANTL_AC_INVALID(ucAC) )
12942 {
12943 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
12944 "WLAN TL:Invalid input params on WLANTL_DisableUAPSDForAC"
Jeff Johnsonddec6482017-09-19 08:33:57 -070012945 " TL: %pK STA: %d AC: %d", pTLCb, ucSTAId, ucAC ));
Jeff Johnson295189b2012-06-20 16:38:30 -070012946 return VOS_STATUS_E_FAULT;
12947 }
12948
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053012949 if ( NULL == pTLCb->atlSTAClients[ucSTAId] )
12950 {
12951 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
12952 "WLAN TL:Client Memory was not allocated on %s", __func__));
12953 return VOS_STATUS_E_FAILURE;
12954 }
12955
Jeff Johnson295189b2012-06-20 16:38:30 -070012956 /*Reset this flag as this is no longer a trigger enabled AC*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053012957 pTLCb->atlSTAClients[ucSTAId]->wUAPSDInfo[ucAC].ucSet = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -070012958
12959 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
12960 "WLAN TL:Disabling U-APSD in FW for STA: %d AC: %d ",
12961 ucSTAId, ucAC));
12962
12963 /*Notify HAL*/
12964 WDA_DisableUapsdAcParams(pvosGCtx, ucSTAId, ucAC);
12965
12966 return VOS_STATUS_SUCCESS;
12967}/* WLANTL_DisableUAPSDForAC */
12968
12969#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
12970/*==========================================================================
12971 FUNCTION WLANTL_RegRSSIIndicationCB
12972
12973 DESCRIPTION Registration function to get notification if RSSI cross
12974 threshold.
12975 Client should register threshold, direction, and notification
12976 callback function pointer
12977
12978 DEPENDENCIES NONE
12979
12980 PARAMETERS in pAdapter - Global handle
12981 in rssiValue - RSSI threshold value
12982 in triggerEvent - Cross direction should be notified
12983 UP, DOWN, and CROSS
12984 in crossCBFunction - Notification CB Function
12985 in usrCtxt - user context
12986
12987 RETURN VALUE VOS_STATUS
12988
12989 SIDE EFFECTS NONE
12990
12991============================================================================*/
12992VOS_STATUS WLANTL_RegRSSIIndicationCB
12993(
12994 v_PVOID_t pAdapter,
12995 v_S7_t rssiValue,
12996 v_U8_t triggerEvent,
12997 WLANTL_RSSICrossThresholdCBType crossCBFunction,
12998 VOS_MODULE_ID moduleID,
12999 v_PVOID_t usrCtxt
13000)
13001{
13002 VOS_STATUS status = VOS_STATUS_SUCCESS;
13003
13004 status = WLANTL_HSRegRSSIIndicationCB(pAdapter,
13005 rssiValue,
13006 triggerEvent,
13007 crossCBFunction,
13008 moduleID,
13009 usrCtxt);
13010
13011 return status;
13012}
13013
13014/*==========================================================================
13015 FUNCTION WLANTL_DeregRSSIIndicationCB
13016
13017 DESCRIPTION Remove specific threshold from list
13018
13019 DEPENDENCIES NONE
13020
13021 PARAMETERS in pAdapter - Global handle
13022 in rssiValue - RSSI threshold value
13023 in triggerEvent - Cross direction should be notified
13024 UP, DOWN, and CROSS
13025
13026 RETURN VALUE VOS_STATUS
13027
13028 SIDE EFFECTS NONE
13029
13030============================================================================*/
13031VOS_STATUS WLANTL_DeregRSSIIndicationCB
13032(
13033 v_PVOID_t pAdapter,
13034 v_S7_t rssiValue,
13035 v_U8_t triggerEvent,
13036 WLANTL_RSSICrossThresholdCBType crossCBFunction,
13037 VOS_MODULE_ID moduleID
13038)
13039{
13040 VOS_STATUS status = VOS_STATUS_SUCCESS;
13041
13042 status = WLANTL_HSDeregRSSIIndicationCB(pAdapter,
13043 rssiValue,
13044 triggerEvent,
13045 crossCBFunction,
13046 moduleID);
13047 return status;
13048}
13049
13050/*==========================================================================
13051 FUNCTION WLANTL_SetAlpha
13052
13053 DESCRIPTION ALPLA is weight value to calculate AVG RSSI
13054 avgRSSI = (ALPHA * historyRSSI) + ((10 - ALPHA) * newRSSI)
13055 avgRSSI has (ALPHA * 10)% of history RSSI weight and
13056 (10 - ALPHA)% of newRSSI weight
13057 This portion is dynamically configurable.
13058 Default is ?
13059
13060 DEPENDENCIES NONE
13061
13062 PARAMETERS in pAdapter - Global handle
13063 in valueAlpah - ALPHA
13064
13065 RETURN VALUE VOS_STATUS
13066
13067 SIDE EFFECTS NONE
13068
13069============================================================================*/
13070VOS_STATUS WLANTL_SetAlpha
13071(
13072 v_PVOID_t pAdapter,
13073 v_U8_t valueAlpha
13074)
13075{
13076 VOS_STATUS status = VOS_STATUS_SUCCESS;
13077
13078 status = WLANTL_HSSetAlpha(pAdapter, valueAlpha);
13079 return status;
13080}
13081
13082/*==========================================================================
13083
13084 FUNCTION
13085
13086 DESCRIPTION
13087
13088 PARAMETERS
13089
13090 RETURN VALUE
13091
13092============================================================================*/
13093VOS_STATUS WLANTL_BMPSRSSIRegionChangedNotification
13094(
13095 v_PVOID_t pAdapter,
13096 tpSirRSSINotification pRSSINotification
13097)
13098{
13099 VOS_STATUS status = VOS_STATUS_SUCCESS;
13100
13101 status = WLANTL_HSBMPSRSSIRegionChangedNotification(pAdapter, pRSSINotification);
13102 return status;
13103}
13104
13105/*==========================================================================
13106 FUNCTION WLANTL_RegGetTrafficStatus
13107
13108 DESCRIPTION Registration function for traffic status monitoring
13109 During measure period count data frames.
13110 If frame count is larger then IDLE threshold set as traffic ON
13111 or OFF.
13112 And traffic status is changed send report to client with
13113 registered callback function
13114
13115 DEPENDENCIES NONE
13116
13117 PARAMETERS in pAdapter - Global handle
13118 in idleThreshold - Traffic on or off threshold
13119 in measurePeriod - Traffic state check period
13120 in trfficStatusCB - traffic status changed notification
13121 CB function
13122 in usrCtxt - user context
13123
13124 RETURN VALUE VOS_STATUS
13125
13126 SIDE EFFECTS NONE
13127
13128============================================================================*/
13129VOS_STATUS WLANTL_RegGetTrafficStatus
13130(
13131 v_PVOID_t pAdapter,
13132 v_U32_t idleThreshold,
13133 v_U32_t measurePeriod,
13134 WLANTL_TrafficStatusChangedCBType trfficStatusCB,
13135 v_PVOID_t usrCtxt
13136)
13137{
13138 VOS_STATUS status = VOS_STATUS_SUCCESS;
13139
13140 status = WLANTL_HSRegGetTrafficStatus(pAdapter,
13141 idleThreshold,
13142 measurePeriod,
13143 trfficStatusCB,
13144 usrCtxt);
13145 return status;
13146}
13147#endif
13148/*==========================================================================
13149 FUNCTION WLANTL_GetStatistics
13150
13151 DESCRIPTION Get traffic statistics for identified station
13152
13153 DEPENDENCIES NONE
13154
13155 PARAMETERS in pAdapter - Global handle
13156 in statType - specific statistics field to reset
13157 out statBuffer - traffic statistics buffer
13158
13159 RETURN VALUE VOS_STATUS
13160
13161 SIDE EFFECTS NONE
13162
13163============================================================================*/
13164VOS_STATUS WLANTL_GetStatistics
13165(
13166 v_PVOID_t pAdapter,
13167 WLANTL_TRANSFER_STA_TYPE *statBuffer,
13168 v_U8_t STAid
13169)
13170{
13171 WLANTL_CbType *pTLCb = VOS_GET_TL_CB(pAdapter);
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053013172 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070013173 VOS_STATUS status = VOS_STATUS_SUCCESS;
13174 WLANTL_TRANSFER_STA_TYPE *statistics = NULL;
13175
13176 /*------------------------------------------------------------------------
13177 Sanity check
13178 Extract TL control block
13179 ------------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053013180 if ( NULL == pTLCb )
Jeff Johnson295189b2012-06-20 16:38:30 -070013181 {
13182 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
13183 "WLAN TL:Invalid TL pointer on WLANTL_GetStatistics"));
13184 return VOS_STATUS_E_FAULT;
13185 }
13186
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053013187 pClientSTA = pTLCb->atlSTAClients[STAid];
13188
13189 if ( NULL == pClientSTA )
13190 {
13191 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
13192 "WLAN TL:Client Memory was not allocated on %s", __func__));
13193 return VOS_STATUS_E_FAILURE;
13194 }
13195
13196 if(0 == pClientSTA->ucExists)
Jeff Johnson295189b2012-06-20 16:38:30 -070013197 {
13198 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
13199 "WLAN TL: %d STA ID does not exist", STAid));
13200 return VOS_STATUS_E_INVAL;
13201 }
13202
13203 if(NULL == statBuffer)
13204 {
13205 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
13206 "WLAN TL:Invalid TL statistics buffer pointer on WLANTL_GetStatistics"));
13207 return VOS_STATUS_E_INVAL;
13208 }
13209
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053013210 statistics = &pClientSTA->trafficStatistics;
Katya Nigam493ff652014-02-11 14:31:04 +053013211 vos_mem_copy(statBuffer, statistics, sizeof(WLANTL_TRANSFER_STA_TYPE));
Jeff Johnson295189b2012-06-20 16:38:30 -070013212
13213 return status;
13214}
13215
13216/*==========================================================================
13217 FUNCTION WLANTL_ResetStatistics
13218
13219 DESCRIPTION Reset statistics structure for identified station ID
13220 Reset means set values as 0
13221
13222 DEPENDENCIES NONE
13223
13224 PARAMETERS in pAdapter - Global handle
13225 in statType - specific statistics field to reset
13226
13227 RETURN VALUE VOS_STATUS
13228
13229 SIDE EFFECTS NONE
13230
13231============================================================================*/
13232VOS_STATUS WLANTL_ResetStatistics
13233(
13234 v_PVOID_t pAdapter,
13235 v_U8_t STAid
13236)
13237{
13238 WLANTL_CbType *pTLCb = VOS_GET_TL_CB(pAdapter);
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053013239 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070013240 VOS_STATUS status = VOS_STATUS_SUCCESS;
13241 WLANTL_TRANSFER_STA_TYPE *statistics = NULL;
13242
13243 /*------------------------------------------------------------------------
13244 Sanity check
13245 Extract TL control block
13246 ------------------------------------------------------------------------*/
13247 if (NULL == pTLCb)
13248 {
13249 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
13250 "WLAN TL:Invalid TL pointer on WLANTL_GetStatistics"));
13251 return VOS_STATUS_E_FAULT;
13252 }
13253
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053013254 pClientSTA = pTLCb->atlSTAClients[STAid];
13255
13256 if ( NULL == pClientSTA )
13257 {
13258 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
13259 "WLAN TL:Client Memory was not allocated on %s", __func__));
13260 return VOS_STATUS_E_FAILURE;
13261 }
13262
13263 if(0 == pClientSTA->ucExists)
Jeff Johnson295189b2012-06-20 16:38:30 -070013264 {
13265 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
13266 "WLAN TL: %d STA ID does not exist", STAid));
13267 return VOS_STATUS_E_INVAL;
13268 }
13269
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053013270 statistics = &pClientSTA->trafficStatistics;
Jeff Johnson295189b2012-06-20 16:38:30 -070013271 vos_mem_zero((v_VOID_t *)statistics, sizeof(WLANTL_TRANSFER_STA_TYPE));
13272
13273 return status;
13274}
13275
13276/*==========================================================================
13277 FUNCTION WLANTL_GetSpecStatistic
13278
13279 DESCRIPTION Get specific field within statistics structure for
13280 identified station ID
13281
13282 DEPENDENCIES NONE
13283
13284 PARAMETERS in pAdapter - Global handle
13285 in statType - specific statistics field to reset
13286 in STAid - Station ID
13287 out buffer - Statistic value
13288
13289 RETURN VALUE VOS_STATUS
13290
13291 SIDE EFFECTS NONE
13292
13293============================================================================*/
13294VOS_STATUS WLANTL_GetSpecStatistic
13295(
13296 v_PVOID_t pAdapter,
13297 WLANTL_TRANSFER_STATIC_TYPE statType,
13298 v_U32_t *buffer,
13299 v_U8_t STAid
13300)
13301{
13302 WLANTL_CbType *pTLCb = VOS_GET_TL_CB(pAdapter);
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053013303 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070013304 VOS_STATUS status = VOS_STATUS_SUCCESS;
13305 WLANTL_TRANSFER_STA_TYPE *statistics = NULL;
13306
13307 /*------------------------------------------------------------------------
13308 Sanity check
13309 Extract TL control block
13310 ------------------------------------------------------------------------*/
13311 if (NULL == pTLCb)
13312 {
13313 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
13314 "WLAN TL:Invalid TL pointer on WLANTL_GetStatistics"));
13315 return VOS_STATUS_E_FAULT;
13316 }
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053013317 pClientSTA = pTLCb->atlSTAClients[STAid];
Jeff Johnson295189b2012-06-20 16:38:30 -070013318
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053013319 if ( NULL == pClientSTA )
13320 {
13321 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
13322 "WLAN TL:Client Memory was not allocated on %s", __func__));
13323 return VOS_STATUS_E_FAILURE;
13324 }
13325
13326 if(0 == pClientSTA->ucExists)
Jeff Johnson295189b2012-06-20 16:38:30 -070013327 {
13328 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
13329 "WLAN TL: %d STA ID does not exist", STAid));
13330 return VOS_STATUS_E_INVAL;
13331 }
13332
13333 if(NULL == buffer)
13334 {
13335 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
13336 "WLAN TL:Invalid TL statistic buffer pointer on WLANTL_GetStatistics"));
13337 return VOS_STATUS_E_INVAL;
13338 }
13339
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053013340 statistics = &pClientSTA->trafficStatistics;
Jeff Johnson295189b2012-06-20 16:38:30 -070013341 switch(statType)
13342 {
13343 case WLANTL_STATIC_TX_UC_FCNT:
13344 *buffer = statistics->txUCFcnt;
13345 break;
13346
13347 case WLANTL_STATIC_TX_MC_FCNT:
13348 *buffer = statistics->txMCFcnt;
13349 break;
13350
13351 case WLANTL_STATIC_TX_BC_FCNT:
13352 *buffer = statistics->txBCFcnt;
13353 break;
13354
13355 case WLANTL_STATIC_TX_UC_BCNT:
13356 *buffer = statistics->txUCBcnt;
13357 break;
13358
13359 case WLANTL_STATIC_TX_MC_BCNT:
13360 *buffer = statistics->txMCBcnt;
13361 break;
13362
13363 case WLANTL_STATIC_TX_BC_BCNT:
13364 *buffer = statistics->txBCBcnt;
13365 break;
13366
13367 case WLANTL_STATIC_RX_UC_FCNT:
13368 *buffer = statistics->rxUCFcnt;
13369 break;
13370
13371 case WLANTL_STATIC_RX_MC_FCNT:
13372 *buffer = statistics->rxMCFcnt;
13373 break;
13374
13375 case WLANTL_STATIC_RX_BC_FCNT:
13376 *buffer = statistics->rxBCFcnt;
13377 break;
13378
13379 case WLANTL_STATIC_RX_UC_BCNT:
13380 *buffer = statistics->rxUCBcnt;
13381 break;
13382
13383 case WLANTL_STATIC_RX_MC_BCNT:
13384 *buffer = statistics->rxMCBcnt;
13385 break;
13386
13387 case WLANTL_STATIC_RX_BC_BCNT:
13388 *buffer = statistics->rxBCBcnt;
13389 break;
13390
13391 case WLANTL_STATIC_RX_BCNT:
13392 *buffer = statistics->rxBcnt;
13393 break;
13394
13395 case WLANTL_STATIC_RX_BCNT_CRC_OK:
13396 *buffer = statistics->rxBcntCRCok;
13397 break;
13398
13399 case WLANTL_STATIC_RX_RATE:
13400 *buffer = statistics->rxRate;
13401 break;
13402
13403 default:
13404 *buffer = 0;
13405 status = VOS_STATUS_E_INVAL;
13406 break;
13407 }
13408
13409
13410 return status;
13411}
13412
13413/*==========================================================================
13414 FUNCTION WLANTL_ResetSpecStatistic
13415
13416 DESCRIPTION Reset specific field within statistics structure for
13417 identified station ID
13418 Reset means set as 0
13419
13420 DEPENDENCIES NONE
13421
13422 PARAMETERS in pAdapter - Global handle
13423 in statType - specific statistics field to reset
13424 in STAid - Station ID
13425
13426 RETURN VALUE VOS_STATUS
13427
13428 SIDE EFFECTS NONE
13429
13430============================================================================*/
13431VOS_STATUS WLANTL_ResetSpecStatistic
13432(
13433 v_PVOID_t pAdapter,
13434 WLANTL_TRANSFER_STATIC_TYPE statType,
13435 v_U8_t STAid
13436)
13437{
13438 WLANTL_CbType *pTLCb = VOS_GET_TL_CB(pAdapter);
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053013439 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070013440 VOS_STATUS status = VOS_STATUS_SUCCESS;
13441 WLANTL_TRANSFER_STA_TYPE *statistics = NULL;
13442
13443 /*------------------------------------------------------------------------
13444 Sanity check
13445 Extract TL control block
13446 ------------------------------------------------------------------------*/
13447 if (NULL == pTLCb)
13448 {
13449 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
13450 "WLAN TL:Invalid TL pointer on WLANTL_GetStatistics"));
13451 return VOS_STATUS_E_FAULT;
13452 }
13453
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053013454 pClientSTA = pTLCb->atlSTAClients[STAid];
13455
13456 if ( NULL == pClientSTA )
13457 {
13458 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
13459 "WLAN TL:Client Memory was not allocated on %s", __func__));
13460 return VOS_STATUS_E_FAILURE;
13461 }
13462
13463 if(0 == pClientSTA->ucExists)
Jeff Johnson295189b2012-06-20 16:38:30 -070013464 {
13465 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
13466 "WLAN TL: %d STA ID does not exist", STAid));
13467 return VOS_STATUS_E_INVAL;
13468 }
13469
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053013470 statistics = &pClientSTA->trafficStatistics;
Jeff Johnson295189b2012-06-20 16:38:30 -070013471 switch(statType)
13472 {
13473 case WLANTL_STATIC_TX_UC_FCNT:
13474 statistics->txUCFcnt = 0;
13475 break;
13476
13477 case WLANTL_STATIC_TX_MC_FCNT:
13478 statistics->txMCFcnt = 0;
13479 break;
13480
13481 case WLANTL_STATIC_TX_BC_FCNT:
13482 statistics->txBCFcnt = 0;
13483 break;
13484
13485 case WLANTL_STATIC_TX_UC_BCNT:
13486 statistics->txUCBcnt = 0;
13487 break;
13488
13489 case WLANTL_STATIC_TX_MC_BCNT:
13490 statistics->txMCBcnt = 0;
13491 break;
13492
13493 case WLANTL_STATIC_TX_BC_BCNT:
13494 statistics->txBCBcnt = 0;
13495 break;
13496
13497 case WLANTL_STATIC_RX_UC_FCNT:
13498 statistics->rxUCFcnt = 0;
13499 break;
13500
13501 case WLANTL_STATIC_RX_MC_FCNT:
13502 statistics->rxMCFcnt = 0;
13503 break;
13504
13505 case WLANTL_STATIC_RX_BC_FCNT:
13506 statistics->rxBCFcnt = 0;
13507 break;
13508
13509 case WLANTL_STATIC_RX_UC_BCNT:
13510 statistics->rxUCBcnt = 0;
13511 break;
13512
13513 case WLANTL_STATIC_RX_MC_BCNT:
13514 statistics->rxMCBcnt = 0;
13515 break;
13516
13517 case WLANTL_STATIC_RX_BC_BCNT:
13518 statistics->rxBCBcnt = 0;
13519 break;
13520
13521 case WLANTL_STATIC_RX_BCNT:
13522 statistics->rxBcnt = 0;
13523 break;
13524
13525 case WLANTL_STATIC_RX_BCNT_CRC_OK:
13526 statistics->rxBcntCRCok = 0;
13527 break;
13528
13529 case WLANTL_STATIC_RX_RATE:
13530 statistics->rxRate = 0;
13531 break;
13532
13533 default:
13534 status = VOS_STATUS_E_INVAL;
13535 break;
13536 }
13537
13538 return status;
13539}
13540
13541
13542/*==========================================================================
13543
13544 FUNCTION
13545
13546 DESCRIPTION Read RSSI value out of a RX BD
13547
13548 PARAMETERS: Caller must validate all parameters
13549
13550 RETURN VALUE
13551
13552============================================================================*/
13553VOS_STATUS WLANTL_ReadRSSI
13554(
13555 v_PVOID_t pAdapter,
13556 v_PVOID_t pBDHeader,
13557 v_U8_t STAid
13558)
13559{
13560 WLANTL_CbType *tlCtxt = VOS_GET_TL_CB(pAdapter);
13561 v_S7_t currentRSSI, currentRSSI0, currentRSSI1;
13562
13563
13564 if(NULL == tlCtxt)
13565 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070013566 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR, "%s Invalid TL handle", __func__));
Jeff Johnson295189b2012-06-20 16:38:30 -070013567 return VOS_STATUS_E_INVAL;
13568 }
13569
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053013570 if ( NULL == tlCtxt->atlSTAClients[STAid] )
13571 {
13572 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
13573 "WLAN TL:Client Memory was not allocated on %s", __func__));
13574 return VOS_STATUS_E_FAILURE;
13575 }
13576
Jeff Johnson295189b2012-06-20 16:38:30 -070013577 currentRSSI0 = WLANTL_GETRSSI0(pBDHeader);
13578 currentRSSI1 = WLANTL_GETRSSI1(pBDHeader);
13579 currentRSSI = (currentRSSI0 > currentRSSI1) ? currentRSSI0 : currentRSSI1;
13580
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053013581 tlCtxt->atlSTAClients[STAid]->rssiAvg = currentRSSI;
Jeff Johnson295189b2012-06-20 16:38:30 -070013582
13583 return VOS_STATUS_SUCCESS;
13584}
13585
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053013586/*==========================================================================
13587
13588 FUNCTION
13589
13590 DESCRIPTION Read SNR value out of a RX BD
13591
13592 PARAMETERS: Caller must validate all parameters
13593
13594 RETURN VALUE
13595
13596============================================================================*/
13597VOS_STATUS WLANTL_ReadSNR
13598(
13599 v_PVOID_t pAdapter,
13600 v_PVOID_t pBDHeader,
13601 v_U8_t STAid
13602)
13603{
13604 WLANTL_CbType *tlCtxt = VOS_GET_TL_CB(pAdapter);
13605 v_S7_t currentSNR;
13606
13607
13608 if (NULL == tlCtxt)
13609 {
13610 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
13611 "%s Invalid TL handle", __func__));
13612 return VOS_STATUS_E_INVAL;
13613 }
13614
13615 if (NULL == tlCtxt->atlSTAClients[STAid])
13616 {
13617 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
13618 "WLAN TL:Client Memory was not allocated on %s", __func__));
13619 return VOS_STATUS_E_FAILURE;
13620 }
13621
13622 currentSNR = WLANTL_GETSNR(pBDHeader);
13623
Madan Mohan Koyyalamudi43acf032013-09-27 04:33:28 +053013624 /* SNR reported in the Buffer Descriptor is scaled up by 2(SNR*2),
13625 * Get the correct SNR value
13626 */
13627 currentSNR = currentSNR >> 1;
13628
13629 /* SNR reported by HW cannot be more than 35dB due to HW limitations */
13630 currentSNR = (WLANTL_MAX_HW_SNR > currentSNR ? currentSNR :
13631 WLANTL_MAX_HW_SNR);
13632
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053013633 TLLOG2(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
13634 "%s: snrsum: %d snridx: %d prevsnravg: %d",
13635 __func__,
13636 tlCtxt->atlSTAClients[STAid]->snrSum,
13637 tlCtxt->atlSTAClients[STAid]->snrIdx,
13638 tlCtxt->atlSTAClients[STAid]->prevSnrAvg));
13639
13640 /* The SNR returned for all purposes is the average SNR over
13641 * WLANTL_MAX_SNR_DATA_SMAPLES.When data samples
13642 * > WLANTL_MAX_SNR_DATA_SAMPLES are obtained,
13643 * store the average of the samples in prevSnrAvg
13644 * and start a new averaging window. The prevSnrAvg is used when
13645 * enough data samples are not available when applications
13646 * actually query for SNR.
13647 *
13648 * SEE: WLANTL_GetSnr()
13649 */
13650 if (tlCtxt->atlSTAClients[STAid]->snrIdx >= WLANTL_MAX_SNR_DATA_SAMPLES)
13651 {
13652 tlCtxt->atlSTAClients[STAid]->prevSnrAvg =
13653 tlCtxt->atlSTAClients[STAid]->snrSum /
13654 tlCtxt->atlSTAClients[STAid]->snrIdx;
13655 tlCtxt->atlSTAClients[STAid]->snrSum = 0;
13656 tlCtxt->atlSTAClients[STAid]->snrIdx = 0;
13657 }
13658 tlCtxt->atlSTAClients[STAid]->snrSum += currentSNR;
13659 tlCtxt->atlSTAClients[STAid]->snrIdx += 1;
13660
13661 return VOS_STATUS_SUCCESS;
13662}
Jeff Johnson295189b2012-06-20 16:38:30 -070013663
13664/*
13665 DESCRIPTION
13666 TL returns the weight currently maintained in TL.
13667 IN
13668 pvosGCtx: pointer to the global vos context; a handle to TL's
13669 or SME's control block can be extracted from its context
13670
13671 OUT
13672 pACWeights: Caller allocated memory for filling in weights
13673
13674 RETURN VALUE VOS_STATUS
13675*/
13676VOS_STATUS
13677WLANTL_GetACWeights
13678(
13679 v_PVOID_t pvosGCtx,
13680 v_U8_t* pACWeights
13681)
13682{
13683 WLANTL_CbType* pTLCb = NULL;
13684 v_U8_t ucIndex;
13685 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
13686
13687 /*------------------------------------------------------------------------
13688 Sanity check
13689 ------------------------------------------------------------------------*/
13690 if ( NULL == pACWeights )
13691 {
13692 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
13693 "WLAN TL:Invalid parameter sent on WLANTL_GetACWeights"));
13694 return VOS_STATUS_E_INVAL;
13695 }
13696
13697 /*------------------------------------------------------------------------
13698 Extract TL control block and check existance
13699 ------------------------------------------------------------------------*/
13700 pTLCb = VOS_GET_TL_CB(pvosGCtx);
13701 if ( NULL == pTLCb )
13702 {
13703 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
13704 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_GetACWeights"));
13705 return VOS_STATUS_E_FAULT;
13706 }
13707 for ( ucIndex = 0; ucIndex < WLANTL_MAX_AC ; ucIndex++)
13708 {
13709 pACWeights[ucIndex] = pTLCb->tlConfigInfo.ucAcWeights[ucIndex];
13710 }
13711
13712 return VOS_STATUS_SUCCESS;
13713}
13714
13715
13716
13717/*
13718 DESCRIPTION
13719 Change the weight currently maintained by TL.
13720 IN
13721 pvosGCtx: pointer to the global vos context; a handle to TL's
13722 or SME's control block can be extracted from its context
13723 pACWeights: Caller allocated memory contain the weights to use
13724
13725
13726 RETURN VALUE VOS_STATUS
13727*/
13728VOS_STATUS
13729WLANTL_SetACWeights
13730(
13731 v_PVOID_t pvosGCtx,
13732 v_U8_t* pACWeights
13733)
13734{
13735 WLANTL_CbType* pTLCb = NULL;
13736 v_U8_t ucIndex;
13737 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
13738
13739 /*------------------------------------------------------------------------
13740 Sanity check
13741 ------------------------------------------------------------------------*/
13742 if ( NULL == pACWeights )
13743 {
13744 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
13745 "WLAN TL:Invalid parameter sent on WLANTL_GetACWeights"));
13746 return VOS_STATUS_E_INVAL;
13747 }
13748
13749 /*------------------------------------------------------------------------
13750 Extract TL control block and check existance
13751 ------------------------------------------------------------------------*/
13752 pTLCb = VOS_GET_TL_CB(pvosGCtx);
13753 if ( NULL == pTLCb )
13754 {
13755 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
13756 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_GetACWeights"));
13757 return VOS_STATUS_E_FAULT;
13758 }
13759 for ( ucIndex = 0; ucIndex < WLANTL_MAX_AC ; ucIndex++)
13760 {
13761 pTLCb->tlConfigInfo.ucAcWeights[ucIndex] = pACWeights[ucIndex];
13762 }
13763
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +053013764 pTLCb->tlConfigInfo.ucAcWeights[WLANTL_AC_HIGH_PRIO] = pACWeights[WLANTL_AC_VO];
Jeff Johnson295189b2012-06-20 16:38:30 -070013765 return VOS_STATUS_SUCCESS;
13766}
13767
13768
13769/*==========================================================================
13770
13771 FUNCTION
13772
13773 DESCRIPTION
13774
13775 PARAMETERS
13776
13777 RETURN VALUE
13778
13779============================================================================*/
13780void WLANTL_PowerStateChangedCB
13781(
13782 v_PVOID_t pAdapter,
13783 tPmcState newState
13784)
13785{
13786 WLANTL_CbType *tlCtxt = VOS_GET_TL_CB(pAdapter);
13787
13788 if (NULL == tlCtxt)
13789 {
13790 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +053013791 "%s: Invalid TL Control Block", __func__ );
Jeff Johnson295189b2012-06-20 16:38:30 -070013792 return;
13793 }
13794
13795 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO, "Power state changed, new state is %d", newState );
13796 switch(newState)
13797 {
13798 case FULL_POWER:
13799 tlCtxt->isBMPS = VOS_FALSE;
13800 break;
13801
13802 case BMPS:
13803#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
13804 WLANTL_SetFWRSSIThresholds(pAdapter);
13805#endif
13806
13807 tlCtxt->isBMPS = VOS_TRUE;
13808 break;
13809
13810 case IMPS:
13811 case LOW_POWER:
13812 case REQUEST_BMPS:
13813 case REQUEST_FULL_POWER:
13814 case REQUEST_IMPS:
13815 case STOPPED:
13816 case REQUEST_START_UAPSD:
13817 case REQUEST_STOP_UAPSD:
13818 case UAPSD:
13819 case REQUEST_STANDBY:
13820 case STANDBY:
13821 case REQUEST_ENTER_WOWL:
13822 case REQUEST_EXIT_WOWL:
13823 case WOWL:
13824 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN, "Not handle this events %d", newState ));
13825 break;
13826
13827 default:
13828 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR, "Not a valid event %d", newState ));
13829 break;
13830 }
13831
13832 return;
13833}
13834/*==========================================================================
13835 FUNCTION WLANTL_GetEtherType
13836
13837 DESCRIPTION Extract Ether type information from the BD
13838
13839 DEPENDENCIES NONE
13840
13841 PARAMETERS in aucBDHeader - BD header
13842 in vosDataBuff - data buffer
13843 in ucMPDUHLen - MPDU header length
13844 out pUsEtherType - pointer to Ethertype
13845
13846 RETURN VALUE VOS_STATUS_SUCCESS : if the EtherType is successfully extracted
13847 VOS_STATUS_FAILURE : if the EtherType extraction failed and
13848 the packet was dropped
13849
13850 SIDE EFFECTS NONE
13851
13852============================================================================*/
13853static VOS_STATUS WLANTL_GetEtherType
13854(
13855 v_U8_t * aucBDHeader,
13856 vos_pkt_t * vosDataBuff,
13857 v_U8_t ucMPDUHLen,
13858 v_U16_t * pUsEtherType
13859)
13860{
13861 v_U8_t ucOffset;
13862 v_U16_t usEtherType = *pUsEtherType;
13863 v_SIZE_t usLLCSize = sizeof(usEtherType);
13864 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
13865
13866 /*------------------------------------------------------------------------
13867 Check if LLC is present - if not, TL is unable to determine type
13868 ------------------------------------------------------------------------*/
13869 if ( VOS_FALSE == WDA_IS_RX_LLC_PRESENT( aucBDHeader ) )
13870 {
13871 ucOffset = WLANTL_802_3_HEADER_LEN - sizeof(usEtherType);
13872 }
13873 else
13874 {
13875 ucOffset = ucMPDUHLen + WLANTL_LLC_PROTO_TYPE_OFFSET;
13876 }
13877
13878 /*------------------------------------------------------------------------
13879 Extract LLC type
13880 ------------------------------------------------------------------------*/
13881 vosStatus = vos_pkt_extract_data( vosDataBuff, ucOffset,
13882 (v_PVOID_t)&usEtherType, &usLLCSize);
13883
13884 if (( VOS_STATUS_SUCCESS != vosStatus ) ||
13885 ( sizeof(usEtherType) != usLLCSize ))
13886
13887 {
13888 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
13889 "WLAN TL:Error extracting Ether type from data packet"));
13890 /* Drop packet */
13891 vos_pkt_return_packet(vosDataBuff);
13892 vosStatus = VOS_STATUS_E_FAILURE;
13893 }
13894 else
13895 {
13896 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
13897 "WLAN TL:Ether type retrieved before endianess conv: %d",
13898 usEtherType));
13899
13900 usEtherType = vos_be16_to_cpu(usEtherType);
13901 *pUsEtherType = usEtherType;
13902
13903 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
13904 "WLAN TL:Ether type retrieved: %d", usEtherType));
13905 }
13906
13907 return vosStatus;
13908}
13909
Jeff Johnson295189b2012-06-20 16:38:30 -070013910/*==========================================================================
13911 FUNCTION WLANTL_GetSoftAPStatistics
13912
13913 DESCRIPTION Collect the cumulative statistics for all Softap stations
13914
13915 DEPENDENCIES NONE
13916
13917 PARAMETERS in pvosGCtx - Pointer to the global vos context
13918 bReset - If set TL statistics will be cleared after reading
13919 out statsSum - pointer to collected statistics
13920
13921 RETURN VALUE VOS_STATUS_SUCCESS : if the Statistics are successfully extracted
13922
13923 SIDE EFFECTS NONE
13924
13925============================================================================*/
13926VOS_STATUS WLANTL_GetSoftAPStatistics(v_PVOID_t pAdapter, WLANTL_TRANSFER_STA_TYPE *statsSum, v_BOOL_t bReset)
13927{
13928 v_U8_t i = 0;
13929 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
13930 WLANTL_CbType *pTLCb = VOS_GET_TL_CB(pAdapter);
13931 WLANTL_TRANSFER_STA_TYPE statBufferTemp;
13932 vos_mem_zero((v_VOID_t *)&statBufferTemp, sizeof(WLANTL_TRANSFER_STA_TYPE));
13933 vos_mem_zero((v_VOID_t *)statsSum, sizeof(WLANTL_TRANSFER_STA_TYPE));
13934
13935
13936 if ( NULL == pTLCb )
13937 {
13938 return VOS_STATUS_E_FAULT;
13939 }
13940
13941 // Sum up all the statistics for stations of Soft AP from TL
13942 for (i = 0; i < WLAN_MAX_STA_COUNT; i++)
13943 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053013944 if ( NULL == pTLCb->atlSTAClients[i])
13945 {
13946 continue;
13947 }
13948 if (pTLCb->atlSTAClients[i]->wSTADesc.wSTAType == WLAN_STA_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -070013949 {
13950 vosStatus = WLANTL_GetStatistics(pAdapter, &statBufferTemp, i);// Can include staId 1 because statistics not collected for it
13951
13952 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
13953 return VOS_STATUS_E_FAULT;
13954
13955 // Add to the counters
13956 statsSum->txUCFcnt += statBufferTemp.txUCFcnt;
13957 statsSum->txMCFcnt += statBufferTemp.txMCFcnt;
13958 statsSum->txBCFcnt += statBufferTemp.txBCFcnt;
13959 statsSum->txUCBcnt += statBufferTemp.txUCBcnt;
13960 statsSum->txMCBcnt += statBufferTemp.txMCBcnt;
13961 statsSum->txBCBcnt += statBufferTemp.txBCBcnt;
13962 statsSum->rxUCFcnt += statBufferTemp.rxUCFcnt;
13963 statsSum->rxMCFcnt += statBufferTemp.rxMCFcnt;
13964 statsSum->rxBCFcnt += statBufferTemp.rxBCFcnt;
13965 statsSum->rxUCBcnt += statBufferTemp.rxUCBcnt;
13966 statsSum->rxMCBcnt += statBufferTemp.rxMCBcnt;
13967 statsSum->rxBCBcnt += statBufferTemp.rxBCBcnt;
13968
13969 if (bReset)
13970 {
13971 vosStatus = WLANTL_ResetStatistics(pAdapter, i);
13972 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
13973 return VOS_STATUS_E_FAULT;
13974 }
13975 }
13976 }
13977
13978 return vosStatus;
13979}
Mohit Khanna698ba2a2012-12-04 15:08:18 -080013980
Jeff Johnson295189b2012-06-20 16:38:30 -070013981/*===============================================================================
13982 FUNCTION WLANTL_IsReplayPacket
13983
13984 DESCRIPTION This function does replay check for valid stations
13985
13986 DEPENDENCIES Validity of replay check must be done before the function
13987 is called
13988
13989 PARAMETERS currentReplayCounter current replay counter taken from RX BD
13990 previousReplayCounter previous replay counter taken from TL CB
13991
13992 RETRUN VOS_TRUE packet is a replay packet
13993 VOS_FALSE packet is not a replay packet
13994
13995 SIDE EFFECTS none
13996 ===============================================================================*/
13997v_BOOL_t
13998WLANTL_IsReplayPacket
13999(
14000 v_U64_t ullcurrentReplayCounter,
14001 v_U64_t ullpreviousReplayCounter
14002)
14003{
14004 /* Do the replay check by comparing previous received replay counter with
14005 current received replay counter*/
14006 if(ullpreviousReplayCounter < ullcurrentReplayCounter)
14007 {
14008 /* Valid packet not replay */
14009 return VOS_FALSE;
14010 }
14011 else
14012 {
14013
14014 /* Current packet number is less than or equal to previuos received
14015 packet no, this means current packet is replay packet */
14016 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
14017 "WLAN TL: Replay packet found with replay counter :[0x%llX]",ullcurrentReplayCounter);
14018
14019 return VOS_TRUE;
14020 }
14021}
14022
14023#if 0
14024/*===============================================================================
14025 FUNCTION WLANTL_GetReplayCounterFromRxBD
14026
14027 DESCRIPTION This function extracts 48-bit replay packet number from RX BD
14028
14029 DEPENDENCIES Validity of replay check must be done before the function
14030 is called
14031
14032 PARAMETERS pucRxHeader pointer to RX BD header
14033
14034 RETRUN v_U64_t Packet number extarcted from RX BD
14035
14036 SIDE EFFECTS none
14037 ===============================================================================*/
14038v_U64_t
14039WLANTL_GetReplayCounterFromRxBD
14040(
14041 v_U8_t *pucRxBDHeader
14042)
14043{
14044/* 48-bit replay counter is created as follows
14045 from RX BD 6 byte PMI command:
14046 Addr : AES/TKIP
14047 0x38 : pn3/tsc3
14048 0x39 : pn2/tsc2
14049 0x3a : pn1/tsc1
14050 0x3b : pn0/tsc0
14051
14052 0x3c : pn5/tsc5
14053 0x3d : pn4/tsc4 */
14054
14055#ifdef ANI_BIG_BYTE_ENDIAN
14056 v_U64_t ullcurrentReplayCounter = 0;
14057 /* Getting 48-bit replay counter from the RX BD */
14058 ullcurrentReplayCounter = WLANHAL_RX_BD_GET_PMICMD_20TO23(pucRxBDHeader);
14059 ullcurrentReplayCounter <<= 16;
14060 ullcurrentReplayCounter |= (( WLANHAL_RX_BD_GET_PMICMD_24TO25(pucRxBDHeader) & 0xFFFF0000) >> 16);
14061 return ullcurrentReplayCounter;
14062#else
14063 v_U64_t ullcurrentReplayCounter = 0;
14064 /* Getting 48-bit replay counter from the RX BD */
14065 ullcurrentReplayCounter = (WLANHAL_RX_BD_GET_PMICMD_24TO25(pucRxBDHeader) & 0x0000FFFF);
14066 ullcurrentReplayCounter <<= 32;
14067 ullcurrentReplayCounter |= WLANHAL_RX_BD_GET_PMICMD_20TO23(pucRxBDHeader);
14068 return ullcurrentReplayCounter;
14069#endif
14070}
14071#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070014072
14073/*===============================================================================
14074 FUNCTION WLANTL_PostResNeeded
14075
14076 DESCRIPTION This function posts message to TL to reserve BD/PDU memory
14077
14078 DEPENDENCIES None
14079
14080 PARAMETERS pvosGCtx
14081
14082 RETURN None
14083
14084 SIDE EFFECTS none
14085 ===============================================================================*/
14086
14087void WLANTL_PostResNeeded(v_PVOID_t pvosGCtx)
14088{
14089 vos_msg_t vosMsg;
14090
14091 vosMsg.reserved = 0;
14092 vosMsg.bodyptr = NULL;
14093 vosMsg.type = WLANTL_TX_RES_NEEDED;
14094 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
14095 "WLAN TL: BD/PDU available interrupt received, Posting message to TL");
14096 if(!VOS_IS_STATUS_SUCCESS(vos_tx_mq_serialize( VOS_MQ_ID_TL, &vosMsg)))
14097 {
14098 VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070014099 " %s fails to post message", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070014100 }
14101}
14102
14103/*===============================================================================
14104 FUNCTION WLANTL_UpdateRssiBmps
14105
14106 DESCRIPTION This function updates the TL's RSSI (in BMPS mode)
14107
14108 DEPENDENCIES None
14109
14110 PARAMETERS
14111
14112 pvosGCtx VOS context VOS Global context
14113 staId Station ID Station ID
14114 rssi RSSI (BMPS mode) RSSI in BMPS mode
14115
14116 RETURN None
14117
14118 SIDE EFFECTS none
14119 ===============================================================================*/
14120
14121void WLANTL_UpdateRssiBmps(v_PVOID_t pvosGCtx, v_U8_t staId, v_S7_t rssi)
14122{
14123 WLANTL_CbType* pTLCb = VOS_GET_TL_CB(pvosGCtx);
14124
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053014125 if (NULL != pTLCb && NULL != pTLCb->atlSTAClients[staId])
Jeff Johnson295189b2012-06-20 16:38:30 -070014126 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053014127 pTLCb->atlSTAClients[staId]->rssiAvgBmps = rssi;
Jeff Johnson295189b2012-06-20 16:38:30 -070014128 }
14129}
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053014130
14131/*===============================================================================
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053014132 FUNCTION WLANTL_UpdateSnrBmps
14133
14134 DESCRIPTION This function updates the TL's SNR (in BMPS mode)
14135
14136 DEPENDENCIES None
14137
14138 PARAMETERS
14139
14140 pvosGCtx VOS context VOS Global context
14141 staId Station ID Station ID
14142 snr SNR (BMPS mode) SNR in BMPS mode
14143
14144 RETURN None
14145
14146 SIDE EFFECTS none
14147 ===============================================================================*/
14148
14149void WLANTL_UpdateSnrBmps(v_PVOID_t pvosGCtx, v_U8_t staId, v_S7_t snr)
14150{
14151 WLANTL_CbType* pTLCb = VOS_GET_TL_CB(pvosGCtx);
14152
14153 if (NULL != pTLCb && NULL != pTLCb->atlSTAClients[staId])
14154 {
14155 pTLCb->atlSTAClients[staId]->snrAvgBmps = snr;
14156 }
14157}
14158
14159/*===============================================================================
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053014160 FUNCTION WLANTL_UpdateLinkCapacity
14161
14162 DESCRIPTION This function updates the STA's Link Capacity in TL
14163
14164 DEPENDENCIES None
14165
14166 PARAMETERS
14167
14168 pvosGCtx VOS context VOS Global context
14169 staId Station ID Station ID
14170 linkCapacity linkCapacity Link Capacity
14171
14172 RETURN None
14173
14174 SIDE EFFECTS none
14175 ===============================================================================*/
14176
14177void WLANTL_UpdateLinkCapacity(v_PVOID_t pvosGCtx, v_U8_t staId, v_U32_t linkCapacity)
14178{
14179 WLANTL_CbType* pTLCb = VOS_GET_TL_CB(pvosGCtx);
14180
14181 if (NULL != pTLCb && NULL != pTLCb->atlSTAClients[staId])
14182 {
14183 pTLCb->atlSTAClients[staId]->linkCapacity = linkCapacity;
14184 }
14185}
14186
14187
14188/*===========================================================================
14189
14190 FUNCTION WLANTL_GetSTALinkCapacity
14191
14192 DESCRIPTION
14193
14194 Returns Link Capacity of a particular STA.
14195
14196 DEPENDENCIES
14197
14198 A station must have been registered before its state can be retrieved.
14199
14200
14201 PARAMETERS
14202
14203 IN
14204 pvosGCtx: pointer to the global vos context; a handle to TL's
14205 control block can be extracted from its context
14206 ucSTAId: identifier of the station
14207
14208 OUT
14209 plinkCapacity: the current link capacity the connection to
14210 the given station
14211
14212
14213 RETURN VALUE
14214
14215 The result code associated with performing the operation
14216
14217 VOS_STATUS_E_INVAL: Input parameters are invalid
14218 VOS_STATUS_E_FAULT: Station ID is outside array boundaries or pointer to
14219 TL cb is NULL ; access would cause a page fault
14220 VOS_STATUS_E_EXISTS: Station was not registered
14221 VOS_STATUS_SUCCESS: Everything is good :)
14222
14223 SIDE EFFECTS
14224
14225============================================================================*/
14226VOS_STATUS
14227WLANTL_GetSTALinkCapacity
14228(
14229 v_PVOID_t pvosGCtx,
14230 v_U8_t ucSTAId,
14231 v_U32_t *plinkCapacity
14232)
14233{
14234 WLANTL_CbType* pTLCb = NULL;
14235 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
14236
14237 /*------------------------------------------------------------------------
14238 Sanity check
14239 ------------------------------------------------------------------------*/
14240 if ( NULL == plinkCapacity )
14241 {
14242 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
14243 FL("WLAN TL:Invalid parameter")));
14244 return VOS_STATUS_E_INVAL;
14245 }
14246
14247 if ( WLANTL_STA_ID_INVALID( ucSTAId ) )
14248 {
14249 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
14250 FL("WLAN TL:Invalid station id")));
14251 return VOS_STATUS_E_FAULT;
14252 }
14253
14254 /*------------------------------------------------------------------------
14255 Extract TL control block and check existance
14256 ------------------------------------------------------------------------*/
14257 pTLCb = VOS_GET_TL_CB(pvosGCtx);
14258 if ( NULL == pTLCb )
14259 {
14260 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
14261 FL("WLAN TL:Invalid TL pointer from pvosGCtx")));
14262 return VOS_STATUS_E_FAULT;
14263 }
14264
14265 if ( NULL == pTLCb->atlSTAClients[ucSTAId] )
14266 {
14267 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
14268 FL("WLAN TL:Client Memory was not allocated")));
14269 return VOS_STATUS_E_FAILURE;
14270 }
14271
14272 if ( 0 == pTLCb->atlSTAClients[ucSTAId]->ucExists )
14273 {
14274 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
14275 FL("WLAN TL:Station was not previously registered")));
14276 return VOS_STATUS_E_EXISTS;
14277 }
14278
14279 /*------------------------------------------------------------------------
14280 Get STA state
14281 ------------------------------------------------------------------------*/
14282 *plinkCapacity = pTLCb->atlSTAClients[ucSTAId]->linkCapacity;
14283
14284 return VOS_STATUS_SUCCESS;
14285}/* WLANTL_GetSTALinkCapacity */
Abhishek Singh00b71972016-01-07 10:51:04 +053014286
Sravan Kumar Kairam893801a2016-11-01 19:14:23 +053014287/*
14288 * WLANTL_ResetRxSSN - reset last rx ssn
14289 * @pvosGCtx: global vos context
14290 * @ucSTAId: station id
14291 *
14292 * This function resets the last ssn of all tids of the station
14293 * for whom BA reorder session exists.
14294 *
14295 * Return: none
14296 */
14297void WLANTL_ResetRxSSN(v_PVOID_t pvosGCtx, uint8_t ucSTAId)
14298{
14299 WLANTL_CbType* pTLCb = NULL;
14300 WLANTL_STAClientType* pClientSTA = NULL;
14301 uint8_t i;
14302
14303 if (WLANTL_STA_ID_INVALID(ucSTAId)) {
14304 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
14305 "WLAN TL:Invalid station id requested WLANTL_ResetRxSSN"));
14306 return;
14307 }
14308
14309 pTLCb = VOS_GET_TL_CB(pvosGCtx);
14310 if (NULL == pTLCb) {
14311 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
14312 "WLAN TL:Invalid TL pointer from pvosGCtx WLANTL_ResetRxSSN"));
14313 return;
14314 }
14315
14316 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
14317
14318 for (i = 0; i < WLAN_MAX_TID ; i++) {
14319 if (0 == pClientSTA->atlBAReorderInfo[i].ucExists) {
14320 continue;
14321 }
14322 TLLOG1(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
14323 "WLAN TL: Last RxSSN reset to zero for tid %d", i));
14324 pClientSTA->atlBAReorderInfo[i].LastSN = 0;
14325 }
14326}
Abhishek Singh00b71972016-01-07 10:51:04 +053014327
Sravan Kumar Kairama97e2372016-11-11 17:20:03 +053014328void WLANTL_SetDataPktFilter(v_PVOID_t pvosGCtx, uint8_t ucSTAId, bool flag)
14329{
14330 WLANTL_CbType* pTLCb = NULL;
14331 WLANTL_STAClientType* pClientSTA = NULL;
14332 uint8_t i;
14333
14334 if (WLANTL_STA_ID_INVALID(ucSTAId)) {
14335 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
14336 "%s: Invalid station id requested", __func__));
14337 return;
14338 }
14339
14340 pTLCb = VOS_GET_TL_CB(pvosGCtx);
14341 if (NULL == pTLCb) {
14342 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
14343 "%s: Invalid TL pointer from pvosGCtx", __func__));
14344 return;
14345 }
14346
14347 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
14348
14349 for (i = 0; i < WLAN_MAX_TID ; i++) {
14350 if (0 == pClientSTA->atlBAReorderInfo[i].ucExists)
14351 continue;
14352
14353 TLLOG1(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
14354 "WLAN TL: Last RxSSN reset to zero for tid %d", i));
14355 pClientSTA->atlBAReorderInfo[i].set_data_filter = flag;
14356 }
14357}
14358
Sravan Kumar Kairam60b8cf02016-12-12 16:22:09 +053014359/**
14360 * WLANTL_ShiftArrByOne() - utility function to shift array by one
14361 * @arr: pointer to array
14362 * @len: length of the array
14363 *
14364 * Caller responsibility to provide the correct length of the array
14365 * other may leads to bugs.
14366 *
14367 * Return: void
14368 */
14369static void WLANTL_ShiftArrByOne(uint32_t *arr, uint8_t len)
14370{
14371 int i;
14372 for (i = 0; i < len - 1; i ++)
14373 arr[i] = arr[i + 1];
14374 arr[i] = 0;
14375}
14376
14377/**
14378 * WLANTL_SampleTx() - collect tx samples
14379 * @data: TL context pointer
14380 *
14381 * This function records the last five tx bytes sent samples
14382 * collected after tx_bytes_timer expire.
14383 *
14384 * Return: void
14385 */
14386void WLANTL_SampleTx(void *data)
14387{
14388 WLANTL_CbType* pTLCb = (WLANTL_CbType *)data;
14389 WLANTL_STAClientType* pClientSTA = NULL;
14390 uint8_t count = pTLCb->sample_count;
14391 uint8_t i;
14392
14393 for ( i = 0; i < WLAN_MAX_STA_COUNT; i++) {
14394 if (NULL != pTLCb->atlSTAClients[i] &&
14395 pTLCb->atlSTAClients[i]->ucExists) {
14396 pClientSTA = pTLCb->atlSTAClients[i];
14397
14398 if (count > (WLANTL_SAMPLE_COUNT - 1)) {
14399 count = WLANTL_SAMPLE_COUNT - 1;
14400 pClientSTA->tx_samples_sum -= pClientSTA->tx_sample[0];
14401 WLANTL_ShiftArrByOne(pClientSTA->tx_sample, WLANTL_SAMPLE_COUNT);
14402 }
14403
14404 pClientSTA->tx_sample[count] = pClientSTA->tx_frames;
14405 pClientSTA->tx_samples_sum += pClientSTA->tx_sample[count];
14406 pClientSTA->tx_frames = 0;
14407 count++;
14408 pTLCb->sample_count = count;
14409 }
14410 }
14411
14412 vos_timer_start(&pTLCb->tx_frames_timer, WLANTL_SAMPLE_INTERVAL);
14413}
Sravan Kumar Kairam091e5b62017-01-23 14:14:20 +053014414
14415/**
14416 * WLANTL_EnablePreAssocCaching() - Enable caching EAPOL frames
14417 *
14418 * Return: None
14419 *
14420 */
14421void WLANTL_EnablePreAssocCaching(void)
14422{
14423 v_PVOID_t pvosGCtx= vos_get_global_context(VOS_MODULE_ID_TL,NULL);
14424 WLANTL_CbType* pTLCb = VOS_GET_TL_CB(pvosGCtx);
14425 if (NULL == pTLCb ) {
14426 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
14427 "%s: Invalid TL pointer for global context", __func__));
14428 return;
14429 }
14430
14431 pTLCb->vosEapolCachedFrame = NULL;
14432 pTLCb->preassoc_caching = true;
14433}
14434
14435/**
14436 * WLANTL_ForwardPreAssoc() - forward cached eapol frames
14437 * @flag: Value to forward or flush
14438 *
14439 * Return: vos status
14440 *
14441 */
14442static VOS_STATUS WLANTL_ForwardPreAssoc(bool flag)
14443{
14444 vos_msg_t sMessage;
14445
14446 VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
14447 " ---- Serializing TL for forwarding pre assoc cache frames");
14448
14449 vos_mem_zero( &sMessage, sizeof(vos_msg_t));
14450 sMessage.type = WLANTL_RX_FWD_PRE_ASSOC_CACHED;
14451 sMessage.bodyval = flag;
14452
14453 return vos_rx_mq_serialize(VOS_MQ_ID_TL, &sMessage);
14454}
14455
14456/**
14457 * WLANTL_PreAssocForward() - forward cached eapol frames
14458 * @flag: Value to forward or flush
14459 *
14460 * Return: None
14461 *
14462 */
14463void WLANTL_PreAssocForward(bool flag)
14464{
14465 if(!VOS_IS_STATUS_SUCCESS(WLANTL_ForwardPreAssoc(flag)))
14466 {
14467 VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
14468 " %s fails to forward packets", __func__);
14469 }
14470}
14471
14472/**
14473 * WLANTL_RegisterFwdEapol() - register call back to forward cached eapol frame
14474 * @pvosGCtx : pointer to vos global context
14475 * @pfnFwdEapol: call back function pointer
14476 *
14477 * Return: None
14478 *
14479 */
14480void WLANTL_RegisterFwdEapol(v_PVOID_t pvosGCtx,
14481 WLANTL_FwdEapolCBType pfnFwdEapol)
14482{
14483 WLANTL_CbType* pTLCb = NULL;
14484 pTLCb = VOS_GET_TL_CB(pvosGCtx);
14485
14486 pTLCb->pfnEapolFwd = pfnFwdEapol;
14487
14488}
14489
Sravan Kumar Kairamd9e8cbb2017-01-17 12:17:28 +053014490 /**
14491 * WLANTL_SetARPFWDatapath() - keep or remove FW in data path for ARP
14492 *
14493 * @flag: value to keep or remove FW from data path
14494 *
14495 * Return: void
14496 */
14497void WLANTL_SetARPFWDatapath(void * pvosGCtx, bool flag)
14498{
14499
14500 WLANTL_CbType* pTLCb = NULL;
14501
14502 pTLCb = VOS_GET_TL_CB(pvosGCtx);
14503 if (NULL == pTLCb) {
14504 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
14505 "%s: Invalid TL pointer from pvosGCtx", __func__));
14506 return;
14507 }
14508
14509 pTLCb->track_arp = flag;
14510
14511}
14512
Hanumanth Reddy Pothula57323632017-12-06 17:55:09 +053014513v_U16_t wlan_tl_get_sta_rx_rate(void *pvosGCtx, uint8_t ucSTAId)
14514{
14515 WLANTL_CbType* pTLCb = NULL;
14516 v_U16_t rate = 0;
14517
14518 pTLCb = VOS_GET_TL_CB(pvosGCtx);
14519 if (NULL == pTLCb) {
14520 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
14521 "%s: Invalid TL pointer from pvosGCtx", __func__));
14522 return rate;
14523 }
14524
14525 if (pTLCb->atlSTAClients[ucSTAId]->ucExists)
14526 rate = vos_get_rate_from_rateidx(
14527 pTLCb->atlSTAClients[ucSTAId]->rate_idx);
14528
14529 return rate;
14530}
14531
Sravan Kumar Kairame0e78442017-09-18 18:00:53 +053014532void WLANTL_GetSAPStaRSSi(void *pvosGCtx, uint8_t ucSTAId, s8 *rssi)
14533{
14534 WLANTL_CbType* pTLCb = NULL;
14535 uint8_t count;
14536
14537 pTLCb = VOS_GET_TL_CB(pvosGCtx);
14538 if (NULL == pTLCb) {
14539 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
14540 "%s: Invalid TL pointer from pvosGCtx", __func__));
14541 return;
14542 }
14543
14544 count = pTLCb->atlSTAClients[ucSTAId]->rssi_sample_cnt;
14545 count < WLANTL_RSSI_SAMPLE_CNT ? count++ : count;
14546
14547 *rssi = pTLCb->atlSTAClients[ucSTAId]->rssi_sample_sum / count;
14548}
14549
Sravan Kumar Kairam8bb90ca2017-11-01 19:00:23 +053014550void WLANTL_SetKeySeqCounter(void *pvosGCtx, u64 counter, uint8_t staid)
14551{
14552 WLANTL_CbType* pTLCb = NULL;
14553 uint8_t i;
14554
14555 pTLCb = VOS_GET_TL_CB(pvosGCtx);
14556 if (NULL == pTLCb) {
14557 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
14558 "%s: Invalid TL pointer from pvosGCtx", __func__));
14559 return;
14560 }
14561
14562 if (WLANTL_STA_ID_INVALID(staid)) {
14563 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
14564 "%s: Invalid Sta id passed", __func__));
14565 return;
14566 }
14567
14568 if (NULL == pTLCb->atlSTAClients[staid]) {
14569 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
14570 "%s: Station context is NULL", __func__));
14571 return;
14572 }
14573
14574 for(i = 0; i < WLANTL_MAX_TID; i++)
14575 pTLCb->atlSTAClients[staid]->ullReplayCounter[i] = counter;
14576}
14577
Abhishek Singh00b71972016-01-07 10:51:04 +053014578#ifdef WLAN_FEATURE_RMC
14579VOS_STATUS WLANTL_RmcInit
14580(
14581 v_PVOID_t pAdapter
14582)
14583{
14584 WLANTL_CbType *pTLCb = VOS_GET_TL_CB(pAdapter);
14585 VOS_STATUS status = VOS_STATUS_SUCCESS;
14586 tANI_U8 count;
14587
14588 /*sanity check*/
14589 if (NULL == pTLCb)
14590 {
14591 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
14592 "Invalid TL handle"));
14593 return VOS_STATUS_E_INVAL;
14594 }
14595
14596 for ( count = 0; count < WLANTL_RMC_HASH_TABLE_SIZE; count++ )
14597 {
14598 pTLCb->rmcSession[count] = NULL;
14599 }
14600
14601 vos_lock_init(&pTLCb->rmcLock);
14602
14603 pTLCb->multicastDuplicateDetectionEnabled = 1;
14604 pTLCb->rmcDataPathEnabled = 0;
14605
14606 return status;
14607}
14608
14609
14610VOS_STATUS WLANTL_RmcDeInit
14611(
14612 v_PVOID_t pAdapter
14613)
14614{
14615 WLANTL_CbType *pTLCb = VOS_GET_TL_CB(pAdapter);
14616 VOS_STATUS status = VOS_STATUS_SUCCESS;
14617 tANI_U8 count;
14618 WLANTL_RMC_SESSION *pNode;
14619 WLANTL_RMC_SESSION *pPrev;
14620
14621 /*sanity check*/
14622 if (NULL == pTLCb)
14623 {
14624 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
14625 "Invalid TL handle"));
14626 return VOS_STATUS_E_INVAL;
14627 }
14628
14629 for ( count = 0; count < WLANTL_RMC_HASH_TABLE_SIZE; count++ )
14630 {
14631 pNode = pTLCb->rmcSession[count];
14632 while (pNode)
14633 {
14634 pPrev = pNode;
14635 pNode = pNode->next;
14636 vos_mem_free((v_VOID_t * )pPrev);
14637 }
14638 }
14639
14640 vos_lock_destroy(&pTLCb->rmcLock);
14641
14642 return status;
14643}
14644
14645
14646tANI_U8 WLANTL_RmcHashRmcSession ( v_MACADDR_t *pMcastAddr )
14647{
14648 tANI_U32 sum;
14649 tANI_U8 hash;
14650
14651 sum = (pMcastAddr->bytes[0] + pMcastAddr->bytes[1] + pMcastAddr->bytes[2] +
14652 pMcastAddr->bytes[3] + pMcastAddr->bytes[4] + pMcastAddr->bytes[5]);
14653
14654 hash = (tANI_U8)(sum & ((WLANTL_RMC_HASH_TABLE_SIZE - 1)));
14655
14656 return hash;
14657}
14658
14659
14660WLANTL_RMC_SESSION* WLANTL_RmcLookUpRmcSession
14661(
14662 WLANTL_RMC_SESSION *rmcSession[],
14663 v_MACADDR_t *pMcastAddr
14664)
14665{
14666 WLANTL_RMC_SESSION *pNode;
14667 tANI_U8 index;
14668
14669 /*sanity check*/
14670 if (NULL == pMcastAddr)
14671 {
14672 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Jeff Johnsonddec6482017-09-19 08:33:57 -070014673 "Sanity check failed pMcastAddr %pK", pMcastAddr));
Abhishek Singh00b71972016-01-07 10:51:04 +053014674 return NULL;
14675 }
14676
14677 index = WLANTL_RmcHashRmcSession(pMcastAddr);
14678 pNode = rmcSession[index];
14679 while ( pNode )
14680 {
14681 if (vos_is_macaddr_equal( &(pNode->rmcAddr), pMcastAddr))
14682 {
14683 return pNode;
14684 }
14685 pNode = pNode->next;
14686 }
14687
14688 return NULL;
14689}
14690
14691WLANTL_RMC_SESSION *WLANTL_RmcAddRmcSession
14692(
14693 WLANTL_RMC_SESSION *rmcSession[],
14694 v_MACADDR_t *pMcastAddr
14695)
14696{
14697 WLANTL_RMC_SESSION *pNode;
14698 tANI_U8 index;
14699
14700 index = WLANTL_RmcHashRmcSession(pMcastAddr);
14701 pNode = WLANTL_RmcLookUpRmcSession(rmcSession, pMcastAddr);
14702 if ( NULL != pNode )
14703 {
14704 /*already exists*/
14705 return NULL;
14706 }
14707 else
14708 {
14709 pNode = (WLANTL_RMC_SESSION *)vos_mem_malloc(sizeof(*pNode));
14710 if (pNode)
14711 {
14712 vos_mem_copy( &(pNode->rmcAddr), pMcastAddr,
14713 sizeof(pNode->rmcAddr) );
14714 pNode->next = rmcSession[index];
14715 rmcSession[index] = pNode;
14716 return pNode;
14717 }
14718 else
14719 {
14720 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14721 "%s: vos_mem_malloc failed can't enable RMC session",
14722 __func__);
14723 return NULL;
14724 }
14725 }
14726}
14727
14728tANI_U8
14729WLANTL_RmcDeleteRmcSession
14730(
14731 WLANTL_RMC_SESSION *rmcSession[],
14732 v_MACADDR_t *pMcastAddr
14733)
14734{
14735 WLANTL_RMC_SESSION *pHead;
14736 WLANTL_RMC_SESSION *pNode;
14737 WLANTL_RMC_SESSION *pPrev;
14738 tANI_U8 index;
14739
14740 index = WLANTL_RmcHashRmcSession(pMcastAddr);
14741 pHead = pNode = rmcSession[index];
14742 while (pNode)
14743 {
14744 if (vos_is_macaddr_equal( &(pNode->rmcAddr), pMcastAddr))
14745 {
14746 if (pHead == pNode)
14747 {
14748 rmcSession[index] = pNode->next;
14749 }
14750 else
14751 {
14752 pPrev->next = pNode->next;
14753 }
14754 vos_mem_free((v_VOID_t * )pNode);
14755 return 1;
14756 }
14757 pPrev = pNode;
14758 pNode = pNode->next;
14759 }
14760
14761 return 0;
14762}
14763
14764VOS_STATUS
14765WLANTL_ProcessRmcCommand
14766(
14767 WLANTL_CbType* pTLCb,
14768 v_MACADDR_t *pMcastAddr,
14769 tANI_U32 command
14770)
14771{
14772 VOS_STATUS status;
14773 tANI_U32 count;
14774 tANI_U32 rmcActive;
14775
14776 if (!VOS_IS_STATUS_SUCCESS(vos_lock_acquire( &(pTLCb->rmcLock))))
14777 {
14778 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
14779 "%s Get Lock Fail", __func__));
14780 return VOS_STATUS_E_FAILURE;
14781 }
14782
14783 /*add or delete node from active rmc hash table*/
14784 if (command)
14785 {
14786 /*add requested rmc session in active rmc session list*/
14787 if (WLANTL_RmcAddRmcSession(pTLCb->rmcSession, pMcastAddr))
14788 {
14789 TLLOGE( VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
14790 "RMC session " MAC_ADDRESS_STR " added in TL hash table",
14791 MAC_ADDR_ARRAY(pMcastAddr->bytes) ) );
14792 pTLCb->rmcDataPathEnabled = TRUE;
14793 status = VOS_STATUS_SUCCESS;
14794 }
14795 else
14796 {
14797 TLLOGE( VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
14798 "RMC session " MAC_ADDRESS_STR " already exists in TL hash"
14799 " table", MAC_ADDR_ARRAY(pMcastAddr->bytes) ) );
14800 status = VOS_STATUS_E_FAILURE;
14801 }
14802 }
14803 else
14804 {
14805 /*delete requested rmc session from active rmc session list*/
14806 if (WLANTL_RmcDeleteRmcSession(pTLCb->rmcSession, pMcastAddr))
14807 {
14808 TLLOGE( VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
14809 "RMC session " MAC_ADDRESS_STR " deleted from TL hash table",
14810 MAC_ADDR_ARRAY(pMcastAddr->bytes)) );
14811 status = VOS_STATUS_SUCCESS;
14812 rmcActive = FALSE;
14813 for ( count = 0; count < WLANTL_RMC_HASH_TABLE_SIZE; count++ )
14814 {
14815 if (pTLCb->rmcSession[count])
14816 {
14817 rmcActive = TRUE;
14818 break;
14819 }
14820 }
14821 if (TRUE == rmcActive)
14822 {
14823 pTLCb->rmcDataPathEnabled = TRUE;
14824 }
14825 else
14826 {
14827 pTLCb->rmcDataPathEnabled = FALSE;
14828 }
14829 }
14830 else
14831 {
14832 TLLOGE( VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
14833 "RMC session " MAC_ADDRESS_STR " doesn't exist in TL hash"
14834 " table", MAC_ADDR_ARRAY(pMcastAddr->bytes) ) );
14835 status = VOS_STATUS_E_FAILURE;
14836 }
14837 }
14838
14839 if (!VOS_IS_STATUS_SUCCESS(vos_lock_release(&(pTLCb->rmcLock))))
14840 {
14841 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
14842 "%s Release Lock Fail", __func__));
14843 return VOS_STATUS_E_FAILURE;
14844 }
14845
14846 return status;
14847}/* End of WLANTL_ProcessRmcCommand */
14848
14849VOS_STATUS
14850WLANTL_EnableRMC
14851(
14852 v_PVOID_t pvosGCtx,
14853 v_MACADDR_t *pMcastTransmitterAddr
14854)
14855{
14856 WLANTL_CbType* pTLCb;
14857 VOS_STATUS status;
14858
14859 /*sanity check*/
14860 if ( (NULL == pvosGCtx) || (NULL == pMcastTransmitterAddr) )
14861 {
14862 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Jeff Johnsonddec6482017-09-19 08:33:57 -070014863 "WLAN TL %s: Sanity check failed pvosGCtx %pK aMcastAddr %pK",
Abhishek Singh00b71972016-01-07 10:51:04 +053014864 __func__, pvosGCtx, pMcastTransmitterAddr));
14865 return VOS_STATUS_E_FAILURE;
14866 }
14867
14868 /*sanity check*/
14869 pTLCb = VOS_GET_TL_CB(pvosGCtx);
14870 if ( NULL == pTLCb )
14871 {
14872 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
14873 "WLAN TL %s: pTLCb is NULL", __func__));
14874 return VOS_STATUS_E_FAILURE;
14875 }
14876
14877 status = WLANTL_ProcessRmcCommand(pTLCb, pMcastTransmitterAddr , 1);
14878
14879 return status;
14880} /* End of WLANTL_EnableRMC */
14881
14882
14883VOS_STATUS
14884WLANTL_DisableRMC
14885(
14886 v_PVOID_t pvosGCtx,
14887 v_MACADDR_t *pMcastTransmitterAddr
14888)
14889{
14890 WLANTL_CbType* pTLCb;
14891 VOS_STATUS status;
14892
14893 /*Sanity check*/
14894 if ((NULL == pvosGCtx) || (NULL == pMcastTransmitterAddr))
14895 {
14896 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Jeff Johnsonddec6482017-09-19 08:33:57 -070014897 "WLAN TL %s: Sanity check failed pvosGCtx %pK aMcastAddr %pK",
Abhishek Singh00b71972016-01-07 10:51:04 +053014898 __func__, pvosGCtx, pMcastTransmitterAddr));
14899 return VOS_STATUS_E_FAILURE;
14900 }
14901
14902 /*Sanity check*/
14903 pTLCb = VOS_GET_TL_CB(pvosGCtx);
14904 if (NULL == pTLCb)
14905 {
14906 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
14907 "WLAN TL %s: pTLCb is NULL", __func__));
14908 return VOS_STATUS_E_FAILURE;
14909 }
14910
14911 status = WLANTL_ProcessRmcCommand(pTLCb, pMcastTransmitterAddr, 0);
14912
14913 return status;
14914} /* End of WLANTL_DisableRMC */
14915
14916
14917/*=============================================================================
14918 Duplicate Multicast Detection Functions
14919==============================================================================*/
14920
14921/*=============================================================================
14922 FUNCTION WLANTL_IsDuplicateMcastFrm
14923
14924 DESCRIPTION
14925 This function checks for duplicast multicast frames and drops them.
14926
14927 DEPENDENCIES
14928
14929 PARAMETERS
14930
14931 IN
14932
14933 pClientSTA : Pointer to WLANTL_STAClientType
14934 aucBDHeader : Pointer to BD header
14935
14936 RETURN VALUE
14937
14938 VOS_FALSE: This frame is not a duplicate
14939
14940 VOS_TRUE: This frame is a duplicate
14941
14942==============================================================================*/
14943v_U8_t
14944WLANTL_IsDuplicateMcastFrm
14945(
14946 WLANTL_STAClientType *pClientSTA,
14947 vos_pkt_t *vosDataBuff
14948)
14949{
14950 v_U8_t duplicate = VOS_FALSE;
14951 WLANTL_RMC_SESSION *pNode;
14952 v_U16_t usSeqCtrl;
14953 v_MACADDR_t mcastAddr;
14954 VOS_STATUS vosStatus;
14955 v_PVOID_t pvPeekData;
14956
14957 /* Get address 1 of Data Frame */
14958 vosStatus = vos_pkt_peek_data(vosDataBuff, WLANTL_MAC_ADDR_ALIGN(1),
14959 (v_PVOID_t)&pvPeekData, VOS_MAC_ADDR_SIZE);
14960
14961 if ( VOS_STATUS_SUCCESS != vosStatus )
14962 {
14963 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
14964 "WLAN TL: Failed to get Addr 1 of 80211 header from packet %d",
14965 vosStatus));
14966 return VOS_FALSE;
14967 }
14968
14969 /* Copy address 1 of Data Frame */
14970 vos_mem_copy(&mcastAddr.bytes, pvPeekData, VOS_MAC_ADDR_SIZE);
14971
14972 /*
14973 * We perform duplicate detection for only multicast data frames
14974 */
14975 if (vos_is_macaddr_group(&mcastAddr) &&
14976 !vos_is_macaddr_broadcast(&mcastAddr))
14977 {
14978 /* Get sequence control of Data Frame */
14979 vosStatus = vos_pkt_peek_data(vosDataBuff,
14980 (WLANTL_MAC_ADDR_ALIGN(1) + (3 * VOS_MAC_ADDR_SIZE)),
14981 (v_PVOID_t)&pvPeekData, sizeof(v_U16_t));
14982
14983 if ( VOS_STATUS_SUCCESS != vosStatus )
14984 {
14985 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
14986 "WLAN TL: Failed to get Sequence Control from packet %d",
14987 vosStatus));
14988 return VOS_FALSE;
14989 }
14990
14991 /* Copy sequence control from the Data Frame */
14992 usSeqCtrl = *(v_U16_t *)pvPeekData;
14993
14994 if (!VOS_IS_STATUS_SUCCESS(vos_lock_acquire(&(pClientSTA->mcLock))))
14995 {
14996 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
14997 "%s Get Lock Fail", __func__));
14998 return VOS_FALSE;
14999 }
15000
15001 pNode = WLANTL_RmcLookUpRmcSession(pClientSTA->mcastSession,
15002 &mcastAddr);
15003 if (NULL == pNode)
15004 {
15005 /* If the session does not exist, add it. */
15006 pNode = WLANTL_RmcAddRmcSession(pClientSTA->mcastSession,
15007 &mcastAddr);
15008 /* If we could not add a entry, skip duplicate detection */
15009 if (NULL == pNode)
15010 {
15011 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
15012 "%s Failed to add multicast session", __func__));
15013 if (!VOS_IS_STATUS_SUCCESS
15014 (vos_lock_release(&(pClientSTA->mcLock))))
15015 {
15016 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
15017 "%s Release Lock Fail", __func__));
15018 }
15019 return VOS_FALSE;
15020 }
15021 /* Initialize the sequence control value. */
15022 pNode->mcSeqCtl = usSeqCtrl;
15023 }
15024 else
15025 {
15026 /*
15027 * Check if the sequence number of this frame matches the last
15028 * we have seen.
15029 */
15030 if (pNode->mcSeqCtl == usSeqCtrl)
15031 {
15032 pNode->rxMCDupcnt++;
15033 TLLOG1(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
15034 "%s Rx Multicast Duplicate %d " MAC_ADDRESS_STR
15035 " (Seq %x)", __func__,
15036 pNode->rxMCDupcnt, MAC_ADDR_ARRAY(mcastAddr.bytes),
15037 usSeqCtrl));
15038 duplicate = VOS_TRUE;
15039 }
15040 else
15041 {
15042 /* Update the last seen sequence number */
15043 pNode->mcSeqCtl = usSeqCtrl;
15044 }
15045 }
15046
15047 if (!VOS_IS_STATUS_SUCCESS (vos_lock_release(&(pClientSTA->mcLock))))
15048 {
15049 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
15050 "%s Release Lock Fail", __func__));
15051 }
15052 }
15053
15054 return duplicate;
15055}
15056
15057/*=============================================================================
15058 FUNCTION WLANTL_McastDeleteAllEntries
15059
15060 DESCRIPTION
15061 This function removes all multicast entries used for duplicate detection
15062
15063 DEPENDENCIES
15064
15065 PARAMETERS
15066
15067 IN
15068
15069 pClientSTA : Pointer to WLANTL_STAClientType
15070
15071 RETURN VALUE
15072
15073 None
15074
15075==============================================================================*/
15076void
15077WLANTL_McastDeleteAllEntries(WLANTL_STAClientType * pClientSTA)
15078{
15079 WLANTL_RMC_SESSION *pNode, **head;
15080 int index;
15081
15082 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
15083 "%s Deleting all multicast entries", __func__));
15084
15085 if (!VOS_IS_STATUS_SUCCESS(vos_lock_acquire(&(pClientSTA->mcLock))))
15086 {
15087 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
15088 "%s Get Lock Fail", __func__));
15089 return;
15090 }
15091
15092 for (index = 0; index < WLANTL_RMC_HASH_TABLE_SIZE; index++)
15093 {
15094 head = &pClientSTA->mcastSession[index];
15095
15096 pNode = *head;
15097
15098 while (pNode)
15099 {
15100 *head = pNode->next;
15101 /* free the group entry */
15102 vos_mem_free(pNode);
15103 pNode = *head;
15104 }
15105 }
15106
15107 if (!VOS_IS_STATUS_SUCCESS (vos_lock_release(&(pClientSTA->mcLock))))
15108 {
15109 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
15110 "%s Release Lock Fail", __func__));
15111 }
15112}
15113
15114/*=============================================================================
15115 FUNCTION WLANTL_SetMcastDuplicateDetection
15116
15117 DESCRIPTION
15118 This function sets multicate duplicate detection operation.
15119 If enable is 1, the detection is enabled, else it is disabled.
15120
15121 DEPENDENCIES
15122
15123 PARAMETERS
15124
15125 IN
15126
15127 pvosGCtx : Pointer to VOS global context
15128 enable : Boolean to enable or disable
15129
15130 RETURN VALUE
15131 The result code associated with performing the operation
15132
15133 VOS_STATUS_E_FAULT: Sanity check on input failed
15134
15135 VOS_STATUS_SUCCESS: Everything is good :)
15136
15137 Other return values are possible coming from the called functions.
15138 Please check API for additional info.
15139
15140 SIDE EFFECTS
15141
15142==============================================================================*/
15143VOS_STATUS
15144WLANTL_SetMcastDuplicateDetection
15145(
15146 v_PVOID_t pvosGCtx,
15147 v_U8_t enable
15148)
15149{
15150 WLANTL_CbType* pTLCb;
15151
15152 /*Sanity check*/
15153 if (NULL == pvosGCtx)
15154 {
15155 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Jeff Johnsonddec6482017-09-19 08:33:57 -070015156 "WLAN TL %s: Sanity check failed pvosGCtx %pK",
Abhishek Singh00b71972016-01-07 10:51:04 +053015157 __func__, pvosGCtx));
15158 return VOS_STATUS_E_FAILURE;
15159 }
15160
15161 /*Sanity check*/
15162 pTLCb = VOS_GET_TL_CB(pvosGCtx);
15163 if (NULL == pTLCb)
15164 {
15165 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
15166 "WLAN TL %s: pTLCb is NULL", __func__));
15167 return VOS_STATUS_E_FAILURE;
15168 }
15169
15170 switch (enable)
15171 {
15172 default:
15173 /*
15174 * Any value other than 0 or 1 is used to dump the
15175 * duplicate count.
15176 */
15177 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
15178 "WLAN TL %s: Multicast Duplicate Count %d",
15179 __func__, pTLCb->mcastDupCnt));
15180 break;
15181 case 0:
15182 case 1:
15183 pTLCb->multicastDuplicateDetectionEnabled = enable;
15184 break;
15185 }
15186
15187 return VOS_STATUS_SUCCESS;
15188}
15189
15190#endif /* WLAN_FEATURE_RMC */