blob: 26b3ab8473b736426d050c560839a8d9f76e3cc2 [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Sravan Kumar Kairam80d06ee2015-09-28 12:53:20 +05302 * Copyright (c) 2011-2015 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.
Gopichand Nakkala92f07d82013-01-08 21:16:34 -080020 */
Kiet Lam1ed83fc2014-02-19 01:15:45 -080021
22/*
23 * This file was originally distributed by Qualcomm Atheros, Inc.
24 * under proprietary terms before Copyright ownership was assigned
25 * to the Linux Foundation.
26 */
27
Jeff Johnson295189b2012-06-20 16:38:30 -070028/**=========================================================================
29 *
30 * \file wlan_qct_wdi_dts.c
31 *
32 * \brief Data Transport Service API
33 *
34 * WLAN Device Abstraction layer External API for Dataservice
35 * DESCRIPTION
36 * This file contains the external API implemntation exposed by the
37 * wlan device abstarction layer module.
38 *
Jeff Johnson295189b2012-06-20 16:38:30 -070039 */
40
41
42#include "wlan_qct_wdi.h"
43#include "wlan_qct_dxe.h"
44#include "wlan_qct_wdi_ds.h"
45#include "wlan_qct_wdi_ds_i.h"
46#include "wlan_qct_wdi_dts.h"
47#include "wlan_qct_wdi_dp.h"
48#include "wlan_qct_wdi_sta.h"
Mukul Sharmadc517962014-06-25 20:28:44 +053049#include "vos_utils.h"
Karthick Sa6616c32015-07-22 14:49:02 +053050#include "vos_api.h"
Mukul Sharmadc517962014-06-25 20:28:44 +053051
Sushant Kaushik33200572015-08-05 16:46:20 +053052
Jeff Johnson295189b2012-06-20 16:38:30 -070053static WDTS_TransportDriverTrype gTransportDriver = {
54 WLANDXE_Open,
55 WLANDXE_Start,
56 WLANDXE_ClientRegistration,
57 WLANDXE_TxFrame,
58 WLANDXE_CompleteTX,
59 WLANDXE_SetPowerState,
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -070060 WLANDXE_ChannelDebug,
Sravan Kumar Kairam6eac7522015-11-27 23:37:02 +053061 WLANDXE_KickDxe,
Jeff Johnson295189b2012-06-20 16:38:30 -070062 WLANDXE_Stop,
63 WLANDXE_Close,
Mihir Shete5affadc2015-05-29 20:54:57 +053064 WLANDXE_GetFreeTxDataResNumber,
65 WLANDXE_SetupLogTransfer,
66 WLANDXE_StartLogTransfer
Jeff Johnson295189b2012-06-20 16:38:30 -070067};
68
69static WDTS_SetPowerStateCbInfoType gSetPowerStateCbInfo;
70
Madan Mohan Koyyalamudi01cba042013-01-10 21:56:05 -080071typedef struct
72{
73 uint32 phyRate; //unit in Mega bits per sec X 10
74 uint32 tputRate; //unit in Mega bits per sec X 10
75 uint32 tputBpms; //unit in Bytes per msec = (tputRateX1024x1024)/(8x10X1000) ~= (tputRate*13)
Kumar Anand90ca3dd2013-01-18 15:24:47 -080076 uint32 tputBpus; //unit in Bytes per usec: round off to integral value
Madan Mohan Koyyalamudi01cba042013-01-10 21:56:05 -080077}WDTS_RateInfo;
78
Viral Modif45f7672013-09-06 13:29:06 -070079#define WDTS_MAX_RATE_NUM 137
80#define WDTS_MAX_11B_RATE_NUM 8
81#define MB_PER_SEC_TO_BYTES_PER_MSEC 13
Kumar Anand90ca3dd2013-01-18 15:24:47 -080082
83WDTS_RateInfo g11bRateInfo[WDTS_MAX_11B_RATE_NUM] = {
84 //11b rates
85 { 10, 9, 117, 8}, //index 0
86 { 20, 17, 221, 5}, //index 1
87 { 55, 41, 533, 2}, //index 2
88 { 110, 68, 884, 1}, //index 3
89
90 //11b short preamble
91 { 10, 10, 130, 8}, //index 4
92 { 20, 18, 234, 5}, //index 5
93 { 55, 44, 572, 2}, //index 6
94 { 110, 77, 1001, 1}, //index 7
95};
Madan Mohan Koyyalamudi01cba042013-01-10 21:56:05 -080096
97WDTS_RateInfo gRateInfo[WDTS_MAX_RATE_NUM] = {
98 //11b rates
Kumar Anand90ca3dd2013-01-18 15:24:47 -080099 { 10, 9, 117, 0}, //index 0
100 { 20, 17, 221, 0}, //index 1
101 { 55, 41, 533, 0}, //index 2
102 { 110, 68, 884, 0}, //index 3
Madan Mohan Koyyalamudi01cba042013-01-10 21:56:05 -0800103
104 //11b short preamble
Kumar Anand90ca3dd2013-01-18 15:24:47 -0800105 { 10, 10, 130, 0}, //index 4
106 { 20, 18, 234, 0}, //index 5
107 { 55, 44, 572, 0}, //index 6
108 { 110, 77, 1001, 0}, //index 7
Madan Mohan Koyyalamudi01cba042013-01-10 21:56:05 -0800109
110 //11ag
Kumar Anand90ca3dd2013-01-18 15:24:47 -0800111 { 60, 50, 650, 1}, //index 8
112 { 90, 70, 910, 1}, //index 9
113 { 120, 100, 1300, 1}, //index 10
114 { 180, 150, 1950, 2}, //index 11
115 { 240, 190, 2470, 2}, //index 12
116 { 360, 280, 3640, 4}, //index 13
117 { 480, 350, 4550, 5}, //index 14
118 { 540, 380, 4940, 6}, //index 15
Madan Mohan Koyyalamudi01cba042013-01-10 21:56:05 -0800119
120 //11n SIMO
Kumar Anand90ca3dd2013-01-18 15:24:47 -0800121 { 65, 54, 702, 1}, //index 16
122 { 130, 108, 1404, 1}, //index 17
123 { 195, 161, 2093, 2}, //index 18
124 { 260, 217, 2821, 3}, //index 19
125 { 390, 326, 4238, 4}, //index 20
126 { 520, 435, 5655, 6}, //index 21
127 { 585, 492, 6396, 6}, //index 22
128 { 650, 548, 7124, 7}, //index 23
Madan Mohan Koyyalamudi01cba042013-01-10 21:56:05 -0800129
130 //11n SIMO SGI
Kumar Anand90ca3dd2013-01-18 15:24:47 -0800131 { 72, 59, 767, 1}, //index 24
132 { 144, 118, 1534, 2}, //index 25
133 { 217, 180, 2340, 2}, //index 26
134 { 289, 243, 3159, 3}, //index 27
135 { 434, 363, 4719, 5}, //index 28
136 { 578, 486, 6318, 6}, //index 29
137 { 650, 548, 7124, 7}, //index 30
138 { 722, 606, 7878, 8}, //index 31
Madan Mohan Koyyalamudi01cba042013-01-10 21:56:05 -0800139
140 //11n GF SIMO
Kumar Anand90ca3dd2013-01-18 15:24:47 -0800141 { 65, 54, 702, 1}, //index 32
142 { 130, 108, 1404, 1}, //index 33
143 { 195, 161, 2093, 2}, //index 34
144 { 260, 217, 2821, 3}, //index 35
145 { 390, 326, 4238, 4}, //index 36
146 { 520, 435, 5655, 6}, //index 37
147 { 585, 492, 6396, 6}, //index 38
148 { 650, 548, 7124, 7}, //index 39
Madan Mohan Koyyalamudi01cba042013-01-10 21:56:05 -0800149
150 //11n SIMO CB MCS 0 - 7
Kumar Anand90ca3dd2013-01-18 15:24:47 -0800151 { 135, 110, 1430, 1}, //index 40
152 { 270, 223, 2899, 3}, //index 41
153 { 405, 337, 4381, 4}, //index 42
154 { 540, 454, 5902, 6}, //index 43
155 { 810, 679, 8827, 9}, //index 44
156 { 1080, 909, 11817, 12}, //index 45
157 { 1215, 1022, 13286, 13}, //index 46
158 { 1350, 1137, 14781, 15}, //index 47
Madan Mohan Koyyalamudi01cba042013-01-10 21:56:05 -0800159
160 //11n SIMO CB SGI MCS 0 - 7
Kumar Anand90ca3dd2013-01-18 15:24:47 -0800161 { 150, 121, 1573, 2}, //index 48
162 { 300, 249, 3237, 3}, //index 49
163 { 450, 378, 4914, 5}, //index 50
164 { 600, 503, 6539, 7}, //index 51
165 { 900, 758, 9854, 10}, //index 52
166 { 1200, 1010, 13130, 13}, //index 53
167 { 1350, 1137, 14781, 15}, //index 54
168 { 1500, 1262, 16406, 16}, //index 55
Madan Mohan Koyyalamudi01cba042013-01-10 21:56:05 -0800169
170 //11n SIMO GF CB MCS 0 - 7
Kumar Anand90ca3dd2013-01-18 15:24:47 -0800171 { 135, 110, 1430, 1}, //index 56
172 { 270, 223, 2899, 3}, //index 57
173 { 405, 337, 4381, 4}, //index 58
174 { 540, 454, 5902, 6}, //index 59
175 { 810, 679, 8827, 9}, //index 60
176 { 1080, 909, 11817, 12}, //index 61
177 { 1215, 1022, 13286, 13}, //index 62
178 { 1350, 1137, 14781, 15}, //index 63
Madan Mohan Koyyalamudi01cba042013-01-10 21:56:05 -0800179
180 //11AC
Viral Modif45f7672013-09-06 13:29:06 -0700181 { 1350, 675, 8775, 9}, //reserved 64
182 { 1350, 675, 8775, 9}, //reserved 65
183 { 65, 45, 585, 1}, //index 66
184 { 130, 91, 1183, 1}, //index 67
185 { 195, 136, 1768, 2}, //index 68
186 { 260, 182, 2366, 2}, //index 69
187 { 390, 273, 3549, 4}, //index 70
188 { 520, 364, 4732, 5}, //index 71
189 { 585, 409, 5317, 5}, //index 72
190 { 650, 455, 5915, 6}, //index 73
191 { 780, 546, 7098, 7}, //index 74
192 { 1350, 675, 8775, 9}, //reserved 75
193 { 1350, 675, 8775, 9}, //reserved 76
194 { 1350, 675, 8775, 9}, //reserved 77
195 { 1350, 675, 8775, 9}, //index 78
196 { 1350, 675, 8775, 9}, //index 79
197 { 1350, 675, 8775, 9}, //index 80
198 { 1350, 675, 8775, 9}, //index 81
199 { 1350, 675, 8775, 9}, //index 82
200 { 1350, 675, 8775, 9}, //index 83
201 { 655, 458, 5954, 6}, //index 84
202 { 722, 505, 6565, 7}, //index 85
203 { 866, 606, 7878, 8}, //index 86
204 { 1350, 675, 8775, 9}, //reserved 87
205 { 1350, 675, 8775, 9}, //reserved 88
206 { 1350, 675, 8775, 9}, //reserved 89
207 { 135, 94, 1222, 1}, //index 90
208 { 270, 189, 2457, 2}, //index 91
209 { 405, 283, 3679, 4}, //index 92
210 { 540, 378, 4914, 5}, //index 93
211 { 810, 567, 7371, 7}, //index 94
212 { 1080, 756, 9828, 10}, //index 95
213 { 1215, 850, 11050, 11}, //index 96
214 { 1350, 675, 8775, 9}, //index 97
215 { 1350, 675, 8775, 9}, //index 98
216 { 1620, 810, 10530, 11}, //index 99
217 { 1800, 900, 11700, 12}, //index 100
218 { 1350, 675, 8775, 9}, //reserved 101
219 { 1350, 675, 8775, 9}, //index 102
220 { 1350, 675, 8775, 9}, //index 103
221 { 1350, 675, 8775, 9}, //index 104
222 { 1350, 675, 8775, 9}, //index 105
223 { 1350, 675, 8775, 9}, //index 106
224 { 1200, 840, 10920, 11}, //index 107
225 { 1350, 675, 8775, 9}, //index 108
226 { 1500, 750, 9750, 10}, //index 109
227 { 1350, 675, 8775, 9}, //index 110
228 { 1800, 900, 11700, 12}, //index 111
229 { 2000, 1000, 13000, 13}, //index 112
230 { 1350, 675, 8775, 9}, //index 113
231 { 292, 204, 2652, 3}, //index 114
232 { 585, 409, 5317, 5}, //index 115
233 { 877, 613, 7969, 8}, //index 116
234 { 1170, 819, 10647, 11}, //index 117
235 { 1755, 877, 11401, 11}, //index 118
236 { 2340, 1170, 15210, 15}, //index 119
237 { 2632, 1316, 17108, 17}, //index 120
238 { 2925, 1462, 19006, 19}, //index 121
239 { 1350, 675, 8775, 9}, //index 122
240 { 3510, 1755, 22815, 23}, //index 123
241 { 3900, 1950, 25350, 25}, //index 124
242 { 1350, 675, 8775, 9}, //reserved 125
243 { 1350, 675, 8775, 9}, //index 126
244 { 1350, 675, 8775, 9}, //index 127
245 { 1350, 675, 8775, 9}, //index 128
246 { 1350, 675, 8775, 9}, //index 129
247 { 1350, 675, 8775, 9}, //index 130
248 { 1350, 675, 8775, 9}, //index 131
249 { 2925, 1462, 19006, 19}, //index 132
250 { 3250, 1625, 21125, 21}, //index 133
251 { 1350, 675, 8775, 9}, //index 134
252 { 3900, 1950, 25350, 25}, //index 135
253 { 4333, 2166, 28158, 28} //index 136
Madan Mohan Koyyalamudi01cba042013-01-10 21:56:05 -0800254 };
255
256/* TX stats */
257typedef struct
258{
259 wpt_uint32 txBytesPushed;
260 wpt_uint32 txPacketsPushed; //Can be removed to optimize memory
261}WDI_DTS_TX_TrafficStatsType;
262
263/* RX stats */
264typedef struct
265{
266 wpt_uint32 rxBytesRcvd;
267 wpt_uint32 rxPacketsRcvd; //Can be removed to optimize memory
268}WDI_DTS_RX_TrafficStatsType;
269
270typedef struct {
271 wpt_uint8 running;
272 WDI_DTS_RX_TrafficStatsType rxStats[HAL_NUM_STA][WDTS_MAX_RATE_NUM];
273 WDI_DTS_TX_TrafficStatsType txStats[HAL_NUM_STA];
274 WDI_TrafficStatsType netTxRxStats[HAL_NUM_STA];
275}WDI_DTS_TrafficStatsType;
276
277static WDI_DTS_TrafficStatsType gDsTrafficStats;
278
Kumar Anand90ca3dd2013-01-18 15:24:47 -0800279#define DTS_RATE_TPUT(x) gRateInfo[x].tputBpus
280#define DTS_11BRATE_TPUT_MULTIPLIER(x) g11bRateInfo[x].tputBpus
Madan Mohan Koyyalamudi01cba042013-01-10 21:56:05 -0800281
Leo Changf8940fd2013-07-12 14:00:25 -0700282/* RX thread frame size threshold to delay frame drain */
283#define DTS_RX_DELAY_FRAMESIZE_THRESHOLD 500
284
Viral Modif45f7672013-09-06 13:29:06 -0700285/* API to fill Rate Info based on the mac efficiency passed to it
286 * macEff si used to caclulate mac throughput based on each rate index/PHY rate.
287 * This is eventually used by MAS to calculate RX stats periodically sent to FW
288 * The start and end Rate Index are the other arguments to this API - the new mac
289 * efficiency passed to this API (Arg1) is only applied between startRateIndex (arg2) and endRateIndex (arg3).
290 */
291void WDTS_FillRateInfo(wpt_uint8 macEff, wpt_int16 startRateIndex, wpt_int16 endRateIndex)
292{
293 int i;
294
Arif Hussain9a5d5382013-11-17 22:05:35 -0800295 DTI_TRACE( DTI_TRACE_LEVEL_ERROR, "Change only 11ac rates");
Viral Modif45f7672013-09-06 13:29:06 -0700296
297 for (i=startRateIndex; i<=endRateIndex; i++)
298 {
299 // tputRate --> unit in Mega bits per sec X 10
300 gRateInfo[i].tputRate = ((gRateInfo[i].phyRate * macEff)/100);
301 // tputBmps --> unit in Bytes per msec = (tputRateX1024x1024)/(8x10X1000) ~= (tputRate*13)
302 gRateInfo[i].tputBpms = gRateInfo[i].tputRate * MB_PER_SEC_TO_BYTES_PER_MSEC;
303 // tputBpus --> unit in Bytes per usec: (+ 500) to round off to integral value
304 gRateInfo[i].tputBpus = ((gRateInfo[i].tputBpms + 500) / 1000);
305 if (gRateInfo[i].tputBpus == 0)
306 gRateInfo[i].tputBpus = 1;
307
308 DTI_TRACE( DTI_TRACE_LEVEL_ERROR, "%4u, %4u, %5u, %2u",
309 gRateInfo[i].phyRate,
310 gRateInfo[i].tputRate,
311 gRateInfo[i].tputBpms,
312 gRateInfo[i].tputBpus );
313 }
314}
315
Madan Mohan Koyyalamudi01cba042013-01-10 21:56:05 -0800316/* Tx/Rx stats function
317 * This function should be invoked to fetch the current stats
318 * Parameters:
319 * pStats:Pointer to the collected stats
320 * len: length of buffer pointed to by pStats
321 * Return Status: None
322 */
323void WDTS_GetTrafficStats(WDI_TrafficStatsType** pStats, wpt_uint32 *len)
324{
325 if(gDsTrafficStats.running)
326 {
327 uint8 staIdx, rate;
328 WDI_TrafficStatsType *pNetTxRxStats = gDsTrafficStats.netTxRxStats;
329 wpalMemoryZero(pNetTxRxStats, sizeof(gDsTrafficStats.netTxRxStats));
330
331 for(staIdx = 0; staIdx < HAL_NUM_STA; staIdx++, pNetTxRxStats++)
332 {
333 pNetTxRxStats->txBytesPushed += gDsTrafficStats.txStats[staIdx].txBytesPushed;
334 pNetTxRxStats->txPacketsPushed+= gDsTrafficStats.txStats[staIdx].txPacketsPushed;
Kumar Anand90ca3dd2013-01-18 15:24:47 -0800335 for(rate = 0; rate < WDTS_MAX_11B_RATE_NUM; rate++)
336 {
337 pNetTxRxStats->rxBytesRcvd +=
338 gDsTrafficStats.rxStats[staIdx][rate].rxBytesRcvd;
339 pNetTxRxStats->rxPacketsRcvd +=
340 gDsTrafficStats.rxStats[staIdx][rate].rxPacketsRcvd;
341 pNetTxRxStats->rxTimeTotal +=
342 gDsTrafficStats.rxStats[staIdx][rate].rxBytesRcvd*DTS_11BRATE_TPUT_MULTIPLIER(rate);
343 }
344 for(rate = WDTS_MAX_11B_RATE_NUM; rate < WDTS_MAX_RATE_NUM; rate++)
Madan Mohan Koyyalamudi01cba042013-01-10 21:56:05 -0800345 {
346 pNetTxRxStats->rxBytesRcvd +=
347 gDsTrafficStats.rxStats[staIdx][rate].rxBytesRcvd;
348 pNetTxRxStats->rxPacketsRcvd +=
349 gDsTrafficStats.rxStats[staIdx][rate].rxPacketsRcvd;
350 pNetTxRxStats->rxTimeTotal +=
Kumar Anand90ca3dd2013-01-18 15:24:47 -0800351 gDsTrafficStats.rxStats[staIdx][rate].rxBytesRcvd/DTS_RATE_TPUT(rate);
Madan Mohan Koyyalamudi01cba042013-01-10 21:56:05 -0800352 }
Kumar Anand90ca3dd2013-01-18 15:24:47 -0800353
354 pNetTxRxStats->rxTimeTotal = pNetTxRxStats->rxTimeTotal/1000;
355
Madan Mohan Koyyalamudi01cba042013-01-10 21:56:05 -0800356 }
357 *pStats = gDsTrafficStats.netTxRxStats;
358 *len = sizeof(gDsTrafficStats.netTxRxStats);
359 }
360 else
361 {
362 *pStats = NULL;
363 *len = 0;
364 }
365}
366
367/* WDTS_DeactivateTrafficStats
368 * This function should be invoked to deactivate traffic stats collection
369 * Parameters: None
370 * Return Status: None
371 */
372void WDTS_DeactivateTrafficStats(void)
373{
374 gDsTrafficStats.running = eWLAN_PAL_FALSE;
375}
376
377/* WDTS_ActivateTrafficStats
378 * This function should be invoked to activate traffic stats collection
379 * Parameters: None
380 * Return Status: None
381 */
382void WDTS_ActivateTrafficStats(void)
383{
384 gDsTrafficStats.running = eWLAN_PAL_TRUE;
385}
386
387/* WDTS_ClearTrafficStats
388 * This function should be invoked to clear traffic stats
389 * Parameters: None
390 * Return Status: None
391 */
392void WDTS_ClearTrafficStats(void)
393{
394 wpalMemoryZero(gDsTrafficStats.rxStats, sizeof(gDsTrafficStats.rxStats));
395 wpalMemoryZero(gDsTrafficStats.txStats, sizeof(gDsTrafficStats.txStats));
396}
397
Jeff Johnson295189b2012-06-20 16:38:30 -0700398/* DTS Tx packet complete function.
399 * This function should be invoked by the transport device to indicate
400 * transmit complete for a frame.
401 * Parameters:
402 * pContext:Cookie that should be passed back to the caller
403 * pFrame:Refernce to PAL frame.
404 * Return Value: SUCCESS Completed successfully.
405 * FAILURE_XXX Request was rejected due XXX Reason.
406 *
407 */
408wpt_status WDTS_TxPacketComplete(void *pContext, wpt_packet *pFrame, wpt_status status)
409{
410 WDI_DS_ClientDataType *pClientData = (WDI_DS_ClientDataType*)(pContext);
411 WDI_DS_TxMetaInfoType *pTxMetadata;
412 void *pvBDHeader, *physBDHeader;
413 wpt_uint8 staIndex;
414
415 // Do Sanity checks
416 if(NULL == pContext || NULL == pFrame){
Mihir Shete63341222015-03-24 15:39:18 +0530417 VOS_TRACE(VOS_MODULE_ID_WDI, VOS_TRACE_LEVEL_WARN,
418 "%s: Tx complete cannot proceed(%p:%p)",
419 __func__, pContext, pFrame);
Jeff Johnson295189b2012-06-20 16:38:30 -0700420 return eWLAN_PAL_STATUS_E_FAILURE;
421 }
422
423
424 // extract metadata from PAL packet
425 pTxMetadata = WDI_DS_ExtractTxMetaData(pFrame);
426 pTxMetadata->txCompleteStatus = status;
427
428 // Free BD header from pool
429 WDI_GetBDPointers(pFrame, &pvBDHeader, &physBDHeader);
430 switch(pTxMetadata->frmType)
431 {
432 case WDI_MAC_DATA_FRAME:
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -0700433 /* note that EAPOL frame hasn't incremented ReserveCount. see
434 WDI_DS_TxPacket() in wlan_qct_wdi_ds.c
435 */
Hoonki Leee10ce392013-02-26 11:47:00 -0800436#ifdef FEATURE_WLAN_TDLS
437 /* I utilizes TDLS mgmt frame always sent at BD_RATE2. (See limProcessTdls.c)
438 Assumption here is data frame sent by WDA_TxPacket() <- HalTxFrame/HalTxFrameWithComplete()
439 should take managment path. As of today, only TDLS feature has special data frame
440 which needs to be treated as mgmt.
441 */
442 if((!pTxMetadata->isEapol) &&
443 ((pTxMetadata->txFlags & WDI_USE_BD_RATE2_FOR_MANAGEMENT_FRAME) != WDI_USE_BD_RATE2_FOR_MANAGEMENT_FRAME))
444#else
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -0700445 if(!pTxMetadata->isEapol)
Hoonki Leee10ce392013-02-26 11:47:00 -0800446#endif
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -0700447 {
Jeff Johnson295189b2012-06-20 16:38:30 -0700448 /* SWAP BD header to get STA index for completed frame */
449 WDI_SwapTxBd(pvBDHeader);
450 staIndex = (wpt_uint8)WDI_TX_BD_GET_STA_ID(pvBDHeader);
451 WDI_DS_MemPoolFree(&(pClientData->dataMemPool), pvBDHeader, physBDHeader);
452 WDI_DS_MemPoolDecreaseReserveCount(&(pClientData->dataMemPool), staIndex);
453 break;
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -0700454 }
455 // intentional fall-through to handle eapol packet as mgmt
Jeff Johnson295189b2012-06-20 16:38:30 -0700456 case WDI_MAC_MGMT_FRAME:
457 WDI_DS_MemPoolFree(&(pClientData->mgmtMemPool), pvBDHeader, physBDHeader);
Mihir Shete63341222015-03-24 15:39:18 +0530458 VOS_TRACE(VOS_MODULE_ID_WDI, VOS_TRACE_LEVEL_INFO,
459 "%s: Management frame Tx complete status: %d", __func__, status);
Jeff Johnson295189b2012-06-20 16:38:30 -0700460 break;
461 }
462 WDI_SetBDPointers(pFrame, 0, 0);
463
464 // Invoke Tx complete callback
465 pClientData->txCompleteCB(pClientData->pCallbackContext, pFrame);
466 return eWLAN_PAL_STATUS_SUCCESS;
467
468}
469
470
471/*===============================================================================
472 FUNCTION WLANTL_GetReplayCounterFromRxBD
473
474 DESCRIPTION This function extracts 48-bit replay packet number from RX BD
475
476 DEPENDENCIES Validity of replay check must be done before the function
477 is called
478
479 PARAMETERS pucRxHeader pointer to RX BD header
480
481 RETRUN v_U64_t Packet number extarcted from RX BD
482
483 SIDE EFFECTS none
484 ===============================================================================*/
485v_U64_t
486WDTS_GetReplayCounterFromRxBD
487(
488 v_U8_t *pucRxBDHeader
489)
490{
491 v_U64_t ullcurrentReplayCounter = 0;
492 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
493/* 48-bit replay counter is created as follows
494 from RX BD 6 byte PMI command:
495 Addr : AES/TKIP
496 0x38 : pn3/tsc3
497 0x39 : pn2/tsc2
498 0x3a : pn1/tsc1
499 0x3b : pn0/tsc0
500
501 0x3c : pn5/tsc5
502 0x3d : pn4/tsc4 */
503
504#ifdef ANI_BIG_BYTE_ENDIAN
505 /* Getting 48-bit replay counter from the RX BD */
506 ullcurrentReplayCounter = WDI_RX_BD_GET_PMICMD_20TO23(pucRxBDHeader);
507 ullcurrentReplayCounter <<= 16;
508 ullcurrentReplayCounter |= (( WDI_RX_BD_GET_PMICMD_24TO25(pucRxBDHeader) & 0xFFFF0000) >> 16);
509 return ullcurrentReplayCounter;
510#else
511 /* Getting 48-bit replay counter from the RX BD */
512 ullcurrentReplayCounter = (WDI_RX_BD_GET_PMICMD_24TO25(pucRxBDHeader) & 0x0000FFFF);
513 ullcurrentReplayCounter <<= 32;
514 ullcurrentReplayCounter |= WDI_RX_BD_GET_PMICMD_20TO23(pucRxBDHeader);
515 return ullcurrentReplayCounter;
516#endif
517}
518
519
520/* DTS Rx packet function.
521 * This function should be invoked by the transport device to indicate
522 * reception of a frame.
523 * Parameters:
524 * pContext:Cookie that should be passed back to the caller
525 * pFrame:Refernce to PAL frame.
526 * Return Value: SUCCESS Completed successfully.
527 * FAILURE_XXX Request was rejected due XXX Reason.
528 *
529 */
530wpt_status WDTS_RxPacket (void *pContext, wpt_packet *pFrame, WDTS_ChannelType channel)
531{
532 WDI_DS_ClientDataType *pClientData =
533 (WDI_DS_ClientDataType*)(pContext);
534 wpt_boolean bASF, bFSF, bLSF, bAEF;
535 wpt_uint8 ucMPDUHOffset, ucMPDUHLen, ucTid;
536 wpt_uint8 *pBDHeader;
537 wpt_uint16 usMPDUDOffset, usMPDULen;
538 WDI_DS_RxMetaInfoType *pRxMetadata;
539 wpt_uint8 isFcBd = 0;
Hanumantha Reddy Pothulae00a7e22015-09-15 20:11:30 +0530540 WDI_DS_LoggingSessionType *pLoggingSession;
Sushant Kaushik33200572015-08-05 16:46:20 +0530541 tPerPacketStats rxStats = {0};
542
Jeff Johnson295189b2012-06-20 16:38:30 -0700543 tpSirMacFrameCtl pMacFrameCtl;
544 // Do Sanity checks
545 if(NULL == pContext || NULL == pFrame){
546 return eWLAN_PAL_STATUS_E_FAILURE;
547 }
548
Mihir Shete5affadc2015-05-29 20:54:57 +0530549 // Normal DMA transfer does not contain RxBD
550 if (WDTS_CHANNEL_RX_FW_LOG == channel)
551 {
Hanumantha Reddy Pothulae00a7e22015-09-15 20:11:30 +0530552 pLoggingSession = (WDI_DS_LoggingSessionType *)
553 WDI_DS_GetLoggingSession(pContext);
554 wpalFwLogPktSerialize(pFrame, pLoggingSession->logType);
Mihir Shete5affadc2015-05-29 20:54:57 +0530555
556 return eWLAN_PAL_STATUS_SUCCESS;
557 }
558
Jeff Johnson295189b2012-06-20 16:38:30 -0700559 /*------------------------------------------------------------------------
560 Extract BD header and check if valid
561 ------------------------------------------------------------------------*/
562 pBDHeader = (wpt_uint8*)wpalPacketGetRawBuf(pFrame);
563 if(NULL == pBDHeader)
564 {
565 DTI_TRACE( DTI_TRACE_LEVEL_ERROR,
566 "WLAN TL:BD header received NULL - dropping packet");
567 wpalPacketFree(pFrame);
568 return eWLAN_PAL_STATUS_E_FAILURE;
569 }
570 WDI_SwapRxBd(pBDHeader);
571
572 ucMPDUHOffset = (wpt_uint8)WDI_RX_BD_GET_MPDU_H_OFFSET(pBDHeader);
573 usMPDUDOffset = (wpt_uint16)WDI_RX_BD_GET_MPDU_D_OFFSET(pBDHeader);
574 usMPDULen = (wpt_uint16)WDI_RX_BD_GET_MPDU_LEN(pBDHeader);
575 ucMPDUHLen = (wpt_uint8)WDI_RX_BD_GET_MPDU_H_LEN(pBDHeader);
576 ucTid = (wpt_uint8)WDI_RX_BD_GET_TID(pBDHeader);
577
Leo Changf8940fd2013-07-12 14:00:25 -0700578 /* If RX thread drain small size of frame from HW too fast
579 * Sometimes HW cannot handle interrupt fast enough
580 * And system crash might happen
581 * To avoid system crash, input 1usec delay each frame draining
582 * within host side, if frame size is smaller that threshold.
583 * This is SW work around, to fix HW problem
584 * Throughput and SnS test done successfully */
585 if (usMPDULen < DTS_RX_DELAY_FRAMESIZE_THRESHOLD)
586 {
587 wpalBusyWait(1);
588 }
589
Jeff Johnson295189b2012-06-20 16:38:30 -0700590 /*------------------------------------------------------------------------
591 Gather AMSDU information
592 ------------------------------------------------------------------------*/
593 bASF = WDI_RX_BD_GET_ASF(pBDHeader);
594 bAEF = WDI_RX_BD_GET_AEF(pBDHeader);
595 bFSF = WDI_RX_BD_GET_ESF(pBDHeader);
596 bLSF = WDI_RX_BD_GET_LSF(pBDHeader);
597 isFcBd = WDI_RX_FC_BD_GET_FC(pBDHeader);
598
599 DTI_TRACE( DTI_TRACE_LEVEL_INFO,
600 "WLAN TL:BD header processing data: HO %d DO %d Len %d HLen %d"
601 " Tid %d BD %d",
602 ucMPDUHOffset, usMPDUDOffset, usMPDULen, ucMPDUHLen, ucTid,
603 WDI_RX_BD_HEADER_SIZE);
604
Mihir Shete2187b8c2015-03-18 16:54:29 +0530605 pRxMetadata = WDI_DS_ExtractRxMetaData(pFrame);
606
607 // Special handling for frames which contain logging information
608 if (WDTS_CHANNEL_RX_LOG == channel)
609 {
610 if(VPKT_SIZE_BUFFER_ALIGNED < (usMPDULen+ucMPDUHOffset)){
611 WPAL_TRACE(eWLAN_MODULE_DAL_DATA, eWLAN_PAL_TRACE_LEVEL_FATAL,
612 "Invalid Frame size, might memory corrupted(%d+%d/%d)",
613 usMPDULen, ucMPDUHOffset, VPKT_SIZE_BUFFER_ALIGNED);
614
615 /* Size of the packet tranferred by the DMA engine is
616 * greater than the the memory allocated for the skb
617 */
618 WPAL_BUG(0);
619
620 wpalPacketFree(pFrame);
621 return eWLAN_PAL_STATUS_SUCCESS;
622 }
623
624 /* Firmware should send the Header offset as length
625 * of RxBd and data length should be populated to
626 * the length of total data being sent
627 */
628 wpalPacketSetRxLength(pFrame, usMPDULen+ucMPDUHOffset);
629 wpalPacketRawTrimHead(pFrame, ucMPDUHOffset);
630
631 // Invoke Rx complete callback
632 wpalLogPktSerialize(pFrame);
633
634 return eWLAN_PAL_STATUS_SUCCESS;
635 }
636 else
637 {
638 pRxMetadata->loggingData = 0;
639 }
640
Jeff Johnson295189b2012-06-20 16:38:30 -0700641 if(!isFcBd)
642 {
643 if(usMPDUDOffset <= ucMPDUHOffset || usMPDULen < ucMPDUHLen) {
644 DTI_TRACE( DTI_TRACE_LEVEL_ERROR,
645 "WLAN TL:BD header corrupted - dropping packet");
646 /* Drop packet ???? */
647 wpalPacketFree(pFrame);
648 return eWLAN_PAL_STATUS_SUCCESS;
649 }
650
651 if((ucMPDUHOffset < WDI_RX_BD_HEADER_SIZE) && (!(bASF && !bFSF))){
652 /* AMSDU case, ucMPDUHOffset = 0 it should be hancdled seperatly */
653 /* Drop packet ???? */
654 wpalPacketFree(pFrame);
655 return eWLAN_PAL_STATUS_SUCCESS;
656 }
657
658 /* AMSDU frame, but not first sub-frame
659 * No MPDU header, MPDU header offset is 0
660 * Total frame size is actual frame size + MPDU data offset */
661 if((ucMPDUHOffset < WDI_RX_BD_HEADER_SIZE) && (bASF && !bFSF)){
662 ucMPDUHOffset = usMPDUDOffset;
663 }
664
Mihir Sheteeb95ede2014-09-03 14:37:54 +0530665 if(VPKT_SIZE_BUFFER_ALIGNED < (usMPDULen+ucMPDUHOffset)){
666 WPAL_TRACE(eWLAN_MODULE_DAL_DATA, eWLAN_PAL_TRACE_LEVEL_FATAL,
667 "Invalid Frame size, might memory corrupted(%d+%d/%d)",
668 usMPDULen, ucMPDUHOffset, VPKT_SIZE_BUFFER_ALIGNED);
Madan Mohan Koyyalamudic69614b2013-08-20 19:15:47 +0530669
670 /* Size of the packet tranferred by the DMA engine is
671 * greater than the the memory allocated for the skb
672 */
673 WPAL_BUG(0);
674
Jeff Johnson295189b2012-06-20 16:38:30 -0700675 wpalPacketFree(pFrame);
676 return eWLAN_PAL_STATUS_SUCCESS;
677 }
Leela V Kiran Kumar Reddy Chirala6a458752013-02-16 15:41:27 -0800678 if(eWLAN_PAL_STATUS_SUCCESS != wpalPacketSetRxLength(pFrame, usMPDULen+ucMPDUHOffset))
679 {
680 DTI_TRACE( DTI_TRACE_LEVEL_ERROR, "Invalid Frame Length, Frame dropped..");
681 wpalPacketFree(pFrame);
682 return eWLAN_PAL_STATUS_SUCCESS;
683 }
684 if(eWLAN_PAL_STATUS_SUCCESS != wpalPacketRawTrimHead(pFrame, ucMPDUHOffset))
685 {
686 DTI_TRACE( DTI_TRACE_LEVEL_ERROR, "Failed to trim Raw Packet Head, Frame dropped..");
687 wpalPacketFree(pFrame);
688 return eWLAN_PAL_STATUS_SUCCESS;
689 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700690
691 pRxMetadata->fc = isFcBd;
692 pRxMetadata->staId = WDI_RX_BD_GET_STA_ID(pBDHeader);
693 pRxMetadata->addr3Idx = WDI_RX_BD_GET_ADDR3_IDX(pBDHeader);
694 pRxMetadata->rxChannel = WDI_RX_BD_GET_RX_CHANNEL(pBDHeader);
Kiran Kumar Lokere79540f92013-04-25 17:32:16 -0700695 pRxMetadata->rfBand = WDI_RX_BD_GET_RFBAND(pBDHeader);
Jeff Johnson295189b2012-06-20 16:38:30 -0700696 pRxMetadata->rtsf = WDI_RX_BD_GET_RTSF(pBDHeader);
697 pRxMetadata->bsf = WDI_RX_BD_GET_BSF(pBDHeader);
698 pRxMetadata->scan = WDI_RX_BD_GET_SCAN(pBDHeader);
699 pRxMetadata->dpuSig = WDI_RX_BD_GET_DPU_SIG(pBDHeader);
700 pRxMetadata->ft = WDI_RX_BD_GET_FT(pBDHeader);
701 pRxMetadata->ne = WDI_RX_BD_GET_NE(pBDHeader);
702 pRxMetadata->llcr = WDI_RX_BD_GET_LLCR(pBDHeader);
703 pRxMetadata->bcast = WDI_RX_BD_GET_UB(pBDHeader);
704 pRxMetadata->tid = ucTid;
705 pRxMetadata->dpuFeedback = WDI_RX_BD_GET_DPU_FEEDBACK(pBDHeader);
706 pRxMetadata->rateIndex = WDI_RX_BD_GET_RATEINDEX(pBDHeader);
707 pRxMetadata->rxpFlags = WDI_RX_BD_GET_RXPFLAGS(pBDHeader);
708 pRxMetadata->mclkRxTimestamp = WDI_RX_BD_GET_TIMESTAMP(pBDHeader);
Chet Lanctot186b5732013-03-18 10:26:30 -0700709#ifdef WLAN_FEATURE_11W
710 pRxMetadata->rmf = WDI_RX_BD_GET_RMF(pBDHeader);
711#endif
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -0700712#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
713 pRxMetadata->offloadScanLearn = WDI_RX_BD_GET_OFFLOADSCANLEARN(pBDHeader);
714 pRxMetadata->roamCandidateInd = WDI_RX_BD_GET_ROAMCANDIDATEIND(pBDHeader);
715#endif
Dino Mycle41bdc942014-06-10 11:30:24 +0530716#ifdef WLAN_FEATURE_EXTSCAN
717 pRxMetadata->extscanBuffer = WDI_RX_BD_GET_EXTSCANFULLSCANRESIND(pBDHeader);
718#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700719 /* typeSubtype in BD doesn't look like correct. Fill from frame ctrl
720 TL does it for Volans but TL does not know BD for Prima. WDI should do it */
721 if ( 0 == WDI_RX_BD_GET_FT(pBDHeader) ) {
722 if ( bASF ) {
723 pRxMetadata->subtype = WDI_MAC_DATA_QOS_DATA;
724 pRxMetadata->type = WDI_MAC_DATA_FRAME;
725 } else {
726 pMacFrameCtl = (tpSirMacFrameCtl)(((wpt_uint8*)pBDHeader) + ucMPDUHOffset);
727 pRxMetadata->subtype = pMacFrameCtl->subType;
728 pRxMetadata->type = pMacFrameCtl->type;
729 }
730 } else {
731 pMacFrameCtl = (tpSirMacFrameCtl)(((wpt_uint8*)pBDHeader) + WDI_RX_BD_HEADER_SIZE);
732 pRxMetadata->subtype = pMacFrameCtl->subType;
733 pRxMetadata->type = pMacFrameCtl->type;
734 }
735
736 pRxMetadata->mpduHeaderPtr = pBDHeader + ucMPDUHOffset;
737 pRxMetadata->mpduDataPtr = pBDHeader + usMPDUDOffset;
738 pRxMetadata->mpduLength = usMPDULen;
739 pRxMetadata->mpduHeaderLength = ucMPDUHLen;
740
741 /*------------------------------------------------------------------------
742 Gather AMPDU information
743 ------------------------------------------------------------------------*/
744 pRxMetadata->ampdu_reorderOpcode = (wpt_uint8)WDI_RX_BD_GET_BA_OPCODE(pBDHeader);
745 pRxMetadata->ampdu_reorderSlotIdx = (wpt_uint8)WDI_RX_BD_GET_BA_SI(pBDHeader);
746 pRxMetadata->ampdu_reorderFwdIdx = (wpt_uint8)WDI_RX_BD_GET_BA_FI(pBDHeader);
Madan Mohan Koyyalamudi31e4cad2013-08-21 20:21:14 +0530747 pRxMetadata->currentPktSeqNo = (wpt_uint16)WDI_RX_BD_GET_BA_CSN(pBDHeader);
Jeff Johnson295189b2012-06-20 16:38:30 -0700748
749
750 /*------------------------------------------------------------------------
751 Gather AMSDU information
752 ------------------------------------------------------------------------*/
753 pRxMetadata->amsdu_asf = bASF;
754 pRxMetadata->amsdu_aef = bAEF;
755 pRxMetadata->amsdu_esf = bFSF;
756 pRxMetadata->amsdu_lsf = bLSF;
757 pRxMetadata->amsdu_size = WDI_RX_BD_GET_AMSDU_SIZE(pBDHeader);
758
759 pRxMetadata->rssi0 = WDI_RX_BD_GET_RSSI0(pBDHeader);
760 pRxMetadata->rssi1 = WDI_RX_BD_GET_RSSI1(pBDHeader);
761
762
763 /* Missing:
764 wpt_uint32 fcSTATxQStatus:8;
765 wpt_uint32 fcSTAThreshIndMask:8;
766 wpt_uint32 fcSTAPwrSaveStateMask:8;
767 wpt_uint32 fcSTAValidMask:8;
768
769 wpt_uint8 fcSTATxQLen[8]; // one byte per STA.
770 wpt_uint8 fcSTACurTxRate[8]; // current Tx rate for each sta.
771 unknownUcastPkt
772 */
773
774 pRxMetadata->replayCount = WDTS_GetReplayCounterFromRxBD(pBDHeader);
775 pRxMetadata->snr = WDI_RX_BD_GET_SNR(pBDHeader);
776
777 /*
778 * PAL BD pointer information needs to be populated
779 */
780 WPAL_PACKET_SET_BD_POINTER(pFrame, pBDHeader);
781 WPAL_PACKET_SET_BD_LENGTH(pFrame, sizeof(WDI_RxBdType));
782
Girish Gowli55caa852015-01-19 16:09:49 +0530783 if (((WDI_ControlBlockType *)pClientData->pcontext)->roamDelayStatsEnabled)
Mukul Sharmadc517962014-06-25 20:28:44 +0530784 {
Girish Gowli55caa852015-01-19 16:09:49 +0530785 vos_record_roam_event(e_DXE_RX_PKT_TIME, (void *)pFrame, pRxMetadata->type);
Mukul Sharmadc517962014-06-25 20:28:44 +0530786 }
Sushant Kaushik33200572015-08-05 16:46:20 +0530787 if ((WLAN_LOG_LEVEL_ACTIVE ==
788 vos_get_ring_log_level(RING_ID_PER_PACKET_STATS)) &&
Abhishek Singhb3e1e7b2015-10-12 16:23:33 +0530789 !(WDI_MAC_CTRL_FRAME == pRxMetadata->type))
Sushant Kaushik33200572015-08-05 16:46:20 +0530790 {
791 vos_mem_zero(&rxStats,sizeof(tPerPacketStats));
792 /* Peer tx packet and it is an Rx packet for us */
793 rxStats.is_rx= VOS_TRUE;
794 rxStats.tid = ucTid;
795 rxStats.rssi = (pRxMetadata->rssi0 > pRxMetadata->rssi1)?
796 pRxMetadata->rssi0 : pRxMetadata->rssi1;
797 rxStats.rate_idx = pRxMetadata->rateIndex;
798 rxStats.seq_num = pRxMetadata->currentPktSeqNo;
799 rxStats.dxe_timestamp = vos_timer_get_system_ticks();
Abhishek Singhb3e1e7b2015-10-12 16:23:33 +0530800 rxStats.data_len =
801 vos_copy_80211_data(pFrame, rxStats.data, pRxMetadata->type);
Sushant Kaushik33200572015-08-05 16:46:20 +0530802 wpalPerPktSerialize(&rxStats);
803 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700804 // Invoke Rx complete callback
805 pClientData->receiveFrameCB(pClientData->pCallbackContext, pFrame);
806 }
807 else
808 {
809 wpalPacketSetRxLength(pFrame, usMPDULen+ucMPDUHOffset);
810 wpalPacketRawTrimHead(pFrame, ucMPDUHOffset);
811
Jeff Johnson295189b2012-06-20 16:38:30 -0700812 //flow control related
813 pRxMetadata->fc = isFcBd;
Hoonki Lee14621352013-04-16 17:51:19 -0700814 pRxMetadata->mclkRxTimestamp = WDI_RX_BD_GET_TIMESTAMP(pBDHeader);
Jeff Johnson295189b2012-06-20 16:38:30 -0700815 pRxMetadata->fcStaTxDisabledBitmap = WDI_RX_FC_BD_GET_STA_TX_DISABLED_BITMAP(pBDHeader);
816 pRxMetadata->fcSTAValidMask = WDI_RX_FC_BD_GET_STA_VALID_MASK(pBDHeader);
817 // Invoke Rx complete callback
818 pClientData->receiveFrameCB(pClientData->pCallbackContext, pFrame);
819 }
Madan Mohan Koyyalamudi01cba042013-01-10 21:56:05 -0800820
821 //Log the RX Stats
822 if(gDsTrafficStats.running && pRxMetadata->staId < HAL_NUM_STA)
823 {
824 if(pRxMetadata->rateIndex < WDTS_MAX_RATE_NUM)
825 {
Kumar Anand90ca3dd2013-01-18 15:24:47 -0800826 if(pRxMetadata->type == WDI_MAC_DATA_FRAME)
827 {
828 gDsTrafficStats.rxStats[pRxMetadata->staId][pRxMetadata->rateIndex].rxBytesRcvd +=
829 pRxMetadata->mpduLength;
830 gDsTrafficStats.rxStats[pRxMetadata->staId][pRxMetadata->rateIndex].rxPacketsRcvd++;
831 }
Madan Mohan Koyyalamudi01cba042013-01-10 21:56:05 -0800832 }
833 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700834 return eWLAN_PAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -0700835}
836
837
838
839/* DTS Out of Resource packet function.
840 * This function should be invoked by the transport device to indicate
841 * the device is out of resources.
842 * Parameters:
843 * pContext:Cookie that should be passed back to the caller
844 * priority: indicates which channel is out of resource.
845 * Return Value: SUCCESS Completed successfully.
846 * FAILURE_XXX Request was rejected due XXX Reason.
847 */
848wpt_status WDTS_OOResourceNotification(void *pContext, WDTS_ChannelType channel, wpt_boolean on)
849{
850 WDI_DS_ClientDataType *pClientData =
851 (WDI_DS_ClientDataType *) pContext;
852 static wpt_uint8 ac_mask = 0x1f;
853
854 // Do Sanity checks
855 if(NULL == pContext){
856 return eWLAN_PAL_STATUS_E_FAILURE;
857 }
858
859 if(on){
860 ac_mask |= channel == WDTS_CHANNEL_TX_LOW_PRI? 0x0f : 0x10;
861 } else {
862 ac_mask &= channel == WDTS_CHANNEL_TX_LOW_PRI? 0x10 : 0x0f;
863 }
864
865
866 // Invoke OOR callback
867 pClientData->txResourceCB(pClientData->pCallbackContext, ac_mask);
868 return eWLAN_PAL_STATUS_SUCCESS;
869
870}
871
Mihir Shete5affadc2015-05-29 20:54:57 +0530872void WDTS_LogRxDone(void *pContext)
873{
Karthick Sa6616c32015-07-22 14:49:02 +0530874 WDI_DS_LoggingSessionType *pLoggingSession;
875
876 pLoggingSession = (WDI_DS_LoggingSessionType *)
877 WDI_DS_GetLoggingSession(pContext);
878
879 if (NULL == pContext || pLoggingSession == NULL)
Mihir Shete5affadc2015-05-29 20:54:57 +0530880 {
881 return;
882 }
Karthick Sa6616c32015-07-22 14:49:02 +0530883 /* check for done and Log type Mgmt frame = 0, QXDM = 1, FW Mem dump = 2 */
884 if (pLoggingSession->done && pLoggingSession->logType <= VALID_FW_LOG_TYPES)
Hanumantha Reddy Pothulae00a7e22015-09-15 20:11:30 +0530885 vos_process_done_indication(pLoggingSession->logType,
886 pLoggingSession->reasonCode);
887
Sachin Ahujac08f72a2015-09-22 15:25:47 +0530888
889 if (pLoggingSession->logType == QXDM_LOGGING &&
890 pLoggingSession->reasonCode)
891 pLoggingSession->logType = FATAL_EVENT;
Hanumantha Reddy Pothulae00a7e22015-09-15 20:11:30 +0530892 ((WDI_DS_ClientDataType *)(pContext))->rxLogCB(pLoggingSession->logType);
Mihir Shete5affadc2015-05-29 20:54:57 +0530893
Karthick Sa6616c32015-07-22 14:49:02 +0530894 pLoggingSession->done = 0;
895 pLoggingSession->logType = 0;
Hanumantha Reddy Pothulae00a7e22015-09-15 20:11:30 +0530896 pLoggingSession->reasonCode = 0;
Mihir Shete5affadc2015-05-29 20:54:57 +0530897
Mihir Shetec4093f92015-05-28 15:21:11 +0530898 return;
899}
900
Sravan Kumar Kairam80d06ee2015-09-28 12:53:20 +0530901void WDTS_MbReceiveMsg(void *pContext)
902{
903 tpLoggingMailBox pLoggingMb;
904 WDI_DS_LoggingSessionType *pLoggingSession;
905 wpt_int8 i, noMem = 0;
906 wpt_uint32 totalLen = 0;
907
908 pLoggingMb = (tpLoggingMailBox)WDI_DS_GetLoggingMbAddr(pContext);
909 pLoggingSession = (WDI_DS_LoggingSessionType *)
910 WDI_DS_GetLoggingSession(pContext);
911
912 for(i = 0; i < MAX_NUM_OF_BUFFER; i++)
913 {
914 totalLen += pLoggingMb->logBuffLength[i];
915 // Send done indication when the logbuffer size exceeds 128KB.
916 if (totalLen > MAX_LOG_BUFFER_LENGTH || pLoggingMb->logBuffLength[i] > MAX_LOG_BUFFER_LENGTH)
917 {
918 DTI_TRACE( DTI_TRACE_LEVEL_ERROR, " %d received invalid log buffer length",
919 totalLen);
920 // Done using Mailbox, zero out the memory.
921 wpalMemoryZero(pLoggingMb, sizeof(tLoggingMailBox));
922 wpalMemoryZero(pLoggingSession, sizeof(WDI_DS_LoggingSessionType));
923 //Set Status as Failure
924 pLoggingSession->status = WDTS_LOGGING_STATUS_ERROR;
925 WDTS_LogRxDone(pContext);
926
927 return;
928 }
929 }
930
931 totalLen = 0;
932 for(i = 0; i < MAX_NUM_OF_BUFFER; i++)
933 {
934 pLoggingSession->logBuffAddress[i] = pLoggingMb->logBuffAddress[i];
935 if (!noMem)
936 {
937 pLoggingSession->logBuffLength[i] = gTransportDriver.setupLogTransfer(
938 pLoggingMb->logBuffAddress[i],
939 pLoggingMb->logBuffLength[i]);
940 }
941 else
942 {
943 pLoggingSession->logBuffLength[i] = 0;
944 continue;
945 }
946
947 totalLen += pLoggingSession->logBuffLength[i];
948
949 if (pLoggingSession->logBuffLength[i] < pLoggingMb->logBuffLength[i])
950 {
951 noMem = 1;
952 }
953 }
954
955 pLoggingSession->done = pLoggingMb->done;
956 pLoggingSession->logType = pLoggingMb->logType;
957 pLoggingSession->reasonCode = pLoggingMb->reasonCode;
958 pLoggingSession->status = WDTS_LOGGING_STATUS_SUCCESS;
959 // Done using Mailbox, zero out the memory.
960 wpalMemoryZero(pLoggingMb, sizeof(tLoggingMailBox));
961
962 if (totalLen)
963 {
964 if (gTransportDriver.startLogTransfer() == eWLAN_PAL_STATUS_SUCCESS)
965 return;
966 }
967
968 // Send Done event to upper layers, since we wont be getting any from DXE
969}
970
Jeff Johnson295189b2012-06-20 16:38:30 -0700971/* DTS open function.
972 * On open the transport device should initialize itself.
973 * Parameters:
974 * pContext:Cookie that should be passed back to the caller along
975 * with the callback.
976 *
977 * Return Value: SUCCESS Completed successfully.
978 * FAILURE_XXX Request was rejected due XXX Reason.
979 *
980 */
981wpt_status WDTS_openTransport( void *pContext)
982{
983 void *pDTDriverContext;
984 WDI_DS_ClientDataType *pClientData;
985 WDI_Status sWdiStatus = WDI_STATUS_SUCCESS;
Mihir Shetec4093f92015-05-28 15:21:11 +0530986 WDTS_ClientCallbacks WDTSCb;
Jeff Johnson295189b2012-06-20 16:38:30 -0700987
988 pClientData = (WDI_DS_ClientDataType*) wpalMemoryAllocate(sizeof(WDI_DS_ClientDataType));
989 if (!pClientData){
990 return eWLAN_PAL_STATUS_E_NOMEM;
991 }
992
993 pClientData->suspend = 0;
994 WDI_DS_AssignDatapathContext(pContext, (void*)pClientData);
995
996 pDTDriverContext = gTransportDriver.open();
997 if( NULL == pDTDriverContext )
998 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700999 DTI_TRACE( DTI_TRACE_LEVEL_ERROR, " %s fail from transport open", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001000 return eWLAN_PAL_STATUS_E_FAILURE;
1001 }
1002 WDT_AssignTransportDriverContext(pContext, pDTDriverContext);
Mihir Shetec4093f92015-05-28 15:21:11 +05301003
1004 WDTSCb.rxFrameReadyCB = WDTS_RxPacket;
1005 WDTSCb.txCompleteCB = WDTS_TxPacketComplete;
1006 WDTSCb.lowResourceCB = WDTS_OOResourceNotification;
1007 WDTSCb.receiveMbMsgCB = WDTS_MbReceiveMsg;
Mihir Shete5affadc2015-05-29 20:54:57 +05301008 WDTSCb.receiveLogCompleteCB = WDTS_LogRxDone;
Mihir Shetec4093f92015-05-28 15:21:11 +05301009 gTransportDriver.register_client(pDTDriverContext, WDTSCb, (void*)pClientData);
Jeff Johnson295189b2012-06-20 16:38:30 -07001010
1011 /* Create a memory pool for Mgmt BDheaders.*/
1012 sWdiStatus = WDI_DS_MemPoolCreate(&pClientData->mgmtMemPool, WDI_DS_MAX_CHUNK_SIZE,
1013 WDI_DS_HI_PRI_RES_NUM);
1014 if (WDI_STATUS_SUCCESS != sWdiStatus){
1015 return eWLAN_PAL_STATUS_E_NOMEM;
1016 }
1017
1018 /* Create a memory pool for Data BDheaders.*/
1019 sWdiStatus = WDI_DS_MemPoolCreate(&pClientData->dataMemPool, WDI_DS_MAX_CHUNK_SIZE,
1020 WDI_DS_LO_PRI_RES_NUM);
1021 if (WDI_STATUS_SUCCESS != sWdiStatus){
1022 return eWLAN_PAL_STATUS_E_NOMEM;
1023 }
1024
Madan Mohan Koyyalamudi01cba042013-01-10 21:56:05 -08001025 wpalMemoryZero(&gDsTrafficStats, sizeof(gDsTrafficStats));
1026
Abhishek Singh2b055852015-10-07 14:14:13 +05301027 sWdiStatus = WDI_DS_LoggingMbCreate(&pClientData->loggingMbContext, sizeof(tLoggingMailBox));
Mihir Shetecb352cd2015-05-25 10:58:59 +05301028 if (WDI_STATUS_SUCCESS != sWdiStatus)
1029 return eWLAN_PAL_STATUS_E_NOMEM;
1030
Jeff Johnson295189b2012-06-20 16:38:30 -07001031 return eWLAN_PAL_STATUS_SUCCESS;
1032
1033}
1034
1035
1036
1037/* DTS start function.
1038 * On start the transport device should start running.
1039 * Parameters:
1040 * pContext:Cookie that should be passed back to the caller along
1041 * with the callback.
1042 *
1043 * Return Value: SUCCESS Completed successfully.
1044 * FAILURE_XXX Request was rejected due XXX Reason.
1045 *
1046 */
1047wpt_status WDTS_startTransport( void *pContext)
1048{
1049 void *pDTDriverContext = WDT_GetTransportDriverContext(pContext);
1050 gTransportDriver.start(pDTDriverContext);
1051 return eWLAN_PAL_STATUS_SUCCESS;
1052
1053}
1054
1055
1056/* DTS Tx packet function.
1057 * This function should be invoked by the DAL Dataservice to schedule transmit frame through DXE/SDIO.
1058 * Parameters:
1059 * pContext:Cookie that should be passed back to the caller along with the callback.
1060 * pFrame:Refernce to PAL frame.
1061 * Return Value: SUCCESS Completed successfully.
1062 * FAILURE_XXX Request was rejected due XXX Reason.
1063 *
1064 */
1065wpt_status WDTS_TxPacket(void *pContext, wpt_packet *pFrame)
1066{
1067 void *pDTDriverContext = WDT_GetTransportDriverContext(pContext);
1068 WDI_DS_TxMetaInfoType *pTxMetadata;
1069 WDTS_ChannelType channel = WDTS_CHANNEL_TX_LOW_PRI;
1070 wpt_status status = eWLAN_PAL_STATUS_SUCCESS;
Sushant Kaushik33200572015-08-05 16:46:20 +05301071 tPerPacketStats txPktStat = {0};
Jeff Johnson295189b2012-06-20 16:38:30 -07001072
1073 // extract metadata from PAL packet
1074 pTxMetadata = WDI_DS_ExtractTxMetaData(pFrame);
Madan Mohan Koyyalamudi01cba042013-01-10 21:56:05 -08001075
1076 //Log the TX Stats
Kumar Anand90ca3dd2013-01-18 15:24:47 -08001077 if(gDsTrafficStats.running && pTxMetadata->staIdx < HAL_NUM_STA)
Madan Mohan Koyyalamudi01cba042013-01-10 21:56:05 -08001078 {
Kumar Anand90ca3dd2013-01-18 15:24:47 -08001079 if(pTxMetadata->frmType & WDI_MAC_DATA_FRAME)
1080 {
1081 gDsTrafficStats.txStats[pTxMetadata->staIdx].txBytesPushed +=
1082 pTxMetadata->fPktlen;
1083 gDsTrafficStats.txStats[pTxMetadata->staIdx].txPacketsPushed += 1;
1084 }
Madan Mohan Koyyalamudi01cba042013-01-10 21:56:05 -08001085 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001086
1087 // assign MDPU to correct channel??
1088 channel = (pTxMetadata->frmType & WDI_MAC_DATA_FRAME)?
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -07001089 /* EAPOL frame uses TX_HIGH_PRIORITY DXE channel
1090 To make sure EAPOL (for second session) is pushed even if TX_LO channel
1091 already reached to low resource condition
1092 This can happen especially in MCC, high data traffic TX in first session
1093 */
Hoonki Leee10ce392013-02-26 11:47:00 -08001094#ifdef FEATURE_WLAN_TDLS
1095 /* I utilizes TDLS mgmt frame always sent at BD_RATE2. (See limProcessTdls.c)
1096 Assumption here is data frame sent by WDA_TxPacket() <- HalTxFrame/HalTxFrameWithComplete()
1097 should take managment path. As of today, only TDLS feature has special data frame
1098 which needs to be treated as mgmt.
1099 */
1100 (((pTxMetadata->isEapol) || (pTxMetadata->txFlags & WDI_USE_BD_RATE2_FOR_MANAGEMENT_FRAME))? WDTS_CHANNEL_TX_HIGH_PRI : WDTS_CHANNEL_TX_LOW_PRI) : WDTS_CHANNEL_TX_HIGH_PRI;
1101#else
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -07001102 ((pTxMetadata->isEapol) ? WDTS_CHANNEL_TX_HIGH_PRI : WDTS_CHANNEL_TX_LOW_PRI) : WDTS_CHANNEL_TX_HIGH_PRI;
Hoonki Leee10ce392013-02-26 11:47:00 -08001103#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001104 // Send packet to Transport Driver.
1105 status = gTransportDriver.xmit(pDTDriverContext, pFrame, channel);
Sushant Kaushik33200572015-08-05 16:46:20 +05301106 if ((WLAN_LOG_LEVEL_ACTIVE ==
1107 vos_get_ring_log_level(RING_ID_PER_PACKET_STATS)) &&
Abhishek Singhb3e1e7b2015-10-12 16:23:33 +05301108 !(pTxMetadata->frmType & WDI_MAC_CTRL_FRAME)){
Sushant Kaushik33200572015-08-05 16:46:20 +05301109
1110 vos_mem_zero(&txPktStat,sizeof(tPerPacketStats));
1111 txPktStat.tid = pTxMetadata->fUP;
1112 txPktStat.dxe_timestamp = vos_timer_get_system_ticks();
1113 /*HW limitation cant get the seq number*/
1114 txPktStat.seq_num = 0;
1115 txPktStat.data_len =
Abhishek Singhb3e1e7b2015-10-12 16:23:33 +05301116 vos_copy_80211_data((void *)pFrame, txPktStat.data,
1117 pTxMetadata->frmType);
Sushant Kaushik33200572015-08-05 16:46:20 +05301118 wpalPerPktSerialize(&txPktStat);
1119 }
Girish Gowli55caa852015-01-19 16:09:49 +05301120 if (((WDI_ControlBlockType *)pContext)->roamDelayStatsEnabled)
1121 {
1122 vos_record_roam_event(e_DXE_FIRST_XMIT_TIME, (void *)pFrame, pTxMetadata->frmType);
1123 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001124 return status;
1125}
1126
1127/* DTS Tx Complete function.
1128 * This function should be invoked by the DAL Dataservice to notify tx completion to DXE/SDIO.
1129 * Parameters:
1130 * pContext:Cookie that should be passed back to the caller along with the callback.
1131 * ucTxResReq:TX resource number required by TL
1132 * Return Value: SUCCESS Completed successfully.
1133 * FAILURE_XXX Request was rejected due XXX Reason.
1134 *
1135 */
1136wpt_status WDTS_CompleteTx(void *pContext, wpt_uint32 ucTxResReq)
1137{
1138 void *pDTDriverContext = WDT_GetTransportDriverContext(pContext);
1139
1140 // Notify completion to Transport Driver.
1141 return gTransportDriver.txComplete(pDTDriverContext, ucTxResReq);
1142}
1143
1144/* DXE Set power state ACK callback.
1145 * This callback function should be invoked by the DXE to notify WDI that set
1146 * power state request is complete.
1147 * Parameters:
1148 * status: status of the set operation
1149 * Return Value: None.
1150 *
1151 */
1152void WDTS_SetPowerStateCb(wpt_status status, unsigned int dxePhyAddr)
1153{
1154 //print a msg
1155 if(NULL != gSetPowerStateCbInfo.cback)
1156 {
1157 gSetPowerStateCbInfo.cback(status, dxePhyAddr, gSetPowerStateCbInfo.pUserData);
1158 }
1159}
1160
1161
1162/* DTS Set power state function.
1163 * This function should be invoked by the DAL to notify the WLAN device power state.
1164 * Parameters:
1165 * pContext:Cookie that should be passed back to the caller along with the callback.
1166 * powerState:Power state of the WLAN device.
1167 * Return Value: SUCCESS Set successfully in DXE control blk.
1168 * FAILURE_XXX Request was rejected due XXX Reason.
1169 *
1170 */
1171wpt_status WDTS_SetPowerState(void *pContext, WDTS_PowerStateType powerState,
1172 WDTS_SetPowerStateCbType cback)
1173{
1174 void *pDTDriverContext = WDT_GetTransportDriverContext(pContext);
1175 wpt_status status = eWLAN_PAL_STATUS_SUCCESS;
1176
1177 if( cback )
1178 {
1179 //save the cback & cookie
1180 gSetPowerStateCbInfo.pUserData = pContext;
1181 gSetPowerStateCbInfo.cback = cback;
1182 status = gTransportDriver.setPowerState(pDTDriverContext, powerState,
1183 WDTS_SetPowerStateCb);
1184 }
1185 else
1186 {
1187 status = gTransportDriver.setPowerState(pDTDriverContext, powerState,
1188 NULL);
1189 }
1190
1191 return status;
1192}
1193
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07001194/* DTS Transport Channel Debug
1195 * Display DXE Channel debugging information
1196 * User may request to display DXE channel snapshot
1197 * Or if host driver detects any abnormal stcuk may display
1198 * Parameters:
Jeff Johnsonb88db982012-12-10 13:34:59 -08001199 * displaySnapshot : Display DXE snapshot option
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07001200 * enableStallDetect : Enable stall detect feature
1201 This feature will take effect to data performance
1202 Not integrate till fully verification
1203 * Return Value: NONE
1204 *
1205 */
Mihir Shete40a55652014-03-02 14:14:47 +05301206void WDTS_ChannelDebug(wpt_boolean displaySnapshot, wpt_uint8 debugFlags)
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07001207{
Mihir Shete40a55652014-03-02 14:14:47 +05301208 gTransportDriver.channelDebug(displaySnapshot, debugFlags);
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07001209 return;
1210}
1211
Sravan Kumar Kairam6eac7522015-11-27 23:37:02 +05301212/* DTS Transport Channel Kick Dxe
1213 * Request Kick DXE when HDD TX time out happen
1214 *
1215 * Parameters : NONE
1216 * Return Value: NONE
1217 *
1218 */
1219void WDTS_ChannelKickDxe()
1220{
1221 gTransportDriver.kickDxe();
1222 return;
1223}
1224
Jeff Johnson295189b2012-06-20 16:38:30 -07001225/* DTS Stop function.
1226 * Stop Transport driver, ie DXE, SDIO
1227 * Parameters:
1228 * pContext:Cookie that should be passed back to the caller along with the callback.
1229 * Return Value: SUCCESS Completed successfully.
1230 * FAILURE_XXX Request was rejected due XXX Reason.
1231 *
1232 */
1233wpt_status WDTS_Stop(void *pContext)
1234{
1235 void *pDTDriverContext = WDT_GetTransportDriverContext(pContext);
1236 wpt_status status = eWLAN_PAL_STATUS_SUCCESS;
1237
1238 status = gTransportDriver.stop(pDTDriverContext);
1239
Madan Mohan Koyyalamudi01cba042013-01-10 21:56:05 -08001240 wpalMemoryZero(&gDsTrafficStats, sizeof(gDsTrafficStats));
1241
Jeff Johnson295189b2012-06-20 16:38:30 -07001242 return status;
1243}
1244
1245/* DTS Stop function.
1246 * Stop Transport driver, ie DXE, SDIO
1247 * Parameters:
1248 * pContext:Cookie that should be passed back to the caller along with the callback.
1249 * Return Value: SUCCESS Completed successfully.
1250 * FAILURE_XXX Request was rejected due XXX Reason.
1251 *
1252 */
1253wpt_status WDTS_Close(void *pContext)
1254{
1255 void *pDTDriverContext = WDT_GetTransportDriverContext(pContext);
1256 WDI_DS_ClientDataType *pClientData = WDI_DS_GetDatapathContext(pContext);
1257 wpt_status status = eWLAN_PAL_STATUS_SUCCESS;
1258
1259 /*Destroy the mem pool for mgmt BD headers*/
1260 WDI_DS_MemPoolDestroy(&pClientData->mgmtMemPool);
1261
1262 /*Destroy the mem pool for mgmt BD headers*/
1263 WDI_DS_MemPoolDestroy(&pClientData->dataMemPool);
Mihir Shetecb352cd2015-05-25 10:58:59 +05301264
1265 WDI_DS_LoggingMbDestroy(&pClientData->loggingMbContext);
1266
Jeff Johnson295189b2012-06-20 16:38:30 -07001267 status = gTransportDriver.close(pDTDriverContext);
1268
1269 wpalMemoryFree(pClientData);
1270
1271 return status;
1272}
1273
1274/* Get free TX data descriptor number from DXE
1275 * Parameters:
1276 * pContext: Cookie that should be passed back to the caller along with the callback.
1277 * Return Value: number of free descriptors for TX data channel
1278 *
1279 */
1280wpt_uint32 WDTS_GetFreeTxDataResNumber(void *pContext)
1281{
1282 return
1283 gTransportDriver.getFreeTxDataResNumber(WDT_GetTransportDriverContext(pContext));
1284}