blob: b88af2c2d725ba69e48ef8b68d649ef6007aeb1d [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,
Jeff Johnson295189b2012-06-20 16:38:30 -070061 WLANDXE_Stop,
62 WLANDXE_Close,
Mihir Shete5affadc2015-05-29 20:54:57 +053063 WLANDXE_GetFreeTxDataResNumber,
64 WLANDXE_SetupLogTransfer,
65 WLANDXE_StartLogTransfer
Jeff Johnson295189b2012-06-20 16:38:30 -070066};
67
68static WDTS_SetPowerStateCbInfoType gSetPowerStateCbInfo;
69
Madan Mohan Koyyalamudi01cba042013-01-10 21:56:05 -080070typedef struct
71{
72 uint32 phyRate; //unit in Mega bits per sec X 10
73 uint32 tputRate; //unit in Mega bits per sec X 10
74 uint32 tputBpms; //unit in Bytes per msec = (tputRateX1024x1024)/(8x10X1000) ~= (tputRate*13)
Kumar Anand90ca3dd2013-01-18 15:24:47 -080075 uint32 tputBpus; //unit in Bytes per usec: round off to integral value
Madan Mohan Koyyalamudi01cba042013-01-10 21:56:05 -080076}WDTS_RateInfo;
77
Viral Modif45f7672013-09-06 13:29:06 -070078#define WDTS_MAX_RATE_NUM 137
79#define WDTS_MAX_11B_RATE_NUM 8
80#define MB_PER_SEC_TO_BYTES_PER_MSEC 13
Kumar Anand90ca3dd2013-01-18 15:24:47 -080081
82WDTS_RateInfo g11bRateInfo[WDTS_MAX_11B_RATE_NUM] = {
83 //11b rates
84 { 10, 9, 117, 8}, //index 0
85 { 20, 17, 221, 5}, //index 1
86 { 55, 41, 533, 2}, //index 2
87 { 110, 68, 884, 1}, //index 3
88
89 //11b short preamble
90 { 10, 10, 130, 8}, //index 4
91 { 20, 18, 234, 5}, //index 5
92 { 55, 44, 572, 2}, //index 6
93 { 110, 77, 1001, 1}, //index 7
94};
Madan Mohan Koyyalamudi01cba042013-01-10 21:56:05 -080095
96WDTS_RateInfo gRateInfo[WDTS_MAX_RATE_NUM] = {
97 //11b rates
Kumar Anand90ca3dd2013-01-18 15:24:47 -080098 { 10, 9, 117, 0}, //index 0
99 { 20, 17, 221, 0}, //index 1
100 { 55, 41, 533, 0}, //index 2
101 { 110, 68, 884, 0}, //index 3
Madan Mohan Koyyalamudi01cba042013-01-10 21:56:05 -0800102
103 //11b short preamble
Kumar Anand90ca3dd2013-01-18 15:24:47 -0800104 { 10, 10, 130, 0}, //index 4
105 { 20, 18, 234, 0}, //index 5
106 { 55, 44, 572, 0}, //index 6
107 { 110, 77, 1001, 0}, //index 7
Madan Mohan Koyyalamudi01cba042013-01-10 21:56:05 -0800108
109 //11ag
Kumar Anand90ca3dd2013-01-18 15:24:47 -0800110 { 60, 50, 650, 1}, //index 8
111 { 90, 70, 910, 1}, //index 9
112 { 120, 100, 1300, 1}, //index 10
113 { 180, 150, 1950, 2}, //index 11
114 { 240, 190, 2470, 2}, //index 12
115 { 360, 280, 3640, 4}, //index 13
116 { 480, 350, 4550, 5}, //index 14
117 { 540, 380, 4940, 6}, //index 15
Madan Mohan Koyyalamudi01cba042013-01-10 21:56:05 -0800118
119 //11n SIMO
Kumar Anand90ca3dd2013-01-18 15:24:47 -0800120 { 65, 54, 702, 1}, //index 16
121 { 130, 108, 1404, 1}, //index 17
122 { 195, 161, 2093, 2}, //index 18
123 { 260, 217, 2821, 3}, //index 19
124 { 390, 326, 4238, 4}, //index 20
125 { 520, 435, 5655, 6}, //index 21
126 { 585, 492, 6396, 6}, //index 22
127 { 650, 548, 7124, 7}, //index 23
Madan Mohan Koyyalamudi01cba042013-01-10 21:56:05 -0800128
129 //11n SIMO SGI
Kumar Anand90ca3dd2013-01-18 15:24:47 -0800130 { 72, 59, 767, 1}, //index 24
131 { 144, 118, 1534, 2}, //index 25
132 { 217, 180, 2340, 2}, //index 26
133 { 289, 243, 3159, 3}, //index 27
134 { 434, 363, 4719, 5}, //index 28
135 { 578, 486, 6318, 6}, //index 29
136 { 650, 548, 7124, 7}, //index 30
137 { 722, 606, 7878, 8}, //index 31
Madan Mohan Koyyalamudi01cba042013-01-10 21:56:05 -0800138
139 //11n GF SIMO
Kumar Anand90ca3dd2013-01-18 15:24:47 -0800140 { 65, 54, 702, 1}, //index 32
141 { 130, 108, 1404, 1}, //index 33
142 { 195, 161, 2093, 2}, //index 34
143 { 260, 217, 2821, 3}, //index 35
144 { 390, 326, 4238, 4}, //index 36
145 { 520, 435, 5655, 6}, //index 37
146 { 585, 492, 6396, 6}, //index 38
147 { 650, 548, 7124, 7}, //index 39
Madan Mohan Koyyalamudi01cba042013-01-10 21:56:05 -0800148
149 //11n SIMO CB MCS 0 - 7
Kumar Anand90ca3dd2013-01-18 15:24:47 -0800150 { 135, 110, 1430, 1}, //index 40
151 { 270, 223, 2899, 3}, //index 41
152 { 405, 337, 4381, 4}, //index 42
153 { 540, 454, 5902, 6}, //index 43
154 { 810, 679, 8827, 9}, //index 44
155 { 1080, 909, 11817, 12}, //index 45
156 { 1215, 1022, 13286, 13}, //index 46
157 { 1350, 1137, 14781, 15}, //index 47
Madan Mohan Koyyalamudi01cba042013-01-10 21:56:05 -0800158
159 //11n SIMO CB SGI MCS 0 - 7
Kumar Anand90ca3dd2013-01-18 15:24:47 -0800160 { 150, 121, 1573, 2}, //index 48
161 { 300, 249, 3237, 3}, //index 49
162 { 450, 378, 4914, 5}, //index 50
163 { 600, 503, 6539, 7}, //index 51
164 { 900, 758, 9854, 10}, //index 52
165 { 1200, 1010, 13130, 13}, //index 53
166 { 1350, 1137, 14781, 15}, //index 54
167 { 1500, 1262, 16406, 16}, //index 55
Madan Mohan Koyyalamudi01cba042013-01-10 21:56:05 -0800168
169 //11n SIMO GF CB MCS 0 - 7
Kumar Anand90ca3dd2013-01-18 15:24:47 -0800170 { 135, 110, 1430, 1}, //index 56
171 { 270, 223, 2899, 3}, //index 57
172 { 405, 337, 4381, 4}, //index 58
173 { 540, 454, 5902, 6}, //index 59
174 { 810, 679, 8827, 9}, //index 60
175 { 1080, 909, 11817, 12}, //index 61
176 { 1215, 1022, 13286, 13}, //index 62
177 { 1350, 1137, 14781, 15}, //index 63
Madan Mohan Koyyalamudi01cba042013-01-10 21:56:05 -0800178
179 //11AC
Viral Modif45f7672013-09-06 13:29:06 -0700180 { 1350, 675, 8775, 9}, //reserved 64
181 { 1350, 675, 8775, 9}, //reserved 65
182 { 65, 45, 585, 1}, //index 66
183 { 130, 91, 1183, 1}, //index 67
184 { 195, 136, 1768, 2}, //index 68
185 { 260, 182, 2366, 2}, //index 69
186 { 390, 273, 3549, 4}, //index 70
187 { 520, 364, 4732, 5}, //index 71
188 { 585, 409, 5317, 5}, //index 72
189 { 650, 455, 5915, 6}, //index 73
190 { 780, 546, 7098, 7}, //index 74
191 { 1350, 675, 8775, 9}, //reserved 75
192 { 1350, 675, 8775, 9}, //reserved 76
193 { 1350, 675, 8775, 9}, //reserved 77
194 { 1350, 675, 8775, 9}, //index 78
195 { 1350, 675, 8775, 9}, //index 79
196 { 1350, 675, 8775, 9}, //index 80
197 { 1350, 675, 8775, 9}, //index 81
198 { 1350, 675, 8775, 9}, //index 82
199 { 1350, 675, 8775, 9}, //index 83
200 { 655, 458, 5954, 6}, //index 84
201 { 722, 505, 6565, 7}, //index 85
202 { 866, 606, 7878, 8}, //index 86
203 { 1350, 675, 8775, 9}, //reserved 87
204 { 1350, 675, 8775, 9}, //reserved 88
205 { 1350, 675, 8775, 9}, //reserved 89
206 { 135, 94, 1222, 1}, //index 90
207 { 270, 189, 2457, 2}, //index 91
208 { 405, 283, 3679, 4}, //index 92
209 { 540, 378, 4914, 5}, //index 93
210 { 810, 567, 7371, 7}, //index 94
211 { 1080, 756, 9828, 10}, //index 95
212 { 1215, 850, 11050, 11}, //index 96
213 { 1350, 675, 8775, 9}, //index 97
214 { 1350, 675, 8775, 9}, //index 98
215 { 1620, 810, 10530, 11}, //index 99
216 { 1800, 900, 11700, 12}, //index 100
217 { 1350, 675, 8775, 9}, //reserved 101
218 { 1350, 675, 8775, 9}, //index 102
219 { 1350, 675, 8775, 9}, //index 103
220 { 1350, 675, 8775, 9}, //index 104
221 { 1350, 675, 8775, 9}, //index 105
222 { 1350, 675, 8775, 9}, //index 106
223 { 1200, 840, 10920, 11}, //index 107
224 { 1350, 675, 8775, 9}, //index 108
225 { 1500, 750, 9750, 10}, //index 109
226 { 1350, 675, 8775, 9}, //index 110
227 { 1800, 900, 11700, 12}, //index 111
228 { 2000, 1000, 13000, 13}, //index 112
229 { 1350, 675, 8775, 9}, //index 113
230 { 292, 204, 2652, 3}, //index 114
231 { 585, 409, 5317, 5}, //index 115
232 { 877, 613, 7969, 8}, //index 116
233 { 1170, 819, 10647, 11}, //index 117
234 { 1755, 877, 11401, 11}, //index 118
235 { 2340, 1170, 15210, 15}, //index 119
236 { 2632, 1316, 17108, 17}, //index 120
237 { 2925, 1462, 19006, 19}, //index 121
238 { 1350, 675, 8775, 9}, //index 122
239 { 3510, 1755, 22815, 23}, //index 123
240 { 3900, 1950, 25350, 25}, //index 124
241 { 1350, 675, 8775, 9}, //reserved 125
242 { 1350, 675, 8775, 9}, //index 126
243 { 1350, 675, 8775, 9}, //index 127
244 { 1350, 675, 8775, 9}, //index 128
245 { 1350, 675, 8775, 9}, //index 129
246 { 1350, 675, 8775, 9}, //index 130
247 { 1350, 675, 8775, 9}, //index 131
248 { 2925, 1462, 19006, 19}, //index 132
249 { 3250, 1625, 21125, 21}, //index 133
250 { 1350, 675, 8775, 9}, //index 134
251 { 3900, 1950, 25350, 25}, //index 135
252 { 4333, 2166, 28158, 28} //index 136
Madan Mohan Koyyalamudi01cba042013-01-10 21:56:05 -0800253 };
254
255/* TX stats */
256typedef struct
257{
258 wpt_uint32 txBytesPushed;
259 wpt_uint32 txPacketsPushed; //Can be removed to optimize memory
260}WDI_DTS_TX_TrafficStatsType;
261
262/* RX stats */
263typedef struct
264{
265 wpt_uint32 rxBytesRcvd;
266 wpt_uint32 rxPacketsRcvd; //Can be removed to optimize memory
267}WDI_DTS_RX_TrafficStatsType;
268
269typedef struct {
270 wpt_uint8 running;
271 WDI_DTS_RX_TrafficStatsType rxStats[HAL_NUM_STA][WDTS_MAX_RATE_NUM];
272 WDI_DTS_TX_TrafficStatsType txStats[HAL_NUM_STA];
273 WDI_TrafficStatsType netTxRxStats[HAL_NUM_STA];
274}WDI_DTS_TrafficStatsType;
275
276static WDI_DTS_TrafficStatsType gDsTrafficStats;
277
Kumar Anand90ca3dd2013-01-18 15:24:47 -0800278#define DTS_RATE_TPUT(x) gRateInfo[x].tputBpus
279#define DTS_11BRATE_TPUT_MULTIPLIER(x) g11bRateInfo[x].tputBpus
Madan Mohan Koyyalamudi01cba042013-01-10 21:56:05 -0800280
Leo Changf8940fd2013-07-12 14:00:25 -0700281/* RX thread frame size threshold to delay frame drain */
282#define DTS_RX_DELAY_FRAMESIZE_THRESHOLD 500
283
Viral Modif45f7672013-09-06 13:29:06 -0700284/* API to fill Rate Info based on the mac efficiency passed to it
285 * macEff si used to caclulate mac throughput based on each rate index/PHY rate.
286 * This is eventually used by MAS to calculate RX stats periodically sent to FW
287 * The start and end Rate Index are the other arguments to this API - the new mac
288 * efficiency passed to this API (Arg1) is only applied between startRateIndex (arg2) and endRateIndex (arg3).
289 */
290void WDTS_FillRateInfo(wpt_uint8 macEff, wpt_int16 startRateIndex, wpt_int16 endRateIndex)
291{
292 int i;
293
Arif Hussain9a5d5382013-11-17 22:05:35 -0800294 DTI_TRACE( DTI_TRACE_LEVEL_ERROR, "Change only 11ac rates");
Viral Modif45f7672013-09-06 13:29:06 -0700295
296 for (i=startRateIndex; i<=endRateIndex; i++)
297 {
298 // tputRate --> unit in Mega bits per sec X 10
299 gRateInfo[i].tputRate = ((gRateInfo[i].phyRate * macEff)/100);
300 // tputBmps --> unit in Bytes per msec = (tputRateX1024x1024)/(8x10X1000) ~= (tputRate*13)
301 gRateInfo[i].tputBpms = gRateInfo[i].tputRate * MB_PER_SEC_TO_BYTES_PER_MSEC;
302 // tputBpus --> unit in Bytes per usec: (+ 500) to round off to integral value
303 gRateInfo[i].tputBpus = ((gRateInfo[i].tputBpms + 500) / 1000);
304 if (gRateInfo[i].tputBpus == 0)
305 gRateInfo[i].tputBpus = 1;
306
307 DTI_TRACE( DTI_TRACE_LEVEL_ERROR, "%4u, %4u, %5u, %2u",
308 gRateInfo[i].phyRate,
309 gRateInfo[i].tputRate,
310 gRateInfo[i].tputBpms,
311 gRateInfo[i].tputBpus );
312 }
313}
314
Madan Mohan Koyyalamudi01cba042013-01-10 21:56:05 -0800315/* Tx/Rx stats function
316 * This function should be invoked to fetch the current stats
317 * Parameters:
318 * pStats:Pointer to the collected stats
319 * len: length of buffer pointed to by pStats
320 * Return Status: None
321 */
322void WDTS_GetTrafficStats(WDI_TrafficStatsType** pStats, wpt_uint32 *len)
323{
324 if(gDsTrafficStats.running)
325 {
326 uint8 staIdx, rate;
327 WDI_TrafficStatsType *pNetTxRxStats = gDsTrafficStats.netTxRxStats;
328 wpalMemoryZero(pNetTxRxStats, sizeof(gDsTrafficStats.netTxRxStats));
329
330 for(staIdx = 0; staIdx < HAL_NUM_STA; staIdx++, pNetTxRxStats++)
331 {
332 pNetTxRxStats->txBytesPushed += gDsTrafficStats.txStats[staIdx].txBytesPushed;
333 pNetTxRxStats->txPacketsPushed+= gDsTrafficStats.txStats[staIdx].txPacketsPushed;
Kumar Anand90ca3dd2013-01-18 15:24:47 -0800334 for(rate = 0; rate < WDTS_MAX_11B_RATE_NUM; rate++)
335 {
336 pNetTxRxStats->rxBytesRcvd +=
337 gDsTrafficStats.rxStats[staIdx][rate].rxBytesRcvd;
338 pNetTxRxStats->rxPacketsRcvd +=
339 gDsTrafficStats.rxStats[staIdx][rate].rxPacketsRcvd;
340 pNetTxRxStats->rxTimeTotal +=
341 gDsTrafficStats.rxStats[staIdx][rate].rxBytesRcvd*DTS_11BRATE_TPUT_MULTIPLIER(rate);
342 }
343 for(rate = WDTS_MAX_11B_RATE_NUM; rate < WDTS_MAX_RATE_NUM; rate++)
Madan Mohan Koyyalamudi01cba042013-01-10 21:56:05 -0800344 {
345 pNetTxRxStats->rxBytesRcvd +=
346 gDsTrafficStats.rxStats[staIdx][rate].rxBytesRcvd;
347 pNetTxRxStats->rxPacketsRcvd +=
348 gDsTrafficStats.rxStats[staIdx][rate].rxPacketsRcvd;
349 pNetTxRxStats->rxTimeTotal +=
Kumar Anand90ca3dd2013-01-18 15:24:47 -0800350 gDsTrafficStats.rxStats[staIdx][rate].rxBytesRcvd/DTS_RATE_TPUT(rate);
Madan Mohan Koyyalamudi01cba042013-01-10 21:56:05 -0800351 }
Kumar Anand90ca3dd2013-01-18 15:24:47 -0800352
353 pNetTxRxStats->rxTimeTotal = pNetTxRxStats->rxTimeTotal/1000;
354
Madan Mohan Koyyalamudi01cba042013-01-10 21:56:05 -0800355 }
356 *pStats = gDsTrafficStats.netTxRxStats;
357 *len = sizeof(gDsTrafficStats.netTxRxStats);
358 }
359 else
360 {
361 *pStats = NULL;
362 *len = 0;
363 }
364}
365
366/* WDTS_DeactivateTrafficStats
367 * This function should be invoked to deactivate traffic stats collection
368 * Parameters: None
369 * Return Status: None
370 */
371void WDTS_DeactivateTrafficStats(void)
372{
373 gDsTrafficStats.running = eWLAN_PAL_FALSE;
374}
375
376/* WDTS_ActivateTrafficStats
377 * This function should be invoked to activate traffic stats collection
378 * Parameters: None
379 * Return Status: None
380 */
381void WDTS_ActivateTrafficStats(void)
382{
383 gDsTrafficStats.running = eWLAN_PAL_TRUE;
384}
385
386/* WDTS_ClearTrafficStats
387 * This function should be invoked to clear traffic stats
388 * Parameters: None
389 * Return Status: None
390 */
391void WDTS_ClearTrafficStats(void)
392{
393 wpalMemoryZero(gDsTrafficStats.rxStats, sizeof(gDsTrafficStats.rxStats));
394 wpalMemoryZero(gDsTrafficStats.txStats, sizeof(gDsTrafficStats.txStats));
395}
396
Jeff Johnson295189b2012-06-20 16:38:30 -0700397/* DTS Tx packet complete function.
398 * This function should be invoked by the transport device to indicate
399 * transmit complete for a frame.
400 * Parameters:
401 * pContext:Cookie that should be passed back to the caller
402 * pFrame:Refernce to PAL frame.
403 * Return Value: SUCCESS Completed successfully.
404 * FAILURE_XXX Request was rejected due XXX Reason.
405 *
406 */
407wpt_status WDTS_TxPacketComplete(void *pContext, wpt_packet *pFrame, wpt_status status)
408{
409 WDI_DS_ClientDataType *pClientData = (WDI_DS_ClientDataType*)(pContext);
410 WDI_DS_TxMetaInfoType *pTxMetadata;
411 void *pvBDHeader, *physBDHeader;
412 wpt_uint8 staIndex;
413
414 // Do Sanity checks
415 if(NULL == pContext || NULL == pFrame){
Mihir Shete63341222015-03-24 15:39:18 +0530416 VOS_TRACE(VOS_MODULE_ID_WDI, VOS_TRACE_LEVEL_WARN,
417 "%s: Tx complete cannot proceed(%p:%p)",
418 __func__, pContext, pFrame);
Jeff Johnson295189b2012-06-20 16:38:30 -0700419 return eWLAN_PAL_STATUS_E_FAILURE;
420 }
421
422
423 // extract metadata from PAL packet
424 pTxMetadata = WDI_DS_ExtractTxMetaData(pFrame);
425 pTxMetadata->txCompleteStatus = status;
426
427 // Free BD header from pool
428 WDI_GetBDPointers(pFrame, &pvBDHeader, &physBDHeader);
429 switch(pTxMetadata->frmType)
430 {
431 case WDI_MAC_DATA_FRAME:
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -0700432 /* note that EAPOL frame hasn't incremented ReserveCount. see
433 WDI_DS_TxPacket() in wlan_qct_wdi_ds.c
434 */
Hoonki Leee10ce392013-02-26 11:47:00 -0800435#ifdef FEATURE_WLAN_TDLS
436 /* I utilizes TDLS mgmt frame always sent at BD_RATE2. (See limProcessTdls.c)
437 Assumption here is data frame sent by WDA_TxPacket() <- HalTxFrame/HalTxFrameWithComplete()
438 should take managment path. As of today, only TDLS feature has special data frame
439 which needs to be treated as mgmt.
440 */
441 if((!pTxMetadata->isEapol) &&
442 ((pTxMetadata->txFlags & WDI_USE_BD_RATE2_FOR_MANAGEMENT_FRAME) != WDI_USE_BD_RATE2_FOR_MANAGEMENT_FRAME))
443#else
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -0700444 if(!pTxMetadata->isEapol)
Hoonki Leee10ce392013-02-26 11:47:00 -0800445#endif
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -0700446 {
Jeff Johnson295189b2012-06-20 16:38:30 -0700447 /* SWAP BD header to get STA index for completed frame */
448 WDI_SwapTxBd(pvBDHeader);
449 staIndex = (wpt_uint8)WDI_TX_BD_GET_STA_ID(pvBDHeader);
450 WDI_DS_MemPoolFree(&(pClientData->dataMemPool), pvBDHeader, physBDHeader);
451 WDI_DS_MemPoolDecreaseReserveCount(&(pClientData->dataMemPool), staIndex);
452 break;
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -0700453 }
454 // intentional fall-through to handle eapol packet as mgmt
Jeff Johnson295189b2012-06-20 16:38:30 -0700455 case WDI_MAC_MGMT_FRAME:
456 WDI_DS_MemPoolFree(&(pClientData->mgmtMemPool), pvBDHeader, physBDHeader);
Mihir Shete63341222015-03-24 15:39:18 +0530457 VOS_TRACE(VOS_MODULE_ID_WDI, VOS_TRACE_LEVEL_INFO,
458 "%s: Management frame Tx complete status: %d", __func__, status);
Jeff Johnson295189b2012-06-20 16:38:30 -0700459 break;
460 }
461 WDI_SetBDPointers(pFrame, 0, 0);
462
463 // Invoke Tx complete callback
464 pClientData->txCompleteCB(pClientData->pCallbackContext, pFrame);
465 return eWLAN_PAL_STATUS_SUCCESS;
466
467}
468
469
470/*===============================================================================
471 FUNCTION WLANTL_GetReplayCounterFromRxBD
472
473 DESCRIPTION This function extracts 48-bit replay packet number from RX BD
474
475 DEPENDENCIES Validity of replay check must be done before the function
476 is called
477
478 PARAMETERS pucRxHeader pointer to RX BD header
479
480 RETRUN v_U64_t Packet number extarcted from RX BD
481
482 SIDE EFFECTS none
483 ===============================================================================*/
484v_U64_t
485WDTS_GetReplayCounterFromRxBD
486(
487 v_U8_t *pucRxBDHeader
488)
489{
490 v_U64_t ullcurrentReplayCounter = 0;
491 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
492/* 48-bit replay counter is created as follows
493 from RX BD 6 byte PMI command:
494 Addr : AES/TKIP
495 0x38 : pn3/tsc3
496 0x39 : pn2/tsc2
497 0x3a : pn1/tsc1
498 0x3b : pn0/tsc0
499
500 0x3c : pn5/tsc5
501 0x3d : pn4/tsc4 */
502
503#ifdef ANI_BIG_BYTE_ENDIAN
504 /* Getting 48-bit replay counter from the RX BD */
505 ullcurrentReplayCounter = WDI_RX_BD_GET_PMICMD_20TO23(pucRxBDHeader);
506 ullcurrentReplayCounter <<= 16;
507 ullcurrentReplayCounter |= (( WDI_RX_BD_GET_PMICMD_24TO25(pucRxBDHeader) & 0xFFFF0000) >> 16);
508 return ullcurrentReplayCounter;
509#else
510 /* Getting 48-bit replay counter from the RX BD */
511 ullcurrentReplayCounter = (WDI_RX_BD_GET_PMICMD_24TO25(pucRxBDHeader) & 0x0000FFFF);
512 ullcurrentReplayCounter <<= 32;
513 ullcurrentReplayCounter |= WDI_RX_BD_GET_PMICMD_20TO23(pucRxBDHeader);
514 return ullcurrentReplayCounter;
515#endif
516}
517
518
519/* DTS Rx packet function.
520 * This function should be invoked by the transport device to indicate
521 * reception of a frame.
522 * Parameters:
523 * pContext:Cookie that should be passed back to the caller
524 * pFrame:Refernce to PAL frame.
525 * Return Value: SUCCESS Completed successfully.
526 * FAILURE_XXX Request was rejected due XXX Reason.
527 *
528 */
529wpt_status WDTS_RxPacket (void *pContext, wpt_packet *pFrame, WDTS_ChannelType channel)
530{
531 WDI_DS_ClientDataType *pClientData =
532 (WDI_DS_ClientDataType*)(pContext);
533 wpt_boolean bASF, bFSF, bLSF, bAEF;
534 wpt_uint8 ucMPDUHOffset, ucMPDUHLen, ucTid;
535 wpt_uint8 *pBDHeader;
536 wpt_uint16 usMPDUDOffset, usMPDULen;
537 WDI_DS_RxMetaInfoType *pRxMetadata;
538 wpt_uint8 isFcBd = 0;
Hanumantha Reddy Pothulae00a7e22015-09-15 20:11:30 +0530539 WDI_DS_LoggingSessionType *pLoggingSession;
Sushant Kaushik33200572015-08-05 16:46:20 +0530540 tPerPacketStats rxStats = {0};
541
Jeff Johnson295189b2012-06-20 16:38:30 -0700542 tpSirMacFrameCtl pMacFrameCtl;
543 // Do Sanity checks
544 if(NULL == pContext || NULL == pFrame){
545 return eWLAN_PAL_STATUS_E_FAILURE;
546 }
547
Mihir Shete5affadc2015-05-29 20:54:57 +0530548 // Normal DMA transfer does not contain RxBD
549 if (WDTS_CHANNEL_RX_FW_LOG == channel)
550 {
Hanumantha Reddy Pothulae00a7e22015-09-15 20:11:30 +0530551 pLoggingSession = (WDI_DS_LoggingSessionType *)
552 WDI_DS_GetLoggingSession(pContext);
553 wpalFwLogPktSerialize(pFrame, pLoggingSession->logType);
Mihir Shete5affadc2015-05-29 20:54:57 +0530554
555 return eWLAN_PAL_STATUS_SUCCESS;
556 }
557
Jeff Johnson295189b2012-06-20 16:38:30 -0700558 /*------------------------------------------------------------------------
559 Extract BD header and check if valid
560 ------------------------------------------------------------------------*/
561 pBDHeader = (wpt_uint8*)wpalPacketGetRawBuf(pFrame);
562 if(NULL == pBDHeader)
563 {
564 DTI_TRACE( DTI_TRACE_LEVEL_ERROR,
565 "WLAN TL:BD header received NULL - dropping packet");
566 wpalPacketFree(pFrame);
567 return eWLAN_PAL_STATUS_E_FAILURE;
568 }
569 WDI_SwapRxBd(pBDHeader);
570
571 ucMPDUHOffset = (wpt_uint8)WDI_RX_BD_GET_MPDU_H_OFFSET(pBDHeader);
572 usMPDUDOffset = (wpt_uint16)WDI_RX_BD_GET_MPDU_D_OFFSET(pBDHeader);
573 usMPDULen = (wpt_uint16)WDI_RX_BD_GET_MPDU_LEN(pBDHeader);
574 ucMPDUHLen = (wpt_uint8)WDI_RX_BD_GET_MPDU_H_LEN(pBDHeader);
575 ucTid = (wpt_uint8)WDI_RX_BD_GET_TID(pBDHeader);
576
Leo Changf8940fd2013-07-12 14:00:25 -0700577 /* If RX thread drain small size of frame from HW too fast
578 * Sometimes HW cannot handle interrupt fast enough
579 * And system crash might happen
580 * To avoid system crash, input 1usec delay each frame draining
581 * within host side, if frame size is smaller that threshold.
582 * This is SW work around, to fix HW problem
583 * Throughput and SnS test done successfully */
584 if (usMPDULen < DTS_RX_DELAY_FRAMESIZE_THRESHOLD)
585 {
586 wpalBusyWait(1);
587 }
588
Jeff Johnson295189b2012-06-20 16:38:30 -0700589 /*------------------------------------------------------------------------
590 Gather AMSDU information
591 ------------------------------------------------------------------------*/
592 bASF = WDI_RX_BD_GET_ASF(pBDHeader);
593 bAEF = WDI_RX_BD_GET_AEF(pBDHeader);
594 bFSF = WDI_RX_BD_GET_ESF(pBDHeader);
595 bLSF = WDI_RX_BD_GET_LSF(pBDHeader);
596 isFcBd = WDI_RX_FC_BD_GET_FC(pBDHeader);
597
598 DTI_TRACE( DTI_TRACE_LEVEL_INFO,
599 "WLAN TL:BD header processing data: HO %d DO %d Len %d HLen %d"
600 " Tid %d BD %d",
601 ucMPDUHOffset, usMPDUDOffset, usMPDULen, ucMPDUHLen, ucTid,
602 WDI_RX_BD_HEADER_SIZE);
603
Mihir Shete2187b8c2015-03-18 16:54:29 +0530604 pRxMetadata = WDI_DS_ExtractRxMetaData(pFrame);
605
606 // Special handling for frames which contain logging information
607 if (WDTS_CHANNEL_RX_LOG == channel)
608 {
609 if(VPKT_SIZE_BUFFER_ALIGNED < (usMPDULen+ucMPDUHOffset)){
610 WPAL_TRACE(eWLAN_MODULE_DAL_DATA, eWLAN_PAL_TRACE_LEVEL_FATAL,
611 "Invalid Frame size, might memory corrupted(%d+%d/%d)",
612 usMPDULen, ucMPDUHOffset, VPKT_SIZE_BUFFER_ALIGNED);
613
614 /* Size of the packet tranferred by the DMA engine is
615 * greater than the the memory allocated for the skb
616 */
617 WPAL_BUG(0);
618
619 wpalPacketFree(pFrame);
620 return eWLAN_PAL_STATUS_SUCCESS;
621 }
622
623 /* Firmware should send the Header offset as length
624 * of RxBd and data length should be populated to
625 * the length of total data being sent
626 */
627 wpalPacketSetRxLength(pFrame, usMPDULen+ucMPDUHOffset);
628 wpalPacketRawTrimHead(pFrame, ucMPDUHOffset);
629
630 // Invoke Rx complete callback
631 wpalLogPktSerialize(pFrame);
632
633 return eWLAN_PAL_STATUS_SUCCESS;
634 }
635 else
636 {
637 pRxMetadata->loggingData = 0;
638 }
639
Jeff Johnson295189b2012-06-20 16:38:30 -0700640 if(!isFcBd)
641 {
642 if(usMPDUDOffset <= ucMPDUHOffset || usMPDULen < ucMPDUHLen) {
643 DTI_TRACE( DTI_TRACE_LEVEL_ERROR,
644 "WLAN TL:BD header corrupted - dropping packet");
645 /* Drop packet ???? */
646 wpalPacketFree(pFrame);
647 return eWLAN_PAL_STATUS_SUCCESS;
648 }
649
650 if((ucMPDUHOffset < WDI_RX_BD_HEADER_SIZE) && (!(bASF && !bFSF))){
651 /* AMSDU case, ucMPDUHOffset = 0 it should be hancdled seperatly */
652 /* Drop packet ???? */
653 wpalPacketFree(pFrame);
654 return eWLAN_PAL_STATUS_SUCCESS;
655 }
656
657 /* AMSDU frame, but not first sub-frame
658 * No MPDU header, MPDU header offset is 0
659 * Total frame size is actual frame size + MPDU data offset */
660 if((ucMPDUHOffset < WDI_RX_BD_HEADER_SIZE) && (bASF && !bFSF)){
661 ucMPDUHOffset = usMPDUDOffset;
662 }
663
Mihir Sheteeb95ede2014-09-03 14:37:54 +0530664 if(VPKT_SIZE_BUFFER_ALIGNED < (usMPDULen+ucMPDUHOffset)){
665 WPAL_TRACE(eWLAN_MODULE_DAL_DATA, eWLAN_PAL_TRACE_LEVEL_FATAL,
666 "Invalid Frame size, might memory corrupted(%d+%d/%d)",
667 usMPDULen, ucMPDUHOffset, VPKT_SIZE_BUFFER_ALIGNED);
Madan Mohan Koyyalamudic69614b2013-08-20 19:15:47 +0530668
669 /* Size of the packet tranferred by the DMA engine is
670 * greater than the the memory allocated for the skb
671 */
672 WPAL_BUG(0);
673
Jeff Johnson295189b2012-06-20 16:38:30 -0700674 wpalPacketFree(pFrame);
675 return eWLAN_PAL_STATUS_SUCCESS;
676 }
Leela V Kiran Kumar Reddy Chirala6a458752013-02-16 15:41:27 -0800677 if(eWLAN_PAL_STATUS_SUCCESS != wpalPacketSetRxLength(pFrame, usMPDULen+ucMPDUHOffset))
678 {
679 DTI_TRACE( DTI_TRACE_LEVEL_ERROR, "Invalid Frame Length, Frame dropped..");
680 wpalPacketFree(pFrame);
681 return eWLAN_PAL_STATUS_SUCCESS;
682 }
683 if(eWLAN_PAL_STATUS_SUCCESS != wpalPacketRawTrimHead(pFrame, ucMPDUHOffset))
684 {
685 DTI_TRACE( DTI_TRACE_LEVEL_ERROR, "Failed to trim Raw Packet Head, Frame dropped..");
686 wpalPacketFree(pFrame);
687 return eWLAN_PAL_STATUS_SUCCESS;
688 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700689
690 pRxMetadata->fc = isFcBd;
691 pRxMetadata->staId = WDI_RX_BD_GET_STA_ID(pBDHeader);
692 pRxMetadata->addr3Idx = WDI_RX_BD_GET_ADDR3_IDX(pBDHeader);
693 pRxMetadata->rxChannel = WDI_RX_BD_GET_RX_CHANNEL(pBDHeader);
Kiran Kumar Lokere79540f92013-04-25 17:32:16 -0700694 pRxMetadata->rfBand = WDI_RX_BD_GET_RFBAND(pBDHeader);
Jeff Johnson295189b2012-06-20 16:38:30 -0700695 pRxMetadata->rtsf = WDI_RX_BD_GET_RTSF(pBDHeader);
696 pRxMetadata->bsf = WDI_RX_BD_GET_BSF(pBDHeader);
697 pRxMetadata->scan = WDI_RX_BD_GET_SCAN(pBDHeader);
698 pRxMetadata->dpuSig = WDI_RX_BD_GET_DPU_SIG(pBDHeader);
699 pRxMetadata->ft = WDI_RX_BD_GET_FT(pBDHeader);
700 pRxMetadata->ne = WDI_RX_BD_GET_NE(pBDHeader);
701 pRxMetadata->llcr = WDI_RX_BD_GET_LLCR(pBDHeader);
702 pRxMetadata->bcast = WDI_RX_BD_GET_UB(pBDHeader);
703 pRxMetadata->tid = ucTid;
704 pRxMetadata->dpuFeedback = WDI_RX_BD_GET_DPU_FEEDBACK(pBDHeader);
705 pRxMetadata->rateIndex = WDI_RX_BD_GET_RATEINDEX(pBDHeader);
706 pRxMetadata->rxpFlags = WDI_RX_BD_GET_RXPFLAGS(pBDHeader);
707 pRxMetadata->mclkRxTimestamp = WDI_RX_BD_GET_TIMESTAMP(pBDHeader);
Chet Lanctot186b5732013-03-18 10:26:30 -0700708#ifdef WLAN_FEATURE_11W
709 pRxMetadata->rmf = WDI_RX_BD_GET_RMF(pBDHeader);
710#endif
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -0700711#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
712 pRxMetadata->offloadScanLearn = WDI_RX_BD_GET_OFFLOADSCANLEARN(pBDHeader);
713 pRxMetadata->roamCandidateInd = WDI_RX_BD_GET_ROAMCANDIDATEIND(pBDHeader);
714#endif
Dino Mycle41bdc942014-06-10 11:30:24 +0530715#ifdef WLAN_FEATURE_EXTSCAN
716 pRxMetadata->extscanBuffer = WDI_RX_BD_GET_EXTSCANFULLSCANRESIND(pBDHeader);
717#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700718 /* typeSubtype in BD doesn't look like correct. Fill from frame ctrl
719 TL does it for Volans but TL does not know BD for Prima. WDI should do it */
720 if ( 0 == WDI_RX_BD_GET_FT(pBDHeader) ) {
721 if ( bASF ) {
722 pRxMetadata->subtype = WDI_MAC_DATA_QOS_DATA;
723 pRxMetadata->type = WDI_MAC_DATA_FRAME;
724 } else {
725 pMacFrameCtl = (tpSirMacFrameCtl)(((wpt_uint8*)pBDHeader) + ucMPDUHOffset);
726 pRxMetadata->subtype = pMacFrameCtl->subType;
727 pRxMetadata->type = pMacFrameCtl->type;
728 }
729 } else {
730 pMacFrameCtl = (tpSirMacFrameCtl)(((wpt_uint8*)pBDHeader) + WDI_RX_BD_HEADER_SIZE);
731 pRxMetadata->subtype = pMacFrameCtl->subType;
732 pRxMetadata->type = pMacFrameCtl->type;
733 }
734
735 pRxMetadata->mpduHeaderPtr = pBDHeader + ucMPDUHOffset;
736 pRxMetadata->mpduDataPtr = pBDHeader + usMPDUDOffset;
737 pRxMetadata->mpduLength = usMPDULen;
738 pRxMetadata->mpduHeaderLength = ucMPDUHLen;
739
740 /*------------------------------------------------------------------------
741 Gather AMPDU information
742 ------------------------------------------------------------------------*/
743 pRxMetadata->ampdu_reorderOpcode = (wpt_uint8)WDI_RX_BD_GET_BA_OPCODE(pBDHeader);
744 pRxMetadata->ampdu_reorderSlotIdx = (wpt_uint8)WDI_RX_BD_GET_BA_SI(pBDHeader);
745 pRxMetadata->ampdu_reorderFwdIdx = (wpt_uint8)WDI_RX_BD_GET_BA_FI(pBDHeader);
Madan Mohan Koyyalamudi31e4cad2013-08-21 20:21:14 +0530746 pRxMetadata->currentPktSeqNo = (wpt_uint16)WDI_RX_BD_GET_BA_CSN(pBDHeader);
Jeff Johnson295189b2012-06-20 16:38:30 -0700747
748
749 /*------------------------------------------------------------------------
750 Gather AMSDU information
751 ------------------------------------------------------------------------*/
752 pRxMetadata->amsdu_asf = bASF;
753 pRxMetadata->amsdu_aef = bAEF;
754 pRxMetadata->amsdu_esf = bFSF;
755 pRxMetadata->amsdu_lsf = bLSF;
756 pRxMetadata->amsdu_size = WDI_RX_BD_GET_AMSDU_SIZE(pBDHeader);
757
758 pRxMetadata->rssi0 = WDI_RX_BD_GET_RSSI0(pBDHeader);
759 pRxMetadata->rssi1 = WDI_RX_BD_GET_RSSI1(pBDHeader);
760
761
762 /* Missing:
763 wpt_uint32 fcSTATxQStatus:8;
764 wpt_uint32 fcSTAThreshIndMask:8;
765 wpt_uint32 fcSTAPwrSaveStateMask:8;
766 wpt_uint32 fcSTAValidMask:8;
767
768 wpt_uint8 fcSTATxQLen[8]; // one byte per STA.
769 wpt_uint8 fcSTACurTxRate[8]; // current Tx rate for each sta.
770 unknownUcastPkt
771 */
772
773 pRxMetadata->replayCount = WDTS_GetReplayCounterFromRxBD(pBDHeader);
774 pRxMetadata->snr = WDI_RX_BD_GET_SNR(pBDHeader);
775
776 /*
777 * PAL BD pointer information needs to be populated
778 */
779 WPAL_PACKET_SET_BD_POINTER(pFrame, pBDHeader);
780 WPAL_PACKET_SET_BD_LENGTH(pFrame, sizeof(WDI_RxBdType));
781
Girish Gowli55caa852015-01-19 16:09:49 +0530782 if (((WDI_ControlBlockType *)pClientData->pcontext)->roamDelayStatsEnabled)
Mukul Sharmadc517962014-06-25 20:28:44 +0530783 {
Girish Gowli55caa852015-01-19 16:09:49 +0530784 vos_record_roam_event(e_DXE_RX_PKT_TIME, (void *)pFrame, pRxMetadata->type);
Mukul Sharmadc517962014-06-25 20:28:44 +0530785 }
Sushant Kaushik33200572015-08-05 16:46:20 +0530786 if ((WLAN_LOG_LEVEL_ACTIVE ==
787 vos_get_ring_log_level(RING_ID_PER_PACKET_STATS)) &&
Abhishek Singhb3e1e7b2015-10-12 16:23:33 +0530788 !(WDI_MAC_CTRL_FRAME == pRxMetadata->type))
Sushant Kaushik33200572015-08-05 16:46:20 +0530789 {
790 vos_mem_zero(&rxStats,sizeof(tPerPacketStats));
791 /* Peer tx packet and it is an Rx packet for us */
792 rxStats.is_rx= VOS_TRUE;
793 rxStats.tid = ucTid;
794 rxStats.rssi = (pRxMetadata->rssi0 > pRxMetadata->rssi1)?
795 pRxMetadata->rssi0 : pRxMetadata->rssi1;
796 rxStats.rate_idx = pRxMetadata->rateIndex;
797 rxStats.seq_num = pRxMetadata->currentPktSeqNo;
798 rxStats.dxe_timestamp = vos_timer_get_system_ticks();
Abhishek Singhb3e1e7b2015-10-12 16:23:33 +0530799 rxStats.data_len =
800 vos_copy_80211_data(pFrame, rxStats.data, pRxMetadata->type);
Sushant Kaushik33200572015-08-05 16:46:20 +0530801 wpalPerPktSerialize(&rxStats);
802 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700803 // Invoke Rx complete callback
804 pClientData->receiveFrameCB(pClientData->pCallbackContext, pFrame);
805 }
806 else
807 {
808 wpalPacketSetRxLength(pFrame, usMPDULen+ucMPDUHOffset);
809 wpalPacketRawTrimHead(pFrame, ucMPDUHOffset);
810
Jeff Johnson295189b2012-06-20 16:38:30 -0700811 //flow control related
812 pRxMetadata->fc = isFcBd;
Hoonki Lee14621352013-04-16 17:51:19 -0700813 pRxMetadata->mclkRxTimestamp = WDI_RX_BD_GET_TIMESTAMP(pBDHeader);
Jeff Johnson295189b2012-06-20 16:38:30 -0700814 pRxMetadata->fcStaTxDisabledBitmap = WDI_RX_FC_BD_GET_STA_TX_DISABLED_BITMAP(pBDHeader);
815 pRxMetadata->fcSTAValidMask = WDI_RX_FC_BD_GET_STA_VALID_MASK(pBDHeader);
816 // Invoke Rx complete callback
817 pClientData->receiveFrameCB(pClientData->pCallbackContext, pFrame);
818 }
Madan Mohan Koyyalamudi01cba042013-01-10 21:56:05 -0800819
820 //Log the RX Stats
821 if(gDsTrafficStats.running && pRxMetadata->staId < HAL_NUM_STA)
822 {
823 if(pRxMetadata->rateIndex < WDTS_MAX_RATE_NUM)
824 {
Kumar Anand90ca3dd2013-01-18 15:24:47 -0800825 if(pRxMetadata->type == WDI_MAC_DATA_FRAME)
826 {
827 gDsTrafficStats.rxStats[pRxMetadata->staId][pRxMetadata->rateIndex].rxBytesRcvd +=
828 pRxMetadata->mpduLength;
829 gDsTrafficStats.rxStats[pRxMetadata->staId][pRxMetadata->rateIndex].rxPacketsRcvd++;
830 }
Madan Mohan Koyyalamudi01cba042013-01-10 21:56:05 -0800831 }
832 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700833 return eWLAN_PAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -0700834}
835
836
837
838/* DTS Out of Resource packet function.
839 * This function should be invoked by the transport device to indicate
840 * the device is out of resources.
841 * Parameters:
842 * pContext:Cookie that should be passed back to the caller
843 * priority: indicates which channel is out of resource.
844 * Return Value: SUCCESS Completed successfully.
845 * FAILURE_XXX Request was rejected due XXX Reason.
846 */
847wpt_status WDTS_OOResourceNotification(void *pContext, WDTS_ChannelType channel, wpt_boolean on)
848{
849 WDI_DS_ClientDataType *pClientData =
850 (WDI_DS_ClientDataType *) pContext;
851 static wpt_uint8 ac_mask = 0x1f;
852
853 // Do Sanity checks
854 if(NULL == pContext){
855 return eWLAN_PAL_STATUS_E_FAILURE;
856 }
857
858 if(on){
859 ac_mask |= channel == WDTS_CHANNEL_TX_LOW_PRI? 0x0f : 0x10;
860 } else {
861 ac_mask &= channel == WDTS_CHANNEL_TX_LOW_PRI? 0x10 : 0x0f;
862 }
863
864
865 // Invoke OOR callback
866 pClientData->txResourceCB(pClientData->pCallbackContext, ac_mask);
867 return eWLAN_PAL_STATUS_SUCCESS;
868
869}
870
Mihir Shete5affadc2015-05-29 20:54:57 +0530871void WDTS_LogRxDone(void *pContext)
872{
Karthick Sa6616c32015-07-22 14:49:02 +0530873 WDI_DS_LoggingSessionType *pLoggingSession;
874
875 pLoggingSession = (WDI_DS_LoggingSessionType *)
876 WDI_DS_GetLoggingSession(pContext);
877
878 if (NULL == pContext || pLoggingSession == NULL)
Mihir Shete5affadc2015-05-29 20:54:57 +0530879 {
880 return;
881 }
Karthick Sa6616c32015-07-22 14:49:02 +0530882 /* check for done and Log type Mgmt frame = 0, QXDM = 1, FW Mem dump = 2 */
883 if (pLoggingSession->done && pLoggingSession->logType <= VALID_FW_LOG_TYPES)
Hanumantha Reddy Pothulae00a7e22015-09-15 20:11:30 +0530884 vos_process_done_indication(pLoggingSession->logType,
885 pLoggingSession->reasonCode);
886
Sachin Ahujac08f72a2015-09-22 15:25:47 +0530887
888 if (pLoggingSession->logType == QXDM_LOGGING &&
889 pLoggingSession->reasonCode)
890 pLoggingSession->logType = FATAL_EVENT;
Hanumantha Reddy Pothulae00a7e22015-09-15 20:11:30 +0530891 ((WDI_DS_ClientDataType *)(pContext))->rxLogCB(pLoggingSession->logType);
Mihir Shete5affadc2015-05-29 20:54:57 +0530892
Karthick Sa6616c32015-07-22 14:49:02 +0530893 pLoggingSession->done = 0;
894 pLoggingSession->logType = 0;
Hanumantha Reddy Pothulae00a7e22015-09-15 20:11:30 +0530895 pLoggingSession->reasonCode = 0;
Mihir Shete5affadc2015-05-29 20:54:57 +0530896
Mihir Shetec4093f92015-05-28 15:21:11 +0530897 return;
898}
899
Sravan Kumar Kairam80d06ee2015-09-28 12:53:20 +0530900void WDTS_MbReceiveMsg(void *pContext)
901{
902 tpLoggingMailBox pLoggingMb;
903 WDI_DS_LoggingSessionType *pLoggingSession;
904 wpt_int8 i, noMem = 0;
905 wpt_uint32 totalLen = 0;
906
907 pLoggingMb = (tpLoggingMailBox)WDI_DS_GetLoggingMbAddr(pContext);
908 pLoggingSession = (WDI_DS_LoggingSessionType *)
909 WDI_DS_GetLoggingSession(pContext);
910
911 for(i = 0; i < MAX_NUM_OF_BUFFER; i++)
912 {
913 totalLen += pLoggingMb->logBuffLength[i];
914 // Send done indication when the logbuffer size exceeds 128KB.
915 if (totalLen > MAX_LOG_BUFFER_LENGTH || pLoggingMb->logBuffLength[i] > MAX_LOG_BUFFER_LENGTH)
916 {
917 DTI_TRACE( DTI_TRACE_LEVEL_ERROR, " %d received invalid log buffer length",
918 totalLen);
919 // Done using Mailbox, zero out the memory.
920 wpalMemoryZero(pLoggingMb, sizeof(tLoggingMailBox));
921 wpalMemoryZero(pLoggingSession, sizeof(WDI_DS_LoggingSessionType));
922 //Set Status as Failure
923 pLoggingSession->status = WDTS_LOGGING_STATUS_ERROR;
924 WDTS_LogRxDone(pContext);
925
926 return;
927 }
928 }
929
930 totalLen = 0;
931 for(i = 0; i < MAX_NUM_OF_BUFFER; i++)
932 {
933 pLoggingSession->logBuffAddress[i] = pLoggingMb->logBuffAddress[i];
934 if (!noMem)
935 {
936 pLoggingSession->logBuffLength[i] = gTransportDriver.setupLogTransfer(
937 pLoggingMb->logBuffAddress[i],
938 pLoggingMb->logBuffLength[i]);
939 }
940 else
941 {
942 pLoggingSession->logBuffLength[i] = 0;
943 continue;
944 }
945
946 totalLen += pLoggingSession->logBuffLength[i];
947
948 if (pLoggingSession->logBuffLength[i] < pLoggingMb->logBuffLength[i])
949 {
950 noMem = 1;
951 }
952 }
953
954 pLoggingSession->done = pLoggingMb->done;
955 pLoggingSession->logType = pLoggingMb->logType;
956 pLoggingSession->reasonCode = pLoggingMb->reasonCode;
957 pLoggingSession->status = WDTS_LOGGING_STATUS_SUCCESS;
958 // Done using Mailbox, zero out the memory.
959 wpalMemoryZero(pLoggingMb, sizeof(tLoggingMailBox));
960
961 if (totalLen)
962 {
963 if (gTransportDriver.startLogTransfer() == eWLAN_PAL_STATUS_SUCCESS)
964 return;
965 }
966
967 // Send Done event to upper layers, since we wont be getting any from DXE
968}
969
Jeff Johnson295189b2012-06-20 16:38:30 -0700970/* DTS open function.
971 * On open the transport device should initialize itself.
972 * Parameters:
973 * pContext:Cookie that should be passed back to the caller along
974 * with the callback.
975 *
976 * Return Value: SUCCESS Completed successfully.
977 * FAILURE_XXX Request was rejected due XXX Reason.
978 *
979 */
980wpt_status WDTS_openTransport( void *pContext)
981{
982 void *pDTDriverContext;
983 WDI_DS_ClientDataType *pClientData;
984 WDI_Status sWdiStatus = WDI_STATUS_SUCCESS;
Mihir Shetec4093f92015-05-28 15:21:11 +0530985 WDTS_ClientCallbacks WDTSCb;
Jeff Johnson295189b2012-06-20 16:38:30 -0700986
987 pClientData = (WDI_DS_ClientDataType*) wpalMemoryAllocate(sizeof(WDI_DS_ClientDataType));
988 if (!pClientData){
989 return eWLAN_PAL_STATUS_E_NOMEM;
990 }
991
992 pClientData->suspend = 0;
993 WDI_DS_AssignDatapathContext(pContext, (void*)pClientData);
994
995 pDTDriverContext = gTransportDriver.open();
996 if( NULL == pDTDriverContext )
997 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700998 DTI_TRACE( DTI_TRACE_LEVEL_ERROR, " %s fail from transport open", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700999 return eWLAN_PAL_STATUS_E_FAILURE;
1000 }
1001 WDT_AssignTransportDriverContext(pContext, pDTDriverContext);
Mihir Shetec4093f92015-05-28 15:21:11 +05301002
1003 WDTSCb.rxFrameReadyCB = WDTS_RxPacket;
1004 WDTSCb.txCompleteCB = WDTS_TxPacketComplete;
1005 WDTSCb.lowResourceCB = WDTS_OOResourceNotification;
1006 WDTSCb.receiveMbMsgCB = WDTS_MbReceiveMsg;
Mihir Shete5affadc2015-05-29 20:54:57 +05301007 WDTSCb.receiveLogCompleteCB = WDTS_LogRxDone;
Mihir Shetec4093f92015-05-28 15:21:11 +05301008 gTransportDriver.register_client(pDTDriverContext, WDTSCb, (void*)pClientData);
Jeff Johnson295189b2012-06-20 16:38:30 -07001009
1010 /* Create a memory pool for Mgmt BDheaders.*/
1011 sWdiStatus = WDI_DS_MemPoolCreate(&pClientData->mgmtMemPool, WDI_DS_MAX_CHUNK_SIZE,
1012 WDI_DS_HI_PRI_RES_NUM);
1013 if (WDI_STATUS_SUCCESS != sWdiStatus){
1014 return eWLAN_PAL_STATUS_E_NOMEM;
1015 }
1016
1017 /* Create a memory pool for Data BDheaders.*/
1018 sWdiStatus = WDI_DS_MemPoolCreate(&pClientData->dataMemPool, WDI_DS_MAX_CHUNK_SIZE,
1019 WDI_DS_LO_PRI_RES_NUM);
1020 if (WDI_STATUS_SUCCESS != sWdiStatus){
1021 return eWLAN_PAL_STATUS_E_NOMEM;
1022 }
1023
Madan Mohan Koyyalamudi01cba042013-01-10 21:56:05 -08001024 wpalMemoryZero(&gDsTrafficStats, sizeof(gDsTrafficStats));
1025
Abhishek Singh2b055852015-10-07 14:14:13 +05301026 sWdiStatus = WDI_DS_LoggingMbCreate(&pClientData->loggingMbContext, sizeof(tLoggingMailBox));
Mihir Shetecb352cd2015-05-25 10:58:59 +05301027 if (WDI_STATUS_SUCCESS != sWdiStatus)
1028 return eWLAN_PAL_STATUS_E_NOMEM;
1029
Jeff Johnson295189b2012-06-20 16:38:30 -07001030 return eWLAN_PAL_STATUS_SUCCESS;
1031
1032}
1033
1034
1035
1036/* DTS start function.
1037 * On start the transport device should start running.
1038 * Parameters:
1039 * pContext:Cookie that should be passed back to the caller along
1040 * with the callback.
1041 *
1042 * Return Value: SUCCESS Completed successfully.
1043 * FAILURE_XXX Request was rejected due XXX Reason.
1044 *
1045 */
1046wpt_status WDTS_startTransport( void *pContext)
1047{
1048 void *pDTDriverContext = WDT_GetTransportDriverContext(pContext);
1049 gTransportDriver.start(pDTDriverContext);
1050 return eWLAN_PAL_STATUS_SUCCESS;
1051
1052}
1053
1054
1055/* DTS Tx packet function.
1056 * This function should be invoked by the DAL Dataservice to schedule transmit frame through DXE/SDIO.
1057 * Parameters:
1058 * pContext:Cookie that should be passed back to the caller along with the callback.
1059 * pFrame:Refernce to PAL frame.
1060 * Return Value: SUCCESS Completed successfully.
1061 * FAILURE_XXX Request was rejected due XXX Reason.
1062 *
1063 */
1064wpt_status WDTS_TxPacket(void *pContext, wpt_packet *pFrame)
1065{
1066 void *pDTDriverContext = WDT_GetTransportDriverContext(pContext);
1067 WDI_DS_TxMetaInfoType *pTxMetadata;
1068 WDTS_ChannelType channel = WDTS_CHANNEL_TX_LOW_PRI;
1069 wpt_status status = eWLAN_PAL_STATUS_SUCCESS;
Sushant Kaushik33200572015-08-05 16:46:20 +05301070 tPerPacketStats txPktStat = {0};
Jeff Johnson295189b2012-06-20 16:38:30 -07001071
1072 // extract metadata from PAL packet
1073 pTxMetadata = WDI_DS_ExtractTxMetaData(pFrame);
Madan Mohan Koyyalamudi01cba042013-01-10 21:56:05 -08001074
1075 //Log the TX Stats
Kumar Anand90ca3dd2013-01-18 15:24:47 -08001076 if(gDsTrafficStats.running && pTxMetadata->staIdx < HAL_NUM_STA)
Madan Mohan Koyyalamudi01cba042013-01-10 21:56:05 -08001077 {
Kumar Anand90ca3dd2013-01-18 15:24:47 -08001078 if(pTxMetadata->frmType & WDI_MAC_DATA_FRAME)
1079 {
1080 gDsTrafficStats.txStats[pTxMetadata->staIdx].txBytesPushed +=
1081 pTxMetadata->fPktlen;
1082 gDsTrafficStats.txStats[pTxMetadata->staIdx].txPacketsPushed += 1;
1083 }
Madan Mohan Koyyalamudi01cba042013-01-10 21:56:05 -08001084 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001085
1086 // assign MDPU to correct channel??
1087 channel = (pTxMetadata->frmType & WDI_MAC_DATA_FRAME)?
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -07001088 /* EAPOL frame uses TX_HIGH_PRIORITY DXE channel
1089 To make sure EAPOL (for second session) is pushed even if TX_LO channel
1090 already reached to low resource condition
1091 This can happen especially in MCC, high data traffic TX in first session
1092 */
Hoonki Leee10ce392013-02-26 11:47:00 -08001093#ifdef FEATURE_WLAN_TDLS
1094 /* I utilizes TDLS mgmt frame always sent at BD_RATE2. (See limProcessTdls.c)
1095 Assumption here is data frame sent by WDA_TxPacket() <- HalTxFrame/HalTxFrameWithComplete()
1096 should take managment path. As of today, only TDLS feature has special data frame
1097 which needs to be treated as mgmt.
1098 */
1099 (((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;
1100#else
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -07001101 ((pTxMetadata->isEapol) ? WDTS_CHANNEL_TX_HIGH_PRI : WDTS_CHANNEL_TX_LOW_PRI) : WDTS_CHANNEL_TX_HIGH_PRI;
Hoonki Leee10ce392013-02-26 11:47:00 -08001102#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001103 // Send packet to Transport Driver.
1104 status = gTransportDriver.xmit(pDTDriverContext, pFrame, channel);
Sushant Kaushik33200572015-08-05 16:46:20 +05301105 if ((WLAN_LOG_LEVEL_ACTIVE ==
1106 vos_get_ring_log_level(RING_ID_PER_PACKET_STATS)) &&
Abhishek Singhb3e1e7b2015-10-12 16:23:33 +05301107 !(pTxMetadata->frmType & WDI_MAC_CTRL_FRAME)){
Sushant Kaushik33200572015-08-05 16:46:20 +05301108
1109 vos_mem_zero(&txPktStat,sizeof(tPerPacketStats));
1110 txPktStat.tid = pTxMetadata->fUP;
1111 txPktStat.dxe_timestamp = vos_timer_get_system_ticks();
1112 /*HW limitation cant get the seq number*/
1113 txPktStat.seq_num = 0;
1114 txPktStat.data_len =
Abhishek Singhb3e1e7b2015-10-12 16:23:33 +05301115 vos_copy_80211_data((void *)pFrame, txPktStat.data,
1116 pTxMetadata->frmType);
Sushant Kaushik33200572015-08-05 16:46:20 +05301117 wpalPerPktSerialize(&txPktStat);
1118 }
Girish Gowli55caa852015-01-19 16:09:49 +05301119 if (((WDI_ControlBlockType *)pContext)->roamDelayStatsEnabled)
1120 {
1121 vos_record_roam_event(e_DXE_FIRST_XMIT_TIME, (void *)pFrame, pTxMetadata->frmType);
1122 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001123 return status;
1124}
1125
1126/* DTS Tx Complete function.
1127 * This function should be invoked by the DAL Dataservice to notify tx completion to DXE/SDIO.
1128 * Parameters:
1129 * pContext:Cookie that should be passed back to the caller along with the callback.
1130 * ucTxResReq:TX resource number required by TL
1131 * Return Value: SUCCESS Completed successfully.
1132 * FAILURE_XXX Request was rejected due XXX Reason.
1133 *
1134 */
1135wpt_status WDTS_CompleteTx(void *pContext, wpt_uint32 ucTxResReq)
1136{
1137 void *pDTDriverContext = WDT_GetTransportDriverContext(pContext);
1138
1139 // Notify completion to Transport Driver.
1140 return gTransportDriver.txComplete(pDTDriverContext, ucTxResReq);
1141}
1142
1143/* DXE Set power state ACK callback.
1144 * This callback function should be invoked by the DXE to notify WDI that set
1145 * power state request is complete.
1146 * Parameters:
1147 * status: status of the set operation
1148 * Return Value: None.
1149 *
1150 */
1151void WDTS_SetPowerStateCb(wpt_status status, unsigned int dxePhyAddr)
1152{
1153 //print a msg
1154 if(NULL != gSetPowerStateCbInfo.cback)
1155 {
1156 gSetPowerStateCbInfo.cback(status, dxePhyAddr, gSetPowerStateCbInfo.pUserData);
1157 }
1158}
1159
1160
1161/* DTS Set power state function.
1162 * This function should be invoked by the DAL to notify the WLAN device power state.
1163 * Parameters:
1164 * pContext:Cookie that should be passed back to the caller along with the callback.
1165 * powerState:Power state of the WLAN device.
1166 * Return Value: SUCCESS Set successfully in DXE control blk.
1167 * FAILURE_XXX Request was rejected due XXX Reason.
1168 *
1169 */
1170wpt_status WDTS_SetPowerState(void *pContext, WDTS_PowerStateType powerState,
1171 WDTS_SetPowerStateCbType cback)
1172{
1173 void *pDTDriverContext = WDT_GetTransportDriverContext(pContext);
1174 wpt_status status = eWLAN_PAL_STATUS_SUCCESS;
1175
1176 if( cback )
1177 {
1178 //save the cback & cookie
1179 gSetPowerStateCbInfo.pUserData = pContext;
1180 gSetPowerStateCbInfo.cback = cback;
1181 status = gTransportDriver.setPowerState(pDTDriverContext, powerState,
1182 WDTS_SetPowerStateCb);
1183 }
1184 else
1185 {
1186 status = gTransportDriver.setPowerState(pDTDriverContext, powerState,
1187 NULL);
1188 }
1189
1190 return status;
1191}
1192
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07001193/* DTS Transport Channel Debug
1194 * Display DXE Channel debugging information
1195 * User may request to display DXE channel snapshot
1196 * Or if host driver detects any abnormal stcuk may display
1197 * Parameters:
Jeff Johnsonb88db982012-12-10 13:34:59 -08001198 * displaySnapshot : Display DXE snapshot option
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07001199 * enableStallDetect : Enable stall detect feature
1200 This feature will take effect to data performance
1201 Not integrate till fully verification
1202 * Return Value: NONE
1203 *
1204 */
Mihir Shete40a55652014-03-02 14:14:47 +05301205void WDTS_ChannelDebug(wpt_boolean displaySnapshot, wpt_uint8 debugFlags)
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07001206{
Mihir Shete40a55652014-03-02 14:14:47 +05301207 gTransportDriver.channelDebug(displaySnapshot, debugFlags);
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07001208 return;
1209}
1210
Jeff Johnson295189b2012-06-20 16:38:30 -07001211/* DTS Stop function.
1212 * Stop Transport driver, ie DXE, SDIO
1213 * Parameters:
1214 * pContext:Cookie that should be passed back to the caller along with the callback.
1215 * Return Value: SUCCESS Completed successfully.
1216 * FAILURE_XXX Request was rejected due XXX Reason.
1217 *
1218 */
1219wpt_status WDTS_Stop(void *pContext)
1220{
1221 void *pDTDriverContext = WDT_GetTransportDriverContext(pContext);
1222 wpt_status status = eWLAN_PAL_STATUS_SUCCESS;
1223
1224 status = gTransportDriver.stop(pDTDriverContext);
1225
Madan Mohan Koyyalamudi01cba042013-01-10 21:56:05 -08001226 wpalMemoryZero(&gDsTrafficStats, sizeof(gDsTrafficStats));
1227
Jeff Johnson295189b2012-06-20 16:38:30 -07001228 return status;
1229}
1230
1231/* DTS Stop function.
1232 * Stop Transport driver, ie DXE, SDIO
1233 * Parameters:
1234 * pContext:Cookie that should be passed back to the caller along with the callback.
1235 * Return Value: SUCCESS Completed successfully.
1236 * FAILURE_XXX Request was rejected due XXX Reason.
1237 *
1238 */
1239wpt_status WDTS_Close(void *pContext)
1240{
1241 void *pDTDriverContext = WDT_GetTransportDriverContext(pContext);
1242 WDI_DS_ClientDataType *pClientData = WDI_DS_GetDatapathContext(pContext);
1243 wpt_status status = eWLAN_PAL_STATUS_SUCCESS;
1244
1245 /*Destroy the mem pool for mgmt BD headers*/
1246 WDI_DS_MemPoolDestroy(&pClientData->mgmtMemPool);
1247
1248 /*Destroy the mem pool for mgmt BD headers*/
1249 WDI_DS_MemPoolDestroy(&pClientData->dataMemPool);
Mihir Shetecb352cd2015-05-25 10:58:59 +05301250
1251 WDI_DS_LoggingMbDestroy(&pClientData->loggingMbContext);
1252
Jeff Johnson295189b2012-06-20 16:38:30 -07001253 status = gTransportDriver.close(pDTDriverContext);
1254
1255 wpalMemoryFree(pClientData);
1256
1257 return status;
1258}
1259
1260/* Get free TX data descriptor number from DXE
1261 * Parameters:
1262 * pContext: Cookie that should be passed back to the caller along with the callback.
1263 * Return Value: number of free descriptors for TX data channel
1264 *
1265 */
1266wpt_uint32 WDTS_GetFreeTxDataResNumber(void *pContext)
1267{
1268 return
1269 gTransportDriver.getFreeTxDataResNumber(WDT_GetTransportDriverContext(pContext));
1270}