blob: 18328049b85858209c21fbeb37c3d72b0b139cb6 [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Kiet Lam1ed83fc2014-02-19 01:15:45 -08002 * Copyright (c) 2012-2013 The Linux Foundation. All rights reserved.
3 *
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)) &&
788 !(WDI_MAC_CTRL_FRAME == pRxMetadata->type) &&
789 !((WDI_MAC_MGMT_FRAME== pRxMetadata->type) &&
790 ((WDI_MAC_MGMT_BEACON == (pRxMetadata->subtype)) ||
791 (WDI_MAC_MGMT_PROBE_REQ == (pRxMetadata->subtype)) ||
792 (WDI_MAC_MGMT_PROBE_RSP == (pRxMetadata->subtype)))))
793 {
794 vos_mem_zero(&rxStats,sizeof(tPerPacketStats));
795 /* Peer tx packet and it is an Rx packet for us */
796 rxStats.is_rx= VOS_TRUE;
797 rxStats.tid = ucTid;
798 rxStats.rssi = (pRxMetadata->rssi0 > pRxMetadata->rssi1)?
799 pRxMetadata->rssi0 : pRxMetadata->rssi1;
800 rxStats.rate_idx = pRxMetadata->rateIndex;
801 rxStats.seq_num = pRxMetadata->currentPktSeqNo;
802 rxStats.dxe_timestamp = vos_timer_get_system_ticks();
803 rxStats.data_len = ucMPDUHLen;
804 if(WDI_MAC_DATA_FRAME== pRxMetadata->type)
805 rxStats.data_len += WDI_MAC_LLC_HEADER_SIZE;
806 vos_mem_copy(rxStats.data,pRxMetadata->mpduHeaderPtr,rxStats.data_len);
807
808 wpalPerPktSerialize(&rxStats);
809 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700810 // Invoke Rx complete callback
811 pClientData->receiveFrameCB(pClientData->pCallbackContext, pFrame);
812 }
813 else
814 {
815 wpalPacketSetRxLength(pFrame, usMPDULen+ucMPDUHOffset);
816 wpalPacketRawTrimHead(pFrame, ucMPDUHOffset);
817
Jeff Johnson295189b2012-06-20 16:38:30 -0700818 //flow control related
819 pRxMetadata->fc = isFcBd;
Hoonki Lee14621352013-04-16 17:51:19 -0700820 pRxMetadata->mclkRxTimestamp = WDI_RX_BD_GET_TIMESTAMP(pBDHeader);
Jeff Johnson295189b2012-06-20 16:38:30 -0700821 pRxMetadata->fcStaTxDisabledBitmap = WDI_RX_FC_BD_GET_STA_TX_DISABLED_BITMAP(pBDHeader);
822 pRxMetadata->fcSTAValidMask = WDI_RX_FC_BD_GET_STA_VALID_MASK(pBDHeader);
823 // Invoke Rx complete callback
824 pClientData->receiveFrameCB(pClientData->pCallbackContext, pFrame);
825 }
Madan Mohan Koyyalamudi01cba042013-01-10 21:56:05 -0800826
827 //Log the RX Stats
828 if(gDsTrafficStats.running && pRxMetadata->staId < HAL_NUM_STA)
829 {
830 if(pRxMetadata->rateIndex < WDTS_MAX_RATE_NUM)
831 {
Kumar Anand90ca3dd2013-01-18 15:24:47 -0800832 if(pRxMetadata->type == WDI_MAC_DATA_FRAME)
833 {
834 gDsTrafficStats.rxStats[pRxMetadata->staId][pRxMetadata->rateIndex].rxBytesRcvd +=
835 pRxMetadata->mpduLength;
836 gDsTrafficStats.rxStats[pRxMetadata->staId][pRxMetadata->rateIndex].rxPacketsRcvd++;
837 }
Madan Mohan Koyyalamudi01cba042013-01-10 21:56:05 -0800838 }
839 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700840 return eWLAN_PAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -0700841}
842
843
844
845/* DTS Out of Resource packet function.
846 * This function should be invoked by the transport device to indicate
847 * the device is out of resources.
848 * Parameters:
849 * pContext:Cookie that should be passed back to the caller
850 * priority: indicates which channel is out of resource.
851 * Return Value: SUCCESS Completed successfully.
852 * FAILURE_XXX Request was rejected due XXX Reason.
853 */
854wpt_status WDTS_OOResourceNotification(void *pContext, WDTS_ChannelType channel, wpt_boolean on)
855{
856 WDI_DS_ClientDataType *pClientData =
857 (WDI_DS_ClientDataType *) pContext;
858 static wpt_uint8 ac_mask = 0x1f;
859
860 // Do Sanity checks
861 if(NULL == pContext){
862 return eWLAN_PAL_STATUS_E_FAILURE;
863 }
864
865 if(on){
866 ac_mask |= channel == WDTS_CHANNEL_TX_LOW_PRI? 0x0f : 0x10;
867 } else {
868 ac_mask &= channel == WDTS_CHANNEL_TX_LOW_PRI? 0x10 : 0x0f;
869 }
870
871
872 // Invoke OOR callback
873 pClientData->txResourceCB(pClientData->pCallbackContext, ac_mask);
874 return eWLAN_PAL_STATUS_SUCCESS;
875
876}
877
Mihir Shetec4093f92015-05-28 15:21:11 +0530878void WDTS_MbReceiveMsg(void *pContext)
879{
Mihir Shete5affadc2015-05-29 20:54:57 +0530880 tpLoggingMailBox pLoggingMb;
881 WDI_DS_LoggingSessionType *pLoggingSession;
882 wpt_int8 i, noMem = 0;
883 wpt_uint32 totalLen = 0;
884
885 pLoggingMb = (tpLoggingMailBox)WDI_DS_GetLoggingMbAddr(pContext);
886 pLoggingSession = (WDI_DS_LoggingSessionType *)
887 WDI_DS_GetLoggingSession(pContext);
888
889 for(i = 0; i < MAX_NUM_OF_BUFFER; i++)
890 {
891 pLoggingSession->logBuffAddress[i] = pLoggingMb->logBuffAddress[i];
Karthick Sed59a282015-08-10 14:52:16 +0530892 if (!noMem && (pLoggingMb->logBuffLength[i] <= MAX_LOG_BUFFER_LENGTH))
Mihir Shete5affadc2015-05-29 20:54:57 +0530893 {
894 pLoggingSession->logBuffLength[i] = gTransportDriver.setupLogTransfer(
895 pLoggingMb->logBuffAddress[i],
896 pLoggingMb->logBuffLength[i]);
897 }
898 else
899 {
900 pLoggingSession->logBuffLength[i] = 0;
901 continue;
902 }
903
904 totalLen += pLoggingSession->logBuffLength[i];
905
906 if (pLoggingSession->logBuffLength[i] < pLoggingMb->logBuffLength[i])
907 {
908 noMem = 1;
909 }
910 }
911
Karthick Sa6616c32015-07-22 14:49:02 +0530912 pLoggingSession->done = pLoggingMb->done;
913 pLoggingSession->logType = pLoggingMb->logType;
Hanumantha Reddy Pothulae00a7e22015-09-15 20:11:30 +0530914 pLoggingSession->reasonCode = pLoggingMb->reasonCode;
Mihir Shete0b090bf2015-06-09 14:00:44 +0530915 // Done using Mailbox, zero out the memory.
916 wpalMemoryZero(pLoggingMb, sizeof(tLoggingMailBox));
917
Mihir Shete5affadc2015-05-29 20:54:57 +0530918 if (totalLen)
919 {
920 if (gTransportDriver.startLogTransfer() == eWLAN_PAL_STATUS_SUCCESS)
921 return;
922 }
923
924 // Send Done event to upper layers, since we wont be getting any from DXE
925}
926
927void WDTS_LogRxDone(void *pContext)
928{
Karthick Sa6616c32015-07-22 14:49:02 +0530929 WDI_DS_LoggingSessionType *pLoggingSession;
930
931 pLoggingSession = (WDI_DS_LoggingSessionType *)
932 WDI_DS_GetLoggingSession(pContext);
933
934 if (NULL == pContext || pLoggingSession == NULL)
Mihir Shete5affadc2015-05-29 20:54:57 +0530935 {
936 return;
937 }
Karthick Sa6616c32015-07-22 14:49:02 +0530938 /* check for done and Log type Mgmt frame = 0, QXDM = 1, FW Mem dump = 2 */
939 if (pLoggingSession->done && pLoggingSession->logType <= VALID_FW_LOG_TYPES)
Hanumantha Reddy Pothulae00a7e22015-09-15 20:11:30 +0530940 vos_process_done_indication(pLoggingSession->logType,
941 pLoggingSession->reasonCode);
942
Sachin Ahujac08f72a2015-09-22 15:25:47 +0530943
944 if (pLoggingSession->logType == QXDM_LOGGING &&
945 pLoggingSession->reasonCode)
946 pLoggingSession->logType = FATAL_EVENT;
Hanumantha Reddy Pothulae00a7e22015-09-15 20:11:30 +0530947 ((WDI_DS_ClientDataType *)(pContext))->rxLogCB(pLoggingSession->logType);
Mihir Shete5affadc2015-05-29 20:54:57 +0530948
Karthick Sa6616c32015-07-22 14:49:02 +0530949 pLoggingSession->done = 0;
950 pLoggingSession->logType = 0;
Hanumantha Reddy Pothulae00a7e22015-09-15 20:11:30 +0530951 pLoggingSession->reasonCode = 0;
Mihir Shete5affadc2015-05-29 20:54:57 +0530952
Mihir Shetec4093f92015-05-28 15:21:11 +0530953 return;
954}
955
Jeff Johnson295189b2012-06-20 16:38:30 -0700956/* DTS open function.
957 * On open the transport device should initialize itself.
958 * Parameters:
959 * pContext:Cookie that should be passed back to the caller along
960 * with the callback.
961 *
962 * Return Value: SUCCESS Completed successfully.
963 * FAILURE_XXX Request was rejected due XXX Reason.
964 *
965 */
966wpt_status WDTS_openTransport( void *pContext)
967{
968 void *pDTDriverContext;
969 WDI_DS_ClientDataType *pClientData;
970 WDI_Status sWdiStatus = WDI_STATUS_SUCCESS;
Mihir Shetec4093f92015-05-28 15:21:11 +0530971 WDTS_ClientCallbacks WDTSCb;
Jeff Johnson295189b2012-06-20 16:38:30 -0700972
973 pClientData = (WDI_DS_ClientDataType*) wpalMemoryAllocate(sizeof(WDI_DS_ClientDataType));
974 if (!pClientData){
975 return eWLAN_PAL_STATUS_E_NOMEM;
976 }
977
978 pClientData->suspend = 0;
979 WDI_DS_AssignDatapathContext(pContext, (void*)pClientData);
980
981 pDTDriverContext = gTransportDriver.open();
982 if( NULL == pDTDriverContext )
983 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700984 DTI_TRACE( DTI_TRACE_LEVEL_ERROR, " %s fail from transport open", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700985 return eWLAN_PAL_STATUS_E_FAILURE;
986 }
987 WDT_AssignTransportDriverContext(pContext, pDTDriverContext);
Mihir Shetec4093f92015-05-28 15:21:11 +0530988
989 WDTSCb.rxFrameReadyCB = WDTS_RxPacket;
990 WDTSCb.txCompleteCB = WDTS_TxPacketComplete;
991 WDTSCb.lowResourceCB = WDTS_OOResourceNotification;
992 WDTSCb.receiveMbMsgCB = WDTS_MbReceiveMsg;
Mihir Shete5affadc2015-05-29 20:54:57 +0530993 WDTSCb.receiveLogCompleteCB = WDTS_LogRxDone;
Mihir Shetec4093f92015-05-28 15:21:11 +0530994 gTransportDriver.register_client(pDTDriverContext, WDTSCb, (void*)pClientData);
Jeff Johnson295189b2012-06-20 16:38:30 -0700995
996 /* Create a memory pool for Mgmt BDheaders.*/
997 sWdiStatus = WDI_DS_MemPoolCreate(&pClientData->mgmtMemPool, WDI_DS_MAX_CHUNK_SIZE,
998 WDI_DS_HI_PRI_RES_NUM);
999 if (WDI_STATUS_SUCCESS != sWdiStatus){
1000 return eWLAN_PAL_STATUS_E_NOMEM;
1001 }
1002
1003 /* Create a memory pool for Data BDheaders.*/
1004 sWdiStatus = WDI_DS_MemPoolCreate(&pClientData->dataMemPool, WDI_DS_MAX_CHUNK_SIZE,
1005 WDI_DS_LO_PRI_RES_NUM);
1006 if (WDI_STATUS_SUCCESS != sWdiStatus){
1007 return eWLAN_PAL_STATUS_E_NOMEM;
1008 }
1009
Madan Mohan Koyyalamudi01cba042013-01-10 21:56:05 -08001010 wpalMemoryZero(&gDsTrafficStats, sizeof(gDsTrafficStats));
1011
Mihir Shetecb352cd2015-05-25 10:58:59 +05301012 WDI_DS_LoggingMbCreate(&pClientData->loggingMbContext, sizeof(tLoggingMailBox));
1013 if (WDI_STATUS_SUCCESS != sWdiStatus)
1014 return eWLAN_PAL_STATUS_E_NOMEM;
1015
Jeff Johnson295189b2012-06-20 16:38:30 -07001016 return eWLAN_PAL_STATUS_SUCCESS;
1017
1018}
1019
1020
1021
1022/* DTS start function.
1023 * On start the transport device should start running.
1024 * Parameters:
1025 * pContext:Cookie that should be passed back to the caller along
1026 * with the callback.
1027 *
1028 * Return Value: SUCCESS Completed successfully.
1029 * FAILURE_XXX Request was rejected due XXX Reason.
1030 *
1031 */
1032wpt_status WDTS_startTransport( void *pContext)
1033{
1034 void *pDTDriverContext = WDT_GetTransportDriverContext(pContext);
1035 gTransportDriver.start(pDTDriverContext);
1036 return eWLAN_PAL_STATUS_SUCCESS;
1037
1038}
1039
1040
1041/* DTS Tx packet function.
1042 * This function should be invoked by the DAL Dataservice to schedule transmit frame through DXE/SDIO.
1043 * Parameters:
1044 * pContext:Cookie that should be passed back to the caller along with the callback.
1045 * pFrame:Refernce to PAL frame.
1046 * Return Value: SUCCESS Completed successfully.
1047 * FAILURE_XXX Request was rejected due XXX Reason.
1048 *
1049 */
1050wpt_status WDTS_TxPacket(void *pContext, wpt_packet *pFrame)
1051{
1052 void *pDTDriverContext = WDT_GetTransportDriverContext(pContext);
1053 WDI_DS_TxMetaInfoType *pTxMetadata;
1054 WDTS_ChannelType channel = WDTS_CHANNEL_TX_LOW_PRI;
1055 wpt_status status = eWLAN_PAL_STATUS_SUCCESS;
Sushant Kaushik33200572015-08-05 16:46:20 +05301056 tPerPacketStats txPktStat = {0};
Jeff Johnson295189b2012-06-20 16:38:30 -07001057
1058 // extract metadata from PAL packet
1059 pTxMetadata = WDI_DS_ExtractTxMetaData(pFrame);
Madan Mohan Koyyalamudi01cba042013-01-10 21:56:05 -08001060
1061 //Log the TX Stats
Kumar Anand90ca3dd2013-01-18 15:24:47 -08001062 if(gDsTrafficStats.running && pTxMetadata->staIdx < HAL_NUM_STA)
Madan Mohan Koyyalamudi01cba042013-01-10 21:56:05 -08001063 {
Kumar Anand90ca3dd2013-01-18 15:24:47 -08001064 if(pTxMetadata->frmType & WDI_MAC_DATA_FRAME)
1065 {
1066 gDsTrafficStats.txStats[pTxMetadata->staIdx].txBytesPushed +=
1067 pTxMetadata->fPktlen;
1068 gDsTrafficStats.txStats[pTxMetadata->staIdx].txPacketsPushed += 1;
1069 }
Madan Mohan Koyyalamudi01cba042013-01-10 21:56:05 -08001070 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001071
1072 // assign MDPU to correct channel??
1073 channel = (pTxMetadata->frmType & WDI_MAC_DATA_FRAME)?
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -07001074 /* EAPOL frame uses TX_HIGH_PRIORITY DXE channel
1075 To make sure EAPOL (for second session) is pushed even if TX_LO channel
1076 already reached to low resource condition
1077 This can happen especially in MCC, high data traffic TX in first session
1078 */
Hoonki Leee10ce392013-02-26 11:47:00 -08001079#ifdef FEATURE_WLAN_TDLS
1080 /* I utilizes TDLS mgmt frame always sent at BD_RATE2. (See limProcessTdls.c)
1081 Assumption here is data frame sent by WDA_TxPacket() <- HalTxFrame/HalTxFrameWithComplete()
1082 should take managment path. As of today, only TDLS feature has special data frame
1083 which needs to be treated as mgmt.
1084 */
1085 (((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;
1086#else
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -07001087 ((pTxMetadata->isEapol) ? WDTS_CHANNEL_TX_HIGH_PRI : WDTS_CHANNEL_TX_LOW_PRI) : WDTS_CHANNEL_TX_HIGH_PRI;
Hoonki Leee10ce392013-02-26 11:47:00 -08001088#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001089 // Send packet to Transport Driver.
1090 status = gTransportDriver.xmit(pDTDriverContext, pFrame, channel);
Sushant Kaushik33200572015-08-05 16:46:20 +05301091 if ((WLAN_LOG_LEVEL_ACTIVE ==
1092 vos_get_ring_log_level(RING_ID_PER_PACKET_STATS)) &&
1093 !(pTxMetadata->frmType & WDI_MAC_CTRL_FRAME) &&
1094 !((WDI_MAC_MGMT_FRAME== pTxMetadata->frmType) &&
1095 ((WDI_MAC_MGMT_BEACON == (pTxMetadata->typeSubtype & 0x0F)) ||
1096 (WDI_MAC_MGMT_PROBE_REQ == (pTxMetadata->typeSubtype & 0x0F)) ||
1097 (WDI_MAC_MGMT_PROBE_RSP == (pTxMetadata->typeSubtype & 0x0F))))){
1098
1099 vos_mem_zero(&txPktStat,sizeof(tPerPacketStats));
1100 txPktStat.tid = pTxMetadata->fUP;
1101 txPktStat.dxe_timestamp = vos_timer_get_system_ticks();
1102 /*HW limitation cant get the seq number*/
1103 txPktStat.seq_num = 0;
1104 txPktStat.data_len =
1105 vos_copy_80211_header((void *)pFrame, txPktStat.data,
1106 pTxMetadata->frmType, pTxMetadata->qosEnabled);
1107 wpalPerPktSerialize(&txPktStat);
1108 }
Girish Gowli55caa852015-01-19 16:09:49 +05301109 if (((WDI_ControlBlockType *)pContext)->roamDelayStatsEnabled)
1110 {
1111 vos_record_roam_event(e_DXE_FIRST_XMIT_TIME, (void *)pFrame, pTxMetadata->frmType);
1112 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001113 return status;
1114}
1115
1116/* DTS Tx Complete function.
1117 * This function should be invoked by the DAL Dataservice to notify tx completion to DXE/SDIO.
1118 * Parameters:
1119 * pContext:Cookie that should be passed back to the caller along with the callback.
1120 * ucTxResReq:TX resource number required by TL
1121 * Return Value: SUCCESS Completed successfully.
1122 * FAILURE_XXX Request was rejected due XXX Reason.
1123 *
1124 */
1125wpt_status WDTS_CompleteTx(void *pContext, wpt_uint32 ucTxResReq)
1126{
1127 void *pDTDriverContext = WDT_GetTransportDriverContext(pContext);
1128
1129 // Notify completion to Transport Driver.
1130 return gTransportDriver.txComplete(pDTDriverContext, ucTxResReq);
1131}
1132
1133/* DXE Set power state ACK callback.
1134 * This callback function should be invoked by the DXE to notify WDI that set
1135 * power state request is complete.
1136 * Parameters:
1137 * status: status of the set operation
1138 * Return Value: None.
1139 *
1140 */
1141void WDTS_SetPowerStateCb(wpt_status status, unsigned int dxePhyAddr)
1142{
1143 //print a msg
1144 if(NULL != gSetPowerStateCbInfo.cback)
1145 {
1146 gSetPowerStateCbInfo.cback(status, dxePhyAddr, gSetPowerStateCbInfo.pUserData);
1147 }
1148}
1149
1150
1151/* DTS Set power state function.
1152 * This function should be invoked by the DAL to notify the WLAN device power state.
1153 * Parameters:
1154 * pContext:Cookie that should be passed back to the caller along with the callback.
1155 * powerState:Power state of the WLAN device.
1156 * Return Value: SUCCESS Set successfully in DXE control blk.
1157 * FAILURE_XXX Request was rejected due XXX Reason.
1158 *
1159 */
1160wpt_status WDTS_SetPowerState(void *pContext, WDTS_PowerStateType powerState,
1161 WDTS_SetPowerStateCbType cback)
1162{
1163 void *pDTDriverContext = WDT_GetTransportDriverContext(pContext);
1164 wpt_status status = eWLAN_PAL_STATUS_SUCCESS;
1165
1166 if( cback )
1167 {
1168 //save the cback & cookie
1169 gSetPowerStateCbInfo.pUserData = pContext;
1170 gSetPowerStateCbInfo.cback = cback;
1171 status = gTransportDriver.setPowerState(pDTDriverContext, powerState,
1172 WDTS_SetPowerStateCb);
1173 }
1174 else
1175 {
1176 status = gTransportDriver.setPowerState(pDTDriverContext, powerState,
1177 NULL);
1178 }
1179
1180 return status;
1181}
1182
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07001183/* DTS Transport Channel Debug
1184 * Display DXE Channel debugging information
1185 * User may request to display DXE channel snapshot
1186 * Or if host driver detects any abnormal stcuk may display
1187 * Parameters:
Jeff Johnsonb88db982012-12-10 13:34:59 -08001188 * displaySnapshot : Display DXE snapshot option
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07001189 * enableStallDetect : Enable stall detect feature
1190 This feature will take effect to data performance
1191 Not integrate till fully verification
1192 * Return Value: NONE
1193 *
1194 */
Mihir Shete40a55652014-03-02 14:14:47 +05301195void WDTS_ChannelDebug(wpt_boolean displaySnapshot, wpt_uint8 debugFlags)
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07001196{
Mihir Shete40a55652014-03-02 14:14:47 +05301197 gTransportDriver.channelDebug(displaySnapshot, debugFlags);
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07001198 return;
1199}
1200
Jeff Johnson295189b2012-06-20 16:38:30 -07001201/* DTS Stop function.
1202 * Stop Transport driver, ie DXE, SDIO
1203 * Parameters:
1204 * pContext:Cookie that should be passed back to the caller along with the callback.
1205 * Return Value: SUCCESS Completed successfully.
1206 * FAILURE_XXX Request was rejected due XXX Reason.
1207 *
1208 */
1209wpt_status WDTS_Stop(void *pContext)
1210{
1211 void *pDTDriverContext = WDT_GetTransportDriverContext(pContext);
1212 wpt_status status = eWLAN_PAL_STATUS_SUCCESS;
1213
1214 status = gTransportDriver.stop(pDTDriverContext);
1215
Madan Mohan Koyyalamudi01cba042013-01-10 21:56:05 -08001216 wpalMemoryZero(&gDsTrafficStats, sizeof(gDsTrafficStats));
1217
Jeff Johnson295189b2012-06-20 16:38:30 -07001218 return status;
1219}
1220
1221/* DTS Stop function.
1222 * Stop Transport driver, ie DXE, SDIO
1223 * Parameters:
1224 * pContext:Cookie that should be passed back to the caller along with the callback.
1225 * Return Value: SUCCESS Completed successfully.
1226 * FAILURE_XXX Request was rejected due XXX Reason.
1227 *
1228 */
1229wpt_status WDTS_Close(void *pContext)
1230{
1231 void *pDTDriverContext = WDT_GetTransportDriverContext(pContext);
1232 WDI_DS_ClientDataType *pClientData = WDI_DS_GetDatapathContext(pContext);
1233 wpt_status status = eWLAN_PAL_STATUS_SUCCESS;
1234
1235 /*Destroy the mem pool for mgmt BD headers*/
1236 WDI_DS_MemPoolDestroy(&pClientData->mgmtMemPool);
1237
1238 /*Destroy the mem pool for mgmt BD headers*/
1239 WDI_DS_MemPoolDestroy(&pClientData->dataMemPool);
Mihir Shetecb352cd2015-05-25 10:58:59 +05301240
1241 WDI_DS_LoggingMbDestroy(&pClientData->loggingMbContext);
1242
Jeff Johnson295189b2012-06-20 16:38:30 -07001243 status = gTransportDriver.close(pDTDriverContext);
1244
1245 wpalMemoryFree(pClientData);
1246
1247 return status;
1248}
1249
1250/* Get free TX data descriptor number from DXE
1251 * Parameters:
1252 * pContext: Cookie that should be passed back to the caller along with the callback.
1253 * Return Value: number of free descriptors for TX data channel
1254 *
1255 */
1256wpt_uint32 WDTS_GetFreeTxDataResNumber(void *pContext)
1257{
1258 return
1259 gTransportDriver.getFreeTxDataResNumber(WDT_GetTransportDriverContext(pContext));
1260}