blob: 97e476682fe13410b0e0653a99fdd313b9fadbc8 [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Sravan Kumar Kairam18017eb2017-01-03 14:58:13 +05302 * Copyright (c) 2012-2017 The Linux Foundation. All rights reserved.
Kiet Lam1ed83fc2014-02-19 01:15:45 -08003 *
4 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
5 *
6 *
7 * Permission to use, copy, modify, and/or distribute this software for
8 * any purpose with or without fee is hereby granted, provided that the
9 * above copyright notice and this permission notice appear in all
10 * copies.
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
13 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
14 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
15 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
16 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
17 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
18 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19 * PERFORMANCE OF THIS SOFTWARE.
20 */
21
22/*
Kiet Lama7f454d2014-07-24 12:04:06 -070023 * This file was originally distributed by Qualcomm Atheros, Inc.
24 * under proprietary terms before Copyright ownership was assigned
25 * to the Linux Foundation.
Gopichand Nakkala92f07d82013-01-08 21:16:34 -080026 */
Kiet Lam1ed83fc2014-02-19 01:15:45 -080027
28
Kiet Lama7f454d2014-07-24 12:04:06 -070029
30
Jeff Johnson295189b2012-06-20 16:38:30 -070031/*===========================================================================
32
33
34 W L A N _ Q C T _ T L . C
35
36 OVERVIEW:
37
38 This software unit holds the implementation of the WLAN Transport Layer.
39
40 The functions externalized by this module are to be called ONLY by other
41 WLAN modules that properly register with the Transport Layer initially.
42
43 DEPENDENCIES:
44
45 Are listed for each API below.
46
47
Jeff Johnson295189b2012-06-20 16:38:30 -070048===========================================================================*/
49
50/*===========================================================================
51
52 EDIT HISTORY FOR FILE
53
54
55 This section contains comments describing changes made to the module.
56 Notice that changes are listed in reverse chronological order.
57
58
59 $Header$$DateTime$$Author$
60
61
62 when who what, where, why
63---------- --- --------------------------------------------------------
Abhishek Singh00b71972016-01-07 10:51:04 +0530642013-08-19 rajekuma Added RMC support
Jeff Johnson295189b2012-06-20 16:38:30 -0700652010-07-13 c_shinde Fixed an issue where WAPI rekeying was failing because
66 WAI frame sent out during rekeying had the protected bit
67 set to 1.
682010-05-06 rnair Changed name of variable from usLlcType to usEtherType
69 Changed function name from GetLLCType to GetEtherType
70 Fixed 802.3 to 802.11 frame translation issue where two
71 bytes of the LLC header was getting overwritten in the
72 non-Qos path
732010-05-06 rnair RxAuth path fix for modifying the header before ether
74 type is retreived (Detected while testing rekeying
75 in WAPI Volans)
762010-02-19 bad Fixed 802.11 to 802.3 ft issues with WAPI
772010-02-19 rnair WAPI: If frame is a WAI frame in TxConn and TxAuth, TL
78 does frame translation.
792010-02-01 rnair WAPI: Fixed a bug where the value of ucIsWapiSta was not
80 being set in the TL control block in the RegisterSTA func.
812010-01-08 lti Added TL Data Caching
822009-11-04 rnair WAPI: Moving common functionality to a seperate function
83 called WLANTL_GetLLCType
842009-10-15 rnair WAPI: Featurizing WAPI code
852009-10-09 rnair WAPI: Modifications to authenticated state handling of Rx data
862009-10-06 rnair Adding support for WAPI
872009-09-22 lti Add deregistration API for management client
882009-07-16 rnair Temporary fix to let TL fetch packets when multiple
89 peers exist in an IBSS
902009-06-10 lti Fix for checking TID value of meta info on TX - prevent
91 memory overwrite
92 Fix for properly checking the sta id for resuming trigger
93 frame generation
942009-05-14 lti Fix for sending out trigger frames
952009-05-15 lti Addr3 filtering
962009-04-13 lti Assert if packet larger then allowed
97 Drop packet that fails flatten
982009-04-02 lti Performance fixes for TL
992009-02-19 lti Added fix for LLC management on Rx Connect
1002009-01-16 lti Replaced peek data with extract data for non BD opertions
101 Extracted frame control in Tl and pass to HAL for frame
102 type evaluation
1032009-02-02 sch Add handoff support
1042008-12-09 lti Fixes for AMSS compilation
105 Removed assert on receive when there is no station
1062008-12-02 lti Fix fo trigger frame generation
1072008-10-31 lti Fix fo TL tx suspend
1082008-10-01 lti Merged in fixes from reordering
109 Disabled part of UAPSD functionality in TL
110 (will be re-enabled once UAPSD is tested)
111 Fix for UAPSD multiple enable
1122008-08-10 lti Fixes following UAPSD testing
113 Fixed infinite loop on mask computation when STA no reg
1142008-08-06 lti Fixes after QOS unit testing
1152008-08-06 lti Added QOS support
1162008-07-23 lti Fix for vos packet draining
1172008-07-17 lti Fix for data type value
118 Added frame translation code in TL
119 Avoid returning failure to PE in case previous frame is
120 still pending; fail previous and cache new one for tx
121 Get frames returning boolean true if more frames are pending
1222008-07-03 lti Fixes following pre-integration testing
1232008-06-26 lti Fixes following unit testing
124 Added alloc and free for TL context
125 Using atomic set u8 instead of u32
1262008-05-16 lti Created module
127
128===========================================================================*/
129
130/*----------------------------------------------------------------------------
131 * Include Files
132 * -------------------------------------------------------------------------*/
133#include "wlan_qct_tl.h"
134#include "wlan_qct_wda.h"
135#include "wlan_qct_tli.h"
136#include "wlan_qct_tli_ba.h"
137#include "wlan_qct_tl_hosupport.h"
Katya Nigam42e16e82014-02-04 16:28:55 +0530138#include "vos_types.h"
139#include "vos_trace.h"
140#include "wlan_qct_tl_trace.h"
Jeff Johnson295189b2012-06-20 16:38:30 -0700141#include "tlDebug.h"
Hanumantha Reddy Pothulaee001fc2015-05-26 15:21:53 +0530142#include "cfgApi.h"
Jeff Johnson295189b2012-06-20 16:38:30 -0700143#ifdef FEATURE_WLAN_WAPI
144/*Included to access WDI_RxBdType */
145#include "wlan_qct_wdi_bd.h"
146#endif
147/*Enables debugging behavior in TL*/
148#define TL_DEBUG
Hoonki Lee14621352013-04-16 17:51:19 -0700149/*Enables debugging FC control frame in TL*/
150//#define TL_DEBUG_FC
Jeff Johnson295189b2012-06-20 16:38:30 -0700151//#define WLAN_SOFTAP_FLOWCTRL_EN
Jeff Johnson295189b2012-06-20 16:38:30 -0700152//#define BTAMP_TEST
Hoonki Lee14621352013-04-16 17:51:19 -0700153#ifdef TL_DEBUG_FC
154#include <wlan_qct_pal_status.h>
155#include <wlan_qct_pal_device.h> // wpalReadRegister
156#endif
157
Jeff Johnson295189b2012-06-20 16:38:30 -0700158/*----------------------------------------------------------------------------
159 * Preprocessor Definitions and Constants
160 * -------------------------------------------------------------------------*/
161/*LLC header value*/
162static v_U8_t WLANTL_LLC_HEADER[] = {0xAA, 0xAA, 0x03, 0x00, 0x00, 0x00 };
163
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800164#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -0700165/*Aironet SNAP header value*/
166static v_U8_t WLANTL_AIRONET_SNAP_HEADER[] = {0xAA, 0xAA, 0x03, 0x00, 0x40, 0x96, 0x00, 0x00 };
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800167#endif //FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -0700168
169/*BT-AMP packet LLC OUI value*/
170const v_U8_t WLANTL_BT_AMP_OUI[] = {0x00, 0x19, 0x58 };
171
Dino Mycle3b9536d2014-07-09 22:05:24 +0530172#ifdef WLAN_FEATURE_LINK_LAYER_STATS
173extern const v_U8_t WLANTL_TID_2_AC[WLAN_MAX_TID];
174
175#endif
176
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530177#define WLANTL_MAX_SNR_DATA_SAMPLES 20
Jeff Johnson295189b2012-06-20 16:38:30 -0700178
179#ifdef VOLANS_PERF
180#define WLANTL_BD_PDU_INTERRUPT_ENABLE_THRESHOLD 120
181#define WLANTL_BD_PDU_INTERRUPT_GET_THRESHOLD 120
182
183/* TL BD/PDU threshold to enable interrupt */
184int bdPduInterruptEnableThreshold = WLANTL_BD_PDU_INTERRUPT_ENABLE_THRESHOLD;
185int bdPduInterruptGetThreshold = WLANTL_BD_PDU_INTERRUPT_GET_THRESHOLD;
186#endif /* VOLANS_PERF */
187
188/*-----------------------------------*
189 | Type(2b) | Sub-type(4b) |
190 *-----------------------------------*/
191#define WLANTL_IS_DATA_FRAME(_type_sub) \
192 ( WLANTL_DATA_FRAME_TYPE == ( (_type_sub) & 0x30 ))
193
194#define WLANTL_IS_QOS_DATA_FRAME(_type_sub) \
195 (( WLANTL_DATA_FRAME_TYPE == ( (_type_sub) & 0x30 )) && \
196 ( WLANTL_80211_DATA_QOS_SUBTYPE == ( (_type_sub) & 0xF )))
197
198#define WLANTL_IS_MGMT_FRAME(_type_sub) \
199 ( WLANTL_MGMT_FRAME_TYPE == ( (_type_sub) & 0x30 ))
200
Dino Mycle3b9536d2014-07-09 22:05:24 +0530201#define WLANTL_IS_MGMT_ACTION_FRAME(_type_sub) \
202 (( WLANTL_MGMT_FRAME_TYPE == ( (_type_sub) & 0x30 )) && \
203 ( ( WLANTL_80211_MGMT_ACTION_SUBTYPE == ( (_type_sub) & 0xF )) || \
204 ( WLANTL_80211_MGMT_ACTION_NO_ACK_SUBTYPE == ( (_type_sub) & 0xF ))))
205
Siddharth Bhal4551b102014-10-09 21:36:36 +0530206#define WLANTL_IS_PROBE_REQ(_type_sub) \
207 ( WLANTL_MGMT_PROBE_REQ_FRAME_TYPE == ( (_type_sub) & 0x3F ))
208
Jeff Johnson295189b2012-06-20 16:38:30 -0700209#define WLANTL_IS_CTRL_FRAME(_type_sub) \
210 ( WLANTL_CTRL_FRAME_TYPE == ( (_type_sub) & 0x30 ))
211
Mohit Khanna698ba2a2012-12-04 15:08:18 -0800212#ifdef FEATURE_WLAN_TDLS
213#define WLANTL_IS_TDLS_FRAME(_eth_type) \
214 ( WLANTL_LLC_TDLS_TYPE == ( _eth_type))
215#endif
216
Jeff Johnson295189b2012-06-20 16:38:30 -0700217/*MAX Allowed len processed by TL - MAx MTU + 802.3 header + BD+DXE+XTL*/
Madan Mohan Koyyalamudia53c4dc2012-11-13 10:35:42 -0800218#define WLANTL_MAX_ALLOWED_LEN (1514 + 100)
Jeff Johnson295189b2012-06-20 16:38:30 -0700219
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +0530220#define WLANTL_DATA_FLOW_MASK 0x0F
Jeff Johnson295189b2012-06-20 16:38:30 -0700221
Jeff Johnson295189b2012-06-20 16:38:30 -0700222//some flow_control define
223//LWM mode will be enabled for this station if the egress/ingress falls below this ratio
224#define WLANTL_LWM_EGRESS_INGRESS_THRESHOLD (0.75)
225
226//Get enough sample to do the LWM related calculation
227#define WLANTL_LWM_INGRESS_SAMPLE_THRESHOLD (64)
228
229//Maximal on-fly packet per station in LWM mode
230#define WLANTL_STA_BMU_THRESHOLD_MAX (256)
231
232#define WLANTL_AC_MASK (0x7)
Gopichand Nakkala976e3252013-01-03 15:45:56 -0800233#define WLANTL_STAID_OFFSET (0x6)
Jeff Johnson295189b2012-06-20 16:38:30 -0700234
235/* UINT32 type endian swap */
236#define SWAP_ENDIAN_UINT32(a) ((a) = ((a) >> 0x18 ) |(((a) & 0xFF0000) >> 0x08) | \
237 (((a) & 0xFF00) << 0x08) | (((a) & 0xFF) << 0x18))
238
Madan Mohan Koyyalamudi43acf032013-09-27 04:33:28 +0530239/* Maximum value of SNR that can be calculated by the HW */
240#define WLANTL_MAX_HW_SNR 35
Jeff Johnson295189b2012-06-20 16:38:30 -0700241
Hanumantha Reddy Pothulae5ab23d2015-09-14 18:08:24 +0530242#define DISABLE_ARP_TOGGLE 0
243#define ENABLE_ARP_TOGGLE 1
244#define SEND_ARP_ON_WQ5 2
245
Sravan Kumar Kairamb0edc612016-10-26 13:55:24 +0530246#define WLANTL_RATE_RATIO_THRESHOLD 2
Sravan Kumar Kairam416a0c22017-01-02 22:58:09 +0530247#define WLANTL_PER_THRESHOLD 5
248#define WLANTL_QUEUE_THRESHOLD 60
Sravan Kumar Kairamb0edc612016-10-26 13:55:24 +0530249#define WLANTL_GOOD_STA_WEIGHT 1
Sravan Kumar Kairamd482a2b2017-02-09 17:44:58 +0530250#define WLANTL_WEIGHT_THRESHOLD 50
Sravan Kumar Kairamb0edc612016-10-26 13:55:24 +0530251
Jeff Johnson295189b2012-06-20 16:38:30 -0700252/*----------------------------------------------------------------------------
253 * Type Declarations
254 * -------------------------------------------------------------------------*/
255#define TL_LITTLE_BIT_ENDIAN
256
257typedef struct
258{
259
Jeff Johnson295189b2012-06-20 16:38:30 -0700260
261 v_U8_t protVer :2;
262 v_U8_t type :2;
263 v_U8_t subType :4;
264
265 v_U8_t toDS :1;
266 v_U8_t fromDS :1;
267 v_U8_t moreFrag :1;
268 v_U8_t retry :1;
269 v_U8_t powerMgmt :1;
270 v_U8_t moreData :1;
271 v_U8_t wep :1;
272 v_U8_t order :1;
273
Jeff Johnson295189b2012-06-20 16:38:30 -0700274
275} WLANTL_MACFCType;
276
277/* 802.11 header */
278typedef struct
279{
280 /* Frame control field */
281 WLANTL_MACFCType wFrmCtrl;
282
283 /* Duration ID */
284 v_U16_t usDurationId;
285
286 /* Address 1 field */
287 v_U8_t vA1[VOS_MAC_ADDR_SIZE];
288
289 /* Address 2 field */
290 v_U8_t vA2[VOS_MAC_ADDR_SIZE];
291
292 /* Address 3 field */
293 v_U8_t vA3[VOS_MAC_ADDR_SIZE];
294
295 /* Sequence control field */
296 v_U16_t usSeqCtrl;
297
298 // Find the size of the mandatory header size.
299#define WLAN80211_MANDATORY_HEADER_SIZE \
300 (sizeof(WLANTL_MACFCType) + sizeof(v_U16_t) + \
301 (3 * (sizeof(v_U8_t) * VOS_MAC_ADDR_SIZE)) + \
302 sizeof(v_U16_t))
303
304 /* Optional A4 address */
305 v_U8_t optvA4[VOS_MAC_ADDR_SIZE];
306
307 /* Optional QOS control field */
308 v_U16_t usQosCtrl;
309}WLANTL_80211HeaderType;
310
311/* 802.3 header */
312typedef struct
313{
314 /* Destination address field */
315 v_U8_t vDA[VOS_MAC_ADDR_SIZE];
316
317 /* Source address field */
318 v_U8_t vSA[VOS_MAC_ADDR_SIZE];
319
320 /* Length field */
321 v_U16_t usLenType;
322}WLANTL_8023HeaderType;
323
324/*----------------------------------------------------------------------------
325 * Global Data Definitions
326 * -------------------------------------------------------------------------*/
327#define WLAN_TL_INVALID_U_SIG 255
328#define WLAN_TL_INVALID_B_SIG 255
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +0530329#define ENTER() VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO, "Enter:%s", __func__)
330
Jeff Johnson295189b2012-06-20 16:38:30 -0700331#define WLAN_TL_AC_ARRAY_2_MASK( _pSTA, _ucACMask, i ) \
332 do\
333 {\
334 _ucACMask = 0; \
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +0530335 for ( i = 0; i < WLANTL_NUM_TX_QUEUES; i++ ) \
Jeff Johnson295189b2012-06-20 16:38:30 -0700336 { \
337 if ( 0 != (_pSTA)->aucACMask[i] ) \
338 { \
339 _ucACMask |= ( 1 << i ); \
340 } \
341 } \
342 } while (0);
343
Kapil Guptad90b3862016-06-25 00:42:49 +0530344
345/* Following is the copy of g11bRateInfo to understand rate index at TL */
346#define WLANTL_MAX_RATE_NUM 137
347typedef struct
348{
349 uint32 phyRate; //unit in Mega bits per sec X 10
350 uint32 tputRate; //unit in Mega bits per sec X 10
351 uint32 tputBpms; //unit in Bytes per msec = (tputRateX1024x1024)/(8x10X1000) ~= (tputRate*13)
352 uint32 tputBpus; //unit in Bytes per usec: round off to integral value
353}WLANTL_RateInfo;
354
355WLANTL_RateInfo gTLRateInfo[WLANTL_MAX_RATE_NUM] = {
356 //11b rates
357 { 10, 9, 117, 0}, //index 0
358 { 20, 17, 221, 0}, //index 1
359 { 55, 41, 533, 0}, //index 2
360 { 110, 68, 884, 0}, //index 3
361
362 //11b short preamble
363 { 10, 10, 130, 0}, //index 4
364 { 20, 18, 234, 0}, //index 5
365 { 55, 44, 572, 0}, //index 6
366 { 110, 77, 1001, 0}, //index 7
367
368 //11ag
369 { 60, 50, 650, 1}, //index 8
370 { 90, 70, 910, 1}, //index 9
371 { 120, 100, 1300, 1}, //index 10
372 { 180, 150, 1950, 2}, //index 11
373 { 240, 190, 2470, 2}, //index 12
374 { 360, 280, 3640, 4}, //index 13
375 { 480, 350, 4550, 5}, //index 14
376 { 540, 380, 4940, 6}, //index 15
377
378 //11n SIMO
379 { 65, 54, 702, 1}, //index 16
380 { 130, 108, 1404, 1}, //index 17
381 { 195, 161, 2093, 2}, //index 18
382 { 260, 217, 2821, 3}, //index 19
383 { 390, 326, 4238, 4}, //index 20
384 { 520, 435, 5655, 6}, //index 21
385 { 585, 492, 6396, 6}, //index 22
386 { 650, 548, 7124, 7}, //index 23
387
388 //11n SIMO SGI
389 { 72, 59, 767, 1}, //index 24
390 { 144, 118, 1534, 2}, //index 25
391 { 217, 180, 2340, 2}, //index 26
392 { 289, 243, 3159, 3}, //index 27
393 { 434, 363, 4719, 5}, //index 28
394 { 578, 486, 6318, 6}, //index 29
395 { 650, 548, 7124, 7}, //index 30
396 { 722, 606, 7878, 8}, //index 31
397
398 //11n GF SIMO
399 { 65, 54, 702, 1}, //index 32
400 { 130, 108, 1404, 1}, //index 33
401 { 195, 161, 2093, 2}, //index 34
402 { 260, 217, 2821, 3}, //index 35
403 { 390, 326, 4238, 4}, //index 36
404 { 520, 435, 5655, 6}, //index 37
405 { 585, 492, 6396, 6}, //index 38
406 { 650, 548, 7124, 7}, //index 39
407
408 //11n SIMO CB MCS 0 - 7
409 { 135, 110, 1430, 1}, //index 40
410 { 270, 223, 2899, 3}, //index 41
411 { 405, 337, 4381, 4}, //index 42
412 { 540, 454, 5902, 6}, //index 43
413 { 810, 679, 8827, 9}, //index 44
414 { 1080, 909, 11817, 12}, //index 45
415 { 1215, 1022, 13286, 13}, //index 46
416 { 1350, 1137, 14781, 15}, //index 47
417
418 //11n SIMO CB SGI MCS 0 - 7
419 { 150, 121, 1573, 2}, //index 48
420 { 300, 249, 3237, 3}, //index 49
421 { 450, 378, 4914, 5}, //index 50
422 { 600, 503, 6539, 7}, //index 51
423 { 900, 758, 9854, 10}, //index 52
424 { 1200, 1010, 13130, 13}, //index 53
425 { 1350, 1137, 14781, 15}, //index 54
426 { 1500, 1262, 16406, 16}, //index 55
427
428 //11n SIMO GF CB MCS 0 - 7
429 { 135, 110, 1430, 1}, //index 56
430 { 270, 223, 2899, 3}, //index 57
431 { 405, 337, 4381, 4}, //index 58
432 { 540, 454, 5902, 6}, //index 59
433 { 810, 679, 8827, 9}, //index 60
434 { 1080, 909, 11817, 12}, //index 61
435 { 1215, 1022, 13286, 13}, //index 62
436 { 1350, 1137, 14781, 15}, //index 63
437
438 //11AC
439 { 1350, 675, 8775, 9}, //reserved 64
440 { 1350, 675, 8775, 9}, //reserved 65
441 { 65, 45, 585, 1}, //index 66
442 { 130, 91, 1183, 1}, //index 67
443 { 195, 136, 1768, 2}, //index 68
444 { 260, 182, 2366, 2}, //index 69
445 { 390, 273, 3549, 4}, //index 70
446 { 520, 364, 4732, 5}, //index 71
447 { 585, 409, 5317, 5}, //index 72
448 { 650, 455, 5915, 6}, //index 73
449 { 780, 546, 7098, 7}, //index 74
450 { 1350, 675, 8775, 9}, //reserved 75
451 { 1350, 675, 8775, 9}, //reserved 76
452 { 1350, 675, 8775, 9}, //reserved 77
453 { 1350, 675, 8775, 9}, //index 78
454 { 1350, 675, 8775, 9}, //index 79
455 { 1350, 675, 8775, 9}, //index 80
456 { 1350, 675, 8775, 9}, //index 81
457 { 1350, 675, 8775, 9}, //index 82
458 { 1350, 675, 8775, 9}, //index 83
459 { 655, 458, 5954, 6}, //index 84
460 { 722, 505, 6565, 7}, //index 85
461 { 866, 606, 7878, 8}, //index 86
462 { 1350, 675, 8775, 9}, //reserved 87
463 { 1350, 675, 8775, 9}, //reserved 88
464 { 1350, 675, 8775, 9}, //reserved 89
465 { 135, 94, 1222, 1}, //index 90
466 { 270, 189, 2457, 2}, //index 91
467 { 405, 283, 3679, 4}, //index 92
468 { 540, 378, 4914, 5}, //index 93
469 { 810, 567, 7371, 7}, //index 94
470 { 1080, 756, 9828, 10}, //index 95
471 { 1215, 850, 11050, 11}, //index 96
472 { 1350, 675, 8775, 9}, //index 97
473 { 1350, 675, 8775, 9}, //index 98
474 { 1620, 810, 10530, 11}, //index 99
475 { 1800, 900, 11700, 12}, //index 100
476 { 1350, 675, 8775, 9}, //reserved 101
477 { 1350, 675, 8775, 9}, //index 102
478 { 1350, 675, 8775, 9}, //index 103
479 { 1350, 675, 8775, 9}, //index 104
480 { 1350, 675, 8775, 9}, //index 105
481 { 1350, 675, 8775, 9}, //index 106
482 { 1200, 840, 10920, 11}, //index 107
483 { 1350, 675, 8775, 9}, //index 108
484 { 1500, 750, 9750, 10}, //index 109
485 { 1350, 675, 8775, 9}, //index 110
486 { 1800, 900, 11700, 12}, //index 111
487 { 2000, 1000, 13000, 13}, //index 112
488 { 1350, 675, 8775, 9}, //index 113
489 { 292, 204, 2652, 3}, //index 114
490 { 585, 409, 5317, 5}, //index 115
491 { 877, 613, 7969, 8}, //index 116
492 { 1170, 819, 10647, 11}, //index 117
493 { 1755, 877, 11401, 11}, //index 118
494 { 2340, 1170, 15210, 15}, //index 119
495 { 2632, 1316, 17108, 17}, //index 120
496 { 2925, 1462, 19006, 19}, //index 121
497 { 1350, 675, 8775, 9}, //index 122
498 { 3510, 1755, 22815, 23}, //index 123
499 { 3900, 1950, 25350, 25}, //index 124
500 { 1350, 675, 8775, 9}, //reserved 125
501 { 1350, 675, 8775, 9}, //index 126
502 { 1350, 675, 8775, 9}, //index 127
503 { 1350, 675, 8775, 9}, //index 128
504 { 1350, 675, 8775, 9}, //index 129
505 { 1350, 675, 8775, 9}, //index 130
506 { 1350, 675, 8775, 9}, //index 131
507 { 2925, 1462, 19006, 19}, //index 132
508 { 3250, 1625, 21125, 21}, //index 133
509 { 1350, 675, 8775, 9}, //index 134
510 { 3900, 1950, 25350, 25}, //index 135
511 { 4333, 2166, 28158, 28} //index 136
512 };
513
514
515
Jeff Johnson295189b2012-06-20 16:38:30 -0700516/*----------------------------------------------------------------------------
517 * Static Variable Definitions
518 * -------------------------------------------------------------------------*/
519
520/*----------------------------------------------------------------------------
521 * Static Function Declarations and Definitions
522 * -------------------------------------------------------------------------*/
523
524static VOS_STATUS
525WLANTL_GetEtherType
526(
527 v_U8_t * aucBDHeader,
528 vos_pkt_t * vosDataBuff,
529 v_U8_t ucMPDUHLen,
530 v_U16_t * usEtherType
531);
532
Jeff Johnson295189b2012-06-20 16:38:30 -0700533
534/*----------------------------------------------------------------------------
535 * Externalized Function Definitions
536* -------------------------------------------------------------------------*/
537
538/*----------------------------------------------------------------------------
539 * Function Declarations and Documentation
540 * -------------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +0530541/*==========================================================================
542
543 FUNCTION WLANTL_FreeClientMemory
544
545 DESCRIPTION
546 It frees up the memory allocated to all the STA clients in TLCB block
547 Can be called inside Close, Stop or when some FAULT occurs
548
549 DEPENDENCIES
550
551 PARAMETERS
552
553 IN
554 pClientSTA: Pointer to the global client pointer array
555
556 RETURN VALUE
557
558 SIDE EFFECTS
559
560============================================================================*/
561void WLANTL_FreeClientMemory
562(WLANTL_STAClientType* pClientSTA[WLAN_MAX_STA_COUNT])
563{
564 v_U32_t i = 0;
565 for(i =0; i < WLAN_MAX_STA_COUNT; i++)
566 {
567 if( NULL != pClientSTA[i] )
568 {
569 vos_mem_free(pClientSTA[i]);
570 }
571 pClientSTA[i] = NULL;
572 }
573 return;
574}
Jeff Johnson295189b2012-06-20 16:38:30 -0700575
576/*==========================================================================
577
578 FUNCTION WLANTL_Open
579
580 DESCRIPTION
581 Called by HDD at driver initialization. TL will initialize all its
582 internal resources and will wait for the call to start to register
583 with the other modules.
584
585 DEPENDENCIES
586
587 PARAMETERS
588
589 IN
590 pvosGCtx: pointer to the global vos context; a handle to TL's
591 control block can be extracted from its context
592 pTLConfig: TL Configuration
593
594 RETURN VALUE
595 The result code associated with performing the operation
596
597 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a page
598 fault
599 VOS_STATUS_SUCCESS: Everything is good :)
600
601 SIDE EFFECTS
602
603============================================================================*/
604VOS_STATUS
605WLANTL_Open
606(
607 v_PVOID_t pvosGCtx,
608 WLANTL_ConfigInfoType* pTLConfig
609)
610{
611 WLANTL_CbType* pTLCb = NULL;
612 v_U8_t ucIndex;
613 tHalHandle smeContext;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +0530614 v_U32_t i = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700615#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
616 VOS_STATUS status = VOS_STATUS_SUCCESS;
617#endif
618 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
619
620 /*------------------------------------------------------------------------
621 Sanity check
622 Extract TL control block
623 ------------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +0530624 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -0700625 vos_alloc_context( pvosGCtx, VOS_MODULE_ID_TL,
626 (void*)&pTLCb, sizeof(WLANTL_CbType));
627
628 pTLCb = VOS_GET_TL_CB(pvosGCtx);
629 if (( NULL == pTLCb ) || ( NULL == pTLConfig ) )
630 {
Madan Mohan Koyyalamudic0e5bd82012-09-18 17:12:27 -0700631 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_FATAL,
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
Jeff Johnson295189b2012-06-20 16:38:30 -07006162/*==========================================================================
6163
6164 FUNCTION WLANTL_RxFrames
6165
6166 DESCRIPTION
6167 Callback registered by TL and called by BAL when a packet is received
6168 over the bus. Upon the call of this function TL will make the necessary
6169 decision with regards to the forwarding or queuing of this packet and
6170 the layer it needs to be delivered to.
6171
6172 DEPENDENCIES
6173 TL must be initiailized before this function gets called.
6174 If the frame carried is a data frame then the station for which it is
6175 destined to must have been previously registered with TL.
6176
6177 PARAMETERS
6178
6179 IN
6180 pvosGCtx: pointer to the global vos context; a handle to TL's
6181 or BAL's control block can be extracted from its context
6182
6183 vosDataBuff: it will contain a pointer to the first buffer received,
6184 if there is more then one packet they will be chained
6185 using vOSS buffers.
6186
6187 RETURN VALUE
6188 The result code associated with performing the operation
6189
6190 VOS_STATUS_E_INVAL: Input parameters are invalid
6191 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
6192 page fault
6193 VOS_STATUS_SUCCESS: Everything is good :)
6194
6195 SIDE EFFECTS
6196
6197============================================================================*/
6198VOS_STATUS
6199WLANTL_RxFrames
6200(
6201 v_PVOID_t pvosGCtx,
6202 vos_pkt_t *pFrameDataBuff
6203)
6204{
6205 vos_pkt_t* vosDataBuff = (vos_pkt_t*)pFrameDataBuff;
6206 WLANTL_CbType* pTLCb = NULL;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306207 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07006208 WLANTL_STAFuncType pfnSTAFsm;
6209 vos_pkt_t* vosTempBuff;
6210 v_U8_t ucSTAId;
6211 VOS_STATUS vosStatus;
6212 v_U8_t ucFrmType;
6213 v_PVOID_t pvBDHeader = NULL;
6214 WLANTL_STAEventType wSTAEvent = WLANTL_RX_EVENT;
6215 v_U8_t ucTid = 0;
6216 v_BOOL_t broadcast = VOS_FALSE;
6217 v_BOOL_t selfBcastLoopback = VOS_FALSE;
Madan Mohan Koyyalamudidfd6aa82012-10-18 20:18:43 -07006218 static v_U8_t first_data_pkt_arrived;
Jeff Johnson295189b2012-06-20 16:38:30 -07006219 v_U32_t uDPUSig;
Jeff Johnson295189b2012-06-20 16:38:30 -07006220 v_U16_t usPktLen;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07006221 v_BOOL_t bForwardIAPPwithLLC = VOS_FALSE;
Dino Mycle3b9536d2014-07-09 22:05:24 +05306222#ifdef WLAN_FEATURE_LINK_LAYER_STATS
6223 v_S7_t currentAvgRSSI = 0;
6224 v_U8_t ac;
Dino Mycle3b9536d2014-07-09 22:05:24 +05306225#endif
Sravan Kumar Kairam2e44dd42017-02-13 18:31:09 +05306226 uint8_t ucMPDUHLen;
Sravan Kumar Kairam091e5b62017-01-23 14:14:20 +05306227 uint16_t seq_no;
Sravan Kumar Kairam2e44dd42017-02-13 18:31:09 +05306228 uint16_t usEtherType = 0;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07006229
Jeff Johnson295189b2012-06-20 16:38:30 -07006230 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
6231
6232 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
6233 "WLAN TL:TL Receive Frames called"));
6234
6235 /*------------------------------------------------------------------------
6236 Sanity check
6237 ------------------------------------------------------------------------*/
6238 if ( NULL == vosDataBuff )
6239 {
6240 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6241 "WLAN TL:Invalid parameter sent on WLANTL_RxFrames"));
6242 return VOS_STATUS_E_INVAL;
6243 }
6244
Katya Nigam3802f202013-12-16 19:27:14 +05306245 /*------------------------------------------------------------------------
6246 Popolaute timestamp as the time when packet arrives
6247 ---------------------------------------------------------------------- */
6248 vosDataBuff->timestamp = vos_timer_get_system_ticks();
6249
Jeff Johnson295189b2012-06-20 16:38:30 -07006250 /*------------------------------------------------------------------------
6251 Extract TL control block
6252 ------------------------------------------------------------------------*/
6253 pTLCb = VOS_GET_TL_CB(pvosGCtx);
6254 if ( NULL == pTLCb )
6255 {
6256 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6257 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_ChangeSTAState"));
6258 return VOS_STATUS_E_FAULT;
6259 }
6260
6261 /*---------------------------------------------------------------------
6262 Save the initial buffer - this is the first received buffer
6263 ---------------------------------------------------------------------*/
6264 vosTempBuff = vosDataBuff;
6265
Sravan Kumar Kairam4ea1c422017-02-21 11:59:13 +05306266 while (NULL != vosDataBuff)
Jeff Johnson295189b2012-06-20 16:38:30 -07006267 {
Madan Mohan Koyyalamudia148e1e2012-11-30 14:52:59 -08006268 broadcast = VOS_FALSE;
6269 selfBcastLoopback = VOS_FALSE;
6270
Jeff Johnson295189b2012-06-20 16:38:30 -07006271 vos_pkt_walk_packet_chain( vosDataBuff, &vosDataBuff, 1/*true*/ );
6272
Katya Nigame7b69a82015-04-28 15:24:06 +05306273 if( vos_get_conparam() == VOS_MONITOR_MODE )
6274 {
6275 if( pTLCb->isConversionReq )
6276 WLANTL_MonTranslate80211To8023Header(vosTempBuff, pTLCb);
6277
6278 pTLCb->pfnMonRx(pvosGCtx, vosTempBuff, pTLCb->isConversionReq);
6279 vosTempBuff = vosDataBuff;
6280 continue;
6281 }
6282
Jeff Johnson295189b2012-06-20 16:38:30 -07006283 /*---------------------------------------------------------------------
6284 Peek at BD header - do not remove
6285 !!! Optimize me: only part of header is needed; not entire one
6286 ---------------------------------------------------------------------*/
6287 vosStatus = WDA_DS_PeekRxPacketInfo( vosTempBuff, (v_PVOID_t)&pvBDHeader, 1/*Swap BD*/ );
6288
6289 if ( NULL == pvBDHeader )
6290 {
6291 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6292 "WLAN TL:Cannot extract BD header"));
6293 /* Drop packet */
6294 vos_pkt_return_packet(vosTempBuff);
6295 vosTempBuff = vosDataBuff;
6296 continue;
6297 }
6298
Jeff Johnson295189b2012-06-20 16:38:30 -07006299 /*---------------------------------------------------------------------
6300 Check if FC frame reported from FW
6301 ---------------------------------------------------------------------*/
6302 if(WDA_IS_RX_FC(pvBDHeader))
6303 {
6304 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
6305 "WLAN TL:receive one FC frame"));
6306
Sravan Kumar Kairamb0edc612016-10-26 13:55:24 +05306307 WLANTL_FlowControl(pTLCb, vosTempBuff);
6308
Jeff Johnson295189b2012-06-20 16:38:30 -07006309 /* Drop packet */
6310 vos_pkt_return_packet(vosTempBuff);
6311 vosTempBuff = vosDataBuff;
6312 continue;
6313 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006314
6315 /* AMSDU HW bug fix
6316 * After 2nd AMSDU subframe HW could not handle BD correctly
6317 * HAL workaround is needed */
6318 if(WDA_GET_RX_ASF(pvBDHeader))
6319 {
6320 WDA_DS_RxAmsduBdFix(pvosGCtx, pvBDHeader);
6321 }
6322
6323 /*---------------------------------------------------------------------
6324 Extract frame control field from 802.11 header if present
6325 (frame translation not done)
6326 ---------------------------------------------------------------------*/
6327
6328 vosStatus = WDA_DS_GetFrameTypeSubType( pvosGCtx, vosTempBuff,
6329 pvBDHeader, &ucFrmType );
6330 if ( VOS_STATUS_SUCCESS != vosStatus )
6331 {
6332 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6333 "WLAN TL:Cannot extract Frame Control Field"));
6334 /* Drop packet */
6335 vos_pkt_return_packet(vosTempBuff);
6336 vosTempBuff = vosDataBuff;
6337 continue;
6338 }
6339
Jeff Johnson295189b2012-06-20 16:38:30 -07006340 vos_pkt_get_packet_length(vosTempBuff, &usPktLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07006341
6342 /*---------------------------------------------------------------------
6343 Check if management and send to PE
6344 ---------------------------------------------------------------------*/
6345
Deepthi Gowrie89de132015-05-14 12:23:57 +05306346 if ( WLANTL_IS_MGMT_FRAME(ucFrmType))
Jeff Johnson295189b2012-06-20 16:38:30 -07006347 {
6348 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
6349 "WLAN TL:Sending packet to management client"));
6350 if ( VOS_STATUS_SUCCESS != vos_pkt_flatten_rx_pkt(&vosTempBuff))
6351 {
6352 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6353 "WLAN TL:Cannot flatten packet - dropping"));
6354 /* Drop packet */
6355 vos_pkt_return_packet(vosTempBuff);
6356 vosTempBuff = vosDataBuff;
6357 continue;
6358 }
6359 ucSTAId = (v_U8_t)WDA_GET_RX_STAID( pvBDHeader );
6360 /* Read RSSI and update */
6361 if(!WLANTL_STA_ID_INVALID(ucSTAId))
6362 {
6363#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
6364 /* Read RSSI and update */
6365 vosStatus = WLANTL_HSHandleRXFrame(pvosGCtx,
6366 WLANTL_MGMT_FRAME_TYPE,
6367 pvBDHeader,
6368 ucSTAId,
6369 VOS_FALSE,
6370 NULL);
6371#else
6372 vosStatus = WLANTL_ReadRSSI(pvosGCtx, pvBDHeader, ucSTAId);
6373#endif
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05306374 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
6375 {
6376 TLLOGW(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
6377 "Handle RX Management Frame fail within Handoff "
6378 "support module"));
6379 /* Do Not Drop packet at here
6380 * Revisit why HO module return fail
6381 * vos_pkt_return_packet(vosTempBuff);
6382 * vosTempBuff = vosDataBuff;
6383 * continue;
6384 */
6385 }
6386 vosStatus = WLANTL_ReadSNR(pvosGCtx, pvBDHeader, ucSTAId);
6387
6388 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
6389 {
6390 TLLOGW(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
6391 FL("Failed to Read SNR")));
6392 }
Dino Mycle3b9536d2014-07-09 22:05:24 +05306393#ifdef WLAN_FEATURE_LINK_LAYER_STATS
6394 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
6395 if ( NULL != pClientSTA)
6396 {
6397 pClientSTA->interfaceStats.mgmtRx++;
Dino Mycle3b9536d2014-07-09 22:05:24 +05306398 }
6399#endif
Sravan Kumar Kairame0e78442017-09-18 18:00:53 +05306400
6401 WLANTL_SampleRxRSSI(pTLCb, pvBDHeader, ucSTAId);
6402
Jeff Johnson295189b2012-06-20 16:38:30 -07006403 }
6404
Jeff Johnson295189b2012-06-20 16:38:30 -07006405 pTLCb->tlMgmtFrmClient.pfnTlMgmtFrmRx( pvosGCtx, vosTempBuff);
6406 }
6407 else /* Data Frame */
6408 {
6409 ucSTAId = (v_U8_t)WDA_GET_RX_STAID( pvBDHeader );
6410 ucTid = (v_U8_t)WDA_GET_RX_TID( pvBDHeader );
Sravan Kumar Kairam091e5b62017-01-23 14:14:20 +05306411 uDPUSig = WDA_GET_RX_DPUSIG(pvBDHeader);
Sravan Kumar Kairam2e44dd42017-02-13 18:31:09 +05306412 ucMPDUHLen = (uint8_t)WDA_GET_RX_MPDU_HEADER_LEN(pvBDHeader);
Sravan Kumar Kairam091e5b62017-01-23 14:14:20 +05306413 seq_no = (uint16_t)WDA_GET_RX_REORDER_CUR_PKT_SEQ_NO(pvBDHeader);
Jeff Johnson295189b2012-06-20 16:38:30 -07006414
6415 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
6416 "WLAN TL:Data packet received for STA %d", ucSTAId));
6417
6418 /*------------------------------------------------------------------
6419 This should be corrected when multipe sta support is added !!!
6420 for now bcast frames will be sent to the last registered STA
6421 ------------------------------------------------------------------*/
6422 if ( WDA_IS_RX_BCAST(pvBDHeader))
6423 {
6424 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
6425 "WLAN TL:TL rx Bcast frame - sending to last registered station"));
6426 broadcast = VOS_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006427 /*-------------------------------------------------------------------
6428 If Addr1 is b/mcast, but Addr3 is our own self MAC, it is a b/mcast
6429 pkt we sent looping back to us. To be dropped if we are non BTAMP
6430 -------------------------------------------------------------------*/
6431 if( WLANHAL_RX_BD_ADDR3_SELF_IDX ==
6432 (v_U8_t)WDA_GET_RX_ADDR3_IDX( pvBDHeader ))
6433 {
6434 selfBcastLoopback = VOS_TRUE;
6435 }
6436 }/*if bcast*/
6437
Sravan Kumar Kairam091e5b62017-01-23 14:14:20 +05306438 /* Pre assoc cache eapol */
6439 if (pTLCb->preassoc_caching)
6440 {
Sravan Kumar Kairam2e44dd42017-02-13 18:31:09 +05306441 WLANTL_GetEtherType(pvBDHeader,vosTempBuff, ucMPDUHLen, &usEtherType);
6442 if (WLANTL_LLC_8021X_TYPE != usEtherType)
6443 {
6444 VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
6445 "%s: RX Frame not EAPOL EtherType %d",
6446 __func__, usEtherType);
6447 vos_pkt_return_packet(vosTempBuff);
6448 }
6449 else
6450 {
6451 WLANTL_CacheEapol(pTLCb, vosTempBuff);
6452 TLLOG1(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
6453 "WLAN TL:TL preassoc_caching is enabled seq No: %d", seq_no));
6454 }
6455
Sravan Kumar Kairam091e5b62017-01-23 14:14:20 +05306456 vosTempBuff = vosDataBuff;
6457 continue;
6458 }
6459
Sravan Kumar Kairam09a5e0b2016-05-03 13:17:42 +05306460 if (WLANTL_STA_ID_INVALID(ucSTAId))
Jeff Johnson295189b2012-06-20 16:38:30 -07006461 {
6462 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
Sravan Kumar Kairam09a5e0b2016-05-03 13:17:42 +05306463 "WLAN TL:STAId %d. Invalid STA ID dropping pkt",
6464 ucSTAId));
Jeff Johnson295189b2012-06-20 16:38:30 -07006465 /* Drop packet */
6466 vos_pkt_return_packet(vosTempBuff);
6467 vosTempBuff = vosDataBuff;
6468 continue;
6469 }
6470
Sravan Kumar Kairam09a5e0b2016-05-03 13:17:42 +05306471 if (WLANTL_TID_INVALID( ucTid)) {
6472 /* There is a possibility AP uses wrong TID. In that case to avoid
6473 dropping EAPOL packet in the driver use TID to zero.*/
6474 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
6475 "WLAN TL:Invalid Tid: %d Frame type: %d", ucTid, ucFrmType);
Paul Zhangda6dd252016-08-11 13:51:49 +08006476 WDA_GET_RX_TID( pvBDHeader ) = 0;
Sravan Kumar Kairam09a5e0b2016-05-03 13:17:42 +05306477 ucTid = 0;
6478 }
6479
jagadeesh99d8e632015-04-27 13:21:24 +05306480#ifdef WLAN_FEATURE_LINK_LAYER_STATS
6481 ac = WLANTL_TID_2_AC[ucTid];
6482#endif
6483
Jeff Johnson295189b2012-06-20 16:38:30 -07006484 /*----------------------------------------------------------------------
6485 No need to lock cache access because cache manipulation only happens
6486 in the transport thread/task context
6487 - These frames are to be forwarded to the station upon registration
6488 which happens in the main thread context
6489 The caching here can happen in either Tx or Rx thread depending
6490 on the current SSC scheduling
6491 - also we need to make sure that the frames in the cache are fwd-ed to
6492 the station before the new incoming ones
6493 -----------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306494 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
6495 if (NULL == pClientSTA)
6496 {
6497 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
6498 "WLAN TL:STA not allocated memory. Dropping packet"));
6499 vos_pkt_return_packet(vosTempBuff);
6500 vosTempBuff = vosDataBuff;
6501 continue;
6502 }
6503
Hoonki Lee5305c3a2013-04-29 23:28:59 -07006504#ifdef FEATURE_WLAN_TDLS
6505 if (( pClientSTA->ucExists ) &&
6506 (WLAN_STA_TDLS == pClientSTA->wSTADesc.wSTAType) &&
6507 (pClientSTA->ucTxSuspended))
6508 vos_atomic_set_U8( &pClientSTA->ucTxSuspended, 0 );
6509 else if ( !broadcast && (pClientSTA->ucExists == 0 ) )
6510 {
6511 tpSirMacMgmtHdr pMacHeader = WDA_GET_RX_MAC_HEADER( pvBDHeader );
6512
6513 /* from the direct peer while it is not registered to TL yet */
6514 if ( (pMacHeader->fc.fromDS == 0) &&
6515 (pMacHeader->fc.toDS == 0) )
6516 {
6517 v_U8_t ucAddr3STAId;
6518
6519 ucAddr3STAId = WDA_GET_RX_ADDR3_IDX(pvBDHeader);
6520
6521 if ( WLANTL_STA_ID_INVALID(ucAddr3STAId) )
6522 {
6523 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
6524 "WLAN TL:STA ID %d invalid - dropping pkt", ucAddr3STAId));
6525 /* Drop packet */
6526 vos_pkt_return_packet(vosTempBuff);
6527 vosTempBuff = vosDataBuff;
6528 continue;
6529 }
6530
6531 if (!(pTLCb->atlSTAClients[ucAddr3STAId] && pTLCb->atlSTAClients[ucAddr3STAId]->ucExists &&
6532 (WLAN_STA_INFRA == pTLCb->atlSTAClients[ucAddr3STAId]->wSTADesc.wSTAType) &&
6533 (WLANTL_STA_AUTHENTICATED == pTLCb->atlSTAClients[ucAddr3STAId]->tlState)))
6534 {
6535 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
Arif Hussainf2b00992013-11-17 21:46:15 -08006536 "%s: staId %d addr3Id %d tlState %d. Unkown Receiver/Transmitter Dropping packet", __func__,
Hoonki Lee5305c3a2013-04-29 23:28:59 -07006537 ucSTAId, ucAddr3STAId, pTLCb->atlSTAClients[ucAddr3STAId]->tlState));
6538 vos_pkt_return_packet(vosTempBuff);
6539 vosTempBuff = vosDataBuff;
6540 continue;
6541 }
6542 else
6543 {
6544 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
Arif Hussainf2b00992013-11-17 21:46:15 -08006545 "%s: staId %d doesn't exist, but mapped to AP staId %d", __func__,
Hoonki Lee5305c3a2013-04-29 23:28:59 -07006546 ucSTAId, ucAddr3STAId));
6547 ucSTAId = ucAddr3STAId;
6548 pClientSTA = pTLCb->atlSTAClients[ucAddr3STAId];
6549 }
6550 }
6551 }
6552#endif
6553
Katya Nigam63902932014-06-26 19:04:23 +05306554 if (( pClientSTA->enableCaching == 1 ) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07006555 /*Dont buffer Broadcast/Multicast frames. If AP transmits bursts of Broadcast/Multicast data frames,
6556 * libra buffers all Broadcast/Multicast packets after authentication with AP,
6557 * So it will lead to low resource condition in Rx Data Path.*/
Katya Nigam63902932014-06-26 19:04:23 +05306558 ( WDA_IS_RX_BCAST(pvBDHeader) == 0 ))
Jeff Johnson295189b2012-06-20 16:38:30 -07006559 {
Katya Nigam6201c3e2014-05-27 17:51:42 +05306560 if( WDA_IsSelfSTA(pvosGCtx,ucSTAId))
6561 {
6562 //drop packet for Self STA index
6563 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
6564 "%s: Packet dropped for Self STA with staId %d ", __func__, ucSTAId ));
6565
6566 vos_pkt_return_packet(vosTempBuff);
6567 vosTempBuff = vosDataBuff;
6568 continue;
6569 }
Sravan Kumar Kairam091e5b62017-01-23 14:14:20 +05306570 /* Station has not yet been registered with TL - cache the frame */
Hoonki Lee5305c3a2013-04-29 23:28:59 -07006571 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
Arif Hussainf2b00992013-11-17 21:46:15 -08006572 "%s: staId %d exist %d tlState %d cache rx frame", __func__, ucSTAId,
Hoonki Lee5305c3a2013-04-29 23:28:59 -07006573 pClientSTA->ucExists, pClientSTA->tlState));
Jeff Johnson295189b2012-06-20 16:38:30 -07006574 WLANTL_CacheSTAFrame( pTLCb, ucSTAId, vosTempBuff, uDPUSig, broadcast, ucFrmType);
6575 vosTempBuff = vosDataBuff;
6576 continue;
6577 }
6578
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08006579#ifdef FEATURE_WLAN_ESE_UPLOAD
6580 if ((pClientSTA->wSTADesc.ucIsEseSta)|| broadcast)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07006581 {
6582 /*--------------------------------------------------------------------
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08006583 Filter the IAPP frames for ESE connection;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07006584 if data it will return false and it
6585 will be routed through the regular data path
6586 --------------------------------------------------------------------*/
6587 if ( WLANTL_IsIAPPFrame(pvBDHeader,
6588 vosTempBuff))
6589 {
6590 bForwardIAPPwithLLC = VOS_TRUE;
6591 }
6592 }
6593#endif
6594
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08006595#if defined(FEATURE_WLAN_ESE) && !defined(FEATURE_WLAN_ESE_UPLOAD)
6596 if ((pClientSTA->wSTADesc.ucIsEseSta)|| broadcast)
Jeff Johnson295189b2012-06-20 16:38:30 -07006597 {
6598 /*--------------------------------------------------------------------
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08006599 Filter the IAPP frames for ESE connection;
Jeff Johnson295189b2012-06-20 16:38:30 -07006600 if data it will return false and it
6601 will be routed through the regular data path
6602 --------------------------------------------------------------------*/
6603 if ( WLANTL_IsIAPPFrame(pvBDHeader,
6604 vosTempBuff))
6605 {
6606 if ( VOS_STATUS_SUCCESS != vos_pkt_flatten_rx_pkt(&vosTempBuff))
6607 {
6608 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6609 "WLAN TL:Cannot flatten packet - dropping"));
6610 /* Drop packet */
6611 vos_pkt_return_packet(vosTempBuff);
6612 } else {
6613
6614 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08006615 "WLAN TL: Received ESE IAPP Frame"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006616
6617 pTLCb->tlMgmtFrmClient.pfnTlMgmtFrmRx( pvosGCtx, vosTempBuff);
6618 }
6619 vosTempBuff = vosDataBuff;
6620 continue;
6621 }
6622 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08006623#endif /* defined(FEATURE_WLAN_ESE) && !defined(FEATURE_WLAN_ESE_UPLOAD) */
Jeff Johnson295189b2012-06-20 16:38:30 -07006624
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306625 if ( WLAN_STA_BT_AMP == pClientSTA->wSTADesc.wSTAType )
Jeff Johnson295189b2012-06-20 16:38:30 -07006626 {
6627 /*--------------------------------------------------------------------
6628 Process the ctrl BAP frame; if data it will return false and it
6629 will be routed through the regular data path
6630 --------------------------------------------------------------------*/
6631 if ( WLANTL_ProcessBAPFrame( pvBDHeader,
6632 vosTempBuff,
6633 pTLCb,
6634 &first_data_pkt_arrived,
6635 ucSTAId))
6636 {
6637 vosTempBuff = vosDataBuff;
6638 continue;
6639 }
6640 }/*if BT-AMP station*/
6641 else if(selfBcastLoopback == VOS_TRUE)
6642 {
6643 /* Drop packet */
6644 vos_pkt_return_packet(vosTempBuff);
6645 vosTempBuff = vosDataBuff;
6646 continue;
6647 }
6648
6649 /*---------------------------------------------------------------------
6650 Data packet received, send to state machine
6651 ---------------------------------------------------------------------*/
6652 wSTAEvent = WLANTL_RX_EVENT;
6653
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306654 pfnSTAFsm = tlSTAFsm[pClientSTA->tlState].
Jeff Johnson295189b2012-06-20 16:38:30 -07006655 pfnSTATbl[wSTAEvent];
6656
6657 if ( NULL != pfnSTAFsm )
6658 {
6659#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
6660 /* Read RSSI and update */
6661 vosStatus = WLANTL_HSHandleRXFrame(pvosGCtx,
6662 WLANTL_DATA_FRAME_TYPE,
6663 pvBDHeader,
6664 ucSTAId,
6665 broadcast,
6666 vosTempBuff);
6667 broadcast = VOS_FALSE;
6668#else
6669 vosStatus = WLANTL_ReadRSSI(pvosGCtx, pvBDHeader, ucSTAId);
Kiet Lam47325522014-03-10 11:50:46 -07006670#endif
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05306671 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
Jeff Johnson295189b2012-06-20 16:38:30 -07006672 {
6673 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
6674 "Handle RX Data Frame fail within Handoff support module"));
6675 /* Do Not Drop packet at here
6676 * Revisit why HO module return fail
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05306677 * vos_pkt_return_packet(vosTempBuff);
6678 * vosTempBuff = vosDataBuff;
6679 * continue;
Jeff Johnson295189b2012-06-20 16:38:30 -07006680 */
6681 }
Dino Mycle3b9536d2014-07-09 22:05:24 +05306682#ifdef WLAN_FEATURE_LINK_LAYER_STATS
6683 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
6684 if ( NULL != pClientSTA)
6685 {
6686 tpSirMacMgmtHdr pMacHeader = WDA_GET_RX_MAC_HEADER( pvBDHeader );
Mahesh A Saptasagarbbdcf122014-10-28 20:57:11 +05306687 if (!IS_BROADCAST_ADD(pMacHeader->da) && IS_MULTICAST_ADD(pMacHeader->da))
Dino Mycle3b9536d2014-07-09 22:05:24 +05306688 {
6689 pClientSTA->interfaceStats.accessCategoryStats[ac].rxMcast++;
6690 }
6691
6692 WLANTL_HSGetDataRSSI(pvosGCtx, pvBDHeader, ucSTAId,
6693 &currentAvgRSSI);
6694 pClientSTA->interfaceStats.rssiData = currentAvgRSSI;
6695
6696 pClientSTA->interfaceStats.accessCategoryStats[ac].rxMpdu++;
6697 if (WDA_IS_RX_AN_AMPDU (pvBDHeader))
6698 {
6699 pClientSTA->interfaceStats.accessCategoryStats[ac].rxAmpdu++;
6700 }
6701 }
6702
6703
6704#endif
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05306705 vosStatus = WLANTL_ReadSNR(pvosGCtx, pvBDHeader, ucSTAId);
6706
6707 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
6708 {
6709 TLLOGW(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
6710 FL("Failed to Read SNR")));
6711 }
6712
Sravan Kumar Kairame0e78442017-09-18 18:00:53 +05306713 WLANTL_SampleRxRSSI(pTLCb, pvBDHeader, ucSTAId);
6714
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07006715 pfnSTAFsm( pvosGCtx, ucSTAId, &vosTempBuff, bForwardIAPPwithLLC);
Jeff Johnson295189b2012-06-20 16:38:30 -07006716 }
6717 else
6718 {
6719 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
6720 "WLAN TL:NULL state function, STA:%d, State: %d- dropping packet",
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306721 ucSTAId, pClientSTA->tlState));
Jeff Johnson295189b2012-06-20 16:38:30 -07006722 /* Drop packet */
6723 vos_pkt_return_packet(vosTempBuff);
6724 vosTempBuff = vosDataBuff;
6725 continue;
6726 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006727 }/* else data frame*/
6728
6729 vosTempBuff = vosDataBuff;
6730 }/*while chain*/
6731
6732 return VOS_STATUS_SUCCESS;
6733}/* WLANTL_RxFrames */
6734
Dino Mycle3b9536d2014-07-09 22:05:24 +05306735#ifdef WLAN_FEATURE_LINK_LAYER_STATS
6736/*==========================================================================
6737
6738 FUNCTION WLANTL_CollectInterfaceStats
6739
6740 DESCRIPTION
6741 Utility function used by TL to send the statitics
6742
6743 DEPENDENCIES
6744
6745
6746 PARAMETERS
6747
6748 IN
6749
6750 ucSTAId: station for which the statistics need to collected
6751
6752 vosDataBuff: it will contain the pointer to the corresponding
6753 structure
6754
6755 RETURN VALUE
6756 The result code associated with performing the operation
6757
6758 VOS_STATUS_E_INVAL: Input parameters are invalid
6759 VOS_STATUS_SUCCESS: Everything is good :)
6760
6761 SIDE EFFECTS
6762
6763============================================================================*/
6764VOS_STATUS
6765WLANTL_CollectInterfaceStats
6766(
6767 v_PVOID_t pvosGCtx,
6768 v_U8_t ucSTAId,
6769 WLANTL_InterfaceStatsType *vosDataBuff
6770)
6771{
6772 WLANTL_CbType* pTLCb = NULL;
6773 /*------------------------------------------------------------------------
6774 Sanity check
6775 ------------------------------------------------------------------------*/
6776 if ( WLANTL_STA_ID_INVALID( ucSTAId ) )
6777 {
6778 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6779 "WLAN TL:Invalid station id requested on WLANTL_CollectStats"));
6780 return VOS_STATUS_E_FAULT;
6781 }
6782 /*------------------------------------------------------------------------
6783 Extract TL control block
6784 ------------------------------------------------------------------------*/
6785 pTLCb = VOS_GET_TL_CB(pvosGCtx);
6786 if ( NULL == pTLCb )
6787 {
6788 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6789 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_CollectStats"));
6790 return VOS_STATUS_E_FAULT;
6791 }
6792
6793 if ( NULL == pTLCb->atlSTAClients[ucSTAId] )
6794 {
6795 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6796 "WLAN TL:Client Memory was not allocated on %s", __func__));
6797 return VOS_STATUS_E_FAILURE;
6798 }
Srinivas Dasari98947432014-11-07 19:41:24 +05306799 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
6800 "WLAN TL: collect WIFI_STATS_IFACE results"));
6801
Dino Mycle3b9536d2014-07-09 22:05:24 +05306802 vos_mem_copy(vosDataBuff, &pTLCb->atlSTAClients[ucSTAId]->interfaceStats,
6803 sizeof(WLANTL_InterfaceStatsType));
6804 return VOS_STATUS_SUCCESS;
6805}
6806
Srinivas Dasari98947432014-11-07 19:41:24 +05306807/*==========================================================================
6808
6809 FUNCTION WLANTL_ClearInterfaceStats
6810
6811 DESCRIPTION
6812 Utility function used by TL to clear the statitics
6813
6814 DEPENDENCIES
6815
6816
6817 PARAMETERS
6818
6819 IN
6820
6821 ucSTAId: station for which the statistics need to collected
6822
6823 RETURN VALUE
6824 The result code associated with performing the operation
6825
6826 VOS_STATUS_E_INVAL: Input parameters are invalid
6827 VOS_STATUS_SUCCESS: Everything is good :)
6828
6829 SIDE EFFECTS
6830
6831============================================================================*/
6832VOS_STATUS
6833WLANTL_ClearInterfaceStats
6834(
6835 v_PVOID_t pvosGCtx,
6836 v_U8_t ucSTAId,
6837 v_U8_t statsClearReqMask
6838)
6839{
6840 WLANTL_CbType* pTLCb = NULL;
6841 WLANTL_STAClientType* pClientSTA = NULL;
6842 /*------------------------------------------------------------------------
6843 Sanity check
6844 ------------------------------------------------------------------------*/
6845 if ( WLANTL_STA_ID_INVALID( ucSTAId ) )
6846 {
6847 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6848 "WLAN TL:Invalid station id requested on WLANTL_CollectStats"));
6849 return VOS_STATUS_E_FAULT;
6850 }
6851 /*------------------------------------------------------------------------
6852 Extract TL control block
6853 ------------------------------------------------------------------------*/
6854 pTLCb = VOS_GET_TL_CB(pvosGCtx);
6855 if ( NULL == pTLCb )
6856 {
6857 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
6858 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_CollectStats"));
6859 return VOS_STATUS_E_FAULT;
6860 }
6861
6862 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
6863 if ( NULL == pClientSTA )
6864 {
6865 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
6866 "WLAN TL:Client Memory was not allocated on %s", __func__));
6867 return VOS_STATUS_E_FAILURE;
6868 }
6869
6870 if ((statsClearReqMask & WIFI_STATS_IFACE_AC) ||
6871 (statsClearReqMask & WIFI_STATS_IFACE)) {
6872 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
6873 "WLAN TL:cleared WIFI_STATS_IFACE_AC results"));
6874 pClientSTA->interfaceStats.accessCategoryStats[0].rxMcast = 0;
6875 pClientSTA->interfaceStats.accessCategoryStats[1].rxMcast = 0;
6876 pClientSTA->interfaceStats.accessCategoryStats[2].rxMcast = 0;
6877 pClientSTA->interfaceStats.accessCategoryStats[3].rxMcast = 0;
6878
6879 pClientSTA->interfaceStats.accessCategoryStats[0].rxMpdu = 0;
6880 pClientSTA->interfaceStats.accessCategoryStats[1].rxMpdu = 0;
6881 pClientSTA->interfaceStats.accessCategoryStats[2].rxMpdu = 0;
6882 pClientSTA->interfaceStats.accessCategoryStats[3].rxMpdu = 0;
6883
6884 pClientSTA->interfaceStats.accessCategoryStats[0].rxAmpdu = 0;
6885 pClientSTA->interfaceStats.accessCategoryStats[1].rxAmpdu = 0;
6886 pClientSTA->interfaceStats.accessCategoryStats[2].rxAmpdu = 0;
6887 pClientSTA->interfaceStats.accessCategoryStats[3].rxAmpdu = 0;
6888 }
6889
6890 if (statsClearReqMask & WIFI_STATS_IFACE) {
6891 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
6892 "WLAN TL:cleared WIFI_STATS_IFACE results"));
6893 pClientSTA->interfaceStats.mgmtRx = 0;
6894 pClientSTA->interfaceStats.rssiData = 0;
6895 return VOS_STATUS_SUCCESS;
6896 }
6897
6898 return VOS_STATUS_SUCCESS;
6899}
6900
Dino Mycle3b9536d2014-07-09 22:05:24 +05306901#endif /* WLAN_FEATURE_LINK_LAYER_STATS */
Jeff Johnson295189b2012-06-20 16:38:30 -07006902
6903/*==========================================================================
6904
6905 FUNCTION WLANTL_RxCachedFrames
6906
6907 DESCRIPTION
6908 Utility function used by TL to forward the cached frames to a particular
6909 station;
6910
6911 DEPENDENCIES
6912 TL must be initiailized before this function gets called.
6913 If the frame carried is a data frame then the station for which it is
6914 destined to must have been previously registered with TL.
6915
6916 PARAMETERS
6917
6918 IN
6919 pTLCb: pointer to TL handle
6920
6921 ucSTAId: station for which we need to forward the packets
6922
6923 vosDataBuff: it will contain a pointer to the first cached buffer
6924 received, if there is more then one packet they will be
6925 chained using vOSS buffers.
6926
6927 RETURN VALUE
6928 The result code associated with performing the operation
6929
6930 VOS_STATUS_E_INVAL: Input parameters are invalid
6931 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
6932 page fault
6933 VOS_STATUS_SUCCESS: Everything is good :)
6934
6935 SIDE EFFECTS
6936
6937============================================================================*/
6938VOS_STATUS
6939WLANTL_RxCachedFrames
6940(
6941 WLANTL_CbType* pTLCb,
6942 v_U8_t ucSTAId,
6943 vos_pkt_t* vosDataBuff
6944)
6945{
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306946 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07006947 WLANTL_STAFuncType pfnSTAFsm;
6948 vos_pkt_t* vosTempBuff;
6949 VOS_STATUS vosStatus;
6950 v_PVOID_t pvBDHeader = NULL;
6951 WLANTL_STAEventType wSTAEvent = WLANTL_RX_EVENT;
6952 v_U8_t ucTid = 0;
6953 v_BOOL_t broadcast = VOS_FALSE;
6954 v_BOOL_t bSigMatch = VOS_FALSE;
6955 v_BOOL_t selfBcastLoopback = VOS_FALSE;
Madan Mohan Koyyalamudidfd6aa82012-10-18 20:18:43 -07006956 static v_U8_t first_data_pkt_arrived;
Jeff Johnson295189b2012-06-20 16:38:30 -07006957 v_U32_t uDPUSig;
6958 v_U8_t ucUcastSig;
6959 v_U8_t ucBcastSig;
6960 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
6961
6962 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
6963 "WLAN TL:TL Receive Cached Frames called"));
6964
6965 /*------------------------------------------------------------------------
6966 Sanity check
6967 ------------------------------------------------------------------------*/
6968 if ( NULL == vosDataBuff )
6969 {
6970 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6971 "WLAN TL:Invalid parameter sent on WLANTL_RxFrames"));
6972 return VOS_STATUS_E_INVAL;
6973 }
6974
Mihir Sheteae6f02b2014-04-11 19:49:21 +05306975 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
6976
6977 if ( NULL == pClientSTA )
6978 {
6979 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6980 "WLAN TL:Client Memory was not allocated on %s", __func__));
6981 return VOS_STATUS_E_FAILURE;
6982 }
6983
6984 MTRACE(vos_trace(VOS_MODULE_ID_TL, TRACE_CODE_TL_FORWARD_CACHED_FRAMES,
6985 ucSTAId, 1<<16 | pClientSTA->tlCacheInfo.cacheSize));
6986
Jeff Johnson295189b2012-06-20 16:38:30 -07006987 /*---------------------------------------------------------------------
6988 Save the initial buffer - this is the first received buffer
6989 ---------------------------------------------------------------------*/
6990 vosTempBuff = vosDataBuff;
6991
6992 while ( NULL != vosTempBuff )
6993 {
Madan Mohan Koyyalamudia148e1e2012-11-30 14:52:59 -08006994 broadcast = VOS_FALSE;
6995 selfBcastLoopback = VOS_FALSE;
6996
Jeff Johnson295189b2012-06-20 16:38:30 -07006997 vos_pkt_walk_packet_chain( vosDataBuff, &vosDataBuff, 1/*true*/ );
6998
6999 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
7000 "WLAN TL:Sending new cached packet to station %d", ucSTAId));
7001 /*---------------------------------------------------------------------
7002 Peek at BD header - do not remove
7003 !!! Optimize me: only part of header is needed; not entire one
7004 ---------------------------------------------------------------------*/
7005 vosStatus = WDA_DS_PeekRxPacketInfo( vosTempBuff, (v_PVOID_t)&pvBDHeader, 0 );
7006
7007 if ( NULL == pvBDHeader )
7008 {
7009 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7010 "WLAN TL:Cannot extract BD header"));
7011 /* Drop packet */
7012 vos_pkt_return_packet(vosTempBuff);
7013 vosTempBuff = vosDataBuff;
7014 continue;
7015 }
7016
7017 uDPUSig = WDA_GET_RX_DPUSIG( pvBDHeader );
7018
7019 /* AMSDU HW bug fix
7020 * After 2nd AMSDU subframe HW could not handle BD correctly
7021 * HAL workaround is needed */
7022 if(WDA_GET_RX_ASF(pvBDHeader))
7023 {
7024 WDA_DS_RxAmsduBdFix(vos_get_global_context(VOS_MODULE_ID_TL,pTLCb),
7025 pvBDHeader);
7026 }
7027
7028 ucTid = (v_U8_t)WDA_GET_RX_TID( pvBDHeader );
7029
7030 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
7031 "WLAN TL:Data packet cached for STA %d", ucSTAId);
7032
7033 /*------------------------------------------------------------------
7034 This should be corrected when multipe sta support is added !!!
7035 for now bcast frames will be sent to the last registered STA
7036 ------------------------------------------------------------------*/
7037 if ( WDA_IS_RX_BCAST(pvBDHeader))
7038 {
7039 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
7040 "WLAN TL:TL rx Bcast frame "));
7041 broadcast = VOS_TRUE;
7042
7043 /* If Addr1 is b/mcast, but Addr3 is our own self MAC, it is a b/mcast
7044 * pkt we sent looping back to us. To be dropped if we are non BTAMP
7045 */
7046 if( WLANHAL_RX_BD_ADDR3_SELF_IDX ==
7047 (v_U8_t)WDA_GET_RX_ADDR3_IDX( pvBDHeader ))
7048 {
7049 selfBcastLoopback = VOS_TRUE;
7050 }
7051 }/*if bcast*/
7052
7053 /*-------------------------------------------------------------------------
7054 Check if the packet that we cached matches the DPU signature of the
7055 newly added station
7056 -------------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307057 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
7058
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307059 if ( NULL == pClientSTA )
7060 {
7061 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7062 "WLAN TL:Client Memory was not allocated on %s", __func__));
7063 return VOS_STATUS_E_FAILURE;
7064 }
7065
Jeff Johnson295189b2012-06-20 16:38:30 -07007066 if ( broadcast )
7067 {
7068 ucBcastSig = (v_U8_t)uDPUSig;
7069 bSigMatch = (( WLAN_TL_INVALID_B_SIG !=
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307070 pClientSTA->wSTADesc.ucBcastSig ) &&
7071 ( ucBcastSig == pClientSTA->wSTADesc.ucBcastSig ));
Jeff Johnson295189b2012-06-20 16:38:30 -07007072 }
7073 else
7074 {
7075 ucUcastSig = (v_U8_t)uDPUSig;
7076 bSigMatch = (( WLAN_TL_INVALID_U_SIG !=
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307077 pClientSTA->wSTADesc.ucUcastSig ) &&
7078 ( ucUcastSig == pClientSTA->wSTADesc.ucUcastSig ));
Jeff Johnson295189b2012-06-20 16:38:30 -07007079 }
7080
7081 /*-------------------------------------------------------------------------
7082 If the packet doesn't match - drop it
7083 -------------------------------------------------------------------------*/
7084 if ( !bSigMatch )
7085 {
Rajesh Chauhana6b08f42013-06-18 19:01:26 -07007086 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_MED,
Jeff Johnson295189b2012-06-20 16:38:30 -07007087 "WLAN TL: Cached packet does not match DPU Sig of the new STA - drop "
7088 " DPU Sig %d UC %d BC %d B %d",
7089 uDPUSig,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307090 pClientSTA->wSTADesc.ucUcastSig,
Rajesh Chauhana6b08f42013-06-18 19:01:26 -07007091 pClientSTA->wSTADesc.ucBcastSig,
Jeff Johnson295189b2012-06-20 16:38:30 -07007092 broadcast));
7093
7094 /* Drop packet */
7095 vos_pkt_return_packet(vosTempBuff);
7096 vosTempBuff = vosDataBuff;
7097 continue;
7098
7099 }/*if signature mismatch*/
7100
7101 /*------------------------------------------------------------------------
7102 Check if BT-AMP frame:
7103 - additional processing needed in this case to separate BT-AMP date
7104 from BT-AMP Ctrl path
7105 ------------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307106 if ( WLAN_STA_BT_AMP == pClientSTA->wSTADesc.wSTAType )
Jeff Johnson295189b2012-06-20 16:38:30 -07007107 {
7108 /*--------------------------------------------------------------------
7109 Process the ctrl BAP frame; if data it will return false and it
7110 will be routed through the regular data path
7111 --------------------------------------------------------------------*/
7112 if ( WLANTL_ProcessBAPFrame( pvBDHeader,
7113 vosTempBuff,
7114 pTLCb,
7115 &first_data_pkt_arrived,
7116 ucSTAId))
7117 {
7118 vosTempBuff = vosDataBuff;
7119 continue;
7120 }
7121 }/*if BT-AMP station*/
7122 else if(selfBcastLoopback == VOS_TRUE)
7123 {
7124 /* Drop packet */
7125 vos_pkt_return_packet(vosTempBuff);
7126 vosTempBuff = vosDataBuff;
7127 continue;
7128 }
7129
7130 /*---------------------------------------------------------------------
7131 Data packet received, send to state machine
7132 ---------------------------------------------------------------------*/
7133 wSTAEvent = WLANTL_RX_EVENT;
7134
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307135 pfnSTAFsm = tlSTAFsm[pClientSTA->tlState].
Jeff Johnson295189b2012-06-20 16:38:30 -07007136 pfnSTATbl[wSTAEvent];
7137
7138 if ( NULL != pfnSTAFsm )
7139 {
7140#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
7141 /* Read RSSI and update */
7142 vosStatus = WLANTL_HSHandleRXFrame(vos_get_global_context(
7143 VOS_MODULE_ID_TL,pTLCb),
7144 WLANTL_DATA_FRAME_TYPE,
7145 pvBDHeader,
7146 ucSTAId,
7147 broadcast,
7148 vosTempBuff);
7149 broadcast = VOS_FALSE;
7150#else
7151 vosStatus = WLANTL_ReadRSSI(vos_get_global_context(VOS_MODULE_ID_TL,pTLCb), pvBDHeader, ucSTAId);
Kiet Lam47325522014-03-10 11:50:46 -07007152#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007153 if(!VOS_IS_STATUS_SUCCESS(vosStatus))
7154 {
7155 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7156 "Handle RX Data Frame fail within Handoff support module"));
7157 /* Do Not Drop packet at here
7158 * Revisit why HO module return fail
7159 vos_pkt_return_packet(vosTempBuff);
7160 vosTempBuff = vosDataBuff;
7161 continue;
7162 */
7163 }
7164 pfnSTAFsm( vos_get_global_context(VOS_MODULE_ID_TL,pTLCb), ucSTAId,
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07007165 &vosTempBuff, VOS_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07007166 }
7167 else
7168 {
7169 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7170 "WLAN TL:NULL state function, STA:%d, State: %d- dropping packet",
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307171 ucSTAId, pClientSTA->tlState));
Jeff Johnson295189b2012-06-20 16:38:30 -07007172 /* Drop packet */
7173 vos_pkt_return_packet(vosTempBuff);
7174 vosTempBuff = vosDataBuff;
7175 continue;
7176 }
7177
7178 vosTempBuff = vosDataBuff;
7179 }/*while chain*/
7180
7181 return VOS_STATUS_SUCCESS;
7182}/* WLANTL_RxCachedFrames */
7183
Sravan Kumar Kairam091e5b62017-01-23 14:14:20 +05307184/**
7185 * WLANTL_ForwardPkts() - forward cached eapol frames
7186 * @pvosGCtx: pointer to vos global context
7187 * @data: value to indicate either forward or flush
7188 *
7189 * Return: None
7190 *
7191 */
7192static VOS_STATUS WLANTL_ForwardPkts(void* pvosGCtx, uint32_t data)
7193{
7194 WLANTL_CbType* pTLCb = NULL;
7195
7196 pTLCb = VOS_GET_TL_CB(pvosGCtx);
7197 if (NULL == pTLCb) {
7198 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7199 "%s: Invalid input pointer", __func__));
7200 return VOS_STATUS_E_FAULT;
7201 }
7202
7203 if (!data) {
7204 TLLOG2(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
7205 "%s: Pre assoc fail flush cache", __func__));
7206 WLANTL_FlushCachedFrames(pTLCb->vosEapolCachedFrame);
7207 goto done;
7208 }
7209
7210 /* forward packets to HDD */
7211 if (NULL != pTLCb->vosEapolCachedFrame) {
7212 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
7213 "%s: forward pre assoc cached frames", __func__));
7214 WLANTL_MonTranslate80211To8023Header(pTLCb->vosEapolCachedFrame, pTLCb);
7215 pTLCb->pfnEapolFwd(pvosGCtx, pTLCb->vosEapolCachedFrame);
7216 }
7217
7218done:
7219 pTLCb->vosEapolCachedFrame = NULL;
7220 pTLCb->preassoc_caching = false;
7221
7222 return VOS_STATUS_SUCCESS;
7223}
7224
Jeff Johnson295189b2012-06-20 16:38:30 -07007225/*==========================================================================
Katya Nigam664f5032014-05-05 12:24:32 +05307226 FUNCTION WLANTL_RxProcessMsg
7227
7228 DESCRIPTION
7229 Called by VOSS when a message was serialized for TL through the
7230 rx thread/task.
7231
7232 DEPENDENCIES
7233 The TL must be initialized before this function can be called.
7234
7235 PARAMETERS
7236
7237 IN
7238 pvosGCtx: pointer to the global vos context; a handle to TL's
7239 control block can be extracted from its context
7240 message: type and content of the message
7241
7242
7243 RETURN VALUE
7244 The result code associated with performing the operation
7245
7246 VOS_STATUS_E_INVAL: invalid input parameters
7247 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
7248 page fault
7249 VOS_STATUS_SUCCESS: Everything is good :)
7250
7251 Other values can be returned as a result of a function call, please check
7252 corresponding API for more info.
7253 SIDE EFFECTS
7254
7255============================================================================*/
7256VOS_STATUS
7257WLANTL_RxProcessMsg
7258(
7259 v_PVOID_t pvosGCtx,
7260 vos_msg_t* message
7261)
7262{
7263 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
7264 v_U32_t uData;
7265 v_U8_t ucSTAId;
7266 v_U8_t ucUcastSig;
7267 v_U8_t ucBcastSig;
7268
7269 /*------------------------------------------------------------------------
7270 Sanity check
7271 ------------------------------------------------------------------------*/
7272 if ( NULL == message )
7273 {
7274 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7275 "WLAN TL:Invalid parameter sent on WLANTL_RxProcessMessage"));
7276 return VOS_STATUS_E_INVAL;
7277 }
7278
7279 /*------------------------------------------------------------------------
7280 Process message
7281 ------------------------------------------------------------------------*/
7282 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
7283 "WLAN TL:Received message: %d through rx flow", message->type));
7284
7285 switch( message->type )
7286 {
7287
7288 case WLANTL_RX_FWD_CACHED:
7289 /*---------------------------------------------------------------------
7290 The data sent with the message has the following structure:
7291 | 00 | ucBcastSignature | ucUcastSignature | ucSTAID |
7292 each field above is one byte
7293 ---------------------------------------------------------------------*/
7294 uData = message->bodyval;
7295 ucSTAId = ( uData & 0x000000FF);
7296 ucUcastSig = ( uData & 0x0000FF00)>>8;
7297 ucBcastSig = (v_U8_t)(( uData & 0x00FF0000)>>16);
7298 vosStatus = WLANTL_ForwardSTAFrames( pvosGCtx, ucSTAId,
7299 ucUcastSig, ucBcastSig);
7300 break;
7301
Sravan Kumar Kairam091e5b62017-01-23 14:14:20 +05307302 case WLANTL_RX_FWD_PRE_ASSOC_CACHED:
7303 uData = message->bodyval;
7304 vosStatus = WLANTL_ForwardPkts(pvosGCtx, uData);
7305 break;
7306
Katya Nigam664f5032014-05-05 12:24:32 +05307307 default:
7308 /*no processing for now*/
7309 break;
7310 }
7311
7312 return VOS_STATUS_SUCCESS;
7313}
7314
7315
7316/*==========================================================================
Jeff Johnson295189b2012-06-20 16:38:30 -07007317 FUNCTION WLANTL_ResourceCB
7318
7319 DESCRIPTION
7320 Called by the TL when it has packets available for transmission.
7321
7322 DEPENDENCIES
7323 The TL must be registered with BAL before this function can be called.
7324
7325 PARAMETERS
7326
7327 IN
7328 pvosGCtx: pointer to the global vos context; a handle to TL's
7329 or BAL's control block can be extracted from its context
7330
7331 RETURN VALUE
7332 The result code associated with performing the operation
7333
7334 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
7335 page fault
7336 VOS_STATUS_SUCCESS: Everything is good :)
7337
7338 SIDE EFFECTS
7339
7340============================================================================*/
7341VOS_STATUS
7342WLANTL_ResourceCB
7343(
7344 v_PVOID_t pvosGCtx,
7345 v_U32_t uCount
7346)
7347{
7348 WLANTL_CbType* pTLCb = NULL;
7349 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
7350
7351 /*------------------------------------------------------------------------
7352 Sanity check
7353 Extract TL control block
7354 ------------------------------------------------------------------------*/
7355 pTLCb = VOS_GET_TL_CB(pvosGCtx);
7356 if ( NULL == pTLCb )
7357 {
7358 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7359 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_ChangeSTAState"));
7360 return VOS_STATUS_E_FAULT;
7361 }
7362
7363 pTLCb->uResCount = uCount;
7364
7365
7366 /*-----------------------------------------------------------------------
7367 Resume Tx if enough res and not suspended
7368 -----------------------------------------------------------------------*/
7369 if (( pTLCb->uResCount >= WDA_TLI_MIN_RES_MF ) &&
7370 ( 0 == pTLCb->ucTxSuspended ))
7371 {
7372 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
7373 "WLAN TL:Issuing Xmit start request to BAL for avail res ASYNC"));
7374 return WDA_DS_StartXmit(pvosGCtx);
7375 }
7376
7377 return VOS_STATUS_SUCCESS;
7378}/* WLANTL_ResourceCB */
7379
7380
Gopichand Nakkala11acd112012-12-31 16:04:04 -08007381/*==========================================================================
7382 FUNCTION WLANTL_IsTxXmitPending
7383
7384 DESCRIPTION
7385 Called by the WDA when it wants to know whether WDA_DS_TX_START_XMIT msg
7386 is pending in TL msg queue
7387
7388 DEPENDENCIES
7389 The TL must be registered with WDA before this function can be called.
7390
7391 PARAMETERS
7392
7393 IN
7394 pvosGCtx: pointer to the global vos context; a handle to TL's
7395 or WDA's control block can be extracted from its context
7396
7397 RETURN VALUE
7398 The result code associated with performing the operation
7399
7400 0: No WDA_DS_TX_START_XMIT msg pending
7401 1: Msg WDA_DS_TX_START_XMIT already pending in TL msg queue
7402
7403 SIDE EFFECTS
7404
7405============================================================================*/
7406v_BOOL_t
7407WLANTL_IsTxXmitPending
7408(
7409 v_PVOID_t pvosGCtx
7410)
7411{
7412
7413 WLANTL_CbType* pTLCb = NULL;
7414 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
7415
7416 /*------------------------------------------------------------------------
7417 Sanity check
7418 Extract TL control block
7419 ------------------------------------------------------------------------*/
7420 pTLCb = VOS_GET_TL_CB(pvosGCtx);
7421 if ( NULL == pTLCb )
7422 {
7423 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_FATAL,
7424 "WLAN TL:Invalid TL pointer from pvosGCtx in WLANTL_IsTxXmitPending "));
7425 return FALSE;
7426 }
7427
7428 return pTLCb->isTxTranmitMsgPending;
7429
7430}/*WLANTL_IsTxXmitPending */
7431
7432/*==========================================================================
7433 FUNCTION WLANTL_SetTxXmitPending
7434
7435 DESCRIPTION
7436 Called by the WDA when it wants to indicate that WDA_DS_TX_START_XMIT msg
7437 is pending in TL msg queue
7438
7439 DEPENDENCIES
7440 The TL must be registered with WDA before this function can be called.
7441
7442 PARAMETERS
7443
7444 IN
7445 pvosGCtx: pointer to the global vos context; a handle to TL's
7446 or WDA's control block can be extracted from its context
7447
7448 RETURN VALUE None
7449
7450 SIDE EFFECTS
7451
7452============================================================================*/
7453
7454v_VOID_t
7455WLANTL_SetTxXmitPending
7456(
7457 v_PVOID_t pvosGCtx
7458)
7459{
7460
7461 WLANTL_CbType* pTLCb = NULL;
7462 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
7463
7464 /*------------------------------------------------------------------------
7465 Sanity check
7466 Extract TL control block
7467 ------------------------------------------------------------------------*/
7468 pTLCb = VOS_GET_TL_CB(pvosGCtx);
7469 if ( NULL == pTLCb )
7470 {
7471 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_FATAL,
7472 "WLAN TL:Invalid TL pointer from pvosGCtx in WLANTL_SetTxXmitPending"));
7473 return;
7474 }
7475
7476 pTLCb->isTxTranmitMsgPending = 1;
7477 return;
7478
7479}/*WLANTL_SetTxXmitPending */
7480
7481/*==========================================================================
7482 FUNCTION WLANTL_ClearTxXmitPending
7483
7484 DESCRIPTION
7485 Called by the WDA when it wants to indicate that no WDA_DS_TX_START_XMIT msg
7486 is pending in TL msg queue
7487
7488 DEPENDENCIES
7489 The TL must be registered with WDA before this function can be called.
7490
7491 PARAMETERS
7492
7493 IN
7494 pvosGCtx: pointer to the global vos context; a handle to TL's
7495 or WDA's control block can be extracted from its context
7496
7497 RETURN VALUE None
7498
7499 SIDE EFFECTS
7500
7501============================================================================*/
7502
7503v_VOID_t
7504WLANTL_ClearTxXmitPending
7505(
7506 v_PVOID_t pvosGCtx
7507)
7508{
7509
7510 WLANTL_CbType* pTLCb = NULL;
7511 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
7512
7513 /*------------------------------------------------------------------------
7514 Sanity check
7515 Extract TL control block
7516 ------------------------------------------------------------------------*/
7517 pTLCb = VOS_GET_TL_CB(pvosGCtx);
7518 if ( NULL == pTLCb )
7519 {
7520 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_FATAL,
7521 "WLAN TL:Invalid TL pointer from pvosGCtx in WLANTL_ClearTxXmitPending "));
7522 return;
7523 }
7524
7525 pTLCb->isTxTranmitMsgPending = 0;
7526 return;
7527}/*WLANTL_ClearTxXmitPending */
7528
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307529/*==========================================================================
7530 FUNCTION WLANTL_TxThreadDebugHandler
7531
7532 DESCRIPTION
7533 Printing TL Snapshot dump, processed under TxThread context, currently
7534 information regarding the global TlCb struture. Dumps information related
7535 to per active STA connection currently in use by TL.
7536
7537 DEPENDENCIES
7538 The TL must be initialized before this gets called.
7539
7540 PARAMETERS
7541
7542 IN
7543 pvosGCtx: pointer to the global vos context; a handle to TL's
7544 or WDA's control block can be extracted from its context
7545
7546 RETURN VALUE None
7547
7548 SIDE EFFECTS
7549
7550============================================================================*/
7551
7552v_VOID_t
7553WLANTL_TxThreadDebugHandler
7554(
7555 v_PVOID_t *pVosContext
7556)
7557{
7558 WLANTL_CbType* pTLCb = NULL;
7559 WLANTL_STAClientType* pClientSTA = NULL;
7560 int i = 0;
Mihir Shete5d148f12014-12-16 17:54:49 +05307561 v_U8_t uFlowMask; // TX FlowMask from WDA
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307562
7563 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_FATAL,
7564 "WLAN TL: %s Enter ", __func__));
7565
7566 pTLCb = VOS_GET_TL_CB(pVosContext);
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307567
7568 if ( NULL == pVosContext || NULL == pTLCb )
7569 {
7570 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7571 "Global VoS Context or TL Context are NULL"));
7572 return;
7573 }
7574
Mihir Shete5d148f12014-12-16 17:54:49 +05307575 if (VOS_STATUS_SUCCESS == WDA_DS_GetTxFlowMask(pVosContext, &uFlowMask))
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307576 {
7577 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Mihir Shete5d148f12014-12-16 17:54:49 +05307578 "WDA uTxFlowMask: 0x%x", uFlowMask));
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307579 }
Mihir Shete5d148f12014-12-16 17:54:49 +05307580
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307581 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7582 "************************TL DUMP INFORMATION**************"));
7583
7584 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7585 "uDelayedTriggerFrmInt:%d\tuMinFramesProcThres:%d",
7586 pTLCb->tlConfigInfo.uDelayedTriggerFrmInt,
7587 pTLCb->tlConfigInfo.uMinFramesProcThres));
7588
7589 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7590 "Management Frame Client exists: %d",
7591 pTLCb->tlMgmtFrmClient.ucExists));
7592 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7593 "usPendingTxCompleteCount: %d\tucTxSuspended: %d",
7594 pTLCb->usPendingTxCompleteCount,
7595 pTLCb->ucTxSuspended));
7596
7597 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7598 "uResCount: %d", pTLCb->uResCount));
7599
7600 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7601 "ucRegisteredStaId: %d\tucCurrentSTA: %d",
7602 pTLCb->ucRegisteredStaId, pTLCb->ucCurrentSTA));
7603
7604 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7605 "UrgentFrameProcessing: %s\tuFramesProcThres: %d",
7606 (pTLCb->bUrgent?"True":"False"), pTLCb->uFramesProcThres));
7607
7608 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7609 "isTxTranmitMsgPending: %d\t isBMPS: %s",
7610 pTLCb->isTxTranmitMsgPending, pTLCb->isBMPS?"True":"False"));
7611
7612#ifdef FEATURE_WLAN_TDLS
7613 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7614 "TDLS Peer Count: %d", pTLCb->ucTdlsPeerCount));
7615#endif
7616
Mukul Sharma252582d2015-10-23 16:47:36 +05307617 TLLOG1(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307618 "++++++++++++++++++++Registerd Client Information++++++++++"));
7619
7620 for ( i =0; i<WLAN_MAX_STA_COUNT; i++ )
7621 {
7622 pClientSTA = pTLCb->atlSTAClients[i];
7623 if( NULL == pClientSTA || 0 == pClientSTA->ucExists)
7624 {
7625 continue;
7626 }
7627
Mukul Sharma252582d2015-10-23 16:47:36 +05307628 TLLOG1(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307629 "######################STA Index: %d ############################",i));
Mukul Sharma252582d2015-10-23 16:47:36 +05307630 TLLOG1(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO, "WLAN_STADescType:"));
7631 TLLOG1(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307632 "STAId: %d\t STA MAC Address: %pM", pClientSTA->wSTADesc.ucSTAId,
7633 pClientSTA->wSTADesc.vSTAMACAddress.bytes));
Mukul Sharma252582d2015-10-23 16:47:36 +05307634 TLLOG1(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307635 "STA Type: %d\tProtectedFrame: %d",
7636 pClientSTA->wSTADesc.wSTAType, pClientSTA->wSTADesc.ucProtectedFrame));
Mukul Sharma252582d2015-10-23 16:47:36 +05307637 TLLOG1(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307638 "QoS: %d\tRxFrameTrans: %d\tTxFrameTrans: %d",
7639 pClientSTA->wSTADesc.ucQosEnabled, pClientSTA->wSTADesc.ucSwFrameRXXlation,
7640 pClientSTA->wSTADesc.ucSwFrameTXXlation));
Mukul Sharma252582d2015-10-23 16:47:36 +05307641 TLLOG1(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307642 "ucUcastSig: %d\tucBcastSig: %d", pClientSTA->wSTADesc.ucUcastSig,
7643 pClientSTA->wSTADesc.ucBcastSig));
7644
Mukul Sharma252582d2015-10-23 16:47:36 +05307645 TLLOG1(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307646 "ClientIndex: %d\t Exists: %d", i, pClientSTA->ucExists));
Mukul Sharma252582d2015-10-23 16:47:36 +05307647 TLLOG1(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307648 "TL State: %d\t TL Priority: %d", pClientSTA->tlState,
7649 pClientSTA->tlPri));
Mukul Sharma252582d2015-10-23 16:47:36 +05307650 TLLOG1(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307651 "ucTxSuspended: %d\tucPktPending: %d", pClientSTA->ucTxSuspended,
7652 pClientSTA->ucPktPending));
Mukul Sharma252582d2015-10-23 16:47:36 +05307653 TLLOG1(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307654 "ucEAPOLPktPending: %d\tucNoMoreData: %d",
7655 pClientSTA->ucEapolPktPending, pClientSTA->ucNoMoreData));
Mukul Sharma252582d2015-10-23 16:47:36 +05307656 TLLOG1(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Katya Nigam63902932014-06-26 19:04:23 +05307657 "enableCaching: %d\t fcStaTxDisabled: %d", pClientSTA->enableCaching,
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307658 pClientSTA->fcStaTxDisabled));
Mukul Sharma252582d2015-10-23 16:47:36 +05307659 TLLOG1(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307660 "ucCurrentAC: %d\tucServicedAC: %d", pClientSTA->ucCurrentAC,
7661 pClientSTA->ucServicedAC));
Mukul Sharma252582d2015-10-23 16:47:36 +05307662 TLLOG1(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307663 "TID: %d\tautTxCount[0]: %d\tauRxCount[0]: %d",0, pClientSTA->auTxCount[0],
7664 pClientSTA->auRxCount[0]));
Mukul Sharma252582d2015-10-23 16:47:36 +05307665 TLLOG1(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307666 "aucAcMask[0]: %d\taucAcMask[1]: %d\taucAcMask[2]: %d\taucAcMask[3]: %d\t",
7667 pClientSTA->aucACMask[0], pClientSTA->aucACMask[1],
7668 pClientSTA->aucACMask[2], pClientSTA->aucACMask[3]));
7669 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Mukul Sharma252582d2015-10-23 16:47:36 +05307670
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307671 "ucCurrentWeight: %d", pClientSTA->ucCurrentWeight));
7672
7673 if( WLAN_STA_SOFTAP == pClientSTA->wSTADesc.wSTAType)
7674 {
mukul sharma2cdb8ea2015-10-01 14:53:38 +05307675 TLLOG1(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307676 "TrafficStatistics for SOFTAP Station:"));
mukul sharma2cdb8ea2015-10-01 14:53:38 +05307677 TLLOG1(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307678 "RUF=%d\tRMF=%d\tRBF=%d", pClientSTA->trafficStatistics.rxUCFcnt,
7679 pClientSTA->trafficStatistics.rxMCFcnt,
7680 pClientSTA->trafficStatistics.rxBCFcnt));
mukul sharma2cdb8ea2015-10-01 14:53:38 +05307681 TLLOG1(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307682 "RUB=%d\tRMB=%d\tRBB=%d", pClientSTA->trafficStatistics.rxUCBcnt,
7683 pClientSTA->trafficStatistics.rxMCBcnt,
7684 pClientSTA->trafficStatistics.rxBCBcnt));
mukul sharma2cdb8ea2015-10-01 14:53:38 +05307685 TLLOG1(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307686 "TUF=%d\tTMF=%d\tTBF=%d", pClientSTA->trafficStatistics.txUCFcnt,
7687 pClientSTA->trafficStatistics.txMCFcnt,
7688 pClientSTA->trafficStatistics.txBCFcnt));
mukul sharma2cdb8ea2015-10-01 14:53:38 +05307689 TLLOG1(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307690 "TUB=%d\tTMB=%d\tTBB=%d", pClientSTA->trafficStatistics.txUCBcnt,
7691 pClientSTA->trafficStatistics.txMCBcnt,
7692 pClientSTA->trafficStatistics.txBCBcnt));
7693 }
mukul sharma2cdb8ea2015-10-01 14:53:38 +05307694
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307695 }
7696 return;
7697}
7698
7699/*==========================================================================
Mihir Shetefd62d9d2014-08-06 15:08:21 +05307700 FUNCTION WLANTL_FatalErrorHandler
7701
7702 DESCRIPTION
7703 Handle Fatal errors detected on the TX path.
7704 Currently issues SSR to recover from the error.
7705
7706 DEPENDENCIES
7707 The TL must be initialized before this gets called.
7708
7709 PARAMETERS
7710
7711 IN
7712 pvosGCtx: pointer to the global vos context; a handle to TL's
7713 or WDA's control block can be extracted from its context
7714
7715 RETURN VALUE None
7716
7717 SIDE EFFECTS
7718
7719============================================================================*/
7720v_VOID_t
7721WLANTL_FatalErrorHandler
7722(
7723 v_PVOID_t *pVosContext
7724)
7725{
7726
7727 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_FATAL,
7728 "WLAN TL: %s Enter ", __func__));
7729
7730 if ( NULL == pVosContext )
7731 {
7732 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7733 "%s: Global VoS Context or TL Context are NULL",
7734 __func__));
7735 return;
7736 }
7737
7738 /*
7739 * Issue SSR. vos_wlanRestart has tight checks to make sure that
7740 * we do not send an FIQ if previous FIQ is not processed
7741 */
7742 vos_wlanRestart();
7743}
7744
7745/*==========================================================================
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307746 FUNCTION WLANTL_TLDebugMessage
7747
7748 DESCRIPTION
7749 Post a TL Snapshot request, posts message in TxThread.
7750
7751 DEPENDENCIES
7752 The TL must be initialized before this gets called.
7753
7754 PARAMETERS
7755
7756 IN
7757 displaySnapshot Boolean showing whether to dump the snapshot or not.
7758
7759 RETURN VALUE None
7760
7761 SIDE EFFECTS
7762
7763============================================================================*/
7764
7765v_VOID_t
7766WLANTL_TLDebugMessage
7767(
Mihir Shete327c2ab2014-11-13 15:17:02 +05307768 v_U32_t debugFlags
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307769)
7770{
7771 vos_msg_t vosMsg;
7772 VOS_STATUS status;
7773
Mihir Shete327c2ab2014-11-13 15:17:02 +05307774 if(debugFlags & WLANTL_DEBUG_TX_SNAPSHOT)
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307775 {
7776 vosMsg.reserved = 0;
7777 vosMsg.bodyptr = NULL;
7778 vosMsg.type = WLANTL_TX_SNAPSHOT;
7779
7780 status = vos_tx_mq_serialize( VOS_MODULE_ID_TL, &vosMsg);
7781 if(status != VOS_STATUS_SUCCESS)
7782 {
7783 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR, "TX Msg Posting Failed with status: %d",status));
7784 return;
7785 }
7786 }
Mihir Shete327c2ab2014-11-13 15:17:02 +05307787 if (debugFlags & WLANTL_DEBUG_FW_CLEANUP)
7788 {
7789 vosMsg.reserved = 0;
7790 vosMsg.bodyptr = NULL;
7791 vosMsg.type = WLANTL_TX_FW_DEBUG;
7792
7793 status = vos_tx_mq_serialize( VOS_MODULE_ID_TL, &vosMsg);
7794 if(status != VOS_STATUS_SUCCESS)
7795 {
7796 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR, "TX Msg Posting Failed with status: %d",status));
7797 return;
7798 }
7799 }
Sravan Kumar Kairame9d186c2015-11-27 23:37:02 +05307800 if(debugFlags & WLANTL_DEBUG_KICKDXE)
7801 {
7802 vosMsg.reserved = 0;
7803 vosMsg.bodyptr = NULL;
7804 vosMsg.type = WLANTL_TX_KICKDXE;
7805
7806 status = vos_tx_mq_serialize( VOS_MODULE_ID_TL, &vosMsg);
7807 if(status != VOS_STATUS_SUCCESS)
7808 {
7809 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR, "TX Msg Posting Failed with status: %d",status));
7810 return;
7811 }
7812 }
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307813 return;
7814}
Jeff Johnson295189b2012-06-20 16:38:30 -07007815
Mihir Shetefd62d9d2014-08-06 15:08:21 +05307816/*==========================================================================
7817 FUNCTION WLANTL_FatalError
7818
7819 DESCRIPTION
7820 Fatal error reported in TX path, post an event to TX Thread for further
7821 handling
7822
7823 DEPENDENCIES
7824 The TL must be initialized before this gets called.
7825
7826 PARAMETERS
7827
7828 VOID
7829
7830 RETURN VALUE None
7831
7832 SIDE EFFECTS
7833
7834============================================================================*/
7835
7836v_VOID_t
7837WLANTL_FatalError
7838(
7839 v_VOID_t
7840)
7841{
7842 vos_msg_t vosMsg;
7843 VOS_STATUS status;
7844
7845 vosMsg.reserved = 0;
7846 vosMsg.bodyptr = NULL;
7847 vosMsg.type = WLANTL_TX_FATAL_ERROR;
7848
7849 status = vos_tx_mq_serialize( VOS_MODULE_ID_TL, &vosMsg);
7850 if(status != VOS_STATUS_SUCCESS)
7851 {
7852 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7853 "%s: TX Msg Posting Failed with status: %d",
7854 __func__,status));
7855 }
7856 return;
7857}
Jeff Johnson295189b2012-06-20 16:38:30 -07007858/*============================================================================
7859 TL STATE MACHINE
7860============================================================================*/
7861
7862/*==========================================================================
7863 FUNCTION WLANTL_STATxConn
7864
7865 DESCRIPTION
7866 Transmit in connected state - only EAPOL and WAI packets allowed
7867
7868 DEPENDENCIES
7869 The STA must be registered with TL before this function can be called.
7870
7871 PARAMETERS
7872
7873 IN
7874 pvosGCtx: pointer to the global vos context; a handle to TL's
7875 control block can be extracted from its context
7876 ucSTAId: identifier of the station being processed
7877 vosDataBuff: pointer to the tx vos buffer
7878
7879 RETURN VALUE
7880 The result code associated with performing the operation
7881
7882 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
7883 page fault
7884 VOS_STATUS_SUCCESS: Everything is good :)
7885
7886 Other return values are possible coming from the called functions.
7887 Please check API for additional info.
7888
7889 SIDE EFFECTS
7890
7891============================================================================*/
7892VOS_STATUS
7893WLANTL_STATxConn
7894(
7895 v_PVOID_t pvosGCtx,
7896 v_U8_t ucSTAId,
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07007897 vos_pkt_t** pvosDataBuff,
7898 v_BOOL_t bForwardIAPPwithLLC
Jeff Johnson295189b2012-06-20 16:38:30 -07007899)
7900{
7901 v_U16_t usPktLen;
7902 VOS_STATUS vosStatus;
7903 v_MACADDR_t vDestMacAddr;
7904 vos_pkt_t* vosDataBuff = NULL;
7905 WLANTL_CbType* pTLCb = NULL;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307906 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07007907 WLANTL_MetaInfoType tlMetaInfo;
7908 v_U8_t ucTypeSubtype = 0;
7909 v_U8_t ucTid;
7910 v_U8_t extraHeadSpace = 0;
7911 v_U8_t ucWDSEnabled = 0;
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07007912 v_U8_t ucAC, ucACMask, i;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05307913 v_U32_t txFlag = HAL_TX_NO_ENCRYPTION_MASK;
Jeff Johnson295189b2012-06-20 16:38:30 -07007914 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
7915
7916 /*------------------------------------------------------------------------
7917 Sanity check
7918 Extract TL control block
7919 ------------------------------------------------------------------------*/
7920 pTLCb = VOS_GET_TL_CB(pvosGCtx);
7921 if ( NULL == pTLCb )
7922 {
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07007923 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7924 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_STATxConn");
Jeff Johnson295189b2012-06-20 16:38:30 -07007925 *pvosDataBuff = NULL;
7926 return VOS_STATUS_E_FAULT;
7927 }
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307928 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
7929
7930 if ( NULL == pClientSTA )
7931 {
7932 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7933 "WLAN TL:Client Memory was not allocated on %s", __func__));
7934 return VOS_STATUS_E_FAILURE;
7935 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007936
7937 /*-------------------------------------------------------------------
7938 Disable AC temporary - if successfull retrieve re-enable
7939 The order is justified because of the possible scenario
7940 - TL tryes to fetch packet for AC and it returns NULL
7941 - TL analyzes the data it has received to see if there are
7942 any more pkts available for AC -> if not TL will disable AC
7943 - however it is possible that while analyzing results TL got
7944 preempted by a pending indication where the mask was again set
7945 TL will not check again and as a result when it resumes
7946 execution it will disable AC
7947 To prevent this the AC will be disabled here and if retrieve
7948 is successfull it will be re-enabled
7949 -------------------------------------------------------------------*/
7950
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07007951
7952 //LTI:pTLCb->atlSTAClients[ucSTAId].
7953 //LTI: aucACMask[pTLCb->atlSTAClients[ucSTAId].ucCurrentAC] = 0;
7954
7955 /*------------------------------------------------------------------------
7956 Fetch packet from HDD
7957 ------------------------------------------------------------------------*/
Sunil Ravid5406f22013-01-22 00:18:31 -08007958#ifdef FEATURE_WLAN_TDLS
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307959 if ((WLAN_STA_SOFTAP != pClientSTA->wSTADesc.wSTAType) &&
Agarwal Ashishcd86f7b2014-06-16 17:11:58 +05307960 !(vos_concurrent_open_sessions_running()) &&
Sunil Ravid5406f22013-01-22 00:18:31 -08007961 !pTLCb->ucTdlsPeerCount)
7962 {
7963#else
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307964 if ((WLAN_STA_SOFTAP != pClientSTA->wSTADesc.wSTAType) &&
Agarwal Ashishcd86f7b2014-06-16 17:11:58 +05307965 !(vos_concurrent_open_sessions_running()))
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07007966 {
Sunil Ravid5406f22013-01-22 00:18:31 -08007967#endif
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307968 ucAC = pClientSTA->ucCurrentAC;
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07007969
7970 /*-------------------------------------------------------------------
7971 Disable AC temporary - if successfull retrieve re-enable
7972 The order is justified because of the possible scenario
7973 - TL tryes to fetch packet for AC and it returns NULL
7974 - TL analyzes the data it has received to see if there are
7975 any more pkts available for AC -> if not TL will disable AC
7976 - however it is possible that while analyzing results TL got
7977 preempted by a pending indication where the mask was again set
7978 TL will not check again and as a result when it resumes
7979 execution it will disable AC
7980 To prevent this the AC will be disabled here and if retrieve
7981 is successfull it will be re-enabled
7982 -------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307983 pClientSTA->aucACMask[ucAC] = 0;
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07007984 }
7985 else
7986 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307987 //softap case
7988 ucAC = pTLCb->uCurServedAC;
7989 pClientSTA->aucACMask[ucAC] = 0;
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07007990 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007991
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307992 /*You make an initial assumption that HDD has no more data and if the
Jeff Johnson295189b2012-06-20 16:38:30 -07007993 assumption was wrong you reset the flags to their original state
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307994 This will prevent from exposing a race condition between checking with HDD
Jeff Johnson295189b2012-06-20 16:38:30 -07007995 for packets and setting the flags to false*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307996 //LTI: vos_atomic_set_U8( &pTLCb->atlSTAClients[ucSTAId].ucPktPending, 0);
7997 //LTI: pTLCb->atlSTAClients[ucSTAId].ucNoMoreData = 1;
7998 vos_atomic_set_U8( &pClientSTA->ucPktPending, 0);
7999 WLAN_TL_AC_ARRAY_2_MASK( pClientSTA, ucACMask, i);
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308000 /*You make an initial assumption that HDD has no more data and if the
8001 assumption was wrong you reset the flags to their original state
8002 This will prevent from exposing a race condition between checking with HDD
8003 for packets and setting the flags to false*/
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07008004 if ( 0 == ucACMask )
8005 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308006 pClientSTA->ucNoMoreData = 1;
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07008007 }
8008 else
8009 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308010 vos_atomic_set_U8( &pClientSTA->ucPktPending, 1);
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07008011 }
8012
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07008013
Madan Mohan Koyyalamudid93f4942012-10-05 15:05:40 -07008014 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07008015 "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 +05308016 ucAC, ucACMask, pClientSTA->ucPktPending);
Jeff Johnson295189b2012-06-20 16:38:30 -07008017
8018 /*------------------------------------------------------------------------
8019 Fetch tx packet from HDD
8020 ------------------------------------------------------------------------*/
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07008021
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308022 vosStatus = pClientSTA->pfnSTAFetchPkt( pvosGCtx,
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07008023 &ucSTAId,
8024 ucAC,
8025 &vosDataBuff, &tlMetaInfo );
Jeff Johnson295189b2012-06-20 16:38:30 -07008026
8027 if (( VOS_STATUS_SUCCESS != vosStatus ) || ( NULL == vosDataBuff ))
8028 {
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07008029 TLLOG1(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -07008030 "WLAN TL:No more data at HDD status %d", vosStatus));
8031 *pvosDataBuff = NULL;
8032
8033 /*--------------------------------------------------------------------
8034 Reset AC for the serviced station to the highest priority AC
8035 -> due to no more data at the station
8036 Even if this AC is not supported by the station, correction will be
8037 made in the main TL loop
8038 --------------------------------------------------------------------*/
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05308039 pClientSTA->ucCurrentAC = WLANTL_AC_HIGH_PRIO;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308040 pClientSTA->ucCurrentWeight = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07008041
Madan Mohan Koyyalamudid8000342012-11-08 14:55:26 -08008042 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07008043 "WLAN TL: WLANTL_STATxConn no more packets in HDD for AC: %d AC Mask: %d",
8044 ucAC, ucACMask);
8045
Jeff Johnson295189b2012-06-20 16:38:30 -07008046 return vosStatus;
8047 }
8048
8049 /*There are still packets in HDD - set back the pending packets and
8050 the no more data assumption*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308051 vos_atomic_set_U8( &pClientSTA->ucPktPending, 1);
8052 pClientSTA->ucNoMoreData = 0;
8053 pClientSTA->aucACMask[ucAC] = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07008054
Jeff Johnson295189b2012-06-20 16:38:30 -07008055#ifdef WLAN_PERF
8056 vos_pkt_set_user_data_ptr( vosDataBuff, VOS_PKT_USER_DATA_ID_BAL,
8057 (v_PVOID_t)0);
8058
8059#endif /*WLAN_PERF*/
8060
8061
8062#ifdef FEATURE_WLAN_WAPI
8063 /*------------------------------------------------------------------------
8064 If the packet is neither an Eapol packet nor a WAI packet then drop it
8065 ------------------------------------------------------------------------*/
8066 if ( 0 == tlMetaInfo.ucIsEapol && 0 == tlMetaInfo.ucIsWai )
8067 {
Madan Mohan Koyyalamudid93f4942012-10-05 15:05:40 -07008068 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -07008069 "WLAN TL:Only EAPOL or WAI packets allowed before authentication"));
8070
8071 /* Fail tx for packet */
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308072 pClientSTA->pfnSTATxComp( pvosGCtx, vosDataBuff,
Jeff Johnson295189b2012-06-20 16:38:30 -07008073 VOS_STATUS_E_BADMSG);
8074 vosDataBuff = NULL;
8075 *pvosDataBuff = NULL;
8076 return VOS_STATUS_SUCCESS;
8077 }
8078#else
8079 if ( 0 == tlMetaInfo.ucIsEapol )
8080 {
8081 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
8082 "WLAN TL:Received non EAPOL packet before authentication"));
8083
8084 /* Fail tx for packet */
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308085 pClientSTA->pfnSTATxComp( pvosGCtx, vosDataBuff,
Jeff Johnson295189b2012-06-20 16:38:30 -07008086 VOS_STATUS_E_BADMSG);
8087 vosDataBuff = NULL;
8088 *pvosDataBuff = NULL;
8089 return VOS_STATUS_SUCCESS;
8090 }
8091#endif /* FEATURE_WLAN_WAPI */
8092
8093 /*-------------------------------------------------------------------------
8094 Check TID
8095 -------------------------------------------------------------------------*/
8096 ucTid = tlMetaInfo.ucTID;
8097
8098 /*Make sure TID is valid*/
8099 if ( WLANTL_TID_INVALID(ucTid))
8100 {
Rajesh Chauhan2df40bf2013-08-22 11:26:12 -07008101 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
Jeff Johnson295189b2012-06-20 16:38:30 -07008102 "WLAN TL:Invalid TID sent in meta info %d - defaulting to 0 (BE)",
8103 ucTid));
8104 ucTid = 0;
8105 }
8106
8107 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
8108 "WLAN TL:Attaching BD header to pkt on WLANTL_STATxConn"));
8109
8110#ifdef FEATURE_WLAN_WAPI
8111 /*------------------------------------------------------------------------
8112 Translate 802.3 frame to 802.11 if Frame translation is enabled or if
8113 frame is a WAI frame.
8114 ------------------------------------------------------------------------*/
8115 if ( ( 1 == tlMetaInfo.ucIsWai ) ||
8116 ( 0 == tlMetaInfo.ucDisableFrmXtl ) )
8117#else
8118 /*------------------------------------------------------------------------
8119 Translate 802.3 frame to 802.11 if Frame translation is enabled
8120 ------------------------------------------------------------------------*/
8121 if ( ( 0 == tlMetaInfo.ucDisableFrmXtl ) &&
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308122 ( 0 != pClientSTA->wSTADesc.ucSwFrameTXXlation) )
Jeff Johnson295189b2012-06-20 16:38:30 -07008123#endif //#ifdef FEATURE_WLAN_WAPI
8124 {
Kiran Venkatappacab0d352012-12-17 13:09:22 -08008125 vosStatus = WLANTL_Translate8023To80211Header( vosDataBuff, &vosStatus,
8126 pTLCb, &ucSTAId,
Ravi Joshid0699502013-07-08 15:48:47 -07008127 &tlMetaInfo, &ucWDSEnabled,
8128 &extraHeadSpace);
Jeff Johnson295189b2012-06-20 16:38:30 -07008129 if ( VOS_STATUS_SUCCESS != vosStatus )
8130 {
8131 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8132 "WLAN TL:Error when translating header WLANTL_STATxConn"));
8133
8134 return vosStatus;
8135 }
8136
8137 tlMetaInfo.ucDisableFrmXtl = 1;
8138 }
8139
8140 /*-------------------------------------------------------------------------
8141 Call HAL to fill BD header
8142 -------------------------------------------------------------------------*/
8143 ucTypeSubtype |= (WLANTL_80211_DATA_TYPE << 4);
8144
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308145 if ( pClientSTA->wSTADesc.ucQosEnabled )
Jeff Johnson295189b2012-06-20 16:38:30 -07008146 {
8147 ucTypeSubtype |= (WLANTL_80211_DATA_QOS_SUBTYPE);
8148 }
8149
Gopichand Nakkala8b54e912013-03-11 10:44:21 +05308150#ifdef FEATURE_WLAN_WAPI
8151 /* TL State does not transition to AUTHENTICATED till GTK is installed, So in
8152 * case of WPA where GTK handshake is done after the 4 way handshake, the
8153 * unicast 2/2 EAPOL packet from the STA->AP has to be encrypted even before
8154 * the TL is in authenticated state. Since the PTK has been installed
8155 * already (after the 4 way handshake) we make sure that all traffic
8156 * is encrypted henceforth.(Note: TL is still not in AUTHENTICATED state so
8157 * we will only allow EAPOL data or WAI in case of WAPI)
8158 */
8159 if (tlMetaInfo.ucIsEapol && pClientSTA->ptkInstalled)
8160 {
8161 txFlag = 0;
8162 }
8163#else
8164 if (pClientSTA->ptkInstalled)
8165 {
8166 txFlag = 0;
8167 }
8168#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07008169
8170 vosStatus = (VOS_STATUS)WDA_DS_BuildTxPacketInfo( pvosGCtx, vosDataBuff , &vDestMacAddr,
8171 tlMetaInfo.ucDisableFrmXtl, &usPktLen,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308172 pClientSTA->wSTADesc.ucQosEnabled, ucWDSEnabled,
Jeff Johnson295189b2012-06-20 16:38:30 -07008173 extraHeadSpace,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308174 ucTypeSubtype, &pClientSTA->wSTADesc.vSelfMACAddress,
Gopichand Nakkala8b54e912013-03-11 10:44:21 +05308175 ucTid, txFlag,
Sravan Kumar Kairamd9e8cbb2017-01-17 12:17:28 +05308176 tlMetaInfo.usTimeStamp, tlMetaInfo.ucIsEapol || tlMetaInfo.ucIsWai,
8177 tlMetaInfo.ucIsArp, tlMetaInfo.ucUP, tlMetaInfo.ucTxBdToken);
Jeff Johnson295189b2012-06-20 16:38:30 -07008178
8179 if ( VOS_STATUS_SUCCESS != vosStatus )
8180 {
8181 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8182 "WLAN TL:Failed while attempting to fill BD %d", vosStatus));
8183 *pvosDataBuff = NULL;
8184 return vosStatus;
8185 }
8186
8187 /*-----------------------------------------------------------------------
8188 Update tx counter for BA session query for tx side
8189 !1 - should this be done for EAPOL frames?
8190 -----------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308191 pClientSTA->auTxCount[ucTid]++;
Jeff Johnson295189b2012-06-20 16:38:30 -07008192
8193 vos_pkt_set_user_data_ptr( vosDataBuff, VOS_PKT_USER_DATA_ID_TL,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308194 (v_PVOID_t)pClientSTA->pfnSTATxComp );
Jeff Johnson295189b2012-06-20 16:38:30 -07008195
8196 /*------------------------------------------------------------------------
8197 Save data to input pointer for TL core
8198 ------------------------------------------------------------------------*/
8199 *pvosDataBuff = vosDataBuff;
8200 /*security frames cannot be delayed*/
8201 pTLCb->bUrgent = TRUE;
8202
Jeff Johnson295189b2012-06-20 16:38:30 -07008203 /* TX Statistics */
8204 if (!(tlMetaInfo.ucBcast || tlMetaInfo.ucMcast))
8205 {
8206 /* This is TX UC frame */
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308207 pClientSTA->trafficStatistics.txUCFcnt++;
8208 pClientSTA->trafficStatistics.txUCBcnt += usPktLen;
Jeff Johnson295189b2012-06-20 16:38:30 -07008209 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008210
8211 return VOS_STATUS_SUCCESS;
8212}/* WLANTL_STATxConn */
8213
8214
8215/*==========================================================================
8216 FUNCTION WLANTL_STATxAuth
8217
8218 DESCRIPTION
8219 Transmit in authenticated state - all data allowed
8220
8221 DEPENDENCIES
8222 The STA must be registered with TL before this function can be called.
8223
8224 PARAMETERS
8225
8226 IN
8227 pvosGCtx: pointer to the global vos context; a handle to TL's
8228 control block can be extracted from its context
8229 ucSTAId: identifier of the station being processed
8230 vosDataBuff: pointer to the tx vos buffer
8231
8232 RETURN VALUE
8233 The result code associated with performing the operation
8234
8235 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
8236 page fault
8237 VOS_STATUS_SUCCESS: Everything is good :)
8238
8239 Other return values are possible coming from the called functions.
8240 Please check API for additional info.
8241
8242 SIDE EFFECTS
8243
8244============================================================================*/
8245VOS_STATUS
8246WLANTL_STATxAuth
8247(
8248 v_PVOID_t pvosGCtx,
8249 v_U8_t ucSTAId,
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07008250 vos_pkt_t** pvosDataBuff,
8251 v_BOOL_t bForwardIAPPwithLLC
Jeff Johnson295189b2012-06-20 16:38:30 -07008252)
8253{
8254 v_U16_t usPktLen;
8255 VOS_STATUS vosStatus;
8256 v_MACADDR_t vDestMacAddr;
8257 vos_pkt_t* vosDataBuff = NULL;
8258 WLANTL_CbType* pTLCb = NULL;
8259 WLANTL_MetaInfoType tlMetaInfo;
8260 v_U8_t ucTypeSubtype = 0;
8261 WLANTL_ACEnumType ucAC;
8262 WLANTL_ACEnumType ucNextAC;
8263 v_U8_t ucTid;
8264 v_U8_t ucSwFrmXtl = 0;
8265 v_U8_t extraHeadSpace = 0;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308266 WLANTL_STAClientType *pStaClient = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07008267 v_U8_t ucWDSEnabled = 0;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05308268 v_U32_t ucTxFlag = 0;
Abhishek Singh45e68fe2014-12-11 12:55:59 +05308269 v_U8_t ucACMask, i;
Jeff Johnson295189b2012-06-20 16:38:30 -07008270 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
8271
8272 /*------------------------------------------------------------------------
8273 Sanity check
8274 Extract TL control block
8275 ------------------------------------------------------------------------*/
8276 pTLCb = VOS_GET_TL_CB(pvosGCtx);
8277 if (( NULL == pTLCb ) || ( NULL == pvosDataBuff ))
8278 {
8279 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Jeff Johnsonddec6482017-09-19 08:33:57 -07008280 "WLAN TL:Invalid input params on WLANTL_STATxAuth TL %pK DB %pK",
Jeff Johnson295189b2012-06-20 16:38:30 -07008281 pTLCb, pvosDataBuff));
8282 if (NULL != pvosDataBuff)
8283 {
8284 *pvosDataBuff = NULL;
8285 }
8286 if(NULL != pTLCb)
8287 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308288 if ( NULL == pTLCb->atlSTAClients[ucSTAId] )
8289 {
8290 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8291 "WLAN TL:Client Memory was not allocated on %s", __func__));
8292 return VOS_STATUS_E_FAILURE;
8293 }
8294 pTLCb->atlSTAClients[ucSTAId]->ucNoMoreData = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07008295 }
8296 return VOS_STATUS_E_FAULT;
8297 }
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308298 pStaClient = pTLCb->atlSTAClients[ucSTAId];
Jeff Johnson295189b2012-06-20 16:38:30 -07008299
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308300 if ( NULL == pStaClient )
8301 {
8302 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8303 "WLAN TL:Client Memory was not allocated on %s", __func__));
8304 return VOS_STATUS_E_FAILURE;
8305 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008306
8307 vos_mem_zero(&tlMetaInfo, sizeof(tlMetaInfo));
8308 /*------------------------------------------------------------------------
8309 Fetch packet from HDD
8310 ------------------------------------------------------------------------*/
Sunil Ravid5406f22013-01-22 00:18:31 -08008311#ifdef FEATURE_WLAN_TDLS
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308312 if ((WLAN_STA_SOFTAP != pStaClient->wSTADesc.wSTAType) &&
Agarwal Ashishcd86f7b2014-06-16 17:11:58 +05308313 (!vos_concurrent_open_sessions_running()) &&
Sunil Ravid5406f22013-01-22 00:18:31 -08008314 !pTLCb->ucTdlsPeerCount)
8315 {
8316#else
Jeff Johnson295189b2012-06-20 16:38:30 -07008317 if ((WLAN_STA_SOFTAP != pStaClient->wSTADesc.wSTAType) &&
Agarwal Ashishcd86f7b2014-06-16 17:11:58 +05308318 (!vos_concurrent_open_sessions_running()))
Jeff Johnson295189b2012-06-20 16:38:30 -07008319 {
8320#endif
8321 ucAC = pStaClient->ucCurrentAC;
8322
8323 /*-------------------------------------------------------------------
8324 Disable AC temporary - if successfull retrieve re-enable
8325 The order is justified because of the possible scenario
8326 - TL tryes to fetch packet for AC and it returns NULL
8327 - TL analyzes the data it has received to see if there are
8328 any more pkts available for AC -> if not TL will disable AC
8329 - however it is possible that while analyzing results TL got
8330 preempted by a pending indication where the mask was again set
8331 TL will not check again and as a result when it resumes
8332 execution it will disable AC
8333 To prevent this the AC will be disabled here and if retrieve
8334 is successfull it will be re-enabled
8335 -------------------------------------------------------------------*/
8336 pStaClient->aucACMask[pStaClient->ucCurrentAC] = 0;
8337
8338 // don't reset it, as other AC queues in HDD may have packets
8339 //vos_atomic_set_U8( &pStaClient->ucPktPending, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07008340 }
8341 else
8342 {
8343 //softap case
8344 ucAC = pTLCb->uCurServedAC;
8345 pStaClient->aucACMask[ucAC] = 0;
8346
8347 //vos_atomic_set_U8( &pStaClient->ucPktPending, 0);
8348 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008349
8350 WLAN_TL_AC_ARRAY_2_MASK( pStaClient, ucACMask, i);
Jeff Johnson295189b2012-06-20 16:38:30 -07008351 /*You make an initial assumption that HDD has no more data and if the
8352 assumption was wrong you reset the flags to their original state
8353 This will prevent from exposing a race condition between checking with HDD
8354 for packets and setting the flags to false*/
8355 if ( 0 == ucACMask )
8356 {
8357 vos_atomic_set_U8( &pStaClient->ucPktPending, 0);
8358 pStaClient->ucNoMoreData = 1;
8359 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008360
8361 vosStatus = pStaClient->pfnSTAFetchPkt( pvosGCtx,
8362 &ucSTAId,
8363 ucAC,
8364 &vosDataBuff, &tlMetaInfo );
8365
8366
8367 if (( VOS_STATUS_SUCCESS != vosStatus ) || ( NULL == vosDataBuff ))
8368 {
8369
8370 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05308371 "WLAN TL:Failed while attempting to fetch pkt from HDD QId:%d status:%d",
8372 ucAC, vosStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07008373 *pvosDataBuff = NULL;
8374 /*--------------------------------------------------------------------
8375 Reset AC for the serviced station to the highest priority AC
8376 -> due to no more data at the station
8377 Even if this AC is not supported by the station, correction will be
8378 made in the main TL loop
8379 --------------------------------------------------------------------*/
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05308380 pStaClient->ucCurrentAC = WLANTL_AC_HIGH_PRIO;
Jeff Johnson295189b2012-06-20 16:38:30 -07008381 pStaClient->ucCurrentWeight = 0;
8382
8383 return vosStatus;
8384 }
8385
Jeff Johnsone7245742012-09-05 17:12:55 -07008386 WLANTL_StatHandleTXFrame(pvosGCtx, ucSTAId, vosDataBuff, NULL, &tlMetaInfo);
Jeff Johnsone7245742012-09-05 17:12:55 -07008387
Jeff Johnson295189b2012-06-20 16:38:30 -07008388 /*There are still packets in HDD - set back the pending packets and
8389 the no more data assumption*/
8390 vos_atomic_set_U8( &pStaClient->ucPktPending, 1);
8391 pStaClient->ucNoMoreData = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07008392
Jeff Johnson295189b2012-06-20 16:38:30 -07008393 if (WLAN_STA_SOFTAP != pStaClient->wSTADesc.wSTAType)
8394 {
Jeff Johnson295189b2012-06-20 16:38:30 -07008395 // don't need to set it, as we don't reset it in this function.
8396 //vos_atomic_set_U8( &pTLCb->atlSTAClients[ucSTAId].ucPktPending, 1);
Jeff Johnson295189b2012-06-20 16:38:30 -07008397 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008398
8399#ifdef WLAN_PERF
8400 vos_pkt_set_user_data_ptr( vosDataBuff, VOS_PKT_USER_DATA_ID_BAL,
8401 (v_PVOID_t)0);
8402#endif /*WLAN_PERF*/
8403
8404 /*-------------------------------------------------------------------------
8405 Check TID
8406 -------------------------------------------------------------------------*/
8407 ucTid = tlMetaInfo.ucTID;
8408
8409 /*Make sure TID is valid*/
8410 if ( WLANTL_TID_INVALID(ucTid))
8411 {
Rajesh Chauhan2df40bf2013-08-22 11:26:12 -07008412 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
Jeff Johnson295189b2012-06-20 16:38:30 -07008413 "WLAN TL:Invalid TID sent in meta info %d - defaulting to 0 (BE)",
8414 ucTid));
8415 ucTid = 0;
8416 }
8417
8418 /*Save for UAPSD timer consideration*/
8419 pStaClient->ucServicedAC = ucAC;
8420
8421 if ( ucAC == pStaClient->ucCurrentAC )
8422 {
8423 pStaClient->aucACMask[pStaClient->ucCurrentAC] = 1;
8424 pStaClient->ucCurrentWeight--;
8425 }
8426 else
8427 {
8428 pStaClient->ucCurrentAC = ucAC;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308429 pStaClient->ucCurrentWeight = pTLCb->tlConfigInfo.ucAcWeights[ucAC] - 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07008430
8431 pStaClient->aucACMask[pStaClient->ucCurrentAC] = 1;
8432
8433 }
8434
Jeff Johnson295189b2012-06-20 16:38:30 -07008435 if (WLAN_STA_SOFTAP != pStaClient->wSTADesc.wSTAType)
8436 {
Jeff Johnson295189b2012-06-20 16:38:30 -07008437 if ( 0 == pStaClient->ucCurrentWeight )
8438 {
8439 WLANTL_ACEnumType tempAC = ucAC;
8440 /*-----------------------------------------------------------------------
8441 Choose next AC - !!! optimize me
8442 -----------------------------------------------------------------------*/
8443 while ( 0 != ucACMask )
8444 {
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05308445 if(tempAC == WLANTL_AC_BK)
8446 ucNextAC = WLANTL_AC_HIGH_PRIO;
8447 else
8448 ucNextAC = (tempAC - 1);
8449
Jeff Johnson295189b2012-06-20 16:38:30 -07008450 if ( 0 != pStaClient->aucACMask[ucNextAC] )
8451 {
8452 pStaClient->ucCurrentAC = ucNextAC;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308453 pStaClient->ucCurrentWeight = pTLCb->tlConfigInfo.ucAcWeights[ucNextAC];
Jeff Johnson295189b2012-06-20 16:38:30 -07008454
8455 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
8456 "WLAN TL: Changing serviced AC to: %d with Weight: %d",
8457 pStaClient->ucCurrentAC ,
8458 pStaClient->ucCurrentWeight));
8459 break;
8460 }
8461 tempAC = ucNextAC;
8462 }
8463 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008464 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008465
8466 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
8467 "WLAN TL:Attaching BD header to pkt on WLANTL_STATxAuth"));
8468
8469 /*------------------------------------------------------------------------
8470 Translate 802.3 frame to 802.11
8471 ------------------------------------------------------------------------*/
8472 if ( 0 == tlMetaInfo.ucDisableFrmXtl )
8473 {
8474 /* Needs frame translation */
8475 // if the client has not enabled SW-only frame translation
8476 // and if the frame is a unicast frame
8477 // (HW frame translation does not support multiple broadcast domains
8478 // so we use SW frame translation for broadcast/multicast frames)
8479#ifdef FEATURE_WLAN_WAPI
8480 // and if the frame is not a WAPI frame
8481#endif
8482 // then use HW_based frame translation
8483
8484 if ( ( 0 == pStaClient->wSTADesc.ucSwFrameTXXlation ) &&
8485 ( 0 == tlMetaInfo.ucBcast ) &&
8486 ( 0 == tlMetaInfo.ucMcast )
8487#ifdef FEATURE_WLAN_WAPI
8488 && ( tlMetaInfo.ucIsWai != 1 )
8489#endif
8490 )
8491 {
8492#ifdef WLAN_PERF
8493 v_U32_t uFastFwdOK = 0;
8494
8495 /* HW based translation. See if the frame could be fast forwarded */
8496 WDA_TLI_FastHwFwdDataFrame( pvosGCtx, vosDataBuff , &vosStatus,
8497 &uFastFwdOK, &tlMetaInfo, &pStaClient->wSTADesc);
8498
8499 if( VOS_STATUS_SUCCESS == vosStatus )
8500 {
8501 if(uFastFwdOK)
8502 {
8503 /* Packet could be fast forwarded now */
8504 vos_pkt_set_user_data_ptr( vosDataBuff, VOS_PKT_USER_DATA_ID_TL,
8505 (v_PVOID_t)pStaClient->pfnSTATxComp );
8506
8507 *pvosDataBuff = vosDataBuff;
8508
8509 /* TODO: Do we really need to update WLANTL_HSHandleTXFrame()
8510 stats for every pkt? */
8511 pStaClient->auTxCount[tlMetaInfo.ucTID]++;
8512 return vosStatus;
8513 }
8514 /* can't be fast forwarded, fall through normal (slow) path. */
8515 }
8516 else
8517 {
8518
8519 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8520 "WLAN TL:Failed while attempting to fastFwd BD %d", vosStatus));
8521 *pvosDataBuff = NULL;
8522 return vosStatus;
8523 }
8524#endif /*WLAN_PERF*/
8525 }
8526 else
8527 {
8528 /* SW based translation */
8529
Kiran Venkatappacab0d352012-12-17 13:09:22 -08008530 vosStatus = WLANTL_Translate8023To80211Header( vosDataBuff, &vosStatus,
8531 pTLCb, &ucSTAId,
Ravi Joshid0699502013-07-08 15:48:47 -07008532 &tlMetaInfo, &ucWDSEnabled,
8533 &extraHeadSpace);
Jeff Johnson295189b2012-06-20 16:38:30 -07008534 if ( VOS_STATUS_SUCCESS != vosStatus )
8535 {
8536 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8537 "WLAN TL:Error when translating header WLANTL_STATxAuth"));
8538 return vosStatus;
8539 }
8540
8541 TLLOG4(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_LOW,
Arif Hussainf2b00992013-11-17 21:46:15 -08008542 "WLAN TL software translation success"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008543 ucSwFrmXtl = 1;
8544 tlMetaInfo.ucDisableFrmXtl = 1;
8545 }
8546 }
Gopichand Nakkala574f6d12013-06-27 19:38:43 +05308547#ifdef FEATURE_WLAN_TDLS
8548 /*In case of TDLS, if the packet is destined to TDLS STA ucSTAId may
8549 change. so update the pStaClient accordingly */
8550 pStaClient = pTLCb->atlSTAClients[ucSTAId];
Jeff Johnson295189b2012-06-20 16:38:30 -07008551
Gopichand Nakkala574f6d12013-06-27 19:38:43 +05308552 if ( NULL == pStaClient )
8553 {
8554 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8555 "pStaClient is NULL %s", __func__));
8556 return VOS_STATUS_E_FAILURE;
8557 }
8558#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07008559 /*-------------------------------------------------------------------------
8560 Call HAL to fill BD header
8561 -------------------------------------------------------------------------*/
8562 ucTypeSubtype |= (WLANTL_80211_DATA_TYPE << 4);
8563
8564 if ( pStaClient->wSTADesc.ucQosEnabled )
8565 {
8566 ucTypeSubtype |= (WLANTL_80211_DATA_QOS_SUBTYPE);
8567 }
8568
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05308569 /* ucAC now points to TL Q ID with a new queue added in TL,
8570 * hence look for the uapsd info for the correct AC that
8571 * this packet belongs to.
8572 */
8573 ucTxFlag = (0 != pStaClient->wUAPSDInfo[tlMetaInfo.ac].ucSet)?
Jeff Johnson295189b2012-06-20 16:38:30 -07008574 HAL_TRIGGER_ENABLED_AC_MASK:0;
8575
8576#ifdef FEATURE_WLAN_WAPI
8577 if ( pStaClient->wSTADesc.ucIsWapiSta == 1 )
8578 {
8579#ifdef LIBRA_WAPI_SUPPORT
8580 ucTxFlag = ucTxFlag | HAL_WAPI_STA_MASK;
8581#endif //LIBRA_WAPI_SUPPORT
8582 if ( tlMetaInfo.ucIsWai == 1 )
8583 {
8584 ucTxFlag = ucTxFlag | HAL_TX_NO_ENCRYPTION_MASK;
8585 }
8586 }
8587#endif /* FEATURE_WLAN_WAPI */
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008588#ifdef FEATURE_WLAN_TDLS
8589 if ( pStaClient->wSTADesc.wSTAType == WLAN_STA_TDLS )
8590 {
8591 ucTxFlag = ucTxFlag | HAL_TDLS_PEER_STA_MASK;
8592 }
8593#endif /* FEATURE_WLAN_TDLS */
Abhishek Singhfa011222014-04-14 10:57:08 +05308594 if( tlMetaInfo.ucIsArp )
8595 {
Sravan Kumar Kairamd9e8cbb2017-01-17 12:17:28 +05308596 if (pTLCb->track_arp)
8597 {
8598 if (vos_check_arp_target_ip(vosDataBuff))
8599 {
8600 ucTxFlag |= HAL_USE_FW_IN_TX_PATH;
8601 ucTxFlag |= HAL_TXCOMP_REQUESTED_MASK;
8602 tlMetaInfo.ucTxBdToken = ++ pTLCb->txbd_token;
8603 }
8604 }
8605
Hanumantha Reddy Pothulae5ab23d2015-09-14 18:08:24 +05308606 if (pStaClient->arpOnWQ5)
8607 {
8608 ucTxFlag |= HAL_USE_FW_IN_TX_PATH;
8609 }
Hanumantha Reddy Pothulaee001fc2015-05-26 15:21:53 +05308610 if (pStaClient->arpRate == 0)
8611 {
8612 ucTxFlag |= HAL_USE_BD_RATE_1_MASK;
8613 }
8614 else if (pStaClient->arpRate == 1 || pStaClient->arpRate == 3)
8615 {
8616 pStaClient->arpRate ^= 0x2;
8617 ucTxFlag |= HAL_USE_BD_RATE_1_MASK<<(pStaClient->arpRate-1);
8618 }
8619 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
8620 "arp pkt sending on BD rate: %hhu", pStaClient->arpRate));
Abhishek Singhfa011222014-04-14 10:57:08 +05308621 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008622
8623 vosStatus = (VOS_STATUS)WDA_DS_BuildTxPacketInfo( pvosGCtx,
8624 vosDataBuff , &vDestMacAddr,
8625 tlMetaInfo.ucDisableFrmXtl, &usPktLen,
8626 pStaClient->wSTADesc.ucQosEnabled, ucWDSEnabled,
8627 extraHeadSpace,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308628 ucTypeSubtype, &pStaClient->wSTADesc.vSelfMACAddress,
Jeff Johnson295189b2012-06-20 16:38:30 -07008629 ucTid, ucTxFlag, tlMetaInfo.usTimeStamp,
Sravan Kumar Kairamd9e8cbb2017-01-17 12:17:28 +05308630 tlMetaInfo.ucIsEapol, tlMetaInfo.ucIsArp, tlMetaInfo.ucUP,
Ganesh Kondabattini10e67352015-03-16 17:41:57 +05308631 tlMetaInfo.ucTxBdToken);
Jeff Johnson295189b2012-06-20 16:38:30 -07008632
8633 if(!VOS_IS_STATUS_SUCCESS(vosStatus))
8634 {
8635 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8636 "Fill TX BD Error status %d", vosStatus));
8637
8638 return vosStatus;
8639 }
8640
Jeff Johnson295189b2012-06-20 16:38:30 -07008641 /* TX Statistics */
8642 if (!(tlMetaInfo.ucBcast || tlMetaInfo.ucMcast))
8643 {
8644 /* This is TX UC frame */
8645 pStaClient->trafficStatistics.txUCFcnt++;
8646 pStaClient->trafficStatistics.txUCBcnt += usPktLen;
8647 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008648
Kiran Venkatappacab0d352012-12-17 13:09:22 -08008649#ifndef FEATURE_WLAN_TDLS
Jeff Johnson295189b2012-06-20 16:38:30 -07008650 /*-----------------------------------------------------------------------
8651 Update tx counter for BA session query for tx side
8652 -----------------------------------------------------------------------*/
8653 pStaClient->auTxCount[ucTid]++;
Kiran Venkatappacab0d352012-12-17 13:09:22 -08008654#else
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308655 pTLCb->atlSTAClients[ucSTAId]->auTxCount[ucTid]++;
Kiran Venkatappacab0d352012-12-17 13:09:22 -08008656#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07008657
8658 /* This code is to send traffic with lower priority AC when we does not
8659 get admitted to send it. Today HAL does not downgrade AC so this code
8660 does not get executed.(In other words, HAL doesnÂ’t change tid. The if
8661 statement is always false.)
8662 NOTE: In the case of LA downgrade occurs in HDD (that was the change
8663 Phani made during WMM-AC plugfest). If WM & BMP also took this approach,
8664 then there will be no need for any AC downgrade logic in TL/WDI. */
8665#if 0
8666 if (( ucTid != tlMetaInfo.ucTID ) &&
8667 ( 0 != pStaClient->wSTADesc.ucQosEnabled ) &&
8668 ( 0 != ucSwFrmXtl ))
8669 {
8670 /*---------------------------------------------------------------------
8671 !! FIX me: Once downgrading is clear put in the proper change
8672 ---------------------------------------------------------------------*/
8673 ucQCOffset = WLANHAL_TX_BD_HEADER_SIZE + WLANTL_802_11_HEADER_LEN;
8674
8675 //!!!Fix this replace peek with extract
8676 vos_pkt_peek_data( vosDataBuff, ucQCOffset,(v_PVOID_t)&pucQosCtrl,
8677 sizeof(*pucQosCtrl));
8678 *pucQosCtrl = ucTid; //? proper byte order
8679 }
8680#endif
8681
8682 if ( VOS_STATUS_SUCCESS != vosStatus )
8683 {
8684 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8685 "WLAN TL:Failed while attempting to fill BD %d", vosStatus));
8686 *pvosDataBuff = NULL;
8687 return vosStatus;
8688 }
8689
8690 vos_pkt_set_user_data_ptr( vosDataBuff, VOS_PKT_USER_DATA_ID_TL,
8691 (v_PVOID_t)pStaClient->pfnSTATxComp );
8692
8693 *pvosDataBuff = vosDataBuff;
8694
8695 /*BE & BK can be delayed, VO and VI not frames cannot be delayed*/
8696 if ( pStaClient->ucServicedAC > WLANTL_AC_BE )
8697 {
8698 pTLCb->bUrgent= TRUE;
8699 }
8700
8701 return VOS_STATUS_SUCCESS;
8702}/* WLANTL_STATxAuth */
8703
8704/*==========================================================================
8705 FUNCTION WLANTL_STATxDisc
8706
8707 DESCRIPTION
8708 Transmit in disconnected state - no data allowed
8709
8710 DEPENDENCIES
8711 The STA must be registered with TL before this function can be called.
8712
8713 PARAMETERS
8714
8715 IN
8716 pvosGCtx: pointer to the global vos context; a handle to TL's
8717 control block can be extracted from its context
8718 ucSTAId: identifier of the station being processed
8719 vosDataBuff: pointer to the tx vos buffer
8720
8721 RETURN VALUE
8722 The result code associated with performing the operation
8723
8724 VOS_STATUS_SUCCESS: Everything is good :)
8725
8726 SIDE EFFECTS
8727
8728============================================================================*/
8729VOS_STATUS
8730WLANTL_STATxDisc
8731(
8732 v_PVOID_t pvosGCtx,
8733 v_U8_t ucSTAId,
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07008734 vos_pkt_t** pvosDataBuff,
8735 v_BOOL_t bForwardIAPPwithLLC
Jeff Johnson295189b2012-06-20 16:38:30 -07008736)
8737{
8738 WLANTL_CbType* pTLCb = NULL;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308739 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07008740 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
8741
Jeff Johnson295189b2012-06-20 16:38:30 -07008742 /*------------------------------------------------------------------------
8743 Sanity check
8744 Extract TL control block
8745 ------------------------------------------------------------------------*/
8746 pTLCb = VOS_GET_TL_CB(pvosGCtx);
8747 if ( NULL == pTLCb )
8748 {
8749 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8750 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_STATxAuth"));
8751 *pvosDataBuff = NULL;
8752 return VOS_STATUS_E_FAULT;
8753 }
8754
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308755 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
8756
8757 if ( NULL == pClientSTA )
8758 {
8759 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8760 "WLAN TL:Client Memory was not allocated on %s", __func__));
8761 return VOS_STATUS_E_FAILURE;
8762 }
8763
Jeff Johnson295189b2012-06-20 16:38:30 -07008764 /*------------------------------------------------------------------------
8765 Error
8766 ------------------------------------------------------------------------*/
8767 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
8768 "WLAN TL:Packet should not be transmitted in state disconnected ignoring"
8769 " request"));
8770
8771 *pvosDataBuff = NULL;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308772 pClientSTA->ucNoMoreData = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07008773
8774 //Should not be anything pending in disconnect state
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308775 vos_atomic_set_U8( &pClientSTA->ucPktPending, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07008776
8777 return VOS_STATUS_SUCCESS;
8778}/* WLANTL_STATxDisc */
8779
8780/*==========================================================================
8781 FUNCTION WLANTL_STARxConn
8782
8783 DESCRIPTION
8784 Receive in connected state - only EAPOL
8785
8786 DEPENDENCIES
8787 The STA must be registered with TL before this function can be called.
8788
8789 PARAMETERS
8790
8791 IN
8792 pvosGCtx: pointer to the global vos context; a handle to TL's
8793 control block can be extracted from its context
8794 ucSTAId: identifier of the station being processed
8795 vosDataBuff: pointer to the tx/rx vos buffer
8796
8797 RETURN VALUE
8798 The result code associated with performing the operation
8799
8800 VOS_STATUS_E_INVAL: invalid input parameters
8801 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
8802 page fault
8803 VOS_STATUS_SUCCESS: Everything is good :)
8804
8805 SIDE EFFECTS
8806
8807============================================================================*/
8808VOS_STATUS
8809WLANTL_STARxConn
8810(
8811 v_PVOID_t pvosGCtx,
8812 v_U8_t ucSTAId,
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07008813 vos_pkt_t** pvosDataBuff,
8814 v_BOOL_t bForwardIAPPwithLLC
Jeff Johnson295189b2012-06-20 16:38:30 -07008815)
8816{
8817 WLANTL_CbType* pTLCb = NULL;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308818 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07008819 v_U16_t usEtherType = 0;
8820 v_U16_t usPktLen;
8821 v_U8_t ucMPDUHOffset;
8822 v_U16_t usMPDUDOffset;
8823 v_U16_t usMPDULen;
8824 v_U8_t ucMPDUHLen;
8825 v_U16_t usActualHLen = 0;
8826 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
8827 vos_pkt_t* vosDataBuff;
8828 v_PVOID_t aucBDHeader;
8829 v_U8_t ucTid;
8830 WLANTL_RxMetaInfoType wRxMetaInfo;
8831 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
8832
8833 /*------------------------------------------------------------------------
8834 Sanity check
8835 ------------------------------------------------------------------------*/
8836 if (( NULL == pvosDataBuff ) || ( NULL == ( vosDataBuff = *pvosDataBuff )))
8837 {
8838 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8839 "WLAN TL:Invalid parameter sent on WLANTL_STARxConn"));
8840 return VOS_STATUS_E_INVAL;
8841 }
8842
8843 /*------------------------------------------------------------------------
8844 Extract TL control block
8845 ------------------------------------------------------------------------*/
8846 pTLCb = VOS_GET_TL_CB(pvosGCtx);
8847 if ( NULL == pTLCb )
8848 {
8849 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8850 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_ChangeSTAState"));
8851 return VOS_STATUS_E_FAULT;
8852 }
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308853 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
8854
8855 if ( NULL == pClientSTA )
8856 {
8857 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8858 "WLAN TL:Client Memory was not allocated on %s", __func__));
8859 return VOS_STATUS_E_FAILURE;
8860 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008861
8862 /*------------------------------------------------------------------------
8863 Extract BD header and check if valid
8864 ------------------------------------------------------------------------*/
8865 vosStatus = WDA_DS_PeekRxPacketInfo( vosDataBuff, (v_PVOID_t)&aucBDHeader, 0/*Swap BD*/ );
8866
8867 if ( NULL == aucBDHeader )
8868 {
8869 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8870 "WLAN TL:Cannot extract BD header"));
8871 VOS_ASSERT( 0 );
8872 return VOS_STATUS_E_FAULT;
8873 }
8874
8875
8876 ucMPDUHOffset = (v_U8_t)WDA_GET_RX_MPDU_HEADER_OFFSET(aucBDHeader);
8877 usMPDUDOffset = (v_U16_t)WDA_GET_RX_MPDU_DATA_OFFSET(aucBDHeader);
8878 usMPDULen = (v_U16_t)WDA_GET_RX_MPDU_LEN(aucBDHeader);
8879 ucMPDUHLen = (v_U8_t)WDA_GET_RX_MPDU_HEADER_LEN(aucBDHeader);
8880 ucTid = (v_U8_t)WDA_GET_RX_TID(aucBDHeader);
8881
8882 vos_pkt_get_packet_length( vosDataBuff, &usPktLen);
8883
8884 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
8885 "WLAN TL:BD header processing data: HO %d DO %d Len %d HLen %d",
8886 ucMPDUHOffset, usMPDUDOffset, usMPDULen, ucMPDUHLen));
8887
8888 /*It will cut out the 802.11 header if not used*/
8889 if ( VOS_STATUS_SUCCESS != WDA_DS_TrimRxPacketInfo( vosDataBuff ) )
8890 {
8891 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
8892 "WLAN TL:BD header corrupted - dropping packet"));
8893 /* Drop packet */
8894 vos_pkt_return_packet(vosDataBuff);
8895 return VOS_STATUS_SUCCESS;
8896 }
8897
8898 vosStatus = WLANTL_GetEtherType(aucBDHeader,vosDataBuff,ucMPDUHLen,&usEtherType);
8899
8900 if( VOS_IS_STATUS_SUCCESS(vosStatus) )
8901 {
8902#ifdef FEATURE_WLAN_WAPI
8903 /* If frame is neither an EAPOL frame nor a WAI frame then we drop the frame*/
8904 /* TODO: Do we need a check to see if we are in WAPI mode? If not is it possible */
8905 /* that we get an EAPOL packet in WAPI mode or vice versa? */
8906 if ( WLANTL_LLC_8021X_TYPE != usEtherType && WLANTL_LLC_WAI_TYPE != usEtherType )
8907 {
Sunil Ravid5406f22013-01-22 00:18:31 -08008908 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07008909 "WLAN TL:RX Frame not EAPOL or WAI EtherType %d - dropping", usEtherType );
Jeff Johnson295189b2012-06-20 16:38:30 -07008910 /* Drop packet */
8911 vos_pkt_return_packet(vosDataBuff);
8912 }
8913#else
8914 if ( WLANTL_LLC_8021X_TYPE != usEtherType )
8915 {
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07008916 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8917 "WLAN TL:RX Frame not EAPOL EtherType %d - dropping", usEtherType);
Jeff Johnson295189b2012-06-20 16:38:30 -07008918 /* Drop packet */
8919 vos_pkt_return_packet(vosDataBuff);
8920 }
8921#endif /* FEATURE_WLAN_WAPI */
8922 else /* Frame is an EAPOL frame or a WAI frame*/
8923 {
Katya Nigam42e16e82014-02-04 16:28:55 +05308924 MTRACE(vos_trace(VOS_MODULE_ID_TL,
8925 TRACE_CODE_TL_RX_CONN_EAPOL, ucSTAId, usEtherType ));
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07008926
Madan Mohan Koyyalamudid8000342012-11-08 14:55:26 -08008927 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07008928 "WLAN TL:RX Frame EAPOL EtherType %d - processing", usEtherType);
8929
Jeff Johnson295189b2012-06-20 16:38:30 -07008930 if (( 0 == WDA_GET_RX_FT_DONE(aucBDHeader) ) &&
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308931 ( 0 != pClientSTA->wSTADesc.ucSwFrameRXXlation))
Jeff Johnson295189b2012-06-20 16:38:30 -07008932 {
8933 if (usMPDUDOffset > ucMPDUHOffset)
8934 {
8935 usActualHLen = usMPDUDOffset - ucMPDUHOffset;
8936 }
8937
8938 vosStatus = WLANTL_Translate80211To8023Header( vosDataBuff, &vosStatus, usActualHLen,
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07008939 ucMPDUHLen, pTLCb, ucSTAId, bForwardIAPPwithLLC);
Jeff Johnson295189b2012-06-20 16:38:30 -07008940
8941 if ( VOS_STATUS_SUCCESS != vosStatus )
8942 {
Kaushik, Sushante386ee12014-05-01 15:50:52 +05308943 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
Jeff Johnson295189b2012-06-20 16:38:30 -07008944 "WLAN TL:Failed to translate from 802.11 to 802.3 - dropping"));
8945 /* Drop packet */
8946 vos_pkt_return_packet(vosDataBuff);
8947 return vosStatus;
8948 }
8949 }
8950 /*-------------------------------------------------------------------
8951 Increment receive counter
8952 -------------------------------------------------------------------*/
Madan Mohan Koyyalamudic0e5bd82012-09-18 17:12:27 -07008953 if ( !WLANTL_TID_INVALID( ucTid) )
8954 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308955 pClientSTA->auRxCount[ucTid]++;
Madan Mohan Koyyalamudic0e5bd82012-09-18 17:12:27 -07008956 }
8957 else
8958 {
8959 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8960 "WLAN TL:Invalid tid %d (Station ID %d) on %s",
8961 ucTid, ucSTAId, __func__));
Hanumantha Reddy Pothula0de10802016-02-11 17:29:27 +05308962 vos_pkt_return_packet(vosDataBuff);
8963 return VOS_STATUS_E_FAILURE;
Madan Mohan Koyyalamudic0e5bd82012-09-18 17:12:27 -07008964 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008965
8966 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
8967 "WLAN TL:Sending EAPoL frame to station %d AC %d", ucSTAId, ucTid));
8968
8969 /*-------------------------------------------------------------------
8970 !!!Assuming TID = UP mapping
8971 -------------------------------------------------------------------*/
8972 wRxMetaInfo.ucUP = ucTid;
8973
Jeff Johnson295189b2012-06-20 16:38:30 -07008974 TLLOG4(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_LOW,
Arif Hussainf2b00992013-11-17 21:46:15 -08008975 "WLAN TL %s:Sending data chain to station", __func__));
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308976 if ( WLAN_STA_SOFTAP == pClientSTA->wSTADesc.wSTAType )
Jeff Johnson295189b2012-06-20 16:38:30 -07008977 {
8978 wRxMetaInfo.ucDesSTAId = WLAN_RX_SAP_SELF_STA_ID;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308979 pClientSTA->pfnSTARx( pvosGCtx, vosDataBuff, ucSTAId,
Jeff Johnson295189b2012-06-20 16:38:30 -07008980 &wRxMetaInfo );
8981 }
8982 else
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308983 pClientSTA->pfnSTARx( pvosGCtx, vosDataBuff, ucSTAId,
Jeff Johnson295189b2012-06-20 16:38:30 -07008984 &wRxMetaInfo );
8985 }/*EAPOL frame or WAI frame*/
8986 }/*vos status success*/
8987
8988 return VOS_STATUS_SUCCESS;
8989}/* WLANTL_STARxConn */
8990
Jeff Johnson295189b2012-06-20 16:38:30 -07008991/*==========================================================================
8992 FUNCTION WLANTL_FwdPktToHDD
8993
8994 DESCRIPTION
8995 Determine the Destation Station ID and route the Frame to Upper Layer
8996
8997 DEPENDENCIES
8998
8999 PARAMETERS
9000
9001 IN
9002 pvosGCtx: pointer to the global vos context; a handle to TL's
9003 control block can be extracted from its context
9004 ucSTAId: identifier of the station being processed
9005 vosDataBuff: pointer to the rx vos buffer
9006
9007 RETURN VALUE
9008 The result code associated with performing the operation
9009
9010 VOS_STATUS_E_INVAL: invalid input parameters
9011 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
9012 page fault
9013 VOS_STATUS_SUCCESS: Everything is good :)
9014
9015 SIDE EFFECTS
9016
9017============================================================================*/
9018
9019VOS_STATUS
9020WLANTL_FwdPktToHDD
9021(
9022 v_PVOID_t pvosGCtx,
9023 vos_pkt_t* pvosDataBuff,
9024 v_U8_t ucSTAId
9025)
9026{
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309027 v_MACADDR_t DestMacAddress;
9028 v_MACADDR_t *pDestMacAddress = &DestMacAddress;
9029 v_SIZE_t usMacAddSize = VOS_MAC_ADDR_SIZE;
Jeff Johnson295189b2012-06-20 16:38:30 -07009030 WLANTL_CbType* pTLCb = NULL;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309031 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07009032 vos_pkt_t* vosDataBuff ;
9033 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
Girish Gowli93e3edd2014-05-01 15:42:31 +05309034 v_U32_t* STAMetaInfoPtr;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309035 vos_pkt_t* vosNextDataBuff ;
9036 v_U8_t ucDesSTAId;
Jeff Johnson295189b2012-06-20 16:38:30 -07009037 WLANTL_RxMetaInfoType wRxMetaInfo;
9038
Jeff Johnson295189b2012-06-20 16:38:30 -07009039 /*------------------------------------------------------------------------
9040 Sanity check
9041 ------------------------------------------------------------------------*/
9042 if (( NULL == pvosDataBuff ) || ( NULL == ( vosDataBuff = pvosDataBuff )))
9043 {
9044 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9045 "WLAN TL:Invalid parameter sent on WLANTL_FwdPktToHdd"));
9046 return VOS_STATUS_E_INVAL;
9047 }
9048
9049 /*------------------------------------------------------------------------
9050 Extract TL control block
9051 ------------------------------------------------------------------------*/
9052 pTLCb = VOS_GET_TL_CB(pvosGCtx);
9053 if ( NULL == pTLCb )
9054 {
9055 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9056 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_FwdPktToHdd"));
9057 return VOS_STATUS_E_FAULT;
9058 }
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309059
Tushnim Bhattacharyya5dd94562013-03-20 20:15:03 -07009060 if(WLANTL_STA_ID_INVALID(ucSTAId))
9061 {
9062 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,"ucSTAId %d is not valid",
9063 ucSTAId));
9064 return VOS_STATUS_E_INVAL;
9065 }
9066
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309067 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
9068
9069 if ( NULL == pClientSTA )
9070 {
9071 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9072 "WLAN TL:Client Memory was not allocated on %s", __func__));
9073 return VOS_STATUS_E_FAILURE;
9074 }
9075
Jeff Johnson295189b2012-06-20 16:38:30 -07009076 /* This the change required for SoftAp to handle Reordered Buffer. Since a STA
9077 may have packets destined to multiple destinations we have to process each packet
9078 at a time and determine its Destination. So the Voschain provided by Reorder code
9079 is unchain and forwarded to Upper Layer after Determining the Destination */
9080
9081 vosDataBuff = pvosDataBuff;
9082 while (vosDataBuff != NULL)
9083 {
9084 vos_pkt_walk_packet_chain( vosDataBuff, &vosNextDataBuff, 1/*true*/ );
9085 vos_pkt_get_user_data_ptr( vosDataBuff, VOS_PKT_USER_DATA_ID_TL,
Girish Gowli93e3edd2014-05-01 15:42:31 +05309086 (v_PVOID_t *)&STAMetaInfoPtr );
9087 wRxMetaInfo.ucUP = (v_U8_t)((uintptr_t)STAMetaInfoPtr & WLANTL_AC_MASK);
9088 ucDesSTAId = (v_U8_t)(((uintptr_t)STAMetaInfoPtr) >> WLANTL_STAID_OFFSET);
Jeff Johnson295189b2012-06-20 16:38:30 -07009089
9090 vosStatus = vos_pkt_extract_data( vosDataBuff, 0, (v_VOID_t *)pDestMacAddress, &usMacAddSize);
9091 if ( VOS_STATUS_SUCCESS != vosStatus )
9092 {
9093 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Arif Hussainf2b00992013-11-17 21:46:15 -08009094 "WLAN TL: recv corrupted data packet"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009095 vos_pkt_return_packet(vosDataBuff);
9096 return vosStatus;
9097 }
9098
Arif Hussaina7c8e412013-11-20 11:06:42 -08009099 TLLOG4(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_LOW,
9100 "station mac "MAC_ADDRESS_STR,
9101 MAC_ADDR_ARRAY(pDestMacAddress->bytes)));
Jeff Johnson295189b2012-06-20 16:38:30 -07009102
9103 if (vos_is_macaddr_broadcast( pDestMacAddress ) || vos_is_macaddr_group(pDestMacAddress))
9104 {
9105 // destination is mc/bc station
9106 ucDesSTAId = WLAN_RX_BCMC_STA_ID;
9107 TLLOG4(VOS_TRACE( VOS_MODULE_ID_HDD_SOFTAP, VOS_TRACE_LEVEL_INFO_LOW,
Arif Hussainf2b00992013-11-17 21:46:15 -08009108 "%s: BC/MC packet, id %d", __func__, WLAN_RX_BCMC_STA_ID));
Jeff Johnson295189b2012-06-20 16:38:30 -07009109 }
9110 else
9111 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309112 if (vos_is_macaddr_equal(pDestMacAddress, &pClientSTA->wSTADesc.vSelfMACAddress))
Jeff Johnson295189b2012-06-20 16:38:30 -07009113 {
9114 // destination is AP itself
9115 ucDesSTAId = WLAN_RX_SAP_SELF_STA_ID;
9116 TLLOG4(VOS_TRACE( VOS_MODULE_ID_HDD_SOFTAP, VOS_TRACE_LEVEL_INFO_LOW,
Arif Hussainf2b00992013-11-17 21:46:15 -08009117 "%s: packet to AP itself, id %d", __func__, WLAN_RX_SAP_SELF_STA_ID));
Jeff Johnson295189b2012-06-20 16:38:30 -07009118 }
Madan Mohan Koyylamudi64258222013-01-30 14:35:10 +05309119 else if (( WLAN_MAX_STA_COUNT <= ucDesSTAId ) || (NULL != pTLCb->atlSTAClients[ucDesSTAId] && pTLCb->atlSTAClients[ucDesSTAId]->ucExists == 0))
Jeff Johnson295189b2012-06-20 16:38:30 -07009120 {
9121 // destination station is something else
9122 TLLOG4(VOS_TRACE( VOS_MODULE_ID_HDD_SOFTAP, VOS_TRACE_LEVEL_INFO_LOW,
Arif Hussainf2b00992013-11-17 21:46:15 -08009123 "%s: get an station index larger than WLAN_MAX_STA_COUNT %d", __func__, ucDesSTAId));
Jeff Johnson295189b2012-06-20 16:38:30 -07009124 ucDesSTAId = WLAN_RX_SAP_SELF_STA_ID;
9125 }
9126
9127
9128 //loopback unicast station comes here
9129 }
9130
Girish Gowli93e3edd2014-05-01 15:42:31 +05309131 wRxMetaInfo.ucUP = (v_U8_t)((uintptr_t)STAMetaInfoPtr & WLANTL_AC_MASK);
Jeff Johnson295189b2012-06-20 16:38:30 -07009132 wRxMetaInfo.ucDesSTAId = ucDesSTAId;
9133
Madan Mohan Koyyalamudi6c2977d2013-09-04 15:42:45 +05309134 vosStatus = pClientSTA->pfnSTARx( pvosGCtx, vosDataBuff, ucDesSTAId,
Jeff Johnson295189b2012-06-20 16:38:30 -07009135 &wRxMetaInfo );
Madan Mohan Koyyalamudi6c2977d2013-09-04 15:42:45 +05309136 if ( VOS_STATUS_SUCCESS != vosStatus )
9137 {
9138 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Arif Hussainf2b00992013-11-17 21:46:15 -08009139 "WLAN TL: failed to send pkt to HDD"));
Madan Mohan Koyyalamudi6c2977d2013-09-04 15:42:45 +05309140 vos_pkt_return_packet(vosDataBuff);
9141
9142 return vosStatus;
9143 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009144 vosDataBuff = vosNextDataBuff;
9145 }
9146 return VOS_STATUS_SUCCESS;
9147}
Jeff Johnson295189b2012-06-20 16:38:30 -07009148
Kapil Guptad90b3862016-06-25 00:42:49 +05309149#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
9150void WLANTL_StopRxRateMonitor(v_PVOID_t pvosGCtx)
9151{
9152 WLANTL_CbType *pTLCb = VOS_GET_TL_CB(pvosGCtx);
9153 if (!pTLCb)
9154 return;
9155 pTLCb->gDsRxRoamStats.running = eWLAN_PAL_FALSE;
9156}
9157
9158void WLANTL_StartRxRateMonitor(v_PVOID_t pvosGCtx, v_U8_t staId,
9159 v_U16_t minRate,
9160 v_U16_t maxRate, v_U8_t minPercentage,
9161 v_U16_t minPktRequired, void *hHal,
9162 v_U64_t timeToWait,
9163 void (*triggerRoamScanfn) (void *, v_U8_t))
9164{
9165
9166 WLANTL_CbType *pTLCb = VOS_GET_TL_CB(pvosGCtx);
9167 if (!pTLCb)
9168 return;
9169
9170 pTLCb->gDsRxRoamStats.running = eWLAN_PAL_TRUE;
9171 pTLCb->gDsRxRoamStats.index = 0;
9172 pTLCb->gDsRxRoamStats.lastTriggerTime = jiffies_to_msecs(jiffies);
9173 pTLCb->gDsRxRoamStats.maxRate = maxRate;
9174 pTLCb->gDsRxRoamStats.minRate = minRate;
9175 pTLCb->gDsRxRoamStats.staId = staId;
9176 pTLCb->gDsRxRoamStats.minPercentage = minPercentage;
9177 pTLCb->gDsRxRoamStats.timeToWait = timeToWait * 1000;
9178 pTLCb->gDsRxRoamStats.intialPktToStart = 0;
9179 pTLCb->gDsRxRoamStats.minPktRequired = minPktRequired;
9180 pTLCb->gDsRxRoamStats.triggerRoamScanfn = triggerRoamScanfn;
9181 pTLCb->gDsRxRoamStats.hHal = hHal;
9182 vos_mem_zero(pTLCb->gDsRxRoamStats.rxRoamStats, ROAM_MAX_INDEX_NUM *
9183 sizeof(WLANTL_RoamTrafficStatsType));
9184 VOS_TRACE(VOS_MODULE_ID_WDI, VOS_TRACE_LEVEL_DEBUG,
9185 "staId=%d, minRate=%d maxRate=%d minPercentage=%d minPktRequired=%d",
9186 staId, minRate, maxRate, minPercentage, minPktRequired);
9187}
9188
9189void static WLANTL_ClearAllRoamStats(WLANTL_CbType *pTLCb)
9190{
9191 pTLCb->gDsRxRoamStats.index = 0;
9192 pTLCb->gDsRxRoamStats.totalPkt = 0;
9193 pTLCb->gDsRxRoamStats.lowRatePkt = 0;
9194 pTLCb->gDsRxRoamStats.intialPktToStart = 0;
9195 vos_mem_zero(pTLCb->gDsRxRoamStats.rxRoamStats, ROAM_MAX_INDEX_NUM *
9196 sizeof(WLANTL_RoamTrafficStatsType));
9197}
9198
9199/*
9200 * WLANTL_ClearRoamStatsTillIndex : This API will clear older data
9201 * at the indexes.
9202 *
9203 * Since its a circular buffer we don't know if we are filling
9204 * data first time or some older data was already present at
9205 * the index. In that case we should clear the older data from
9206 * current index to new index and subtract this data from
9207 * global count as well before filling new one.
9208 */
9209static inline void WLANTL_ClearRoamStatsTillIndex(WLANTL_CbType *pTLCb,
9210 v_U8_t newIndex)
9211{
9212 while (pTLCb->gDsRxRoamStats.index < newIndex)
9213 {
9214 pTLCb->gDsRxRoamStats.index++;
9215 pTLCb->gDsRxRoamStats.totalPkt -=
9216 pTLCb->gDsRxRoamStats.
9217 rxRoamStats[pTLCb->gDsRxRoamStats.index].totalPktRcvd;
9218 pTLCb->gDsRxRoamStats.lowRatePkt -=
9219 pTLCb->gDsRxRoamStats.
9220 rxRoamStats[pTLCb->gDsRxRoamStats.index].lowRateRxPacketsRcvd;
9221 pTLCb->gDsRxRoamStats.
9222 rxRoamStats[pTLCb->gDsRxRoamStats.index].totalPktRcvd = 0;
9223 pTLCb->gDsRxRoamStats.
9224 rxRoamStats[pTLCb->gDsRxRoamStats.index].lowRateRxPacketsRcvd = 0;
9225 }
9226}
9227
9228
9229static void WLANTL_ClearOldPERStats(WLANTL_CbType *pTLCb, v_U8_t incrementCnt)
9230{
9231 v_U8_t newIndex;
9232
9233 newIndex = (pTLCb->gDsRxRoamStats.index + incrementCnt) %
9234 ROAM_MAX_INDEX_NUM;
9235
9236 /* We have crossed the max limit of buffer, clear the stats
9237 * till ROAM_MAX_INDEX_NUM and set index as 0 */
9238 if ((pTLCb->gDsRxRoamStats.index + incrementCnt) >=
9239 ROAM_MAX_INDEX_NUM)
9240 {
9241 WLANTL_ClearRoamStatsTillIndex(pTLCb, ROAM_MAX_INDEX_NUM - 1);
9242 pTLCb->gDsRxRoamStats.index = -1;
9243 }
9244 /* Clear the stats from current index till new index */
9245 WLANTL_ClearRoamStatsTillIndex(pTLCb, newIndex);
9246}
9247
9248/*
9249 * This API implements a circular buffer to store rate stats for a station to
9250 * trigger PER based roam scan.
9251 * API will start monitoring only if DUT gets continues packets which are below
9252 * configured rate. In the upper rates, this should have minimal effect on data
9253 * throughput.
9254 *
9255 * This API will store stats in a circular buffer of size ROAM_MAX_INDEX_NUM
9256 * where each index will have time duration of ROAM_PER_INDEX_TIME.
9257 * Using a buffer instead of counter will help to maintain stats of time
9258 * duration ROAM_PER_INDEX_TIME * ROAM_MAX_INDEX_NUM. Whenever host gets a new
9259 * packet, it will remove last ROAM_PER_INDEX_TIME duration of packets from
9260 * global entry and index entry and fill new data.
9261 *
9262 * Global stats of data also be maintained so that host need not to parse whole
9263 * buffer while checking the trigger condition
9264 * Each of the index will be having the packets stats at duration of
9265 * ROAM_PER_INDEX_TIME from the first packet which arrived in that.
9266 * Global index will be used to calculate new index position to fill once host
9267 * gets a packet.
9268 */
9269static void WLANTL_updatePERStats(WLANTL_CbType *pTLCb,
9270 v_U8_t rateIndex)
9271{
Sravan Kumar Kairamd634cc92016-08-26 16:36:09 +05309272 v_U8_t incrementCnt = 0;
Kapil Guptad90b3862016-06-25 00:42:49 +05309273 v_U64_t currentTime, timeDifference;
9274
9275 /*
9276 * Host will start monitoring Rx rates only if it gets
9277 * MIN_PKTS_TO_START_MONTIOR number of pkts continuously below min rate
9278 * This will make sure we never do this much processing in high
9279 * rates/throughput cases
9280 */
9281
9282 if(pTLCb->gDsRxRoamStats.intialPktToStart < MIN_PKTS_TO_START_MONTIOR)
9283 {
9284 if (gTLRateInfo[rateIndex].phyRate < pTLCb->gDsRxRoamStats.minRate)
9285 pTLCb->gDsRxRoamStats.intialPktToStart++;
9286 else
9287 pTLCb->gDsRxRoamStats.intialPktToStart = 0;
9288 return;
9289 }
9290
9291 currentTime = jiffies_to_msecs(jiffies);
9292 /*
9293 * scan was triggered in last timeToWait time duration
9294 * Wait for timeToWait before monitoring again.
9295 */
9296 if((currentTime - pTLCb->gDsRxRoamStats.lastTriggerTime) <
9297 pTLCb->gDsRxRoamStats.timeToWait)
9298 return;
9299
9300 /* paket above max rate, clear current stats and montior again */
9301 if (gTLRateInfo[rateIndex].phyRate >=
9302 pTLCb->gDsRxRoamStats.maxRate)
9303 {
9304 WLANTL_ClearAllRoamStats(pTLCb);
9305 /* Stop any PER based scan if going on */
9306 pTLCb->gDsRxRoamStats.
9307 triggerRoamScanfn(pTLCb->gDsRxRoamStats.hHal, 0);
9308 return;
9309 }
9310
9311 timeDifference = currentTime -
9312 pTLCb->gDsRxRoamStats.rxRoamStats[pTLCb->gDsRxRoamStats.index].time;
9313
9314 if (timeDifference)
Kapil Guptafe5d92a2016-07-12 18:05:24 +05309315 incrementCnt = do_div(timeDifference, ROAM_PER_INDEX_TIME);
Kapil Guptad90b3862016-06-25 00:42:49 +05309316
9317 /* More that ROAM_PER_INDEX_TIME has esclapsed,
9318 * fill data at new index */
9319 if (incrementCnt)
9320 {
9321 if (incrementCnt > ROAM_MAX_INDEX_NUM)
9322 {
9323 /*
9324 * Clear all stats, these are older than
9325 * ROAM_MAX_INDEX_NUM * ROAM_PER_INDEX_TIME (Max buffer time)
9326 */
9327 WLANTL_ClearAllRoamStats(pTLCb);
9328 pTLCb->gDsRxRoamStats.index = 0;
9329 }
9330 else
9331 WLANTL_ClearOldPERStats(pTLCb, incrementCnt);
9332
9333 pTLCb->gDsRxRoamStats.rxRoamStats
9334 [pTLCb->gDsRxRoamStats.index].time = currentTime;
9335 }
9336
9337 /* If pkt rate below minRate, increment low pkts counts */
9338 if (gTLRateInfo[rateIndex].phyRate <
9339 pTLCb->gDsRxRoamStats.minRate)
9340 {
9341 pTLCb->gDsRxRoamStats.
9342 rxRoamStats[pTLCb->gDsRxRoamStats.index].
9343 lowRateRxPacketsRcvd++;
9344 pTLCb->gDsRxRoamStats.lowRatePkt++;
9345 }
9346 /* Increment total pkts counts */
9347 pTLCb->gDsRxRoamStats.
9348 rxRoamStats[pTLCb->gDsRxRoamStats.index].totalPktRcvd++;
9349 pTLCb->gDsRxRoamStats.totalPkt++;
9350
9351 /* Check if we have reached threshold value to trigger a roam scan */
9352 if ((pTLCb->gDsRxRoamStats.totalPkt != 0) &&
9353 (pTLCb->gDsRxRoamStats.totalPkt >
9354 pTLCb->gDsRxRoamStats.minPktRequired)&&
Kapil Guptafe5d92a2016-07-12 18:05:24 +05309355 ((pTLCb->gDsRxRoamStats.lowRatePkt * 100) >
9356 (pTLCb->gDsRxRoamStats.totalPkt *
9357 pTLCb->gDsRxRoamStats.minPercentage)))
Kapil Guptad90b3862016-06-25 00:42:49 +05309358 {
9359 /* callback handler to trigger a roam scan */
9360 if (pTLCb->gDsRxRoamStats.triggerRoamScanfn)
9361 pTLCb->gDsRxRoamStats.
9362 triggerRoamScanfn(pTLCb->gDsRxRoamStats.hHal, 1);
9363
9364 VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_DEBUG,
9365 "PER Roam: triggerring roam scan totalPkt =%lu lowRatePkt %lu minPktRequired %u minPercentage %d",
9366 (long unsigned int) pTLCb->gDsRxRoamStats.totalPkt,
9367 (long unsigned int) pTLCb->gDsRxRoamStats.lowRatePkt,
9368 (unsigned int) pTLCb->gDsRxRoamStats.minPktRequired,
9369 pTLCb->gDsRxRoamStats.minPercentage);
9370
9371 WLANTL_ClearAllRoamStats(pTLCb);
9372 /* save current time as last trigger time */
9373 pTLCb->gDsRxRoamStats.lastTriggerTime = currentTime;
9374 }
9375}
9376#endif
9377
Jeff Johnson295189b2012-06-20 16:38:30 -07009378/*==========================================================================
9379 FUNCTION WLANTL_STARxAuth
9380
9381 DESCRIPTION
9382 Receive in authenticated state - all data allowed
9383
9384 DEPENDENCIES
9385 The STA must be registered with TL before this function can be called.
9386
9387 PARAMETERS
9388
9389 IN
9390 pvosGCtx: pointer to the global vos context; a handle to TL's
9391 control block can be extracted from its context
9392 ucSTAId: identifier of the station being processed
9393 vosDataBuff: pointer to the rx vos buffer
9394
9395 RETURN VALUE
9396 The result code associated with performing the operation
9397
9398 VOS_STATUS_E_INVAL: invalid input parameters
9399 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
9400 page fault
9401 VOS_STATUS_SUCCESS: Everything is good :)
9402
9403 SIDE EFFECTS
9404
9405============================================================================*/
9406VOS_STATUS
9407WLANTL_STARxAuth
9408(
9409 v_PVOID_t pvosGCtx,
9410 v_U8_t ucSTAId,
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009411 vos_pkt_t** pvosDataBuff,
9412 v_BOOL_t bForwardIAPPwithLLC
Jeff Johnson295189b2012-06-20 16:38:30 -07009413)
9414{
9415 WLANTL_CbType* pTLCb = NULL;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309416 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07009417 v_U8_t ucAsf; /* AMSDU sub frame */
9418 v_U16_t usMPDUDOffset;
9419 v_U8_t ucMPDUHOffset;
9420 v_U16_t usMPDULen;
9421 v_U8_t ucMPDUHLen;
9422 v_U16_t usActualHLen = 0;
9423 v_U8_t ucTid;
Kapil Guptad90b3862016-06-25 00:42:49 +05309424#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
9425 v_U8_t rxRate;
9426 v_U8_t type;
9427#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009428#ifdef FEATURE_WLAN_WAPI
Jeff Johnsone0343db2013-04-03 16:39:24 -07009429 v_U16_t usEtherType = 0;
Abhishek Singh3c47c6c2015-06-15 11:36:08 +05309430 tSirMacMgmtHdr *hdr;
Jeff Johnson295189b2012-06-20 16:38:30 -07009431#endif
9432 v_U16_t usPktLen;
9433 vos_pkt_t* vosDataBuff ;
9434 v_PVOID_t aucBDHeader;
9435 VOS_STATUS vosStatus;
9436 WLANTL_RxMetaInfoType wRxMetaInfo;
Madan Mohan Koyyalamudidfd6aa82012-10-18 20:18:43 -07009437 static v_U8_t ucPMPDUHLen;
Girish Gowli93e3edd2014-05-01 15:42:31 +05309438 v_U32_t* STAMetaInfoPtr;
Jeff Johnson295189b2012-06-20 16:38:30 -07009439 v_U8_t ucEsf=0; /* first subframe of AMSDU flag */
9440 v_U64_t ullcurrentReplayCounter=0; /*current replay counter*/
9441 v_U64_t ullpreviousReplayCounter=0; /*previous replay counter*/
9442 v_U16_t ucUnicastBroadcastType=0; /*It denotes whether received frame is UC or BC*/
Madan Mohan Koyyalamudi4fe30172012-10-18 20:13:40 -07009443 struct _BARFrmStruct *pBarFrame = NULL;
9444
Jeff Johnson295189b2012-06-20 16:38:30 -07009445 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
9446
9447 /*------------------------------------------------------------------------
9448 Sanity check
9449 ------------------------------------------------------------------------*/
9450 if (( NULL == pvosDataBuff ) || ( NULL == ( vosDataBuff = *pvosDataBuff )))
9451 {
9452 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9453 "WLAN TL:Invalid parameter sent on WLANTL_STARxAuth"));
9454 return VOS_STATUS_E_INVAL;
9455 }
9456
9457 /*------------------------------------------------------------------------
9458 Extract TL control block
9459 ------------------------------------------------------------------------*/
9460 pTLCb = VOS_GET_TL_CB(pvosGCtx);
9461 if ( NULL == pTLCb )
9462 {
9463 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9464 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_STARxAuth"));
9465 return VOS_STATUS_E_FAULT;
9466 }
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309467 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
9468
9469 if ( NULL == pClientSTA )
9470 {
9471 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9472 "WLAN TL:Client Memory was not allocated on %s", __func__));
9473 return VOS_STATUS_E_FAILURE;
9474 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009475
9476 /*------------------------------------------------------------------------
9477 Extract BD header and check if valid
9478 ------------------------------------------------------------------------*/
9479 WDA_DS_PeekRxPacketInfo( vosDataBuff, (v_PVOID_t)&aucBDHeader, 0 );
9480
9481 ucMPDUHOffset = (v_U8_t)WDA_GET_RX_MPDU_HEADER_OFFSET(aucBDHeader);
9482 usMPDUDOffset = (v_U16_t)WDA_GET_RX_MPDU_DATA_OFFSET(aucBDHeader);
9483 usMPDULen = (v_U16_t)WDA_GET_RX_MPDU_LEN(aucBDHeader);
9484 ucMPDUHLen = (v_U8_t)WDA_GET_RX_MPDU_HEADER_LEN(aucBDHeader);
9485 ucTid = (v_U8_t)WDA_GET_RX_TID(aucBDHeader);
Kapil Guptad90b3862016-06-25 00:42:49 +05309486#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
9487 rxRate = (v_U8_t)WDA_GET_RX_MAC_RATE_IDX(aucBDHeader);
9488 type = (v_U8_t)WDA_GET_RX_TYPE(aucBDHeader);
9489#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009490
Madan Mohan Koyyalamudi4fe30172012-10-18 20:13:40 -07009491 /* Fix for a hardware bug.
9492 * H/W does not update the tid field in BD header for BAR frames.
9493 * Fix is to read the tid field from MAC header of BAR frame */
9494 if( (WDA_GET_RX_TYPE(aucBDHeader) == SIR_MAC_CTRL_FRAME) &&
9495 (WDA_GET_RX_SUBTYPE(aucBDHeader) == SIR_MAC_CTRL_BAR))
9496 {
9497 pBarFrame = (struct _BARFrmStruct *)(WDA_GET_RX_MAC_HEADER(aucBDHeader));
9498 ucTid = pBarFrame->barControl.numTID;
9499 }
9500
Jeff Johnson295189b2012-06-20 16:38:30 -07009501 /*Host based replay check is needed for unicast data frames*/
9502 ucUnicastBroadcastType = (v_U16_t)WDA_IS_RX_BCAST(aucBDHeader);
Jeff Johnson295189b2012-06-20 16:38:30 -07009503 if(0 != ucMPDUHLen)
9504 {
9505 ucPMPDUHLen = ucMPDUHLen;
9506 }
9507
9508 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
9509 "WLAN TL:BD header processing data: HO %d DO %d Len %d HLen %d"
9510 " Tid %d BD %d",
9511 ucMPDUHOffset, usMPDUDOffset, usMPDULen, ucMPDUHLen, ucTid,
9512 WLANHAL_RX_BD_HEADER_SIZE));
9513
9514 vos_pkt_get_packet_length( vosDataBuff, &usPktLen);
9515
9516 if ( VOS_STATUS_SUCCESS != WDA_DS_TrimRxPacketInfo( vosDataBuff ) )
9517 {
9518 if((WDA_GET_RX_ASF(aucBDHeader) && !WDA_GET_RX_ESF(aucBDHeader)))
9519 {
9520 /* AMSDU case, ucMPDUHOffset = 0
9521 * it should be hancdled seperatly */
9522 if(( usMPDUDOffset > ucMPDUHOffset ) &&
9523 ( usMPDULen >= ucMPDUHLen ) && ( usPktLen >= usMPDULen ) &&
9524 ( !WLANTL_TID_INVALID(ucTid) ))
9525 {
9526 ucMPDUHOffset = usMPDUDOffset - WLANTL_MPDU_HEADER_LEN;
9527 }
9528 else
9529 {
9530 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
9531 "WLAN TL:BD header corrupted - dropping packet"));
9532 /* Drop packet */
9533 vos_pkt_return_packet(vosDataBuff);
9534 return VOS_STATUS_SUCCESS;
9535 }
9536 }
9537 else
9538 {
9539 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
9540 "WLAN TL:BD header corrupted - dropping packet"));
9541 /* Drop packet */
9542 vos_pkt_return_packet(vosDataBuff);
9543 return VOS_STATUS_SUCCESS;
9544 }
9545 }
9546
Abhishek Singh00b71972016-01-07 10:51:04 +05309547#ifdef WLAN_FEATURE_RMC
9548 if (pTLCb->multicastDuplicateDetectionEnabled &&
9549 (WLAN_STA_IBSS == pClientSTA->wSTADesc.wSTAType) &&
9550 WLANTL_IS_DATA_FRAME(WDA_GET_RX_TYPE_SUBTYPE(aucBDHeader)))
9551 {
9552 /*
9553 * Multicast duplicate detection is only for frames received in
9554 * IBSS mode.
9555 */
9556 if (VOS_TRUE == WLANTL_IsDuplicateMcastFrm(pClientSTA, vosDataBuff))
9557 {
9558 pTLCb->mcastDupCnt++;
9559 /* Duplicate multicast data packet, drop the packet */
9560 vos_pkt_return_packet(vosDataBuff);
9561 return VOS_STATUS_SUCCESS;
9562 }
9563 }
9564#endif /* WLAN_FEATURE_RMC */
9565
Jeff Johnson295189b2012-06-20 16:38:30 -07009566#ifdef FEATURE_WLAN_WAPI
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309567 if ( pClientSTA->wSTADesc.ucIsWapiSta )
Jeff Johnson295189b2012-06-20 16:38:30 -07009568 {
9569 vosStatus = WLANTL_GetEtherType(aucBDHeader, vosDataBuff, ucMPDUHLen, &usEtherType);
9570 if( VOS_IS_STATUS_SUCCESS(vosStatus) )
9571 {
9572 if ( WLANTL_LLC_WAI_TYPE == usEtherType )
Abhishek Singh3c47c6c2015-06-15 11:36:08 +05309573 {
9574 hdr = WDA_GET_RX_MAC_HEADER(aucBDHeader);
9575 if ( hdr->fc.wep )
Jeff Johnson295189b2012-06-20 16:38:30 -07009576 {
9577 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9578 "WLAN TL:WAI frame was received encrypted - dropping"));
9579 /* Drop packet */
9580 /*Temporary fix added to fix wapi rekey issue*/
Abhishek Singh3c47c6c2015-06-15 11:36:08 +05309581 vos_pkt_return_packet(vosDataBuff);
9582 return vosStatus; //returning success
Jeff Johnson295189b2012-06-20 16:38:30 -07009583 }
9584 }
9585 else
9586 {
9587 if ( WLANHAL_RX_IS_UNPROTECTED_WPI_FRAME(aucBDHeader) )
9588 {
9589 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9590 "WLAN TL:Non-WAI frame was received unencrypted - dropping"));
9591 /* Drop packet */
9592 vos_pkt_return_packet(vosDataBuff);
9593 return vosStatus; //returning success
9594 }
9595 }
9596 }
9597 else //could not extract EtherType - this should not happen
9598 {
9599 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009600 "WLAN TL:Could not extract EtherType"));
9601 //Packet is already freed
Jeff Johnson295189b2012-06-20 16:38:30 -07009602 return vosStatus; //returning failure
Jeff Johnson295189b2012-06-20 16:38:30 -07009603 }
9604 }
9605#endif /* FEATURE_WLAN_WAPI */
9606
9607 /*----------------------------------------------------------------------
9608 Increment receive counter
9609 !! not sure this is the best place to increase this - pkt might be
9610 dropped below or delayed in TL's queues
9611 - will leave it here for now
9612 ------------------------------------------------------------------------*/
Madan Mohan Koyyalamudic0e5bd82012-09-18 17:12:27 -07009613 if ( !WLANTL_TID_INVALID( ucTid) )
9614 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309615 pClientSTA->auRxCount[ucTid]++;
Madan Mohan Koyyalamudic0e5bd82012-09-18 17:12:27 -07009616 }
9617 else
9618 {
9619 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9620 "WLAN TL:Invalid tid %d (Station ID %d) on %s",
9621 ucTid, ucSTAId, __func__));
Hanumantha Reddy Pothula0de10802016-02-11 17:29:27 +05309622 vos_pkt_return_packet(vosDataBuff);
9623 return VOS_STATUS_E_FAILURE;
Madan Mohan Koyyalamudic0e5bd82012-09-18 17:12:27 -07009624 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009625
Kapil Guptad90b3862016-06-25 00:42:49 +05309626#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
9627 if (pTLCb->gDsRxRoamStats.running &&
9628 (ucSTAId == pTLCb->gDsRxRoamStats.staId) &&
9629 (rxRate < WLANTL_MAX_RATE_NUM) && (type == SIR_MAC_DATA_FRAME))
9630 {
9631 WLANTL_updatePERStats(pTLCb, rxRate);
9632 }
9633#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009634 /*------------------------------------------------------------------------
9635 Check if AMSDU and send for processing if so
9636 ------------------------------------------------------------------------*/
9637 ucAsf = (v_U8_t)WDA_GET_RX_ASF(aucBDHeader);
9638
9639 if ( 0 != ucAsf )
9640 {
9641 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
9642 "WLAN TL:Packet is AMSDU sub frame - sending for completion"));
9643 vosStatus = WLANTL_AMSDUProcess( pvosGCtx, &vosDataBuff, aucBDHeader, ucSTAId,
9644 ucMPDUHLen, usMPDULen );
9645 if(NULL == vosDataBuff)
9646 {
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009647 //Packet is already freed
Jeff Johnson295189b2012-06-20 16:38:30 -07009648 return VOS_STATUS_SUCCESS;
9649 }
9650 }
9651 /* After AMSDU header handled
9652 * AMSDU frame just same with normal frames */
9653 /*-------------------------------------------------------------------
9654 Translating header if necesary
9655 !! Fix me: rmv comments below
9656 ----------------------------------------------------------------------*/
9657 if (( 0 == WDA_GET_RX_FT_DONE(aucBDHeader) ) &&
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309658 ( 0 != pClientSTA->wSTADesc.ucSwFrameRXXlation) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07009659 ( WLANTL_IS_DATA_FRAME(WDA_GET_RX_TYPE_SUBTYPE(aucBDHeader)) ))
9660 {
9661 if(0 == ucMPDUHLen)
9662 {
9663 ucMPDUHLen = ucPMPDUHLen;
9664 }
9665 if (usMPDUDOffset > ucMPDUHOffset)
9666 {
9667 usActualHLen = usMPDUDOffset - ucMPDUHOffset;
9668 }
9669 vosStatus = WLANTL_Translate80211To8023Header( vosDataBuff, &vosStatus, usActualHLen,
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009670 ucMPDUHLen, pTLCb, ucSTAId, bForwardIAPPwithLLC);
Jeff Johnson295189b2012-06-20 16:38:30 -07009671
9672 if ( VOS_STATUS_SUCCESS != vosStatus )
9673 {
Kaushik, Sushante386ee12014-05-01 15:50:52 +05309674 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
Jeff Johnson295189b2012-06-20 16:38:30 -07009675 "WLAN TL:Failed to translate from 802.11 to 802.3 - dropping"));
9676 /* Drop packet */
9677 vos_pkt_return_packet(vosDataBuff);
9678 return vosStatus;
9679 }
9680 }
9681 /* Softap requires additional Info such as Destination STAID and Access
9682 Category. Voschain or Buffer returned by BA would be unchain and this
9683 Meta Data would help in routing the packets to appropriate Destination */
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309684 if( WLAN_STA_SOFTAP == pClientSTA->wSTADesc.wSTAType)
Jeff Johnson295189b2012-06-20 16:38:30 -07009685 {
Arun Kumar Khandavalli37cfc222014-01-09 22:32:40 +05309686 STAMetaInfoPtr = (v_U32_t *)(uintptr_t)(ucTid | (WDA_GET_RX_ADDR3_IDX(aucBDHeader) << WLANTL_STAID_OFFSET));
Jeff Johnson295189b2012-06-20 16:38:30 -07009687 vos_pkt_set_user_data_ptr( vosDataBuff, VOS_PKT_USER_DATA_ID_TL,
9688 (v_PVOID_t)STAMetaInfoPtr);
9689 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009690
9691 /*------------------------------------------------------------------------
9692 Check to see if re-ordering session is in place
9693 ------------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309694 if ( 0 != pClientSTA->atlBAReorderInfo[ucTid].ucExists )
Jeff Johnson295189b2012-06-20 16:38:30 -07009695 {
9696 WLANTL_MSDUReorder( pTLCb, &vosDataBuff, aucBDHeader, ucSTAId, ucTid );
9697 }
9698
Jeff Johnson295189b2012-06-20 16:38:30 -07009699if(0 == ucUnicastBroadcastType
9700#ifdef FEATURE_ON_CHIP_REORDERING
9701 && (WLANHAL_IsOnChipReorderingEnabledForTID(pvosGCtx, ucSTAId, ucTid) != TRUE)
9702#endif
9703)
9704{
9705 /* replay check code : check whether replay check is needed or not */
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309706 if(VOS_TRUE == pClientSTA->ucIsReplayCheckValid)
Jeff Johnson295189b2012-06-20 16:38:30 -07009707 {
9708 /* replay check is needed for the station */
9709
9710 /* check whether frame is AMSDU frame */
9711 if ( 0 != ucAsf )
9712 {
9713 /* Since virgo can't send AMSDU frames this leg of the code
9714 was not tested properly, it needs to be tested properly*/
9715 /* Frame is AMSDU frame. As per 802.11n only first
9716 subframe will have replay counter */
9717 ucEsf = WDA_GET_RX_ESF( aucBDHeader );
9718 if( 0 != ucEsf )
9719 {
9720 v_BOOL_t status;
9721 /* Getting 48-bit replay counter from the RX BD */
9722 ullcurrentReplayCounter = WDA_DS_GetReplayCounter(aucBDHeader);
9723
9724 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Arif Hussainf2b00992013-11-17 21:46:15 -08009725 "WLAN TL: AMSDU currentReplayCounter [0x%llX]",ullcurrentReplayCounter);
Jeff Johnson295189b2012-06-20 16:38:30 -07009726
9727 /* Getting 48-bit previous replay counter from TL control block */
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309728 ullpreviousReplayCounter = pClientSTA->ullReplayCounter[ucTid];
Jeff Johnson295189b2012-06-20 16:38:30 -07009729
9730 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Arif Hussainf2b00992013-11-17 21:46:15 -08009731 "WLAN TL: AMSDU previousReplayCounter [0x%llX]",ullpreviousReplayCounter);
Jeff Johnson295189b2012-06-20 16:38:30 -07009732
9733 /* It is first subframe of AMSDU thus it
9734 conatains replay counter perform the
9735 replay check for this first subframe*/
9736 status = WLANTL_IsReplayPacket( ullcurrentReplayCounter, ullpreviousReplayCounter);
9737 if(VOS_FALSE == status)
9738 {
9739 /* Not a replay paket, update previous replay counter in TL CB */
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309740 pClientSTA->ullReplayCounter[ucTid] = ullcurrentReplayCounter;
Jeff Johnson295189b2012-06-20 16:38:30 -07009741 }
9742 else
9743 {
9744 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Arif Hussainf2b00992013-11-17 21:46:15 -08009745 "WLAN TL: AMSDU Drop the replay packet with PN : [0x%llX]",ullcurrentReplayCounter);
Jeff Johnson295189b2012-06-20 16:38:30 -07009746
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309747 pClientSTA->ulTotalReplayPacketsDetected++;
Jeff Johnson295189b2012-06-20 16:38:30 -07009748 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Arif Hussainf2b00992013-11-17 21:46:15 -08009749 "WLAN TL: AMSDU total dropped replay packets on STA ID %X is [0x%X]",
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309750 ucSTAId, pClientSTA->ulTotalReplayPacketsDetected);
Jeff Johnson295189b2012-06-20 16:38:30 -07009751
9752 /* Drop the packet */
9753 vos_pkt_return_packet(vosDataBuff);
9754 return VOS_STATUS_SUCCESS;
9755 }
9756 }
9757 }
9758 else
9759 {
9760 v_BOOL_t status;
9761
9762 /* Getting 48-bit replay counter from the RX BD */
9763 ullcurrentReplayCounter = WDA_DS_GetReplayCounter(aucBDHeader);
9764
9765 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Arif Hussainf2b00992013-11-17 21:46:15 -08009766 "WLAN TL: Non-AMSDU currentReplayCounter [0x%llX]",ullcurrentReplayCounter);
Jeff Johnson295189b2012-06-20 16:38:30 -07009767
9768 /* Getting 48-bit previous replay counter from TL control block */
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309769 ullpreviousReplayCounter = pClientSTA->ullReplayCounter[ucTid];
Jeff Johnson295189b2012-06-20 16:38:30 -07009770
9771 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Arif Hussainf2b00992013-11-17 21:46:15 -08009772 "WLAN TL: Non-AMSDU previousReplayCounter [0x%llX]",ullpreviousReplayCounter);
Jeff Johnson295189b2012-06-20 16:38:30 -07009773
9774 /* It is not AMSDU frame so perform
9775 reaply check for each packet, as
9776 each packet contains valid replay counter*/
9777 status = WLANTL_IsReplayPacket( ullcurrentReplayCounter, ullpreviousReplayCounter);
9778 if(VOS_FALSE == status)
9779 {
9780 /* Not a replay paket, update previous replay counter in TL CB */
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309781 pClientSTA->ullReplayCounter[ucTid] = ullcurrentReplayCounter;
Jeff Johnson295189b2012-06-20 16:38:30 -07009782 }
9783 else
9784 {
9785 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Arif Hussainf2b00992013-11-17 21:46:15 -08009786 "WLAN TL: Non-AMSDU Drop the replay packet with PN : [0x%llX]",ullcurrentReplayCounter);
Jeff Johnson295189b2012-06-20 16:38:30 -07009787
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309788 pClientSTA->ulTotalReplayPacketsDetected++;
Jeff Johnson295189b2012-06-20 16:38:30 -07009789 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Arif Hussainf2b00992013-11-17 21:46:15 -08009790 "WLAN TL: Non-AMSDU total dropped replay packets on STA ID %X is [0x%X]",
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309791 ucSTAId, pClientSTA->ulTotalReplayPacketsDetected);
Jeff Johnson295189b2012-06-20 16:38:30 -07009792
9793 /* Repaly packet, drop the packet */
9794 vos_pkt_return_packet(vosDataBuff);
9795 return VOS_STATUS_SUCCESS;
9796 }
9797 }
9798 }
9799}
9800/*It is a broadast packet DPU has already done replay check for
9801 broadcast packets no need to do replay check of these packets*/
Jeff Johnson295189b2012-06-20 16:38:30 -07009802
9803 if ( NULL != vosDataBuff )
9804 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309805 if( WLAN_STA_SOFTAP == pClientSTA->wSTADesc.wSTAType)
Jeff Johnson295189b2012-06-20 16:38:30 -07009806 {
9807 WLANTL_FwdPktToHDD( pvosGCtx, vosDataBuff, ucSTAId );
9808 }
9809 else
Jeff Johnson295189b2012-06-20 16:38:30 -07009810 {
9811 wRxMetaInfo.ucUP = ucTid;
Shailender Karmuchi13c0d082013-03-26 14:41:39 -07009812 wRxMetaInfo.rssiAvg = pClientSTA->rssiAvg;
Gopichand Nakkala4a2fc1a2013-05-17 16:59:39 +05309813#ifdef FEATURE_WLAN_TDLS
9814 if (WLAN_STA_TDLS == pClientSTA->wSTADesc.wSTAType)
9815 {
9816 wRxMetaInfo.isStaTdls = TRUE;
9817 }
9818 else
9819 {
9820 wRxMetaInfo.isStaTdls = FALSE;
9821 }
9822#endif
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309823 pClientSTA->pfnSTARx( pvosGCtx, vosDataBuff, ucSTAId,
Jeff Johnson295189b2012-06-20 16:38:30 -07009824 &wRxMetaInfo );
9825 }
9826 }/* if not NULL */
9827
9828 return VOS_STATUS_SUCCESS;
9829}/* WLANTL_STARxAuth */
9830
9831
9832/*==========================================================================
9833 FUNCTION WLANTL_STARxDisc
9834
9835 DESCRIPTION
9836 Receive in disconnected state - no data allowed
9837
9838 DEPENDENCIES
9839 The STA must be registered with TL before this function can be called.
9840
9841 PARAMETERS
9842
9843 IN
9844 pvosGCtx: pointer to the global vos context; a handle to TL's
9845 control block can be extracted from its context
9846 ucSTAId: identifier of the station being processed
9847 vosDataBuff: pointer to the rx vos buffer
9848
9849 RETURN VALUE
9850 The result code associated with performing the operation
9851
9852 VOS_STATUS_SUCCESS: Everything is good :)
9853
9854 SIDE EFFECTS
9855
9856============================================================================*/
9857VOS_STATUS
9858WLANTL_STARxDisc
9859(
9860 v_PVOID_t pvosGCtx,
9861 v_U8_t ucSTAId,
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009862 vos_pkt_t** pvosDataBuff,
9863 v_BOOL_t bForwardIAPPwithLLC
Jeff Johnson295189b2012-06-20 16:38:30 -07009864)
9865{
9866 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
9867
9868 /*------------------------------------------------------------------------
9869 Sanity check
9870 ------------------------------------------------------------------------*/
9871 if (( NULL == pvosDataBuff ) || ( NULL == *pvosDataBuff ))
9872 {
9873 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9874 "WLAN TL:Invalid parameter sent on WLANTL_STARxDisc"));
9875 return VOS_STATUS_E_INVAL;
9876 }
9877
9878 /*------------------------------------------------------------------------
9879 Error - drop packet
9880 ------------------------------------------------------------------------*/
9881 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9882 "WLAN TL:Packet should not be received in state disconnected"
9883 " - dropping"));
9884 vos_pkt_return_packet(*pvosDataBuff);
9885 *pvosDataBuff = NULL;
9886
9887 return VOS_STATUS_SUCCESS;
9888}/* WLANTL_STARxDisc */
9889
9890/*==========================================================================
9891 Processing main loops for MAIN and TX threads
9892 ==========================================================================*/
9893
9894/*==========================================================================
9895 FUNCTION WLANTL_McProcessMsg
9896
9897 DESCRIPTION
9898 Called by VOSS when a message was serialized for TL through the
9899 main thread/task.
9900
9901 DEPENDENCIES
9902 The TL must be initialized before this function can be called.
9903
9904 PARAMETERS
9905
9906 IN
9907 pvosGCtx: pointer to the global vos context; a handle to TL's
9908 control block can be extracted from its context
9909 message: type and content of the message
9910
9911
9912 RETURN VALUE
9913 The result code associated with performing the operation
9914
9915 VOS_STATUS_E_INVAL: invalid input parameters
9916 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
9917 page fault
9918 VOS_STATUS_SUCCESS: Everything is good :)
9919
9920 SIDE EFFECTS
9921
9922============================================================================*/
9923VOS_STATUS
9924WLANTL_McProcessMsg
9925(
9926 v_PVOID_t pvosGCtx,
9927 vos_msg_t* message
9928)
9929{
9930 WLANTL_CbType* pTLCb = NULL;
9931 tAddBAInd* ptAddBaInd = NULL;
9932 tDelBAInd* ptDelBaInd = NULL;
9933 tAddBARsp* ptAddBaRsp = NULL;
9934 vos_msg_t vosMessage;
9935 VOS_STATUS vosStatus;
9936 tpFlushACRsp FlushACRspPtr;
9937 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
9938
9939 /*------------------------------------------------------------------------
9940 Sanity check
9941 ------------------------------------------------------------------------*/
9942 if ( NULL == message )
9943 {
9944 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9945 "WLAN TL:Invalid parameter sent on WLANTL_ProcessMainMessage"));
9946 return VOS_STATUS_E_INVAL;
9947 }
9948
9949 /*------------------------------------------------------------------------
9950 Extract TL control block
9951 ------------------------------------------------------------------------*/
9952 pTLCb = VOS_GET_TL_CB(pvosGCtx);
9953 if ( NULL == pTLCb )
9954 {
9955 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9956 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_ProcessMainMessage"));
9957 return VOS_STATUS_E_FAULT;
9958 }
9959
9960 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
9961 "WLAN TL:Received message: %d through main flow", message->type));
9962
9963 switch( message->type )
9964 {
9965 case WDA_TL_FLUSH_AC_RSP:
9966 // Extract the message from the message body
9967 FlushACRspPtr = (tpFlushACRsp)(message->bodyptr);
9968 // Make sure the call back function is not null.
Tushnim Bhattacharyya5dd94562013-03-20 20:15:03 -07009969 if ( NULL == pTLCb->tlBAPClient.pfnFlushOpCompleteCb )
9970 {
9971 VOS_ASSERT(0);
9972 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9973 "WLAN TL:Invalid TL pointer pfnFlushOpCompleteCb"));
9974 return VOS_STATUS_E_FAULT;
9975 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009976
9977 TLLOG2(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
9978 "Received message: Flush complete received by TL"));
9979
9980 // Since we have the response back from HAL, just call the BAP client
9981 // registered call back from TL. There is only 1 possible
9982 // BAP client. So directly reference tlBAPClient
9983 pTLCb->tlBAPClient.pfnFlushOpCompleteCb( pvosGCtx,
9984 FlushACRspPtr->ucSTAId,
9985 FlushACRspPtr->ucTid, FlushACRspPtr->status );
9986
9987 // Free the PAL memory, we are done with it.
9988 TLLOG2(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
Jeff Johnsonddec6482017-09-19 08:33:57 -07009989 "Flush complete received by TL: Freeing %pK", FlushACRspPtr));
Jeff Johnson295189b2012-06-20 16:38:30 -07009990 vos_mem_free((v_VOID_t *)FlushACRspPtr);
9991 break;
9992
9993 case WDA_HDD_ADDBA_REQ:
9994 ptAddBaInd = (tAddBAInd*)(message->bodyptr);
9995 vosStatus = WLANTL_BaSessionAdd( pvosGCtx,
9996 ptAddBaInd->baSession.baSessionID,
9997 ptAddBaInd->baSession.STAID,
9998 ptAddBaInd->baSession.baTID,
9999 (v_U32_t)ptAddBaInd->baSession.baBufferSize,
10000 ptAddBaInd->baSession.winSize,
10001 ptAddBaInd->baSession.SSN);
10002 ptAddBaRsp = vos_mem_malloc(sizeof(*ptAddBaRsp));
10003
10004 if ( NULL == ptAddBaRsp )
10005 {
10006 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
10007 "WLAN TL: fatal failure, cannot allocate BA Rsp structure"));
10008 VOS_ASSERT(0);
10009 return VOS_STATUS_E_NOMEM;
10010 }
10011
10012 if ( VOS_STATUS_SUCCESS == vosStatus )
10013 {
10014 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
10015 "WLAN TL: Sending success indication to HAL for ADD BA"));
10016 /*Send success*/
10017 ptAddBaRsp->mesgType = WDA_HDD_ADDBA_RSP;
10018 vosMessage.type = WDA_HDD_ADDBA_RSP;
10019 }
10020 else
10021 {
10022 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
10023 "WLAN TL: Sending failure indication to HAL for ADD BA"));
10024
10025 /*Send failure*/
10026 ptAddBaRsp->mesgType = WDA_BA_FAIL_IND;
10027 vosMessage.type = WDA_BA_FAIL_IND;
10028 }
10029
10030 ptAddBaRsp->mesgLen = sizeof(tAddBARsp);
10031 ptAddBaRsp->baSessionID = ptAddBaInd->baSession.baSessionID;
10032 /* This is default, reply win size has to be handled BA module, FIX THIS */
10033 ptAddBaRsp->replyWinSize = WLANTL_MAX_WINSIZE;
10034 vosMessage.bodyptr = ptAddBaRsp;
10035
10036 vos_mq_post_message( VOS_MQ_ID_WDA, &vosMessage );
10037 WLANTL_McFreeMsg (pvosGCtx, message);
10038 break;
10039 case WDA_DELETEBA_IND:
10040 ptDelBaInd = (tDelBAInd*)(message->bodyptr);
10041 vosStatus = WLANTL_BaSessionDel(pvosGCtx,
10042 ptDelBaInd->staIdx,
10043 ptDelBaInd->baTID);
10044
10045 if ( VOS_STATUS_SUCCESS != vosStatus )
10046 {
10047 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
10048 "WLAN TL: Failed to del BA session STA:%d TID:%d Status :%d",
10049 ptDelBaInd->staIdx,
10050 ptDelBaInd->baTID,
10051 vosStatus));
10052 }
10053 WLANTL_McFreeMsg (pvosGCtx, message);
10054 break;
10055 default:
10056 /*no processing for now*/
10057 break;
10058 }
10059
10060 return VOS_STATUS_SUCCESS;
10061}/* WLANTL_ProcessMainMessage */
10062
10063/*==========================================================================
10064 FUNCTION WLANTL_McFreeMsg
10065
10066 DESCRIPTION
10067 Called by VOSS to free a given TL message on the Main thread when there
10068 are messages pending in the queue when the whole system is been reset.
10069 For now, TL does not allocate any body so this function shout translate
10070 into a NOOP
10071
10072 DEPENDENCIES
10073 The TL must be initialized before this function can be called.
10074
10075 PARAMETERS
10076
10077 IN
10078 pvosGCtx: pointer to the global vos context; a handle to TL's
10079 control block can be extracted from its context
10080 message: type and content of the message
10081
10082
10083 RETURN VALUE
10084 The result code associated with performing the operation
10085
10086 VOS_STATUS_SUCCESS: Everything is good :)
10087
10088 SIDE EFFECTS
10089
10090============================================================================*/
10091VOS_STATUS
10092WLANTL_McFreeMsg
10093(
10094 v_PVOID_t pvosGCtx,
10095 vos_msg_t* message
10096)
10097{
10098 WLANTL_CbType* pTLCb = NULL;
10099 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
10100
10101 /*------------------------------------------------------------------------
10102 Sanity check
10103 ------------------------------------------------------------------------*/
10104 if ( NULL == message )
10105 {
10106 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
10107 "WLAN TL:Invalid parameter sent on WLANTL_McFreeMsg"));
10108 return VOS_STATUS_E_INVAL;
10109 }
10110
10111 /*------------------------------------------------------------------------
10112 Extract TL control block
10113 ------------------------------------------------------------------------*/
10114 pTLCb = VOS_GET_TL_CB(pvosGCtx);
10115 if ( NULL == pTLCb )
10116 {
10117 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
10118 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_McFreeMsg"));
10119 return VOS_STATUS_E_FAULT;
10120 }
10121
10122 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
10123 "WLAN TL:Received message: %d through main free", message->type));
10124
10125 switch( message->type )
10126 {
10127 case WDA_HDD_ADDBA_REQ:
10128 case WDA_DELETEBA_IND:
10129 /*vos free body pointer*/
10130 vos_mem_free(message->bodyptr);
10131 message->bodyptr = NULL;
10132 break;
10133 default:
10134 /*no processing for now*/
10135 break;
10136 }
10137
10138 return VOS_STATUS_SUCCESS;
10139}/*WLANTL_McFreeMsg*/
10140
10141/*==========================================================================
10142 FUNCTION WLANTL_TxProcessMsg
10143
10144 DESCRIPTION
10145 Called by VOSS when a message was serialized for TL through the
10146 tx thread/task.
10147
10148 DEPENDENCIES
10149 The TL must be initialized before this function can be called.
10150
10151 PARAMETERS
10152
10153 IN
10154 pvosGCtx: pointer to the global vos context; a handle to TL's
10155 control block can be extracted from its context
10156 message: type and content of the message
10157
10158
10159 RETURN VALUE
10160 The result code associated with performing the operation
10161
10162 VOS_STATUS_E_INVAL: invalid input parameters
10163 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
10164 page fault
10165 VOS_STATUS_SUCCESS: Everything is good :)
10166
10167 Other values can be returned as a result of a function call, please check
10168 corresponding API for more info.
10169 SIDE EFFECTS
10170
10171============================================================================*/
10172VOS_STATUS
10173WLANTL_TxProcessMsg
10174(
10175 v_PVOID_t pvosGCtx,
10176 vos_msg_t* message
10177)
10178{
10179 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070010180 void (*callbackRoutine) (void *callbackContext);
10181 void *callbackContext;
Jeff Johnson295189b2012-06-20 16:38:30 -070010182 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
10183
10184 /*------------------------------------------------------------------------
10185 Sanity check
10186 ------------------------------------------------------------------------*/
10187 if ( NULL == message )
10188 {
10189 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
10190 "WLAN TL:Invalid parameter sent on WLANTL_ProcessTxMessage"));
10191 return VOS_STATUS_E_INVAL;
10192 }
10193
10194 /*------------------------------------------------------------------------
10195 Process message
10196 ------------------------------------------------------------------------*/
10197 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
10198 "WLAN TL:Received message: %d through tx flow", message->type));
10199
10200 switch( message->type )
10201 {
10202 case WLANTL_TX_SIG_SUSPEND:
10203 vosStatus = WLANTL_SuspendCB( pvosGCtx,
10204 (WLANTL_SuspendCBType)message->bodyptr,
10205 message->reserved);
10206 break;
10207 case WLANTL_TX_RES_NEEDED:
10208 vosStatus = WLANTL_GetTxResourcesCB( pvosGCtx );
10209 break;
Katya Nigam664f5032014-05-05 12:24:32 +053010210
Jeff Johnson295189b2012-06-20 16:38:30 -070010211 case WDA_DS_TX_START_XMIT:
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +053010212 WLANTL_ClearTxXmitPending(pvosGCtx);
10213 vosStatus = WDA_DS_TxFrames( pvosGCtx );
Jeff Johnson295189b2012-06-20 16:38:30 -070010214 break;
10215
10216 case WDA_DS_FINISH_ULA:
Arun Kumar Khandavalli8d1979d2014-01-09 21:12:25 +053010217 callbackContext = message->bodyptr;
10218 callbackRoutine = message->callback;
10219 if ( NULL != callbackRoutine )
10220 {
10221 callbackRoutine(callbackContext);
10222 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010223 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010224
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +053010225 case WLANTL_TX_SNAPSHOT:
10226 /*Dumping TL State and then continuing to print
10227 the DXE Dump*/
10228 WLANTL_TxThreadDebugHandler(pvosGCtx);
10229 WDA_TransportChannelDebug(NULL, VOS_TRUE, VOS_FALSE);
10230 break;
10231
Mihir Shetefd62d9d2014-08-06 15:08:21 +053010232 case WLANTL_TX_FATAL_ERROR:
10233 WLANTL_FatalErrorHandler(pvosGCtx);
10234 break;
10235
Mihir Shete327c2ab2014-11-13 15:17:02 +053010236 case WLANTL_TX_FW_DEBUG:
Siddharth Bhal68115602015-01-18 20:44:55 +053010237 vos_fwDumpReq(274, 0, 0, 0, 0, 1); //Async event
Mihir Shete327c2ab2014-11-13 15:17:02 +053010238 break;
10239
Sravan Kumar Kairame9d186c2015-11-27 23:37:02 +053010240 case WLANTL_TX_KICKDXE:
10241 WDA_TransportKickDxe();
10242 break;
10243
Jeff Johnson295189b2012-06-20 16:38:30 -070010244 default:
10245 /*no processing for now*/
10246 break;
10247 }
10248
10249 return vosStatus;
10250}/* WLANTL_TxProcessMsg */
10251
10252/*==========================================================================
10253 FUNCTION WLANTL_McFreeMsg
10254
10255 DESCRIPTION
10256 Called by VOSS to free a given TL message on the Main thread when there
10257 are messages pending in the queue when the whole system is been reset.
10258 For now, TL does not allocate any body so this function shout translate
10259 into a NOOP
10260
10261 DEPENDENCIES
10262 The TL must be initialized before this function can be called.
10263
10264 PARAMETERS
10265
10266 IN
10267 pvosGCtx: pointer to the global vos context; a handle to TL's
10268 control block can be extracted from its context
10269 message: type and content of the message
10270
10271
10272 RETURN VALUE
10273 The result code associated with performing the operation
10274
10275 VOS_STATUS_SUCCESS: Everything is good :)
10276
10277 SIDE EFFECTS
10278
10279============================================================================*/
10280VOS_STATUS
10281WLANTL_TxFreeMsg
10282(
10283 v_PVOID_t pvosGCtx,
10284 vos_msg_t* message
10285)
10286{
10287 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
10288
10289 /*Nothing to do for now!!!*/
10290 return VOS_STATUS_SUCCESS;
10291}/*WLANTL_TxFreeMsg*/
10292
Jeff Johnson295189b2012-06-20 16:38:30 -070010293/*==========================================================================
10294
10295 FUNCTION WLANTL_TxFCFrame
10296
10297 DESCRIPTION
10298 Internal utility function to send FC frame. Enable
10299 or disable LWM mode based on the information.
10300
10301 DEPENDENCIES
10302 TL must be initiailized before this function gets called.
10303 FW sends up special flow control frame.
10304
10305 PARAMETERS
10306
10307 IN
10308 pvosGCtx: pointer to the global vos context; a handle to TL's
10309 control block can be extracted from its context
10310
10311 RETURN VALUE
10312 The result code associated with performing the operation
10313
10314 VOS_STATUS_E_INVAL: Input pointers are NULL.
10315 VOS_STATUS_E_FAULT: Something is wrong.
10316 VOS_STATUS_SUCCESS: Everything is good.
10317
10318 SIDE EFFECTS
10319 Newly formed FC frame is generated and waits to be transmitted. Previously unsent frame will
10320 be released.
10321
10322============================================================================*/
10323VOS_STATUS
10324WLANTL_TxFCFrame
10325(
10326 v_PVOID_t pvosGCtx
10327)
10328{
10329#if 0
10330 WLANTL_CbType* pTLCb = NULL;
10331 VOS_STATUS vosStatus;
10332 tpHalFcTxBd pvFcTxBd = NULL;
10333 vos_pkt_t * pPacket = NULL;
10334 v_U8_t ucSTAId = 0;
10335 v_U8_t ucBitCheck = 1;
10336
10337 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070010338 "WLAN TL: Send FC frame %s", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070010339
10340 /*------------------------------------------------------------------------
10341 Sanity check
10342 ------------------------------------------------------------------------*/
10343 if ( NULL == pvosGCtx )
10344 {
10345 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070010346 "WLAN TL:Invalid parameter %s", __func__));
Jeff Johnson295189b2012-06-20 16:38:30 -070010347 return VOS_STATUS_E_INVAL;
10348 }
10349 /*------------------------------------------------------------------------
10350 Extract TL control block
10351 ------------------------------------------------------------------------*/
10352 pTLCb = VOS_GET_TL_CB(pvosGCtx);
10353
10354 if (NULL == pTLCb)
10355 {
10356 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070010357 "WLAN TL:Invalid pointer in %s \n", __func__));
Jeff Johnson295189b2012-06-20 16:38:30 -070010358 return VOS_STATUS_E_INVAL;
10359 }
10360
10361 //Get one voss packet
10362 vosStatus = vos_pkt_get_packet( &pPacket, VOS_PKT_TYPE_TX_802_11_MGMT, sizeof(tHalFcTxBd), 1,
10363 VOS_FALSE, NULL, NULL );
10364
10365 if ( VOS_STATUS_SUCCESS != vosStatus )
10366 {
10367 return VOS_STATUS_E_INVAL;
10368 }
10369
10370 vosStatus = vos_pkt_reserve_head( pPacket, (void *)&pvFcTxBd, sizeof(tHalFcTxBd));
10371
10372 if( VOS_STATUS_SUCCESS != vosStatus )
10373 {
10374 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070010375 "%s: failed to reserve FC TX BD %d\n",__func__, sizeof(tHalFcTxBd)));
Jeff Johnson295189b2012-06-20 16:38:30 -070010376 vos_pkt_return_packet( pPacket );
10377 return VOS_STATUS_E_FAULT;
10378 }
10379
10380 //Generate most recent tlFCInfo. Most fields are correct.
10381 pTLCb->tlFCInfo.fcSTAThreshEnabledMask = 0;
10382 pTLCb->tlFCInfo.fcSTATxMoreDataMask = 0;
10383 for( ucSTAId = 0, ucBitCheck = 1 ; ucSTAId < WLAN_MAX_STA_COUNT; ucBitCheck <<= 1, ucSTAId ++)
10384 {
10385 if (0 == pTLCb->atlSTAClients[ucSTAId].ucExists)
10386 {
10387 continue;
10388 }
10389
10390 if (pTLCb->atlSTAClients[ucSTAId].ucPktPending)
10391 {
10392 pTLCb->tlFCInfo.fcSTATxMoreDataMask |= ucBitCheck;
10393 }
10394
10395 if ( (pTLCb->atlSTAClients[ucSTAId].ucLwmModeEnabled) &&
10396 (pTLCb->atlSTAClients[ucSTAId].bmuMemConsumed > pTLCb->atlSTAClients[ucSTAId].uLwmThreshold))
10397 {
10398 pTLCb->tlFCInfo.fcSTAThreshEnabledMask |= ucBitCheck;
10399
10400 pTLCb->tlFCInfo.fcSTAThresh[ucSTAId] = (tANI_U8)pTLCb->atlSTAClients[ucSTAId].uLwmThreshold;
10401
10402 pTLCb->atlSTAClients[ucSTAId].ucLwmEventReported = FALSE;
10403 }
10404
10405 }
10406
10407 //request immediate feedback
10408 pTLCb->tlFCInfo.fcConfig |= 0x4;
10409
10410 //fill in BD to sent
10411 vosStatus = WLANHAL_FillFcTxBd(pvosGCtx, &pTLCb->tlFCInfo, (void *)pvFcTxBd);
10412
10413 if( VOS_STATUS_SUCCESS != vosStatus )
10414 {
10415 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070010416 "%s: Fill FC TX BD unsuccessful\n", __func__));
Jeff Johnson295189b2012-06-20 16:38:30 -070010417 vos_pkt_return_packet( pPacket );
10418 return VOS_STATUS_E_FAULT;
10419 }
10420
10421 if (NULL != pTLCb->vosTxFCBuf)
10422 {
10423 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070010424 "%s: Previous FC TX BD not sent\n", __func__));
Jeff Johnson295189b2012-06-20 16:38:30 -070010425 vos_pkt_return_packet(pTLCb->vosTxFCBuf);
10426 }
10427
10428 pTLCb->vosTxFCBuf = pPacket;
10429
10430 vos_pkt_set_user_data_ptr( pPacket, VOS_PKT_USER_DATA_ID_TL,
10431 (v_PVOID_t)WLANTL_TxCompDefaultCb);
10432 vosStatus = WDA_DS_StartXmit(pvosGCtx);
10433
10434 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070010435 "WLAN TL: send FC frame leave %s", __func__));
Jeff Johnson295189b2012-06-20 16:38:30 -070010436#endif
10437 return VOS_STATUS_SUCCESS;
10438}
10439
Jeff Johnson295189b2012-06-20 16:38:30 -070010440
10441/*==========================================================================
10442 FUNCTION WLANTL_GetTxResourcesCB
10443
10444 DESCRIPTION
10445 Processing function for Resource needed signal. A request will be issued
10446 to BAL to get more tx resources.
10447
10448 DEPENDENCIES
10449 The TL must be initialized before this function can be called.
10450
10451 PARAMETERS
10452
10453 IN
10454 pvosGCtx: pointer to the global vos context; a handle to TL's
10455 control block can be extracted from its context
10456
10457
10458 RETURN VALUE
10459 The result code associated with performing the operation
10460
10461 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
10462 page fault
10463 VOS_STATUS_SUCCESS: Everything is good :)
10464
10465 Other values can be returned as a result of a function call, please check
10466 corresponding API for more info.
10467 SIDE EFFECTS
10468
10469============================================================================*/
10470VOS_STATUS
10471WLANTL_GetTxResourcesCB
10472(
10473 v_PVOID_t pvosGCtx
10474)
10475{
10476 WLANTL_CbType* pTLCb = NULL;
10477 v_U32_t uResCount = WDA_TLI_MIN_RES_DATA;
10478 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
10479 v_U8_t ucMgmt = 0;
10480 v_U8_t ucBAP = 0;
10481 v_U8_t ucData = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070010482#ifdef WLAN_SOFTAP_FLOWCTRL_EN
10483 tBssSystemRole systemRole;
10484 tpAniSirGlobal pMac;
10485#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010486 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
10487 /*------------------------------------------------------------------------
10488 Extract TL control block
10489 ------------------------------------------------------------------------*/
10490 pTLCb = VOS_GET_TL_CB(pvosGCtx);
10491 if ( NULL == pTLCb )
10492 {
10493 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
10494 "WLAN TL:Invalid TL pointer from pvosGCtx on"
10495 " WLANTL_ProcessTxMessage"));
10496 return VOS_STATUS_E_FAULT;
10497 }
10498
10499 /*------------------------------------------------------------------------
10500 Get tx resources from BAL
10501 ------------------------------------------------------------------------*/
10502 vosStatus = WDA_DS_GetTxResources( pvosGCtx, &uResCount );
10503
10504 if ( (VOS_STATUS_SUCCESS != vosStatus) && (VOS_STATUS_E_RESOURCES != vosStatus))
10505 {
10506 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
10507 "WLAN TL:TL failed to get resources from BAL, Err: %d",
10508 vosStatus));
10509 return vosStatus;
10510 }
10511
10512 /* Currently only Linux BAL returns the E_RESOURCES error code when it is running
10513 out of BD/PDUs. To make use of this interrupt for throughput enhancement, similar
10514 changes should be done in BAL code of AMSS and WM */
10515 if (VOS_STATUS_E_RESOURCES == vosStatus)
10516 {
10517#ifdef VOLANS_PERF
10518 WLANHAL_EnableIdleBdPduInterrupt(pvosGCtx, (tANI_U8)bdPduInterruptGetThreshold);
10519 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
10520 "WLAN TL: Enabling Idle BD/PDU interrupt, Current resources = %d", uResCount);
10521#else
10522 return VOS_STATUS_E_FAILURE;
10523#endif
10524 }
10525
10526 pTLCb->uResCount = uResCount;
10527
10528
Jeff Johnson295189b2012-06-20 16:38:30 -070010529#ifdef WLAN_SOFTAP_FLOWCTRL_EN
10530 /* FIXME: disabled since creating issues in power-save, needs to be addressed */
10531 pTLCb->sendFCFrame ++;
10532 pMac = vos_get_context(VOS_MODULE_ID_WDA, pvosGCtx);
10533 systemRole = wdaGetGlobalSystemRole(pMac);
10534 if (eSYSTEM_AP_ROLE == systemRole)
10535 {
10536 if (pTLCb->sendFCFrame % 16 == 0)
10537 {
10538 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
10539 "Transmit FC"));
10540 WLANTL_TxFCFrame (pvosGCtx);
10541 }
10542 }
10543#endif //WLAN_SOFTAP_FLOWCTRL_EN
Jeff Johnson295189b2012-06-20 16:38:30 -070010544
10545 ucData = ( pTLCb->uResCount >= WDA_TLI_MIN_RES_DATA );
10546 ucBAP = ( pTLCb->uResCount >= WDA_TLI_MIN_RES_BAP ) &&
10547 ( NULL != pTLCb->tlBAPClient.vosPendingDataBuff );
10548 ucMgmt = ( pTLCb->uResCount >= WDA_TLI_MIN_RES_MF ) &&
10549 ( NULL != pTLCb->tlMgmtFrmClient.vosPendingDataBuff );
10550
10551 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
10552 "WLAN TL: Eval Resume tx Res: %d DATA: %d BAP: %d MGMT: %d",
10553 pTLCb->uResCount, ucData, ucBAP, ucMgmt));
10554
10555 if (( 0 == pTLCb->ucTxSuspended ) &&
10556 (( 0 != ucData ) || ( 0 != ucMgmt ) || ( 0 != ucBAP ) ) )
10557 {
10558 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
10559 "Issuing Xmit start request to BAL for avail res SYNC"));
10560 vosStatus =WDA_DS_StartXmit(pvosGCtx);
10561 }
10562 return vosStatus;
10563}/*WLANTL_GetTxResourcesCB*/
10564
10565/*==========================================================================
10566 Utility functions
10567 ==========================================================================*/
10568
10569/*==========================================================================
10570 FUNCTION WLANTL_Translate8023To80211Header
10571
10572 DESCRIPTION
10573 Inline function for translating and 802.11 header into an 802.3 header.
10574
10575 DEPENDENCIES
10576
10577
10578 PARAMETERS
10579
10580 IN
10581 pTLCb: TL control block
Kiran Venkatappaa044eb92012-12-17 15:48:49 -080010582 IN/OUT
10583 ucStaId: station ID. Incase of TDLS, this returns actual TDLS
10584 station ID used
Jeff Johnson295189b2012-06-20 16:38:30 -070010585
10586 IN/OUT
10587 vosDataBuff: vos data buffer, will contain the new header on output
10588
10589 OUT
10590 pvosStatus: status of the operation
10591
10592 RETURN VALUE
10593
10594 VOS_STATUS_SUCCESS: Everything is good :)
10595
10596 Other error codes might be returned from the vos api used in the function
10597 please check those return values.
10598
10599 SIDE EFFECTS
10600
10601============================================================================*/
Kiran Venkatappacab0d352012-12-17 13:09:22 -080010602VOS_STATUS
10603WLANTL_Translate8023To80211Header
10604(
10605 vos_pkt_t* vosDataBuff,
10606 VOS_STATUS* pvosStatus,
10607 WLANTL_CbType* pTLCb,
10608 v_U8_t *pucStaId,
Ravi Joshid0699502013-07-08 15:48:47 -070010609 WLANTL_MetaInfoType *tlMetaInfo,
Kiran Venkatappacab0d352012-12-17 13:09:22 -080010610 v_U8_t *ucWDSEnabled,
10611 v_U8_t *extraHeadSpace
10612)
Jeff Johnson295189b2012-06-20 16:38:30 -070010613{
10614 WLANTL_8023HeaderType w8023Header;
10615 WLANTL_80211HeaderType *pw80211Header; // Allocate an aligned BD and then fill it.
10616 VOS_STATUS vosStatus;
10617 v_U8_t MandatoryucHeaderSize = WLAN80211_MANDATORY_HEADER_SIZE;
10618 v_U8_t ucHeaderSize = 0;
10619 v_VOID_t *ppvBDHeader = NULL;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053010620 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070010621 v_U8_t ucQoSOffset = WLAN80211_MANDATORY_HEADER_SIZE;
Kiran Venkatappacab0d352012-12-17 13:09:22 -080010622 v_U8_t ucStaId;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010623#ifdef FEATURE_WLAN_ESE_UPLOAD
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070010624 v_BOOL_t bIAPPTxwithLLC = VOS_FALSE;
10625 v_SIZE_t wIAPPSnapSize = WLANTL_LLC_HEADER_LEN;
10626 v_U8_t wIAPPSnap[WLANTL_LLC_HEADER_LEN] = {0};
10627#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010628 *ucWDSEnabled = 0; // default WDS off.
10629 vosStatus = vos_pkt_pop_head( vosDataBuff, &w8023Header,
10630 sizeof(w8023Header));
10631
10632 if ( VOS_STATUS_SUCCESS != vosStatus )
10633 {
10634 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
10635 "WLAN TL: Packet pop header fails on WLANTL_Translate8023To80211Header"));
10636 return vosStatus;
10637 }
10638
Kiran Venkatappacab0d352012-12-17 13:09:22 -080010639 if( NULL == pucStaId )
10640 {
10641 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
10642 "WLAN TL: Invalid pointer for StaId"));
10643 return VOS_STATUS_E_INVAL;
10644 }
10645 ucStaId = *pucStaId;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053010646 pClientSTA = pTLCb->atlSTAClients[ucStaId];
10647
10648 if ( NULL == pClientSTA )
10649 {
10650 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
10651 "WLAN TL:Client Memory was not allocated on %s", __func__));
10652 return VOS_STATUS_E_FAILURE;
10653 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080010654
Kiran Venkatappaa044eb92012-12-17 15:48:49 -080010655#ifdef FEATURE_WLAN_TDLS
10656
Madan Mohan Koyylamudi64258222013-01-30 14:35:10 +053010657 if ( WLAN_STA_INFRA == pTLCb->atlSTAClients[ucStaId]->wSTADesc.wSTAType
10658 && pTLCb->ucTdlsPeerCount )
Kiran Venkatappacab0d352012-12-17 13:09:22 -080010659 {
10660 v_U8_t ucIndex = 0;
10661 for ( ucIndex = 0; ucIndex < WLAN_MAX_STA_COUNT ; ucIndex++)
10662 {
Madan Mohan Koyylamudi64258222013-01-30 14:35:10 +053010663 if ( ucIndex != ucStaId && pTLCb->atlSTAClients[ucIndex] && pTLCb->atlSTAClients[ucIndex]->ucExists &&
Gopichand Nakkala471708b2013-06-04 20:03:01 +053010664 (pTLCb->atlSTAClients[ucIndex]->tlState == WLANTL_STA_AUTHENTICATED) &&
10665 (!pTLCb->atlSTAClients[ucIndex]->ucTxSuspended) &&
Madan Mohan Koyylamudi64258222013-01-30 14:35:10 +053010666 vos_mem_compare( (void*)pTLCb->atlSTAClients[ucIndex]->wSTADesc.vSTAMACAddress.bytes,
Kiran Venkatappacab0d352012-12-17 13:09:22 -080010667 (void*)w8023Header.vDA, 6) )
10668 {
10669 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_LOW,
10670 "WLAN TL: Got a TDLS station. Using that index"));
10671 ucStaId = ucIndex;
10672 *pucStaId = ucStaId;
Madan Mohan Koyylamudi64258222013-01-30 14:35:10 +053010673 pClientSTA = pTLCb->atlSTAClients[ucStaId];
10674 if ( NULL == pClientSTA )
10675 {
10676 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
10677 "WLAN TL:Client Memory was not allocated on %s", __func__));
10678 return VOS_STATUS_E_FAILURE;
10679 }
Kiran Venkatappacab0d352012-12-17 13:09:22 -080010680 break;
10681 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080010682 }
Kiran Venkatappacab0d352012-12-17 13:09:22 -080010683 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080010684#endif
10685
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010686#ifdef FEATURE_WLAN_ESE_UPLOAD
10687if ((0 == w8023Header.usLenType) && (pClientSTA->wSTADesc.ucIsEseSta))
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070010688{
10689 vos_pkt_extract_data(vosDataBuff,0,&wIAPPSnap[0],&wIAPPSnapSize);
10690 if (vos_mem_compare(wIAPPSnap,WLANTL_AIRONET_SNAP_HEADER,WLANTL_LLC_HEADER_LEN))
10691 {
10692 /*The SNAP and the protocol type are already in the data buffer.
10693 They are filled by the application (wpa_supplicant). So, Skip Adding LLC below.*/
10694 bIAPPTxwithLLC = VOS_TRUE;
10695 }
10696 else
10697 {
10698 bIAPPTxwithLLC = VOS_FALSE;
10699 }
10700}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010701#endif /* FEATURE_WLAN_ESE_UPLOAD */
Jeff Johnson295189b2012-06-20 16:38:30 -070010702
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070010703 if ((0 != pClientSTA->wSTADesc.ucAddRmvLLC)
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010704#ifdef FEATURE_WLAN_ESE_UPLOAD
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070010705 && (!bIAPPTxwithLLC)
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010706#endif /* FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070010707 )
Jeff Johnson295189b2012-06-20 16:38:30 -070010708 {
10709 /* Push the length */
10710 vosStatus = vos_pkt_push_head(vosDataBuff,
10711 &w8023Header.usLenType, sizeof(w8023Header.usLenType));
10712
10713 if ( VOS_STATUS_SUCCESS != vosStatus )
10714 {
10715 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
10716 "WLAN TL: Packet push ether type fails on"
10717 " WLANTL_Translate8023To80211Header"));
10718 return vosStatus;
10719 }
10720
10721#ifdef BTAMP_TEST
10722 // The STA side will execute this, a hack to test BTAMP by using the
10723 // infra setup. On real BTAMP this will come from BAP itself.
10724 {
10725 static v_U8_t WLANTL_BT_AMP_LLC_HEADER[] = {0xAA, 0xAA, 0x03, 0x00, 0x19, 0x58 };
10726 vosStatus = vos_pkt_push_head(vosDataBuff, WLANTL_BT_AMP_LLC_HEADER,
10727 sizeof(WLANTL_BT_AMP_LLC_HEADER));
10728
10729 if ( VOS_STATUS_SUCCESS != vosStatus )
10730 {
10731 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
10732 "WLAN TL: Packet push LLC header fails on"
10733 " WLANTL_Translate8023To80211Header"));
10734 return vosStatus;
10735 }
10736 }
10737#else
10738 vosStatus = vos_pkt_push_head(vosDataBuff, WLANTL_LLC_HEADER,
10739 sizeof(WLANTL_LLC_HEADER));
10740
10741 if ( VOS_STATUS_SUCCESS != vosStatus )
10742 {
10743 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
10744 "WLAN TL: Packet push LLC header fails on"
10745 " WLANTL_Translate8023To80211Header"));
10746 return vosStatus;
10747 }
10748#endif
10749 }/*If add LLC is enabled*/
10750 else
10751 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010752#ifdef FEATURE_WLAN_ESE_UPLOAD
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070010753 bIAPPTxwithLLC = VOS_FALSE; /*Reset the Flag here to start afresh with the next TX pkt*/
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010754#endif /* FEATURE_WLAN_ESE_UPLOAD */
Jeff Johnson295189b2012-06-20 16:38:30 -070010755 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
10756 "WLAN TL: STA Client registered to not remove LLC"
10757 " WLANTL_Translate8023To80211Header"));
10758 }
10759
10760#ifdef BTAMP_TEST
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053010761 pClientSTA->wSTADesc.wSTAType = WLAN_STA_BT_AMP;
Jeff Johnson295189b2012-06-20 16:38:30 -070010762#endif
10763
10764 // Find the space required for the 802.11 header format
10765 // based on the frame control fields.
10766 ucHeaderSize = MandatoryucHeaderSize;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053010767 if (pClientSTA->wSTADesc.ucQosEnabled)
Jeff Johnson295189b2012-06-20 16:38:30 -070010768 {
10769 ucHeaderSize += sizeof(pw80211Header->usQosCtrl);
10770 }
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053010771 if (pClientSTA->wSTADesc.wSTAType == WLAN_STA_BT_AMP)
Jeff Johnson295189b2012-06-20 16:38:30 -070010772 {
10773 ucHeaderSize += sizeof(pw80211Header->optvA4);
Jeff Johnson295189b2012-06-20 16:38:30 -070010774 ucQoSOffset += sizeof(pw80211Header->optvA4);
Jeff Johnson295189b2012-06-20 16:38:30 -070010775 }
10776
10777 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
10778 " WLANTL_Translate8023To80211Header : Header size = %d ", ucHeaderSize));
10779
10780 vos_pkt_reserve_head( vosDataBuff, &ppvBDHeader, ucHeaderSize );
10781 if ( NULL == ppvBDHeader )
10782 {
10783 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
10784 "WLAN TL:VOSS packet corrupted "));
10785 *pvosStatus = VOS_STATUS_E_INVAL;
10786 return *pvosStatus;
10787 }
10788
Jeff Johnson295189b2012-06-20 16:38:30 -070010789
10790 // OK now we have the space. Fill the 80211 header
10791 /* Fill A2 */
10792 pw80211Header = (WLANTL_80211HeaderType *)(ppvBDHeader);
10793 // only clear the required space.
10794 vos_mem_set( pw80211Header, ucHeaderSize, 0 );
10795 vos_mem_copy( pw80211Header->vA2, w8023Header.vSA, VOS_MAC_ADDR_SIZE);
10796
10797
10798#ifdef FEATURE_WLAN_WAPI
Gopichand Nakkala8b54e912013-03-11 10:44:21 +053010799 if (( WLANTL_STA_AUTHENTICATED == pClientSTA->tlState ||
Abhishek Singh8cecdaa2015-05-22 14:46:40 +053010800 pClientSTA->ptkInstalled ) && (tlMetaInfo->ucIsWai != 1))
Jeff Johnson295189b2012-06-20 16:38:30 -070010801#else
Gopichand Nakkala8b54e912013-03-11 10:44:21 +053010802 if ( WLANTL_STA_AUTHENTICATED == pClientSTA->tlState ||
10803 pClientSTA->ptkInstalled )
Jeff Johnson295189b2012-06-20 16:38:30 -070010804#endif
10805 {
10806 pw80211Header->wFrmCtrl.wep =
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053010807 pClientSTA->wSTADesc.ucProtectedFrame;
Jeff Johnson295189b2012-06-20 16:38:30 -070010808 }
10809
10810 pw80211Header->usDurationId = 0;
10811 pw80211Header->usSeqCtrl = 0;
10812
10813 pw80211Header->wFrmCtrl.type = WLANTL_80211_DATA_TYPE;
10814
10815
10816
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053010817 if(pClientSTA->wSTADesc.ucQosEnabled)
Jeff Johnson295189b2012-06-20 16:38:30 -070010818 {
10819 pw80211Header->wFrmCtrl.subType = WLANTL_80211_DATA_QOS_SUBTYPE;
10820
Ravi Joshid0699502013-07-08 15:48:47 -070010821 *((v_U16_t *)((v_U8_t *)ppvBDHeader + ucQoSOffset)) = tlMetaInfo->ucUP;
Jeff Johnson295189b2012-06-20 16:38:30 -070010822
10823 }
10824 else
10825 {
10826 pw80211Header->wFrmCtrl.subType = 0;
Agarwal Ashish8b343f12015-01-08 20:06:44 +053010827 tlMetaInfo->ucUP = 0;
10828 tlMetaInfo->ucTID = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070010829
10830 // NO NO NO - there is not enough memory allocated to write the QOS ctrl
10831 // field, it will overwrite the first 2 bytes of the data packet(LLC header)
10832 // pw80211Header->usQosCtrl = 0;
10833 }
10834
10835
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053010836 switch( pClientSTA->wSTADesc.wSTAType )
Jeff Johnson295189b2012-06-20 16:38:30 -070010837 {
Ravi Joshid0699502013-07-08 15:48:47 -070010838 case WLAN_STA_IBSS:
Jeff Johnson295189b2012-06-20 16:38:30 -070010839 pw80211Header->wFrmCtrl.toDS = 0;
10840 pw80211Header->wFrmCtrl.fromDS = 0;
Ravi Joshid0699502013-07-08 15:48:47 -070010841
Abhishek Singh45e68fe2014-12-11 12:55:59 +053010842 vos_copy_macaddr( (v_MACADDR_t*)&pw80211Header->vA1,
Ravi Joshid0699502013-07-08 15:48:47 -070010843 (v_MACADDR_t*)&w8023Header.vDA);
Jeff Johnson295189b2012-06-20 16:38:30 -070010844 vos_mem_copy( pw80211Header->vA3,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053010845 &pClientSTA->wSTADesc.vBSSIDforIBSS ,
Jeff Johnson295189b2012-06-20 16:38:30 -070010846 VOS_MAC_ADDR_SIZE);
10847 break;
10848
Ravi Joshid0699502013-07-08 15:48:47 -070010849 case WLAN_STA_BT_AMP:
Jeff Johnson295189b2012-06-20 16:38:30 -070010850 *ucWDSEnabled = 1; // WDS on.
10851 pw80211Header->wFrmCtrl.toDS = 1;
10852 pw80211Header->wFrmCtrl.fromDS = 1;
10853 vos_copy_macaddr( (v_MACADDR_t*)&pw80211Header->vA1,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053010854 &pClientSTA->wSTADesc.vSTAMACAddress);
Jeff Johnson295189b2012-06-20 16:38:30 -070010855 vos_mem_copy( pw80211Header->vA2,
Ravi Joshid0699502013-07-08 15:48:47 -070010856 w8023Header.vSA, VOS_MAC_ADDR_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -070010857 vos_copy_macaddr( (v_MACADDR_t*)&pw80211Header->vA3,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053010858 &pClientSTA->wSTADesc.vSTAMACAddress);
Jeff Johnson295189b2012-06-20 16:38:30 -070010859 /* fill the optional A4 header */
10860 vos_mem_copy( pw80211Header->optvA4,
Ravi Joshid0699502013-07-08 15:48:47 -070010861 w8023Header.vSA, VOS_MAC_ADDR_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -070010862 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
Arif Hussainf2b00992013-11-17 21:46:15 -080010863 "BTAMP CASE NOW ---------staid=%d",
Ravi Joshid0699502013-07-08 15:48:47 -070010864 ucStaId));
Jeff Johnson295189b2012-06-20 16:38:30 -070010865 break;
10866
Ravi Joshid0699502013-07-08 15:48:47 -070010867 case WLAN_STA_SOFTAP:
Jeff Johnson295189b2012-06-20 16:38:30 -070010868 *ucWDSEnabled = 0; // WDS off.
10869 pw80211Header->wFrmCtrl.toDS = 0;
10870 pw80211Header->wFrmCtrl.fromDS = 1;
10871 /*Copy the DA to A1*/
10872 vos_mem_copy( pw80211Header->vA1, w8023Header.vDA , VOS_MAC_ADDR_SIZE);
10873 vos_copy_macaddr( (v_MACADDR_t*)&pw80211Header->vA2,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053010874 &pClientSTA->wSTADesc.vSelfMACAddress);
Jeff Johnson295189b2012-06-20 16:38:30 -070010875 vos_mem_copy( pw80211Header->vA3,
Ravi Joshid0699502013-07-08 15:48:47 -070010876 w8023Header.vSA, VOS_MAC_ADDR_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -070010877 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
Arif Hussainf2b00992013-11-17 21:46:15 -080010878 "sw 802 to 80211 softap case ---------staid=%d",
Ravi Joshid0699502013-07-08 15:48:47 -070010879 ucStaId));
Jeff Johnson295189b2012-06-20 16:38:30 -070010880 break;
Mohit Khanna698ba2a2012-12-04 15:08:18 -080010881#ifdef FEATURE_WLAN_TDLS
Ravi Joshid0699502013-07-08 15:48:47 -070010882 case WLAN_STA_TDLS:
Mohit Khanna698ba2a2012-12-04 15:08:18 -080010883 pw80211Header->wFrmCtrl.toDS = 0;
10884 pw80211Header->wFrmCtrl.fromDS = 0;
10885 /*Fix me*/
10886 vos_copy_macaddr( (v_MACADDR_t*)&pw80211Header->vA1,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053010887 &pClientSTA->wSTADesc.vSTAMACAddress);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080010888 vos_mem_copy( pw80211Header->vA3,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053010889 &pClientSTA->wSTADesc.vBSSIDforIBSS ,
Mohit Khanna698ba2a2012-12-04 15:08:18 -080010890 VOS_MAC_ADDR_SIZE);
10891 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
Arif Hussainf2b00992013-11-17 21:46:15 -080010892 ("TL:TDLS CASE NOW ---------staid=%d"), ucStaId);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080010893 break;
10894#endif
Ravi Joshid0699502013-07-08 15:48:47 -070010895 case WLAN_STA_INFRA:
10896 default:
Jeff Johnson295189b2012-06-20 16:38:30 -070010897 pw80211Header->wFrmCtrl.toDS = 1;
10898 pw80211Header->wFrmCtrl.fromDS = 0;
10899 vos_copy_macaddr( (v_MACADDR_t*)&pw80211Header->vA1,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053010900 &pClientSTA->wSTADesc.vSTAMACAddress);
Jeff Johnson295189b2012-06-20 16:38:30 -070010901 vos_mem_copy( pw80211Header->vA3, w8023Header.vDA , VOS_MAC_ADDR_SIZE);
10902 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
Arif Hussainf2b00992013-11-17 21:46:15 -080010903 "REGULAR INFRA LINK CASE---------staid=%d",
Ravi Joshid0699502013-07-08 15:48:47 -070010904 ucStaId));
Jeff Johnson295189b2012-06-20 16:38:30 -070010905 break;
10906 }
10907 // OK now we have the space. Fill the 80211 header
10908 /* Fill A2 */
10909 pw80211Header = (WLANTL_80211HeaderType *)(ppvBDHeader);
10910 return VOS_STATUS_SUCCESS;
10911}/*WLANTL_Translate8023To80211Header*/
10912
10913
10914/*=============================================================================
10915 BEGIN LOG FUNCTION !!! Remove me or clean me
10916=============================================================================*/
Ravi Kumar Vaishnavb7652402013-01-18 19:05:15 -080010917#if 0 //def WLANTL_DEBUG
Jeff Johnson295189b2012-06-20 16:38:30 -070010918
10919#define WLANTL_DEBUG_FRAME_BYTE_PER_LINE 16
10920#define WLANTL_DEBUG_FRAME_BYTE_PER_BYTE 4
10921
10922static v_VOID_t WLANTL_DebugFrame
10923(
10924 v_PVOID_t dataPointer,
10925 v_U32_t dataSize
10926)
10927{
10928 v_U8_t lineBuffer[WLANTL_DEBUG_FRAME_BYTE_PER_LINE];
10929 v_U32_t numLines;
10930 v_U32_t numBytes;
10931 v_U32_t idx;
10932 v_U8_t *linePointer;
10933
10934 numLines = dataSize / WLANTL_DEBUG_FRAME_BYTE_PER_LINE;
10935 numBytes = dataSize % WLANTL_DEBUG_FRAME_BYTE_PER_LINE;
10936 linePointer = (v_U8_t *)dataPointer;
10937
Jeff Johnsonddec6482017-09-19 08:33:57 -070010938 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 -070010939 for(idx = 0; idx < numLines; idx++)
10940 {
10941 memset(lineBuffer, 0, WLANTL_DEBUG_FRAME_BYTE_PER_LINE);
10942 memcpy(lineBuffer, linePointer, WLANTL_DEBUG_FRAME_BYTE_PER_LINE);
10943 TLLOGE(VOS_TRACE(VOS_MODULE_ID_SAL, VOS_TRACE_LEVEL_ERROR,
10944 "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",
10945 lineBuffer[0], lineBuffer[1], lineBuffer[2], lineBuffer[3], lineBuffer[4], lineBuffer[5], lineBuffer[6], lineBuffer[7],
10946 lineBuffer[8], lineBuffer[9], lineBuffer[10], lineBuffer[11], lineBuffer[12], lineBuffer[13], lineBuffer[14], lineBuffer[15]));
10947 linePointer += WLANTL_DEBUG_FRAME_BYTE_PER_LINE;
10948 }
10949
10950 if(0 == numBytes)
10951 return;
10952
10953 memset(lineBuffer, 0, WLANTL_DEBUG_FRAME_BYTE_PER_LINE);
10954 memcpy(lineBuffer, linePointer, numBytes);
10955 for(idx = 0; idx < WLANTL_DEBUG_FRAME_BYTE_PER_LINE / WLANTL_DEBUG_FRAME_BYTE_PER_BYTE; idx++)
10956 {
10957 TLLOGE(VOS_TRACE(VOS_MODULE_ID_SAL, VOS_TRACE_LEVEL_ERROR, "WLAN TL:0x%2x 0x%2x 0x%2x 0x%2x",
10958 lineBuffer[idx * WLANTL_DEBUG_FRAME_BYTE_PER_BYTE], lineBuffer[1 + idx * WLANTL_DEBUG_FRAME_BYTE_PER_BYTE],
10959 lineBuffer[2 + idx * WLANTL_DEBUG_FRAME_BYTE_PER_BYTE], lineBuffer[3 + idx * WLANTL_DEBUG_FRAME_BYTE_PER_BYTE]));
10960 if(((idx + 1) * WLANTL_DEBUG_FRAME_BYTE_PER_BYTE) >= numBytes)
10961 break;
10962 }
10963
10964 return;
10965}
10966#endif
10967
10968/*=============================================================================
10969 END LOG FUNCTION
10970=============================================================================*/
10971
10972/*==========================================================================
10973 FUNCTION WLANTL_Translate80211To8023Header
10974
10975 DESCRIPTION
10976 Inline function for translating and 802.11 header into an 802.3 header.
10977
10978 DEPENDENCIES
10979
10980
10981 PARAMETERS
10982
10983 IN
10984 pTLCb: TL control block
10985 ucStaId: station ID
10986 ucHeaderLen: Length of the header from BD
10987 ucActualHLen: Length of header including padding or any other trailers
10988
10989 IN/OUT
10990 vosDataBuff: vos data buffer, will contain the new header on output
10991
10992 OUT
10993 pvosStatus: status of the operation
10994
10995 RETURN VALUE
10996
10997 The result code associated with performing the operation
10998 VOS_STATUS_SUCCESS: Everything is good :)
10999
11000 SIDE EFFECTS
11001
11002============================================================================*/
11003VOS_STATUS
11004WLANTL_Translate80211To8023Header
11005(
11006 vos_pkt_t* vosDataBuff,
11007 VOS_STATUS* pvosStatus,
11008 v_U16_t usActualHLen,
11009 v_U8_t ucHeaderLen,
11010 WLANTL_CbType* pTLCb,
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070011011 v_U8_t ucSTAId,
11012 v_BOOL_t bForwardIAPPwithLLC
Jeff Johnson295189b2012-06-20 16:38:30 -070011013)
11014{
11015 WLANTL_8023HeaderType w8023Header;
11016 WLANTL_80211HeaderType w80211Header;
11017 v_U8_t aucLLCHeader[WLANTL_LLC_HEADER_LEN];
11018 VOS_STATUS vosStatus;
11019 v_U16_t usDataStartOffset = 0;
11020 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
11021
11022 if ( sizeof(w80211Header) < ucHeaderLen )
11023 {
11024 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
11025 "Warning !: Check the header size for the Rx frame structure=%d received=%dn",
11026 sizeof(w80211Header), ucHeaderLen));
11027 ucHeaderLen = sizeof(w80211Header);
11028 }
11029
11030 // This will take care of headers of all sizes, 3 address, 3 addr QOS,
11031 // WDS non-QOS and WDS QoS etc. We have space for all in the 802.11 header structure.
11032 vosStatus = vos_pkt_pop_head( vosDataBuff, &w80211Header, ucHeaderLen);
11033
11034 if ( VOS_STATUS_SUCCESS != vosStatus )
11035 {
11036 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11037 "WLAN TL: Failed to pop 80211 header from packet %d",
11038 vosStatus));
11039
11040 return vosStatus;
11041 }
11042
11043 switch ( w80211Header.wFrmCtrl.fromDS )
11044 {
11045 case 0:
Jeff Johnson295189b2012-06-20 16:38:30 -070011046 if ( w80211Header.wFrmCtrl.toDS )
11047 {
11048 //SoftAP AP mode
11049 vos_mem_copy( w8023Header.vDA, w80211Header.vA3, VOS_MAC_ADDR_SIZE);
11050 vos_mem_copy( w8023Header.vSA, w80211Header.vA2, VOS_MAC_ADDR_SIZE);
11051 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
Arif Hussainf2b00992013-11-17 21:46:15 -080011052 "WLAN TL SoftAP: 802 3 DA %08x SA %08x",
Jeff Johnson295189b2012-06-20 16:38:30 -070011053 w8023Header.vDA, w8023Header.vSA));
11054 }
11055 else
11056 {
11057 /* IBSS */
11058 vos_mem_copy( w8023Header.vDA, w80211Header.vA1, VOS_MAC_ADDR_SIZE);
11059 vos_mem_copy( w8023Header.vSA, w80211Header.vA2, VOS_MAC_ADDR_SIZE);
11060 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011061 break;
11062 case 1:
11063 if ( w80211Header.wFrmCtrl.toDS )
11064 {
11065 /* BT-AMP case */
11066 vos_mem_copy( w8023Header.vDA, w80211Header.vA1, VOS_MAC_ADDR_SIZE);
11067 vos_mem_copy( w8023Header.vSA, w80211Header.vA2, VOS_MAC_ADDR_SIZE);
11068 }
11069 else
11070 { /* Infra */
11071 vos_mem_copy( w8023Header.vDA, w80211Header.vA1, VOS_MAC_ADDR_SIZE);
11072 vos_mem_copy( w8023Header.vSA, w80211Header.vA3, VOS_MAC_ADDR_SIZE);
11073 }
11074 break;
11075 }
11076
11077 if( usActualHLen > ucHeaderLen )
11078 {
11079 usDataStartOffset = usActualHLen - ucHeaderLen;
11080 }
11081
11082 if ( 0 < usDataStartOffset )
11083 {
11084 vosStatus = vos_pkt_trim_head( vosDataBuff, usDataStartOffset );
11085
11086 if ( VOS_STATUS_SUCCESS != vosStatus )
11087 {
11088 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11089 "WLAN TL: Failed to trim header from packet %d",
11090 vosStatus));
11091 return vosStatus;
11092 }
11093 }
11094
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053011095 if ( NULL == pTLCb->atlSTAClients[ucSTAId] )
11096 {
11097 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11098 "WLAN TL:Client Memory was not allocated on %s", __func__));
11099 return VOS_STATUS_E_FAILURE;
11100 }
11101
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070011102 if ( 0 != pTLCb->atlSTAClients[ucSTAId]->wSTADesc.ucAddRmvLLC
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080011103#ifdef FEATURE_WLAN_ESE_UPLOAD
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070011104 && (!bForwardIAPPwithLLC)
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080011105#endif /* FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070011106 )
Jeff Johnson295189b2012-06-20 16:38:30 -070011107 {
11108 // Extract the LLC header
11109 vosStatus = vos_pkt_pop_head( vosDataBuff, aucLLCHeader,
11110 WLANTL_LLC_HEADER_LEN);
11111
11112 if ( VOS_STATUS_SUCCESS != vosStatus )
11113 {
Kaushik, Sushante386ee12014-05-01 15:50:52 +053011114 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
Jeff Johnson295189b2012-06-20 16:38:30 -070011115 "WLAN TL: Failed to pop LLC header from packet %d",
11116 vosStatus));
11117
11118 return vosStatus;
11119 }
11120
11121 //Extract the length
11122 vos_mem_copy(&w8023Header.usLenType,
11123 &aucLLCHeader[WLANTL_LLC_HEADER_LEN - sizeof(w8023Header.usLenType)],
11124 sizeof(w8023Header.usLenType) );
11125 }
11126 else
11127 {
11128 vosStatus = vos_pkt_get_packet_length(vosDataBuff,
11129 &w8023Header.usLenType);
11130
11131 if ( VOS_STATUS_SUCCESS != vosStatus )
11132 {
11133 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11134 "WLAN TL: Failed to get packet length %d",
11135 vosStatus));
11136
11137 return vosStatus;
11138 }
11139
11140 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
11141 "WLAN TL: BTAMP len (ethertype) fld = %d",
11142 w8023Header.usLenType));
11143 w8023Header.usLenType = vos_cpu_to_be16(w8023Header.usLenType);
11144 }
11145
11146 vos_pkt_push_head(vosDataBuff, &w8023Header, sizeof(w8023Header));
11147
11148#ifdef BTAMP_TEST
11149 {
11150 // AP side will execute this.
11151 v_U8_t *temp_w8023Header = NULL;
11152 vosStatus = vos_pkt_peek_data( vosDataBuff, 0,
11153 &temp_w8023Header, sizeof(w8023Header) );
11154 }
11155#endif
11156#if 0 /*TL_DEBUG*/
11157 vos_pkt_get_packet_length(vosDataBuff, &usLen);
11158 vos_pkt_pop_head( vosDataBuff, aucData, usLen);
11159
11160 WLANTL_DebugFrame(aucData, usLen);
11161
11162 vos_pkt_push_head(vosDataBuff, aucData, usLen);
11163
11164#endif
11165
11166 *pvosStatus = VOS_STATUS_SUCCESS;
11167
11168 return VOS_STATUS_SUCCESS;
11169}/*WLANTL_Translate80211To8023Header*/
11170
Katya Nigame7b69a82015-04-28 15:24:06 +053011171VOS_STATUS
11172WLANTL_MonTranslate80211To8023Header
11173(
11174 vos_pkt_t* vosDataBuff,
11175 WLANTL_CbType* pTLCb
11176)
11177{
11178 v_U16_t usMPDUDOffset;
11179 v_U8_t ucMPDUHOffset;
11180 v_U8_t ucMPDUHLen;
11181 v_U16_t usActualHLen = 0;
11182 v_U16_t usDataStartOffset = 0;
11183 v_PVOID_t aucBDHeader;
11184 WLANTL_8023HeaderType w8023Header;
11185 WLANTL_80211HeaderType w80211Header;
11186 VOS_STATUS vosStatus;
11187 v_U8_t aucLLCHeader[WLANTL_LLC_HEADER_LEN];
11188
11189 WDA_DS_PeekRxPacketInfo( vosDataBuff, (v_PVOID_t)&aucBDHeader, 0 );
11190 ucMPDUHOffset = (v_U8_t)WDA_GET_RX_MPDU_HEADER_OFFSET(aucBDHeader);
11191 usMPDUDOffset = (v_U16_t)WDA_GET_RX_MPDU_DATA_OFFSET(aucBDHeader);
11192 ucMPDUHLen = (v_U8_t)WDA_GET_RX_MPDU_HEADER_LEN(aucBDHeader);
11193 if (usMPDUDOffset > ucMPDUHOffset)
11194 {
11195 usActualHLen = usMPDUDOffset - ucMPDUHOffset;
11196 }
11197
11198 if ( sizeof(w80211Header) < ucMPDUHLen )
11199 {
11200 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
11201 "Warning !: Check the header size for the Rx frame structure=%d received=%dn",
11202 sizeof(w80211Header), ucMPDUHLen));
11203 ucMPDUHLen = sizeof(w80211Header);
11204 }
11205
11206 vosStatus = vos_pkt_pop_head( vosDataBuff, &w80211Header, ucMPDUHLen);
11207 if ( VOS_STATUS_SUCCESS != vosStatus )
11208 {
11209 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11210 "WLAN TL: Failed to pop 80211 header from packet %d",
11211 vosStatus));
11212
11213 return vosStatus;
11214 }
11215 switch ( w80211Header.wFrmCtrl.fromDS )
11216 {
11217 case 0:
11218 if ( w80211Header.wFrmCtrl.toDS )
11219 {
11220 vos_mem_copy( w8023Header.vDA, w80211Header.vA3, VOS_MAC_ADDR_SIZE);
11221 vos_mem_copy( w8023Header.vSA, w80211Header.vA2, VOS_MAC_ADDR_SIZE);
11222 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
11223 "WLAN TL SoftAP: 802 3 DA %08x SA %08x",
11224 w8023Header.vDA, w8023Header.vSA));
11225 }
11226 else
11227 {
11228 vos_mem_copy( w8023Header.vDA, w80211Header.vA1, VOS_MAC_ADDR_SIZE);
11229 vos_mem_copy( w8023Header.vSA, w80211Header.vA2, VOS_MAC_ADDR_SIZE);
11230 }
11231 break;
11232 case 1:
11233 if ( w80211Header.wFrmCtrl.toDS )
11234 {
11235 vos_mem_copy( w8023Header.vDA, w80211Header.vA1, VOS_MAC_ADDR_SIZE);
11236 vos_mem_copy( w8023Header.vSA, w80211Header.vA2, VOS_MAC_ADDR_SIZE);
11237 }
11238 else
11239 {
11240 vos_mem_copy( w8023Header.vDA, w80211Header.vA1, VOS_MAC_ADDR_SIZE);
11241 vos_mem_copy( w8023Header.vSA, w80211Header.vA3, VOS_MAC_ADDR_SIZE);
11242 }
11243 break;
11244 }
11245 if( usActualHLen > ucMPDUHLen )
11246 {
11247 usDataStartOffset = usActualHLen - ucMPDUHLen;
11248 }
11249
11250 if ( 0 < usDataStartOffset )
11251 {
11252 vosStatus = vos_pkt_trim_head( vosDataBuff, usDataStartOffset );
11253
11254 if ( VOS_STATUS_SUCCESS != vosStatus )
11255 {
11256 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11257 "WLAN TL: Failed to trim header from packet %d",
11258 vosStatus));
11259 return vosStatus;
11260 }
11261 }
11262 // Extract the LLC header
11263 vosStatus = vos_pkt_pop_head( vosDataBuff, aucLLCHeader,
11264 WLANTL_LLC_HEADER_LEN);
11265
11266 if ( VOS_STATUS_SUCCESS != vosStatus )
11267 {
11268 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
11269 "WLAN TL: Failed to pop LLC header from packet %d",
11270 vosStatus));
11271
11272 return vosStatus;
11273 }
11274
11275 //Extract the length
11276 vos_mem_copy(&w8023Header.usLenType,
11277 &aucLLCHeader[WLANTL_LLC_HEADER_LEN - sizeof(w8023Header.usLenType)],
11278 sizeof(w8023Header.usLenType) );
11279
11280 vos_pkt_push_head(vosDataBuff, &w8023Header, sizeof(w8023Header));
11281 return VOS_STATUS_SUCCESS;
11282}
11283
Madan Mohan Koyyalamudia148e1e2012-11-30 14:52:59 -080011284/*==========================================================================
11285 FUNCTION WLANTL_FindFrameTypeBcMcUc
11286
11287 DESCRIPTION
11288 Utility function to find whether received frame is broadcast, multicast
11289 or unicast.
11290
11291 DEPENDENCIES
11292 The STA must be registered with TL before this function can be called.
11293
11294 PARAMETERS
11295
11296 IN
11297 pTLCb: pointer to the TL's control block
11298 ucSTAId: identifier of the station being processed
11299 vosDataBuff: pointer to the vos buffer
11300
11301 IN/OUT
11302 pucBcMcUc: pointer to buffer, will contain frame type on return
11303
11304 RETURN VALUE
11305 The result code associated with performing the operation
11306
11307 VOS_STATUS_E_INVAL: invalid input parameters
11308 VOS_STATUS_E_BADMSG: failed to extract info from data buffer
11309 VOS_STATUS_SUCCESS: success
11310
11311 SIDE EFFECTS
11312 None.
11313============================================================================*/
11314VOS_STATUS
11315WLANTL_FindFrameTypeBcMcUc
11316(
11317 WLANTL_CbType *pTLCb,
11318 v_U8_t ucSTAId,
11319 vos_pkt_t *vosDataBuff,
11320 v_U8_t *pucBcMcUc
11321)
11322{
11323 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
11324 v_PVOID_t aucBDHeader;
11325 v_PVOID_t pvPeekData;
11326 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
11327
11328 /*------------------------------------------------------------------------
11329 Sanity check
11330 ------------------------------------------------------------------------*/
11331 if ((NULL == pTLCb) ||
11332 (NULL == vosDataBuff) ||
11333 (NULL == pucBcMcUc))
11334 {
11335 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11336 "WLAN TL:Invalid parameter in WLANTL_FindFrameTypeBcMcUc"));
11337 return VOS_STATUS_E_INVAL;
11338 }
11339
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053011340 if ( NULL == pTLCb->atlSTAClients[ucSTAId] )
11341 {
11342 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11343 "WLAN TL:Client Memory was not allocated on %s", __func__));
11344 return VOS_STATUS_E_FAILURE;
11345 }
11346
Madan Mohan Koyyalamudia148e1e2012-11-30 14:52:59 -080011347 /*------------------------------------------------------------------------
11348 Extract BD header and check if valid
11349 ------------------------------------------------------------------------*/
11350 vosStatus = WDA_DS_PeekRxPacketInfo(vosDataBuff, (v_PVOID_t)&aucBDHeader, 0/*Swap BD*/ );
11351
11352 if (NULL == aucBDHeader)
11353 {
11354 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11355 "WLAN TL:WLANTL_FindFrameTypeBcMcUc - Cannot extract BD header"));
11356 VOS_ASSERT(0);
11357 return VOS_STATUS_E_BADMSG;
11358 }
11359
11360 if ((0 == WDA_GET_RX_FT_DONE(aucBDHeader)) &&
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053011361 (0 != pTLCb->atlSTAClients[ucSTAId]->wSTADesc.ucSwFrameRXXlation))
Madan Mohan Koyyalamudia148e1e2012-11-30 14:52:59 -080011362 {
11363 /* Its an 802.11 frame, extract MAC address 1 */
11364 TLLOG2(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
11365 "WLAN TL:WLANTL_FindFrameTypeBcMcUc - 802.11 frame, peeking Addr1"));
11366 vosStatus = vos_pkt_peek_data(vosDataBuff, WLANTL_MAC_ADDR_ALIGN(1),
11367 (v_PVOID_t)&pvPeekData, VOS_MAC_ADDR_SIZE);
11368 }
11369 else
11370 {
11371 /* Its an 802.3 frame, extract Destination MAC address */
11372 TLLOG2(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
11373 "WLAN TL:WLANTL_FindFrameTypeBcMcUc - 802.3 frame, peeking DA"));
11374 vosStatus = vos_pkt_peek_data(vosDataBuff, WLANTL_MAC_ADDR_ALIGN(0),
11375 (v_PVOID_t)&pvPeekData, VOS_MAC_ADDR_SIZE);
11376 }
11377
11378 if (VOS_STATUS_SUCCESS != vosStatus)
11379 {
11380 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11381 "WLAN TL:WLANTL_FindFrameTypeBcMcUc - Failed to peek MAC address"));
11382 return vosStatus;
11383 }
11384
11385 if (((tANI_U8 *)pvPeekData)[0] == 0xff)
11386 {
11387 *pucBcMcUc = WLANTL_FRAME_TYPE_BCAST;
11388 }
11389 else
11390 {
11391 if ((((tANI_U8 *)pvPeekData)[0] & 0x01) == 0x01)
11392 *pucBcMcUc = WLANTL_FRAME_TYPE_MCAST;
11393 else
11394 *pucBcMcUc = WLANTL_FRAME_TYPE_UCAST;
11395 }
11396
11397 TLLOG2(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
11398 "WLAN TL:WLANTL_FindFrameTypeBcMcUc - Addr1Byte1 is: %x",
11399 ((tANI_U8 *)pvPeekData)[0]));
11400
11401 return VOS_STATUS_SUCCESS;
11402}
11403
Jeff Johnson295189b2012-06-20 16:38:30 -070011404#if 0
11405#ifdef WLAN_PERF
11406/*==========================================================================
11407 FUNCTION WLANTL_FastHwFwdDataFrame
11408
11409 DESCRIPTION
11410 Fast path function to quickly forward a data frame if HAL determines BD
11411 signature computed here matches the signature inside current VOSS packet.
11412 If there is a match, HAL and TL fills in the swapped packet length into
11413 BD header and DxE header, respectively. Otherwise, packet goes back to
11414 normal (slow) path and a new BD signature would be tagged into BD in this
11415 VOSS packet later by the WLANHAL_FillTxBd() function.
11416
11417 DEPENDENCIES
11418
11419 PARAMETERS
11420
11421 IN
11422 pvosGCtx VOS context
11423 vosDataBuff Ptr to VOSS packet
11424 pMetaInfo For getting frame's TID
11425 pStaInfo For checking STA type
11426
11427 OUT
11428 pvosStatus returned status
11429 puFastFwdOK Flag to indicate whether frame could be fast forwarded
11430
11431 RETURN VALUE
11432 No return.
11433
11434 SIDE EFFECTS
11435
11436============================================================================*/
11437static void
11438WLANTL_FastHwFwdDataFrame
11439(
11440 v_PVOID_t pvosGCtx,
11441 vos_pkt_t* vosDataBuff,
11442 VOS_STATUS* pvosStatus,
11443 v_U32_t* puFastFwdOK,
11444 WLANTL_MetaInfoType* pMetaInfo,
11445 WLAN_STADescType* pStaInfo
11446
11447)
11448{
11449 v_PVOID_t pvPeekData;
11450 v_U8_t ucDxEBDWLANHeaderLen = WLANTL_BD_HEADER_LEN(0) + sizeof(WLANBAL_sDXEHeaderType);
11451 v_U8_t ucIsUnicast;
11452 WLANBAL_sDXEHeaderType *pDxEHeader;
11453 v_PVOID_t pvBDHeader;
11454 v_PVOID_t pucBuffPtr;
11455 v_U16_t usPktLen;
11456
11457 /*-----------------------------------------------------------------------
11458 Extract packet length
11459 -----------------------------------------------------------------------*/
11460
11461 vos_pkt_get_packet_length( vosDataBuff, &usPktLen);
11462
11463 /*-----------------------------------------------------------------------
11464 Extract MAC address
11465 -----------------------------------------------------------------------*/
11466 *pvosStatus = vos_pkt_peek_data( vosDataBuff,
11467 WLANTL_MAC_ADDR_ALIGN(0),
11468 (v_PVOID_t)&pvPeekData,
11469 VOS_MAC_ADDR_SIZE );
11470
11471 if ( VOS_STATUS_SUCCESS != *pvosStatus )
11472 {
11473 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11474 "WLAN TL:Failed while attempting to extract MAC Addr %d",
11475 *pvosStatus));
11476 *pvosStatus = VOS_STATUS_E_INVAL;
11477 return;
11478 }
11479
11480 /*-----------------------------------------------------------------------
11481 Reserve head room for DxE header, BD, and WLAN header
11482 -----------------------------------------------------------------------*/
11483
11484 vos_pkt_reserve_head( vosDataBuff, &pucBuffPtr,
11485 ucDxEBDWLANHeaderLen );
11486 if ( NULL == pucBuffPtr )
11487 {
11488 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Jeff Johnsonddec6482017-09-19 08:33:57 -070011489 "WLAN TL:No enough space in VOSS packet %pK for DxE/BD/WLAN header", vosDataBuff));
Jeff Johnson295189b2012-06-20 16:38:30 -070011490 *pvosStatus = VOS_STATUS_E_INVAL;
11491 return;
11492 }
11493 pDxEHeader = (WLANBAL_sDXEHeaderType *)pucBuffPtr;
11494 pvBDHeader = (v_PVOID_t) &pDxEHeader[1];
11495
11496 /* UMA Tx acceleration is enabled.
11497 * UMA would help convert frames to 802.11, fill partial BD fields and
11498 * construct LLC header. To further accelerate this kind of frames,
11499 * HAL would attempt to reuse the BD descriptor if the BD signature
11500 * matches to the saved BD descriptor.
11501 */
11502 if(pStaInfo->wSTAType == WLAN_STA_IBSS)
11503 ucIsUnicast = !(((tANI_U8 *)pvPeekData)[0] & 0x01);
11504 else
11505 ucIsUnicast = 1;
11506
11507 *puFastFwdOK = (v_U32_t) WLANHAL_TxBdFastFwd(pvosGCtx, pvPeekData, pMetaInfo->ucTID, ucIsUnicast, pvBDHeader, usPktLen );
11508
11509 /* Can't be fast forwarded. Trim the VOS head back to original location. */
11510 if(! *puFastFwdOK){
11511 vos_pkt_trim_head(vosDataBuff, ucDxEBDWLANHeaderLen);
11512 }else{
11513 /* could be fast forwarded. Now notify BAL DxE header filling could be completely skipped
11514 */
11515 v_U32_t uPacketSize = WLANTL_BD_HEADER_LEN(0) + usPktLen;
11516 vos_pkt_set_user_data_ptr( vosDataBuff, VOS_PKT_USER_DATA_ID_BAL,
11517 (v_PVOID_t)uPacketSize);
11518 pDxEHeader->size = SWAP_ENDIAN_UINT32(uPacketSize);
11519 }
11520 *pvosStatus = VOS_STATUS_SUCCESS;
11521 return;
11522}
11523#endif /*WLAN_PERF*/
11524#endif
11525
11526#if 0
11527/*==========================================================================
11528 FUNCTION WLANTL_PrepareBDHeader
11529
11530 DESCRIPTION
11531 Inline function for preparing BD header before HAL processing.
11532
11533 DEPENDENCIES
11534 Just notify HAL that suspend in TL is complete.
11535
11536 PARAMETERS
11537
11538 IN
11539 vosDataBuff: vos data buffer
11540 ucDisableFrmXtl: is frame xtl disabled
11541
11542 OUT
11543 ppvBDHeader: it will contain the BD header
11544 pvDestMacAdddr: it will contain the destination MAC address
11545 pvosStatus: status of the combined processing
11546 pusPktLen: packet len.
11547
11548 RETURN VALUE
11549 No return.
11550
11551 SIDE EFFECTS
11552
11553============================================================================*/
11554void
11555WLANTL_PrepareBDHeader
11556(
11557 vos_pkt_t* vosDataBuff,
11558 v_PVOID_t* ppvBDHeader,
11559 v_MACADDR_t* pvDestMacAdddr,
11560 v_U8_t ucDisableFrmXtl,
11561 VOS_STATUS* pvosStatus,
11562 v_U16_t* pusPktLen,
11563 v_U8_t ucQosEnabled,
11564 v_U8_t ucWDSEnabled,
11565 v_U8_t extraHeadSpace
11566)
11567{
11568 v_U8_t ucHeaderOffset;
11569 v_U8_t ucHeaderLen;
Jeff Johnson295189b2012-06-20 16:38:30 -070011570 v_U8_t ucBDHeaderLen = WLANTL_BD_HEADER_LEN(ucDisableFrmXtl);
11571
11572 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
11573 /*-------------------------------------------------------------------------
11574 Get header pointer from VOSS
11575 !!! make sure reserve head zeros out the memory
11576 -------------------------------------------------------------------------*/
11577 vos_pkt_get_packet_length( vosDataBuff, pusPktLen);
11578
11579 if ( WLANTL_MAC_HEADER_LEN(ucDisableFrmXtl) > *pusPktLen )
11580 {
11581 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11582 "WLAN TL: Length of the packet smaller than expected network"
11583 " header %d", *pusPktLen ));
11584
11585 *pvosStatus = VOS_STATUS_E_INVAL;
11586 return;
11587 }
11588
11589 vos_pkt_reserve_head( vosDataBuff, ppvBDHeader,
11590 ucBDHeaderLen );
11591 if ( NULL == *ppvBDHeader )
11592 {
11593 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11594 "WLAN TL:VOSS packet corrupted on Attach BD header"));
11595 *pvosStatus = VOS_STATUS_E_INVAL;
11596 return;
11597 }
11598
11599 /*-----------------------------------------------------------------------
11600 Extract MAC address
11601 -----------------------------------------------------------------------*/
Jeff Johnson295189b2012-06-20 16:38:30 -070011602 {
11603 v_SIZE_t usMacAddrSize = VOS_MAC_ADDR_SIZE;
11604 *pvosStatus = vos_pkt_extract_data( vosDataBuff,
11605 ucBDHeaderLen +
11606 WLANTL_MAC_ADDR_ALIGN(ucDisableFrmXtl),
11607 (v_PVOID_t)pvDestMacAdddr,
11608 &usMacAddrSize );
11609 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011610 if ( VOS_STATUS_SUCCESS != *pvosStatus )
11611 {
11612 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11613 "WLAN TL:Failed while attempting to extract MAC Addr %d",
11614 *pvosStatus));
11615 }
11616 else
11617 {
11618 /*---------------------------------------------------------------------
11619 Fill MPDU info fields:
11620 - MPDU data start offset
11621 - MPDU header start offset
11622 - MPDU header length
11623 - MPDU length - this is a 16b field - needs swapping
11624 --------------------------------------------------------------------*/
11625 ucHeaderOffset = ucBDHeaderLen;
11626 ucHeaderLen = WLANTL_MAC_HEADER_LEN(ucDisableFrmXtl);
11627
11628 if ( 0 != ucDisableFrmXtl )
11629 {
11630 if ( 0 != ucQosEnabled )
11631 {
11632 ucHeaderLen += WLANTL_802_11_HEADER_QOS_CTL;
11633 }
11634
11635 // Similar to Qos we need something for WDS format !
11636 if ( ucWDSEnabled != 0 )
11637 {
11638 // If we have frame translation enabled
11639 ucHeaderLen += WLANTL_802_11_HEADER_ADDR4_LEN;
11640 }
11641 if ( extraHeadSpace != 0 )
11642 {
11643 // Decrease the packet length with the extra padding after the header
11644 *pusPktLen = *pusPktLen - extraHeadSpace;
11645 }
11646 }
11647
11648 WLANHAL_TX_BD_SET_MPDU_HEADER_LEN( *ppvBDHeader, ucHeaderLen);
11649 WLANHAL_TX_BD_SET_MPDU_HEADER_OFFSET( *ppvBDHeader, ucHeaderOffset);
11650 WLANHAL_TX_BD_SET_MPDU_DATA_OFFSET( *ppvBDHeader,
11651 ucHeaderOffset + ucHeaderLen + extraHeadSpace);
11652 WLANHAL_TX_BD_SET_MPDU_LEN( *ppvBDHeader, *pusPktLen);
11653
11654 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
11655 "WLAN TL: VALUES ARE HLen=%x Hoff=%x doff=%x len=%x ex=%d",
11656 ucHeaderLen, ucHeaderOffset,
11657 (ucHeaderOffset + ucHeaderLen + extraHeadSpace),
11658 *pusPktLen, extraHeadSpace));
11659 }/* if peek MAC success*/
11660
11661}/* WLANTL_PrepareBDHeader */
11662#endif
11663
Jeff Johnson295189b2012-06-20 16:38:30 -070011664//THIS IS A HACK AND NEEDS TO BE FIXED FOR CONCURRENCY
11665/*==========================================================================
11666 FUNCTION WLAN_TLGetNextTxIds
11667
11668 DESCRIPTION
11669 Gets the next station and next AC in the list that should be served by the TL.
11670
11671 Multiple Station Scheduling and TL queue management.
11672
11673 4 HDD BC/MC data packet queue status is specified as Station 0's status. Weights used
11674 in WFQ algorith are initialized in WLANTL_OPEN and contained in tlConfigInfo field.
11675 Each station has fields of ucPktPending and AC mask to tell whether a AC has traffic
11676 or not.
11677
11678 Stations are served in a round-robin fashion from highest priority to lowest priority.
11679 The number of round-robin times of each prioirty equals to the WFQ weights and differetiates
11680 the traffic of different prioirty. As such, stations can not provide low priority packets if
11681 high priority packets are all served.
11682
11683 DEPENDENCIES
11684
11685 PARAMETERS
11686
11687 IN
11688 pvosGCtx: pointer to the global vos context; a handle to TL's
11689 control block can be extracted from its context
11690
11691 OUT
11692 pucSTAId: Station ID
11693
11694 RETURN VALUE
11695 The result code associated with performing the operation
11696
11697 VOS_STATUS_SUCCESS: Everything is good
11698
11699 SIDE EFFECTS
11700
11701 TL context contains currently served station ID in ucCurrentSTA field, currently served AC
11702 in uCurServedAC field, and unserved weights of current AC in uCurLeftWeight.
11703 When existing from the function, these three fields are changed accordingly.
11704
11705============================================================================*/
11706VOS_STATUS
11707WLAN_TLAPGetNextTxIds
11708(
11709 v_PVOID_t pvosGCtx,
11710 v_U8_t* pucSTAId
11711)
11712{
11713 WLANTL_CbType* pTLCb;
11714 v_U8_t ucACFilter = 1;
Sravan Kumar Kairamb0edc612016-10-26 13:55:24 +053011715 v_U8_t ucNextSTA, ucTempSTA;
Jeff Johnson295189b2012-06-20 16:38:30 -070011716 v_BOOL_t isServed = TRUE; //current round has find a packet or not
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +053011717 v_U8_t ucACLoopNum = WLANTL_AC_HIGH_PRIO + 1; //number of loop to go
Jeff Johnson295189b2012-06-20 16:38:30 -070011718 v_U8_t uFlowMask; // TX FlowMask from WDA
11719 uint8 ucACMask;
Sravan Kumar Kairamb0edc612016-10-26 13:55:24 +053011720 uint8 i = 0;
11721 uint8 j;
Sravan Kumar Kairam18017eb2017-01-03 14:58:13 +053011722 uint8 minWeightSta;
11723 uint32_t sta_bitmask = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070011724 /*------------------------------------------------------------------------
11725 Extract TL control block
11726 ------------------------------------------------------------------------*/
11727 //ENTER();
11728
11729 pTLCb = VOS_GET_TL_CB(pvosGCtx);
11730 if ( NULL == pTLCb )
11731 {
11732 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11733 "WLAN TL:Invalid TL pointer from pvosGCtx on WLAN_TLAPGetNextTxIds"));
11734 return VOS_STATUS_E_FAULT;
11735 }
11736
11737 if ( VOS_STATUS_SUCCESS != WDA_DS_GetTxFlowMask( pvosGCtx, &uFlowMask ) )
11738 {
11739 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11740 "WLAN TL:Failed to retrieve Flow control mask from WDA"));
11741 return VOS_STATUS_E_FAULT;
11742 }
11743
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +053011744 /* The flow mask does not differentiate between different ACs/Qs
11745 * since we use a single dxe channel for all ACs/Qs, hence it is
11746 * enough to check that there are dxe resources on data channel
11747 */
11748 uFlowMask &= WLANTL_DATA_FLOW_MASK;
11749
11750 if (0 == uFlowMask)
11751 {
11752 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11753 "WLAN TL: No resources to send packets"));
11754
11755 // Setting STA Id to invalid if mask is 0
11756 *pucSTAId = WLAN_MAX_STA_COUNT;
11757 return VOS_STATUS_E_FAULT;
11758 }
11759
Jeff Johnson295189b2012-06-20 16:38:30 -070011760 ucNextSTA = pTLCb->ucCurrentSTA;
11761
11762 ++ucNextSTA;
11763
11764 if ( WLAN_MAX_STA_COUNT <= ucNextSTA )
Jeff Johnson295189b2012-06-20 16:38:30 -070011765 ucNextSTA = 0;
Sravan Kumar Kairam715072e2017-03-10 17:12:43 +053011766
Jeff Johnson295189b2012-06-20 16:38:30 -070011767 isServed = FALSE;
11768 if ( 0 == pTLCb->ucCurLeftWeight )
11769 {
11770 //current prioirty is done
11771 if ( WLANTL_AC_BK == (WLANTL_ACEnumType)pTLCb->uCurServedAC )
11772 {
11773 //end of current VO, VI, BE, BK loop. Reset priority.
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +053011774 pTLCb->uCurServedAC = WLANTL_AC_HIGH_PRIO;
Jeff Johnson295189b2012-06-20 16:38:30 -070011775 }
11776 else
11777 {
11778 pTLCb->uCurServedAC --;
11779 }
11780
11781 pTLCb->ucCurLeftWeight = pTLCb->tlConfigInfo.ucAcWeights[pTLCb->uCurServedAC];
11782
11783 } // (0 == pTLCb->ucCurLeftWeight)
Jeff Johnson295189b2012-06-20 16:38:30 -070011784
Sravan Kumar Kairamb0edc612016-10-26 13:55:24 +053011785 ucTempSTA = ucNextSTA;
Sravan Kumar Kairam18017eb2017-01-03 14:58:13 +053011786 minWeightSta = ucNextSTA;
Sravan Kumar Kairamb0edc612016-10-26 13:55:24 +053011787
Jeff Johnson295189b2012-06-20 16:38:30 -070011788 //decide how many loops to go. if current loop is partial, do one extra to make sure
11789 //we cover every station
11790 if ((1 == pTLCb->ucCurLeftWeight) && (ucNextSTA != 0))
11791 {
11792 ucACLoopNum ++; // now is 5 loops
11793 }
11794
11795 /* Start with highest priority. ucNextSTA, pTLCb->uCurServedAC, pTLCb->ucCurLeftWeight
11796 all have previous values.*/
11797 for (; ucACLoopNum > 0; ucACLoopNum--)
11798 {
11799
11800 ucACFilter = 1 << pTLCb->uCurServedAC;
11801
11802 // pTLCb->ucCurLeftWeight keeps previous results.
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +053011803 for (; (pTLCb->ucCurLeftWeight > 0) ; pTLCb->ucCurLeftWeight-- )
Jeff Johnson295189b2012-06-20 16:38:30 -070011804 {
11805
11806 for ( ; ucNextSTA < WLAN_MAX_STA_COUNT; ucNextSTA ++ )
11807 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053011808 if(NULL == pTLCb->atlSTAClients[ucNextSTA])
11809 {
11810 continue;
11811 }
11812 WLAN_TL_AC_ARRAY_2_MASK (pTLCb->atlSTAClients[ucNextSTA], ucACMask, i);
Jeff Johnson295189b2012-06-20 16:38:30 -070011813
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053011814 if ( (0 == pTLCb->atlSTAClients[ucNextSTA]->ucExists) ||
11815 ((0 == pTLCb->atlSTAClients[ucNextSTA]->ucPktPending) && !(ucACMask)) ||
Jeff Johnson295189b2012-06-20 16:38:30 -070011816 (0 == (ucACMask & ucACFilter)) )
11817
11818 {
Tushnim Bhattacharyya39a8f182013-02-20 18:10:30 -080011819 //current station does not exist or have any packet to serve.
11820 continue;
11821 }
11822
Bhargav Shahfbaeca22016-07-13 10:27:35 +053011823 if ((WLANTL_STA_AUTHENTICATED != pTLCb->atlSTAClients[ucNextSTA]->tlState)
11824 || (pTLCb->atlSTAClients[ucNextSTA]->disassoc_progress == VOS_TRUE ))
Tushnim Bhattacharyya39a8f182013-02-20 18:10:30 -080011825 {
11826 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
11827 "%s Sta %d not in auth state so skipping it.",
11828 __func__, ucNextSTA));
Jeff Johnson295189b2012-06-20 16:38:30 -070011829 continue;
11830 }
11831
11832 //go to next station if current station can't send due to flow control
11833 //Station is allowed to send when it is not in LWM mode. When station is in LWM mode,
11834 //station is allowed to send only after FW reports FW memory is below threshold and on-fly
11835 //packets are less then allowed value
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053011836 if ( (TRUE == pTLCb->atlSTAClients[ucNextSTA]->ucLwmModeEnabled) &&
11837 ((FALSE == pTLCb->atlSTAClients[ucNextSTA]->ucLwmEventReported) ||
11838 (0 < pTLCb->atlSTAClients[ucNextSTA]->uBuffThresholdMax))
Jeff Johnson295189b2012-06-20 16:38:30 -070011839 )
11840 {
11841 continue;
11842 }
11843
Sravan Kumar Kairamb0edc612016-10-26 13:55:24 +053011844 /*
11845 * Initial weight is 0 is for all the stations. As part of FW TX stats
11846 * indication to host, good peer weight is updated to one and the
11847 * remaining peers weight is updated based on their RA rates and BTQM
11848 * queued frames length. TL skips fetching the packet until the station
11849 * has got chances equal to its weight.
11850 */
11851 if (pTLCb->atlSTAClients[ucNextSTA]->weight > WLANTL_GOOD_STA_WEIGHT) {
11852 if (pTLCb->atlSTAClients[ucNextSTA]->weight_count <=
Sravan Kumar Kairam18017eb2017-01-03 14:58:13 +053011853 pTLCb->atlSTAClients[ucNextSTA]->weight)
11854 {
11855 if (pTLCb->atlSTAClients[minWeightSta]->weight <= 1)
11856 minWeightSta = ucNextSTA;
11857 else if (pTLCb->atlSTAClients[ucNextSTA]->weight <
11858 pTLCb->atlSTAClients[minWeightSta]->weight) {
11859 minWeightSta = ucNextSTA;
11860 }
11861 sta_bitmask |= (1 << ucNextSTA);
Sravan Kumar Kairamb0edc612016-10-26 13:55:24 +053011862 pTLCb->atlSTAClients[ucNextSTA]->weight_count++;
11863 continue;
11864 }
11865 else
11866 pTLCb->atlSTAClients[ucNextSTA]->weight_count = 0;
11867 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011868
11869 // Find a station. Weight is updated already.
11870 *pucSTAId = ucNextSTA;
11871 pTLCb->ucCurrentSTA = ucNextSTA;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053011872 pTLCb->atlSTAClients[*pucSTAId]->ucCurrentAC = pTLCb->uCurServedAC;
Jeff Johnson295189b2012-06-20 16:38:30 -070011873
11874 TLLOG4(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_LOW,
11875 " TL serve one station AC: %d W: %d StaId: %d",
11876 pTLCb->uCurServedAC, pTLCb->ucCurLeftWeight, pTLCb->ucCurrentSTA ));
11877
Sravan Kumar Kairam715072e2017-03-10 17:12:43 +053011878 pTLCb->ucCurLeftWeight--;
Jeff Johnson295189b2012-06-20 16:38:30 -070011879 return VOS_STATUS_SUCCESS;
11880 } //STA loop
11881
Sravan Kumar Kairamb0edc612016-10-26 13:55:24 +053011882 for (j = 0; j < ucTempSTA; j++) {
11883 if (NULL == pTLCb->atlSTAClients[j])
11884 continue;
11885
11886 WLAN_TL_AC_ARRAY_2_MASK (pTLCb->atlSTAClients[j], ucACMask, i);
11887
11888 if ((0 == pTLCb->atlSTAClients[j]->ucExists) ||
11889 ((0 == pTLCb->atlSTAClients[j]->ucPktPending) && !(ucACMask)) ||
11890 (0 == (ucACMask & ucACFilter)))
11891 continue;
11892
11893 if ((WLANTL_STA_AUTHENTICATED != pTLCb->atlSTAClients[j]->tlState) ||
11894 (pTLCb->atlSTAClients[j]->disassoc_progress == VOS_TRUE)) {
11895 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
11896 "%s Sta %d not in auth state so skipping it.",
11897 __func__, ucNextSTA));
11898 continue;
11899 }
11900
11901 if ((TRUE == pTLCb->atlSTAClients[j]->ucLwmModeEnabled) &&
11902 ((FALSE == pTLCb->atlSTAClients[j]->ucLwmEventReported) ||
11903 (0 < pTLCb->atlSTAClients[j]->uBuffThresholdMax)))
11904 continue;
11905
11906 if (pTLCb->atlSTAClients[j]->weight > WLANTL_GOOD_STA_WEIGHT) {
11907 if (pTLCb->atlSTAClients[j]->weight_count <=
Sravan Kumar Kairam18017eb2017-01-03 14:58:13 +053011908 pTLCb->atlSTAClients[j]->weight)
11909 {
11910 if (pTLCb->atlSTAClients[minWeightSta]->weight <= 1)
11911 minWeightSta = j;
11912 else if (pTLCb->atlSTAClients[j]->weight <
11913 pTLCb->atlSTAClients[minWeightSta]->weight) {
11914 minWeightSta = j;
11915 }
11916 sta_bitmask |= (1 << j);
Sravan Kumar Kairamb0edc612016-10-26 13:55:24 +053011917 pTLCb->atlSTAClients[j]->weight_count++;
11918 continue;
11919 }
11920 else
11921 pTLCb->atlSTAClients[j]->weight_count = 0;
11922 }
11923
11924 *pucSTAId = j;
11925 pTLCb->ucCurrentSTA = j;
11926 pTLCb->atlSTAClients[*pucSTAId]->ucCurrentAC = pTLCb->uCurServedAC;
11927
11928 TLLOG4(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_LOW,
11929 " TL serve one station AC: %d W: %d StaId: %d",
11930 pTLCb->uCurServedAC, pTLCb->ucCurLeftWeight, pTLCb->ucCurrentSTA ));
Sravan Kumar Kairam715072e2017-03-10 17:12:43 +053011931 pTLCb->ucCurLeftWeight--;
Sravan Kumar Kairamb0edc612016-10-26 13:55:24 +053011932 return VOS_STATUS_SUCCESS;
11933 }
11934
Sravan Kumar Kairam18017eb2017-01-03 14:58:13 +053011935 /* Fecth packet from the stations with minimum weight among them */
11936 if (pTLCb->atlSTAClients[minWeightSta] &&
11937 pTLCb->atlSTAClients[minWeightSta]->ucPktPending)
11938 {
11939 *pucSTAId = minWeightSta;
11940 pTLCb->ucCurrentSTA = minWeightSta;
11941 pTLCb->atlSTAClients[*pucSTAId]->ucCurrentAC = pTLCb->uCurServedAC;
11942
11943 for (j = 0; sta_bitmask != 0; sta_bitmask >>= 1, j++)
11944 {
11945 if (0 == (sta_bitmask & 0x1))
11946 continue;
11947
11948 if (minWeightSta == j)
11949 continue;
11950 /* To ensure fairness between stations */
11951 pTLCb->atlSTAClients[j]->weight_count +=
11952 pTLCb->atlSTAClients[minWeightSta]->weight -
11953 pTLCb->atlSTAClients[minWeightSta]->weight_count;
11954 }
11955 pTLCb->atlSTAClients[minWeightSta]->weight_count = 0;
11956
11957 TLLOG4(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_LOW,
11958 " TL serve one station AC: %d W: %d StaId: %d",
11959 pTLCb->uCurServedAC, pTLCb->ucCurLeftWeight, pTLCb->ucCurrentSTA ));
Sravan Kumar Kairam715072e2017-03-10 17:12:43 +053011960 pTLCb->ucCurLeftWeight--;
Sravan Kumar Kairam18017eb2017-01-03 14:58:13 +053011961 return VOS_STATUS_SUCCESS;
11962 }
11963
Jeff Johnson295189b2012-06-20 16:38:30 -070011964 ucNextSTA = 0;
11965 if ( FALSE == isServed )
11966 {
11967 //current loop finds no packet.no need to repeat for the same priority
11968 break;
11969 }
11970 //current loop is partial loop. go for one more loop.
11971 isServed = FALSE;
11972
11973 } //Weight loop
11974
11975 if (WLANTL_AC_BK == pTLCb->uCurServedAC)
11976 {
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +053011977 pTLCb->uCurServedAC = WLANTL_AC_HIGH_PRIO;
Jeff Johnson295189b2012-06-20 16:38:30 -070011978 }
11979 else
11980 {
11981 pTLCb->uCurServedAC--;
11982 }
11983 pTLCb->ucCurLeftWeight = pTLCb->tlConfigInfo.ucAcWeights[pTLCb->uCurServedAC];
11984
11985 }// AC loop
11986
11987 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
Arif Hussainf2b00992013-11-17 21:46:15 -080011988 " TL can't find one station to serve" ));
Jeff Johnson295189b2012-06-20 16:38:30 -070011989
11990 pTLCb->uCurServedAC = WLANTL_AC_BK;
11991 pTLCb->ucCurLeftWeight = 1;
11992 //invalid number will be captured by caller
11993 pTLCb->ucCurrentSTA = WLAN_MAX_STA_COUNT;
11994
11995 *pucSTAId = pTLCb->ucCurrentSTA;
Jeff Johnson295189b2012-06-20 16:38:30 -070011996 return VOS_STATUS_E_FAULT;
11997}
11998
11999
12000/*==========================================================================
12001 FUNCTION WLAN_TLGetNextTxIds
12002
12003 DESCRIPTION
12004 Gets the next station and next AC in the list
12005
12006 DEPENDENCIES
12007
12008 PARAMETERS
12009
12010 IN
12011 pvosGCtx: pointer to the global vos context; a handle to TL's
12012 control block can be extracted from its context
12013
12014 OUT
12015 pucSTAId: Station ID
12016
12017
12018 RETURN VALUE
12019 The result code associated with performing the operation
12020
12021 VOS_STATUS_SUCCESS: Everything is good :)
12022
12023 SIDE EFFECTS
12024
12025============================================================================*/
12026VOS_STATUS
12027WLAN_TLGetNextTxIds
12028(
12029 v_PVOID_t pvosGCtx,
12030 v_U8_t* pucSTAId
12031)
12032{
12033 WLANTL_CbType* pTLCb;
12034 v_U8_t ucNextAC;
12035 v_U8_t ucNextSTA;
12036 v_U8_t ucCount;
12037 v_U8_t uFlowMask; // TX FlowMask from WDA
12038 v_U8_t ucACMask = 0;
12039 v_U8_t i = 0;
12040
12041 tBssSystemRole systemRole; //RG HACK to be removed
12042 tpAniSirGlobal pMac;
12043
12044 pMac = vos_get_context(VOS_MODULE_ID_PE, pvosGCtx);
12045 if ( NULL == pMac )
12046 {
12047 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070012048 "%s: Invalid pMac", __func__));
Jeff Johnson295189b2012-06-20 16:38:30 -070012049 return VOS_STATUS_E_FAULT;
12050 }
12051
12052 systemRole = wdaGetGlobalSystemRole(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -070012053
Jeff Johnson295189b2012-06-20 16:38:30 -070012054 /*------------------------------------------------------------------------
12055 Extract TL control block
12056 ------------------------------------------------------------------------*/
12057 pTLCb = VOS_GET_TL_CB(pvosGCtx);
12058 if ( NULL == pTLCb )
12059 {
12060 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
12061 "WLAN TL:Invalid TL pointer from pvosGCtx on WLAN_TLGetNextTxIds"));
12062 return VOS_STATUS_E_FAULT;
12063 }
12064
Sunil Ravid5406f22013-01-22 00:18:31 -080012065#ifdef FEATURE_WLAN_TDLS
Agarwal Ashishcd86f7b2014-06-16 17:11:58 +053012066 if ((eSYSTEM_AP_ROLE == systemRole) ||
Katya Nigam1fd24402015-02-16 14:52:19 +053012067 (eSYSTEM_STA_IN_IBSS_ROLE == systemRole) ||
Agarwal Ashishcd86f7b2014-06-16 17:11:58 +053012068 (vos_concurrent_open_sessions_running()) || pTLCb->ucTdlsPeerCount)
Sunil Ravid5406f22013-01-22 00:18:31 -080012069#else
Agarwal Ashishcd86f7b2014-06-16 17:11:58 +053012070 if ((eSYSTEM_AP_ROLE == systemRole) ||
Katya Nigam1fd24402015-02-16 14:52:19 +053012071 (eSYSTEM_STA_IN_IBSS_ROLE == systemRole) ||
Agarwal Ashishcd86f7b2014-06-16 17:11:58 +053012072 (vos_concurrent_open_sessions_running()))
Sunil Ravid5406f22013-01-22 00:18:31 -080012073#endif
12074 {
12075 return WLAN_TLAPGetNextTxIds(pvosGCtx,pucSTAId);
12076 }
12077
12078
Jeff Johnson295189b2012-06-20 16:38:30 -070012079 if ( VOS_STATUS_SUCCESS != WDA_DS_GetTxFlowMask( pvosGCtx, &uFlowMask ) )
12080 {
12081 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
12082 "WLAN TL:Failed to retrieve Flow control mask from WDA"));
12083 return VOS_STATUS_E_FAULT;
12084 }
12085
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +053012086 /* The flow mask does not differentiate between different ACs/Qs
12087 * since we use a single dxe channel for all ACs/Qs, hence it is
12088 * enough to check that there are dxe resources on data channel
12089 */
12090 uFlowMask &= WLANTL_DATA_FLOW_MASK;
12091
12092 if (0 == uFlowMask)
12093 {
12094 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
12095 "WLAN TL: No resources to send packets"));
12096
12097 // Setting STA id to invalid if mask is 0
12098 *pucSTAId = WLAN_MAX_STA_COUNT;
12099 return VOS_STATUS_E_FAULT;
12100 }
12101
Jeff Johnson295189b2012-06-20 16:38:30 -070012102 /*STA id - no priority yet implemented */
12103 /*-----------------------------------------------------------------------
12104 Choose the next STA for tx - for now go in a round robin fashion
12105 through all the stations that have pending packets
12106 -------------------------------------------------------------------------*/
12107 ucNextSTA = pTLCb->ucCurrentSTA;
12108
12109 pTLCb->ucCurrentSTA = WLAN_MAX_STA_COUNT;
12110 for ( ucCount = 0;
12111 ucCount < WLAN_MAX_STA_COUNT;
12112 ucCount++ )
12113 {
12114 ucNextSTA = ( (ucNextSTA+1) >= WLAN_MAX_STA_COUNT )?0:(ucNextSTA+1);
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053012115 if(NULL == pTLCb->atlSTAClients[ucNextSTA])
12116 {
12117 continue;
12118 }
Sravan Kumar Kairamb0edc612016-10-26 13:55:24 +053012119
12120 if ((pTLCb->atlSTAClients[ucNextSTA]->weight > WLANTL_GOOD_STA_WEIGHT) &&
12121 (pTLCb->atlSTAClients[ucNextSTA]->ucPktPending)) {
12122 if (pTLCb->atlSTAClients[ucNextSTA]->weight_count <=
12123 pTLCb->atlSTAClients[ucNextSTA]->weight) {
12124 pTLCb->atlSTAClients[ucNextSTA]->weight_count++;
12125 continue;
12126 }
12127 else
12128 pTLCb->atlSTAClients[ucNextSTA]->weight_count = 0;
12129 }
12130
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053012131 if (( pTLCb->atlSTAClients[ucNextSTA]->ucExists ) &&
12132 ( pTLCb->atlSTAClients[ucNextSTA]->ucPktPending ))
Jeff Johnson295189b2012-06-20 16:38:30 -070012133 {
Tushnim Bhattacharyya39a8f182013-02-20 18:10:30 -080012134 if (WLANTL_STA_AUTHENTICATED == pTLCb->atlSTAClients[ucNextSTA]->tlState)
12135 {
12136 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
12137 "STA ID: %d on WLAN_TLGetNextTxIds", *pucSTAId));
12138 pTLCb->ucCurrentSTA = ucNextSTA;
12139 break;
Tushnim Bhattacharyya5dd94562013-03-20 20:15:03 -070012140 }
12141 else
12142 {
Tushnim Bhattacharyya39a8f182013-02-20 18:10:30 -080012143 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
12144 "%s Sta %d is not in auth state, skipping this sta.",
12145 __func__, ucNextSTA));
Tushnim Bhattacharyya5dd94562013-03-20 20:15:03 -070012146 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012147 }
12148 }
12149
12150 *pucSTAId = pTLCb->ucCurrentSTA;
12151
12152 if ( WLANTL_STA_ID_INVALID( *pucSTAId ) )
12153 {
12154 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
12155 "WLAN TL:No station registered with TL at this point"));
12156
12157 return VOS_STATUS_E_FAULT;
12158
12159 }
12160
12161 /*Convert the array to a mask for easier operation*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053012162 WLAN_TL_AC_ARRAY_2_MASK( pTLCb->atlSTAClients[*pucSTAId], ucACMask, i);
Jeff Johnson295189b2012-06-20 16:38:30 -070012163
12164 if ( 0 == ucACMask )
12165 {
12166 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
12167 "WLAN TL: Mask 0 "
12168 "STA ID: %d on WLAN_TLGetNextTxIds", *pucSTAId));
12169
12170 /*setting STA id to invalid if mask is 0*/
12171 *pucSTAId = WLAN_MAX_STA_COUNT;
12172
12173 return VOS_STATUS_E_FAULT;
12174 }
12175
12176 /*-----------------------------------------------------------------------
12177 AC is updated whenever a packet is fetched from HDD -> the current
12178 weight of such an AC cannot be 0 -> in this case TL is expected to
12179 exit this function at this point during the main Tx loop
12180 -----------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053012181 if ( 0 < pTLCb->atlSTAClients[*pucSTAId]->ucCurrentWeight )
Jeff Johnson295189b2012-06-20 16:38:30 -070012182 {
12183 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
12184 "WLAN TL: Maintaining serviced AC to: %d for Weight: %d",
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053012185 pTLCb->atlSTAClients[*pucSTAId]->ucCurrentAC ,
12186 pTLCb->atlSTAClients[*pucSTAId]->ucCurrentWeight));
Jeff Johnson295189b2012-06-20 16:38:30 -070012187 return VOS_STATUS_SUCCESS;
12188 }
12189
12190 /*-----------------------------------------------------------------------
12191 Choose highest priority AC - !!! optimize me
12192 -----------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053012193 ucNextAC = pTLCb->atlSTAClients[*pucSTAId]->ucCurrentAC;
Jeff Johnson295189b2012-06-20 16:38:30 -070012194 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
12195 "Next AC: %d", ucNextAC));
12196
12197 while ( 0 != ucACMask )
12198 {
12199 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
12200 " AC Mask: %d Next: %d Res : %d",
12201 ucACMask, ( 1 << ucNextAC ), ( ucACMask & ( 1 << ucNextAC ))));
12202
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +053012203 if ( 0 != ( ucACMask & ( 1 << ucNextAC )))
Jeff Johnson295189b2012-06-20 16:38:30 -070012204 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053012205 pTLCb->atlSTAClients[*pucSTAId]->ucCurrentAC =
Jeff Johnson295189b2012-06-20 16:38:30 -070012206 (WLANTL_ACEnumType)ucNextAC;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053012207 pTLCb->atlSTAClients[*pucSTAId]->ucCurrentWeight =
Jeff Johnson295189b2012-06-20 16:38:30 -070012208 pTLCb->tlConfigInfo.ucAcWeights[ucNextAC];
12209
12210 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
12211 "WLAN TL: Switching serviced AC to: %d with Weight: %d",
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053012212 pTLCb->atlSTAClients[*pucSTAId]->ucCurrentAC ,
12213 pTLCb->atlSTAClients[*pucSTAId]->ucCurrentWeight));
Jeff Johnson295189b2012-06-20 16:38:30 -070012214 break;
12215 }
12216
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +053012217 if (ucNextAC == WLANTL_AC_BK)
12218 ucNextAC = WLANTL_AC_HIGH_PRIO;
12219 else
12220 ucNextAC--;
Jeff Johnson295189b2012-06-20 16:38:30 -070012221
12222 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
12223 "Next AC %d", ucNextAC));
Jeff Johnson295189b2012-06-20 16:38:30 -070012224 }
12225
12226 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
12227 " C AC: %d C W: %d",
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053012228 pTLCb->atlSTAClients[*pucSTAId]->ucCurrentAC,
12229 pTLCb->atlSTAClients[*pucSTAId]->ucCurrentWeight));
Jeff Johnson295189b2012-06-20 16:38:30 -070012230
12231 return VOS_STATUS_SUCCESS;
12232}/* WLAN_TLGetNextTxIds */
12233
Jeff Johnson295189b2012-06-20 16:38:30 -070012234
12235
12236/*==========================================================================
12237 DEFAULT HANDLERS: Registered at initialization with TL
12238 ==========================================================================*/
12239
12240/*==========================================================================
12241
12242 FUNCTION WLANTL_MgmtFrmRxDefaultCb
12243
12244 DESCRIPTION
12245 Default Mgmt Frm rx callback: asserts all the time. If this function gets
12246 called it means there is no registered rx cb pointer for Mgmt Frm.
12247
12248 DEPENDENCIES
12249
12250 PARAMETERS
12251 Not used.
12252
12253 RETURN VALUE
12254
12255 VOS_STATUS_E_FAILURE: Always FAILURE.
12256
12257============================================================================*/
12258VOS_STATUS
12259WLANTL_MgmtFrmRxDefaultCb
12260(
12261 v_PVOID_t pvosGCtx,
12262 v_PVOID_t vosBuff
12263)
12264{
12265 if ( NULL != vosBuff )
12266 {
12267 TLLOGP(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_FATAL,
12268 "WLAN TL:Fatal failure: No registered Mgmt Frm client on pkt RX"));
12269 /* Drop packet */
12270 vos_pkt_return_packet((vos_pkt_t *)vosBuff);
12271 }
12272
Jeff Johnson295189b2012-06-20 16:38:30 -070012273 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
12274 "WLAN TL: No registered Mgmt Frm client on pkt RX. Load/Unload in progress, Ignore"));
Jeff Johnson295189b2012-06-20 16:38:30 -070012275
12276 return VOS_STATUS_E_FAILURE;
12277}/*WLANTL_MgmtFrmRxDefaultCb*/
12278
12279/*==========================================================================
12280
Madan Mohan Koyyalamudi6c2977d2013-09-04 15:42:45 +053012281 FUNCTION WLANTL_BAPRxDefaultCb
Jeff Johnson295189b2012-06-20 16:38:30 -070012282
12283 DESCRIPTION
12284 Default BAP rx callback: asserts all the time. If this function gets
12285 called it means there is no registered rx cb pointer for BAP.
12286
12287 DEPENDENCIES
12288
12289 PARAMETERS
12290 Not used.
12291
12292 RETURN VALUE
12293
12294 VOS_STATUS_E_FAILURE: Always FAILURE.
12295
12296============================================================================*/
12297VOS_STATUS
12298WLANTL_BAPRxDefaultCb
12299(
12300 v_PVOID_t pvosGCtx,
12301 vos_pkt_t* vosDataBuff,
12302 WLANTL_BAPFrameEnumType frameType
12303)
12304{
12305 TLLOGP(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_FATAL,
12306 "WLAN TL:Fatal failure: No registered BAP client on BAP pkt RX"));
12307#ifndef BTAMP_TEST
12308 VOS_ASSERT(0);
12309#endif
12310 return VOS_STATUS_E_FAILURE;
12311}/*WLANTL_MgmtFrmRxDefaultCb*/
12312
12313/*==========================================================================
12314
12315 FUNCTION WLANTL_STARxDefaultCb
12316
12317 DESCRIPTION
12318 Default STA rx callback: asserts all the time. If this function gets
12319 called it means there is no registered rx cb pointer for station.
12320 (Mem corruption most likely, it should never happen)
12321
12322 DEPENDENCIES
12323
12324 PARAMETERS
12325 Not used.
12326
12327 RETURN VALUE
12328
12329 VOS_STATUS_E_FAILURE: Always FAILURE.
12330
12331============================================================================*/
12332VOS_STATUS
12333WLANTL_STARxDefaultCb
12334(
12335 v_PVOID_t pvosGCtx,
12336 vos_pkt_t* vosDataBuff,
12337 v_U8_t ucSTAId,
12338 WLANTL_RxMetaInfoType* pRxMetaInfo
12339)
12340{
12341 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
12342 "WLAN TL: No registered STA client rx cb for STAID: %d dropping pkt",
12343 ucSTAId));
12344 vos_pkt_return_packet(vosDataBuff);
Madan Mohan Koyyalamudi6c2977d2013-09-04 15:42:45 +053012345 return VOS_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012346}/*WLANTL_MgmtFrmRxDefaultCb*/
12347
12348
12349/*==========================================================================
12350
12351 FUNCTION WLANTL_STAFetchPktDefaultCb
12352
12353 DESCRIPTION
12354 Default fetch callback: asserts all the time. If this function gets
12355 called it means there is no registered fetch cb pointer for station.
12356 (Mem corruption most likely, it should never happen)
12357
12358 DEPENDENCIES
12359
12360 PARAMETERS
12361 Not used.
12362
12363 RETURN VALUE
12364
12365 VOS_STATUS_E_FAILURE: Always FAILURE.
12366
12367============================================================================*/
12368VOS_STATUS
12369WLANTL_STAFetchPktDefaultCb
12370(
12371 v_PVOID_t pvosGCtx,
12372 v_U8_t* pucSTAId,
12373 WLANTL_ACEnumType ucAC,
12374 vos_pkt_t** vosDataBuff,
12375 WLANTL_MetaInfoType* tlMetaInfo
12376)
12377{
12378 TLLOGP(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_FATAL,
12379 "WLAN TL:Fatal failure: No registered STA client on data pkt RX"));
12380 VOS_ASSERT(0);
12381 return VOS_STATUS_E_FAILURE;
12382}/*WLANTL_MgmtFrmRxDefaultCb*/
12383
12384/*==========================================================================
12385
12386 FUNCTION WLANTL_TxCompDefaultCb
12387
12388 DESCRIPTION
12389 Default tx complete handler. It will release the completed pkt to
12390 prevent memory leaks.
12391
12392 PARAMETERS
12393
12394 IN
12395 pvosGCtx: pointer to the global vos context; a handle to
12396 TL/HAL/PE/BAP/HDD control block can be extracted from
12397 its context
12398 vosDataBuff: pointer to the VOSS data buffer that was transmitted
12399 wTxSTAtus: status of the transmission
12400
12401
12402 RETURN VALUE
12403 The result code associated with performing the operation; please
12404 check vos_pkt_return_packet for possible error codes.
12405
12406 Please check vos_pkt_return_packet API for possible return values.
12407
12408============================================================================*/
12409VOS_STATUS
12410WLANTL_TxCompDefaultCb
12411(
12412 v_PVOID_t pvosGCtx,
12413 vos_pkt_t* vosDataBuff,
12414 VOS_STATUS wTxSTAtus
12415)
12416{
12417 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
12418 "WLAN TL:TXComp not registered, releasing pkt to prevent mem leak"));
12419 return vos_pkt_return_packet(vosDataBuff);
12420}/*WLANTL_TxCompDefaultCb*/
12421
12422
12423/*==========================================================================
12424 Cleanup functions
12425 ==========================================================================*/
12426
12427/*==========================================================================
12428
12429 FUNCTION WLANTL_CleanCB
12430
12431 DESCRIPTION
12432 Cleans TL control block
12433
12434 DEPENDENCIES
12435
12436 PARAMETERS
12437
12438 IN
12439 pTLCb: pointer to TL's control block
12440 ucEmpty: set if TL has to clean up the queues and release pedning pkts
12441
12442 RETURN VALUE
12443 The result code associated with performing the operation
12444
12445 VOS_STATUS_E_INVAL: invalid input parameters
12446 VOS_STATUS_SUCCESS: Everything is good :)
12447
12448 SIDE EFFECTS
12449
12450============================================================================*/
12451VOS_STATUS
12452WLANTL_CleanCB
12453(
12454 WLANTL_CbType* pTLCb,
12455 v_U8_t ucEmpty
12456)
12457{
12458 v_U8_t ucIndex;
12459 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
12460
12461 /*-------------------------------------------------------------------------
12462 Sanity check
12463 -------------------------------------------------------------------------*/
12464 if ( NULL == pTLCb )
12465 {
12466 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
12467 "WLAN TL:Invalid parameter sent on WLANTL_CleanCB"));
12468 return VOS_STATUS_E_INVAL;
12469 }
12470
12471 /* number of packets sent to BAL waiting for tx complete confirmation */
12472 pTLCb->usPendingTxCompleteCount = 0;
12473
12474 /* global suspend flag */
12475 vos_atomic_set_U8( &pTLCb->ucTxSuspended, 1);
12476
12477 /* resource flag */
12478 pTLCb->uResCount = 0;
12479
12480
12481 /*-------------------------------------------------------------------------
12482 Client stations
12483 -------------------------------------------------------------------------*/
12484 for ( ucIndex = 0; ucIndex < WLAN_MAX_STA_COUNT ; ucIndex++)
12485 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053012486 if(NULL != pTLCb->atlSTAClients[ucIndex])
12487 {
12488 WLANTL_CleanSTA( pTLCb->atlSTAClients[ucIndex], ucEmpty);
12489 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012490 }
12491
12492 /*-------------------------------------------------------------------------
12493 Management Frame client
12494 -------------------------------------------------------------------------*/
12495 pTLCb->tlMgmtFrmClient.ucExists = 0;
12496
12497 if ( ( 0 != ucEmpty) &&
12498 ( NULL != pTLCb->tlMgmtFrmClient.vosPendingDataBuff ))
12499 {
12500 vos_pkt_return_packet(pTLCb->tlMgmtFrmClient.vosPendingDataBuff);
12501 }
12502
12503 pTLCb->tlMgmtFrmClient.vosPendingDataBuff = NULL;
12504
12505 /* set to a default cb in order to prevent constant checking for NULL */
12506 pTLCb->tlMgmtFrmClient.pfnTlMgmtFrmRx = WLANTL_MgmtFrmRxDefaultCb;
12507
12508 /*-------------------------------------------------------------------------
12509 BT AMP client
12510 -------------------------------------------------------------------------*/
12511 pTLCb->tlBAPClient.ucExists = 0;
12512
12513 if (( 0 != ucEmpty) &&
12514 ( NULL != pTLCb->tlBAPClient.vosPendingDataBuff ))
12515 {
12516 vos_pkt_return_packet(pTLCb->tlBAPClient.vosPendingDataBuff);
12517 }
12518
12519 if (( 0 != ucEmpty) &&
12520 ( NULL != pTLCb->vosDummyBuf ))
12521 {
12522 vos_pkt_return_packet(pTLCb->vosDummyBuf);
12523 }
12524
12525 pTLCb->tlBAPClient.vosPendingDataBuff = NULL;
12526
12527 pTLCb->vosDummyBuf = NULL;
12528 pTLCb->vosTempBuf = NULL;
12529 pTLCb->ucCachedSTAId = WLAN_MAX_STA_COUNT;
12530
12531 /* set to a default cb in order to prevent constant checking for NULL */
12532 pTLCb->tlBAPClient.pfnTlBAPRx = WLANTL_BAPRxDefaultCb;
12533
12534 pTLCb->ucRegisteredStaId = WLAN_MAX_STA_COUNT;
12535
12536 return VOS_STATUS_SUCCESS;
12537
12538}/* WLANTL_CleanCB*/
12539
12540/*==========================================================================
12541
12542 FUNCTION WLANTL_CleanSTA
12543
12544 DESCRIPTION
12545 Cleans a station control block.
12546
12547 DEPENDENCIES
12548
12549 PARAMETERS
12550
12551 IN
12552 pvosGCtx: pointer to the global vos context; a handle to TL's
12553 control block can be extracted from its context
12554 ucEmpty: if set the queues and pending pkts will be emptyed
12555
12556 RETURN VALUE
12557 The result code associated with performing the operation
12558
12559 VOS_STATUS_E_INVAL: invalid input parameters
12560 VOS_STATUS_SUCCESS: Everything is good :)
12561
12562 SIDE EFFECTS
12563
12564============================================================================*/
12565VOS_STATUS
12566WLANTL_CleanSTA
12567(
12568 WLANTL_STAClientType* ptlSTAClient,
12569 v_U8_t ucEmpty
12570)
12571{
12572 v_U8_t ucIndex;
12573 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
12574
12575 /*-------------------------------------------------------------------------
12576 Sanity check
12577 -------------------------------------------------------------------------*/
12578 if ( NULL == ptlSTAClient )
12579 {
12580 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
12581 "WLAN TL:Invalid parameter sent on WLANTL_CleanSTA"));
12582 return VOS_STATUS_E_INVAL;
12583 }
12584
12585 /*------------------------------------------------------------------------
12586 Clear station from TL
12587 ------------------------------------------------------------------------*/
12588 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
12589 "WLAN TL: Clearing STA Client ID: %d, Empty flag: %d",
12590 ptlSTAClient->wSTADesc.ucSTAId, ucEmpty ));
12591
12592 ptlSTAClient->pfnSTARx = WLANTL_STARxDefaultCb;
12593 ptlSTAClient->pfnSTATxComp = WLANTL_TxCompDefaultCb;
12594 ptlSTAClient->pfnSTAFetchPkt = WLANTL_STAFetchPktDefaultCb;
12595
12596 ptlSTAClient->tlState = WLANTL_STA_INIT;
12597 ptlSTAClient->tlPri = WLANTL_STA_PRI_NORMAL;
12598
12599 vos_zero_macaddr( &ptlSTAClient->wSTADesc.vSTAMACAddress );
12600 vos_zero_macaddr( &ptlSTAClient->wSTADesc.vBSSIDforIBSS );
12601 vos_zero_macaddr( &ptlSTAClient->wSTADesc.vSelfMACAddress );
12602
12603 ptlSTAClient->wSTADesc.ucSTAId = 0;
12604 ptlSTAClient->wSTADesc.wSTAType = WLAN_STA_MAX;
12605
12606 ptlSTAClient->wSTADesc.ucQosEnabled = 0;
12607 ptlSTAClient->wSTADesc.ucAddRmvLLC = 0;
12608 ptlSTAClient->wSTADesc.ucSwFrameTXXlation = 0;
12609 ptlSTAClient->wSTADesc.ucSwFrameRXXlation = 0;
12610 ptlSTAClient->wSTADesc.ucProtectedFrame = 0;
Bhargav Shahfbaeca22016-07-13 10:27:35 +053012611 ptlSTAClient->disassoc_progress = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070012612 /*-------------------------------------------------------------------------
12613 AMSDU information for the STA
12614 -------------------------------------------------------------------------*/
12615 if ( ( 0 != ucEmpty ) &&
12616 ( NULL != ptlSTAClient->vosAMSDUChainRoot ))
12617 {
Madan Mohan Koyyalamudic0e5bd82012-09-18 17:12:27 -070012618 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_FATAL,
Jeff Johnson0298bd02013-11-14 19:58:38 -080012619 "WLAN TL:Non NULL vosAMSDUChainRoot on WLANTL_CleanSTA, "
Madan Mohan Koyyalamudic0e5bd82012-09-18 17:12:27 -070012620 "suspecting a memory corruption"));
12621
Jeff Johnson295189b2012-06-20 16:38:30 -070012622 }
12623
12624 ptlSTAClient->vosAMSDUChain = NULL;
12625 ptlSTAClient->vosAMSDUChainRoot = NULL;
12626
12627 vos_mem_zero( (v_PVOID_t)ptlSTAClient->aucMPDUHeader,
12628 WLANTL_MPDU_HEADER_LEN);
12629 ptlSTAClient->ucMPDUHeaderLen = 0;
12630
12631 /*-------------------------------------------------------------------------
12632 Reordering information for the STA
12633 -------------------------------------------------------------------------*/
12634 for ( ucIndex = 0; ucIndex < WLAN_MAX_TID ; ucIndex++)
12635 {
12636 if(0 == ptlSTAClient->atlBAReorderInfo[ucIndex].ucExists)
12637 {
12638 continue;
12639 }
12640 if(NULL != ptlSTAClient->atlBAReorderInfo[ucIndex].reorderBuffer)
12641 {
12642 ptlSTAClient->atlBAReorderInfo[ucIndex].reorderBuffer->isAvailable = VOS_TRUE;
12643 memset(&ptlSTAClient->atlBAReorderInfo[ucIndex].reorderBuffer->arrayBuffer[0], 0, WLANTL_MAX_WINSIZE * sizeof(v_PVOID_t));
12644 }
12645 vos_timer_destroy(&ptlSTAClient->atlBAReorderInfo[ucIndex].agingTimer);
12646 memset(&ptlSTAClient->atlBAReorderInfo[ucIndex], 0, sizeof(WLANTL_BAReorderType));
12647 }
12648
12649 /*-------------------------------------------------------------------------
12650 QOS information for the STA
12651 -------------------------------------------------------------------------*/
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +053012652 ptlSTAClient->ucCurrentAC = WLANTL_AC_HIGH_PRIO;
Jeff Johnson295189b2012-06-20 16:38:30 -070012653 ptlSTAClient->ucCurrentWeight = 0;
12654 ptlSTAClient->ucServicedAC = WLANTL_AC_BK;
12655
12656 vos_mem_zero( ptlSTAClient->aucACMask, sizeof(ptlSTAClient->aucACMask));
12657 vos_mem_zero( &ptlSTAClient->wUAPSDInfo, sizeof(ptlSTAClient->wUAPSDInfo));
12658
12659
12660 /*--------------------------------------------------------------------
12661 Stats info
12662 --------------------------------------------------------------------*/
12663 vos_mem_zero( ptlSTAClient->auRxCount,
12664 sizeof(ptlSTAClient->auRxCount[0])* WLAN_MAX_TID);
12665 vos_mem_zero( ptlSTAClient->auTxCount,
12666 sizeof(ptlSTAClient->auTxCount[0])* WLAN_MAX_TID);
12667 ptlSTAClient->rssiAvg = 0;
12668
12669 /*Tx not suspended and station fully registered*/
12670 vos_atomic_set_U8( &ptlSTAClient->ucTxSuspended, 0);
12671 vos_atomic_set_U8( &ptlSTAClient->ucNoMoreData, 1);
12672
12673 if ( 0 == ucEmpty )
12674 {
12675 ptlSTAClient->wSTADesc.ucUcastSig = WLAN_TL_INVALID_U_SIG;
12676 ptlSTAClient->wSTADesc.ucBcastSig = WLAN_TL_INVALID_B_SIG;
12677 }
12678
12679 ptlSTAClient->ucExists = 0;
12680
12681 /*--------------------------------------------------------------------
12682 Statistics info
12683 --------------------------------------------------------------------*/
12684 memset(&ptlSTAClient->trafficStatistics,
12685 0,
12686 sizeof(WLANTL_TRANSFER_STA_TYPE));
12687
12688 /*fix me!!: add new values from the TL Cb for cleanup */
12689 return VOS_STATUS_SUCCESS;
12690}/* WLANTL_CleanSTA */
12691
12692
12693/*==========================================================================
12694 FUNCTION WLANTL_EnableUAPSDForAC
12695
12696 DESCRIPTION
12697 Called by HDD to enable UAPSD. TL in turn calls WDA API to enable the
12698 logic in FW/SLM to start sending trigger frames. Previously TL had the
12699 trigger frame logic which later moved down to FW. Hence
12700 HDD -> TL -> WDA -> FW call flow.
12701
12702 DEPENDENCIES
12703 The TL must be initialized before this function can be called.
12704
12705 PARAMETERS
12706
12707 IN
12708 pvosGCtx: pointer to the global vos context; a handle to TL's
12709 control block can be extracted from its context
12710 ucSTAId: station Id
12711 ucAC: AC for which U-APSD is being enabled
12712 ucTid: TID for which U-APSD is setup
12713 ucUP: used to place in the trigger frame generation
12714 ucServiceInt: service interval used by TL to send trigger frames
12715 ucSuspendInt: suspend interval used by TL to determine that an
12716 app is idle and should start sending trigg frms less often
12717 wTSDir: direction of TSpec
12718
12719 RETURN VALUE
12720 The result code associated with performing the operation
12721
12722 VOS_STATUS_SUCCESS: Everything is good :)
12723
12724 SIDE EFFECTS
12725
12726============================================================================*/
12727VOS_STATUS
12728WLANTL_EnableUAPSDForAC
12729(
12730 v_PVOID_t pvosGCtx,
12731 v_U8_t ucSTAId,
12732 WLANTL_ACEnumType ucAC,
12733 v_U8_t ucTid,
12734 v_U8_t ucUP,
12735 v_U32_t uServiceInt,
12736 v_U32_t uSuspendInt,
12737 WLANTL_TSDirType wTSDir
12738)
12739{
12740
12741 WLANTL_CbType* pTLCb = NULL;
12742 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
12743 tUapsdInfo halUAPSDInfo;
12744 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
12745
12746 /*------------------------------------------------------------------------
12747 Sanity check
12748 Extract TL control block
12749 ------------------------------------------------------------------------*/
12750 pTLCb = VOS_GET_TL_CB(pvosGCtx);
12751 if (( NULL == pTLCb ) || WLANTL_STA_ID_INVALID( ucSTAId )
Gopichand Nakkala574f6d12013-06-27 19:38:43 +053012752 || WLANTL_AC_INVALID(ucAC))
Jeff Johnson295189b2012-06-20 16:38:30 -070012753 {
12754 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
12755 "WLAN TL:Invalid input params on WLANTL_EnableUAPSDForAC"
Jeff Johnsonddec6482017-09-19 08:33:57 -070012756 " TL: %pK STA: %d AC: %d",
Gopichand Nakkala574f6d12013-06-27 19:38:43 +053012757 pTLCb, ucSTAId, ucAC));
Jeff Johnson295189b2012-06-20 16:38:30 -070012758 return VOS_STATUS_E_FAULT;
12759 }
12760
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053012761 if ( NULL == pTLCb->atlSTAClients[ucSTAId] )
12762 {
12763 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
12764 "WLAN TL:Client Memory was not allocated on %s", __func__));
12765 return VOS_STATUS_E_FAILURE;
12766 }
12767
Jeff Johnson295189b2012-06-20 16:38:30 -070012768 /*Set this flag in order to remember that this is a trigger enabled AC*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053012769 pTLCb->atlSTAClients[ucSTAId]->wUAPSDInfo[ucAC].ucSet = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -070012770
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053012771#ifdef FEATURE_WLAN_TDLS
12772 if(pTLCb->atlSTAClients[ucSTAId]->wSTADesc.wSTAType != WLAN_STA_TDLS)
12773#endif
12774 {
12775 if( 0 == uServiceInt )
12776 {
12777 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi198ade32013-09-29 03:52:25 +053012778 "WLAN TL:Input params on WLANTL_EnableUAPSDForAC"
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053012779 " SI: %d", uServiceInt ));
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053012780 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012781
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053012782 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
12783 "WLAN TL:Enabling U-APSD in FW for STA: %d AC: %d SI: %d SPI: %d "
12784 "DI: %d",
12785 ucSTAId, ucAC, uServiceInt, uSuspendInt,
12786 pTLCb->tlConfigInfo.uDelayedTriggerFrmInt));
Jeff Johnson295189b2012-06-20 16:38:30 -070012787
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053012788 /*Save all info for HAL*/
12789 halUAPSDInfo.staidx = ucSTAId;
12790 halUAPSDInfo.ac = ucAC;
12791 halUAPSDInfo.up = ucUP;
12792 halUAPSDInfo.srvInterval = uServiceInt;
12793 halUAPSDInfo.susInterval = uSuspendInt;
12794 halUAPSDInfo.delayInterval = pTLCb->tlConfigInfo.uDelayedTriggerFrmInt;
12795
12796 /*Notify HAL*/
12797 vosStatus = WDA_EnableUapsdAcParams(pvosGCtx, ucSTAId, &halUAPSDInfo);
12798 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012799 return vosStatus;
12800
12801}/*WLANTL_EnableUAPSDForAC*/
12802
12803
12804/*==========================================================================
12805 FUNCTION WLANTL_DisableUAPSDForAC
12806
12807 DESCRIPTION
12808 Called by HDD to disable UAPSD. TL in turn calls WDA API to disable the
12809 logic in FW/SLM to stop sending trigger frames. Previously TL had the
12810 trigger frame logic which later moved down to FW. Hence
12811 HDD -> TL -> WDA -> FW call flow.
12812
12813 DEPENDENCIES
12814 The TL must be initialized before this function can be called.
12815
12816 PARAMETERS
12817
12818 IN
12819 pvosGCtx: pointer to the global vos context; a handle to TL's
12820 control block can be extracted from its context
12821 ucSTAId: station Id
12822 ucAC: AC for which U-APSD is being enabled
12823
12824
12825 RETURN VALUE
12826 The result code associated with performing the operation
12827
12828 VOS_STATUS_SUCCESS: Everything is good :)
12829
12830 SIDE EFFECTS
12831
12832============================================================================*/
12833VOS_STATUS
12834WLANTL_DisableUAPSDForAC
12835(
12836 v_PVOID_t pvosGCtx,
12837 v_U8_t ucSTAId,
12838 WLANTL_ACEnumType ucAC
12839)
12840{
12841 WLANTL_CbType* pTLCb;
12842 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
12843
12844 /*------------------------------------------------------------------------
12845 Sanity check
12846 Extract TL control block
12847 ------------------------------------------------------------------------*/
12848 pTLCb = VOS_GET_TL_CB(pvosGCtx);
12849 if (( NULL == pTLCb ) || WLANTL_STA_ID_INVALID( ucSTAId )
12850 || WLANTL_AC_INVALID(ucAC) )
12851 {
12852 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
12853 "WLAN TL:Invalid input params on WLANTL_DisableUAPSDForAC"
Jeff Johnsonddec6482017-09-19 08:33:57 -070012854 " TL: %pK STA: %d AC: %d", pTLCb, ucSTAId, ucAC ));
Jeff Johnson295189b2012-06-20 16:38:30 -070012855 return VOS_STATUS_E_FAULT;
12856 }
12857
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053012858 if ( NULL == pTLCb->atlSTAClients[ucSTAId] )
12859 {
12860 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
12861 "WLAN TL:Client Memory was not allocated on %s", __func__));
12862 return VOS_STATUS_E_FAILURE;
12863 }
12864
Jeff Johnson295189b2012-06-20 16:38:30 -070012865 /*Reset this flag as this is no longer a trigger enabled AC*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053012866 pTLCb->atlSTAClients[ucSTAId]->wUAPSDInfo[ucAC].ucSet = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -070012867
12868 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
12869 "WLAN TL:Disabling U-APSD in FW for STA: %d AC: %d ",
12870 ucSTAId, ucAC));
12871
12872 /*Notify HAL*/
12873 WDA_DisableUapsdAcParams(pvosGCtx, ucSTAId, ucAC);
12874
12875 return VOS_STATUS_SUCCESS;
12876}/* WLANTL_DisableUAPSDForAC */
12877
12878#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
12879/*==========================================================================
12880 FUNCTION WLANTL_RegRSSIIndicationCB
12881
12882 DESCRIPTION Registration function to get notification if RSSI cross
12883 threshold.
12884 Client should register threshold, direction, and notification
12885 callback function pointer
12886
12887 DEPENDENCIES NONE
12888
12889 PARAMETERS in pAdapter - Global handle
12890 in rssiValue - RSSI threshold value
12891 in triggerEvent - Cross direction should be notified
12892 UP, DOWN, and CROSS
12893 in crossCBFunction - Notification CB Function
12894 in usrCtxt - user context
12895
12896 RETURN VALUE VOS_STATUS
12897
12898 SIDE EFFECTS NONE
12899
12900============================================================================*/
12901VOS_STATUS WLANTL_RegRSSIIndicationCB
12902(
12903 v_PVOID_t pAdapter,
12904 v_S7_t rssiValue,
12905 v_U8_t triggerEvent,
12906 WLANTL_RSSICrossThresholdCBType crossCBFunction,
12907 VOS_MODULE_ID moduleID,
12908 v_PVOID_t usrCtxt
12909)
12910{
12911 VOS_STATUS status = VOS_STATUS_SUCCESS;
12912
12913 status = WLANTL_HSRegRSSIIndicationCB(pAdapter,
12914 rssiValue,
12915 triggerEvent,
12916 crossCBFunction,
12917 moduleID,
12918 usrCtxt);
12919
12920 return status;
12921}
12922
12923/*==========================================================================
12924 FUNCTION WLANTL_DeregRSSIIndicationCB
12925
12926 DESCRIPTION Remove specific threshold from list
12927
12928 DEPENDENCIES NONE
12929
12930 PARAMETERS in pAdapter - Global handle
12931 in rssiValue - RSSI threshold value
12932 in triggerEvent - Cross direction should be notified
12933 UP, DOWN, and CROSS
12934
12935 RETURN VALUE VOS_STATUS
12936
12937 SIDE EFFECTS NONE
12938
12939============================================================================*/
12940VOS_STATUS WLANTL_DeregRSSIIndicationCB
12941(
12942 v_PVOID_t pAdapter,
12943 v_S7_t rssiValue,
12944 v_U8_t triggerEvent,
12945 WLANTL_RSSICrossThresholdCBType crossCBFunction,
12946 VOS_MODULE_ID moduleID
12947)
12948{
12949 VOS_STATUS status = VOS_STATUS_SUCCESS;
12950
12951 status = WLANTL_HSDeregRSSIIndicationCB(pAdapter,
12952 rssiValue,
12953 triggerEvent,
12954 crossCBFunction,
12955 moduleID);
12956 return status;
12957}
12958
12959/*==========================================================================
12960 FUNCTION WLANTL_SetAlpha
12961
12962 DESCRIPTION ALPLA is weight value to calculate AVG RSSI
12963 avgRSSI = (ALPHA * historyRSSI) + ((10 - ALPHA) * newRSSI)
12964 avgRSSI has (ALPHA * 10)% of history RSSI weight and
12965 (10 - ALPHA)% of newRSSI weight
12966 This portion is dynamically configurable.
12967 Default is ?
12968
12969 DEPENDENCIES NONE
12970
12971 PARAMETERS in pAdapter - Global handle
12972 in valueAlpah - ALPHA
12973
12974 RETURN VALUE VOS_STATUS
12975
12976 SIDE EFFECTS NONE
12977
12978============================================================================*/
12979VOS_STATUS WLANTL_SetAlpha
12980(
12981 v_PVOID_t pAdapter,
12982 v_U8_t valueAlpha
12983)
12984{
12985 VOS_STATUS status = VOS_STATUS_SUCCESS;
12986
12987 status = WLANTL_HSSetAlpha(pAdapter, valueAlpha);
12988 return status;
12989}
12990
12991/*==========================================================================
12992
12993 FUNCTION
12994
12995 DESCRIPTION
12996
12997 PARAMETERS
12998
12999 RETURN VALUE
13000
13001============================================================================*/
13002VOS_STATUS WLANTL_BMPSRSSIRegionChangedNotification
13003(
13004 v_PVOID_t pAdapter,
13005 tpSirRSSINotification pRSSINotification
13006)
13007{
13008 VOS_STATUS status = VOS_STATUS_SUCCESS;
13009
13010 status = WLANTL_HSBMPSRSSIRegionChangedNotification(pAdapter, pRSSINotification);
13011 return status;
13012}
13013
13014/*==========================================================================
13015 FUNCTION WLANTL_RegGetTrafficStatus
13016
13017 DESCRIPTION Registration function for traffic status monitoring
13018 During measure period count data frames.
13019 If frame count is larger then IDLE threshold set as traffic ON
13020 or OFF.
13021 And traffic status is changed send report to client with
13022 registered callback function
13023
13024 DEPENDENCIES NONE
13025
13026 PARAMETERS in pAdapter - Global handle
13027 in idleThreshold - Traffic on or off threshold
13028 in measurePeriod - Traffic state check period
13029 in trfficStatusCB - traffic status changed notification
13030 CB function
13031 in usrCtxt - user context
13032
13033 RETURN VALUE VOS_STATUS
13034
13035 SIDE EFFECTS NONE
13036
13037============================================================================*/
13038VOS_STATUS WLANTL_RegGetTrafficStatus
13039(
13040 v_PVOID_t pAdapter,
13041 v_U32_t idleThreshold,
13042 v_U32_t measurePeriod,
13043 WLANTL_TrafficStatusChangedCBType trfficStatusCB,
13044 v_PVOID_t usrCtxt
13045)
13046{
13047 VOS_STATUS status = VOS_STATUS_SUCCESS;
13048
13049 status = WLANTL_HSRegGetTrafficStatus(pAdapter,
13050 idleThreshold,
13051 measurePeriod,
13052 trfficStatusCB,
13053 usrCtxt);
13054 return status;
13055}
13056#endif
13057/*==========================================================================
13058 FUNCTION WLANTL_GetStatistics
13059
13060 DESCRIPTION Get traffic statistics for identified station
13061
13062 DEPENDENCIES NONE
13063
13064 PARAMETERS in pAdapter - Global handle
13065 in statType - specific statistics field to reset
13066 out statBuffer - traffic statistics buffer
13067
13068 RETURN VALUE VOS_STATUS
13069
13070 SIDE EFFECTS NONE
13071
13072============================================================================*/
13073VOS_STATUS WLANTL_GetStatistics
13074(
13075 v_PVOID_t pAdapter,
13076 WLANTL_TRANSFER_STA_TYPE *statBuffer,
13077 v_U8_t STAid
13078)
13079{
13080 WLANTL_CbType *pTLCb = VOS_GET_TL_CB(pAdapter);
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053013081 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070013082 VOS_STATUS status = VOS_STATUS_SUCCESS;
13083 WLANTL_TRANSFER_STA_TYPE *statistics = NULL;
13084
13085 /*------------------------------------------------------------------------
13086 Sanity check
13087 Extract TL control block
13088 ------------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053013089 if ( NULL == pTLCb )
Jeff Johnson295189b2012-06-20 16:38:30 -070013090 {
13091 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
13092 "WLAN TL:Invalid TL pointer on WLANTL_GetStatistics"));
13093 return VOS_STATUS_E_FAULT;
13094 }
13095
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053013096 pClientSTA = pTLCb->atlSTAClients[STAid];
13097
13098 if ( NULL == pClientSTA )
13099 {
13100 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
13101 "WLAN TL:Client Memory was not allocated on %s", __func__));
13102 return VOS_STATUS_E_FAILURE;
13103 }
13104
13105 if(0 == pClientSTA->ucExists)
Jeff Johnson295189b2012-06-20 16:38:30 -070013106 {
13107 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
13108 "WLAN TL: %d STA ID does not exist", STAid));
13109 return VOS_STATUS_E_INVAL;
13110 }
13111
13112 if(NULL == statBuffer)
13113 {
13114 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
13115 "WLAN TL:Invalid TL statistics buffer pointer on WLANTL_GetStatistics"));
13116 return VOS_STATUS_E_INVAL;
13117 }
13118
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053013119 statistics = &pClientSTA->trafficStatistics;
Katya Nigam493ff652014-02-11 14:31:04 +053013120 vos_mem_copy(statBuffer, statistics, sizeof(WLANTL_TRANSFER_STA_TYPE));
Jeff Johnson295189b2012-06-20 16:38:30 -070013121
13122 return status;
13123}
13124
13125/*==========================================================================
13126 FUNCTION WLANTL_ResetStatistics
13127
13128 DESCRIPTION Reset statistics structure for identified station ID
13129 Reset means set values as 0
13130
13131 DEPENDENCIES NONE
13132
13133 PARAMETERS in pAdapter - Global handle
13134 in statType - specific statistics field to reset
13135
13136 RETURN VALUE VOS_STATUS
13137
13138 SIDE EFFECTS NONE
13139
13140============================================================================*/
13141VOS_STATUS WLANTL_ResetStatistics
13142(
13143 v_PVOID_t pAdapter,
13144 v_U8_t STAid
13145)
13146{
13147 WLANTL_CbType *pTLCb = VOS_GET_TL_CB(pAdapter);
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053013148 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070013149 VOS_STATUS status = VOS_STATUS_SUCCESS;
13150 WLANTL_TRANSFER_STA_TYPE *statistics = NULL;
13151
13152 /*------------------------------------------------------------------------
13153 Sanity check
13154 Extract TL control block
13155 ------------------------------------------------------------------------*/
13156 if (NULL == pTLCb)
13157 {
13158 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
13159 "WLAN TL:Invalid TL pointer on WLANTL_GetStatistics"));
13160 return VOS_STATUS_E_FAULT;
13161 }
13162
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053013163 pClientSTA = pTLCb->atlSTAClients[STAid];
13164
13165 if ( NULL == pClientSTA )
13166 {
13167 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
13168 "WLAN TL:Client Memory was not allocated on %s", __func__));
13169 return VOS_STATUS_E_FAILURE;
13170 }
13171
13172 if(0 == pClientSTA->ucExists)
Jeff Johnson295189b2012-06-20 16:38:30 -070013173 {
13174 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
13175 "WLAN TL: %d STA ID does not exist", STAid));
13176 return VOS_STATUS_E_INVAL;
13177 }
13178
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053013179 statistics = &pClientSTA->trafficStatistics;
Jeff Johnson295189b2012-06-20 16:38:30 -070013180 vos_mem_zero((v_VOID_t *)statistics, sizeof(WLANTL_TRANSFER_STA_TYPE));
13181
13182 return status;
13183}
13184
13185/*==========================================================================
13186 FUNCTION WLANTL_GetSpecStatistic
13187
13188 DESCRIPTION Get specific field within statistics structure for
13189 identified station ID
13190
13191 DEPENDENCIES NONE
13192
13193 PARAMETERS in pAdapter - Global handle
13194 in statType - specific statistics field to reset
13195 in STAid - Station ID
13196 out buffer - Statistic value
13197
13198 RETURN VALUE VOS_STATUS
13199
13200 SIDE EFFECTS NONE
13201
13202============================================================================*/
13203VOS_STATUS WLANTL_GetSpecStatistic
13204(
13205 v_PVOID_t pAdapter,
13206 WLANTL_TRANSFER_STATIC_TYPE statType,
13207 v_U32_t *buffer,
13208 v_U8_t STAid
13209)
13210{
13211 WLANTL_CbType *pTLCb = VOS_GET_TL_CB(pAdapter);
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053013212 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070013213 VOS_STATUS status = VOS_STATUS_SUCCESS;
13214 WLANTL_TRANSFER_STA_TYPE *statistics = NULL;
13215
13216 /*------------------------------------------------------------------------
13217 Sanity check
13218 Extract TL control block
13219 ------------------------------------------------------------------------*/
13220 if (NULL == pTLCb)
13221 {
13222 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
13223 "WLAN TL:Invalid TL pointer on WLANTL_GetStatistics"));
13224 return VOS_STATUS_E_FAULT;
13225 }
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053013226 pClientSTA = pTLCb->atlSTAClients[STAid];
Jeff Johnson295189b2012-06-20 16:38:30 -070013227
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053013228 if ( NULL == pClientSTA )
13229 {
13230 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
13231 "WLAN TL:Client Memory was not allocated on %s", __func__));
13232 return VOS_STATUS_E_FAILURE;
13233 }
13234
13235 if(0 == pClientSTA->ucExists)
Jeff Johnson295189b2012-06-20 16:38:30 -070013236 {
13237 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
13238 "WLAN TL: %d STA ID does not exist", STAid));
13239 return VOS_STATUS_E_INVAL;
13240 }
13241
13242 if(NULL == buffer)
13243 {
13244 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
13245 "WLAN TL:Invalid TL statistic buffer pointer on WLANTL_GetStatistics"));
13246 return VOS_STATUS_E_INVAL;
13247 }
13248
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053013249 statistics = &pClientSTA->trafficStatistics;
Jeff Johnson295189b2012-06-20 16:38:30 -070013250 switch(statType)
13251 {
13252 case WLANTL_STATIC_TX_UC_FCNT:
13253 *buffer = statistics->txUCFcnt;
13254 break;
13255
13256 case WLANTL_STATIC_TX_MC_FCNT:
13257 *buffer = statistics->txMCFcnt;
13258 break;
13259
13260 case WLANTL_STATIC_TX_BC_FCNT:
13261 *buffer = statistics->txBCFcnt;
13262 break;
13263
13264 case WLANTL_STATIC_TX_UC_BCNT:
13265 *buffer = statistics->txUCBcnt;
13266 break;
13267
13268 case WLANTL_STATIC_TX_MC_BCNT:
13269 *buffer = statistics->txMCBcnt;
13270 break;
13271
13272 case WLANTL_STATIC_TX_BC_BCNT:
13273 *buffer = statistics->txBCBcnt;
13274 break;
13275
13276 case WLANTL_STATIC_RX_UC_FCNT:
13277 *buffer = statistics->rxUCFcnt;
13278 break;
13279
13280 case WLANTL_STATIC_RX_MC_FCNT:
13281 *buffer = statistics->rxMCFcnt;
13282 break;
13283
13284 case WLANTL_STATIC_RX_BC_FCNT:
13285 *buffer = statistics->rxBCFcnt;
13286 break;
13287
13288 case WLANTL_STATIC_RX_UC_BCNT:
13289 *buffer = statistics->rxUCBcnt;
13290 break;
13291
13292 case WLANTL_STATIC_RX_MC_BCNT:
13293 *buffer = statistics->rxMCBcnt;
13294 break;
13295
13296 case WLANTL_STATIC_RX_BC_BCNT:
13297 *buffer = statistics->rxBCBcnt;
13298 break;
13299
13300 case WLANTL_STATIC_RX_BCNT:
13301 *buffer = statistics->rxBcnt;
13302 break;
13303
13304 case WLANTL_STATIC_RX_BCNT_CRC_OK:
13305 *buffer = statistics->rxBcntCRCok;
13306 break;
13307
13308 case WLANTL_STATIC_RX_RATE:
13309 *buffer = statistics->rxRate;
13310 break;
13311
13312 default:
13313 *buffer = 0;
13314 status = VOS_STATUS_E_INVAL;
13315 break;
13316 }
13317
13318
13319 return status;
13320}
13321
13322/*==========================================================================
13323 FUNCTION WLANTL_ResetSpecStatistic
13324
13325 DESCRIPTION Reset specific field within statistics structure for
13326 identified station ID
13327 Reset means set as 0
13328
13329 DEPENDENCIES NONE
13330
13331 PARAMETERS in pAdapter - Global handle
13332 in statType - specific statistics field to reset
13333 in STAid - Station ID
13334
13335 RETURN VALUE VOS_STATUS
13336
13337 SIDE EFFECTS NONE
13338
13339============================================================================*/
13340VOS_STATUS WLANTL_ResetSpecStatistic
13341(
13342 v_PVOID_t pAdapter,
13343 WLANTL_TRANSFER_STATIC_TYPE statType,
13344 v_U8_t STAid
13345)
13346{
13347 WLANTL_CbType *pTLCb = VOS_GET_TL_CB(pAdapter);
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053013348 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070013349 VOS_STATUS status = VOS_STATUS_SUCCESS;
13350 WLANTL_TRANSFER_STA_TYPE *statistics = NULL;
13351
13352 /*------------------------------------------------------------------------
13353 Sanity check
13354 Extract TL control block
13355 ------------------------------------------------------------------------*/
13356 if (NULL == pTLCb)
13357 {
13358 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
13359 "WLAN TL:Invalid TL pointer on WLANTL_GetStatistics"));
13360 return VOS_STATUS_E_FAULT;
13361 }
13362
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053013363 pClientSTA = pTLCb->atlSTAClients[STAid];
13364
13365 if ( NULL == pClientSTA )
13366 {
13367 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
13368 "WLAN TL:Client Memory was not allocated on %s", __func__));
13369 return VOS_STATUS_E_FAILURE;
13370 }
13371
13372 if(0 == pClientSTA->ucExists)
Jeff Johnson295189b2012-06-20 16:38:30 -070013373 {
13374 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
13375 "WLAN TL: %d STA ID does not exist", STAid));
13376 return VOS_STATUS_E_INVAL;
13377 }
13378
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053013379 statistics = &pClientSTA->trafficStatistics;
Jeff Johnson295189b2012-06-20 16:38:30 -070013380 switch(statType)
13381 {
13382 case WLANTL_STATIC_TX_UC_FCNT:
13383 statistics->txUCFcnt = 0;
13384 break;
13385
13386 case WLANTL_STATIC_TX_MC_FCNT:
13387 statistics->txMCFcnt = 0;
13388 break;
13389
13390 case WLANTL_STATIC_TX_BC_FCNT:
13391 statistics->txBCFcnt = 0;
13392 break;
13393
13394 case WLANTL_STATIC_TX_UC_BCNT:
13395 statistics->txUCBcnt = 0;
13396 break;
13397
13398 case WLANTL_STATIC_TX_MC_BCNT:
13399 statistics->txMCBcnt = 0;
13400 break;
13401
13402 case WLANTL_STATIC_TX_BC_BCNT:
13403 statistics->txBCBcnt = 0;
13404 break;
13405
13406 case WLANTL_STATIC_RX_UC_FCNT:
13407 statistics->rxUCFcnt = 0;
13408 break;
13409
13410 case WLANTL_STATIC_RX_MC_FCNT:
13411 statistics->rxMCFcnt = 0;
13412 break;
13413
13414 case WLANTL_STATIC_RX_BC_FCNT:
13415 statistics->rxBCFcnt = 0;
13416 break;
13417
13418 case WLANTL_STATIC_RX_UC_BCNT:
13419 statistics->rxUCBcnt = 0;
13420 break;
13421
13422 case WLANTL_STATIC_RX_MC_BCNT:
13423 statistics->rxMCBcnt = 0;
13424 break;
13425
13426 case WLANTL_STATIC_RX_BC_BCNT:
13427 statistics->rxBCBcnt = 0;
13428 break;
13429
13430 case WLANTL_STATIC_RX_BCNT:
13431 statistics->rxBcnt = 0;
13432 break;
13433
13434 case WLANTL_STATIC_RX_BCNT_CRC_OK:
13435 statistics->rxBcntCRCok = 0;
13436 break;
13437
13438 case WLANTL_STATIC_RX_RATE:
13439 statistics->rxRate = 0;
13440 break;
13441
13442 default:
13443 status = VOS_STATUS_E_INVAL;
13444 break;
13445 }
13446
13447 return status;
13448}
13449
13450
13451/*==========================================================================
13452
13453 FUNCTION
13454
13455 DESCRIPTION Read RSSI value out of a RX BD
13456
13457 PARAMETERS: Caller must validate all parameters
13458
13459 RETURN VALUE
13460
13461============================================================================*/
13462VOS_STATUS WLANTL_ReadRSSI
13463(
13464 v_PVOID_t pAdapter,
13465 v_PVOID_t pBDHeader,
13466 v_U8_t STAid
13467)
13468{
13469 WLANTL_CbType *tlCtxt = VOS_GET_TL_CB(pAdapter);
13470 v_S7_t currentRSSI, currentRSSI0, currentRSSI1;
13471
13472
13473 if(NULL == tlCtxt)
13474 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070013475 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR, "%s Invalid TL handle", __func__));
Jeff Johnson295189b2012-06-20 16:38:30 -070013476 return VOS_STATUS_E_INVAL;
13477 }
13478
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053013479 if ( NULL == tlCtxt->atlSTAClients[STAid] )
13480 {
13481 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
13482 "WLAN TL:Client Memory was not allocated on %s", __func__));
13483 return VOS_STATUS_E_FAILURE;
13484 }
13485
Jeff Johnson295189b2012-06-20 16:38:30 -070013486 currentRSSI0 = WLANTL_GETRSSI0(pBDHeader);
13487 currentRSSI1 = WLANTL_GETRSSI1(pBDHeader);
13488 currentRSSI = (currentRSSI0 > currentRSSI1) ? currentRSSI0 : currentRSSI1;
13489
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053013490 tlCtxt->atlSTAClients[STAid]->rssiAvg = currentRSSI;
Jeff Johnson295189b2012-06-20 16:38:30 -070013491
13492 return VOS_STATUS_SUCCESS;
13493}
13494
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053013495/*==========================================================================
13496
13497 FUNCTION
13498
13499 DESCRIPTION Read SNR value out of a RX BD
13500
13501 PARAMETERS: Caller must validate all parameters
13502
13503 RETURN VALUE
13504
13505============================================================================*/
13506VOS_STATUS WLANTL_ReadSNR
13507(
13508 v_PVOID_t pAdapter,
13509 v_PVOID_t pBDHeader,
13510 v_U8_t STAid
13511)
13512{
13513 WLANTL_CbType *tlCtxt = VOS_GET_TL_CB(pAdapter);
13514 v_S7_t currentSNR;
13515
13516
13517 if (NULL == tlCtxt)
13518 {
13519 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
13520 "%s Invalid TL handle", __func__));
13521 return VOS_STATUS_E_INVAL;
13522 }
13523
13524 if (NULL == tlCtxt->atlSTAClients[STAid])
13525 {
13526 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
13527 "WLAN TL:Client Memory was not allocated on %s", __func__));
13528 return VOS_STATUS_E_FAILURE;
13529 }
13530
13531 currentSNR = WLANTL_GETSNR(pBDHeader);
13532
Madan Mohan Koyyalamudi43acf032013-09-27 04:33:28 +053013533 /* SNR reported in the Buffer Descriptor is scaled up by 2(SNR*2),
13534 * Get the correct SNR value
13535 */
13536 currentSNR = currentSNR >> 1;
13537
13538 /* SNR reported by HW cannot be more than 35dB due to HW limitations */
13539 currentSNR = (WLANTL_MAX_HW_SNR > currentSNR ? currentSNR :
13540 WLANTL_MAX_HW_SNR);
13541
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053013542 TLLOG2(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
13543 "%s: snrsum: %d snridx: %d prevsnravg: %d",
13544 __func__,
13545 tlCtxt->atlSTAClients[STAid]->snrSum,
13546 tlCtxt->atlSTAClients[STAid]->snrIdx,
13547 tlCtxt->atlSTAClients[STAid]->prevSnrAvg));
13548
13549 /* The SNR returned for all purposes is the average SNR over
13550 * WLANTL_MAX_SNR_DATA_SMAPLES.When data samples
13551 * > WLANTL_MAX_SNR_DATA_SAMPLES are obtained,
13552 * store the average of the samples in prevSnrAvg
13553 * and start a new averaging window. The prevSnrAvg is used when
13554 * enough data samples are not available when applications
13555 * actually query for SNR.
13556 *
13557 * SEE: WLANTL_GetSnr()
13558 */
13559 if (tlCtxt->atlSTAClients[STAid]->snrIdx >= WLANTL_MAX_SNR_DATA_SAMPLES)
13560 {
13561 tlCtxt->atlSTAClients[STAid]->prevSnrAvg =
13562 tlCtxt->atlSTAClients[STAid]->snrSum /
13563 tlCtxt->atlSTAClients[STAid]->snrIdx;
13564 tlCtxt->atlSTAClients[STAid]->snrSum = 0;
13565 tlCtxt->atlSTAClients[STAid]->snrIdx = 0;
13566 }
13567 tlCtxt->atlSTAClients[STAid]->snrSum += currentSNR;
13568 tlCtxt->atlSTAClients[STAid]->snrIdx += 1;
13569
13570 return VOS_STATUS_SUCCESS;
13571}
Jeff Johnson295189b2012-06-20 16:38:30 -070013572
13573/*
13574 DESCRIPTION
13575 TL returns the weight currently maintained in TL.
13576 IN
13577 pvosGCtx: pointer to the global vos context; a handle to TL's
13578 or SME's control block can be extracted from its context
13579
13580 OUT
13581 pACWeights: Caller allocated memory for filling in weights
13582
13583 RETURN VALUE VOS_STATUS
13584*/
13585VOS_STATUS
13586WLANTL_GetACWeights
13587(
13588 v_PVOID_t pvosGCtx,
13589 v_U8_t* pACWeights
13590)
13591{
13592 WLANTL_CbType* pTLCb = NULL;
13593 v_U8_t ucIndex;
13594 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
13595
13596 /*------------------------------------------------------------------------
13597 Sanity check
13598 ------------------------------------------------------------------------*/
13599 if ( NULL == pACWeights )
13600 {
13601 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
13602 "WLAN TL:Invalid parameter sent on WLANTL_GetACWeights"));
13603 return VOS_STATUS_E_INVAL;
13604 }
13605
13606 /*------------------------------------------------------------------------
13607 Extract TL control block and check existance
13608 ------------------------------------------------------------------------*/
13609 pTLCb = VOS_GET_TL_CB(pvosGCtx);
13610 if ( NULL == pTLCb )
13611 {
13612 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
13613 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_GetACWeights"));
13614 return VOS_STATUS_E_FAULT;
13615 }
13616 for ( ucIndex = 0; ucIndex < WLANTL_MAX_AC ; ucIndex++)
13617 {
13618 pACWeights[ucIndex] = pTLCb->tlConfigInfo.ucAcWeights[ucIndex];
13619 }
13620
13621 return VOS_STATUS_SUCCESS;
13622}
13623
13624
13625
13626/*
13627 DESCRIPTION
13628 Change the weight currently maintained by TL.
13629 IN
13630 pvosGCtx: pointer to the global vos context; a handle to TL's
13631 or SME's control block can be extracted from its context
13632 pACWeights: Caller allocated memory contain the weights to use
13633
13634
13635 RETURN VALUE VOS_STATUS
13636*/
13637VOS_STATUS
13638WLANTL_SetACWeights
13639(
13640 v_PVOID_t pvosGCtx,
13641 v_U8_t* pACWeights
13642)
13643{
13644 WLANTL_CbType* pTLCb = NULL;
13645 v_U8_t ucIndex;
13646 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
13647
13648 /*------------------------------------------------------------------------
13649 Sanity check
13650 ------------------------------------------------------------------------*/
13651 if ( NULL == pACWeights )
13652 {
13653 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
13654 "WLAN TL:Invalid parameter sent on WLANTL_GetACWeights"));
13655 return VOS_STATUS_E_INVAL;
13656 }
13657
13658 /*------------------------------------------------------------------------
13659 Extract TL control block and check existance
13660 ------------------------------------------------------------------------*/
13661 pTLCb = VOS_GET_TL_CB(pvosGCtx);
13662 if ( NULL == pTLCb )
13663 {
13664 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
13665 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_GetACWeights"));
13666 return VOS_STATUS_E_FAULT;
13667 }
13668 for ( ucIndex = 0; ucIndex < WLANTL_MAX_AC ; ucIndex++)
13669 {
13670 pTLCb->tlConfigInfo.ucAcWeights[ucIndex] = pACWeights[ucIndex];
13671 }
13672
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +053013673 pTLCb->tlConfigInfo.ucAcWeights[WLANTL_AC_HIGH_PRIO] = pACWeights[WLANTL_AC_VO];
Jeff Johnson295189b2012-06-20 16:38:30 -070013674 return VOS_STATUS_SUCCESS;
13675}
13676
13677
13678/*==========================================================================
13679
13680 FUNCTION
13681
13682 DESCRIPTION
13683
13684 PARAMETERS
13685
13686 RETURN VALUE
13687
13688============================================================================*/
13689void WLANTL_PowerStateChangedCB
13690(
13691 v_PVOID_t pAdapter,
13692 tPmcState newState
13693)
13694{
13695 WLANTL_CbType *tlCtxt = VOS_GET_TL_CB(pAdapter);
13696
13697 if (NULL == tlCtxt)
13698 {
13699 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +053013700 "%s: Invalid TL Control Block", __func__ );
Jeff Johnson295189b2012-06-20 16:38:30 -070013701 return;
13702 }
13703
13704 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO, "Power state changed, new state is %d", newState );
13705 switch(newState)
13706 {
13707 case FULL_POWER:
13708 tlCtxt->isBMPS = VOS_FALSE;
13709 break;
13710
13711 case BMPS:
13712#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
13713 WLANTL_SetFWRSSIThresholds(pAdapter);
13714#endif
13715
13716 tlCtxt->isBMPS = VOS_TRUE;
13717 break;
13718
13719 case IMPS:
13720 case LOW_POWER:
13721 case REQUEST_BMPS:
13722 case REQUEST_FULL_POWER:
13723 case REQUEST_IMPS:
13724 case STOPPED:
13725 case REQUEST_START_UAPSD:
13726 case REQUEST_STOP_UAPSD:
13727 case UAPSD:
13728 case REQUEST_STANDBY:
13729 case STANDBY:
13730 case REQUEST_ENTER_WOWL:
13731 case REQUEST_EXIT_WOWL:
13732 case WOWL:
13733 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN, "Not handle this events %d", newState ));
13734 break;
13735
13736 default:
13737 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR, "Not a valid event %d", newState ));
13738 break;
13739 }
13740
13741 return;
13742}
13743/*==========================================================================
13744 FUNCTION WLANTL_GetEtherType
13745
13746 DESCRIPTION Extract Ether type information from the BD
13747
13748 DEPENDENCIES NONE
13749
13750 PARAMETERS in aucBDHeader - BD header
13751 in vosDataBuff - data buffer
13752 in ucMPDUHLen - MPDU header length
13753 out pUsEtherType - pointer to Ethertype
13754
13755 RETURN VALUE VOS_STATUS_SUCCESS : if the EtherType is successfully extracted
13756 VOS_STATUS_FAILURE : if the EtherType extraction failed and
13757 the packet was dropped
13758
13759 SIDE EFFECTS NONE
13760
13761============================================================================*/
13762static VOS_STATUS WLANTL_GetEtherType
13763(
13764 v_U8_t * aucBDHeader,
13765 vos_pkt_t * vosDataBuff,
13766 v_U8_t ucMPDUHLen,
13767 v_U16_t * pUsEtherType
13768)
13769{
13770 v_U8_t ucOffset;
13771 v_U16_t usEtherType = *pUsEtherType;
13772 v_SIZE_t usLLCSize = sizeof(usEtherType);
13773 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
13774
13775 /*------------------------------------------------------------------------
13776 Check if LLC is present - if not, TL is unable to determine type
13777 ------------------------------------------------------------------------*/
13778 if ( VOS_FALSE == WDA_IS_RX_LLC_PRESENT( aucBDHeader ) )
13779 {
13780 ucOffset = WLANTL_802_3_HEADER_LEN - sizeof(usEtherType);
13781 }
13782 else
13783 {
13784 ucOffset = ucMPDUHLen + WLANTL_LLC_PROTO_TYPE_OFFSET;
13785 }
13786
13787 /*------------------------------------------------------------------------
13788 Extract LLC type
13789 ------------------------------------------------------------------------*/
13790 vosStatus = vos_pkt_extract_data( vosDataBuff, ucOffset,
13791 (v_PVOID_t)&usEtherType, &usLLCSize);
13792
13793 if (( VOS_STATUS_SUCCESS != vosStatus ) ||
13794 ( sizeof(usEtherType) != usLLCSize ))
13795
13796 {
13797 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
13798 "WLAN TL:Error extracting Ether type from data packet"));
13799 /* Drop packet */
13800 vos_pkt_return_packet(vosDataBuff);
13801 vosStatus = VOS_STATUS_E_FAILURE;
13802 }
13803 else
13804 {
13805 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
13806 "WLAN TL:Ether type retrieved before endianess conv: %d",
13807 usEtherType));
13808
13809 usEtherType = vos_be16_to_cpu(usEtherType);
13810 *pUsEtherType = usEtherType;
13811
13812 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
13813 "WLAN TL:Ether type retrieved: %d", usEtherType));
13814 }
13815
13816 return vosStatus;
13817}
13818
Jeff Johnson295189b2012-06-20 16:38:30 -070013819/*==========================================================================
13820 FUNCTION WLANTL_GetSoftAPStatistics
13821
13822 DESCRIPTION Collect the cumulative statistics for all Softap stations
13823
13824 DEPENDENCIES NONE
13825
13826 PARAMETERS in pvosGCtx - Pointer to the global vos context
13827 bReset - If set TL statistics will be cleared after reading
13828 out statsSum - pointer to collected statistics
13829
13830 RETURN VALUE VOS_STATUS_SUCCESS : if the Statistics are successfully extracted
13831
13832 SIDE EFFECTS NONE
13833
13834============================================================================*/
13835VOS_STATUS WLANTL_GetSoftAPStatistics(v_PVOID_t pAdapter, WLANTL_TRANSFER_STA_TYPE *statsSum, v_BOOL_t bReset)
13836{
13837 v_U8_t i = 0;
13838 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
13839 WLANTL_CbType *pTLCb = VOS_GET_TL_CB(pAdapter);
13840 WLANTL_TRANSFER_STA_TYPE statBufferTemp;
13841 vos_mem_zero((v_VOID_t *)&statBufferTemp, sizeof(WLANTL_TRANSFER_STA_TYPE));
13842 vos_mem_zero((v_VOID_t *)statsSum, sizeof(WLANTL_TRANSFER_STA_TYPE));
13843
13844
13845 if ( NULL == pTLCb )
13846 {
13847 return VOS_STATUS_E_FAULT;
13848 }
13849
13850 // Sum up all the statistics for stations of Soft AP from TL
13851 for (i = 0; i < WLAN_MAX_STA_COUNT; i++)
13852 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053013853 if ( NULL == pTLCb->atlSTAClients[i])
13854 {
13855 continue;
13856 }
13857 if (pTLCb->atlSTAClients[i]->wSTADesc.wSTAType == WLAN_STA_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -070013858 {
13859 vosStatus = WLANTL_GetStatistics(pAdapter, &statBufferTemp, i);// Can include staId 1 because statistics not collected for it
13860
13861 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
13862 return VOS_STATUS_E_FAULT;
13863
13864 // Add to the counters
13865 statsSum->txUCFcnt += statBufferTemp.txUCFcnt;
13866 statsSum->txMCFcnt += statBufferTemp.txMCFcnt;
13867 statsSum->txBCFcnt += statBufferTemp.txBCFcnt;
13868 statsSum->txUCBcnt += statBufferTemp.txUCBcnt;
13869 statsSum->txMCBcnt += statBufferTemp.txMCBcnt;
13870 statsSum->txBCBcnt += statBufferTemp.txBCBcnt;
13871 statsSum->rxUCFcnt += statBufferTemp.rxUCFcnt;
13872 statsSum->rxMCFcnt += statBufferTemp.rxMCFcnt;
13873 statsSum->rxBCFcnt += statBufferTemp.rxBCFcnt;
13874 statsSum->rxUCBcnt += statBufferTemp.rxUCBcnt;
13875 statsSum->rxMCBcnt += statBufferTemp.rxMCBcnt;
13876 statsSum->rxBCBcnt += statBufferTemp.rxBCBcnt;
13877
13878 if (bReset)
13879 {
13880 vosStatus = WLANTL_ResetStatistics(pAdapter, i);
13881 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
13882 return VOS_STATUS_E_FAULT;
13883 }
13884 }
13885 }
13886
13887 return vosStatus;
13888}
Mohit Khanna698ba2a2012-12-04 15:08:18 -080013889
Jeff Johnson295189b2012-06-20 16:38:30 -070013890/*===============================================================================
13891 FUNCTION WLANTL_IsReplayPacket
13892
13893 DESCRIPTION This function does replay check for valid stations
13894
13895 DEPENDENCIES Validity of replay check must be done before the function
13896 is called
13897
13898 PARAMETERS currentReplayCounter current replay counter taken from RX BD
13899 previousReplayCounter previous replay counter taken from TL CB
13900
13901 RETRUN VOS_TRUE packet is a replay packet
13902 VOS_FALSE packet is not a replay packet
13903
13904 SIDE EFFECTS none
13905 ===============================================================================*/
13906v_BOOL_t
13907WLANTL_IsReplayPacket
13908(
13909 v_U64_t ullcurrentReplayCounter,
13910 v_U64_t ullpreviousReplayCounter
13911)
13912{
13913 /* Do the replay check by comparing previous received replay counter with
13914 current received replay counter*/
13915 if(ullpreviousReplayCounter < ullcurrentReplayCounter)
13916 {
13917 /* Valid packet not replay */
13918 return VOS_FALSE;
13919 }
13920 else
13921 {
13922
13923 /* Current packet number is less than or equal to previuos received
13924 packet no, this means current packet is replay packet */
13925 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
13926 "WLAN TL: Replay packet found with replay counter :[0x%llX]",ullcurrentReplayCounter);
13927
13928 return VOS_TRUE;
13929 }
13930}
13931
13932#if 0
13933/*===============================================================================
13934 FUNCTION WLANTL_GetReplayCounterFromRxBD
13935
13936 DESCRIPTION This function extracts 48-bit replay packet number from RX BD
13937
13938 DEPENDENCIES Validity of replay check must be done before the function
13939 is called
13940
13941 PARAMETERS pucRxHeader pointer to RX BD header
13942
13943 RETRUN v_U64_t Packet number extarcted from RX BD
13944
13945 SIDE EFFECTS none
13946 ===============================================================================*/
13947v_U64_t
13948WLANTL_GetReplayCounterFromRxBD
13949(
13950 v_U8_t *pucRxBDHeader
13951)
13952{
13953/* 48-bit replay counter is created as follows
13954 from RX BD 6 byte PMI command:
13955 Addr : AES/TKIP
13956 0x38 : pn3/tsc3
13957 0x39 : pn2/tsc2
13958 0x3a : pn1/tsc1
13959 0x3b : pn0/tsc0
13960
13961 0x3c : pn5/tsc5
13962 0x3d : pn4/tsc4 */
13963
13964#ifdef ANI_BIG_BYTE_ENDIAN
13965 v_U64_t ullcurrentReplayCounter = 0;
13966 /* Getting 48-bit replay counter from the RX BD */
13967 ullcurrentReplayCounter = WLANHAL_RX_BD_GET_PMICMD_20TO23(pucRxBDHeader);
13968 ullcurrentReplayCounter <<= 16;
13969 ullcurrentReplayCounter |= (( WLANHAL_RX_BD_GET_PMICMD_24TO25(pucRxBDHeader) & 0xFFFF0000) >> 16);
13970 return ullcurrentReplayCounter;
13971#else
13972 v_U64_t ullcurrentReplayCounter = 0;
13973 /* Getting 48-bit replay counter from the RX BD */
13974 ullcurrentReplayCounter = (WLANHAL_RX_BD_GET_PMICMD_24TO25(pucRxBDHeader) & 0x0000FFFF);
13975 ullcurrentReplayCounter <<= 32;
13976 ullcurrentReplayCounter |= WLANHAL_RX_BD_GET_PMICMD_20TO23(pucRxBDHeader);
13977 return ullcurrentReplayCounter;
13978#endif
13979}
13980#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070013981
13982/*===============================================================================
13983 FUNCTION WLANTL_PostResNeeded
13984
13985 DESCRIPTION This function posts message to TL to reserve BD/PDU memory
13986
13987 DEPENDENCIES None
13988
13989 PARAMETERS pvosGCtx
13990
13991 RETURN None
13992
13993 SIDE EFFECTS none
13994 ===============================================================================*/
13995
13996void WLANTL_PostResNeeded(v_PVOID_t pvosGCtx)
13997{
13998 vos_msg_t vosMsg;
13999
14000 vosMsg.reserved = 0;
14001 vosMsg.bodyptr = NULL;
14002 vosMsg.type = WLANTL_TX_RES_NEEDED;
14003 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
14004 "WLAN TL: BD/PDU available interrupt received, Posting message to TL");
14005 if(!VOS_IS_STATUS_SUCCESS(vos_tx_mq_serialize( VOS_MQ_ID_TL, &vosMsg)))
14006 {
14007 VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070014008 " %s fails to post message", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070014009 }
14010}
14011
14012/*===============================================================================
14013 FUNCTION WLANTL_UpdateRssiBmps
14014
14015 DESCRIPTION This function updates the TL's RSSI (in BMPS mode)
14016
14017 DEPENDENCIES None
14018
14019 PARAMETERS
14020
14021 pvosGCtx VOS context VOS Global context
14022 staId Station ID Station ID
14023 rssi RSSI (BMPS mode) RSSI in BMPS mode
14024
14025 RETURN None
14026
14027 SIDE EFFECTS none
14028 ===============================================================================*/
14029
14030void WLANTL_UpdateRssiBmps(v_PVOID_t pvosGCtx, v_U8_t staId, v_S7_t rssi)
14031{
14032 WLANTL_CbType* pTLCb = VOS_GET_TL_CB(pvosGCtx);
14033
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053014034 if (NULL != pTLCb && NULL != pTLCb->atlSTAClients[staId])
Jeff Johnson295189b2012-06-20 16:38:30 -070014035 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053014036 pTLCb->atlSTAClients[staId]->rssiAvgBmps = rssi;
Jeff Johnson295189b2012-06-20 16:38:30 -070014037 }
14038}
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053014039
14040/*===============================================================================
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053014041 FUNCTION WLANTL_UpdateSnrBmps
14042
14043 DESCRIPTION This function updates the TL's SNR (in BMPS mode)
14044
14045 DEPENDENCIES None
14046
14047 PARAMETERS
14048
14049 pvosGCtx VOS context VOS Global context
14050 staId Station ID Station ID
14051 snr SNR (BMPS mode) SNR in BMPS mode
14052
14053 RETURN None
14054
14055 SIDE EFFECTS none
14056 ===============================================================================*/
14057
14058void WLANTL_UpdateSnrBmps(v_PVOID_t pvosGCtx, v_U8_t staId, v_S7_t snr)
14059{
14060 WLANTL_CbType* pTLCb = VOS_GET_TL_CB(pvosGCtx);
14061
14062 if (NULL != pTLCb && NULL != pTLCb->atlSTAClients[staId])
14063 {
14064 pTLCb->atlSTAClients[staId]->snrAvgBmps = snr;
14065 }
14066}
14067
14068/*===============================================================================
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053014069 FUNCTION WLANTL_UpdateLinkCapacity
14070
14071 DESCRIPTION This function updates the STA's Link Capacity in TL
14072
14073 DEPENDENCIES None
14074
14075 PARAMETERS
14076
14077 pvosGCtx VOS context VOS Global context
14078 staId Station ID Station ID
14079 linkCapacity linkCapacity Link Capacity
14080
14081 RETURN None
14082
14083 SIDE EFFECTS none
14084 ===============================================================================*/
14085
14086void WLANTL_UpdateLinkCapacity(v_PVOID_t pvosGCtx, v_U8_t staId, v_U32_t linkCapacity)
14087{
14088 WLANTL_CbType* pTLCb = VOS_GET_TL_CB(pvosGCtx);
14089
14090 if (NULL != pTLCb && NULL != pTLCb->atlSTAClients[staId])
14091 {
14092 pTLCb->atlSTAClients[staId]->linkCapacity = linkCapacity;
14093 }
14094}
14095
14096
14097/*===========================================================================
14098
14099 FUNCTION WLANTL_GetSTALinkCapacity
14100
14101 DESCRIPTION
14102
14103 Returns Link Capacity of a particular STA.
14104
14105 DEPENDENCIES
14106
14107 A station must have been registered before its state can be retrieved.
14108
14109
14110 PARAMETERS
14111
14112 IN
14113 pvosGCtx: pointer to the global vos context; a handle to TL's
14114 control block can be extracted from its context
14115 ucSTAId: identifier of the station
14116
14117 OUT
14118 plinkCapacity: the current link capacity the connection to
14119 the given station
14120
14121
14122 RETURN VALUE
14123
14124 The result code associated with performing the operation
14125
14126 VOS_STATUS_E_INVAL: Input parameters are invalid
14127 VOS_STATUS_E_FAULT: Station ID is outside array boundaries or pointer to
14128 TL cb is NULL ; access would cause a page fault
14129 VOS_STATUS_E_EXISTS: Station was not registered
14130 VOS_STATUS_SUCCESS: Everything is good :)
14131
14132 SIDE EFFECTS
14133
14134============================================================================*/
14135VOS_STATUS
14136WLANTL_GetSTALinkCapacity
14137(
14138 v_PVOID_t pvosGCtx,
14139 v_U8_t ucSTAId,
14140 v_U32_t *plinkCapacity
14141)
14142{
14143 WLANTL_CbType* pTLCb = NULL;
14144 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
14145
14146 /*------------------------------------------------------------------------
14147 Sanity check
14148 ------------------------------------------------------------------------*/
14149 if ( NULL == plinkCapacity )
14150 {
14151 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
14152 FL("WLAN TL:Invalid parameter")));
14153 return VOS_STATUS_E_INVAL;
14154 }
14155
14156 if ( WLANTL_STA_ID_INVALID( ucSTAId ) )
14157 {
14158 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
14159 FL("WLAN TL:Invalid station id")));
14160 return VOS_STATUS_E_FAULT;
14161 }
14162
14163 /*------------------------------------------------------------------------
14164 Extract TL control block and check existance
14165 ------------------------------------------------------------------------*/
14166 pTLCb = VOS_GET_TL_CB(pvosGCtx);
14167 if ( NULL == pTLCb )
14168 {
14169 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
14170 FL("WLAN TL:Invalid TL pointer from pvosGCtx")));
14171 return VOS_STATUS_E_FAULT;
14172 }
14173
14174 if ( NULL == pTLCb->atlSTAClients[ucSTAId] )
14175 {
14176 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
14177 FL("WLAN TL:Client Memory was not allocated")));
14178 return VOS_STATUS_E_FAILURE;
14179 }
14180
14181 if ( 0 == pTLCb->atlSTAClients[ucSTAId]->ucExists )
14182 {
14183 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
14184 FL("WLAN TL:Station was not previously registered")));
14185 return VOS_STATUS_E_EXISTS;
14186 }
14187
14188 /*------------------------------------------------------------------------
14189 Get STA state
14190 ------------------------------------------------------------------------*/
14191 *plinkCapacity = pTLCb->atlSTAClients[ucSTAId]->linkCapacity;
14192
14193 return VOS_STATUS_SUCCESS;
14194}/* WLANTL_GetSTALinkCapacity */
Abhishek Singh00b71972016-01-07 10:51:04 +053014195
Sravan Kumar Kairam893801a2016-11-01 19:14:23 +053014196/*
14197 * WLANTL_ResetRxSSN - reset last rx ssn
14198 * @pvosGCtx: global vos context
14199 * @ucSTAId: station id
14200 *
14201 * This function resets the last ssn of all tids of the station
14202 * for whom BA reorder session exists.
14203 *
14204 * Return: none
14205 */
14206void WLANTL_ResetRxSSN(v_PVOID_t pvosGCtx, uint8_t ucSTAId)
14207{
14208 WLANTL_CbType* pTLCb = NULL;
14209 WLANTL_STAClientType* pClientSTA = NULL;
14210 uint8_t i;
14211
14212 if (WLANTL_STA_ID_INVALID(ucSTAId)) {
14213 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
14214 "WLAN TL:Invalid station id requested WLANTL_ResetRxSSN"));
14215 return;
14216 }
14217
14218 pTLCb = VOS_GET_TL_CB(pvosGCtx);
14219 if (NULL == pTLCb) {
14220 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
14221 "WLAN TL:Invalid TL pointer from pvosGCtx WLANTL_ResetRxSSN"));
14222 return;
14223 }
14224
14225 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
14226
14227 for (i = 0; i < WLAN_MAX_TID ; i++) {
14228 if (0 == pClientSTA->atlBAReorderInfo[i].ucExists) {
14229 continue;
14230 }
14231 TLLOG1(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
14232 "WLAN TL: Last RxSSN reset to zero for tid %d", i));
14233 pClientSTA->atlBAReorderInfo[i].LastSN = 0;
14234 }
14235}
Abhishek Singh00b71972016-01-07 10:51:04 +053014236
Sravan Kumar Kairama97e2372016-11-11 17:20:03 +053014237void WLANTL_SetDataPktFilter(v_PVOID_t pvosGCtx, uint8_t ucSTAId, bool flag)
14238{
14239 WLANTL_CbType* pTLCb = NULL;
14240 WLANTL_STAClientType* pClientSTA = NULL;
14241 uint8_t i;
14242
14243 if (WLANTL_STA_ID_INVALID(ucSTAId)) {
14244 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
14245 "%s: Invalid station id requested", __func__));
14246 return;
14247 }
14248
14249 pTLCb = VOS_GET_TL_CB(pvosGCtx);
14250 if (NULL == pTLCb) {
14251 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
14252 "%s: Invalid TL pointer from pvosGCtx", __func__));
14253 return;
14254 }
14255
14256 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
14257
14258 for (i = 0; i < WLAN_MAX_TID ; i++) {
14259 if (0 == pClientSTA->atlBAReorderInfo[i].ucExists)
14260 continue;
14261
14262 TLLOG1(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
14263 "WLAN TL: Last RxSSN reset to zero for tid %d", i));
14264 pClientSTA->atlBAReorderInfo[i].set_data_filter = flag;
14265 }
14266}
14267
Sravan Kumar Kairam60b8cf02016-12-12 16:22:09 +053014268/**
14269 * WLANTL_ShiftArrByOne() - utility function to shift array by one
14270 * @arr: pointer to array
14271 * @len: length of the array
14272 *
14273 * Caller responsibility to provide the correct length of the array
14274 * other may leads to bugs.
14275 *
14276 * Return: void
14277 */
14278static void WLANTL_ShiftArrByOne(uint32_t *arr, uint8_t len)
14279{
14280 int i;
14281 for (i = 0; i < len - 1; i ++)
14282 arr[i] = arr[i + 1];
14283 arr[i] = 0;
14284}
14285
14286/**
14287 * WLANTL_SampleTx() - collect tx samples
14288 * @data: TL context pointer
14289 *
14290 * This function records the last five tx bytes sent samples
14291 * collected after tx_bytes_timer expire.
14292 *
14293 * Return: void
14294 */
14295void WLANTL_SampleTx(void *data)
14296{
14297 WLANTL_CbType* pTLCb = (WLANTL_CbType *)data;
14298 WLANTL_STAClientType* pClientSTA = NULL;
14299 uint8_t count = pTLCb->sample_count;
14300 uint8_t i;
14301
14302 for ( i = 0; i < WLAN_MAX_STA_COUNT; i++) {
14303 if (NULL != pTLCb->atlSTAClients[i] &&
14304 pTLCb->atlSTAClients[i]->ucExists) {
14305 pClientSTA = pTLCb->atlSTAClients[i];
14306
14307 if (count > (WLANTL_SAMPLE_COUNT - 1)) {
14308 count = WLANTL_SAMPLE_COUNT - 1;
14309 pClientSTA->tx_samples_sum -= pClientSTA->tx_sample[0];
14310 WLANTL_ShiftArrByOne(pClientSTA->tx_sample, WLANTL_SAMPLE_COUNT);
14311 }
14312
14313 pClientSTA->tx_sample[count] = pClientSTA->tx_frames;
14314 pClientSTA->tx_samples_sum += pClientSTA->tx_sample[count];
14315 pClientSTA->tx_frames = 0;
14316 count++;
14317 pTLCb->sample_count = count;
14318 }
14319 }
14320
14321 vos_timer_start(&pTLCb->tx_frames_timer, WLANTL_SAMPLE_INTERVAL);
14322}
Sravan Kumar Kairam091e5b62017-01-23 14:14:20 +053014323
14324/**
14325 * WLANTL_EnablePreAssocCaching() - Enable caching EAPOL frames
14326 *
14327 * Return: None
14328 *
14329 */
14330void WLANTL_EnablePreAssocCaching(void)
14331{
14332 v_PVOID_t pvosGCtx= vos_get_global_context(VOS_MODULE_ID_TL,NULL);
14333 WLANTL_CbType* pTLCb = VOS_GET_TL_CB(pvosGCtx);
14334 if (NULL == pTLCb ) {
14335 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
14336 "%s: Invalid TL pointer for global context", __func__));
14337 return;
14338 }
14339
14340 pTLCb->vosEapolCachedFrame = NULL;
14341 pTLCb->preassoc_caching = true;
14342}
14343
14344/**
14345 * WLANTL_ForwardPreAssoc() - forward cached eapol frames
14346 * @flag: Value to forward or flush
14347 *
14348 * Return: vos status
14349 *
14350 */
14351static VOS_STATUS WLANTL_ForwardPreAssoc(bool flag)
14352{
14353 vos_msg_t sMessage;
14354
14355 VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
14356 " ---- Serializing TL for forwarding pre assoc cache frames");
14357
14358 vos_mem_zero( &sMessage, sizeof(vos_msg_t));
14359 sMessage.type = WLANTL_RX_FWD_PRE_ASSOC_CACHED;
14360 sMessage.bodyval = flag;
14361
14362 return vos_rx_mq_serialize(VOS_MQ_ID_TL, &sMessage);
14363}
14364
14365/**
14366 * WLANTL_PreAssocForward() - forward cached eapol frames
14367 * @flag: Value to forward or flush
14368 *
14369 * Return: None
14370 *
14371 */
14372void WLANTL_PreAssocForward(bool flag)
14373{
14374 if(!VOS_IS_STATUS_SUCCESS(WLANTL_ForwardPreAssoc(flag)))
14375 {
14376 VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
14377 " %s fails to forward packets", __func__);
14378 }
14379}
14380
14381/**
14382 * WLANTL_RegisterFwdEapol() - register call back to forward cached eapol frame
14383 * @pvosGCtx : pointer to vos global context
14384 * @pfnFwdEapol: call back function pointer
14385 *
14386 * Return: None
14387 *
14388 */
14389void WLANTL_RegisterFwdEapol(v_PVOID_t pvosGCtx,
14390 WLANTL_FwdEapolCBType pfnFwdEapol)
14391{
14392 WLANTL_CbType* pTLCb = NULL;
14393 pTLCb = VOS_GET_TL_CB(pvosGCtx);
14394
14395 pTLCb->pfnEapolFwd = pfnFwdEapol;
14396
14397}
14398
Sravan Kumar Kairamd9e8cbb2017-01-17 12:17:28 +053014399 /**
14400 * WLANTL_SetARPFWDatapath() - keep or remove FW in data path for ARP
14401 *
14402 * @flag: value to keep or remove FW from data path
14403 *
14404 * Return: void
14405 */
14406void WLANTL_SetARPFWDatapath(void * pvosGCtx, bool flag)
14407{
14408
14409 WLANTL_CbType* pTLCb = NULL;
14410
14411 pTLCb = VOS_GET_TL_CB(pvosGCtx);
14412 if (NULL == pTLCb) {
14413 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
14414 "%s: Invalid TL pointer from pvosGCtx", __func__));
14415 return;
14416 }
14417
14418 pTLCb->track_arp = flag;
14419
14420}
14421
Sravan Kumar Kairame0e78442017-09-18 18:00:53 +053014422void WLANTL_GetSAPStaRSSi(void *pvosGCtx, uint8_t ucSTAId, s8 *rssi)
14423{
14424 WLANTL_CbType* pTLCb = NULL;
14425 uint8_t count;
14426
14427 pTLCb = VOS_GET_TL_CB(pvosGCtx);
14428 if (NULL == pTLCb) {
14429 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
14430 "%s: Invalid TL pointer from pvosGCtx", __func__));
14431 return;
14432 }
14433
14434 count = pTLCb->atlSTAClients[ucSTAId]->rssi_sample_cnt;
14435 count < WLANTL_RSSI_SAMPLE_CNT ? count++ : count;
14436
14437 *rssi = pTLCb->atlSTAClients[ucSTAId]->rssi_sample_sum / count;
14438}
14439
Sravan Kumar Kairam8bb90ca2017-11-01 19:00:23 +053014440void WLANTL_SetKeySeqCounter(void *pvosGCtx, u64 counter, uint8_t staid)
14441{
14442 WLANTL_CbType* pTLCb = NULL;
14443 uint8_t i;
14444
14445 pTLCb = VOS_GET_TL_CB(pvosGCtx);
14446 if (NULL == pTLCb) {
14447 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
14448 "%s: Invalid TL pointer from pvosGCtx", __func__));
14449 return;
14450 }
14451
14452 if (WLANTL_STA_ID_INVALID(staid)) {
14453 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
14454 "%s: Invalid Sta id passed", __func__));
14455 return;
14456 }
14457
14458 if (NULL == pTLCb->atlSTAClients[staid]) {
14459 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
14460 "%s: Station context is NULL", __func__));
14461 return;
14462 }
14463
14464 for(i = 0; i < WLANTL_MAX_TID; i++)
14465 pTLCb->atlSTAClients[staid]->ullReplayCounter[i] = counter;
14466}
14467
Abhishek Singh00b71972016-01-07 10:51:04 +053014468#ifdef WLAN_FEATURE_RMC
14469VOS_STATUS WLANTL_RmcInit
14470(
14471 v_PVOID_t pAdapter
14472)
14473{
14474 WLANTL_CbType *pTLCb = VOS_GET_TL_CB(pAdapter);
14475 VOS_STATUS status = VOS_STATUS_SUCCESS;
14476 tANI_U8 count;
14477
14478 /*sanity check*/
14479 if (NULL == pTLCb)
14480 {
14481 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
14482 "Invalid TL handle"));
14483 return VOS_STATUS_E_INVAL;
14484 }
14485
14486 for ( count = 0; count < WLANTL_RMC_HASH_TABLE_SIZE; count++ )
14487 {
14488 pTLCb->rmcSession[count] = NULL;
14489 }
14490
14491 vos_lock_init(&pTLCb->rmcLock);
14492
14493 pTLCb->multicastDuplicateDetectionEnabled = 1;
14494 pTLCb->rmcDataPathEnabled = 0;
14495
14496 return status;
14497}
14498
14499
14500VOS_STATUS WLANTL_RmcDeInit
14501(
14502 v_PVOID_t pAdapter
14503)
14504{
14505 WLANTL_CbType *pTLCb = VOS_GET_TL_CB(pAdapter);
14506 VOS_STATUS status = VOS_STATUS_SUCCESS;
14507 tANI_U8 count;
14508 WLANTL_RMC_SESSION *pNode;
14509 WLANTL_RMC_SESSION *pPrev;
14510
14511 /*sanity check*/
14512 if (NULL == pTLCb)
14513 {
14514 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
14515 "Invalid TL handle"));
14516 return VOS_STATUS_E_INVAL;
14517 }
14518
14519 for ( count = 0; count < WLANTL_RMC_HASH_TABLE_SIZE; count++ )
14520 {
14521 pNode = pTLCb->rmcSession[count];
14522 while (pNode)
14523 {
14524 pPrev = pNode;
14525 pNode = pNode->next;
14526 vos_mem_free((v_VOID_t * )pPrev);
14527 }
14528 }
14529
14530 vos_lock_destroy(&pTLCb->rmcLock);
14531
14532 return status;
14533}
14534
14535
14536tANI_U8 WLANTL_RmcHashRmcSession ( v_MACADDR_t *pMcastAddr )
14537{
14538 tANI_U32 sum;
14539 tANI_U8 hash;
14540
14541 sum = (pMcastAddr->bytes[0] + pMcastAddr->bytes[1] + pMcastAddr->bytes[2] +
14542 pMcastAddr->bytes[3] + pMcastAddr->bytes[4] + pMcastAddr->bytes[5]);
14543
14544 hash = (tANI_U8)(sum & ((WLANTL_RMC_HASH_TABLE_SIZE - 1)));
14545
14546 return hash;
14547}
14548
14549
14550WLANTL_RMC_SESSION* WLANTL_RmcLookUpRmcSession
14551(
14552 WLANTL_RMC_SESSION *rmcSession[],
14553 v_MACADDR_t *pMcastAddr
14554)
14555{
14556 WLANTL_RMC_SESSION *pNode;
14557 tANI_U8 index;
14558
14559 /*sanity check*/
14560 if (NULL == pMcastAddr)
14561 {
14562 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Jeff Johnsonddec6482017-09-19 08:33:57 -070014563 "Sanity check failed pMcastAddr %pK", pMcastAddr));
Abhishek Singh00b71972016-01-07 10:51:04 +053014564 return NULL;
14565 }
14566
14567 index = WLANTL_RmcHashRmcSession(pMcastAddr);
14568 pNode = rmcSession[index];
14569 while ( pNode )
14570 {
14571 if (vos_is_macaddr_equal( &(pNode->rmcAddr), pMcastAddr))
14572 {
14573 return pNode;
14574 }
14575 pNode = pNode->next;
14576 }
14577
14578 return NULL;
14579}
14580
14581WLANTL_RMC_SESSION *WLANTL_RmcAddRmcSession
14582(
14583 WLANTL_RMC_SESSION *rmcSession[],
14584 v_MACADDR_t *pMcastAddr
14585)
14586{
14587 WLANTL_RMC_SESSION *pNode;
14588 tANI_U8 index;
14589
14590 index = WLANTL_RmcHashRmcSession(pMcastAddr);
14591 pNode = WLANTL_RmcLookUpRmcSession(rmcSession, pMcastAddr);
14592 if ( NULL != pNode )
14593 {
14594 /*already exists*/
14595 return NULL;
14596 }
14597 else
14598 {
14599 pNode = (WLANTL_RMC_SESSION *)vos_mem_malloc(sizeof(*pNode));
14600 if (pNode)
14601 {
14602 vos_mem_copy( &(pNode->rmcAddr), pMcastAddr,
14603 sizeof(pNode->rmcAddr) );
14604 pNode->next = rmcSession[index];
14605 rmcSession[index] = pNode;
14606 return pNode;
14607 }
14608 else
14609 {
14610 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14611 "%s: vos_mem_malloc failed can't enable RMC session",
14612 __func__);
14613 return NULL;
14614 }
14615 }
14616}
14617
14618tANI_U8
14619WLANTL_RmcDeleteRmcSession
14620(
14621 WLANTL_RMC_SESSION *rmcSession[],
14622 v_MACADDR_t *pMcastAddr
14623)
14624{
14625 WLANTL_RMC_SESSION *pHead;
14626 WLANTL_RMC_SESSION *pNode;
14627 WLANTL_RMC_SESSION *pPrev;
14628 tANI_U8 index;
14629
14630 index = WLANTL_RmcHashRmcSession(pMcastAddr);
14631 pHead = pNode = rmcSession[index];
14632 while (pNode)
14633 {
14634 if (vos_is_macaddr_equal( &(pNode->rmcAddr), pMcastAddr))
14635 {
14636 if (pHead == pNode)
14637 {
14638 rmcSession[index] = pNode->next;
14639 }
14640 else
14641 {
14642 pPrev->next = pNode->next;
14643 }
14644 vos_mem_free((v_VOID_t * )pNode);
14645 return 1;
14646 }
14647 pPrev = pNode;
14648 pNode = pNode->next;
14649 }
14650
14651 return 0;
14652}
14653
14654VOS_STATUS
14655WLANTL_ProcessRmcCommand
14656(
14657 WLANTL_CbType* pTLCb,
14658 v_MACADDR_t *pMcastAddr,
14659 tANI_U32 command
14660)
14661{
14662 VOS_STATUS status;
14663 tANI_U32 count;
14664 tANI_U32 rmcActive;
14665
14666 if (!VOS_IS_STATUS_SUCCESS(vos_lock_acquire( &(pTLCb->rmcLock))))
14667 {
14668 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
14669 "%s Get Lock Fail", __func__));
14670 return VOS_STATUS_E_FAILURE;
14671 }
14672
14673 /*add or delete node from active rmc hash table*/
14674 if (command)
14675 {
14676 /*add requested rmc session in active rmc session list*/
14677 if (WLANTL_RmcAddRmcSession(pTLCb->rmcSession, pMcastAddr))
14678 {
14679 TLLOGE( VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
14680 "RMC session " MAC_ADDRESS_STR " added in TL hash table",
14681 MAC_ADDR_ARRAY(pMcastAddr->bytes) ) );
14682 pTLCb->rmcDataPathEnabled = TRUE;
14683 status = VOS_STATUS_SUCCESS;
14684 }
14685 else
14686 {
14687 TLLOGE( VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
14688 "RMC session " MAC_ADDRESS_STR " already exists in TL hash"
14689 " table", MAC_ADDR_ARRAY(pMcastAddr->bytes) ) );
14690 status = VOS_STATUS_E_FAILURE;
14691 }
14692 }
14693 else
14694 {
14695 /*delete requested rmc session from active rmc session list*/
14696 if (WLANTL_RmcDeleteRmcSession(pTLCb->rmcSession, pMcastAddr))
14697 {
14698 TLLOGE( VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
14699 "RMC session " MAC_ADDRESS_STR " deleted from TL hash table",
14700 MAC_ADDR_ARRAY(pMcastAddr->bytes)) );
14701 status = VOS_STATUS_SUCCESS;
14702 rmcActive = FALSE;
14703 for ( count = 0; count < WLANTL_RMC_HASH_TABLE_SIZE; count++ )
14704 {
14705 if (pTLCb->rmcSession[count])
14706 {
14707 rmcActive = TRUE;
14708 break;
14709 }
14710 }
14711 if (TRUE == rmcActive)
14712 {
14713 pTLCb->rmcDataPathEnabled = TRUE;
14714 }
14715 else
14716 {
14717 pTLCb->rmcDataPathEnabled = FALSE;
14718 }
14719 }
14720 else
14721 {
14722 TLLOGE( VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
14723 "RMC session " MAC_ADDRESS_STR " doesn't exist in TL hash"
14724 " table", MAC_ADDR_ARRAY(pMcastAddr->bytes) ) );
14725 status = VOS_STATUS_E_FAILURE;
14726 }
14727 }
14728
14729 if (!VOS_IS_STATUS_SUCCESS(vos_lock_release(&(pTLCb->rmcLock))))
14730 {
14731 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
14732 "%s Release Lock Fail", __func__));
14733 return VOS_STATUS_E_FAILURE;
14734 }
14735
14736 return status;
14737}/* End of WLANTL_ProcessRmcCommand */
14738
14739VOS_STATUS
14740WLANTL_EnableRMC
14741(
14742 v_PVOID_t pvosGCtx,
14743 v_MACADDR_t *pMcastTransmitterAddr
14744)
14745{
14746 WLANTL_CbType* pTLCb;
14747 VOS_STATUS status;
14748
14749 /*sanity check*/
14750 if ( (NULL == pvosGCtx) || (NULL == pMcastTransmitterAddr) )
14751 {
14752 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Jeff Johnsonddec6482017-09-19 08:33:57 -070014753 "WLAN TL %s: Sanity check failed pvosGCtx %pK aMcastAddr %pK",
Abhishek Singh00b71972016-01-07 10:51:04 +053014754 __func__, pvosGCtx, pMcastTransmitterAddr));
14755 return VOS_STATUS_E_FAILURE;
14756 }
14757
14758 /*sanity check*/
14759 pTLCb = VOS_GET_TL_CB(pvosGCtx);
14760 if ( NULL == pTLCb )
14761 {
14762 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
14763 "WLAN TL %s: pTLCb is NULL", __func__));
14764 return VOS_STATUS_E_FAILURE;
14765 }
14766
14767 status = WLANTL_ProcessRmcCommand(pTLCb, pMcastTransmitterAddr , 1);
14768
14769 return status;
14770} /* End of WLANTL_EnableRMC */
14771
14772
14773VOS_STATUS
14774WLANTL_DisableRMC
14775(
14776 v_PVOID_t pvosGCtx,
14777 v_MACADDR_t *pMcastTransmitterAddr
14778)
14779{
14780 WLANTL_CbType* pTLCb;
14781 VOS_STATUS status;
14782
14783 /*Sanity check*/
14784 if ((NULL == pvosGCtx) || (NULL == pMcastTransmitterAddr))
14785 {
14786 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Jeff Johnsonddec6482017-09-19 08:33:57 -070014787 "WLAN TL %s: Sanity check failed pvosGCtx %pK aMcastAddr %pK",
Abhishek Singh00b71972016-01-07 10:51:04 +053014788 __func__, pvosGCtx, pMcastTransmitterAddr));
14789 return VOS_STATUS_E_FAILURE;
14790 }
14791
14792 /*Sanity check*/
14793 pTLCb = VOS_GET_TL_CB(pvosGCtx);
14794 if (NULL == pTLCb)
14795 {
14796 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
14797 "WLAN TL %s: pTLCb is NULL", __func__));
14798 return VOS_STATUS_E_FAILURE;
14799 }
14800
14801 status = WLANTL_ProcessRmcCommand(pTLCb, pMcastTransmitterAddr, 0);
14802
14803 return status;
14804} /* End of WLANTL_DisableRMC */
14805
14806
14807/*=============================================================================
14808 Duplicate Multicast Detection Functions
14809==============================================================================*/
14810
14811/*=============================================================================
14812 FUNCTION WLANTL_IsDuplicateMcastFrm
14813
14814 DESCRIPTION
14815 This function checks for duplicast multicast frames and drops them.
14816
14817 DEPENDENCIES
14818
14819 PARAMETERS
14820
14821 IN
14822
14823 pClientSTA : Pointer to WLANTL_STAClientType
14824 aucBDHeader : Pointer to BD header
14825
14826 RETURN VALUE
14827
14828 VOS_FALSE: This frame is not a duplicate
14829
14830 VOS_TRUE: This frame is a duplicate
14831
14832==============================================================================*/
14833v_U8_t
14834WLANTL_IsDuplicateMcastFrm
14835(
14836 WLANTL_STAClientType *pClientSTA,
14837 vos_pkt_t *vosDataBuff
14838)
14839{
14840 v_U8_t duplicate = VOS_FALSE;
14841 WLANTL_RMC_SESSION *pNode;
14842 v_U16_t usSeqCtrl;
14843 v_MACADDR_t mcastAddr;
14844 VOS_STATUS vosStatus;
14845 v_PVOID_t pvPeekData;
14846
14847 /* Get address 1 of Data Frame */
14848 vosStatus = vos_pkt_peek_data(vosDataBuff, WLANTL_MAC_ADDR_ALIGN(1),
14849 (v_PVOID_t)&pvPeekData, VOS_MAC_ADDR_SIZE);
14850
14851 if ( VOS_STATUS_SUCCESS != vosStatus )
14852 {
14853 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
14854 "WLAN TL: Failed to get Addr 1 of 80211 header from packet %d",
14855 vosStatus));
14856 return VOS_FALSE;
14857 }
14858
14859 /* Copy address 1 of Data Frame */
14860 vos_mem_copy(&mcastAddr.bytes, pvPeekData, VOS_MAC_ADDR_SIZE);
14861
14862 /*
14863 * We perform duplicate detection for only multicast data frames
14864 */
14865 if (vos_is_macaddr_group(&mcastAddr) &&
14866 !vos_is_macaddr_broadcast(&mcastAddr))
14867 {
14868 /* Get sequence control of Data Frame */
14869 vosStatus = vos_pkt_peek_data(vosDataBuff,
14870 (WLANTL_MAC_ADDR_ALIGN(1) + (3 * VOS_MAC_ADDR_SIZE)),
14871 (v_PVOID_t)&pvPeekData, sizeof(v_U16_t));
14872
14873 if ( VOS_STATUS_SUCCESS != vosStatus )
14874 {
14875 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
14876 "WLAN TL: Failed to get Sequence Control from packet %d",
14877 vosStatus));
14878 return VOS_FALSE;
14879 }
14880
14881 /* Copy sequence control from the Data Frame */
14882 usSeqCtrl = *(v_U16_t *)pvPeekData;
14883
14884 if (!VOS_IS_STATUS_SUCCESS(vos_lock_acquire(&(pClientSTA->mcLock))))
14885 {
14886 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
14887 "%s Get Lock Fail", __func__));
14888 return VOS_FALSE;
14889 }
14890
14891 pNode = WLANTL_RmcLookUpRmcSession(pClientSTA->mcastSession,
14892 &mcastAddr);
14893 if (NULL == pNode)
14894 {
14895 /* If the session does not exist, add it. */
14896 pNode = WLANTL_RmcAddRmcSession(pClientSTA->mcastSession,
14897 &mcastAddr);
14898 /* If we could not add a entry, skip duplicate detection */
14899 if (NULL == pNode)
14900 {
14901 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
14902 "%s Failed to add multicast session", __func__));
14903 if (!VOS_IS_STATUS_SUCCESS
14904 (vos_lock_release(&(pClientSTA->mcLock))))
14905 {
14906 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
14907 "%s Release Lock Fail", __func__));
14908 }
14909 return VOS_FALSE;
14910 }
14911 /* Initialize the sequence control value. */
14912 pNode->mcSeqCtl = usSeqCtrl;
14913 }
14914 else
14915 {
14916 /*
14917 * Check if the sequence number of this frame matches the last
14918 * we have seen.
14919 */
14920 if (pNode->mcSeqCtl == usSeqCtrl)
14921 {
14922 pNode->rxMCDupcnt++;
14923 TLLOG1(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
14924 "%s Rx Multicast Duplicate %d " MAC_ADDRESS_STR
14925 " (Seq %x)", __func__,
14926 pNode->rxMCDupcnt, MAC_ADDR_ARRAY(mcastAddr.bytes),
14927 usSeqCtrl));
14928 duplicate = VOS_TRUE;
14929 }
14930 else
14931 {
14932 /* Update the last seen sequence number */
14933 pNode->mcSeqCtl = usSeqCtrl;
14934 }
14935 }
14936
14937 if (!VOS_IS_STATUS_SUCCESS (vos_lock_release(&(pClientSTA->mcLock))))
14938 {
14939 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
14940 "%s Release Lock Fail", __func__));
14941 }
14942 }
14943
14944 return duplicate;
14945}
14946
14947/*=============================================================================
14948 FUNCTION WLANTL_McastDeleteAllEntries
14949
14950 DESCRIPTION
14951 This function removes all multicast entries used for duplicate detection
14952
14953 DEPENDENCIES
14954
14955 PARAMETERS
14956
14957 IN
14958
14959 pClientSTA : Pointer to WLANTL_STAClientType
14960
14961 RETURN VALUE
14962
14963 None
14964
14965==============================================================================*/
14966void
14967WLANTL_McastDeleteAllEntries(WLANTL_STAClientType * pClientSTA)
14968{
14969 WLANTL_RMC_SESSION *pNode, **head;
14970 int index;
14971
14972 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
14973 "%s Deleting all multicast entries", __func__));
14974
14975 if (!VOS_IS_STATUS_SUCCESS(vos_lock_acquire(&(pClientSTA->mcLock))))
14976 {
14977 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
14978 "%s Get Lock Fail", __func__));
14979 return;
14980 }
14981
14982 for (index = 0; index < WLANTL_RMC_HASH_TABLE_SIZE; index++)
14983 {
14984 head = &pClientSTA->mcastSession[index];
14985
14986 pNode = *head;
14987
14988 while (pNode)
14989 {
14990 *head = pNode->next;
14991 /* free the group entry */
14992 vos_mem_free(pNode);
14993 pNode = *head;
14994 }
14995 }
14996
14997 if (!VOS_IS_STATUS_SUCCESS (vos_lock_release(&(pClientSTA->mcLock))))
14998 {
14999 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
15000 "%s Release Lock Fail", __func__));
15001 }
15002}
15003
15004/*=============================================================================
15005 FUNCTION WLANTL_SetMcastDuplicateDetection
15006
15007 DESCRIPTION
15008 This function sets multicate duplicate detection operation.
15009 If enable is 1, the detection is enabled, else it is disabled.
15010
15011 DEPENDENCIES
15012
15013 PARAMETERS
15014
15015 IN
15016
15017 pvosGCtx : Pointer to VOS global context
15018 enable : Boolean to enable or disable
15019
15020 RETURN VALUE
15021 The result code associated with performing the operation
15022
15023 VOS_STATUS_E_FAULT: Sanity check on input failed
15024
15025 VOS_STATUS_SUCCESS: Everything is good :)
15026
15027 Other return values are possible coming from the called functions.
15028 Please check API for additional info.
15029
15030 SIDE EFFECTS
15031
15032==============================================================================*/
15033VOS_STATUS
15034WLANTL_SetMcastDuplicateDetection
15035(
15036 v_PVOID_t pvosGCtx,
15037 v_U8_t enable
15038)
15039{
15040 WLANTL_CbType* pTLCb;
15041
15042 /*Sanity check*/
15043 if (NULL == pvosGCtx)
15044 {
15045 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Jeff Johnsonddec6482017-09-19 08:33:57 -070015046 "WLAN TL %s: Sanity check failed pvosGCtx %pK",
Abhishek Singh00b71972016-01-07 10:51:04 +053015047 __func__, pvosGCtx));
15048 return VOS_STATUS_E_FAILURE;
15049 }
15050
15051 /*Sanity check*/
15052 pTLCb = VOS_GET_TL_CB(pvosGCtx);
15053 if (NULL == pTLCb)
15054 {
15055 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
15056 "WLAN TL %s: pTLCb is NULL", __func__));
15057 return VOS_STATUS_E_FAILURE;
15058 }
15059
15060 switch (enable)
15061 {
15062 default:
15063 /*
15064 * Any value other than 0 or 1 is used to dump the
15065 * duplicate count.
15066 */
15067 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
15068 "WLAN TL %s: Multicast Duplicate Count %d",
15069 __func__, pTLCb->mcastDupCnt));
15070 break;
15071 case 0:
15072 case 1:
15073 pTLCb->multicastDuplicateDetectionEnabled = enable;
15074 break;
15075 }
15076
15077 return VOS_STATUS_SUCCESS;
15078}
15079
15080#endif /* WLAN_FEATURE_RMC */